From 7a62f8dc50516d0e14f4bdefc01cbb3a8c9fad7d Mon Sep 17 00:00:00 2001 From: Dmitriy Shabanov Date: Wed, 30 Apr 2014 13:53:46 +0400 Subject: [PATCH 1/5] Change API to allow construction try ( Transaction tx = broker.beginTx() ) { // operations on database tx.success(); } --- src/org/exist/Transaction.java | 33 +++++++++++++++++++ src/org/exist/storage/DBBroker.java | 10 ++++-- .../exist/storage/txn/TransactionManager.java | 2 +- src/org/exist/storage/txn/Txn.java | 27 ++++++++++++--- src/template_java.txt | 2 +- 5 files changed, 64 insertions(+), 10 deletions(-) create mode 100644 src/org/exist/Transaction.java diff --git a/src/org/exist/Transaction.java b/src/org/exist/Transaction.java new file mode 100644 index 00000000000..9f82733fc5a --- /dev/null +++ b/src/org/exist/Transaction.java @@ -0,0 +1,33 @@ +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2014 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +package org.exist; + +import org.exist.storage.txn.TransactionException; + +/** + * @author Dmitriy Shabanov + * + */ +public interface Transaction extends AutoCloseable { + + public void success() throws TransactionException; + + public void failure(); +} diff --git a/src/org/exist/storage/DBBroker.java b/src/org/exist/storage/DBBroker.java index c9a2fa214f8..f89284a53e2 100644 --- a/src/org/exist/storage/DBBroker.java +++ b/src/org/exist/storage/DBBroker.java @@ -839,7 +839,11 @@ public abstract EmbeddedXMLStreamReader newXMLStreamReader(NodeHandle node, bool public abstract void readCollectionEntry(SubCollectionEntry entry); - public void release() { - pool.release(this); - } + public void release() { + pool.release(this); + } + + public Txn beginTx() { + return getDatabase().getTransactionManager().beginTransaction(); + } } diff --git a/src/org/exist/storage/txn/TransactionManager.java b/src/org/exist/storage/txn/TransactionManager.java index 206db98232d..7dc69cb80db 100644 --- a/src/org/exist/storage/txn/TransactionManager.java +++ b/src/org/exist/storage/txn/TransactionManager.java @@ -157,7 +157,7 @@ public Txn beginTransaction() { public Txn execute() { final long txnId = nextTxnId++; LOG.debug("Starting new transaction: " + txnId); - final Txn txn = new Txn(txnId); + final Txn txn = new Txn(TransactionManager.this, txnId); try { journal.writeToLog(new TxnStart(txnId)); } catch (final TransactionException e) { diff --git a/src/org/exist/storage/txn/Txn.java b/src/org/exist/storage/txn/Txn.java index 711d5cdd066..f43e914d49b 100644 --- a/src/org/exist/storage/txn/Txn.java +++ b/src/org/exist/storage/txn/Txn.java @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.List; +import org.exist.Transaction; import org.exist.storage.lock.Lock; import org.exist.util.LockException; @@ -31,7 +32,7 @@ * @author wolf * */ -public class Txn { +public class Txn implements Transaction { public enum State { STARTED, ABORTED, COMMITTED }; @@ -44,8 +45,11 @@ public enum State { STARTED, ABORTED, COMMITTED }; private List listeners = new ArrayList(); private String originId; + + private TransactionManager tm; - public Txn(long transactionId) { + public Txn(TransactionManager tm, long transactionId) { + this.tm = tm; this.id = transactionId; this.state = State.STARTED; } @@ -54,7 +58,7 @@ public State getState() { return state; } - public void setState(State state) { + protected void setState(State state) { this.state = state; } @@ -83,14 +87,14 @@ public void registerListener(TxnListener listener) { listeners.add(listener); } - public void signalAbort() { + protected void signalAbort() { state = State.ABORTED; for (int i = 0; i < listeners.size(); i++) { listeners.get(i).abort(); } } - public void signalCommit() { + protected void signalCommit() { state = State.COMMITTED; for (int i = 0; i < listeners.size(); i++) { listeners.get(i).commit(); @@ -124,4 +128,17 @@ public String getOriginId() { public void setOriginId(String id) { originId = id; } + + public void success() throws TransactionException { + tm.commit(this); + } + + public void failure() { + tm.abort(this); + } + + @Override + public void close() { + tm.close(this); + } } \ No newline at end of file diff --git a/src/template_java.txt b/src/template_java.txt index c4c753a24ef..7ccb0954d97 100644 --- a/src/template_java.txt +++ b/src/template_java.txt @@ -1,6 +1,6 @@ /* * eXist Open Source Native XML Database - * Copyright (C) 2014 The eXist Project + * Copyright (C) 2001-2014 The eXist Project * http://exist-db.org * * This program is free software; you can redistribute it and/or From 57488337625564319421d7d8173d12e14f8905a6 Mon Sep 17 00:00:00 2001 From: Dmitriy Shabanov Date: Wed, 30 Apr 2014 13:53:46 +0400 Subject: [PATCH 2/5] Change API to allow construction try ( DBBroker broker = db.authenticate("user", "passwd") ) { // operations on database DBBroker activeBroker = db.getActiveBroker(); //broker == activeBroker } --- src/org/exist/Transaction.java | 33 +++++++++++++++++++ src/org/exist/storage/DBBroker.java | 18 +++++++--- .../exist/storage/txn/TransactionManager.java | 2 +- src/org/exist/storage/txn/Txn.java | 27 ++++++++++++--- src/template_java.txt | 2 +- 5 files changed, 71 insertions(+), 11 deletions(-) create mode 100644 src/org/exist/Transaction.java diff --git a/src/org/exist/Transaction.java b/src/org/exist/Transaction.java new file mode 100644 index 00000000000..9f82733fc5a --- /dev/null +++ b/src/org/exist/Transaction.java @@ -0,0 +1,33 @@ +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2014 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +package org.exist; + +import org.exist.storage.txn.TransactionException; + +/** + * @author Dmitriy Shabanov + * + */ +public interface Transaction extends AutoCloseable { + + public void success() throws TransactionException; + + public void failure(); +} diff --git a/src/org/exist/storage/DBBroker.java b/src/org/exist/storage/DBBroker.java index c9a2fa214f8..d686b65d55d 100644 --- a/src/org/exist/storage/DBBroker.java +++ b/src/org/exist/storage/DBBroker.java @@ -56,6 +56,7 @@ import java.util.Iterator; import java.util.List; import java.util.Observable; + import org.exist.collections.Collection.SubCollectionEntry; /** @@ -65,7 +66,7 @@ * * @author Wolfgang Meier */ -public abstract class DBBroker extends Observable { +public abstract class DBBroker extends Observable implements AutoCloseable { // Matching types public final static int MATCH_EXACT = 0; @@ -839,7 +840,16 @@ public abstract EmbeddedXMLStreamReader newXMLStreamReader(NodeHandle node, bool public abstract void readCollectionEntry(SubCollectionEntry entry); - public void release() { - pool.release(this); - } + public void close() throws Exception { + pool.release(this); + } + + @Deprecated //use close() method instead + public void release() { + pool.release(this); + } + + public Txn beginTx() { + return getDatabase().getTransactionManager().beginTransaction(); + } } diff --git a/src/org/exist/storage/txn/TransactionManager.java b/src/org/exist/storage/txn/TransactionManager.java index 206db98232d..7dc69cb80db 100644 --- a/src/org/exist/storage/txn/TransactionManager.java +++ b/src/org/exist/storage/txn/TransactionManager.java @@ -157,7 +157,7 @@ public Txn beginTransaction() { public Txn execute() { final long txnId = nextTxnId++; LOG.debug("Starting new transaction: " + txnId); - final Txn txn = new Txn(txnId); + final Txn txn = new Txn(TransactionManager.this, txnId); try { journal.writeToLog(new TxnStart(txnId)); } catch (final TransactionException e) { diff --git a/src/org/exist/storage/txn/Txn.java b/src/org/exist/storage/txn/Txn.java index 711d5cdd066..f43e914d49b 100644 --- a/src/org/exist/storage/txn/Txn.java +++ b/src/org/exist/storage/txn/Txn.java @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.List; +import org.exist.Transaction; import org.exist.storage.lock.Lock; import org.exist.util.LockException; @@ -31,7 +32,7 @@ * @author wolf * */ -public class Txn { +public class Txn implements Transaction { public enum State { STARTED, ABORTED, COMMITTED }; @@ -44,8 +45,11 @@ public enum State { STARTED, ABORTED, COMMITTED }; private List listeners = new ArrayList(); private String originId; + + private TransactionManager tm; - public Txn(long transactionId) { + public Txn(TransactionManager tm, long transactionId) { + this.tm = tm; this.id = transactionId; this.state = State.STARTED; } @@ -54,7 +58,7 @@ public State getState() { return state; } - public void setState(State state) { + protected void setState(State state) { this.state = state; } @@ -83,14 +87,14 @@ public void registerListener(TxnListener listener) { listeners.add(listener); } - public void signalAbort() { + protected void signalAbort() { state = State.ABORTED; for (int i = 0; i < listeners.size(); i++) { listeners.get(i).abort(); } } - public void signalCommit() { + protected void signalCommit() { state = State.COMMITTED; for (int i = 0; i < listeners.size(); i++) { listeners.get(i).commit(); @@ -124,4 +128,17 @@ public String getOriginId() { public void setOriginId(String id) { originId = id; } + + public void success() throws TransactionException { + tm.commit(this); + } + + public void failure() { + tm.abort(this); + } + + @Override + public void close() { + tm.close(this); + } } \ No newline at end of file diff --git a/src/template_java.txt b/src/template_java.txt index c4c753a24ef..7ccb0954d97 100644 --- a/src/template_java.txt +++ b/src/template_java.txt @@ -1,6 +1,6 @@ /* * eXist Open Source Native XML Database - * Copyright (C) 2014 The eXist Project + * Copyright (C) 2001-2014 The eXist Project * http://exist-db.org * * This program is free software; you can redistribute it and/or From 18c620af7aacdb76701c2f212d6fa3146194739d Mon Sep 17 00:00:00 2001 From: Dmitriy Shabanov Date: Wed, 30 Apr 2014 15:44:01 +0400 Subject: [PATCH 3/5] Revert "Merge branch 'develop' of https://github.com/shabanovd/exist into" This reverts commit 46013f7134dbeaf9f2142109ce0447c13192cc41, reversing changes made to 57488337625564319421d7d8173d12e14f8905a6. --- backup.properties | 36 +- bin/backup.bat | 128 +- bin/client.bat | 114 +- bin/run.bat | 120 +- bin/server.bat | 116 +- bin/shutdown.bat | 110 +- bin/startup.bat | 120 +- build.properties | 158 +- build.xml | 70 +- build/scripts/demoserver.xml | 592 +- build/scripts/dist-war-conf.xsl | 52 +- build/scripts/dist-war-log4j.xsl | 42 +- build/scripts/dist.xml | 660 +- build/scripts/installer.xml | 440 +- build/scripts/jarsigner.xml | 346 +- build/scripts/quality.xml | 248 +- build/scripts/soap.xml | 228 +- client.properties.tmpl | 108 +- descriptor.xml.tmpl | 140 +- .../betterform/main/etc/MergeWebXML.xsl | 318 +- .../org/exist/fluent/AttributeBuilder.java | 302 +- .../src/org/exist/fluent/DataUtils.java | 238 +- .../fluent/src/org/exist/fluent/Database.java | 1312 +-- .../org/exist/fluent/DatabaseException.java | 58 +- .../fluent/src/org/exist/fluent/Document.java | 764 +- .../src/org/exist/fluent/ElementBuilder.java | 640 +- .../fluent/src/org/exist/fluent/Folder.java | 2424 ++--- .../fluent/src/org/exist/fluent/Item.java | 666 +- .../fluent/src/org/exist/fluent/ItemList.java | 818 +- .../fluent/src/org/exist/fluent/Listener.java | 134 +- .../fluent/src/org/exist/fluent/Name.java | 472 +- .../src/org/exist/fluent/NamedResource.java | 532 +- .../src/org/exist/fluent/NamespaceMap.java | 442 +- .../fluent/src/org/exist/fluent/QName.java | 312 +- .../src/org/exist/fluent/QueryService.java | 1674 ++-- .../fluent/src/org/exist/fluent/Resource.java | 154 +- .../fluent/src/org/exist/fluent/Source.java | 848 +- .../src/org/exist/fluent/StaleMarker.java | 46 +- .../src/org/exist/fluent/Transaction.java | 174 +- .../exist/fluent/WeakMultiValueHashMap.java | 242 +- .../src/org/exist/fluent/XMLDocument.java | 268 +- .../fluent/src/org/exist/fluent/package.html | 250 +- .../org/exist/fluent/DatabaseTestCase.java | 168 +- .../src/org/exist/fluent/DocumentTest.java | 140 +- .../src/org/exist/fluent/MetadataTest.java | 238 +- .../exist/http/servlets/ScaleImageJAI.java | 914 +- .../src/xquery/lucene/FT_AttTest_complex.xml | 590 +- .../LuceneFT+range_indexRetrievalTest.xml | 380 +- .../src/xquery/lucene/indirectQueriesTest.xml | 876 +- .../test/src/xquery/lucene/startOffset.xml | 326 +- .../org/exist/indexing/ngram/NGramIndex.java | 240 +- .../indexing/ngram/NGramIndexConfig.java | 128 +- .../indexing/ngram/NGramIndexWorker.java | 2236 ++--- .../xquery/modules/ngram/NGramModule.java | 150 +- .../xquery/modules/ngram/NGramSearch.java | 1252 +-- .../exist/indexing/ngram/AllIndexTests.java | 24 +- .../exist/indexing/ngram/CustomIndexTest.java | 1468 +-- .../indexing/ngram/MatchListenerTest.java | 1460 +-- extensions/indexes/spatial/hsql.bat | 4 +- .../spatial/AbstractGMLJDBCIndex.java | 412 +- .../spatial/AbstractGMLJDBCIndexWorker.java | 1696 ++-- .../exist/indexing/spatial/GMLHSQLIndex.java | 602 +- .../indexing/spatial/GMLHSQLIndexWorker.java | 1540 ++-- .../indexing/spatial/GMLIndexConfig.java | 108 +- .../spatial/SpatialIndexException.java | 74 +- .../modules/spatial/FunGMLProducers.java | 870 +- .../spatial/FunGeometricProperties.java | 812 +- .../modules/spatial/FunSpatialSearch.java | 350 +- .../xquery/modules/spatial/SpatialModule.java | 222 +- .../indexing/spatial/AllSpatialTests.java | 68 +- .../exist/indexing/spatial/GMLIndexTest.java | 2208 ++--- extensions/metadata/interface/pom.xml | 12 +- .../exist/storage/md/CollectionEvents.java | 306 +- .../org/exist/storage/md/DocumentEvents.java | 246 +- .../exist/storage/md/MDStorageManager.java | 606 +- .../exist/storage/md/BackupRestoreMDTest.java | 628 +- .../exist/storage/md/DocumentAsValueTest.java | 458 +- .../exist/storage/md/MatchDocumentsTest.java | 1412 +-- .../java/org/exist/storage/md/SearchTest.java | 666 +- .../org/exist/storage/md/SimpleMDTest.java | 2074 ++--- extensions/metadata/sleepycat/pom.xml | 28 +- .../org/exist/storage/md/MetaDataImpl.java | 1192 +-- .../java/org/exist/storage/md/MetaImpl.java | 204 +- .../java/org/exist/storage/md/MetasImpl.java | 292 +- .../modules/cache/CacheBasicFunction.java | 146 +- .../xquery/modules/cache/CacheFunction.java | 138 +- .../xquery/modules/cache/CacheModule.java | 154 +- .../xquery/modules/cache/ClearFunction.java | 182 +- .../xquery/modules/cache/GetFunction.java | 164 +- .../xquery/modules/cache/PutFunction.java | 168 +- .../xquery/modules/cache/RemoveFunction.java | 164 +- .../compression/AbstractCompressFunction.java | 1016 +-- .../compression/CompressionModule.java | 164 +- .../modules/compression/GZipFunction.java | 188 +- .../modules/compression/TarFunction.java | 200 +- .../modules/compression/UnGZipFunction.java | 196 +- .../modules/compression/ZipFunction.java | 204 +- .../modules/compression/example-untar.xql | 64 +- .../modules/compression/example-unzip.xql | 64 +- .../xquery/modules/context/ContextModule.java | 154 +- .../modules/datetime/DayInWeekFunction.java | 138 +- .../modules/datetime/DaysInMonthFunction.java | 146 +- .../modules/datetime/FormatDateFunction.java | 154 +- .../datetime/FormatDateTimeFunction.java | 158 +- .../modules/datetime/FormatTimeFunction.java | 156 +- .../datetime/TimeFromDateTimeFunction.java | 130 +- .../modules/datetime/WeekInMonthFunction.java | 148 +- .../exist/xquery/modules/exi/EXIUtils.java | 116 +- .../xquery/modules/exi/EncodeExiFunction.java | 244 +- .../exist/xquery/modules/exi/ExiModule.java | 140 +- .../exist/xquery/modules/file/FileDelete.java | 188 +- .../exist/xquery/modules/file/FileExists.java | 188 +- .../xquery/modules/file/FileIsDirectory.java | 188 +- .../xquery/modules/file/FileIsReadable.java | 188 +- .../xquery/modules/file/FileIsWriteable.java | 188 +- .../exist/xquery/modules/file/FileRead.java | 270 +- .../xquery/modules/file/FileReadBinary.java | 200 +- .../xquery/modules/file/FileReadUnicode.java | 274 +- .../xquery/modules/file/SerializeToFile.java | 564 +- .../xquery/modules/file/UnicodeReader.java | 356 +- .../exist/xquery/modules/jndi/jndiExample.xql | 226 +- .../mail/access_imap_mailbox_example.xql | 78 +- .../modules/mail/send-email_sendmail.xql | 82 +- .../xquery/modules/mail/send-email_smtp.xql | 82 +- .../exist/xquery/modules/math/MathModule.java | 170 +- .../xquery/modules/math/NoParamFunctions.java | 232 +- .../modules/math/OneParamFunctions.java | 476 +- .../modules/math/TwoParamFunctions.java | 244 +- .../modules/oracle/ExecuteFunction.java | 876 +- .../xquery/modules/oracle/OracleModule.java | 166 +- .../xquery/modules/oracle/oracle-example.xql | 70 +- .../exist/xquery/modules/oracle/readme.txt | 32 +- .../modules/scheduler/SchedulerModule.java | 188 +- .../xquery/modules/simpleql/SimpleQLParser.g | 1606 ++-- .../exist/xquery/modules/sql/SQLUtils.java | 366 +- .../org/exist/xquery/modules/xslfo/readme.txt | 28 +- extensions/scheduler/pom.xml | 28 +- .../main/java/org/exist/scheduler/Job.java | 258 +- .../org/exist/scheduler/SchedulerManager.java | 282 +- .../security/realm/oauth/Google2Api.java | 124 +- .../svn/internal/wc/admin/SVNAdminArea16.java | 478 +- .../wc/admin/SVNAdminArea16Factory.java | 106 +- .../svn/xquery/XQueryFunctionsTest.java | 686 +- extensions/webdav/lib/milton-LICENSE.txt | 104 +- .../src/org/exist/webdav/MiltonDocument.java | 1196 +-- .../org/exist/xquery/xUnit/Annotations.java | 172 +- .../org/exist/xquery/xUnit/AssertEquals.java | 110 +- .../java/org/exist/xquery/xUnit/xUnit.java | 272 +- .../test/java/org/exist/xquery/xUnit/test.xql | 18 +- extensions/xprocxq/main/src/xquery/ant.xqm | 32 +- extensions/xprocxq/main/src/xquery/const.xqm | 268 +- extensions/xprocxq/main/src/xquery/ext.xqm | 134 +- .../xprocxq/main/src/xquery/functions.xqm | 128 +- extensions/xprocxq/main/src/xquery/naming.xqm | 690 +- extensions/xprocxq/main/src/xquery/opt.xqm | 324 +- extensions/xprocxq/main/src/xquery/std.xqm | 1088 +-- extensions/xprocxq/main/src/xquery/util.xqm | 2076 ++--- extensions/xprocxq/main/src/xquery/xproc.xqm | 2108 ++--- extensions/xqdoc/ant-example.xml | 76 +- extensions/xqdoc/xqdoc-1.0.xsd | 378 +- .../org/exist/interpreter/ContextAtExist.java | 128 +- .../xslt/src/org/exist/xslt/SourceImpl.java | 178 +- .../org/exist/xslt/TemplatesHandlerImpl.java | 160 +- .../exist/xslt/TransformerFactoryImpl.java | 546 +- .../exist/xslt/TransformerHandlerImpl.java | 180 +- .../src/org/exist/xslt/TransformerImpl.java | 548 +- extensions/xslt/src/org/exist/xslt/XSL.java | 324 +- .../xslt/src/org/exist/xslt/XSLContext.java | 266 +- .../src/org/exist/xslt/XSLExceptions.java | 1740 ++-- .../src/org/exist/xslt/XSLStylesheet.java | 936 +- .../src/org/exist/xslt/compiler/Factory.java | 202 +- .../src/org/exist/xslt/compiler/Names.java | 294 +- .../org/exist/xslt/compiler/XSLElement.java | 1468 +-- .../exist/xslt/expression/AnalyzeString.java | 236 +- .../exist/xslt/expression/ApplyImports.java | 160 +- .../exist/xslt/expression/ApplyTemplates.java | 448 +- .../org/exist/xslt/expression/Attribute.java | 604 +- .../exist/xslt/expression/AttributeSet.java | 272 +- .../exist/xslt/expression/CallTemplate.java | 316 +- .../exist/xslt/expression/CharacterMap.java | 212 +- .../src/org/exist/xslt/expression/Choose.java | 230 +- .../org/exist/xslt/expression/Comment.java | 354 +- .../src/org/exist/xslt/expression/Copy.java | 410 +- .../src/org/exist/xslt/expression/CopyOf.java | 452 +- .../exist/xslt/expression/DecimalFormat.java | 402 +- .../exist/xslt/expression/Declaration.java | 92 +- .../org/exist/xslt/expression/Document.java | 244 +- .../org/exist/xslt/expression/Element.java | 804 +- .../org/exist/xslt/expression/Fallback.java | 160 +- .../org/exist/xslt/expression/ForEach.java | 362 +- .../exist/xslt/expression/ForEachGroup.java | 578 +- .../org/exist/xslt/expression/Function.java | 234 +- .../src/org/exist/xslt/expression/If.java | 232 +- .../src/org/exist/xslt/expression/Import.java | 186 +- .../exist/xslt/expression/ImportSchema.java | 216 +- .../org/exist/xslt/expression/Include.java | 186 +- .../src/org/exist/xslt/expression/Key.java | 258 +- .../xslt/expression/MatchingSubstring.java | 160 +- .../org/exist/xslt/expression/Message.java | 224 +- .../org/exist/xslt/expression/Namespace.java | 214 +- .../exist/xslt/expression/NamespaceAlias.java | 210 +- .../org/exist/xslt/expression/NextMatch.java | 160 +- .../xslt/expression/NonMatchingSubstring.java | 160 +- .../src/org/exist/xslt/expression/Number.java | 408 +- .../org/exist/xslt/expression/Otherwise.java | 160 +- .../src/org/exist/xslt/expression/Output.java | 560 +- .../xslt/expression/OutputCharacter.java | 204 +- .../src/org/exist/xslt/expression/Param.java | 588 +- .../exist/xslt/expression/PerformSort.java | 192 +- .../exist/xslt/expression/PreserveSpace.java | 186 +- .../expression/ProcessingInstruction.java | 392 +- .../exist/xslt/expression/ResultDocument.java | 608 +- .../xslt/expression/SequenceConstructor.java | 392 +- .../xslt/expression/SimpleConstructor.java | 136 +- .../src/org/exist/xslt/expression/Sort.java | 468 +- .../org/exist/xslt/expression/StripSpace.java | 186 +- .../org/exist/xslt/expression/Template.java | 742 +- .../src/org/exist/xslt/expression/Text.java | 346 +- .../org/exist/xslt/expression/ValueOf.java | 562 +- .../org/exist/xslt/expression/Variable.java | 356 +- .../src/org/exist/xslt/expression/When.java | 250 +- .../org/exist/xslt/expression/WithParam.java | 348 +- .../exist/xslt/expression/XSLExpression.java | 192 +- .../exist/xslt/expression/XSLPathExpr.java | 406 +- .../exist/xslt/expression/i/Parameted.java | 80 +- .../src/org/exist/xslt/functions/Current.java | 130 +- .../org/exist/xslt/functions/Document.java | 150 +- .../org/exist/xslt/functions/Format_date.java | 220 +- .../exist/xslt/functions/Format_dateTime.java | 204 +- .../exist/xslt/functions/Format_number.java | 214 +- .../org/exist/xslt/functions/Format_time.java | 200 +- .../org/exist/xslt/functions/Generate_id.java | 142 +- .../src/org/exist/xslt/functions/Key.java | 154 +- .../exist/xslt/functions/System_property.java | 176 +- .../functions/Unparsed_entity_public_id.java | 132 +- .../xslt/functions/Unparsed_entity_uri.java | 132 +- .../exist/xslt/functions/Unparsed_text.java | 150 +- .../functions/Unparsed_text_available.java | 150 +- .../org/exist/xslt/functions/XSLModule.java | 202 +- .../src/org/exist/xslt/pattern/Pattern.java | 360 +- .../test/src/org/exist/xslt/XSLTestCase.java | 1034 +-- installer/launch_client.bat | 44 +- installer/scripts/setup.bat | 42 +- lib/core/antlr-LICENSE.txt | 56 +- lib/core/clj-ds-LICENSE.html | 522 +- lib/core/commons-codec-LICENSE.txt | 404 +- lib/core/commons-collections-LICENSE.txt | 404 +- lib/core/commons-collections-NOTICE.txt | 10 +- lib/core/commons-io-LICENSE.txt | 406 +- lib/core/commons-io-NOTICE.txt | 12 +- lib/core/commons-logging-LICENSE.txt | 404 +- lib/core/commons-logging-NOTICE.txt | 12 +- lib/core/excalibur-cli-LICENSE.txt | 100 +- lib/core/slf4j-LICENSE.txt | 48 +- lib/endorsed/saxonhe-LICENSE.txt | 28 +- lib/endorsed/serializer-LICENSE.txt | 402 +- lib/endorsed/serializer-NOTICE.txt | 36 +- lib/endorsed/xalan-LICENSE.txt | 1368 +-- lib/endorsed/xalan-NOTICE.txt | 160 +- lib/endorsed/xercesImpl-LICENSE.txt | 404 +- lib/endorsed/xercesImpl-NOTICE.txt | 32 +- lib/endorsed/xml-apis-LICENSE.txt | 404 +- lib/endorsed/xml-apis-NOTICE.txt | 32 +- lib/endorsed/xml-resolver-LICENSE.txt | 402 +- lib/endorsed/xml-resolver-NOTICE.txt | 18 +- lib/optional/commons-fileupload-LICENSE.txt | 404 +- lib/optional/commons-fileupload-NOTICE.txt | 10 +- lib/optional/commons-httpclient-LICENSE.txt | 352 +- lib/optional/commons-httpclient-NOTICE.txt | 10 +- lib/optional/commons-lang-LICENSE.txt | 404 +- lib/optional/commons-net-LICENSE.txt | 404 +- lib/optional/isorelax-LICENSE.txt | 14 +- lib/optional/jing-LICENSE.txt | 62 +- lib/optional/servlet-api-LICENSE.txt | 404 +- lib/optional/servlet-api-NOTICE.txt | 4 +- lib/user/exificient-LICENSE.txt | 678 +- log4j.xml | 540 +- mime-types.xml.tmpl | 710 +- samples/ant/ant-test.xml | 80 +- samples/build.xml | 128 +- .../examples/xmlrpc/RetrieveChunked.java | 236 +- .../exist/examples/xmlrpc/StoreChunked.java | 226 +- samples/validation/addressbook/catalog.xml | 8 +- .../personal/personal-dtd-invalid.xml | 104 +- samples/validation/personal/personal-dtd.xml | 104 +- .../validation/personal/personal-invalid.xml | 102 +- .../validation/personal/personal-relaxng.xml | 104 +- .../validation/personal/personal-valid.xml | 104 +- .../personal-xsd_noSchemaLocation-invalid.xml | 104 +- .../personal-xsd_noSchemaLocation.xml | 104 +- samples/validation/personal/personal.rnc | 110 +- samples/validation/personal/personal.rng | 362 +- .../tournament/1.5/Tournament-invalid.xml | 92 +- .../tournament/1.5/Tournament-valid.xml | 92 +- .../validation/tournament/1.5/Tournament.rng | 194 +- .../validation/tournament/1.5/Tournament.xsd | 230 +- .../tournament/1.5/tournament-schema.sch | 120 +- .../validation/tournament/iso/Tournament.rng | 206 +- .../validation/tournament/iso/Tournament.xml | 92 +- .../validation/tournament/iso/Tournament.xsd | 240 +- .../tournament/iso/tournament-schema.sch | 160 +- samples/xinclude/styles/SyntaxHighlighter.css | 370 +- samples/xinclude/styles/niftyCorners.css | 68 +- samples/xinclude/styles/niftycube.js | 594 +- samples/xquery/backup.xq | 18 +- src/org/exist/EventListener.java | 64 +- src/org/exist/backup/BackupHandler.java | 82 +- src/org/exist/backup/BackupWriter.java | 122 +- src/org/exist/backup/FileSystemWriter.java | 284 +- src/org/exist/backup/RestoreHandler.java | 80 +- src/org/exist/backup/SystemImport.java | 322 +- src/org/exist/backup/ZipWriter.java | 298 +- src/org/exist/client/Messages.java | 86 +- src/org/exist/client/PrettyXmldbURI.java | 84 +- src/org/exist/client/messages.properties | 592 +- .../exist/client/messages_es_ES.properties | 730 +- .../exist/client/messages_fr_FR.properties | 588 +- .../exist/client/messages_it_IT.properties | 634 +- .../exist/client/messages_nl_NL.properties | 574 +- src/org/exist/client/messages_no.properties | 422 +- .../exist/client/messages_ru_RU.properties | 528 +- src/org/exist/dom/AttrAtExist.java | 66 +- src/org/exist/dom/DocumentAtExist.java | 136 +- src/org/exist/dom/ElementAtExist.java | 74 +- src/org/exist/dom/MutableDocumentSet.java | 82 +- src/org/exist/dom/NamespaceNodeAtExist.java | 62 +- src/org/exist/dom/NodeAtExist.java | 90 +- src/org/exist/dom/NodeHandle.java | 42 +- src/org/exist/fulltext/FTMatchListener.java | 444 +- src/org/exist/http/run-xproc.xq | 54 +- src/org/exist/indexing/AbstractIndex.java | 174 +- .../exist/indexing/AbstractMatchListener.java | 248 +- .../indexing/AbstractStreamListener.java | 162 +- src/org/exist/indexing/Index.java | 244 +- src/org/exist/indexing/IndexController.java | 826 +- src/org/exist/indexing/IndexManager.java | 482 +- src/org/exist/indexing/IndexUtils.java | 120 +- src/org/exist/indexing/IndexWorker.java | 436 +- src/org/exist/indexing/MatchListener.java | 72 +- .../exist/indexing/OrderedValuesIndex.java | 44 +- src/org/exist/indexing/QNamedKeysIndex.java | 34 +- src/org/exist/indexing/StreamListener.java | 228 +- src/org/exist/installer/Setup.java | 404 +- .../exist/management/client/JMXClient.java | 846 +- .../eXistURLStreamHandlerFactory.java | 202 +- .../embedded/EmbeddedDownload.java | 328 +- .../embedded/EmbeddedInputStream.java | 238 +- .../embedded/EmbeddedOutputStream.java | 180 +- .../embedded/EmbeddedUser.java | 142 +- .../protocolhandler/embedded/package.html | 8 +- .../protocols/xmldb/Connection.java | 214 +- .../protocols/xmldb/package.html | 8 +- .../exist/protocolhandler/xmldb/XmldbURL.java | 738 +- .../exist/protocolhandler/xmldb/package.html | 8 +- .../xmlrpc/XmlrpcDownload.java | 234 +- .../xmlrpc/XmlrpcDownloadThread.java | 154 +- .../xmlrpc/XmlrpcInputStream.java | 190 +- .../xmlrpc/XmlrpcOutputStream.java | 172 +- .../protocolhandler/xmlrpc/XmlrpcUpload.java | 264 +- .../xmlrpc/XmlrpcUploadThread.java | 134 +- .../exist/protocolhandler/xmlrpc/package.html | 8 +- src/org/exist/scheduler/JobDescription.java | 102 +- src/org/exist/scheduler/JobException.java | 162 +- src/org/exist/scheduler/ScheduledJobInfo.java | 374 +- src/org/exist/scheduler/UserJavaJob.java | 152 +- src/org/exist/scheduler/UserJob.java | 78 +- src/org/exist/scheduler/UserXQueryJob.java | 530 +- .../scheduler/impl/SystemTaskJobImpl.java | 234 +- src/org/exist/security/UUIDGenerator.java | 142 +- .../internal/EventAuthentication.java | 138 +- src/org/exist/security/internal/SMEvents.java | 384 +- src/org/exist/soap/admin.wsdl | 1072 +-- src/org/exist/soap/deployAdmin.wsdd | 246 +- src/org/exist/soap/deployQuery.wsdd | 182 +- src/org/exist/soap/query.wsdl | 1232 +-- src/org/exist/soap/undeployAdmin.wsdd | 30 +- src/org/exist/soap/undeployQuery.wsdd | 30 +- .../exist/source/StringSourceWithMapKey.java | 96 +- src/org/exist/start/LatestFileResolver.java | 226 +- .../exist/stax/EmbeddedXMLStreamReader.java | 1372 +-- src/org/exist/storage/BackupSystemTask.java | 334 +- src/org/exist/storage/DBBroker.java | 1 - .../storage/btree/SetPageLinkLoggable.java | 154 +- src/org/exist/storage/btree/TreeMetrics.java | 148 +- .../exist/storage/dom/RawNodeIterator.java | 448 +- src/org/exist/storage/dom/RecordPos.java | 128 +- .../exist/storage/io/BlockingInputStream.java | 764 +- .../storage/io/BlockingOutputStream.java | 262 +- .../exist/storage/lock/FileLockHeartBeat.java | 154 +- src/org/exist/storage/lock/LockOwner.java | 102 +- .../exist/storage/lock/LockedDocumentMap.java | 226 +- src/org/exist/storage/md/Meta.java | 76 +- src/org/exist/storage/md/MetaData.java | 172 +- src/org/exist/storage/md/Metas.java | 90 +- src/org/exist/storage/sync/Sync.java | 68 +- src/org/exist/util/Base64Decoder.java | 472 +- src/org/exist/util/Base64Encoder.java | 298 +- .../exist/util/FloatingPointConverter.java | 1296 +-- .../util/SingleInstanceConfiguration.java | 278 +- src/org/exist/util/hashtable/MapRWLock.java | 348 +- .../exist/util/io/TemporaryFileManager.java | 302 +- src/org/exist/util/pool/NodePool.java | 242 +- .../exist/util/serializer/EXISerializer.java | 404 +- .../validation/ValidationReportItem.java | 232 +- .../exist/validation/XmlLibraryChecker.java | 736 +- .../internal/DatabaseResources.java | 442 +- .../internal/node/NodeInputStream.java | 176 +- .../internal/node/NodeSerializer.java | 168 +- .../internal/node/NodeSerializerThread.java | 168 +- .../internal/query/find_catalogs_with_dtd.xq | 28 +- .../query/find_schema_by_targetNamespace.xq | 26 +- .../validation/resolver/AnyUriResolver.java | 304 +- .../resolver/SearchResourceResolver.java | 328 +- .../resolver/eXistXMLCatalogResolver.java | 470 +- src/org/exist/webstart/package.html | 10 +- src/org/exist/xmldb/ExtendedResource.java | 130 +- src/org/exist/xquery/AnnotationTrigger.java | 60 +- .../xquery/AnnotationTriggerOnResult.java | 68 +- src/org/exist/xquery/Annotations.java | 116 +- .../xquery/DefaultExpressionVisitor.java | 326 +- src/org/exist/xquery/GroupSpec.java | 178 +- src/org/exist/xquery/IndexUseReporter.java | 76 +- src/org/exist/xquery/Optimizer.java | 736 +- .../xquery/functions/fn/FnFormatNumbers.java | 816 +- .../functions/fn/FunCodepointEqual.java | 186 +- .../xquery/functions/fn/FunDateTime.java | 274 +- .../functions/fn/FunDefaultCollation.java | 146 +- .../exist/xquery/functions/fn/FunEquals.java | 258 +- .../functions/fn/FunGetDurationComponent.java | 338 +- .../exist/xquery/functions/fn/FunIdRef.java | 414 +- .../exist/xquery/functions/fn/FunNilled.java | 202 +- .../exist/xquery/functions/fn/FunTrace.java | 278 +- .../xquery/functions/math/MathModule.java | 164 +- .../functions/math/NoParamFunctions.java | 196 +- .../functions/math/OneParamFunctions.java | 430 +- .../functions/math/TwoParamFunctions.java | 250 +- .../xquery/functions/system/GetRevision.java | 124 +- .../functions/system/TriggerSystemTask.java | 254 +- .../exist/xquery/functions/text/Tokenize.java | 156 +- .../functions/util/DeepCopyFunction.java | 178 +- .../xquery/functions/util/FunDoctype.java | 192 +- .../functions/util/GetSequenceType.java | 126 +- .../functions/util/IndexKeyDocuments.java | 250 +- .../functions/util/IndexKeyOccurrences.java | 254 +- .../xquery/functions/util/IndexType.java | 210 +- src/org/exist/xquery/functions/util/UUID.java | 190 +- src/org/exist/xquery/functions/util/Wait.java | 148 +- .../functions/xmldb/FunXCollection.java | 120 +- .../xquery/functions/xmldb/XMLDBDocument.java | 532 +- src/org/exist/xquery/modules/ModuleUtils.java | 958 +- .../exist/xquery/pragmas/ForceIndexUse.java | 146 +- .../exist/xquery/pragmas/ProfilePragma.java | 92 +- src/org/exist/xquery/regex/CaseVariants.java | 3776 ++++---- src/org/exist/xquery/regex/IntRangeSet.java | 804 +- .../xquery/regex/JDK15RegexTranslator.java | 2032 ++--- src/org/exist/xquery/regex/RegexData.java | 722 +- .../xquery/regex/RegexSyntaxException.java | 106 +- .../exist/xquery/regex/XMLCharacterData.java | 1570 ++-- .../xquery/value/GroupedValueSequence.java | 530 +- .../value/GroupedValueSequenceTable.java | 238 +- .../exist/backup/SystemExportImportTest.java | 564 +- .../org/exist/config/mapping/MappedClass.java | 96 +- test/src/org/exist/config/mapping/Mapping.xml | 24 +- .../org/exist/config/mapping/SubConfig.java | 96 +- .../deadlocks/GetReleaseBrokerDeadlocks.java | 410 +- test/src/org/exist/dom/BasicNodeSetTest.java | 1014 +-- test/src/org/exist/dom/utf8.xml | 12 +- test/src/org/exist/http/RESTTest.java | 72 +- .../performance/actions/XUpdateAction.java | 106 +- test/src/org/exist/performance/test.xml | 1038 +-- .../storage/RemoveRootCollectionTest.java | 158 +- .../org/exist/storage/btree/BTreeTest.java | 1094 +-- test/src/org/exist/test/TestConstants.java | 206 +- test/src/org/exist/util/MimeTableTest.java | 302 +- test/src/org/exist/util/SortTests.java | 146 +- .../org/exist/util/mime-types-foo-default.xml | 18 +- .../org/exist/util/mime-types-xml-default.xml | 18 +- .../exist/util/sorters/ComparatorChecker.java | 166 +- .../exist/util/sorters/FastQSortTester.java | 204 +- .../org/exist/util/sorters/HSortTester.java | 188 +- .../exist/util/sorters/HeapSortTester.java | 204 +- .../util/sorters/InsertionSortTester.java | 200 +- .../org/exist/util/sorters/ListChecker.java | 180 +- .../sorters/LongArrayAndObjectChecker.java | 186 +- .../util/sorters/NodeProxyByIdChecker.java | 168 +- .../exist/util/sorters/NodeProxyChecker.java | 172 +- .../sorters/ObjectAndIntArrayChecker.java | 190 +- .../exist/util/sorters/PlainArrayChecker.java | 312 +- .../exist/util/sorters/SortMethodChecker.java | 206 +- .../org/exist/util/sorters/SortTestCase.java | 382 +- .../util/sorters/SortTestComparator.java | 354 +- .../exist/util/sorters/SortTestNodeId.java | 298 +- .../exist/util/sorters/SortTestNodeProxy.java | 124 +- .../util/sorters/SortingAlgorithmTester.java | 156 +- .../validation/DatabaseCollectionTest.java | 216 +- test/src/org/exist/validation/TestTools.java | 338 +- .../ValidationFunctions_Node_Test.java | 516 +- .../ValidationFunctions_XSD_Test.java | 634 +- test/src/org/exist/xmldb/CollectionTest.java | 144 +- .../org/exist/xmldb/SerializationTest.java | 266 +- .../org/exist/xmlrpc/MoveResourceTest.java | 466 +- .../org/exist/xmlrpc/QuerySessionTest.java | 364 +- .../org/exist/xquery/JavaFunctionsTest.java | 198 +- test/src/org/exist/xquery/OptimizerTest.java | 618 +- .../functions/request/GetHeaderTest.java | 182 +- .../functions/request/GetParameterTest.java | 1026 +-- .../functions/util/Base64FunctionsTest.java | 280 +- .../xquery/functions/util/ExpandTest.java | 216 +- .../org/exist/xquery/value/AnyURITest.java | 132 +- .../rename_including_namespace.xml | 36 +- .../modifications/rename_root_element.xml | 24 +- test/src/xquery/matchHighlighting.xml | 376 +- test/src/xquery/namespaces.xml | 126 +- test/src/xquery/parenthesizedContext.xml | 1090 +-- test/src/xquery/parenthesizedLocationStep.xml | 1110 +-- ...arenthesizedLocationStep_ftquery_Tests.xml | 358 +- test/src/xquery/pathExpression_operators.xml | 72 +- test/src/xquery/selfAxis.xml | 362 +- test/src/xquery/unionOperator.xml | 192 +- tools/ant/LICENSE.txt | 544 +- tools/ant/lib/asocat-exist.LICENSE.txt | 330 +- tools/ant/lib/jdepend-LICENSE.txt | 58 +- tools/backrest/build.xml | 192 +- tools/backrest/src/backup.bat | 108 +- tools/backrest/src/backup.properties | 36 +- tools/ircbot/build.xml | 114 +- tools/ircbot/run.bat | 14 +- tools/ircbot/src/org/exist/irc/IRCProxy.java | 292 +- .../ircbot/src/org/exist/irc/IRCSession.java | 804 +- tools/ircbot/src/org/exist/irc/XBot.java | 924 +- tools/ircbot/webapp/WEB-INF/web.xml | 54 +- .../org/exist/izpack/PasswordValidator.java | 72 +- tools/rulesets/basic.xml | 2006 ++--- tools/rulesets/migrating.xml | 356 +- tools/rulesets/optimizations.xml | 626 +- tools/rulesets/scratchpad.xml | 188 +- tools/wrapper/bin/exist.bat | 270 +- tools/wrapper/bin/install.bat | 270 +- tools/wrapper/bin/uninstall.bat | 266 +- tools/wrapper/wrapper-log4j.xsl | 36 +- webapp/WEB-INF/entities/play.xsd | 280 +- webapp/WEB-INF/entities/xml.xsd | 266 +- webapp/xqts/hacked-tests.xml | 32 +- webapp/xqts/scripts/container.js | 7834 ++++++++--------- webapp/xqts/scripts/dom.js | 1774 ++-- webapp/xqts/scripts/event.js | 2400 ++--- webapp/xqts/scripts/shBrushXQuery.js | 158 +- webapp/xqts/scripts/shBrushXml.js | 122 +- webapp/xqts/scripts/yahoo.js | 168 +- webapp/xqts/skip.xml | 6 +- webapp/xqts/styles/SyntaxHighlighter.css | 502 +- webapp/xqts/styles/container.css | 420 +- 552 files changed, 99753 insertions(+), 99754 deletions(-) diff --git a/backup.properties b/backup.properties index ef444b5115c..a1413caa395 100644 --- a/backup.properties +++ b/backup.properties @@ -1,18 +1,18 @@ -# properties used for backup/restore - -# XMLDB driver -driver=org.exist.xmldb.DatabaseImpl - -# uncomment following line if you want to access a -# stand-alone server -#uri=xmldb:exist://localhost:8088/xmlrpc - -# access eXist via XML-RPC provided by remote Tomcat -uri=xmldb:exist://localhost:8080/exist/xmlrpc - -# access a local instance of the database -#uri=xmldb:exist:// - -# user settings for backup/restore -user=admin -password= +# properties used for backup/restore + +# XMLDB driver +driver=org.exist.xmldb.DatabaseImpl + +# uncomment following line if you want to access a +# stand-alone server +#uri=xmldb:exist://localhost:8088/xmlrpc + +# access eXist via XML-RPC provided by remote Tomcat +uri=xmldb:exist://localhost:8080/exist/xmlrpc + +# access a local instance of the database +#uri=xmldb:exist:// + +# user settings for backup/restore +user=admin +password= diff --git a/bin/backup.bat b/bin/backup.bat index 6ad0a3a8cf2..6fc19397c97 100644 --- a/bin/backup.bat +++ b/bin/backup.bat @@ -1,64 +1,64 @@ -@echo off - -rem $Id$ - -rem Slurp the command line arguments. This loop allows for an unlimited number -rem of arguments (up to the command line limit, anyway). - -set CMD_LINE_ARGS=%1 -if ""%1""=="""" goto doneStart -shift -:setupArgs -if ""%1""=="""" goto doneStart -set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 -shift -goto setupArgs - -rem This label provides a place for the argument list loop to break out -rem and for NT handling to skip to. - -:doneStart - -set JAVA_RUN="java" - -if not "%JAVA_HOME%" == "" ( - set JAVA_RUN="%JAVA_HOME%\bin\java" - goto gotJavaHome -) - -rem @WINDOWS_INSTALLER_1@ - -echo WARNING: JAVA_HOME not found in your environment. -echo. -echo Please, set the JAVA_HOME variable in your enviroment to match the -echo location of the Java Virtual Machine you want to use in case of run fail. -echo. - -:gotJavaHome -if not "%EXIST_HOME%" == "" goto gotExistHome - -rem try to guess (will be overridden by the installer) -set EXIST_HOME=. - -rem @WINDOWS_INSTALLER_2@ - -if exist "%EXIST_HOME%\start.jar" goto gotExistHome - -set EXIST_HOME=.. -if exist "%EXIST_HOME%\start.jar" goto gotExistHome - -echo EXIST_HOME not found. Please set your -echo EXIST_HOME environment variable to the -echo home directory of eXist. -goto :eof - -:gotExistHome -set MX=768 -rem @WINDOWS_INSTALLER_3@ - -set JAVA_ENDORSED_DIRS="%EXIST_HOME%\lib\endorsed" -set JAVA_OPTS="-Xms128m -Xmx%MX%m -Dfile.encoding=UTF-8 -Djava.endorsed.dirs=%JAVA_ENDORSED_DIRS%" - -%JAVA_RUN% "%JAVA_OPTS%" -Dexist.home="%EXIST_HOME%" -jar "%EXIST_HOME%\start.jar" backup %CMD_LINE_ARGS% -:eof - +@echo off + +rem $Id$ + +rem Slurp the command line arguments. This loop allows for an unlimited number +rem of arguments (up to the command line limit, anyway). + +set CMD_LINE_ARGS=%1 +if ""%1""=="""" goto doneStart +shift +:setupArgs +if ""%1""=="""" goto doneStart +set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 +shift +goto setupArgs + +rem This label provides a place for the argument list loop to break out +rem and for NT handling to skip to. + +:doneStart + +set JAVA_RUN="java" + +if not "%JAVA_HOME%" == "" ( + set JAVA_RUN="%JAVA_HOME%\bin\java" + goto gotJavaHome +) + +rem @WINDOWS_INSTALLER_1@ + +echo WARNING: JAVA_HOME not found in your environment. +echo. +echo Please, set the JAVA_HOME variable in your enviroment to match the +echo location of the Java Virtual Machine you want to use in case of run fail. +echo. + +:gotJavaHome +if not "%EXIST_HOME%" == "" goto gotExistHome + +rem try to guess (will be overridden by the installer) +set EXIST_HOME=. + +rem @WINDOWS_INSTALLER_2@ + +if exist "%EXIST_HOME%\start.jar" goto gotExistHome + +set EXIST_HOME=.. +if exist "%EXIST_HOME%\start.jar" goto gotExistHome + +echo EXIST_HOME not found. Please set your +echo EXIST_HOME environment variable to the +echo home directory of eXist. +goto :eof + +:gotExistHome +set MX=768 +rem @WINDOWS_INSTALLER_3@ + +set JAVA_ENDORSED_DIRS="%EXIST_HOME%\lib\endorsed" +set JAVA_OPTS="-Xms128m -Xmx%MX%m -Dfile.encoding=UTF-8 -Djava.endorsed.dirs=%JAVA_ENDORSED_DIRS%" + +%JAVA_RUN% "%JAVA_OPTS%" -Dexist.home="%EXIST_HOME%" -jar "%EXIST_HOME%\start.jar" backup %CMD_LINE_ARGS% +:eof + diff --git a/bin/client.bat b/bin/client.bat index ee1c6f52357..0aadadabbeb 100644 --- a/bin/client.bat +++ b/bin/client.bat @@ -1,57 +1,57 @@ -@echo off -rem $Id$ -rem -rem In addition to the other parameter options for the interactive client -rem pass -j or --jmx to enable JMX agent. The port for it can be specified -rem with optional port number e.g. -j1099 or --jmx=1099. -rem - -set JMX_ENABLED=0 -set JMX_PORT=1099 -set JAVA_ARGS= - -set JAVA_RUN="java" - -if not "%JAVA_HOME%" == "" ( - set JAVA_RUN="%JAVA_HOME%\bin\java" - goto gotJavaHome -) - -rem @WINDOWS_INSTALLER_1@ - -echo WARNING: JAVA_HOME not found in your environment. -echo. -echo Please, set the JAVA_HOME variable in your enviroment to match the -echo location of the Java Virtual Machine you want to use in case of run fail. -echo. - -:gotJavaHome -rem @WINDOWS_INSTALLER_2@ - -if not "%EXIST_HOME%" == "" goto gotExistHome - -rem try to guess (will be set by the installer) -set EXIST_HOME=. -if exist "%EXIST_HOME%\start.jar" goto gotExistHome - -set EXIST_HOME=.. -if exist "%EXIST_HOME%\start.jar" goto gotExistHome - -echo EXIST_HOME not found. Please set your -echo EXIST_HOME environment variable to the -echo home directory of eXist. -goto :eof - -:gotExistHome -set MX=1024 -rem @WINDOWS_INSTALLER_3@ - -set JAVA_ENDORSED_DIRS="%EXIST_HOME%\lib\endorsed" -set JAVA_OPTS="-Xms128m -Xmx%MX%m -Dfile.encoding=UTF-8 -Djava.endorsed.dirs=%JAVA_ENDORSED_DIRS%" - -set BATCH.D="%EXIST_HOME%\bin\batch.d" -call %BATCH.D%\get_opts.bat %* -call %BATCH.D%\check_jmx_status.bat - -%JAVA_RUN% "%JAVA_OPTS%" -Dexist.home="%EXIST_HOME%" -jar "%EXIST_HOME%\start.jar" client %JAVA_ARGS% -:eof +@echo off +rem $Id$ +rem +rem In addition to the other parameter options for the interactive client +rem pass -j or --jmx to enable JMX agent. The port for it can be specified +rem with optional port number e.g. -j1099 or --jmx=1099. +rem + +set JMX_ENABLED=0 +set JMX_PORT=1099 +set JAVA_ARGS= + +set JAVA_RUN="java" + +if not "%JAVA_HOME%" == "" ( + set JAVA_RUN="%JAVA_HOME%\bin\java" + goto gotJavaHome +) + +rem @WINDOWS_INSTALLER_1@ + +echo WARNING: JAVA_HOME not found in your environment. +echo. +echo Please, set the JAVA_HOME variable in your enviroment to match the +echo location of the Java Virtual Machine you want to use in case of run fail. +echo. + +:gotJavaHome +rem @WINDOWS_INSTALLER_2@ + +if not "%EXIST_HOME%" == "" goto gotExistHome + +rem try to guess (will be set by the installer) +set EXIST_HOME=. +if exist "%EXIST_HOME%\start.jar" goto gotExistHome + +set EXIST_HOME=.. +if exist "%EXIST_HOME%\start.jar" goto gotExistHome + +echo EXIST_HOME not found. Please set your +echo EXIST_HOME environment variable to the +echo home directory of eXist. +goto :eof + +:gotExistHome +set MX=1024 +rem @WINDOWS_INSTALLER_3@ + +set JAVA_ENDORSED_DIRS="%EXIST_HOME%\lib\endorsed" +set JAVA_OPTS="-Xms128m -Xmx%MX%m -Dfile.encoding=UTF-8 -Djava.endorsed.dirs=%JAVA_ENDORSED_DIRS%" + +set BATCH.D="%EXIST_HOME%\bin\batch.d" +call %BATCH.D%\get_opts.bat %* +call %BATCH.D%\check_jmx_status.bat + +%JAVA_RUN% "%JAVA_OPTS%" -Dexist.home="%EXIST_HOME%" -jar "%EXIST_HOME%\start.jar" client %JAVA_ARGS% +:eof diff --git a/bin/run.bat b/bin/run.bat index 7ac853b7965..91d98182b8f 100644 --- a/bin/run.bat +++ b/bin/run.bat @@ -1,61 +1,61 @@ -@echo off - -rem $Id$ - -rem Slurp the command line arguments. This loop allows for an unlimited number -rem of arguments (up to the command line limit, anyway). - -set CMD_LINE_ARGS=%1 -if ""%1""=="""" goto doneStart -shift -:setupArgs -if ""%1""=="""" goto doneStart -set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 -shift -goto setupArgs - -rem This label provides a place for the argument list loop to break out -rem and for NT handling to skip to. - -:doneStart -set JAVA_RUN="java" - -if not "%JAVA_HOME%" == "" ( - set JAVA_RUN="%JAVA_HOME%\bin\java" - goto gotJavaHome -) - -rem @WINDOWS_INSTALLER_1@ - -echo WARNING: JAVA_HOME not found in your environment. -echo. -echo Please, set the JAVA_HOME variable in your enviroment to match the -echo location of the Java Virtual Machine you want to use in case of run fail. -echo. - -:gotJavaHome -rem @WINDOWS_INSTALLER_2@ - -if not "%EXIST_HOME%" == "" goto gotExistHome - -rem try to guess -set EXIST_HOME=. -if exist "%EXIST_HOME%\start.jar" goto gotExistHome -set EXIST_HOME=.. -if exist "%EXIST_HOME%\start.jar" goto gotExistHome - -echo EXIST_HOME not found. Please set your -echo EXIST_HOME environment variable to the -echo home directory of eXist. -goto :eof - -:gotExistHome -set MX=768 -rem @WINDOWS_INSTALLER_3@ - -set JAVA_ENDORSED_DIRS="%EXIST_HOME%\lib\endorsed" -set JAVA_OPTS="-Xms128m -Xmx%MX%m -Dfile.encoding=UTF-8 -Djava.endorsed.dirs=%JAVA_ENDORSED_DIRS%" - -:gotJavaOpts -%JAVA_RUN% "%JAVA_OPTS%" -Dexist.home="%EXIST_HOME%" -jar "%EXIST_HOME%\start.jar" %CMD_LINE_ARGS% +@echo off + +rem $Id$ + +rem Slurp the command line arguments. This loop allows for an unlimited number +rem of arguments (up to the command line limit, anyway). + +set CMD_LINE_ARGS=%1 +if ""%1""=="""" goto doneStart +shift +:setupArgs +if ""%1""=="""" goto doneStart +set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 +shift +goto setupArgs + +rem This label provides a place for the argument list loop to break out +rem and for NT handling to skip to. + +:doneStart +set JAVA_RUN="java" + +if not "%JAVA_HOME%" == "" ( + set JAVA_RUN="%JAVA_HOME%\bin\java" + goto gotJavaHome +) + +rem @WINDOWS_INSTALLER_1@ + +echo WARNING: JAVA_HOME not found in your environment. +echo. +echo Please, set the JAVA_HOME variable in your enviroment to match the +echo location of the Java Virtual Machine you want to use in case of run fail. +echo. + +:gotJavaHome +rem @WINDOWS_INSTALLER_2@ + +if not "%EXIST_HOME%" == "" goto gotExistHome + +rem try to guess +set EXIST_HOME=. +if exist "%EXIST_HOME%\start.jar" goto gotExistHome +set EXIST_HOME=.. +if exist "%EXIST_HOME%\start.jar" goto gotExistHome + +echo EXIST_HOME not found. Please set your +echo EXIST_HOME environment variable to the +echo home directory of eXist. +goto :eof + +:gotExistHome +set MX=768 +rem @WINDOWS_INSTALLER_3@ + +set JAVA_ENDORSED_DIRS="%EXIST_HOME%\lib\endorsed" +set JAVA_OPTS="-Xms128m -Xmx%MX%m -Dfile.encoding=UTF-8 -Djava.endorsed.dirs=%JAVA_ENDORSED_DIRS%" + +:gotJavaOpts +%JAVA_RUN% "%JAVA_OPTS%" -Dexist.home="%EXIST_HOME%" -jar "%EXIST_HOME%\start.jar" %CMD_LINE_ARGS% :eof \ No newline at end of file diff --git a/bin/server.bat b/bin/server.bat index de9c4f50f95..649cd4dda59 100644 --- a/bin/server.bat +++ b/bin/server.bat @@ -1,58 +1,58 @@ -@echo off - -rem $Id$ -rem -rem In addition to the other parameter options for the standalone server -rem pass -j or --jmx to enable JMX agent. The port for it can be specified -rem with optional port number e.g. -j1099 or --jmx=1099. -rem - -set JMX_ENABLED=0 -set JMX_PORT=1099 -set JAVA_ARGS= - -set JAVA_RUN="java" - -if not "%JAVA_HOME%" == "" ( - set JAVA_RUN="%JAVA_HOME%\bin\java" - goto gotJavaHome -) - -rem @WINDOWS_INSTALLER_1@ - -echo WARNING: JAVA_HOME not found in your environment. -echo. -echo Please, set the JAVA_HOME variable in your environment to match the -echo location of the Java Virtual Machine you want to use in case of run fail. -echo. - -:gotJavaHome -rem @WINDOWS_INSTALLER_2@ - -if not "%EXIST_HOME%" == "" goto gotExistHome - -rem try to guess (will be set by the installer) -set EXIST_HOME=. - -if exist "%EXIST_HOME%\start.jar" goto gotExistHome -set EXIST_HOME=.. -if exist "%EXIST_HOME%\start.jar" goto gotExistHome - -echo EXIST_HOME not found. Please set your -echo EXIST_HOME environment variable to the -echo home directory of eXist. -goto :eof - -:gotExistHome -set MX=1024 -rem @WINDOWS_INSTALLER_3@ - -set JAVA_ENDORSED_DIRS="%EXIST_HOME%\lib\endorsed" -set JAVA_OPTS="-Xms128m -Xmx%MX%m -Dfile.encoding=UTF-8 -Djava.endorsed.dirs=%JAVA_ENDORSED_DIRS%" - -set BATCH.D="%EXIST_HOME%\bin\batch.d" -call %BATCH.D%\get_opts.bat %* -call %BATCH.D%\check_jmx_status.bat - -%JAVA_RUN% "%JAVA_OPTS%" -Dexist.home="%EXIST_HOME%" -jar "%EXIST_HOME%\start.jar" standalone %JAVA_ARGS% -:eof +@echo off + +rem $Id$ +rem +rem In addition to the other parameter options for the standalone server +rem pass -j or --jmx to enable JMX agent. The port for it can be specified +rem with optional port number e.g. -j1099 or --jmx=1099. +rem + +set JMX_ENABLED=0 +set JMX_PORT=1099 +set JAVA_ARGS= + +set JAVA_RUN="java" + +if not "%JAVA_HOME%" == "" ( + set JAVA_RUN="%JAVA_HOME%\bin\java" + goto gotJavaHome +) + +rem @WINDOWS_INSTALLER_1@ + +echo WARNING: JAVA_HOME not found in your environment. +echo. +echo Please, set the JAVA_HOME variable in your environment to match the +echo location of the Java Virtual Machine you want to use in case of run fail. +echo. + +:gotJavaHome +rem @WINDOWS_INSTALLER_2@ + +if not "%EXIST_HOME%" == "" goto gotExistHome + +rem try to guess (will be set by the installer) +set EXIST_HOME=. + +if exist "%EXIST_HOME%\start.jar" goto gotExistHome +set EXIST_HOME=.. +if exist "%EXIST_HOME%\start.jar" goto gotExistHome + +echo EXIST_HOME not found. Please set your +echo EXIST_HOME environment variable to the +echo home directory of eXist. +goto :eof + +:gotExistHome +set MX=1024 +rem @WINDOWS_INSTALLER_3@ + +set JAVA_ENDORSED_DIRS="%EXIST_HOME%\lib\endorsed" +set JAVA_OPTS="-Xms128m -Xmx%MX%m -Dfile.encoding=UTF-8 -Djava.endorsed.dirs=%JAVA_ENDORSED_DIRS%" + +set BATCH.D="%EXIST_HOME%\bin\batch.d" +call %BATCH.D%\get_opts.bat %* +call %BATCH.D%\check_jmx_status.bat + +%JAVA_RUN% "%JAVA_OPTS%" -Dexist.home="%EXIST_HOME%" -jar "%EXIST_HOME%\start.jar" standalone %JAVA_ARGS% +:eof diff --git a/bin/shutdown.bat b/bin/shutdown.bat index 04176241435..7b092ad21e7 100644 --- a/bin/shutdown.bat +++ b/bin/shutdown.bat @@ -1,56 +1,56 @@ -@echo off - -rem $Id$ - -rem Slurp the command line arguments. This loop allows for an unlimited number -rem of arguments (up to the command line limit, anyway). - -set CMD_LINE_ARGS=%1 -if ""%1""=="""" goto doneStart -shift -:setupArgs -if ""%1""=="""" goto doneStart -set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 -shift -goto setupArgs - -rem This label provides a place for the argument list loop to break out -rem and for NT handling to skip to. - -:doneStart - -set JAVA_RUN="java" - -if not "%JAVA_HOME%" == "" ( - set JAVA_RUN="%JAVA_HOME%\bin\java" - goto gotJavaHome -) - -rem @WINDOWS_INSTALLER_1@ - -echo WARNING: JAVA_HOME not found in your environment. -echo. -echo Please, set the JAVA_HOME variable in your enviroment to match the -echo location of the Java Virtual Machine you want to use in case of run fail. -echo. - -:gotJavaHome -rem @WINDOWS_INSTALLER_2@ - -if not "%EXIST_HOME%" == "" goto gotExistHome - -rem try to guess (will be set by the installer) -set EXIST_HOME=. - -if exist "%EXIST_HOME%\start.jar" goto gotExistHome -set EXIST_HOME=.. -if exist "%EXIST_HOME%\start.jar" goto gotExistHome - -echo EXIST_HOME not found. Please set your -echo EXIST_HOME environment variable to the -echo home directory of eXist. -goto :eof - -:gotExistHome -%JAVA_RUN% -Dexist.home="%EXIST_HOME%" -jar "%EXIST_HOME%\start.jar" shutdown %CMD_LINE_ARGS% +@echo off + +rem $Id$ + +rem Slurp the command line arguments. This loop allows for an unlimited number +rem of arguments (up to the command line limit, anyway). + +set CMD_LINE_ARGS=%1 +if ""%1""=="""" goto doneStart +shift +:setupArgs +if ""%1""=="""" goto doneStart +set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 +shift +goto setupArgs + +rem This label provides a place for the argument list loop to break out +rem and for NT handling to skip to. + +:doneStart + +set JAVA_RUN="java" + +if not "%JAVA_HOME%" == "" ( + set JAVA_RUN="%JAVA_HOME%\bin\java" + goto gotJavaHome +) + +rem @WINDOWS_INSTALLER_1@ + +echo WARNING: JAVA_HOME not found in your environment. +echo. +echo Please, set the JAVA_HOME variable in your enviroment to match the +echo location of the Java Virtual Machine you want to use in case of run fail. +echo. + +:gotJavaHome +rem @WINDOWS_INSTALLER_2@ + +if not "%EXIST_HOME%" == "" goto gotExistHome + +rem try to guess (will be set by the installer) +set EXIST_HOME=. + +if exist "%EXIST_HOME%\start.jar" goto gotExistHome +set EXIST_HOME=.. +if exist "%EXIST_HOME%\start.jar" goto gotExistHome + +echo EXIST_HOME not found. Please set your +echo EXIST_HOME environment variable to the +echo home directory of eXist. +goto :eof + +:gotExistHome +%JAVA_RUN% -Dexist.home="%EXIST_HOME%" -jar "%EXIST_HOME%\start.jar" shutdown %CMD_LINE_ARGS% :eof \ No newline at end of file diff --git a/bin/startup.bat b/bin/startup.bat index 30f59cf7c6b..5a51fe8e72f 100644 --- a/bin/startup.bat +++ b/bin/startup.bat @@ -1,60 +1,60 @@ -@echo off - -rem $Id$ -rem -rem In addition to the other parameter options for the Jetty container -rem pass -j or --jmx to enable JMX agent. The port for it can be specified -rem with optional port number e.g. -j1099 or --jmx=1099. -rem - -set JMX_ENABLED=0 -set JMX_PORT=1099 -set JAVA_ARGS= - -set JAVA_RUN="java" - -if not "%JAVA_HOME%" == "" ( - set JAVA_RUN="%JAVA_HOME%\bin\java" - goto gotJavaHome -) - -rem @WINDOWS_INSTALLER_1@ - -echo WARNING: JAVA_HOME not found in your environment. -echo. -echo Please, set the JAVA_HOME variable in your enviroment to match the -echo location of the Java Virtual Machine you want to use in case of run fail. -echo. - -:gotJavaHome -rem @WINDOWS_INSTALLER_2@ - -if not "%EXIST_HOME%" == "" goto gotExistHome - -rem try to guess -set EXIST_HOME=. - -if exist "%EXIST_HOME%\start.jar" goto gotExistHome -set EXIST_HOME=.. -if exist "%EXIST_HOME%\start.jar" goto gotExistHome - -echo EXIST_HOME not found. Please set your -echo EXIST_HOME environment variable to the -echo home directory of eXist. -goto :eof - -:gotExistHome - -set MX=1024 -rem @WINDOWS_INSTALLER_3@ - -set JAVA_ENDORSED_DIRS="%EXIST_HOME%\lib\endorsed" -set JAVA_OPTS="-Xms128m -Xmx%MX%m -Dfile.encoding=UTF-8 -Djava.endorsed.dirs=%JAVA_ENDORSED_DIRS%" - -set BATCH.D="%EXIST_HOME%\bin\batch.d" -call %BATCH.D%\get_opts.bat %* -call %BATCH.D%\check_jmx_status.bat - -%JAVA_RUN% "%JAVA_OPTS%" -Dexist.home="%EXIST_HOME%" -jar "%EXIST_HOME%\start.jar" jetty %JAVA_ARGS% -:eof - +@echo off + +rem $Id$ +rem +rem In addition to the other parameter options for the Jetty container +rem pass -j or --jmx to enable JMX agent. The port for it can be specified +rem with optional port number e.g. -j1099 or --jmx=1099. +rem + +set JMX_ENABLED=0 +set JMX_PORT=1099 +set JAVA_ARGS= + +set JAVA_RUN="java" + +if not "%JAVA_HOME%" == "" ( + set JAVA_RUN="%JAVA_HOME%\bin\java" + goto gotJavaHome +) + +rem @WINDOWS_INSTALLER_1@ + +echo WARNING: JAVA_HOME not found in your environment. +echo. +echo Please, set the JAVA_HOME variable in your enviroment to match the +echo location of the Java Virtual Machine you want to use in case of run fail. +echo. + +:gotJavaHome +rem @WINDOWS_INSTALLER_2@ + +if not "%EXIST_HOME%" == "" goto gotExistHome + +rem try to guess +set EXIST_HOME=. + +if exist "%EXIST_HOME%\start.jar" goto gotExistHome +set EXIST_HOME=.. +if exist "%EXIST_HOME%\start.jar" goto gotExistHome + +echo EXIST_HOME not found. Please set your +echo EXIST_HOME environment variable to the +echo home directory of eXist. +goto :eof + +:gotExistHome + +set MX=1024 +rem @WINDOWS_INSTALLER_3@ + +set JAVA_ENDORSED_DIRS="%EXIST_HOME%\lib\endorsed" +set JAVA_OPTS="-Xms128m -Xmx%MX%m -Dfile.encoding=UTF-8 -Djava.endorsed.dirs=%JAVA_ENDORSED_DIRS%" + +set BATCH.D="%EXIST_HOME%\bin\batch.d" +call %BATCH.D%\get_opts.bat %* +call %BATCH.D%\check_jmx_status.bat + +%JAVA_RUN% "%JAVA_OPTS%" -Dexist.home="%EXIST_HOME%" -jar "%EXIST_HOME%\start.jar" jetty %JAVA_ARGS% +:eof + diff --git a/build.properties b/build.properties index da397ba37ad..f93f3823c2b 100644 --- a/build.properties +++ b/build.properties @@ -1,79 +1,79 @@ -# -# Don't directly modify this file. Instead, copy it to local.build.properties and -# edit that. -# -# $Id$ -project.name = eXist-db -project.version = 2.1 -project.version.numeric = 2.1 -project.codename = Ruesselsheim - -# build settings -build.debug = on -build.optimize = on -build.deprecation = off -build.encoding = UTF-8 -build.compiler.pedantic = false -build.compiler=modern -build.compiler.source=1.6 -build.compiler.target=1.6 - -autodeploy=dashboard,shared,eXide -autodeploy.repo=http://demo.exist-db.org/exist/apps/public-repo -use.autodeploy.feature=true - -# output dir for junit reports -junit.reports = test -junit.output = true -junit.forked.VM.maxmemory = 300m -# Converted junit tests from external testsuites -# reuire more memory, e g -# XSLTS requires 512m -# XQTS requires more than 400m -junit.forked.VM.maxmemory.external = 512m -proxy.nonproxyhosts = -proxy.host = -proxy.port = 0 -proxy.password = -proxy.user = -proxy.socks.host = -proxy.socks.port = 0 -#proxy.ntlm.domain = - -# Ant -tools.ant = ./tools/ant - -#aspectj -tools.aspectj = ./tools/aspectj - -# Common libs -lib.core = ./lib/core -lib.optional = ./lib/optional -lib.endorsed = ./lib/endorsed -lib.user = ./lib/user -lib.extensions = ./lib/extensions -lib.test = ./lib/test - -# antlr is only needed if you change the XPath/XQuery parser -# set these properties to true to get a lot of debugging output -antlr.traceParser = false -antlr.traceLexer = false -antlr.traceTreeWalker = false - -# IZPack is required to create the installer package. -# We currently require IzPack 4.3.5. The Izpack 5.0 beta does NOT work. -# If you change this property value for a reason, -# please use a version indicator in directory name, -# eg /izpack-dir-path/izpack-5.0-beta-11. -# You might need to change PermSpace to atleast 84 MB eg -XX:MaxPermSize=84m -# If you only want to point to your own izpack installation directory -# add this in local.build.properties instead so you don't commit it by mistake. -izpack.dir = /Applications/IzPack/ - -# Launch4J is required to create the windows installer -# If you change this property value for a reason, -# please use a version indicator in directory name, -# eg /launch4j-dir-path/launch4j-x.x.x. -# If you only want to point to your own launch4j installation directory -# add this in local.build.properties instead so you don't commit it by mistake. -launch4j.dir = /Applications/launch4j/ +# +# Don't directly modify this file. Instead, copy it to local.build.properties and +# edit that. +# +# $Id$ +project.name = eXist-db +project.version = 2.1 +project.version.numeric = 2.1 +project.codename = Ruesselsheim + +# build settings +build.debug = on +build.optimize = on +build.deprecation = off +build.encoding = UTF-8 +build.compiler.pedantic = false +build.compiler=modern +build.compiler.source=1.6 +build.compiler.target=1.6 + +autodeploy=dashboard,shared,eXide +autodeploy.repo=http://demo.exist-db.org/exist/apps/public-repo +use.autodeploy.feature=true + +# output dir for junit reports +junit.reports = test +junit.output = true +junit.forked.VM.maxmemory = 300m +# Converted junit tests from external testsuites +# reuire more memory, e g +# XSLTS requires 512m +# XQTS requires more than 400m +junit.forked.VM.maxmemory.external = 512m +proxy.nonproxyhosts = +proxy.host = +proxy.port = 0 +proxy.password = +proxy.user = +proxy.socks.host = +proxy.socks.port = 0 +#proxy.ntlm.domain = + +# Ant +tools.ant = ./tools/ant + +#aspectj +tools.aspectj = ./tools/aspectj + +# Common libs +lib.core = ./lib/core +lib.optional = ./lib/optional +lib.endorsed = ./lib/endorsed +lib.user = ./lib/user +lib.extensions = ./lib/extensions +lib.test = ./lib/test + +# antlr is only needed if you change the XPath/XQuery parser +# set these properties to true to get a lot of debugging output +antlr.traceParser = false +antlr.traceLexer = false +antlr.traceTreeWalker = false + +# IZPack is required to create the installer package. +# We currently require IzPack 4.3.5. The Izpack 5.0 beta does NOT work. +# If you change this property value for a reason, +# please use a version indicator in directory name, +# eg /izpack-dir-path/izpack-5.0-beta-11. +# You might need to change PermSpace to atleast 84 MB eg -XX:MaxPermSize=84m +# If you only want to point to your own izpack installation directory +# add this in local.build.properties instead so you don't commit it by mistake. +izpack.dir = /Applications/IzPack/ + +# Launch4J is required to create the windows installer +# If you change this property value for a reason, +# please use a version indicator in directory name, +# eg /launch4j-dir-path/launch4j-x.x.x. +# If you only want to point to your own launch4j installation directory +# add this in local.build.properties instead so you don't commit it by mistake. +launch4j.dir = /Applications/launch4j/ diff --git a/build.xml b/build.xml index fabcecaa454..eee82a6c196 100644 --- a/build.xml +++ b/build.xml @@ -1,35 +1,35 @@ - - - - - - - - eXist Open Source Native XML Database - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + eXist Open Source Native XML Database + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/scripts/demoserver.xml b/build/scripts/demoserver.xml index db66eb53ce3..18ef690b51b 100644 --- a/build/scripts/demoserver.xml +++ b/build/scripts/demoserver.xml @@ -1,296 +1,296 @@ - - - - - - - - - - Create HTML files for docs on http://exist-db.org - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Removed cocoon - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + Create HTML files for docs on http://exist-db.org + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Removed cocoon + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/scripts/dist-war-conf.xsl b/build/scripts/dist-war-conf.xsl index 4c1256e1035..81e0caccec5 100644 --- a/build/scripts/dist-war-conf.xsl +++ b/build/scripts/dist-war-conf.xsl @@ -1,26 +1,26 @@ - - - - - - - - - data - - - - data - - - - catalog.xml - - - - - - - - - + + + + + + + + + data + + + + data + + + + catalog.xml + + + + + + + + + diff --git a/build/scripts/dist-war-log4j.xsl b/build/scripts/dist-war-log4j.xsl index 8f8ab6f23a0..3977f49a590 100644 --- a/build/scripts/dist-war-log4j.xsl +++ b/build/scripts/dist-war-log4j.xsl @@ -1,21 +1,21 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/build/scripts/dist.xml b/build/scripts/dist.xml index bcef3217020..f3d2f4c438d 100644 --- a/build/scripts/dist.xml +++ b/build/scripts/dist.xml @@ -1,330 +1,330 @@ - - - - - Create eXist-db distribution - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + Create eXist-db distribution + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/scripts/installer.xml b/build/scripts/installer.xml index 59005a0ffd6..27b7ea52af8 100644 --- a/build/scripts/installer.xml +++ b/build/scripts/installer.xml @@ -1,220 +1,220 @@ - - - - - - - - Build installer - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + Build installer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/scripts/jarsigner.xml b/build/scripts/jarsigner.xml index 4d7b52e76c7..b2c0e6f9e4f 100644 --- a/build/scripts/jarsigner.xml +++ b/build/scripts/jarsigner.xml @@ -1,173 +1,173 @@ - - - - - Sign jarfiles for eXist webstart application - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This target has been deprecated, please use 'jnlp-all' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + Sign jarfiles for eXist webstart application + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This target has been deprecated, please use 'jnlp-all' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/scripts/quality.xml b/build/scripts/quality.xml index b9141502547..0c4b4cec254 100644 --- a/build/scripts/quality.xml +++ b/build/scripts/quality.xml @@ -1,124 +1,124 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Eclipse Public License - v 1.0

- -

THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE -PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR -DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS -AGREEMENT.

- -

1. DEFINITIONS

- -

"Contribution" means:

- -

a) in the case of the initial Contributor, the initial -code and documentation distributed under this Agreement, and

-

b) in the case of each subsequent Contributor:

-

i) changes to the Program, and

-

ii) additions to the Program;

-

where such changes and/or additions to the Program -originate from and are distributed by that particular Contributor. A -Contribution 'originates' from a Contributor if it was added to the -Program by such Contributor itself or anyone acting on such -Contributor's behalf. Contributions do not include additions to the -Program which: (i) are separate modules of software distributed in -conjunction with the Program under their own license agreement, and (ii) -are not derivative works of the Program.

- -

"Contributor" means any person or entity that distributes -the Program.

- -

"Licensed Patents" mean patent claims licensable by a -Contributor which are necessarily infringed by the use or sale of its -Contribution alone or when combined with the Program.

- -

"Program" means the Contributions distributed in accordance -with this Agreement.

- -

"Recipient" means anyone who receives the Program under -this Agreement, including all Contributors.

- -

2. GRANT OF RIGHTS

- -

a) Subject to the terms of this Agreement, each -Contributor hereby grants Recipient a non-exclusive, worldwide, -royalty-free copyright license to reproduce, prepare derivative works -of, publicly display, publicly perform, distribute and sublicense the -Contribution of such Contributor, if any, and such derivative works, in -source code and object code form.

- -

b) Subject to the terms of this Agreement, each -Contributor hereby grants Recipient a non-exclusive, worldwide, -royalty-free patent license under Licensed Patents to make, use, sell, -offer to sell, import and otherwise transfer the Contribution of such -Contributor, if any, in source code and object code form. This patent -license shall apply to the combination of the Contribution and the -Program if, at the time the Contribution is added by the Contributor, -such addition of the Contribution causes such combination to be covered -by the Licensed Patents. The patent license shall not apply to any other -combinations which include the Contribution. No hardware per se is -licensed hereunder.

- -

c) Recipient understands that although each Contributor -grants the licenses to its Contributions set forth herein, no assurances -are provided by any Contributor that the Program does not infringe the -patent or other intellectual property rights of any other entity. Each -Contributor disclaims any liability to Recipient for claims brought by -any other entity based on infringement of intellectual property rights -or otherwise. As a condition to exercising the rights and licenses -granted hereunder, each Recipient hereby assumes sole responsibility to -secure any other intellectual property rights needed, if any. For -example, if a third party patent license is required to allow Recipient -to distribute the Program, it is Recipient's responsibility to acquire -that license before distributing the Program.

- -

d) Each Contributor represents that to its knowledge it -has sufficient copyright rights in its Contribution, if any, to grant -the copyright license set forth in this Agreement.

- -

3. REQUIREMENTS

- -

A Contributor may choose to distribute the Program in object code -form under its own license agreement, provided that:

- -

a) it complies with the terms and conditions of this -Agreement; and

- -

b) its license agreement:

- -

i) effectively disclaims on behalf of all Contributors -all warranties and conditions, express and implied, including warranties -or conditions of title and non-infringement, and implied warranties or -conditions of merchantability and fitness for a particular purpose;

- -

ii) effectively excludes on behalf of all Contributors -all liability for damages, including direct, indirect, special, -incidental and consequential damages, such as lost profits;

- -

iii) states that any provisions which differ from this -Agreement are offered by that Contributor alone and not by any other -party; and

- -

iv) states that source code for the Program is available -from such Contributor, and informs licensees how to obtain it in a -reasonable manner on or through a medium customarily used for software -exchange.

- -

When the Program is made available in source code form:

- -

a) it must be made available under this Agreement; and

- -

b) a copy of this Agreement must be included with each -copy of the Program.

- -

Contributors may not remove or alter any copyright notices contained -within the Program.

- -

Each Contributor must identify itself as the originator of its -Contribution, if any, in a manner that reasonably allows subsequent -Recipients to identify the originator of the Contribution.

- -

4. COMMERCIAL DISTRIBUTION

- -

Commercial distributors of software may accept certain -responsibilities with respect to end users, business partners and the -like. While this license is intended to facilitate the commercial use of -the Program, the Contributor who includes the Program in a commercial -product offering should do so in a manner which does not create -potential liability for other Contributors. Therefore, if a Contributor -includes the Program in a commercial product offering, such Contributor -("Commercial Contributor") hereby agrees to defend and -indemnify every other Contributor ("Indemnified Contributor") -against any losses, damages and costs (collectively "Losses") -arising from claims, lawsuits and other legal actions brought by a third -party against the Indemnified Contributor to the extent caused by the -acts or omissions of such Commercial Contributor in connection with its -distribution of the Program in a commercial product offering. The -obligations in this section do not apply to any claims or Losses -relating to any actual or alleged intellectual property infringement. In -order to qualify, an Indemnified Contributor must: a) promptly notify -the Commercial Contributor in writing of such claim, and b) allow the -Commercial Contributor to control, and cooperate with the Commercial -Contributor in, the defense and any related settlement negotiations. The -Indemnified Contributor may participate in any such claim at its own -expense.

- -

For example, a Contributor might include the Program in a commercial -product offering, Product X. That Contributor is then a Commercial -Contributor. If that Commercial Contributor then makes performance -claims, or offers warranties related to Product X, those performance -claims and warranties are such Commercial Contributor's responsibility -alone. Under this section, the Commercial Contributor would have to -defend claims against the other Contributors related to those -performance claims and warranties, and if a court requires any other -Contributor to pay any damages as a result, the Commercial Contributor -must pay those damages.

- -

5. NO WARRANTY

- -

EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS -PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS -OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, -ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY -OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely -responsible for determining the appropriateness of using and -distributing the Program and assumes all risks associated with its -exercise of rights under this Agreement , including but not limited to -the risks and costs of program errors, compliance with applicable laws, -damage to or loss of data, programs or equipment, and unavailability or -interruption of operations.

- -

6. DISCLAIMER OF LIABILITY

- -

EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT -NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING -WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR -DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED -HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

- -

7. GENERAL

- -

If any provision of this Agreement is invalid or unenforceable under -applicable law, it shall not affect the validity or enforceability of -the remainder of the terms of this Agreement, and without further action -by the parties hereto, such provision shall be reformed to the minimum -extent necessary to make such provision valid and enforceable.

- -

If Recipient institutes patent litigation against any entity -(including a cross-claim or counterclaim in a lawsuit) alleging that the -Program itself (excluding combinations of the Program with other -software or hardware) infringes such Recipient's patent(s), then such -Recipient's rights granted under Section 2(b) shall terminate as of the -date such litigation is filed.

- -

All Recipient's rights under this Agreement shall terminate if it -fails to comply with any of the material terms or conditions of this -Agreement and does not cure such failure in a reasonable period of time -after becoming aware of such noncompliance. If all Recipient's rights -under this Agreement terminate, Recipient agrees to cease use and -distribution of the Program as soon as reasonably practicable. However, -Recipient's obligations under this Agreement and any licenses granted by -Recipient relating to the Program shall continue and survive.

- -

Everyone is permitted to copy and distribute copies of this -Agreement, but in order to avoid inconsistency the Agreement is -copyrighted and may only be modified in the following manner. The -Agreement Steward reserves the right to publish new versions (including -revisions) of this Agreement from time to time. No one other than the -Agreement Steward has the right to modify this Agreement. The Eclipse -Foundation is the initial Agreement Steward. The Eclipse Foundation may -assign the responsibility to serve as the Agreement Steward to a -suitable separate entity. Each new version of the Agreement will be -given a distinguishing version number. The Program (including -Contributions) may always be distributed subject to the version of the -Agreement under which it was received. In addition, after a new version -of the Agreement is published, Contributor may elect to distribute the -Program (including its Contributions) under the new version. Except as -expressly stated in Sections 2(a) and 2(b) above, Recipient receives no -rights or licenses to the intellectual property of any Contributor under -this Agreement, whether expressly, by implication, estoppel or -otherwise. All rights in the Program not expressly granted under this -Agreement are reserved.

- -

This Agreement is governed by the laws of the State of New York and -the intellectual property laws of the United States of America. No party -to this Agreement will bring a legal action under this Agreement more -than one year after the cause of action arose. Each party waives its -rights to a jury trial in any resulting litigation.

- - - - + + + + + + +Eclipse Public License - Version 1.0 + + + + + + +

Eclipse Public License - v 1.0

+ +

THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE +PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR +DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS +AGREEMENT.

+ +

1. DEFINITIONS

+ +

"Contribution" means:

+ +

a) in the case of the initial Contributor, the initial +code and documentation distributed under this Agreement, and

+

b) in the case of each subsequent Contributor:

+

i) changes to the Program, and

+

ii) additions to the Program;

+

where such changes and/or additions to the Program +originate from and are distributed by that particular Contributor. A +Contribution 'originates' from a Contributor if it was added to the +Program by such Contributor itself or anyone acting on such +Contributor's behalf. Contributions do not include additions to the +Program which: (i) are separate modules of software distributed in +conjunction with the Program under their own license agreement, and (ii) +are not derivative works of the Program.

+ +

"Contributor" means any person or entity that distributes +the Program.

+ +

"Licensed Patents" mean patent claims licensable by a +Contributor which are necessarily infringed by the use or sale of its +Contribution alone or when combined with the Program.

+ +

"Program" means the Contributions distributed in accordance +with this Agreement.

+ +

"Recipient" means anyone who receives the Program under +this Agreement, including all Contributors.

+ +

2. GRANT OF RIGHTS

+ +

a) Subject to the terms of this Agreement, each +Contributor hereby grants Recipient a non-exclusive, worldwide, +royalty-free copyright license to reproduce, prepare derivative works +of, publicly display, publicly perform, distribute and sublicense the +Contribution of such Contributor, if any, and such derivative works, in +source code and object code form.

+ +

b) Subject to the terms of this Agreement, each +Contributor hereby grants Recipient a non-exclusive, worldwide, +royalty-free patent license under Licensed Patents to make, use, sell, +offer to sell, import and otherwise transfer the Contribution of such +Contributor, if any, in source code and object code form. This patent +license shall apply to the combination of the Contribution and the +Program if, at the time the Contribution is added by the Contributor, +such addition of the Contribution causes such combination to be covered +by the Licensed Patents. The patent license shall not apply to any other +combinations which include the Contribution. No hardware per se is +licensed hereunder.

+ +

c) Recipient understands that although each Contributor +grants the licenses to its Contributions set forth herein, no assurances +are provided by any Contributor that the Program does not infringe the +patent or other intellectual property rights of any other entity. Each +Contributor disclaims any liability to Recipient for claims brought by +any other entity based on infringement of intellectual property rights +or otherwise. As a condition to exercising the rights and licenses +granted hereunder, each Recipient hereby assumes sole responsibility to +secure any other intellectual property rights needed, if any. For +example, if a third party patent license is required to allow Recipient +to distribute the Program, it is Recipient's responsibility to acquire +that license before distributing the Program.

+ +

d) Each Contributor represents that to its knowledge it +has sufficient copyright rights in its Contribution, if any, to grant +the copyright license set forth in this Agreement.

+ +

3. REQUIREMENTS

+ +

A Contributor may choose to distribute the Program in object code +form under its own license agreement, provided that:

+ +

a) it complies with the terms and conditions of this +Agreement; and

+ +

b) its license agreement:

+ +

i) effectively disclaims on behalf of all Contributors +all warranties and conditions, express and implied, including warranties +or conditions of title and non-infringement, and implied warranties or +conditions of merchantability and fitness for a particular purpose;

+ +

ii) effectively excludes on behalf of all Contributors +all liability for damages, including direct, indirect, special, +incidental and consequential damages, such as lost profits;

+ +

iii) states that any provisions which differ from this +Agreement are offered by that Contributor alone and not by any other +party; and

+ +

iv) states that source code for the Program is available +from such Contributor, and informs licensees how to obtain it in a +reasonable manner on or through a medium customarily used for software +exchange.

+ +

When the Program is made available in source code form:

+ +

a) it must be made available under this Agreement; and

+ +

b) a copy of this Agreement must be included with each +copy of the Program.

+ +

Contributors may not remove or alter any copyright notices contained +within the Program.

+ +

Each Contributor must identify itself as the originator of its +Contribution, if any, in a manner that reasonably allows subsequent +Recipients to identify the originator of the Contribution.

+ +

4. COMMERCIAL DISTRIBUTION

+ +

Commercial distributors of software may accept certain +responsibilities with respect to end users, business partners and the +like. While this license is intended to facilitate the commercial use of +the Program, the Contributor who includes the Program in a commercial +product offering should do so in a manner which does not create +potential liability for other Contributors. Therefore, if a Contributor +includes the Program in a commercial product offering, such Contributor +("Commercial Contributor") hereby agrees to defend and +indemnify every other Contributor ("Indemnified Contributor") +against any losses, damages and costs (collectively "Losses") +arising from claims, lawsuits and other legal actions brought by a third +party against the Indemnified Contributor to the extent caused by the +acts or omissions of such Commercial Contributor in connection with its +distribution of the Program in a commercial product offering. The +obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In +order to qualify, an Indemnified Contributor must: a) promptly notify +the Commercial Contributor in writing of such claim, and b) allow the +Commercial Contributor to control, and cooperate with the Commercial +Contributor in, the defense and any related settlement negotiations. The +Indemnified Contributor may participate in any such claim at its own +expense.

+ +

For example, a Contributor might include the Program in a commercial +product offering, Product X. That Contributor is then a Commercial +Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance +claims and warranties are such Commercial Contributor's responsibility +alone. Under this section, the Commercial Contributor would have to +defend claims against the other Contributors related to those +performance claims and warranties, and if a court requires any other +Contributor to pay any damages as a result, the Commercial Contributor +must pay those damages.

+ +

5. NO WARRANTY

+ +

EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS +PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS +OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, +ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY +OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and +distributing the Program and assumes all risks associated with its +exercise of rights under this Agreement , including but not limited to +the risks and costs of program errors, compliance with applicable laws, +damage to or loss of data, programs or equipment, and unavailability or +interruption of operations.

+ +

6. DISCLAIMER OF LIABILITY

+ +

EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT +NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING +WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR +DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED +HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

+ +

7. GENERAL

+ +

If any provision of this Agreement is invalid or unenforceable under +applicable law, it shall not affect the validity or enforceability of +the remainder of the terms of this Agreement, and without further action +by the parties hereto, such provision shall be reformed to the minimum +extent necessary to make such provision valid and enforceable.

+ +

If Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that the +Program itself (excluding combinations of the Program with other +software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of the +date such litigation is filed.

+ +

All Recipient's rights under this Agreement shall terminate if it +fails to comply with any of the material terms or conditions of this +Agreement and does not cure such failure in a reasonable period of time +after becoming aware of such noncompliance. If all Recipient's rights +under this Agreement terminate, Recipient agrees to cease use and +distribution of the Program as soon as reasonably practicable. However, +Recipient's obligations under this Agreement and any licenses granted by +Recipient relating to the Program shall continue and survive.

+ +

Everyone is permitted to copy and distribute copies of this +Agreement, but in order to avoid inconsistency the Agreement is +copyrighted and may only be modified in the following manner. The +Agreement Steward reserves the right to publish new versions (including +revisions) of this Agreement from time to time. No one other than the +Agreement Steward has the right to modify this Agreement. The Eclipse +Foundation is the initial Agreement Steward. The Eclipse Foundation may +assign the responsibility to serve as the Agreement Steward to a +suitable separate entity. Each new version of the Agreement will be +given a distinguishing version number. The Program (including +Contributions) may always be distributed subject to the version of the +Agreement under which it was received. In addition, after a new version +of the Agreement is published, Contributor may elect to distribute the +Program (including its Contributions) under the new version. Except as +expressly stated in Sections 2(a) and 2(b) above, Recipient receives no +rights or licenses to the intellectual property of any Contributor under +this Agreement, whether expressly, by implication, estoppel or +otherwise. All rights in the Program not expressly granted under this +Agreement are reserved.

+ +

This Agreement is governed by the laws of the State of New York and +the intellectual property laws of the United States of America. No party +to this Agreement will bring a legal action under this Agreement more +than one year after the cause of action arose. Each party waives its +rights to a jury trial in any resulting litigation.

+ + + + diff --git a/lib/core/commons-codec-LICENSE.txt b/lib/core/commons-codec-LICENSE.txt index d6456956733..75b52484ea4 100644 --- a/lib/core/commons-codec-LICENSE.txt +++ b/lib/core/commons-codec-LICENSE.txt @@ -1,202 +1,202 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/lib/core/commons-collections-LICENSE.txt b/lib/core/commons-collections-LICENSE.txt index d6456956733..75b52484ea4 100644 --- a/lib/core/commons-collections-LICENSE.txt +++ b/lib/core/commons-collections-LICENSE.txt @@ -1,202 +1,202 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/lib/core/commons-collections-NOTICE.txt b/lib/core/commons-collections-NOTICE.txt index a9e0fff6c71..c361a5df0a1 100644 --- a/lib/core/commons-collections-NOTICE.txt +++ b/lib/core/commons-collections-NOTICE.txt @@ -1,5 +1,5 @@ -Apache Commons Collections -Copyright 2001-2008 The Apache Software Foundation - -This product includes software developed by -The Apache Software Foundation (http://www.apache.org/). +Apache Commons Collections +Copyright 2001-2008 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). diff --git a/lib/core/commons-io-LICENSE.txt b/lib/core/commons-io-LICENSE.txt index 6b0b1270ff0..43e91eb0b0d 100644 --- a/lib/core/commons-io-LICENSE.txt +++ b/lib/core/commons-io-LICENSE.txt @@ -1,203 +1,203 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/lib/core/commons-io-NOTICE.txt b/lib/core/commons-io-NOTICE.txt index f9e09a55ba7..c482abe6643 100644 --- a/lib/core/commons-io-NOTICE.txt +++ b/lib/core/commons-io-NOTICE.txt @@ -1,6 +1,6 @@ -Apache Commons IO -Copyright 2001-2008 The Apache Software Foundation - -This product includes software developed by -The Apache Software Foundation (http://www.apache.org/). - +Apache Commons IO +Copyright 2001-2008 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/lib/core/commons-logging-LICENSE.txt b/lib/core/commons-logging-LICENSE.txt index d6456956733..75b52484ea4 100644 --- a/lib/core/commons-logging-LICENSE.txt +++ b/lib/core/commons-logging-LICENSE.txt @@ -1,202 +1,202 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/lib/core/commons-logging-NOTICE.txt b/lib/core/commons-logging-NOTICE.txt index 53a733a6790..5554dfcaad7 100644 --- a/lib/core/commons-logging-NOTICE.txt +++ b/lib/core/commons-logging-NOTICE.txt @@ -1,6 +1,6 @@ -Apache Commons Logging -Copyright 2003-2007 The Apache Software Foundation - -This product includes software developed by -The Apache Software Foundation (http://www.apache.org/). - +Apache Commons Logging +Copyright 2003-2007 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/lib/core/excalibur-cli-LICENSE.txt b/lib/core/excalibur-cli-LICENSE.txt index 975c6ed5db2..99c1d1a1f01 100644 --- a/lib/core/excalibur-cli-LICENSE.txt +++ b/lib/core/excalibur-cli-LICENSE.txt @@ -1,50 +1,50 @@ -/* - - ============================================================================ - The Apache Software License, Version 1.1 - ============================================================================ - - Copyright (C) 2000-2002 The Apache Software Foundation. All rights reserved. - - Redistribution and use in source and binary forms, with or without modifica- - tion, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - 3. The end-user documentation included with the redistribution, if any, must - include the following acknowledgment: "This product includes software - developed by the Apache Software Foundation (http://www.apache.org/)." - Alternately, this acknowledgment may appear in the software itself, if - and wherever such third-party acknowledgments normally appear. - - 4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation" - must not be used to endorse or promote products derived from this software - without prior written permission. For written permission, please contact - apache@apache.org. - - 5. Products derived from this software may not be called "Apache", nor may - "Apache" appear in their name, without prior written permission of the - Apache Software Foundation. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- - DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This software consists of voluntary contributions made by many individuals - on behalf of the Apache Software Foundation and was originally created by - Stefano Mazzocchi . For more information on the Apache - Software Foundation, please see . - -*/ +/* + + ============================================================================ + The Apache Software License, Version 1.1 + ============================================================================ + + Copyright (C) 2000-2002 The Apache Software Foundation. All rights reserved. + + Redistribution and use in source and binary forms, with or without modifica- + tion, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + 3. The end-user documentation included with the redistribution, if any, must + include the following acknowledgment: "This product includes software + developed by the Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowledgment may appear in the software itself, if + and wherever such third-party acknowledgments normally appear. + + 4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation" + must not be used to endorse or promote products derived from this software + without prior written permission. For written permission, please contact + apache@apache.org. + + 5. Products derived from this software may not be called "Apache", nor may + "Apache" appear in their name, without prior written permission of the + Apache Software Foundation. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + This software consists of voluntary contributions made by many individuals + on behalf of the Apache Software Foundation and was originally created by + Stefano Mazzocchi . For more information on the Apache + Software Foundation, please see . + +*/ diff --git a/lib/core/slf4j-LICENSE.txt b/lib/core/slf4j-LICENSE.txt index 48b18e39c79..f1c9e37074a 100644 --- a/lib/core/slf4j-LICENSE.txt +++ b/lib/core/slf4j-LICENSE.txt @@ -1,24 +1,24 @@ -Copyright (c) 2004-2008 QOS.ch -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - - +Copyright (c) 2004-2008 QOS.ch +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + + diff --git a/lib/endorsed/saxonhe-LICENSE.txt b/lib/endorsed/saxonhe-LICENSE.txt index 331abb17ff0..c57dd4c1949 100644 --- a/lib/endorsed/saxonhe-LICENSE.txt +++ b/lib/endorsed/saxonhe-LICENSE.txt @@ -1,15 +1,15 @@ -The contents of these file are subject to the Mozilla Public License Version 1.0 (the "License"); -you may not use these files except in compliance with the License. You may obtain a copy of the -License at http://www.mozilla.org/MPL/ - -Software distributed under the License is distributed on an "AS IS" basis, -WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the -specific language governing rights and limitations under the License. - -The Original Code is all Saxon modules labelled with a notice referring to this license. - -The Initial Developer of the Original Code is Michael Kay, except where otherwise specified in an individual module. - -Portions created by other named contributors are copyright as identified in the relevant module. All Rights Reserved. - +The contents of these file are subject to the Mozilla Public License Version 1.0 (the "License"); +you may not use these files except in compliance with the License. You may obtain a copy of the +License at http://www.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" basis, +WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the +specific language governing rights and limitations under the License. + +The Original Code is all Saxon modules labelled with a notice referring to this license. + +The Initial Developer of the Original Code is Michael Kay, except where otherwise specified in an individual module. + +Portions created by other named contributors are copyright as identified in the relevant module. All Rights Reserved. + Contributor(s) are listed in the documentation: see notices/contributors. \ No newline at end of file diff --git a/lib/endorsed/serializer-LICENSE.txt b/lib/endorsed/serializer-LICENSE.txt index 261eeb9e9f8..29f81d812f3 100644 --- a/lib/endorsed/serializer-LICENSE.txt +++ b/lib/endorsed/serializer-LICENSE.txt @@ -1,201 +1,201 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/lib/endorsed/serializer-NOTICE.txt b/lib/endorsed/serializer-NOTICE.txt index c4458581227..33369d0a655 100644 --- a/lib/endorsed/serializer-NOTICE.txt +++ b/lib/endorsed/serializer-NOTICE.txt @@ -1,18 +1,18 @@ - ========================================================================= - == NOTICE file corresponding to section 4(d) of the Apache License, == - == Version 2.0, in this case for the Apache Xalan Java distribution. == - ========================================================================= - - Apache Xalan (Xalan serializer) - Copyright 1999-2006 The Apache Software Foundation - - This product includes software developed at - The Apache Software Foundation (http://www.apache.org/). - - Portions of this software was originally based on the following: - - software copyright (c) 1999-2002, Lotus Development Corporation., - http://www.lotus.com. - - software copyright (c) 2001-2002, Sun Microsystems., - http://www.sun.com. - - software copyright (c) 2003, IBM Corporation., - http://www.ibm.com. + ========================================================================= + == NOTICE file corresponding to section 4(d) of the Apache License, == + == Version 2.0, in this case for the Apache Xalan Java distribution. == + ========================================================================= + + Apache Xalan (Xalan serializer) + Copyright 1999-2006 The Apache Software Foundation + + This product includes software developed at + The Apache Software Foundation (http://www.apache.org/). + + Portions of this software was originally based on the following: + - software copyright (c) 1999-2002, Lotus Development Corporation., + http://www.lotus.com. + - software copyright (c) 2001-2002, Sun Microsystems., + http://www.sun.com. + - software copyright (c) 2003, IBM Corporation., + http://www.ibm.com. diff --git a/lib/endorsed/xalan-LICENSE.txt b/lib/endorsed/xalan-LICENSE.txt index bfb7af06d23..762701ce936 100644 --- a/lib/endorsed/xalan-LICENSE.txt +++ b/lib/endorsed/xalan-LICENSE.txt @@ -1,684 +1,684 @@ -<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - -The license above applies to this Apache Xalan release of: - Xalan-Java 2 - XSLT Processor - Xalan-Java 2 - Serializer - -The license above also applies to the jar files -xalan.jar and xsltc.jar - Xalan-Java 2 - XSLT Processor from -Source: http://xalan.apache.org/ - -The license above also applies to the jar file -serializer.jar - Xalan-Java 2 - Serializer -Source: http://xalan.apache.org/ -Used by: Xalan-Java 2 and Xerces-Java 2 - -The license above also applies to the jar file -xercesImpl.jar - Xerces-Java 2 XML Parser. -Source: http://xerces.apache.org/ -Used by: Xalan-Java 2 - -The license above also applies to the jar file -xml-apis.jar - Xerces-Java 2 XML Parser. -Source: http://xerces.apache.org/ -Used by: Xalan-Java 2 and release copy of Xerces-Java 2 - - - - - - - - -The following license applies to the included files: - tools/ant.jar - tools/antRun - tools/antRun.bat -Source: http://ant.apache.org/ -Used By: Xalan's build process: java/build.xml and test/build.xml - -<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -/* - * ============================================================================ - * The Apache Software License, Version 1.1 - * ============================================================================ - * - * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modifica- - * tion, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. The end-user documentation included with the redistribution, if any, must - * include the following acknowledgment: "This product includes software - * developed by the Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, if - * and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Ant" and "Apache Software Foundation" must not be used to - * endorse or promote products derived from this software without prior - * written permission. For written permission, please contact - * apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", nor may - * "Apache" appear in their name, without prior written permission of the - * Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- - * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This software consists of voluntary contributions made by many individuals - * on behalf of the Apache Software Foundation. For more information on the - * Apache Software Foundation, please see . - * - */ ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - - - - - -The following license, Apache Software License, Version 1.1, -applies to the included BCEL.jar from Apache Jakarta -(Byte Code Engineering Library). -Source: http://jakarta.apache.org/bcel -Used By: XSLTC component of xml-xalan/java - -The following license, Apache Software License, Version 1.1, -also applies to the included regexp.jar, -jakarta-regexp-1.2.jar from Apache Jakarta. -Source: http://jakarta.apache.org/regexp -Used By: BCEL.jar which is used by XSLTC component of xml-xalan/java - -<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -/* - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache BCEL" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * "Apache BCEL", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - - - - - -The following license applies to the DOM documentation -for the org.w3c.dom.* packages: - -<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -W3C® DOCUMENT LICENSE -http://www.w3.org/Consortium/Legal/2002/copyright-documents-20021231 -Public documents on the W3C site are provided by the copyright holders -under the following license. By using and/or copying this document, -or the W3C document from which this statement is linked, you (the licensee) -agree that you have read, understood, and will comply with the following -terms and conditions: - -Permission to copy, and distribute the contents of this document, or the -W3C document from which this statement is linked, in any medium for any -purpose and without fee or royalty is hereby granted, provided that you include -the following on ALL copies of the document, or portions thereof, that you use: - -1. A link or URL to the original W3C document. -2. The pre-existing copyright notice of the original author, or if it - doesn't exist, a notice (hypertext is preferred, but a textual representation - is permitted) of the form: "Copyright © [$date-of-document] World Wide Web - Consortium, (Massachusetts Institute of Technology, European Research - Consortium for Informatics and Mathematics, Keio University). All Rights - Reserved. http://www.w3.org/Consortium/Legal/2002/copyright-documents-20021231" -3. If it exists, the STATUS of the W3C document. - -When space permits, inclusion of the full text of this NOTICE should be provided. -We request that authorship attribution be provided in any software, documents, -or other items or products that you create pursuant to the implementation of the -contents of this document, or any portion thereof. - -No right to create modifications or derivatives of W3C documents is granted pursuant -to this license. However, if additional requirements (documented in the Copyright FAQ) -are satisfied, the right to create modifications or derivatives is sometimes granted -by the W3C to individuals complying with those requirements. - -THIS DOCUMENT IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS -OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, OR TITLE; -THAT THE CONTENTS OF THE DOCUMENT ARE SUITABLE FOR ANY PURPOSE; NOR THAT THE -IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY THIRD PARTY PATENTS, -COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. - -COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE DOCUMENT OR THE PERFORMANCE -OR IMPLEMENTATION OF THE CONTENTS THEREOF. - -The name and trademarks of copyright holders may NOT be used in advertising -or publicity pertaining to this document or its contents without specific, -written prior permission. Title to copyright in this document will at all -times remain with copyright holders. - - ----------------------------------------------------------------------------- - -This formulation of W3C's notice and license became active on December 31 2002. -This version removes the copyright ownership notice such that this license -can be used with materials other than those owned by the W3C, moves information -on style sheets, DTDs, and schemas to the Copyright FAQ, reflects that ERCIM -is now a host of the W3C, includes references to this specific dated version -of the license, and removes the ambiguous grant of "use". See the older -formulation for the policy prior to this date. Please see our Copyright FAQ for -common questions about using materials from our site, such as the translating -or annotating specifications. Other questions about this notice can be directed -to site-policy@w3.org. - - -Joseph Reagle >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - - - - - - -The following license applies to the DOM software, -for the org.w3c.dom.* packages in jar file xml-apis.jar: - -<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -W3C® SOFTWARE NOTICE AND LICENSE -http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 -This work (and included software, documentation such as READMEs, -or other related items) is being provided by the copyright holders -under the following license. By obtaining, using and/or copying this -work, you (the licensee) agree that you have read, understood, and will -comply with the following terms and conditions. - -Permission to copy, modify, and distribute this software and its -documentation, with or without modification, for any purpose and -without fee or royalty is hereby granted, provided that you include -the following on ALL copies of the software and documentation or -portions thereof, including modifications: - -1. The full text of this NOTICE in a location viewable to users of the - redistributed or derivative work. -2. Any pre-existing intellectual property disclaimers, notices, - or terms and conditions. If none exist, the W3C Software Short Notice - should be included (hypertext is preferred, text is permitted) within - the body of any redistributed or derivative code. -3. Notice of any changes or modifications to the files, including the - date changes were made. (We recommend you provide URIs to the location - from which the code is derived.) - -THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS -MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT -NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR -PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE -ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. - -COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION. - -The name and trademarks of copyright holders may NOT be used in advertising -or publicity pertaining to the software without specific, written prior -permission. Title to copyright in this software and any associated documentation -will at all times remain with copyright holders. - - -____________________________________ - -This formulation of W3C's notice and license became active on December 31 2002. -This version removes the copyright ownership notice such that this license can -be used with materials other than those owned by the W3C, reflects that ERCIM -is now a host of the W3C, includes references to this specific dated version -of the license, and removes the ambiguous grant of "use". Otherwise, this -version is the same as the previous version and is written so as to preserve -the Free Software Foundation's assessment of GPL compatibility and OSI's -certification under the Open Source Definition. Please see our Copyright FAQ -for common questions about using materials from our site, including specific -terms and conditions for packages like libwww, Amaya, and Jigsaw. Other -questions about this notice can be directed to site-policy@w3.org. - - -Joseph Reagle >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - - - - - -The following license applies to the SAX software, -for the org.xml.sax.* packages in jar file xml-apis.jar: - -<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -This module, both source code and documentation, is in the Public Domain, -and comes with NO WARRANTY. See http://www.saxproject.org for further information. ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - - - - - -The following license applies to the jar file -java_cup.jar - LALR Parser Generator for Java(TM). -Source: http://www.cs.princeton.edu/~appel/modern/java/CUP -Used By: XSLTC component of xml-xalan/java - -<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -CUP Parser Generator Copyright Notice, License, and Disclaimer - -Copyright 1996-1999 by Scott Hudson, Frank Flannery, C. Scott Ananian - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, provided -that the above copyright notice appear in all copies and that both -the copyright notice and this permission notice and warranty disclaimer -appear in supporting documentation, and that the names of the authors -or their employers not be used in advertising or publicity pertaining -to distribution of the software without specific, written prior permission. - -The authors and their employers disclaim all warranties with regard to -this software, including all implied warranties of merchantability -and fitness. In no event shall the authors or their employers be liable -for any special, indirect or consequential damages or any damages -whatsoever resulting from loss of use, data or profits, whether in an action -of contract, negligence or other tortious action, arising out of or -in connection with the use or performance of this software. ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - - - - - -The following license applies to the jar file runtime.jar - Component -of JavaCup: LALR Parser Generator for Java(TM). -Source: http://www.cs.princeton.edu/~appel/modern/java/CUP -Used By: XSLTC component of xml-xalan/java - -<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -CUP Parser Generator Copyright Notice, License, and Disclaimer -(runtime.jar component) - -Copyright 1996-1999 by Scott Hudson, Frank Flannery, C. Scott Ananian - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, provided -that the above copyright notice appear in all copies and that both -the copyright notice and this permission notice and warranty disclaimer -appear in supporting documentation, and that the names of the authors -or their employers not be used in advertising or publicity pertaining -to distribution of the software without specific, written prior permission. - -The authors and their employers disclaim all warranties with regard to -this software, including all implied warranties of merchantability -and fitness. In no event shall the authors or their employers be liable -for any special, indirect or consequential damages or any damages -whatsoever resulting from loss of use, data or profits, whether in an action -of contract, negligence or other tortious action, arising out of or -in connection with the use or performance of this software. ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - - - - - -The following license applies to the JLEX jar file -JLex.jar - A Lexical Analyzer Generator for Java(TM). -Source: http://www.cs.princeton.edu/~appel/modern/java/JLex -Used By: XSLTC component of xml-xalan/java - -<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -JLEX COPYRIGHT NOTICE, LICENSE AND DISCLAIMER. - -Copyright 1996-2000 by Elliot Joel Berk and C. Scott Ananian - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and -that both the copyright notice and this permission notice and -warranty disclaimer appear in supporting documentation, and that the -name of the authors or their employers not be used in advertising or -publicity pertaining to distribution of the software without specific, -written prior permission. - -The authors and their employers disclaim all warranties with regard -to this software, including all implied warranties of merchantability and -fitness. In no event shall the authors or their employers be liable for any -special, indirect or consequential damages or any damages whatsoever resulting -from loss of use, data or profits, whether in an action of contract, -negligence or other tortious action, arising out of or in connection -with the use or performance of this software. - -Java is a trademark of Sun Microsystems, Inc. References to the Java -programming language in relation to JLex are not meant to imply that -Sun endorses this product. ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - - - - - -The following license applies to the jar file -stylebook-1.0-b3_xalan-2.jar - Tool for generating Xalan documentation. -Integrated with Xalan-Java 2 and Xerces 2. -Source: http://svn.apache.org/viewvc/xml/stylebook/ -Used by: Xalan-Java 2, Xalan-C++ - -<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -/* - * The Apache Software License, Version 1.1 - * - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Xalan", "Xerces", and "Apache Software Foundation" must - * not be used to endorse or promote products derived from this - * software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", - * nor may "Apache" appear in their name, without prior written - * permission of the Apache Software Foundation. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation and was - * originally based on software copyright (c) 1999, International - * Business Machines, Inc., http://www.apache.org. For more - * information on the Apache Software Foundation, please see - * . - */ ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + +The license above applies to this Apache Xalan release of: + Xalan-Java 2 - XSLT Processor + Xalan-Java 2 - Serializer + +The license above also applies to the jar files +xalan.jar and xsltc.jar - Xalan-Java 2 - XSLT Processor from +Source: http://xalan.apache.org/ + +The license above also applies to the jar file +serializer.jar - Xalan-Java 2 - Serializer +Source: http://xalan.apache.org/ +Used by: Xalan-Java 2 and Xerces-Java 2 + +The license above also applies to the jar file +xercesImpl.jar - Xerces-Java 2 XML Parser. +Source: http://xerces.apache.org/ +Used by: Xalan-Java 2 + +The license above also applies to the jar file +xml-apis.jar - Xerces-Java 2 XML Parser. +Source: http://xerces.apache.org/ +Used by: Xalan-Java 2 and release copy of Xerces-Java 2 + + + + + + + + +The following license applies to the included files: + tools/ant.jar + tools/antRun + tools/antRun.bat +Source: http://ant.apache.org/ +Used By: Xalan's build process: java/build.xml and test/build.xml + +<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +/* + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Ant" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation. For more information on the + * Apache Software Foundation, please see . + * + */ +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + + + + + +The following license, Apache Software License, Version 1.1, +applies to the included BCEL.jar from Apache Jakarta +(Byte Code Engineering Library). +Source: http://jakarta.apache.org/bcel +Used By: XSLTC component of xml-xalan/java + +The following license, Apache Software License, Version 1.1, +also applies to the included regexp.jar, +jakarta-regexp-1.2.jar from Apache Jakarta. +Source: http://jakarta.apache.org/regexp +Used By: BCEL.jar which is used by XSLTC component of xml-xalan/java + +<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +/* + * + * Copyright (c) 2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache BCEL" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache BCEL", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + + + + + +The following license applies to the DOM documentation +for the org.w3c.dom.* packages: + +<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +W3C® DOCUMENT LICENSE +http://www.w3.org/Consortium/Legal/2002/copyright-documents-20021231 +Public documents on the W3C site are provided by the copyright holders +under the following license. By using and/or copying this document, +or the W3C document from which this statement is linked, you (the licensee) +agree that you have read, understood, and will comply with the following +terms and conditions: + +Permission to copy, and distribute the contents of this document, or the +W3C document from which this statement is linked, in any medium for any +purpose and without fee or royalty is hereby granted, provided that you include +the following on ALL copies of the document, or portions thereof, that you use: + +1. A link or URL to the original W3C document. +2. The pre-existing copyright notice of the original author, or if it + doesn't exist, a notice (hypertext is preferred, but a textual representation + is permitted) of the form: "Copyright © [$date-of-document] World Wide Web + Consortium, (Massachusetts Institute of Technology, European Research + Consortium for Informatics and Mathematics, Keio University). All Rights + Reserved. http://www.w3.org/Consortium/Legal/2002/copyright-documents-20021231" +3. If it exists, the STATUS of the W3C document. + +When space permits, inclusion of the full text of this NOTICE should be provided. +We request that authorship attribution be provided in any software, documents, +or other items or products that you create pursuant to the implementation of the +contents of this document, or any portion thereof. + +No right to create modifications or derivatives of W3C documents is granted pursuant +to this license. However, if additional requirements (documented in the Copyright FAQ) +are satisfied, the right to create modifications or derivatives is sometimes granted +by the W3C to individuals complying with those requirements. + +THIS DOCUMENT IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS +OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, OR TITLE; +THAT THE CONTENTS OF THE DOCUMENT ARE SUITABLE FOR ANY PURPOSE; NOR THAT THE +IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY THIRD PARTY PATENTS, +COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. + +COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE DOCUMENT OR THE PERFORMANCE +OR IMPLEMENTATION OF THE CONTENTS THEREOF. + +The name and trademarks of copyright holders may NOT be used in advertising +or publicity pertaining to this document or its contents without specific, +written prior permission. Title to copyright in this document will at all +times remain with copyright holders. + + +---------------------------------------------------------------------------- + +This formulation of W3C's notice and license became active on December 31 2002. +This version removes the copyright ownership notice such that this license +can be used with materials other than those owned by the W3C, moves information +on style sheets, DTDs, and schemas to the Copyright FAQ, reflects that ERCIM +is now a host of the W3C, includes references to this specific dated version +of the license, and removes the ambiguous grant of "use". See the older +formulation for the policy prior to this date. Please see our Copyright FAQ for +common questions about using materials from our site, such as the translating +or annotating specifications. Other questions about this notice can be directed +to site-policy@w3.org. + + +Joseph Reagle >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + + + + + + +The following license applies to the DOM software, +for the org.w3c.dom.* packages in jar file xml-apis.jar: + +<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +W3C® SOFTWARE NOTICE AND LICENSE +http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 +This work (and included software, documentation such as READMEs, +or other related items) is being provided by the copyright holders +under the following license. By obtaining, using and/or copying this +work, you (the licensee) agree that you have read, understood, and will +comply with the following terms and conditions. + +Permission to copy, modify, and distribute this software and its +documentation, with or without modification, for any purpose and +without fee or royalty is hereby granted, provided that you include +the following on ALL copies of the software and documentation or +portions thereof, including modifications: + +1. The full text of this NOTICE in a location viewable to users of the + redistributed or derivative work. +2. Any pre-existing intellectual property disclaimers, notices, + or terms and conditions. If none exist, the W3C Software Short Notice + should be included (hypertext is preferred, text is permitted) within + the body of any redistributed or derivative code. +3. Notice of any changes or modifications to the files, including the + date changes were made. (We recommend you provide URIs to the location + from which the code is derived.) + +THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS +MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT +NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR +PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE +ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. + +COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION. + +The name and trademarks of copyright holders may NOT be used in advertising +or publicity pertaining to the software without specific, written prior +permission. Title to copyright in this software and any associated documentation +will at all times remain with copyright holders. + + +____________________________________ + +This formulation of W3C's notice and license became active on December 31 2002. +This version removes the copyright ownership notice such that this license can +be used with materials other than those owned by the W3C, reflects that ERCIM +is now a host of the W3C, includes references to this specific dated version +of the license, and removes the ambiguous grant of "use". Otherwise, this +version is the same as the previous version and is written so as to preserve +the Free Software Foundation's assessment of GPL compatibility and OSI's +certification under the Open Source Definition. Please see our Copyright FAQ +for common questions about using materials from our site, including specific +terms and conditions for packages like libwww, Amaya, and Jigsaw. Other +questions about this notice can be directed to site-policy@w3.org. + + +Joseph Reagle >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + + + + + +The following license applies to the SAX software, +for the org.xml.sax.* packages in jar file xml-apis.jar: + +<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +This module, both source code and documentation, is in the Public Domain, +and comes with NO WARRANTY. See http://www.saxproject.org for further information. +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + + + + + +The following license applies to the jar file +java_cup.jar - LALR Parser Generator for Java(TM). +Source: http://www.cs.princeton.edu/~appel/modern/java/CUP +Used By: XSLTC component of xml-xalan/java + +<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +CUP Parser Generator Copyright Notice, License, and Disclaimer + +Copyright 1996-1999 by Scott Hudson, Frank Flannery, C. Scott Ananian + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided +that the above copyright notice appear in all copies and that both +the copyright notice and this permission notice and warranty disclaimer +appear in supporting documentation, and that the names of the authors +or their employers not be used in advertising or publicity pertaining +to distribution of the software without specific, written prior permission. + +The authors and their employers disclaim all warranties with regard to +this software, including all implied warranties of merchantability +and fitness. In no event shall the authors or their employers be liable +for any special, indirect or consequential damages or any damages +whatsoever resulting from loss of use, data or profits, whether in an action +of contract, negligence or other tortious action, arising out of or +in connection with the use or performance of this software. +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + + + + + +The following license applies to the jar file runtime.jar - Component +of JavaCup: LALR Parser Generator for Java(TM). +Source: http://www.cs.princeton.edu/~appel/modern/java/CUP +Used By: XSLTC component of xml-xalan/java + +<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +CUP Parser Generator Copyright Notice, License, and Disclaimer +(runtime.jar component) + +Copyright 1996-1999 by Scott Hudson, Frank Flannery, C. Scott Ananian + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, provided +that the above copyright notice appear in all copies and that both +the copyright notice and this permission notice and warranty disclaimer +appear in supporting documentation, and that the names of the authors +or their employers not be used in advertising or publicity pertaining +to distribution of the software without specific, written prior permission. + +The authors and their employers disclaim all warranties with regard to +this software, including all implied warranties of merchantability +and fitness. In no event shall the authors or their employers be liable +for any special, indirect or consequential damages or any damages +whatsoever resulting from loss of use, data or profits, whether in an action +of contract, negligence or other tortious action, arising out of or +in connection with the use or performance of this software. +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + + + + + +The following license applies to the JLEX jar file +JLex.jar - A Lexical Analyzer Generator for Java(TM). +Source: http://www.cs.princeton.edu/~appel/modern/java/JLex +Used By: XSLTC component of xml-xalan/java + +<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +JLEX COPYRIGHT NOTICE, LICENSE AND DISCLAIMER. + +Copyright 1996-2000 by Elliot Joel Berk and C. Scott Ananian + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and +that both the copyright notice and this permission notice and +warranty disclaimer appear in supporting documentation, and that the +name of the authors or their employers not be used in advertising or +publicity pertaining to distribution of the software without specific, +written prior permission. + +The authors and their employers disclaim all warranties with regard +to this software, including all implied warranties of merchantability and +fitness. In no event shall the authors or their employers be liable for any +special, indirect or consequential damages or any damages whatsoever resulting +from loss of use, data or profits, whether in an action of contract, +negligence or other tortious action, arising out of or in connection +with the use or performance of this software. + +Java is a trademark of Sun Microsystems, Inc. References to the Java +programming language in relation to JLex are not meant to imply that +Sun endorses this product. +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + + + + + + + +The following license applies to the jar file +stylebook-1.0-b3_xalan-2.jar - Tool for generating Xalan documentation. +Integrated with Xalan-Java 2 and Xerces 2. +Source: http://svn.apache.org/viewvc/xml/stylebook/ +Used by: Xalan-Java 2, Xalan-C++ + +<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +/* + * The Apache Software License, Version 1.1 + * + * + * Copyright (c) 1999 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Xalan", "Xerces", and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation and was + * originally based on software copyright (c) 1999, International + * Business Machines, Inc., http://www.apache.org. For more + * information on the Apache Software Foundation, please see + * . + */ +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> diff --git a/lib/endorsed/xalan-NOTICE.txt b/lib/endorsed/xalan-NOTICE.txt index 097bafb405e..758cb806a5e 100644 --- a/lib/endorsed/xalan-NOTICE.txt +++ b/lib/endorsed/xalan-NOTICE.txt @@ -1,80 +1,80 @@ - ========================================================================= - == NOTICE file corresponding to section 4(d) of the Apache License, == - == Version 2.0, in this case for the Apache Xalan Java distribution. == - ========================================================================= - - Apache Xalan (Xalan XSLT processor) - Copyright 1999-2006 The Apache Software Foundation - - Apache Xalan (Xalan serializer) - Copyright 1999-2006 The Apache Software Foundation - - This product includes software developed at - The Apache Software Foundation (http://www.apache.org/). - - ========================================================================= - Portions of this software was originally based on the following: - - software copyright (c) 1999-2002, Lotus Development Corporation., - http://www.lotus.com. - - software copyright (c) 2001-2002, Sun Microsystems., - http://www.sun.com. - - software copyright (c) 2003, IBM Corporation., - http://www.ibm.com. - - ========================================================================= - The binary distribution package (ie. jars, samples and documentation) of - this product includes software developed by the following: - - - The Apache Software Foundation - - Xerces Java - see LICENSE.txt - - JAXP 1.3 APIs - see LICENSE.txt - - Bytecode Engineering Library - see LICENSE.txt - - Regular Expression - see LICENSE.txt - - - Scott Hudson, Frank Flannery, C. Scott Ananian - - CUP Parser Generator runtime (javacup\runtime) - see LICENSE.txt - - ========================================================================= - The source distribution package (ie. all source and tools required to build - Xalan Java) of this product includes software developed by the following: - - - The Apache Software Foundation - - Xerces Java - see LICENSE.txt - - JAXP 1.3 APIs - see LICENSE.txt - - Bytecode Engineering Library - see LICENSE.txt - - Regular Expression - see LICENSE.txt - - Ant - see LICENSE.txt - - Stylebook doc tool - see LICENSE.txt - - - Elliot Joel Berk and C. Scott Ananian - - Lexical Analyzer Generator (JLex) - see LICENSE.txt - - ========================================================================= - Apache Xerces Java - Copyright 1999-2006 The Apache Software Foundation - - This product includes software developed at - The Apache Software Foundation (http://www.apache.org/). - - Portions of Apache Xerces Java in xercesImpl.jar and xml-apis.jar - were originally based on the following: - - software copyright (c) 1999, IBM Corporation., http://www.ibm.com. - - software copyright (c) 1999, Sun Microsystems., http://www.sun.com. - - voluntary contributions made by Paul Eng on behalf of the - Apache Software Foundation that were originally developed at iClick, Inc., - software copyright (c) 1999. - - ========================================================================= - Apache xml-commons xml-apis (redistribution of xml-apis.jar) - - Apache XML Commons - Copyright 2001-2003,2006 The Apache Software Foundation. - - This product includes software developed at - The Apache Software Foundation (http://www.apache.org/). - - Portions of this software were originally based on the following: - - software copyright (c) 1999, IBM Corporation., http://www.ibm.com. - - software copyright (c) 1999, Sun Microsystems., http://www.sun.com. - - software copyright (c) 2000 World Wide Web Consortium, http://www.w3.org - + ========================================================================= + == NOTICE file corresponding to section 4(d) of the Apache License, == + == Version 2.0, in this case for the Apache Xalan Java distribution. == + ========================================================================= + + Apache Xalan (Xalan XSLT processor) + Copyright 1999-2006 The Apache Software Foundation + + Apache Xalan (Xalan serializer) + Copyright 1999-2006 The Apache Software Foundation + + This product includes software developed at + The Apache Software Foundation (http://www.apache.org/). + + ========================================================================= + Portions of this software was originally based on the following: + - software copyright (c) 1999-2002, Lotus Development Corporation., + http://www.lotus.com. + - software copyright (c) 2001-2002, Sun Microsystems., + http://www.sun.com. + - software copyright (c) 2003, IBM Corporation., + http://www.ibm.com. + + ========================================================================= + The binary distribution package (ie. jars, samples and documentation) of + this product includes software developed by the following: + + - The Apache Software Foundation + - Xerces Java - see LICENSE.txt + - JAXP 1.3 APIs - see LICENSE.txt + - Bytecode Engineering Library - see LICENSE.txt + - Regular Expression - see LICENSE.txt + + - Scott Hudson, Frank Flannery, C. Scott Ananian + - CUP Parser Generator runtime (javacup\runtime) - see LICENSE.txt + + ========================================================================= + The source distribution package (ie. all source and tools required to build + Xalan Java) of this product includes software developed by the following: + + - The Apache Software Foundation + - Xerces Java - see LICENSE.txt + - JAXP 1.3 APIs - see LICENSE.txt + - Bytecode Engineering Library - see LICENSE.txt + - Regular Expression - see LICENSE.txt + - Ant - see LICENSE.txt + - Stylebook doc tool - see LICENSE.txt + + - Elliot Joel Berk and C. Scott Ananian + - Lexical Analyzer Generator (JLex) - see LICENSE.txt + + ========================================================================= + Apache Xerces Java + Copyright 1999-2006 The Apache Software Foundation + + This product includes software developed at + The Apache Software Foundation (http://www.apache.org/). + + Portions of Apache Xerces Java in xercesImpl.jar and xml-apis.jar + were originally based on the following: + - software copyright (c) 1999, IBM Corporation., http://www.ibm.com. + - software copyright (c) 1999, Sun Microsystems., http://www.sun.com. + - voluntary contributions made by Paul Eng on behalf of the + Apache Software Foundation that were originally developed at iClick, Inc., + software copyright (c) 1999. + + ========================================================================= + Apache xml-commons xml-apis (redistribution of xml-apis.jar) + + Apache XML Commons + Copyright 2001-2003,2006 The Apache Software Foundation. + + This product includes software developed at + The Apache Software Foundation (http://www.apache.org/). + + Portions of this software were originally based on the following: + - software copyright (c) 1999, IBM Corporation., http://www.ibm.com. + - software copyright (c) 1999, Sun Microsystems., http://www.sun.com. + - software copyright (c) 2000 World Wide Web Consortium, http://www.w3.org + diff --git a/lib/endorsed/xercesImpl-LICENSE.txt b/lib/endorsed/xercesImpl-LICENSE.txt index d6456956733..75b52484ea4 100644 --- a/lib/endorsed/xercesImpl-LICENSE.txt +++ b/lib/endorsed/xercesImpl-LICENSE.txt @@ -1,202 +1,202 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/lib/endorsed/xercesImpl-NOTICE.txt b/lib/endorsed/xercesImpl-NOTICE.txt index 85e6e4eeeae..b79ac9570b7 100644 --- a/lib/endorsed/xercesImpl-NOTICE.txt +++ b/lib/endorsed/xercesImpl-NOTICE.txt @@ -1,17 +1,17 @@ - ========================================================================= - == NOTICE file corresponding to section 4(d) of the Apache License, == - == Version 2.0, in this case for the Apache Xerces Java distribution. == - ========================================================================= - - Apache Xerces Java - Copyright 1999-2010 The Apache Software Foundation - - This product includes software developed at - The Apache Software Foundation (http://www.apache.org/). - - Portions of this software were originally based on the following: - - software copyright (c) 1999, IBM Corporation., http://www.ibm.com. - - software copyright (c) 1999, Sun Microsystems., http://www.sun.com. - - voluntary contributions made by Paul Eng on behalf of the - Apache Software Foundation that were originally developed at iClick, Inc., + ========================================================================= + == NOTICE file corresponding to section 4(d) of the Apache License, == + == Version 2.0, in this case for the Apache Xerces Java distribution. == + ========================================================================= + + Apache Xerces Java + Copyright 1999-2010 The Apache Software Foundation + + This product includes software developed at + The Apache Software Foundation (http://www.apache.org/). + + Portions of this software were originally based on the following: + - software copyright (c) 1999, IBM Corporation., http://www.ibm.com. + - software copyright (c) 1999, Sun Microsystems., http://www.sun.com. + - voluntary contributions made by Paul Eng on behalf of the + Apache Software Foundation that were originally developed at iClick, Inc., software copyright (c) 1999. \ No newline at end of file diff --git a/lib/endorsed/xml-apis-LICENSE.txt b/lib/endorsed/xml-apis-LICENSE.txt index d6456956733..75b52484ea4 100644 --- a/lib/endorsed/xml-apis-LICENSE.txt +++ b/lib/endorsed/xml-apis-LICENSE.txt @@ -1,202 +1,202 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/lib/endorsed/xml-apis-NOTICE.txt b/lib/endorsed/xml-apis-NOTICE.txt index 6026b4f2776..9a05f3cb849 100644 --- a/lib/endorsed/xml-apis-NOTICE.txt +++ b/lib/endorsed/xml-apis-NOTICE.txt @@ -1,16 +1,16 @@ - ========================================================================= - == NOTICE file corresponding to section 4(d) of the Apache License, == - == Version 2.0, in this case for the Apache xml-commons xml-apis == - == distribution. == - ========================================================================= - - Apache XML Commons XML APIs - Copyright 1999-2009 The Apache Software Foundation. - - This product includes software developed at - The Apache Software Foundation (http://www.apache.org/). - - Portions of this software were originally based on the following: - - software copyright (c) 1999, IBM Corporation., http://www.ibm.com. - - software copyright (c) 1999, Sun Microsystems., http://www.sun.com. - - software copyright (c) 2000 World Wide Web Consortium, http://www.w3.org + ========================================================================= + == NOTICE file corresponding to section 4(d) of the Apache License, == + == Version 2.0, in this case for the Apache xml-commons xml-apis == + == distribution. == + ========================================================================= + + Apache XML Commons XML APIs + Copyright 1999-2009 The Apache Software Foundation. + + This product includes software developed at + The Apache Software Foundation (http://www.apache.org/). + + Portions of this software were originally based on the following: + - software copyright (c) 1999, IBM Corporation., http://www.ibm.com. + - software copyright (c) 1999, Sun Microsystems., http://www.sun.com. + - software copyright (c) 2000 World Wide Web Consortium, http://www.w3.org diff --git a/lib/endorsed/xml-resolver-LICENSE.txt b/lib/endorsed/xml-resolver-LICENSE.txt index 261eeb9e9f8..29f81d812f3 100644 --- a/lib/endorsed/xml-resolver-LICENSE.txt +++ b/lib/endorsed/xml-resolver-LICENSE.txt @@ -1,201 +1,201 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/lib/endorsed/xml-resolver-NOTICE.txt b/lib/endorsed/xml-resolver-NOTICE.txt index cf064e38169..214dadd56a3 100644 --- a/lib/endorsed/xml-resolver-NOTICE.txt +++ b/lib/endorsed/xml-resolver-NOTICE.txt @@ -1,9 +1,9 @@ -Apache XML Commons Resolver -Copyright 2006 The Apache Software Foundation. - -This product includes software developed at -The Apache Software Foundation http://www.apache.org/ - -Portions of this code are derived from classes placed in the -public domain by Arbortext on 10 Apr 2000. See: -http://www.arbortext.com/customer_support/updates_and_technical_notes/catalogs/docs/README.htm +Apache XML Commons Resolver +Copyright 2006 The Apache Software Foundation. + +This product includes software developed at +The Apache Software Foundation http://www.apache.org/ + +Portions of this code are derived from classes placed in the +public domain by Arbortext on 10 Apr 2000. See: +http://www.arbortext.com/customer_support/updates_and_technical_notes/catalogs/docs/README.htm diff --git a/lib/optional/commons-fileupload-LICENSE.txt b/lib/optional/commons-fileupload-LICENSE.txt index d6456956733..75b52484ea4 100644 --- a/lib/optional/commons-fileupload-LICENSE.txt +++ b/lib/optional/commons-fileupload-LICENSE.txt @@ -1,202 +1,202 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/lib/optional/commons-fileupload-NOTICE.txt b/lib/optional/commons-fileupload-NOTICE.txt index 416090ac0bb..f2da6077aa7 100644 --- a/lib/optional/commons-fileupload-NOTICE.txt +++ b/lib/optional/commons-fileupload-NOTICE.txt @@ -1,5 +1,5 @@ -Apache Commons FileUpload -Copyright 2002-2010 The Apache Software Foundation - -This product includes software developed by -The Apache Software Foundation (http://www.apache.org/). +Apache Commons FileUpload +Copyright 2002-2010 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). diff --git a/lib/optional/commons-httpclient-LICENSE.txt b/lib/optional/commons-httpclient-LICENSE.txt index d9a10c0d8e8..7cd40e552f4 100644 --- a/lib/optional/commons-httpclient-LICENSE.txt +++ b/lib/optional/commons-httpclient-LICENSE.txt @@ -1,176 +1,176 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/lib/optional/commons-httpclient-NOTICE.txt b/lib/optional/commons-httpclient-NOTICE.txt index 152a7800c41..c43210bb6df 100644 --- a/lib/optional/commons-httpclient-NOTICE.txt +++ b/lib/optional/commons-httpclient-NOTICE.txt @@ -1,5 +1,5 @@ -Apache Jakarta HttpClient -Copyright 1999-2007 The Apache Software Foundation - -This product includes software developed by -The Apache Software Foundation (http://www.apache.org/). +Apache Jakarta HttpClient +Copyright 1999-2007 The Apache Software Foundation + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). diff --git a/lib/optional/commons-lang-LICENSE.txt b/lib/optional/commons-lang-LICENSE.txt index d6456956733..75b52484ea4 100644 --- a/lib/optional/commons-lang-LICENSE.txt +++ b/lib/optional/commons-lang-LICENSE.txt @@ -1,202 +1,202 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/lib/optional/commons-net-LICENSE.txt b/lib/optional/commons-net-LICENSE.txt index d6456956733..75b52484ea4 100644 --- a/lib/optional/commons-net-LICENSE.txt +++ b/lib/optional/commons-net-LICENSE.txt @@ -1,202 +1,202 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/lib/optional/isorelax-LICENSE.txt b/lib/optional/isorelax-LICENSE.txt index 0b50a1a61c3..f63197d47d7 100644 --- a/lib/optional/isorelax-LICENSE.txt +++ b/lib/optional/isorelax-LICENSE.txt @@ -1,7 +1,7 @@ -Copyright (c) 2001-2002, SourceForge ISO-RELAX Project (ASAMI Tomoharu, Daisuke Okajima, Kohsuke Kawaguchi, and MURATA Makoto) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +Copyright (c) 2001-2002, SourceForge ISO-RELAX Project (ASAMI Tomoharu, Daisuke Okajima, Kohsuke Kawaguchi, and MURATA Makoto) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/lib/optional/jing-LICENSE.txt b/lib/optional/jing-LICENSE.txt index 3fe0aaa7fd7..ccc7e425ece 100644 --- a/lib/optional/jing-LICENSE.txt +++ b/lib/optional/jing-LICENSE.txt @@ -1,31 +1,31 @@ -Copyright (c) 2001-2003 Thai Open Source Software Center Ltd -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - Neither the name of the Thai Open Source Software Center Ltd nor - the names of its contributors may be used to endorse or promote - products derived from this software without specific prior written - permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +Copyright (c) 2001-2003 Thai Open Source Software Center Ltd +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + Neither the name of the Thai Open Source Software Center Ltd nor + the names of its contributors may be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/lib/optional/servlet-api-LICENSE.txt b/lib/optional/servlet-api-LICENSE.txt index d6456956733..75b52484ea4 100644 --- a/lib/optional/servlet-api-LICENSE.txt +++ b/lib/optional/servlet-api-LICENSE.txt @@ -1,202 +1,202 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/lib/optional/servlet-api-NOTICE.txt b/lib/optional/servlet-api-NOTICE.txt index 3f59805ce43..45392059369 100644 --- a/lib/optional/servlet-api-NOTICE.txt +++ b/lib/optional/servlet-api-NOTICE.txt @@ -1,2 +1,2 @@ -This product includes software developed by -The Apache Software Foundation (http://www.apache.org/). +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). diff --git a/lib/user/exificient-LICENSE.txt b/lib/user/exificient-LICENSE.txt index d511905c164..82fa1daad46 100755 --- a/lib/user/exificient-LICENSE.txt +++ b/lib/user/exificient-LICENSE.txt @@ -1,339 +1,339 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/log4j.xml b/log4j.xml index 459c82e4157..16724ee257b 100644 --- a/log4j.xml +++ b/log4j.xml @@ -1,270 +1,270 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mime-types.xml.tmpl b/mime-types.xml.tmpl index 3b0783f33ed..00762557a3c 100644 --- a/mime-types.xml.tmpl +++ b/mime-types.xml.tmpl @@ -1,355 +1,355 @@ - - - - - - - - - XML document - .xml,.xsd,.rng,.mods,.xmp,.xmi,.xconf,.xmap,.xsp,.wsdl,.x3d,.owl,.dbx,.tei,.xces,.ead,.xqx,.xform,.gml,.fo,.nvdl,.sch,.imdi,.cmdi - - - - Deprecated XML document - .xml - - - XSL document - .xsl,.xslt - - - STX document - .stx - - - RDF document - .rdf,.rdfs - - - XHTML document - .xhtml,.xht - - - HTML document - .html,.htm - - - Atom Feed Document - .atom - - - SVG image - .svg,.svgz - - - XML pipeline (XProc) - .xpl,.xproc - - - Open Packaging Format (OPF) Document - .opf - - - Navigation Control file for XML (NCX) Document - .ncx - - - - - Efficient XML Interchange - .exi - - - XQuery script - .xq,.xql,.xqm,.xquery,.xqy,.xqws - - - Generic binary stream - .jar,.exe,.dll,.o - - - JSON - .json - - - - - - - ZIP archive - .zip - - - EPUB document - .epub - - - package XAR archive - .xar - - - - - OpenOffice.org Text Document - .odt - - - OpenOffice.org Presentation - .odp - - - OpenOffice.org spreadsheet - .ods - - - OpenOffice.org Drawing - .odg - - - OpenOffice.org Diagram Chart - .odc - - - OpenOffice.org Formula - .odf - - - - OpenOffice.org Data Base - .odb - - - OpenOffice.org Data Base - .odb - - - - OpenOffice.org Image - .odi - - - - OpenOffice.org Main Document - .odm - - - - - OpenOffice.org formatted Text model - .ott - - - OpenOffice.org spreadsheet model - .ots - - - OpenOffice.org Presentation model - .otp - - - OpenOffice.org Drawing model - .otg - - - - - OpenOffice.org Document - .sxw - - - OpenOffice.org Document - .stw - - - OpenOffice.org Document - .sxg - - - OpenOffice.org Document - .sxc - - - OpenOffice.org Document - .stc - - - OpenOffice.org Document - .sxi - - - OpenOffice.org Document - .sti - - - OpenOffice.org Document - .sxd - - - OpenOffice.org Document - .std - - - OpenOffice.org Document - .sxm - - - - - Microsoft Word Document - .doc - - - Microsoft Powerpoint Document - .ppt - - - Microsoft Excel Document - .xls - - - Microsoft Visio Document - .vsd - - - - - OOXML Text Document - .docx - - - - OOXML Text Template - .dotx - - - - OOXML Presentation Template - .potx - - - - OOXML Presentation - .pptx - - - - OOXML Presentation Slideshow - .ppsx - - - - OOXML Spreadsheet - .xlsx - - - - OOXML Spreadsheet Template - .xltx - - - - - Plain text - .txt,.text,.java,.dtd,.rnc,.properties - - - CSS stylesheet - .css - - - - - DITA document - .dita,.ditamap - - - - - PNG image - .png - - - GIF image - .gif - - - JPEG image - .jpg,.jpeg - - - PBM Bitmap Format - .pbm - - - Windows Bitmap Image - .bmp - - - Tag Image File Format - .tif - - - X Bitmap Graphic - .xbm - - - Icon image - .ico - - - - - PDF (Adobe) - .pdf - - - PostScript Document - .eps,.ps - - - JavaScript - .js - - - Less - .less - - - - - MPEG Audio - .mp2,.mp3,.mpga - - - MPEG Video - .mpg,.mpeg - - - MP4 Video - .mp4 - - - - - WOFF File Format - .woff - - - + + + + + + + + + XML document + .xml,.xsd,.rng,.mods,.xmp,.xmi,.xconf,.xmap,.xsp,.wsdl,.x3d,.owl,.dbx,.tei,.xces,.ead,.xqx,.xform,.gml,.fo,.nvdl,.sch,.imdi,.cmdi + + + + Deprecated XML document + .xml + + + XSL document + .xsl,.xslt + + + STX document + .stx + + + RDF document + .rdf,.rdfs + + + XHTML document + .xhtml,.xht + + + HTML document + .html,.htm + + + Atom Feed Document + .atom + + + SVG image + .svg,.svgz + + + XML pipeline (XProc) + .xpl,.xproc + + + Open Packaging Format (OPF) Document + .opf + + + Navigation Control file for XML (NCX) Document + .ncx + + + + + Efficient XML Interchange + .exi + + + XQuery script + .xq,.xql,.xqm,.xquery,.xqy,.xqws + + + Generic binary stream + .jar,.exe,.dll,.o + + + JSON + .json + + + + + + + ZIP archive + .zip + + + EPUB document + .epub + + + package XAR archive + .xar + + + + + OpenOffice.org Text Document + .odt + + + OpenOffice.org Presentation + .odp + + + OpenOffice.org spreadsheet + .ods + + + OpenOffice.org Drawing + .odg + + + OpenOffice.org Diagram Chart + .odc + + + OpenOffice.org Formula + .odf + + + + OpenOffice.org Data Base + .odb + + + OpenOffice.org Data Base + .odb + + + + OpenOffice.org Image + .odi + + + + OpenOffice.org Main Document + .odm + + + + + OpenOffice.org formatted Text model + .ott + + + OpenOffice.org spreadsheet model + .ots + + + OpenOffice.org Presentation model + .otp + + + OpenOffice.org Drawing model + .otg + + + + + OpenOffice.org Document + .sxw + + + OpenOffice.org Document + .stw + + + OpenOffice.org Document + .sxg + + + OpenOffice.org Document + .sxc + + + OpenOffice.org Document + .stc + + + OpenOffice.org Document + .sxi + + + OpenOffice.org Document + .sti + + + OpenOffice.org Document + .sxd + + + OpenOffice.org Document + .std + + + OpenOffice.org Document + .sxm + + + + + Microsoft Word Document + .doc + + + Microsoft Powerpoint Document + .ppt + + + Microsoft Excel Document + .xls + + + Microsoft Visio Document + .vsd + + + + + OOXML Text Document + .docx + + + + OOXML Text Template + .dotx + + + + OOXML Presentation Template + .potx + + + + OOXML Presentation + .pptx + + + + OOXML Presentation Slideshow + .ppsx + + + + OOXML Spreadsheet + .xlsx + + + + OOXML Spreadsheet Template + .xltx + + + + + Plain text + .txt,.text,.java,.dtd,.rnc,.properties + + + CSS stylesheet + .css + + + + + DITA document + .dita,.ditamap + + + + + PNG image + .png + + + GIF image + .gif + + + JPEG image + .jpg,.jpeg + + + PBM Bitmap Format + .pbm + + + Windows Bitmap Image + .bmp + + + Tag Image File Format + .tif + + + X Bitmap Graphic + .xbm + + + Icon image + .ico + + + + + PDF (Adobe) + .pdf + + + PostScript Document + .eps,.ps + + + JavaScript + .js + + + Less + .less + + + + + MPEG Audio + .mp2,.mp3,.mpga + + + MPEG Video + .mpg,.mpeg + + + MP4 Video + .mp4 + + + + + WOFF File Format + .woff + + + diff --git a/samples/ant/ant-test.xml b/samples/ant/ant-test.xml index 2774f9c4c73..b4c06982885 100644 --- a/samples/ant/ant-test.xml +++ b/samples/ant/ant-test.xml @@ -1,40 +1,40 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/build.xml b/samples/build.xml index 6365497c936..4e6aaad76db 100644 --- a/samples/build.xml +++ b/samples/build.xml @@ -1,64 +1,64 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/src/org/exist/examples/xmlrpc/RetrieveChunked.java b/samples/src/org/exist/examples/xmlrpc/RetrieveChunked.java index 21ce6361731..0f727b5fa41 100644 --- a/samples/src/org/exist/examples/xmlrpc/RetrieveChunked.java +++ b/samples/src/org/exist/examples/xmlrpc/RetrieveChunked.java @@ -1,118 +1,118 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ - -package org.exist.examples.xmlrpc; - -import org.apache.xmlrpc.XmlRpcException; -import org.apache.xmlrpc.client.XmlRpcClient; -import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; -import org.exist.xmldb.XmldbURI; - -import java.io.FileOutputStream; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Vector; - -/** - * Example code for demonstrating XMLRPC methods getDocumentData - * and getNextChunk. Please run 'admin-examples setup' first, this will - * download the required macbeth.xml document. - * - * @author Dannes Wessels - */ -public class RetrieveChunked { - - /** - * @param args ignored command line arguments - */ - public static void main(String[] args) { - - // Download file using xmldb url - String xmldbUri = "xmldb:exist://localhost:8080/exist/xmlrpc/db/shakespeare/plays/macbeth.xml"; - XmldbURI uri = XmldbURI.create(xmldbUri); - - // Construct url for xmlrpc, without collections / document - String url = "http://" + uri.getAuthority() + uri.getContext(); - String path =uri.getCollectionPath(); - - // TODO file is hardcoded - String filename="macbeth.xml"; - - try { - // Setup xmlrpc client - XmlRpcClient client = new XmlRpcClient(); - XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); - config.setServerURL(new URL(url)); - config.setBasicUserName("guest"); - config.setBasicPassword("guest"); - client.setConfig(config); - - // Setup xml serializer - Hashtable options = new Hashtable(); - options.put("indent", "no"); - options.put("encoding", "UTF-8"); - - // Setup xmlrpc parameters - Vector params = new Vector(); - params.addElement( path ); - params.addElement( options ); - - // Setup output stream - FileOutputStream fos = new FileOutputStream(filename); - - // Shoot first method write data - HashMap ht = (HashMap) client.execute("getDocumentData", params); - int offset = ((Integer)ht.get("offset")).intValue(); - byte[]data= (byte[]) ht.get("data"); - String handle = (String) ht.get("handle"); - fos.write(data); - - // When there is more data to download - while(offset!=0){ - // Clean and re-setup xmlrpc parameters - params.clear(); - params.addElement(handle); - params.addElement(new Integer(offset)); - - // Get and write next chunk - ht = (HashMap) client.execute("getNextChunk", params); - data= (byte[]) ht.get("data"); - offset = ((Integer)ht.get("offset")).intValue(); - fos.write(data); - } - - // Finish transport - fos.close(); - - } catch (MalformedURLException ex) { - ex.printStackTrace(); - } catch (XmlRpcException ex) { - ex.printStackTrace(); - } catch (IOException ex) { - ex.printStackTrace(); - } - } - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ + +package org.exist.examples.xmlrpc; + +import org.apache.xmlrpc.XmlRpcException; +import org.apache.xmlrpc.client.XmlRpcClient; +import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; +import org.exist.xmldb.XmldbURI; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Vector; + +/** + * Example code for demonstrating XMLRPC methods getDocumentData + * and getNextChunk. Please run 'admin-examples setup' first, this will + * download the required macbeth.xml document. + * + * @author Dannes Wessels + */ +public class RetrieveChunked { + + /** + * @param args ignored command line arguments + */ + public static void main(String[] args) { + + // Download file using xmldb url + String xmldbUri = "xmldb:exist://localhost:8080/exist/xmlrpc/db/shakespeare/plays/macbeth.xml"; + XmldbURI uri = XmldbURI.create(xmldbUri); + + // Construct url for xmlrpc, without collections / document + String url = "http://" + uri.getAuthority() + uri.getContext(); + String path =uri.getCollectionPath(); + + // TODO file is hardcoded + String filename="macbeth.xml"; + + try { + // Setup xmlrpc client + XmlRpcClient client = new XmlRpcClient(); + XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); + config.setServerURL(new URL(url)); + config.setBasicUserName("guest"); + config.setBasicPassword("guest"); + client.setConfig(config); + + // Setup xml serializer + Hashtable options = new Hashtable(); + options.put("indent", "no"); + options.put("encoding", "UTF-8"); + + // Setup xmlrpc parameters + Vector params = new Vector(); + params.addElement( path ); + params.addElement( options ); + + // Setup output stream + FileOutputStream fos = new FileOutputStream(filename); + + // Shoot first method write data + HashMap ht = (HashMap) client.execute("getDocumentData", params); + int offset = ((Integer)ht.get("offset")).intValue(); + byte[]data= (byte[]) ht.get("data"); + String handle = (String) ht.get("handle"); + fos.write(data); + + // When there is more data to download + while(offset!=0){ + // Clean and re-setup xmlrpc parameters + params.clear(); + params.addElement(handle); + params.addElement(new Integer(offset)); + + // Get and write next chunk + ht = (HashMap) client.execute("getNextChunk", params); + data= (byte[]) ht.get("data"); + offset = ((Integer)ht.get("offset")).intValue(); + fos.write(data); + } + + // Finish transport + fos.close(); + + } catch (MalformedURLException ex) { + ex.printStackTrace(); + } catch (XmlRpcException ex) { + ex.printStackTrace(); + } catch (IOException ex) { + ex.printStackTrace(); + } + } + +} diff --git a/samples/src/org/exist/examples/xmlrpc/StoreChunked.java b/samples/src/org/exist/examples/xmlrpc/StoreChunked.java index 43427ba6cc0..840277c81cc 100644 --- a/samples/src/org/exist/examples/xmlrpc/StoreChunked.java +++ b/samples/src/org/exist/examples/xmlrpc/StoreChunked.java @@ -1,113 +1,113 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-06 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.examples.xmlrpc; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Vector; - -import org.apache.xmlrpc.XmlRpcException; -import org.apache.xmlrpc.client.XmlRpcClient; -import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; -import org.exist.xmldb.XmldbURI; - -/** - * Example code for demonstrating XMLRPC methods upload and parseLocal. - * - * Execute: bin\run.bat org.exist.examples.xmlrpc.StoreChunked - * - * @author dizzzz - */ -public class StoreChunked { - - - public static void main(String args[]) { - - // Upload file to this uri: - String xmldbUri = "xmldb:exist://guest:guest@localhost:8080/exist/xmlrpc/db/admin2.png"; - XmldbURI uri = XmldbURI.create(xmldbUri); - - // Construct url for xmlrpc, without collections / document - // username/password yet hardcoded, need to update XmldbUri fir this - String url = "http://guest:guest@" + uri.getAuthority() + uri.getContext(); - String path =uri.getCollectionPath(); - - // TODO: Filename hardcoded - String filename="webapp/resources/admin2.png"; - try { - InputStream fis = new FileInputStream(filename); - - // Setup xmlrpc client - XmlRpcClient client = new XmlRpcClient(); - XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); - config.setServerURL(new URL(url)); - config.setBasicUserName("guest"); - config.setBasicPassword("guest"); - client.setConfig(config); - - // Initialize xmlrpc parameters - Vector params = new Vector(); - String handle=null; - - // Copy data from inputstream to database - byte[] buf = new byte[4096]; - int len; - while ((len = fis.read(buf)) > 0) { - params.clear(); - if(handle!=null){ - params.addElement(handle); - } - params.addElement(buf); - params.addElement(new Integer(len)); - handle = (String)client.execute("upload", params); - } - fis.close(); - - // All data transported, parse data on server - params.clear(); - params.addElement(handle); - params.addElement(path); - params.addElement(new Boolean(true)); - params.addElement("image/png"); - Boolean result =(Boolean)client.execute("parseLocal", params); // exceptions - - // Check result - if(result.booleanValue()) - System.out.println("document stored."); - else - System.out.println("could not store document."); - - } catch (FileNotFoundException ex) { - ex.printStackTrace(); - } catch (MalformedURLException ex) { - ex.printStackTrace(); - } catch (IOException ex) { - ex.printStackTrace(); - } catch (XmlRpcException ex) { - ex.printStackTrace(); - } - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-06 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.examples.xmlrpc; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Vector; + +import org.apache.xmlrpc.XmlRpcException; +import org.apache.xmlrpc.client.XmlRpcClient; +import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; +import org.exist.xmldb.XmldbURI; + +/** + * Example code for demonstrating XMLRPC methods upload and parseLocal. + * + * Execute: bin\run.bat org.exist.examples.xmlrpc.StoreChunked + * + * @author dizzzz + */ +public class StoreChunked { + + + public static void main(String args[]) { + + // Upload file to this uri: + String xmldbUri = "xmldb:exist://guest:guest@localhost:8080/exist/xmlrpc/db/admin2.png"; + XmldbURI uri = XmldbURI.create(xmldbUri); + + // Construct url for xmlrpc, without collections / document + // username/password yet hardcoded, need to update XmldbUri fir this + String url = "http://guest:guest@" + uri.getAuthority() + uri.getContext(); + String path =uri.getCollectionPath(); + + // TODO: Filename hardcoded + String filename="webapp/resources/admin2.png"; + try { + InputStream fis = new FileInputStream(filename); + + // Setup xmlrpc client + XmlRpcClient client = new XmlRpcClient(); + XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); + config.setServerURL(new URL(url)); + config.setBasicUserName("guest"); + config.setBasicPassword("guest"); + client.setConfig(config); + + // Initialize xmlrpc parameters + Vector params = new Vector(); + String handle=null; + + // Copy data from inputstream to database + byte[] buf = new byte[4096]; + int len; + while ((len = fis.read(buf)) > 0) { + params.clear(); + if(handle!=null){ + params.addElement(handle); + } + params.addElement(buf); + params.addElement(new Integer(len)); + handle = (String)client.execute("upload", params); + } + fis.close(); + + // All data transported, parse data on server + params.clear(); + params.addElement(handle); + params.addElement(path); + params.addElement(new Boolean(true)); + params.addElement("image/png"); + Boolean result =(Boolean)client.execute("parseLocal", params); // exceptions + + // Check result + if(result.booleanValue()) + System.out.println("document stored."); + else + System.out.println("could not store document."); + + } catch (FileNotFoundException ex) { + ex.printStackTrace(); + } catch (MalformedURLException ex) { + ex.printStackTrace(); + } catch (IOException ex) { + ex.printStackTrace(); + } catch (XmlRpcException ex) { + ex.printStackTrace(); + } + } +} diff --git a/samples/validation/addressbook/catalog.xml b/samples/validation/addressbook/catalog.xml index e83b808f530..4c8382134ee 100644 --- a/samples/validation/addressbook/catalog.xml +++ b/samples/validation/addressbook/catalog.xml @@ -1,5 +1,5 @@ - - - - + + + + \ No newline at end of file diff --git a/samples/validation/personal/personal-dtd-invalid.xml b/samples/validation/personal/personal-dtd-invalid.xml index 4501c5ae532..fbf1581d944 100644 --- a/samples/validation/personal/personal-dtd-invalid.xml +++ b/samples/validation/personal/personal-dtd-invalid.xml @@ -1,53 +1,53 @@ - - - - - - - Boss - Big - - chief@oxygenxml.com - - - - - Worker - One - - one@oxygenxml.com - - - - - Worker - Two - - two@oxygenxml.com - - - - - Worker - Three - - three@oxygenxml.com - - - - - Worker - Four - - four@oxygenxml.com - - - - - Worker - Five - - five@oxygenxml.com - - + + + + + + + Boss + Big + + chief@oxygenxml.com + + + + + Worker + One + + one@oxygenxml.com + + + + + Worker + Two + + two@oxygenxml.com + + + + + Worker + Three + + three@oxygenxml.com + + + + + Worker + Four + + four@oxygenxml.com + + + + + Worker + Five + + five@oxygenxml.com + + \ No newline at end of file diff --git a/samples/validation/personal/personal-dtd.xml b/samples/validation/personal/personal-dtd.xml index a0473e98ca6..bb3560689f8 100644 --- a/samples/validation/personal/personal-dtd.xml +++ b/samples/validation/personal/personal-dtd.xml @@ -1,53 +1,53 @@ - - - - - - - Boss - Big - - chief@oxygenxml.com - - - - - Worker - One - - one@oxygenxml.com - - - - - Worker - Two - - two@oxygenxml.com - - - - - Worker - Three - - three@oxygenxml.com - - - - - Worker - Four - - four@oxygenxml.com - - - - - Worker - Five - - five@oxygenxml.com - - + + + + + + + Boss + Big + + chief@oxygenxml.com + + + + + Worker + One + + one@oxygenxml.com + + + + + Worker + Two + + two@oxygenxml.com + + + + + Worker + Three + + three@oxygenxml.com + + + + + Worker + Four + + four@oxygenxml.com + + + + + Worker + Five + + five@oxygenxml.com + + \ No newline at end of file diff --git a/samples/validation/personal/personal-invalid.xml b/samples/validation/personal/personal-invalid.xml index e4cdd8bae0b..ef8562a3d1d 100644 --- a/samples/validation/personal/personal-invalid.xml +++ b/samples/validation/personal/personal-invalid.xml @@ -1,52 +1,52 @@ - - - - - - Boss - Big - - chief@oxygenxml.com - - - - - Worker - One - - one@oxygenxml.com - - - - - Worker - Two - - two@oxygenxml.com - - - - - Worker - Three - - three@oxygenxml.com - - - - - Worker - Four - - four@oxygenxml.com - - - - - Worker - Five - - five@oxygenxml.com - - + + + + + + Boss + Big + + chief@oxygenxml.com + + + + + Worker + One + + one@oxygenxml.com + + + + + Worker + Two + + two@oxygenxml.com + + + + + Worker + Three + + three@oxygenxml.com + + + + + Worker + Four + + four@oxygenxml.com + + + + + Worker + Five + + five@oxygenxml.com + + \ No newline at end of file diff --git a/samples/validation/personal/personal-relaxng.xml b/samples/validation/personal/personal-relaxng.xml index 50f351bdb78..d9928ea904d 100644 --- a/samples/validation/personal/personal-relaxng.xml +++ b/samples/validation/personal/personal-relaxng.xml @@ -1,52 +1,52 @@ - - - - - - Boss - Big - - chief@oxygenxml.com - - - - - Worker - One - - one@oxygenxml.com - - - - - Worker - Two - - two@oxygenxml.com - - - - - Worker - Three - - three@oxygenxml.com - - - - - Worker - Four - - four@oxygenxml.com - - - - - Worker - Five - - five@oxygenxml.com - - - + + + + + + Boss + Big + + chief@oxygenxml.com + + + + + Worker + One + + one@oxygenxml.com + + + + + Worker + Two + + two@oxygenxml.com + + + + + Worker + Three + + three@oxygenxml.com + + + + + Worker + Four + + four@oxygenxml.com + + + + + Worker + Five + + five@oxygenxml.com + + + diff --git a/samples/validation/personal/personal-valid.xml b/samples/validation/personal/personal-valid.xml index faabb4b7e67..f321cd0a20b 100644 --- a/samples/validation/personal/personal-valid.xml +++ b/samples/validation/personal/personal-valid.xml @@ -1,52 +1,52 @@ - - - - - - Boss - Big - - chief@oxygenxml.com - - - - - Worker - One - - one@oxygenxml.com - - - - - Worker - Two - - two@oxygenxml.com - - - - - Worker - Three - - three@oxygenxml.com - - - - - Worker - Four - - four@oxygenxml.com - - - - - Worker - Five - - five@oxygenxml.com - - - + + + + + + Boss + Big + + chief@oxygenxml.com + + + + + Worker + One + + one@oxygenxml.com + + + + + Worker + Two + + two@oxygenxml.com + + + + + Worker + Three + + three@oxygenxml.com + + + + + Worker + Four + + four@oxygenxml.com + + + + + Worker + Five + + five@oxygenxml.com + + + diff --git a/samples/validation/personal/personal-xsd_noSchemaLocation-invalid.xml b/samples/validation/personal/personal-xsd_noSchemaLocation-invalid.xml index 6f989d4fa5f..ceb5132735f 100644 --- a/samples/validation/personal/personal-xsd_noSchemaLocation-invalid.xml +++ b/samples/validation/personal/personal-xsd_noSchemaLocation-invalid.xml @@ -1,53 +1,53 @@ - - - - - - Boss - Big - - chief@oxygenxml.com - - - - - Worker - One - - one@oxygenxml.com - - - - - Worker - Two - - two@oxygenxml.com - - - - - Worker - Three - - three@oxygenxml.com - - - - - Worker - Four - - four@oxygenxml.com - - - - - Worker - Five - - five@oxygenxml.com - - + + + + + + Boss + Big + + chief@oxygenxml.com + + + + + Worker + One + + one@oxygenxml.com + + + + + Worker + Two + + two@oxygenxml.com + + + + + Worker + Three + + three@oxygenxml.com + + + + + Worker + Four + + four@oxygenxml.com + + + + + Worker + Five + + five@oxygenxml.com + + \ No newline at end of file diff --git a/samples/validation/personal/personal-xsd_noSchemaLocation.xml b/samples/validation/personal/personal-xsd_noSchemaLocation.xml index d91e7b69939..5e3d91c0905 100644 --- a/samples/validation/personal/personal-xsd_noSchemaLocation.xml +++ b/samples/validation/personal/personal-xsd_noSchemaLocation.xml @@ -1,53 +1,53 @@ - - - - - - Boss - Big - - chief@oxygenxml.com - - - - - Worker - One - - one@oxygenxml.com - - - - - Worker - Two - - two@oxygenxml.com - - - - - Worker - Three - - three@oxygenxml.com - - - - - Worker - Four - - four@oxygenxml.com - - - - - Worker - Five - - five@oxygenxml.com - - + + + + + + Boss + Big + + chief@oxygenxml.com + + + + + Worker + One + + one@oxygenxml.com + + + + + Worker + Two + + two@oxygenxml.com + + + + + Worker + Three + + three@oxygenxml.com + + + + + Worker + Four + + four@oxygenxml.com + + + + + Worker + Five + + five@oxygenxml.com + + \ No newline at end of file diff --git a/samples/validation/personal/personal.rnc b/samples/validation/personal/personal.rnc index e4547152dd1..57016eb6c83 100644 --- a/samples/validation/personal/personal.rnc +++ b/samples/validation/personal/personal.rnc @@ -1,55 +1,55 @@ -namespace a = "http://relaxng.org/ns/compatibility/annotations/1.0" - -personnel = - ##Defines the personnel as a collection of person elements. - element personnel { attlist.personnel, person+ } -attlist.personnel &= empty -person = - ##Specify information about a person. - element person { attlist.person, name, email*, url*, link? } -attlist.person &= - ##Specify a required unique ID for this person. - attribute id { xsd:ID } -attlist.person &= - ##If there is anything to note about this person. - attribute note { text }? -attlist.person &= - [ a:defaultValue = "false" ] attribute contr { "true" | "false" }? -attlist.person &= - ##Specifies the salary for this person. - attribute salary { text }? -name = - ##Specify the person family and given name. - element name { - attlist.name, - ((family, given) | (given, family)) - } -attlist.name &= empty -family = - ##The person last name. - element family { attlist.family, text } -attlist.family &= empty -given = - ## The person first name. - element given { attlist.given, text } -attlist.given &= empty -email = - ##Email address for this person. - element email { attlist.email, text } -attlist.email &= empty -url = - ##Enter an URL for this person. - element url { attlist.url, empty } -attlist.url &= - ## Enter an URL for this person. - [ a:defaultValue = "http://" ] attribute href { text }? -link = - ##Specify who is the manager and who are the subordinates for this person. - element link { attlist.link, empty } -attlist.link &= - ##The manager ID. - attribute manager { xsd:IDREF }? -attlist.link &= - ##Space separated list with the subordinates IDs. - attribute subordinates { xsd:IDREFS }? -start = personnel +namespace a = "http://relaxng.org/ns/compatibility/annotations/1.0" + +personnel = + ##Defines the personnel as a collection of person elements. + element personnel { attlist.personnel, person+ } +attlist.personnel &= empty +person = + ##Specify information about a person. + element person { attlist.person, name, email*, url*, link? } +attlist.person &= + ##Specify a required unique ID for this person. + attribute id { xsd:ID } +attlist.person &= + ##If there is anything to note about this person. + attribute note { text }? +attlist.person &= + [ a:defaultValue = "false" ] attribute contr { "true" | "false" }? +attlist.person &= + ##Specifies the salary for this person. + attribute salary { text }? +name = + ##Specify the person family and given name. + element name { + attlist.name, + ((family, given) | (given, family)) + } +attlist.name &= empty +family = + ##The person last name. + element family { attlist.family, text } +attlist.family &= empty +given = + ## The person first name. + element given { attlist.given, text } +attlist.given &= empty +email = + ##Email address for this person. + element email { attlist.email, text } +attlist.email &= empty +url = + ##Enter an URL for this person. + element url { attlist.url, empty } +attlist.url &= + ## Enter an URL for this person. + [ a:defaultValue = "http://" ] attribute href { text }? +link = + ##Specify who is the manager and who are the subordinates for this person. + element link { attlist.link, empty } +attlist.link &= + ##The manager ID. + attribute manager { xsd:IDREF }? +attlist.link &= + ##Space separated list with the subordinates IDs. + attribute subordinates { xsd:IDREFS }? +start = personnel diff --git a/samples/validation/personal/personal.rng b/samples/validation/personal/personal.rng index 1ee63c63323..7bc9f334af9 100644 --- a/samples/validation/personal/personal.rng +++ b/samples/validation/personal/personal.rng @@ -1,181 +1,181 @@ - - - - - - Defines the personnel as a collection of person elements. - - - - - - - - - - - - - - Specify information about a person. - - - - - - - - - - - - - - - - - - Specify a required unique ID for this person. - - - - - - - - - If there is anything to note about this person. - - - - - - - - - true - false - - - - - - - - - Specifies the salary for this person. - - - - - - - - Specify the person family and given name. - - - - - - - - - - - - - - - - - - - - - The person last name. - - - - - - - - - - - - The person first name. - - - - - - - - - - - - Email address for this person. - - - - - - - - - - - - Enter an URL for this person. - - - - - - - - - - Enter an URL for this person. - - - - - - - - Specify who is the manager and who are the subordinates for this person. - - - - - - - - - - The manager ID. - - - - - - - - - - Space separated list with the subordinates IDs. - - - - - - - - - - - + + + + + + Defines the personnel as a collection of person elements. + + + + + + + + + + + + + + Specify information about a person. + + + + + + + + + + + + + + + + + + Specify a required unique ID for this person. + + + + + + + + + If there is anything to note about this person. + + + + + + + + + true + false + + + + + + + + + Specifies the salary for this person. + + + + + + + + Specify the person family and given name. + + + + + + + + + + + + + + + + + + + + + The person last name. + + + + + + + + + + + + The person first name. + + + + + + + + + + + + Email address for this person. + + + + + + + + + + + + Enter an URL for this person. + + + + + + + + + + Enter an URL for this person. + + + + + + + + Specify who is the manager and who are the subordinates for this person. + + + + + + + + + + The manager ID. + + + + + + + + + + Space separated list with the subordinates IDs. + + + + + + + + + + + diff --git a/samples/validation/tournament/1.5/Tournament-invalid.xml b/samples/validation/tournament/1.5/Tournament-invalid.xml index fd2f8c0c8b0..a28fd18696d 100644 --- a/samples/validation/tournament/1.5/Tournament-invalid.xml +++ b/samples/validation/tournament/1.5/Tournament-invalid.xml @@ -1,46 +1,46 @@ - - - - Allette Open - Singles - 2001-03-20 - - Nick - Marcus - Eddie - - - - p1 - - - p2 - - - p3 - - - - - t1 - t2 - - - t1 - t3 - - - t2 - t5 - - - + + + + Allette Open + Singles + 2001-03-20 + + Nick + Marcus + Eddie + + + + p1 + + + p2 + + + p3 + + + + + t1 + t2 + + + t1 + t3 + + + t2 + t5 + + + diff --git a/samples/validation/tournament/1.5/Tournament-valid.xml b/samples/validation/tournament/1.5/Tournament-valid.xml index 9a27c590cc2..2bf8b3ce39d 100644 --- a/samples/validation/tournament/1.5/Tournament-valid.xml +++ b/samples/validation/tournament/1.5/Tournament-valid.xml @@ -1,46 +1,46 @@ - - - - Allette Open - Singles - 2001-03-20 - - Nick - Marcus - Eddie - - - - p1 - - - p2 - - - p3 - - - - - t1 - t2 - - - t1 - t3 - - - t2 - t5 - - - + + + + Allette Open + Singles + 2001-03-20 + + Nick + Marcus + Eddie + + + + p1 + + + p2 + + + p3 + + + + + t1 + t2 + + + t1 + t3 + + + t2 + t5 + + + diff --git a/samples/validation/tournament/1.5/Tournament.rng b/samples/validation/tournament/1.5/Tournament.rng index 94ab191ce17..d69a97b8441 100644 --- a/samples/validation/tournament/1.5/Tournament.rng +++ b/samples/validation/tournament/1.5/Tournament.rng @@ -1,97 +1,97 @@ - - - - - - - - - - - - - - - Singles - Doubles - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - If you're playing single matches there must be at least 2 participants. - If you're playing single matches the number of participants must equal the number of teams. - - - If you're playing doubles you must have at least 4 participants. - If you're playing doubles the number of particiapants must be a multiple of 2. - If you're playing doubles the number of participants must equal the number of teams x 2. - - - - - The number of Team elements in should match - the @nbrTeams attribute. - - - - Value of nbrTeams attribute = and number of Team elements = - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + Singles + Doubles + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + If you're playing single matches there must be at least 2 participants. + If you're playing single matches the number of participants must equal the number of teams. + + + If you're playing doubles you must have at least 4 participants. + If you're playing doubles the number of particiapants must be a multiple of 2. + If you're playing doubles the number of participants must equal the number of teams x 2. + + + + + The number of Team elements in should match + the @nbrTeams attribute. + + + + Value of nbrTeams attribute = and number of Team elements = + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/validation/tournament/1.5/Tournament.xsd b/samples/validation/tournament/1.5/Tournament.xsd index 8a0916c642a..3c64b7723d5 100644 --- a/samples/validation/tournament/1.5/Tournament.xsd +++ b/samples/validation/tournament/1.5/Tournament.xsd @@ -1,115 +1,115 @@ - - - - - - Schematron validation schema for the Tournament - - - - - - - - - - - - - If you're playing single matches there must be at least 2 participants. - If you're playing single matches the number of participants must equal the number of teams. - - - If you're playing doubles you must have at least 4 participants. - If you're playing doubles the number of particiapants must be a multiple of 2. - If you're playing doubles the number of participants must equal the number of teams x 2. - - - - - The number of Team elements in should match the @nbrTeams attribute. - - - - Value of nbrTeams attribute = and number of Team elements = - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + Schematron validation schema for the Tournament + + + + + + + + + + + + + If you're playing single matches there must be at least 2 participants. + If you're playing single matches the number of participants must equal the number of teams. + + + If you're playing doubles you must have at least 4 participants. + If you're playing doubles the number of particiapants must be a multiple of 2. + If you're playing doubles the number of participants must equal the number of teams x 2. + + + + + The number of Team elements in should match the @nbrTeams attribute. + + + + Value of nbrTeams attribute = and number of Team elements = + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/validation/tournament/1.5/tournament-schema.sch b/samples/validation/tournament/1.5/tournament-schema.sch index 96df813d573..5dabeebffb1 100644 --- a/samples/validation/tournament/1.5/tournament-schema.sch +++ b/samples/validation/tournament/1.5/tournament-schema.sch @@ -1,60 +1,60 @@ - - - - Schematron validation schema for the Tournament - - - - - - - - - - - If you're playing single matches there must be at least 2 participants. - If you're playing single matches the number of participants must equal the number of teams. - - - If you're playing doubles the number of particiapants must be divisible by 2. - If you're playing doubles the number of participants must equal the number of teams x 2. - - - The number of Name elements in should match the @nbrParticipants attribute. - - - - A team member must also be a participant in the tournament. - - - - - - The number of Team elements in should match the @nbrTeams attribute. - - - - - Value of nbrTeams attribute = and number of Team elements = - - + + + + Schematron validation schema for the Tournament + + + + + + + + + + + If you're playing single matches there must be at least 2 participants. + If you're playing single matches the number of participants must equal the number of teams. + + + If you're playing doubles the number of particiapants must be divisible by 2. + If you're playing doubles the number of participants must equal the number of teams x 2. + + + The number of Name elements in should match the @nbrParticipants attribute. + + + + A team member must also be a participant in the tournament. + + + + + + The number of Team elements in should match the @nbrTeams attribute. + + + + + Value of nbrTeams attribute = and number of Team elements = + + diff --git a/samples/validation/tournament/iso/Tournament.rng b/samples/validation/tournament/iso/Tournament.rng index 30a4532564e..9ad79938863 100644 --- a/samples/validation/tournament/iso/Tournament.rng +++ b/samples/validation/tournament/iso/Tournament.rng @@ -1,103 +1,103 @@ - - - - - - - - - - - - - - - - Singles - Doubles - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - If you're playing single matches there must be at least 2 participants. - If you're playing single matches the number of participants must equal the number of teams. - - - If you're playing doubles you must have at least 4 participants. - If you're playing doubles the number of particiapants must be a multiple of 2. - If you're playing doubles the number of participants must equal the number of teams x 2. - - - - - The number of Team elements in should match - the @nbrTeams attribute. - - - - Value of nbrTeams attribute = and number of Team elements = - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + Singles + Doubles + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + If you're playing single matches there must be at least 2 participants. + If you're playing single matches the number of participants must equal the number of teams. + + + If you're playing doubles you must have at least 4 participants. + If you're playing doubles the number of particiapants must be a multiple of 2. + If you're playing doubles the number of participants must equal the number of teams x 2. + + + + + The number of Team elements in should match + the @nbrTeams attribute. + + + + Value of nbrTeams attribute = and number of Team elements = + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/validation/tournament/iso/Tournament.xml b/samples/validation/tournament/iso/Tournament.xml index 79adf9b2cef..f92f9803eff 100644 --- a/samples/validation/tournament/iso/Tournament.xml +++ b/samples/validation/tournament/iso/Tournament.xml @@ -1,46 +1,46 @@ - - - - Allette Open - Singles - 2001-03-20 - - Nick - Marcus - Eddie - - - - p1 - - - p2 - - - p3 - - - - - t1 - t2 - - - t1 - t3 - - - t2 - t5 - - - + + + + Allette Open + Singles + 2001-03-20 + + Nick + Marcus + Eddie + + + + p1 + + + p2 + + + p3 + + + + + t1 + t2 + + + t1 + t3 + + + t2 + t5 + + + diff --git a/samples/validation/tournament/iso/Tournament.xsd b/samples/validation/tournament/iso/Tournament.xsd index 65d36078550..d2e0959b781 100644 --- a/samples/validation/tournament/iso/Tournament.xsd +++ b/samples/validation/tournament/iso/Tournament.xsd @@ -1,120 +1,120 @@ - - - - - - Schematron validation schema for the Tournament - - - - - - - - - - - - - If you're playing single matches there must be at least 2 participants. - If you're playing single matches the number of participants must equal the number of teams. - - - If you're playing doubles you must have at least 4 participants. - If you're playing doubles the number of particiapants must be a multiple of 2. - If you're playing doubles the number of participants must equal the number of teams x 2. - - - - - The number of Team elements in should match the @nbrTeams attribute. - - - - Value of nbrTeams attribute = and number of Team elements = - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + Schematron validation schema for the Tournament + + + + + + + + + + + + + If you're playing single matches there must be at least 2 participants. + If you're playing single matches the number of participants must equal the number of teams. + + + If you're playing doubles you must have at least 4 participants. + If you're playing doubles the number of particiapants must be a multiple of 2. + If you're playing doubles the number of participants must equal the number of teams x 2. + + + + + The number of Team elements in should match the @nbrTeams attribute. + + + + Value of nbrTeams attribute = and number of Team elements = + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/validation/tournament/iso/tournament-schema.sch b/samples/validation/tournament/iso/tournament-schema.sch index 0f164ab6953..8fabb87220f 100644 --- a/samples/validation/tournament/iso/tournament-schema.sch +++ b/samples/validation/tournament/iso/tournament-schema.sch @@ -1,80 +1,80 @@ - - - - Schematron validation schema for the Tournament - - - - - - - - - - - - If - you're playing single matches there must be at least 2 - participants. - If you're playing single matches the - number of participants must equal the number of - teams. - - - If - you're playing doubles the number of particiapants must be - divisible by 2. - If you're playing doubles the number - of participants must equal the number of teams x 2. - - - The number of - Name elements in should match the @nbrParticipants - attribute. - - - A team member must - also be a participant in the tournament. - - - - - - The - number of Team elements in should match the - @nbrTeams attribute. - - - - - Value of nbrTeams attribute = and number of Team elements = - - + + + + Schematron validation schema for the Tournament + + + + + + + + + + + + If + you're playing single matches there must be at least 2 + participants. + If you're playing single matches the + number of participants must equal the number of + teams. + + + If + you're playing doubles the number of particiapants must be + divisible by 2. + If you're playing doubles the number + of participants must equal the number of teams x 2. + + + The number of + Name elements in should match the @nbrParticipants + attribute. + + + A team member must + also be a participant in the tournament. + + + + + + The + number of Team elements in should match the + @nbrTeams attribute. + + + + + Value of nbrTeams attribute = and number of Team elements = + + diff --git a/samples/xinclude/styles/SyntaxHighlighter.css b/samples/xinclude/styles/SyntaxHighlighter.css index a1da307e72c..85a826190a6 100644 --- a/samples/xinclude/styles/SyntaxHighlighter.css +++ b/samples/xinclude/styles/SyntaxHighlighter.css @@ -1,185 +1,185 @@ -.dp-highlighter -{ - font-family: "Consolas", "Courier New", Courier, mono, serif; - font-size: 12px; - background-color: #E7E5DC; - width: 99%; - overflow: auto; - margin: 18px 0 18px 0 !important; - padding-top: 1px; /* adds a little border on top when controls are hidden */ -} - -/* clear styles */ -.dp-highlighter ol, -.dp-highlighter ol li, -.dp-highlighter ol li span -{ - margin: 0; - padding: 0; - border: none; -} - -.dp-highlighter a, -.dp-highlighter a:hover -{ - background: none; - border: none; - padding: 0; - margin: 0; -} - -.dp-highlighter .bar -{ - padding-left: 45px; -} - -.dp-highlighter.collapsed .bar, -.dp-highlighter.nogutter .bar -{ - padding-left: 0px; -} - -.dp-highlighter ol -{ - list-style: decimal; /* for ie */ - background-color: #fff; - margin: 0px 0px 1px 45px !important; /* 1px bottom margin seems to fix occasional Firefox scrolling */ - padding: 0px; - color: #5C5C5C; -} - -.dp-highlighter.nogutter ol, -.dp-highlighter.nogutter ol li -{ - list-style: none !important; - margin-left: 0px !important; -} - -.dp-highlighter ol li, -.dp-highlighter .columns div -{ - list-style: decimal-leading-zero; /* better look for others, override cascade from OL */ - list-style-position: outside !important; - border-left: 3px solid #6CE26C; - background-color: #F8F8F8; - color: #5C5C5C; - padding: 0 3px 0 10px !important; - margin: 0 !important; - line-height: 14px; -} - -.dp-highlighter.nogutter ol li, -.dp-highlighter.nogutter .columns div -{ - border: 0; -} - -.dp-highlighter .columns -{ - background-color: #F8F8F8; - color: gray; - overflow: hidden; - width: 100%; -} - -.dp-highlighter .columns div -{ - padding-bottom: 5px; -} - -.dp-highlighter ol li.alt -{ - background-color: #FFF; - color: inherit; -} - -.dp-highlighter ol li span -{ - color: black; - background-color: inherit; -} - -/* Adjust some properties when collapsed */ - -.dp-highlighter.collapsed ol -{ - margin: 0px; -} - -.dp-highlighter.collapsed ol li -{ - display: none; -} - -/* Additional modifications when in print-view */ - -.dp-highlighter.printing -{ - border: none; -} - -.dp-highlighter.printing .tools -{ - display: none !important; -} - -.dp-highlighter.printing li -{ - display: list-item !important; -} - -/* Styles for the tools */ - -.dp-highlighter .tools -{ - padding: 3px 8px 3px 10px; - font: 9px Verdana, Geneva, Arial, Helvetica, sans-serif; - color: silver; - background-color: #f8f8f8; - padding-bottom: 10px; - border-left: 3px solid #6CE26C; -} - -.dp-highlighter.nogutter .tools -{ - border-left: 0; -} - -.dp-highlighter.collapsed .tools -{ - border-bottom: 0; -} - -.dp-highlighter .tools a -{ - font-size: 9px; - color: #a0a0a0; - background-color: inherit; - text-decoration: none; - margin-right: 10px; -} - -.dp-highlighter .tools a:hover -{ - color: red; - background-color: inherit; - text-decoration: underline; -} - -/* About dialog styles */ - -.dp-about { background-color: #fff; color: #333; margin: 0px; padding: 0px; } -.dp-about table { width: 100%; height: 100%; font-size: 11px; font-family: Tahoma, Verdana, Arial, sans-serif !important; } -.dp-about td { padding: 10px; vertical-align: top; } -.dp-about .copy { border-bottom: 1px solid #ACA899; height: 95%; } -.dp-about .title { color: red; background-color: inherit; font-weight: bold; } -.dp-about .para { margin: 0 0 4px 0; } -.dp-about .footer { background-color: #ECEADB; color: #333; border-top: 1px solid #fff; text-align: right; } -.dp-about .close { font-size: 11px; font-family: Tahoma, Verdana, Arial, sans-serif !important; background-color: #ECEADB; color: #333; width: 60px; height: 22px; } - -/* Language specific styles */ - -.dp-highlighter .comment, .dp-highlighter .comments { color: #008200; background-color: inherit; } -.dp-highlighter .string { color: blue; background-color: inherit; } -.dp-highlighter .keyword { color: #069; font-weight: bold; background-color: inherit; } -.dp-highlighter .preprocessor { color: gray; background-color: inherit; } +.dp-highlighter +{ + font-family: "Consolas", "Courier New", Courier, mono, serif; + font-size: 12px; + background-color: #E7E5DC; + width: 99%; + overflow: auto; + margin: 18px 0 18px 0 !important; + padding-top: 1px; /* adds a little border on top when controls are hidden */ +} + +/* clear styles */ +.dp-highlighter ol, +.dp-highlighter ol li, +.dp-highlighter ol li span +{ + margin: 0; + padding: 0; + border: none; +} + +.dp-highlighter a, +.dp-highlighter a:hover +{ + background: none; + border: none; + padding: 0; + margin: 0; +} + +.dp-highlighter .bar +{ + padding-left: 45px; +} + +.dp-highlighter.collapsed .bar, +.dp-highlighter.nogutter .bar +{ + padding-left: 0px; +} + +.dp-highlighter ol +{ + list-style: decimal; /* for ie */ + background-color: #fff; + margin: 0px 0px 1px 45px !important; /* 1px bottom margin seems to fix occasional Firefox scrolling */ + padding: 0px; + color: #5C5C5C; +} + +.dp-highlighter.nogutter ol, +.dp-highlighter.nogutter ol li +{ + list-style: none !important; + margin-left: 0px !important; +} + +.dp-highlighter ol li, +.dp-highlighter .columns div +{ + list-style: decimal-leading-zero; /* better look for others, override cascade from OL */ + list-style-position: outside !important; + border-left: 3px solid #6CE26C; + background-color: #F8F8F8; + color: #5C5C5C; + padding: 0 3px 0 10px !important; + margin: 0 !important; + line-height: 14px; +} + +.dp-highlighter.nogutter ol li, +.dp-highlighter.nogutter .columns div +{ + border: 0; +} + +.dp-highlighter .columns +{ + background-color: #F8F8F8; + color: gray; + overflow: hidden; + width: 100%; +} + +.dp-highlighter .columns div +{ + padding-bottom: 5px; +} + +.dp-highlighter ol li.alt +{ + background-color: #FFF; + color: inherit; +} + +.dp-highlighter ol li span +{ + color: black; + background-color: inherit; +} + +/* Adjust some properties when collapsed */ + +.dp-highlighter.collapsed ol +{ + margin: 0px; +} + +.dp-highlighter.collapsed ol li +{ + display: none; +} + +/* Additional modifications when in print-view */ + +.dp-highlighter.printing +{ + border: none; +} + +.dp-highlighter.printing .tools +{ + display: none !important; +} + +.dp-highlighter.printing li +{ + display: list-item !important; +} + +/* Styles for the tools */ + +.dp-highlighter .tools +{ + padding: 3px 8px 3px 10px; + font: 9px Verdana, Geneva, Arial, Helvetica, sans-serif; + color: silver; + background-color: #f8f8f8; + padding-bottom: 10px; + border-left: 3px solid #6CE26C; +} + +.dp-highlighter.nogutter .tools +{ + border-left: 0; +} + +.dp-highlighter.collapsed .tools +{ + border-bottom: 0; +} + +.dp-highlighter .tools a +{ + font-size: 9px; + color: #a0a0a0; + background-color: inherit; + text-decoration: none; + margin-right: 10px; +} + +.dp-highlighter .tools a:hover +{ + color: red; + background-color: inherit; + text-decoration: underline; +} + +/* About dialog styles */ + +.dp-about { background-color: #fff; color: #333; margin: 0px; padding: 0px; } +.dp-about table { width: 100%; height: 100%; font-size: 11px; font-family: Tahoma, Verdana, Arial, sans-serif !important; } +.dp-about td { padding: 10px; vertical-align: top; } +.dp-about .copy { border-bottom: 1px solid #ACA899; height: 95%; } +.dp-about .title { color: red; background-color: inherit; font-weight: bold; } +.dp-about .para { margin: 0 0 4px 0; } +.dp-about .footer { background-color: #ECEADB; color: #333; border-top: 1px solid #fff; text-align: right; } +.dp-about .close { font-size: 11px; font-family: Tahoma, Verdana, Arial, sans-serif !important; background-color: #ECEADB; color: #333; width: 60px; height: 22px; } + +/* Language specific styles */ + +.dp-highlighter .comment, .dp-highlighter .comments { color: #008200; background-color: inherit; } +.dp-highlighter .string { color: blue; background-color: inherit; } +.dp-highlighter .keyword { color: #069; font-weight: bold; background-color: inherit; } +.dp-highlighter .preprocessor { color: gray; background-color: inherit; } diff --git a/samples/xinclude/styles/niftyCorners.css b/samples/xinclude/styles/niftyCorners.css index 55523a49942..6570f60ee5e 100755 --- a/samples/xinclude/styles/niftyCorners.css +++ b/samples/xinclude/styles/niftyCorners.css @@ -1,35 +1,35 @@ -/*Nifty Corners Cube CSS by Alessandro Fulciniti -The following classes are added dinamically by javascript, -and their use should be avoided in the markup */ - -b.niftycorners,b.niftyfill{display:block} -b.niftycorners *{display:block;height: 1px;line-height:1px;font-size: 1px; - overflow:hidden;border-style:solid;border-width: 0 1px} -/*normal*/ -b.r1{margin: 0 3px;border-width: 0 2px} -b.r2{margin: 0 2px} -b.r3{margin: 0 1px} -b.r4{height: 2px} -b.rb1{margin: 0 8px;border-width:0 2px} -b.rb2{margin: 0 6px;border-width:0 2px} -b.rb3{margin: 0 5px} -b.rb4{margin: 0 4px} -b.rb5{margin: 0 3px} -b.rb6{margin: 0 2px} -b.rb7{margin: 0 1px;height:2px} -b.rb8{margin: 0;height:2px} -b.rs1{margin: 0 1px} -/*transparent inside*/ -b.t1{border-width: 0 5px} -b.t2{border-width: 0 3px} -b.t3{border-width: 0 2px} -b.t4{height: 2px} -b.tb1{border-width: 0 10px} -b.tb2{border-width: 0 8px} -b.tb3{border-width: 0 6px} -b.tb4{border-width: 0 5px} -b.tb5{border-width: 0 4px} -b.tb6{border-width: 0 3px} -b.tb7{border-width: 0 2px;height:2px} -b.tb8{border-width: 0 1px;height:2px} +/*Nifty Corners Cube CSS by Alessandro Fulciniti +The following classes are added dinamically by javascript, +and their use should be avoided in the markup */ + +b.niftycorners,b.niftyfill{display:block} +b.niftycorners *{display:block;height: 1px;line-height:1px;font-size: 1px; + overflow:hidden;border-style:solid;border-width: 0 1px} +/*normal*/ +b.r1{margin: 0 3px;border-width: 0 2px} +b.r2{margin: 0 2px} +b.r3{margin: 0 1px} +b.r4{height: 2px} +b.rb1{margin: 0 8px;border-width:0 2px} +b.rb2{margin: 0 6px;border-width:0 2px} +b.rb3{margin: 0 5px} +b.rb4{margin: 0 4px} +b.rb5{margin: 0 3px} +b.rb6{margin: 0 2px} +b.rb7{margin: 0 1px;height:2px} +b.rb8{margin: 0;height:2px} +b.rs1{margin: 0 1px} +/*transparent inside*/ +b.t1{border-width: 0 5px} +b.t2{border-width: 0 3px} +b.t3{border-width: 0 2px} +b.t4{height: 2px} +b.tb1{border-width: 0 10px} +b.tb2{border-width: 0 8px} +b.tb3{border-width: 0 6px} +b.tb4{border-width: 0 5px} +b.tb5{border-width: 0 4px} +b.tb6{border-width: 0 3px} +b.tb7{border-width: 0 2px;height:2px} +b.tb8{border-width: 0 1px;height:2px} b.ts1{border-width: 0 2px} \ No newline at end of file diff --git a/samples/xinclude/styles/niftycube.js b/samples/xinclude/styles/niftycube.js index 39377a3a80a..89cf6555774 100755 --- a/samples/xinclude/styles/niftycube.js +++ b/samples/xinclude/styles/niftycube.js @@ -1,298 +1,298 @@ -/* Nifty Corners Cube - rounded corners with CSS and Javascript -Copyright 2006 Alessandro Fulciniti (a.fulciniti@html.it) - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -var niftyOk=(document.getElementById && document.createElement && Array.prototype.push); -var niftyCss=false; - -String.prototype.find=function(what){ -return(this.indexOf(what)>=0 ? true : false); -} - -var oldonload=window.onload; -if(typeof(NiftyLoad)!='function') NiftyLoad=function(){}; -if(typeof(oldonload)=='function') - window.onload=function(){oldonload();AddCss();NiftyLoad()}; -else window.onload=function(){AddCss();NiftyLoad()}; - -function AddCss(){ -niftyCss=true; -var l=CreateEl("link"); -l.setAttribute("type","text/css"); -l.setAttribute("rel","stylesheet"); -l.setAttribute("href","styles/niftyCorners.css"); -l.setAttribute("media","screen"); -document.getElementsByTagName("head")[0].appendChild(l); -} - -function Nifty(selector,options){ -if(niftyOk==false) return; -if(niftyCss==false) AddCss(); -var i,v=selector.split(","),h=0; -if(options==null) options=""; -if(options.find("fixed-height")) - h=getElementsBySelector(v[0])[0].offsetHeight; -for(i=0;i0;i--) - d.appendChild(CreateStrip(i,side,color,border,btype)); -el.style.paddingBottom=0; -el.appendChild(d); -} - -function CreateStrip(index,side,color,border,btype){ -var x=CreateEl("b"); -x.className=btype+index; -x.style.backgroundColor=color; -x.style.borderColor=border; -if(side=="left"){ - x.style.borderRightWidth="0"; - x.style.marginRight="0"; - } -else if(side=="right"){ - x.style.borderLeftWidth="0"; - x.style.marginLeft="0"; - } -return(x); -} - -function CreateEl(x){ -return(document.createElement(x)); -} - -function FixIE(el){ -if(el.currentStyle!=null && el.currentStyle.hasLayout!=null && el.currentStyle.hasLayout==false) - el.style.display="inline-block"; -} - -function SameHeight(selector,maxh){ -var i,v=selector.split(","),t,j,els=[],gap; -for(i=0;imaxh) maxh=els[i].offsetHeight; - els[i].style.height="auto"; - } -for(i=0;i0){ - t=CreateEl("b");t.className="niftyfill";t.style.height=gap+"px"; - nc=els[i].lastChild; - if(nc.className=="niftycorners") - els[i].insertBefore(t,nc); - else els[i].appendChild(t); - } - } -} - -function getElementsBySelector(selector){ -var i,j,selid="",selclass="",tag=selector,tag2="",v2,k,f,a,s=[],objlist=[],c; -if(selector.find("#")){ //id selector like "tag#id" - if(selector.find(" ")){ //descendant selector like "tag#id tag" - s=selector.split(" "); - var fs=s[0].split("#"); - if(fs.length==1) return(objlist); - f=document.getElementById(fs[1]); - if(f){ - v=f.getElementsByTagName(s[1]); - for(i=0;i=0 ? true : false); +} + +var oldonload=window.onload; +if(typeof(NiftyLoad)!='function') NiftyLoad=function(){}; +if(typeof(oldonload)=='function') + window.onload=function(){oldonload();AddCss();NiftyLoad()}; +else window.onload=function(){AddCss();NiftyLoad()}; + +function AddCss(){ +niftyCss=true; +var l=CreateEl("link"); +l.setAttribute("type","text/css"); +l.setAttribute("rel","stylesheet"); +l.setAttribute("href","styles/niftyCorners.css"); +l.setAttribute("media","screen"); +document.getElementsByTagName("head")[0].appendChild(l); +} + +function Nifty(selector,options){ +if(niftyOk==false) return; +if(niftyCss==false) AddCss(); +var i,v=selector.split(","),h=0; +if(options==null) options=""; +if(options.find("fixed-height")) + h=getElementsBySelector(v[0])[0].offsetHeight; +for(i=0;i0;i--) + d.appendChild(CreateStrip(i,side,color,border,btype)); +el.style.paddingBottom=0; +el.appendChild(d); +} + +function CreateStrip(index,side,color,border,btype){ +var x=CreateEl("b"); +x.className=btype+index; +x.style.backgroundColor=color; +x.style.borderColor=border; +if(side=="left"){ + x.style.borderRightWidth="0"; + x.style.marginRight="0"; + } +else if(side=="right"){ + x.style.borderLeftWidth="0"; + x.style.marginLeft="0"; + } +return(x); +} + +function CreateEl(x){ +return(document.createElement(x)); +} + +function FixIE(el){ +if(el.currentStyle!=null && el.currentStyle.hasLayout!=null && el.currentStyle.hasLayout==false) + el.style.display="inline-block"; +} + +function SameHeight(selector,maxh){ +var i,v=selector.split(","),t,j,els=[],gap; +for(i=0;imaxh) maxh=els[i].offsetHeight; + els[i].style.height="auto"; + } +for(i=0;i0){ + t=CreateEl("b");t.className="niftyfill";t.style.height=gap+"px"; + nc=els[i].lastChild; + if(nc.className=="niftycorners") + els[i].insertBefore(t,nc); + else els[i].appendChild(t); + } + } +} + +function getElementsBySelector(selector){ +var i,j,selid="",selclass="",tag=selector,tag2="",v2,k,f,a,s=[],objlist=[],c; +if(selector.find("#")){ //id selector like "tag#id" + if(selector.find(" ")){ //descendant selector like "tag#id tag" + s=selector.split(" "); + var fs=s[0].split("#"); + if(fs.length==1) return(objlist); + f=document.getElementById(fs[1]); + if(f){ + v=f.getElementsByTagName(s[1]); + for(i=0;i - - - - - -return - system:trigger-system-task("org.exist.storage.BackupSystemTask", $params) +let $params := + + + + + + +return + system:trigger-system-task("org.exist.storage.BackupSystemTask", $params) diff --git a/src/org/exist/EventListener.java b/src/org/exist/EventListener.java index 8aae28fd0d5..37da0fb5798 100644 --- a/src/org/exist/EventListener.java +++ b/src/org/exist/EventListener.java @@ -1,32 +1,32 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2012 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist; - -/** - * @author Dmitriy Shabanov - * - */ -public interface EventListener { - - public void onEvent(T object); - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2012 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist; + +/** + * @author Dmitriy Shabanov + * + */ +public interface EventListener { + + public void onEvent(T object); + +} diff --git a/src/org/exist/backup/BackupHandler.java b/src/org/exist/backup/BackupHandler.java index dba6a22bf5e..9182e552ebf 100644 --- a/src/org/exist/backup/BackupHandler.java +++ b/src/org/exist/backup/BackupHandler.java @@ -1,41 +1,41 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2012 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.backup; - -import org.exist.collections.Collection; -import org.exist.dom.DocumentAtExist; -import org.exist.util.serializer.SAXSerializer; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.AttributesImpl; - -/** - * @author Dmitriy Shabanov - * - */ -public interface BackupHandler { - - public void backup(Collection colection, AttributesImpl attrs); - public void backup(Collection colection, SAXSerializer serializer) throws SAXException; - - public void backup(DocumentAtExist document, AttributesImpl attrs); - public void backup(DocumentAtExist document, SAXSerializer serializer) throws SAXException; -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2012 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.backup; + +import org.exist.collections.Collection; +import org.exist.dom.DocumentAtExist; +import org.exist.util.serializer.SAXSerializer; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.AttributesImpl; + +/** + * @author Dmitriy Shabanov + * + */ +public interface BackupHandler { + + public void backup(Collection colection, AttributesImpl attrs); + public void backup(Collection colection, SAXSerializer serializer) throws SAXException; + + public void backup(DocumentAtExist document, AttributesImpl attrs); + public void backup(DocumentAtExist document, SAXSerializer serializer) throws SAXException; +} diff --git a/src/org/exist/backup/BackupWriter.java b/src/org/exist/backup/BackupWriter.java index d86a50d2739..139b128ec6a 100644 --- a/src/org/exist/backup/BackupWriter.java +++ b/src/org/exist/backup/BackupWriter.java @@ -1,61 +1,61 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2006-2010 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.backup; - -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.io.Writer; - -import java.util.Properties; - - -/** - * Helper interface for writing backups. Serves as an abstraction for writing to different targets like directories or zip files. - */ -public interface BackupWriter -{ - Writer newContents() throws IOException; - - - void closeContents() throws IOException; - - - OutputStream newEntry( String name ) throws IOException; - - - void closeEntry() throws IOException; - - - void newCollection( String name ); - - - void closeCollection(); - - - void close() throws IOException; - - - void setProperties( Properties properties ) throws IOException; - - public void addToRoot(String name, File file) throws IOException; -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2006-2010 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.backup; + +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.io.Writer; + +import java.util.Properties; + + +/** + * Helper interface for writing backups. Serves as an abstraction for writing to different targets like directories or zip files. + */ +public interface BackupWriter +{ + Writer newContents() throws IOException; + + + void closeContents() throws IOException; + + + OutputStream newEntry( String name ) throws IOException; + + + void closeEntry() throws IOException; + + + void newCollection( String name ); + + + void closeCollection(); + + + void close() throws IOException; + + + void setProperties( Properties properties ) throws IOException; + + public void addToRoot(String name, File file) throws IOException; +} diff --git a/src/org/exist/backup/FileSystemWriter.java b/src/org/exist/backup/FileSystemWriter.java index 390d68a1a28..a3b9df81070 100644 --- a/src/org/exist/backup/FileSystemWriter.java +++ b/src/org/exist/backup/FileSystemWriter.java @@ -1,142 +1,142 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2006-2010 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.backup; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.Writer; - -import java.util.Properties; - -import org.apache.commons.io.FileUtils; -import org.exist.storage.DBBroker; -import org.exist.xmldb.XmldbURI; - - -/** - * Implementation of BackupWriter that writes to the file system. - */ -public class FileSystemWriter implements BackupWriter -{ - private File rootDir; - private File currentDir; - private File currentContents; - private Writer currentContentsOut; - private OutputStream currentOut; - private boolean dataWritten = false; - - public FileSystemWriter( String path ) - { - this( new File( path ) ); - } - - - public FileSystemWriter( File file ) - { - if( file.exists() ) { - - //removing "path" - file.delete(); - } - file.mkdirs(); - currentDir = file; - rootDir = file; - } - - public void newCollection( String name ) - { - File file; - if (XmldbURI.createInternal(name).isAbsolute()) { - file = new File( rootDir, name ); - } else { - file = new File( currentDir, name ); - } - - if( file.exists() ) { - file.delete(); - } - file.mkdirs(); - dataWritten = true; - currentDir = file; - } - - - public void closeCollection() - { - currentDir = currentDir.getParentFile(); - } - - - public void close() throws IOException - { - } - - - public Writer newContents() throws IOException - { - currentContents = new File( currentDir, "__contents__.xml" ); - currentContentsOut = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( currentContents ), "UTF-8" ) ); - dataWritten = true; - return( currentContentsOut ); - } - - - public void closeContents() throws IOException - { - currentContentsOut.close(); - } - - - public OutputStream newEntry( String name ) throws IOException - { - currentOut = new FileOutputStream( new File( currentDir, name ) ); - dataWritten = true; - return( currentOut ); - } - - - public void closeEntry() throws IOException - { - currentOut.close(); - } - - - public void setProperties( Properties properties ) throws IOException - { - if( dataWritten ) { - throw( new IOException( "Backup properties need to be set before any backup data is written" ) ); - } - final File propFile = new File( rootDir, "backup.properties" ); - final OutputStream os = new FileOutputStream( propFile ); - properties.store( os, "Backup properties" ); - os.close(); - } - - @Override - public void addToRoot(String name, File file) throws IOException { - FileUtils.copyFile(file, new File(rootDir, name)); - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2006-2010 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.backup; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.Writer; + +import java.util.Properties; + +import org.apache.commons.io.FileUtils; +import org.exist.storage.DBBroker; +import org.exist.xmldb.XmldbURI; + + +/** + * Implementation of BackupWriter that writes to the file system. + */ +public class FileSystemWriter implements BackupWriter +{ + private File rootDir; + private File currentDir; + private File currentContents; + private Writer currentContentsOut; + private OutputStream currentOut; + private boolean dataWritten = false; + + public FileSystemWriter( String path ) + { + this( new File( path ) ); + } + + + public FileSystemWriter( File file ) + { + if( file.exists() ) { + + //removing "path" + file.delete(); + } + file.mkdirs(); + currentDir = file; + rootDir = file; + } + + public void newCollection( String name ) + { + File file; + if (XmldbURI.createInternal(name).isAbsolute()) { + file = new File( rootDir, name ); + } else { + file = new File( currentDir, name ); + } + + if( file.exists() ) { + file.delete(); + } + file.mkdirs(); + dataWritten = true; + currentDir = file; + } + + + public void closeCollection() + { + currentDir = currentDir.getParentFile(); + } + + + public void close() throws IOException + { + } + + + public Writer newContents() throws IOException + { + currentContents = new File( currentDir, "__contents__.xml" ); + currentContentsOut = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( currentContents ), "UTF-8" ) ); + dataWritten = true; + return( currentContentsOut ); + } + + + public void closeContents() throws IOException + { + currentContentsOut.close(); + } + + + public OutputStream newEntry( String name ) throws IOException + { + currentOut = new FileOutputStream( new File( currentDir, name ) ); + dataWritten = true; + return( currentOut ); + } + + + public void closeEntry() throws IOException + { + currentOut.close(); + } + + + public void setProperties( Properties properties ) throws IOException + { + if( dataWritten ) { + throw( new IOException( "Backup properties need to be set before any backup data is written" ) ); + } + final File propFile = new File( rootDir, "backup.properties" ); + final OutputStream os = new FileOutputStream( propFile ); + properties.store( os, "Backup properties" ); + os.close(); + } + + @Override + public void addToRoot(String name, File file) throws IOException { + FileUtils.copyFile(file, new File(rootDir, name)); + } +} diff --git a/src/org/exist/backup/RestoreHandler.java b/src/org/exist/backup/RestoreHandler.java index 6e2a9646ffb..0cf41884c80 100644 --- a/src/org/exist/backup/RestoreHandler.java +++ b/src/org/exist/backup/RestoreHandler.java @@ -1,40 +1,40 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2012 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.backup; - -import org.exist.collections.Collection; -import org.exist.dom.DocumentAtExist; -import org.xml.sax.Attributes; -import org.xml.sax.ContentHandler; - -/** - * @author Dmitriy Shabanov - * - */ -public interface RestoreHandler extends ContentHandler { - - public void startCollectionRestore(Collection colection, Attributes atts); - public void endCollectionRestore(Collection colection); - - public void startDocumentRestore(DocumentAtExist document, Attributes atts); - public void endDocumentRestore(DocumentAtExist document); -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2012 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.backup; + +import org.exist.collections.Collection; +import org.exist.dom.DocumentAtExist; +import org.xml.sax.Attributes; +import org.xml.sax.ContentHandler; + +/** + * @author Dmitriy Shabanov + * + */ +public interface RestoreHandler extends ContentHandler { + + public void startCollectionRestore(Collection colection, Attributes atts); + public void endCollectionRestore(Collection colection); + + public void startDocumentRestore(DocumentAtExist document, Attributes atts); + public void endDocumentRestore(DocumentAtExist document); +} diff --git a/src/org/exist/backup/SystemImport.java b/src/org/exist/backup/SystemImport.java index 4b3b322c098..9b45204a33e 100644 --- a/src/org/exist/backup/SystemImport.java +++ b/src/org/exist/backup/SystemImport.java @@ -1,162 +1,162 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2012 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.backup; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.net.URISyntaxException; -import java.util.Properties; -import java.util.Stack; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - -import org.apache.log4j.Logger; -import org.exist.Database; -import org.exist.backup.restore.SystemImportHandler; -import org.exist.backup.restore.listener.RestoreListener; -import org.exist.config.ConfigurationException; -import org.exist.security.AuthenticationException; -import org.exist.security.PermissionDeniedException; -import org.exist.security.Subject; -import org.exist.storage.DBBroker; -import org.exist.util.EXistInputSource; -import org.exist.xmldb.XmldbURI; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; -import org.xmldb.api.base.ErrorCodes; -import org.xmldb.api.base.XMLDBException; - -/** - * Restore - * - * @author Dmitriy Shabanov - */ -public class SystemImport { - - public final static Logger LOG = Logger.getLogger( SystemImport.class ); - - private Database db; - - public SystemImport(Database db) { - this.db = db; - } - - public void restore(RestoreListener listener, String username, Object credentials, String newCredentials, File f, String uri) throws XMLDBException, FileNotFoundException, IOException, SAXException, ParserConfigurationException, URISyntaxException, AuthenticationException, ConfigurationException, PermissionDeniedException { - - //login - final DBBroker broker = db.authenticate(username, credentials); - try { - //set the new password - setAdminCredentials(broker, newCredentials); - - //get the backup descriptors, can be more than one if it was an incremental backup - final Stack descriptors = getBackupDescriptors(f); - - final SAXParserFactory saxFactory = SAXParserFactory.newInstance(); - saxFactory.setNamespaceAware(true); - saxFactory.setValidating(false); - final SAXParser sax = saxFactory.newSAXParser(); - final XMLReader reader = sax.getXMLReader(); - - try { - listener.restoreStarting(); - - while(!descriptors.isEmpty()) { - final BackupDescriptor descriptor = descriptors.pop(); - final EXistInputSource is = descriptor.getInputSource(); - is.setEncoding( "UTF-8" ); - - final SystemImportHandler handler = new SystemImportHandler(broker, listener, uri, descriptor); - - reader.setContentHandler(handler); - reader.parse(is); - } - } finally { - listener.restoreFinished(); - } - } finally { - db.release(broker); - } - } - - private Stack getBackupDescriptors(File contents) throws XMLDBException, IOException { - - final Stack descriptors = new Stack(); - - do { - final BackupDescriptor bd = getBackupDescriptor(contents); - - - descriptors.push(bd); - - // check if the system collection is in the backup. This should be processed first - final BackupDescriptor sysDescriptor = bd.getChildBackupDescriptor(XmldbURI.SYSTEM_COLLECTION_NAME); - - // check if the system/security collection is in the backup, this must be the first system collection processed - if(sysDescriptor != null) { - descriptors.push(sysDescriptor); - - final BackupDescriptor secDescriptor = sysDescriptor.getChildBackupDescriptor("security"); - if(secDescriptor != null) { - descriptors.push(secDescriptor); - } - } - - contents = null; - - final Properties properties = bd.getProperties(); - if((properties != null ) && "yes".equals(properties.getProperty("incremental", "no"))) { - final String previous = properties.getProperty("previous", ""); - - if(previous.length() > 0) { - contents = new File(bd.getParentDir(), previous); - - if(!contents.canRead()) { - throw new XMLDBException(ErrorCodes.PERMISSION_DENIED, "Required part of incremental backup not found: " + contents.getAbsolutePath()); - } - } - } - } while(contents != null); - - return descriptors; - } - - private BackupDescriptor getBackupDescriptor(File f) throws IOException { - final BackupDescriptor bd; - if(f.isDirectory()) { - bd = new FileSystemBackupDescriptor(new File(new File(f, "db"), BackupDescriptor.COLLECTION_DESCRIPTOR)); - } else if(f.getName().toLowerCase().endsWith( ".zip" )) { - bd = new ZipArchiveBackupDescriptor(f); - } else { - bd = new FileSystemBackupDescriptor(f); - } - return bd; - } - - private void setAdminCredentials(DBBroker broker, String newCredentials) throws ConfigurationException, PermissionDeniedException { - final Subject subject = broker.getSubject(); - subject.setPassword(newCredentials); - subject.save(broker); - } +/* + * eXist Open Source Native XML Database + * Copyright (C) 2012 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.backup; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.net.URISyntaxException; +import java.util.Properties; +import java.util.Stack; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; + +import org.apache.log4j.Logger; +import org.exist.Database; +import org.exist.backup.restore.SystemImportHandler; +import org.exist.backup.restore.listener.RestoreListener; +import org.exist.config.ConfigurationException; +import org.exist.security.AuthenticationException; +import org.exist.security.PermissionDeniedException; +import org.exist.security.Subject; +import org.exist.storage.DBBroker; +import org.exist.util.EXistInputSource; +import org.exist.xmldb.XmldbURI; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; +import org.xmldb.api.base.ErrorCodes; +import org.xmldb.api.base.XMLDBException; + +/** + * Restore + * + * @author Dmitriy Shabanov + */ +public class SystemImport { + + public final static Logger LOG = Logger.getLogger( SystemImport.class ); + + private Database db; + + public SystemImport(Database db) { + this.db = db; + } + + public void restore(RestoreListener listener, String username, Object credentials, String newCredentials, File f, String uri) throws XMLDBException, FileNotFoundException, IOException, SAXException, ParserConfigurationException, URISyntaxException, AuthenticationException, ConfigurationException, PermissionDeniedException { + + //login + final DBBroker broker = db.authenticate(username, credentials); + try { + //set the new password + setAdminCredentials(broker, newCredentials); + + //get the backup descriptors, can be more than one if it was an incremental backup + final Stack descriptors = getBackupDescriptors(f); + + final SAXParserFactory saxFactory = SAXParserFactory.newInstance(); + saxFactory.setNamespaceAware(true); + saxFactory.setValidating(false); + final SAXParser sax = saxFactory.newSAXParser(); + final XMLReader reader = sax.getXMLReader(); + + try { + listener.restoreStarting(); + + while(!descriptors.isEmpty()) { + final BackupDescriptor descriptor = descriptors.pop(); + final EXistInputSource is = descriptor.getInputSource(); + is.setEncoding( "UTF-8" ); + + final SystemImportHandler handler = new SystemImportHandler(broker, listener, uri, descriptor); + + reader.setContentHandler(handler); + reader.parse(is); + } + } finally { + listener.restoreFinished(); + } + } finally { + db.release(broker); + } + } + + private Stack getBackupDescriptors(File contents) throws XMLDBException, IOException { + + final Stack descriptors = new Stack(); + + do { + final BackupDescriptor bd = getBackupDescriptor(contents); + + + descriptors.push(bd); + + // check if the system collection is in the backup. This should be processed first + final BackupDescriptor sysDescriptor = bd.getChildBackupDescriptor(XmldbURI.SYSTEM_COLLECTION_NAME); + + // check if the system/security collection is in the backup, this must be the first system collection processed + if(sysDescriptor != null) { + descriptors.push(sysDescriptor); + + final BackupDescriptor secDescriptor = sysDescriptor.getChildBackupDescriptor("security"); + if(secDescriptor != null) { + descriptors.push(secDescriptor); + } + } + + contents = null; + + final Properties properties = bd.getProperties(); + if((properties != null ) && "yes".equals(properties.getProperty("incremental", "no"))) { + final String previous = properties.getProperty("previous", ""); + + if(previous.length() > 0) { + contents = new File(bd.getParentDir(), previous); + + if(!contents.canRead()) { + throw new XMLDBException(ErrorCodes.PERMISSION_DENIED, "Required part of incremental backup not found: " + contents.getAbsolutePath()); + } + } + } + } while(contents != null); + + return descriptors; + } + + private BackupDescriptor getBackupDescriptor(File f) throws IOException { + final BackupDescriptor bd; + if(f.isDirectory()) { + bd = new FileSystemBackupDescriptor(new File(new File(f, "db"), BackupDescriptor.COLLECTION_DESCRIPTOR)); + } else if(f.getName().toLowerCase().endsWith( ".zip" )) { + bd = new ZipArchiveBackupDescriptor(f); + } else { + bd = new FileSystemBackupDescriptor(f); + } + return bd; + } + + private void setAdminCredentials(DBBroker broker, String newCredentials) throws ConfigurationException, PermissionDeniedException { + final Subject subject = broker.getSubject(); + subject.setPassword(newCredentials); + subject.save(broker); + } } \ No newline at end of file diff --git a/src/org/exist/backup/ZipWriter.java b/src/org/exist/backup/ZipWriter.java index 96a39f76f8f..98e8d931ff7 100644 --- a/src/org/exist/backup/ZipWriter.java +++ b/src/org/exist/backup/ZipWriter.java @@ -1,149 +1,149 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2006-2010 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.backup; - -import java.io.*; - -import java.util.Properties; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; - - -/** - * Implementation of BackupWriter that writes to a zip file. - */ -public class ZipWriter implements BackupWriter -{ - private String currentPath; - private ZipOutputStream out; - private StringWriter contents; - private boolean dataWritten = false; - - public ZipWriter( String zipFile, String collection ) throws IOException - { - this( new File( zipFile ), collection ); - } - - - public ZipWriter( File zipFile, String collection ) throws IOException - { - out = new ZipOutputStream( new FileOutputStream( zipFile ) ); - currentPath = collection; - } - - public Writer newContents() throws IOException - { - contents = new StringWriter(); - return( contents ); - } - - - public void closeContents() throws IOException - { - final ZipEntry entry = new ZipEntry( mkRelative( currentPath ) + "/__contents__.xml" ); - out.putNextEntry( entry ); - out.write( contents.toString().getBytes( "UTF-8" ) ); - out.closeEntry(); - dataWritten = true; - } - - - public OutputStream newEntry( String name ) throws IOException - { - final ZipEntry entry = new ZipEntry( mkRelative( currentPath ) + '/' + name ); - out.putNextEntry( entry ); - dataWritten = true; - return( out ); - } - - - public void closeEntry() throws IOException - { - out.closeEntry(); - } - - - public void newCollection( String name ) - { - if( name.startsWith( "/" ) ) { - currentPath = name; - } else { - currentPath = currentPath + '/' + name; - } - } - - - public void closeCollection() - { - final int p = currentPath.lastIndexOf( '/' ); - - if( p > 0 ) { - currentPath = currentPath.substring( 0, p ); - } - } - - - public void close() throws IOException - { - out.close(); - } - - - public void setProperties( Properties properties ) throws IOException - { - if( dataWritten ) { - throw( new IOException( "Backup properties need to be set before any backup data is written" ) ); - } - final ZipEntry entry = new ZipEntry( "backup.properties" ); - out.putNextEntry( entry ); - properties.store( out, "Backup properties" ); - out.closeEntry(); - } - - public void addToRoot(String name, File file) throws IOException { - if (dataWritten) { - throw new IOException("Additional files have to be added before backup data is written"); - } - final ZipEntry entry = new ZipEntry(name); - out.putNextEntry(entry); - - final byte[] buf = new byte[4096]; - int len; - final FileInputStream is = new FileInputStream(file); - try { - while ((len = is.read(buf)) > 0) { - out.write(buf, 0, len); - } - } finally { - is.close(); - } - out.closeEntry(); - } - - private String mkRelative( String path ) - { - if( ( path.length() > 0 ) && ( path.charAt( 0 ) == '/' ) ) { - return( path.substring( 1 ) ); - } - return( path ); - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2006-2010 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.backup; + +import java.io.*; + +import java.util.Properties; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + + +/** + * Implementation of BackupWriter that writes to a zip file. + */ +public class ZipWriter implements BackupWriter +{ + private String currentPath; + private ZipOutputStream out; + private StringWriter contents; + private boolean dataWritten = false; + + public ZipWriter( String zipFile, String collection ) throws IOException + { + this( new File( zipFile ), collection ); + } + + + public ZipWriter( File zipFile, String collection ) throws IOException + { + out = new ZipOutputStream( new FileOutputStream( zipFile ) ); + currentPath = collection; + } + + public Writer newContents() throws IOException + { + contents = new StringWriter(); + return( contents ); + } + + + public void closeContents() throws IOException + { + final ZipEntry entry = new ZipEntry( mkRelative( currentPath ) + "/__contents__.xml" ); + out.putNextEntry( entry ); + out.write( contents.toString().getBytes( "UTF-8" ) ); + out.closeEntry(); + dataWritten = true; + } + + + public OutputStream newEntry( String name ) throws IOException + { + final ZipEntry entry = new ZipEntry( mkRelative( currentPath ) + '/' + name ); + out.putNextEntry( entry ); + dataWritten = true; + return( out ); + } + + + public void closeEntry() throws IOException + { + out.closeEntry(); + } + + + public void newCollection( String name ) + { + if( name.startsWith( "/" ) ) { + currentPath = name; + } else { + currentPath = currentPath + '/' + name; + } + } + + + public void closeCollection() + { + final int p = currentPath.lastIndexOf( '/' ); + + if( p > 0 ) { + currentPath = currentPath.substring( 0, p ); + } + } + + + public void close() throws IOException + { + out.close(); + } + + + public void setProperties( Properties properties ) throws IOException + { + if( dataWritten ) { + throw( new IOException( "Backup properties need to be set before any backup data is written" ) ); + } + final ZipEntry entry = new ZipEntry( "backup.properties" ); + out.putNextEntry( entry ); + properties.store( out, "Backup properties" ); + out.closeEntry(); + } + + public void addToRoot(String name, File file) throws IOException { + if (dataWritten) { + throw new IOException("Additional files have to be added before backup data is written"); + } + final ZipEntry entry = new ZipEntry(name); + out.putNextEntry(entry); + + final byte[] buf = new byte[4096]; + int len; + final FileInputStream is = new FileInputStream(file); + try { + while ((len = is.read(buf)) > 0) { + out.write(buf, 0, len); + } + } finally { + is.close(); + } + out.closeEntry(); + } + + private String mkRelative( String path ) + { + if( ( path.length() > 0 ) && ( path.charAt( 0 ) == '/' ) ) { + return( path.substring( 1 ) ); + } + return( path ); + } +} diff --git a/src/org/exist/client/Messages.java b/src/org/exist/client/Messages.java index e11f2233b9a..8865865aaf0 100644 --- a/src/org/exist/client/Messages.java +++ b/src/org/exist/client/Messages.java @@ -1,43 +1,43 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2012 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.client; - -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -public class Messages { - private static final String BUNDLE_NAME = "org.exist.client.messages"; //$NON-NLS-1$ - - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle - .getBundle(BUNDLE_NAME); - - private Messages() { - } - - public static String getString(String key) { - try { - return RESOURCE_BUNDLE.getString(key); - } catch (final MissingResourceException e) { - return '!' + key + '!'; - } - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2012 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.client; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +public class Messages { + private static final String BUNDLE_NAME = "org.exist.client.messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle + .getBundle(BUNDLE_NAME); + + private Messages() { + } + + public static String getString(String key) { + try { + return RESOURCE_BUNDLE.getString(key); + } catch (final MissingResourceException e) { + return '!' + key + '!'; + } + } +} diff --git a/src/org/exist/client/PrettyXmldbURI.java b/src/org/exist/client/PrettyXmldbURI.java index a0927140ed8..5b10f0c0e35 100644 --- a/src/org/exist/client/PrettyXmldbURI.java +++ b/src/org/exist/client/PrettyXmldbURI.java @@ -1,42 +1,42 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2012 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.client; - -import org.exist.xmldb.XmldbURI; -import org.exist.xquery.util.URIUtils; - -public class PrettyXmldbURI { - - private XmldbURI target; - - public PrettyXmldbURI(XmldbURI target) { - this.target=target; - } - - public XmldbURI getTargetURI() { - return target; - } - - public String toString() { - return URIUtils.urlDecodeUtf8(target.toString()); - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2012 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.client; + +import org.exist.xmldb.XmldbURI; +import org.exist.xquery.util.URIUtils; + +public class PrettyXmldbURI { + + private XmldbURI target; + + public PrettyXmldbURI(XmldbURI target) { + this.target=target; + } + + public XmldbURI getTargetURI() { + return target; + } + + public String toString() { + return URIUtils.urlDecodeUtf8(target.toString()); + } +} diff --git a/src/org/exist/client/messages.properties b/src/org/exist/client/messages.properties index 8be11b86a8d..a403d508917 100644 --- a/src/org/exist/client/messages.properties +++ b/src/org/exist/client/messages.properties @@ -1,296 +1,296 @@ -ClientFrame.0=Cut -ClientFrame.1=Copy -ClientFrame.2=Paste -ClientFrame.3=eXist Admin Client -ClientFrame.5=Go to parent collection -ClientFrame.7=Refresh collection view -ClientFrame.9=Create new collection -ClientFrame.11=Stores one or more files to the database -ClientFrame.13=Delete selected files or collections -ClientFrame.14=icons/Preferences24.gif -ClientFrame.15=Edit owners/permissions for selected resource -ClientFrame.17=Create backup -ClientFrame.19=Restore files from backup -ClientFrame.20=icons/keyring-small.png -ClientFrame.21=Manage users -ClientFrame.23=Query the database with XPath -ClientFrame.24=Console Menu -ClientFrame.27=eXist Admin Client connected - -ClientFrame.31=File -ClientFrame.32=Store files/directories -ClientFrame.34=Create collection -ClientFrame.36=Create blank document -ClientFrame.38=Name of the XML resource (extension incluse) -ClientFrame.39= -ClientFrame.40=Remove -ClientFrame.42=Copy -ClientFrame.44=Move -ClientFrame.46=Rename -ClientFrame.47=Export a resource to file ... -ClientFrame.48=Reindex collection -ClientFrame.50=Resource properties -ClientFrame.52=Quit -ClientFrame.54=Tools -ClientFrame.55=Query -ClientFrame.57=Edit Users -ClientFrame.59=Edit Indexes -ClientFrame.60=Edit Triggers -ClientFrame.61=Edit Policies -ClientFrame.62a=Enter service mode -ClientFrame.62b=Exit service mode -ClientFrame.63=Backup -ClientFrame.64=Restore -ClientFrame.65=Connection -ClientFrame.66=Shutdown -ClientFrame.67=shutdown\n -ClientFrame.69=Connect -ClientFrame.70=Open login panel to connect to change server or identity. -ClientFrame.71=eXist Admin Client connected - -ClientFrame.75=Connection to -ClientFrame.77=\ failed\! -ClientFrame.78=Can't reconnect to -ClientFrame.80=Options -ClientFrame.81=Indent -ClientFrame.82=yes -ClientFrame.83=yes -ClientFrame.84=no -ClientFrame.85=Expand-XIncludes -ClientFrame.86=yes -ClientFrame.87=yes -ClientFrame.88=no -ClientFrame.89=Help -ClientFrame.90=About -ClientFrame.91=exist: -ClientFrame.92=\ -ClientFrame.93=Backspace -ClientFrame.94=cd ..\n -ClientFrame.96=Please enter name of new collection -ClientFrame.99=Please enter a valid XML:DB base URI (without -ClientFrame.100=collection path) -ClientFrame.102=Connection to -ClientFrame.103=\ failed\! -ClientFrame.104=Are you sure you want to remove the selected -ClientFrame.105=resources? -ClientFrame.106=Confirm deletion -ClientFrame.107=Remove Progress -ClientFrame.108= -ClientFrame.111=Select target collection -ClientFrame.112=Move -ClientFrame.115=Moving -ClientFrame.116=\ to -ClientFrame.117=... -ClientFrame.118=Move completed. -ClientFrame.119=Please enter a new filename -ClientFrame.120=Rename -ClientFrame.121=Could not parse new name as a valid uri: -ClientFrame.124=Renaming -ClientFrame.125=\ to -ClientFrame.126=... -ClientFrame.127=Rename completed. -ClientFrame.128=Select target collection -ClientFrame.129=Copy -ClientFrame.132=Copying -ClientFrame.133=\ to -ClientFrame.134=... -ClientFrame.135=Copy completed. -ClientFrame.136=Only collections can be reindexed. -ClientFrame.137=Error -ClientFrame.138=Are you sure you want to reindex the selected collections \nand all resources below them? -ClientFrame.139=Confirm reindex -ClientFrame.142=Reindexing collection -ClientFrame.143=... -ClientFrame.144=Reindex completed. -ClientFrame.145=working-dir -ClientFrame.146=Select files or directories to store -ClientFrame.147=XMLDBException: -ClientFrame.148=working-dir -ClientFrame.157=Create Backup -ClientFrame.166=Zip files -ClientFrame.167=__contents__.xml -ClientFrame.168=__contents__.xml files -ClientFrame.169=Select backup file for restore -ClientFrame.170=dba/admin password to use for the restore process: -ClientFrame.171=Admin Password -ClientFrame.181=Exception: -ClientFrame.184=Edit Users -ClientFrame.185=Failed to retrieve UserManagementService -ClientFrame.186=Edit Indexes -ClientFrame.187=Could not get system collection -ClientFrame.190=XACML is not currently enabled. To enable it, add\n\n \n\nto conf.xml and restart eXist. -ClientFrame.191=Could not get database instance manager to determine if XACML is enabled -ClientFrame.194=... -ClientFrame.195= -ClientFrame.196= -ClientFrame.197=XMLDB Exception: -ClientFrame.198=\n -ClientFrame.204=cd " -ClientFrame.205=\n -ClientFrame.206=XMLDB error: -ClientFrame.207=Resource -ClientFrame.208=Date -ClientFrame.209=Owner -ClientFrame.210=Group -ClientFrame.211=Permissions -ClientFrame.212=Column does not eXist\! -ClientFrame.213=eXist Database Login -ClientFrame.214=Message: -ClientFrame.215=Exception Stacktrace: -ClientFrame.216=Error -ClientFrame.217=Message: -ClientFrame.218=Exception Stacktrace: -ClientFrame.219=Error -ClientFrame.220=Binary resources -ClientFrame.221=XML files -ClientFrame.222=Permission Denied -LoginPanel.2=Username -LoginPanel.1=favourites -LoginPanel.3=Password -LoginPanel.4=Type -LoginPanel.5=Remote -LoginPanel.6=Embedded -LoginPanel.8=Configuration -LoginPanel.9=An eXist configuration file for an embed instance -LoginPanel.10=Select -LoginPanel.11=Select an alternate conf file for embed mode. -LoginPanel.12=URL -LoginPanel.13=Title -LoginPanel.14=Favourites -LoginPanel.15=Select -LoginPanel.16=Select favourite -LoginPanel.17=Save -LoginPanel.18=Save settings -LoginPanel.19=A connection with this name already exists. Ok to overwrite? -LoginPanel.20=Conflict -LoginPanel.21=Remove -LoginPanel.22=Remove favourite -LoginPanel.23=Export -LoginPanel.24=Export favourites to file -LoginPanel.25=favourites.xml -LoginPanel.26=No favourites file selected -LoginPanel.27=Error -LoginPanel.28=Cannot write selected file -LoginPanel.29=Error -LoginPanel.30=Import -LoginPanel.31=Import favourites from file -LoginPanel.33=No favourites file selected -LoginPanel.34=Error -LoginPanel.35=Cannot read selected file -LoginPanel.36=Error -LoginPanel.37=Select an Exist instance configuration file -#Leave this value -LoginPanel.42=name -#Leave this value -LoginPanel.43=username -#Leave this value -LoginPanel.44=password -#Leave this value -LoginPanel.45=url -#Leave this value -LoginPanel.46=configuration -LoginPanel.47=SSL -LoginPanel.48=Use a secure HTTPS connection. -LoginPanel.49=By default eXist-db receives HTTPS connections on port 8443. Note: a (reverse) proxy or \na webcontainer like Tomcat might influence the availability of this port.\n -LoginPanel.50=Connect -LoginPanel.51=Close -UploadDialog.0=Storing files ... -UploadDialog.1=Stored\: -UploadDialog.2=Calculating file sizes ... -UploadDialog.3=Directory\: -UploadDialog.4=Uploading file\: -UploadDialog.5=Size\: -UploadDialog.6=0K -UploadDialog.7=Progress\: -UploadDialog.9=Cancel -UploadDialog.20=Close -UploadDialog.11=Close -UploadDialog.12=K -UploadDialog.13=Close -#Empty string -UploadDialog.14= -#\\n -UploadDialog.15=\n -UploadDialog.16=Storing ... -UploadDialog.17=Storing words -UploadDialog.18=Storing elements -UploadDialog.19=Storing nodes -DocumentView.0=View Document -DocumentView.6=Resource is already locked by user -DocumentView.7=. Should I try to relock it? -DocumentView.8=Resource locked -DocumentView.9=Resource cannot be locked. Opening read-only. -DocumentView.10=XMLDB error\: -DocumentView.13=Error -DocumentView.16=File -DocumentView.17=Save -DocumentView.20=Store the modified data back into the database. -DocumentView.22=Store a new document into the database. -DocumentView.24=Export to file. -DocumentView.26=Copy selection. -DocumentView.28=Cut selection. -DocumentView.30=Paste selection. -DocumentView.32=Refresh Document. -DocumentView.33=XML -DocumentView.34=Loading -DocumentView.35= ... -DocumentView.36=Storing -DocumentView.37=XMLDBException\: -DocumentView.38=Name of the XML resource (extension incluse) -DocumentView.39=Storing -DocumentView.40=XMLDBException\: -DocumentView.41=URISyntaxException\: -DocumentView.44=Select file for export -DocumentView.45=File exists. Overwrite? -DocumentView.46=Overwrite? -DocumentView.48=XMLDBException\: -DocumentView.52=Loaded -DocumentView.53= from -CreateBackupDialog.1=Collection\: -CreateBackupDialog.2=Target\: -CreateBackupDialog.3=Select -CreateBackupDialog.4=Select ZIP file or directory. -CreateBackupDialog.5=Select target for backup -CreateBackupDialog.6a=Target -CreateBackupDialog.6b= exists. OK to delete? -CreateBackupDialog.6c=Confirm deletion -QueryDialog.0=Query Dialog -QueryDialog.opentooltip=Read query from file. -QueryDialog.saveastooltip=Write query to file. -QueryDialog.saveresultstooltip=Write result to file. -QueryDialog.copytooltip=Copy selection. -QueryDialog.cuttooltip=Cut selection. -QueryDialog.pastetooltip=Paste selection. -QueryDialog.compiletooltip=Compile only query. -QueryDialog.submittooltip=Submit query. -QueryDialog.submitbutton=Submit -QueryDialog.killtooltip=Kill query. -QueryDialog.killbutton=Kill job -QueryDialog.resultslabel=Results\: -QueryDialog.XMLtab=XML -QueryDialog.tracetab=Trace -QueryDialog.inputtab=Query Input\: -QueryDialog.historylabel=History\: -QueryDialog.contextlabel=Context\: -QueryDialog.collectionretrievalerrormessage=An error occurred while retrieving collections list -QueryDialog.maxlabel=Display max.\: -QueryDialog.opendialog=Select query file -QueryDialog.Error=Error -QueryDialog.cannotreadmessage=Cannot read query from file -QueryDialog.savedialogpre=Select file for -QueryDialog.savedialogpost=export -QueryDialog.cannotsavemessagepre=Can not write -QueryDialog.cannotsavemessageinf=to file -QueryDialog.savedialogconfirm=File exists. Overwrite? -QueryDialog.compilemessage=Compiling query ... -QueryDialog.Compilation=Compilation -QueryDialog.Execution=Execution -QueryDialog.compilationerrormessage=An exception occurred during query compilation -QueryDialog.processingquerymessage=Processing query ... -QueryDialog.retrievingmessage=Retrieving results ... -QueryDialog.retrievalerrormessage=An error occurred while retrieving results -QueryDialog.Found=Found -QueryDialog.items=items -QueryDialog.queryrunerrormessage=An exception occurred during query execution -TriggersDialog.Collection=Collection -TriggersDialog.Triggers=Triggers -TriggersDialog.addbutton=Add -TriggersDialog.deletebutton=Delete +ClientFrame.0=Cut +ClientFrame.1=Copy +ClientFrame.2=Paste +ClientFrame.3=eXist Admin Client +ClientFrame.5=Go to parent collection +ClientFrame.7=Refresh collection view +ClientFrame.9=Create new collection +ClientFrame.11=Stores one or more files to the database +ClientFrame.13=Delete selected files or collections +ClientFrame.14=icons/Preferences24.gif +ClientFrame.15=Edit owners/permissions for selected resource +ClientFrame.17=Create backup +ClientFrame.19=Restore files from backup +ClientFrame.20=icons/keyring-small.png +ClientFrame.21=Manage users +ClientFrame.23=Query the database with XPath +ClientFrame.24=Console Menu +ClientFrame.27=eXist Admin Client connected - +ClientFrame.31=File +ClientFrame.32=Store files/directories +ClientFrame.34=Create collection +ClientFrame.36=Create blank document +ClientFrame.38=Name of the XML resource (extension incluse) +ClientFrame.39= +ClientFrame.40=Remove +ClientFrame.42=Copy +ClientFrame.44=Move +ClientFrame.46=Rename +ClientFrame.47=Export a resource to file ... +ClientFrame.48=Reindex collection +ClientFrame.50=Resource properties +ClientFrame.52=Quit +ClientFrame.54=Tools +ClientFrame.55=Query +ClientFrame.57=Edit Users +ClientFrame.59=Edit Indexes +ClientFrame.60=Edit Triggers +ClientFrame.61=Edit Policies +ClientFrame.62a=Enter service mode +ClientFrame.62b=Exit service mode +ClientFrame.63=Backup +ClientFrame.64=Restore +ClientFrame.65=Connection +ClientFrame.66=Shutdown +ClientFrame.67=shutdown\n +ClientFrame.69=Connect +ClientFrame.70=Open login panel to connect to change server or identity. +ClientFrame.71=eXist Admin Client connected - +ClientFrame.75=Connection to +ClientFrame.77=\ failed\! +ClientFrame.78=Can't reconnect to +ClientFrame.80=Options +ClientFrame.81=Indent +ClientFrame.82=yes +ClientFrame.83=yes +ClientFrame.84=no +ClientFrame.85=Expand-XIncludes +ClientFrame.86=yes +ClientFrame.87=yes +ClientFrame.88=no +ClientFrame.89=Help +ClientFrame.90=About +ClientFrame.91=exist: +ClientFrame.92=\ +ClientFrame.93=Backspace +ClientFrame.94=cd ..\n +ClientFrame.96=Please enter name of new collection +ClientFrame.99=Please enter a valid XML:DB base URI (without +ClientFrame.100=collection path) +ClientFrame.102=Connection to +ClientFrame.103=\ failed\! +ClientFrame.104=Are you sure you want to remove the selected +ClientFrame.105=resources? +ClientFrame.106=Confirm deletion +ClientFrame.107=Remove Progress +ClientFrame.108= +ClientFrame.111=Select target collection +ClientFrame.112=Move +ClientFrame.115=Moving +ClientFrame.116=\ to +ClientFrame.117=... +ClientFrame.118=Move completed. +ClientFrame.119=Please enter a new filename +ClientFrame.120=Rename +ClientFrame.121=Could not parse new name as a valid uri: +ClientFrame.124=Renaming +ClientFrame.125=\ to +ClientFrame.126=... +ClientFrame.127=Rename completed. +ClientFrame.128=Select target collection +ClientFrame.129=Copy +ClientFrame.132=Copying +ClientFrame.133=\ to +ClientFrame.134=... +ClientFrame.135=Copy completed. +ClientFrame.136=Only collections can be reindexed. +ClientFrame.137=Error +ClientFrame.138=Are you sure you want to reindex the selected collections \nand all resources below them? +ClientFrame.139=Confirm reindex +ClientFrame.142=Reindexing collection +ClientFrame.143=... +ClientFrame.144=Reindex completed. +ClientFrame.145=working-dir +ClientFrame.146=Select files or directories to store +ClientFrame.147=XMLDBException: +ClientFrame.148=working-dir +ClientFrame.157=Create Backup +ClientFrame.166=Zip files +ClientFrame.167=__contents__.xml +ClientFrame.168=__contents__.xml files +ClientFrame.169=Select backup file for restore +ClientFrame.170=dba/admin password to use for the restore process: +ClientFrame.171=Admin Password +ClientFrame.181=Exception: +ClientFrame.184=Edit Users +ClientFrame.185=Failed to retrieve UserManagementService +ClientFrame.186=Edit Indexes +ClientFrame.187=Could not get system collection +ClientFrame.190=XACML is not currently enabled. To enable it, add\n\n \n\nto conf.xml and restart eXist. +ClientFrame.191=Could not get database instance manager to determine if XACML is enabled +ClientFrame.194=... +ClientFrame.195= +ClientFrame.196= +ClientFrame.197=XMLDB Exception: +ClientFrame.198=\n +ClientFrame.204=cd " +ClientFrame.205=\n +ClientFrame.206=XMLDB error: +ClientFrame.207=Resource +ClientFrame.208=Date +ClientFrame.209=Owner +ClientFrame.210=Group +ClientFrame.211=Permissions +ClientFrame.212=Column does not eXist\! +ClientFrame.213=eXist Database Login +ClientFrame.214=Message: +ClientFrame.215=Exception Stacktrace: +ClientFrame.216=Error +ClientFrame.217=Message: +ClientFrame.218=Exception Stacktrace: +ClientFrame.219=Error +ClientFrame.220=Binary resources +ClientFrame.221=XML files +ClientFrame.222=Permission Denied +LoginPanel.2=Username +LoginPanel.1=favourites +LoginPanel.3=Password +LoginPanel.4=Type +LoginPanel.5=Remote +LoginPanel.6=Embedded +LoginPanel.8=Configuration +LoginPanel.9=An eXist configuration file for an embed instance +LoginPanel.10=Select +LoginPanel.11=Select an alternate conf file for embed mode. +LoginPanel.12=URL +LoginPanel.13=Title +LoginPanel.14=Favourites +LoginPanel.15=Select +LoginPanel.16=Select favourite +LoginPanel.17=Save +LoginPanel.18=Save settings +LoginPanel.19=A connection with this name already exists. Ok to overwrite? +LoginPanel.20=Conflict +LoginPanel.21=Remove +LoginPanel.22=Remove favourite +LoginPanel.23=Export +LoginPanel.24=Export favourites to file +LoginPanel.25=favourites.xml +LoginPanel.26=No favourites file selected +LoginPanel.27=Error +LoginPanel.28=Cannot write selected file +LoginPanel.29=Error +LoginPanel.30=Import +LoginPanel.31=Import favourites from file +LoginPanel.33=No favourites file selected +LoginPanel.34=Error +LoginPanel.35=Cannot read selected file +LoginPanel.36=Error +LoginPanel.37=Select an Exist instance configuration file +#Leave this value +LoginPanel.42=name +#Leave this value +LoginPanel.43=username +#Leave this value +LoginPanel.44=password +#Leave this value +LoginPanel.45=url +#Leave this value +LoginPanel.46=configuration +LoginPanel.47=SSL +LoginPanel.48=Use a secure HTTPS connection. +LoginPanel.49=By default eXist-db receives HTTPS connections on port 8443. Note: a (reverse) proxy or \na webcontainer like Tomcat might influence the availability of this port.\n +LoginPanel.50=Connect +LoginPanel.51=Close +UploadDialog.0=Storing files ... +UploadDialog.1=Stored\: +UploadDialog.2=Calculating file sizes ... +UploadDialog.3=Directory\: +UploadDialog.4=Uploading file\: +UploadDialog.5=Size\: +UploadDialog.6=0K +UploadDialog.7=Progress\: +UploadDialog.9=Cancel +UploadDialog.20=Close +UploadDialog.11=Close +UploadDialog.12=K +UploadDialog.13=Close +#Empty string +UploadDialog.14= +#\\n +UploadDialog.15=\n +UploadDialog.16=Storing ... +UploadDialog.17=Storing words +UploadDialog.18=Storing elements +UploadDialog.19=Storing nodes +DocumentView.0=View Document +DocumentView.6=Resource is already locked by user +DocumentView.7=. Should I try to relock it? +DocumentView.8=Resource locked +DocumentView.9=Resource cannot be locked. Opening read-only. +DocumentView.10=XMLDB error\: +DocumentView.13=Error +DocumentView.16=File +DocumentView.17=Save +DocumentView.20=Store the modified data back into the database. +DocumentView.22=Store a new document into the database. +DocumentView.24=Export to file. +DocumentView.26=Copy selection. +DocumentView.28=Cut selection. +DocumentView.30=Paste selection. +DocumentView.32=Refresh Document. +DocumentView.33=XML +DocumentView.34=Loading +DocumentView.35= ... +DocumentView.36=Storing +DocumentView.37=XMLDBException\: +DocumentView.38=Name of the XML resource (extension incluse) +DocumentView.39=Storing +DocumentView.40=XMLDBException\: +DocumentView.41=URISyntaxException\: +DocumentView.44=Select file for export +DocumentView.45=File exists. Overwrite? +DocumentView.46=Overwrite? +DocumentView.48=XMLDBException\: +DocumentView.52=Loaded +DocumentView.53= from +CreateBackupDialog.1=Collection\: +CreateBackupDialog.2=Target\: +CreateBackupDialog.3=Select +CreateBackupDialog.4=Select ZIP file or directory. +CreateBackupDialog.5=Select target for backup +CreateBackupDialog.6a=Target +CreateBackupDialog.6b= exists. OK to delete? +CreateBackupDialog.6c=Confirm deletion +QueryDialog.0=Query Dialog +QueryDialog.opentooltip=Read query from file. +QueryDialog.saveastooltip=Write query to file. +QueryDialog.saveresultstooltip=Write result to file. +QueryDialog.copytooltip=Copy selection. +QueryDialog.cuttooltip=Cut selection. +QueryDialog.pastetooltip=Paste selection. +QueryDialog.compiletooltip=Compile only query. +QueryDialog.submittooltip=Submit query. +QueryDialog.submitbutton=Submit +QueryDialog.killtooltip=Kill query. +QueryDialog.killbutton=Kill job +QueryDialog.resultslabel=Results\: +QueryDialog.XMLtab=XML +QueryDialog.tracetab=Trace +QueryDialog.inputtab=Query Input\: +QueryDialog.historylabel=History\: +QueryDialog.contextlabel=Context\: +QueryDialog.collectionretrievalerrormessage=An error occurred while retrieving collections list +QueryDialog.maxlabel=Display max.\: +QueryDialog.opendialog=Select query file +QueryDialog.Error=Error +QueryDialog.cannotreadmessage=Cannot read query from file +QueryDialog.savedialogpre=Select file for +QueryDialog.savedialogpost=export +QueryDialog.cannotsavemessagepre=Can not write +QueryDialog.cannotsavemessageinf=to file +QueryDialog.savedialogconfirm=File exists. Overwrite? +QueryDialog.compilemessage=Compiling query ... +QueryDialog.Compilation=Compilation +QueryDialog.Execution=Execution +QueryDialog.compilationerrormessage=An exception occurred during query compilation +QueryDialog.processingquerymessage=Processing query ... +QueryDialog.retrievingmessage=Retrieving results ... +QueryDialog.retrievalerrormessage=An error occurred while retrieving results +QueryDialog.Found=Found +QueryDialog.items=items +QueryDialog.queryrunerrormessage=An exception occurred during query execution +TriggersDialog.Collection=Collection +TriggersDialog.Triggers=Triggers +TriggersDialog.addbutton=Add +TriggersDialog.deletebutton=Delete diff --git a/src/org/exist/client/messages_es_ES.properties b/src/org/exist/client/messages_es_ES.properties index 255012cf861..c054f41a566 100644 --- a/src/org/exist/client/messages_es_ES.properties +++ b/src/org/exist/client/messages_es_ES.properties @@ -1,365 +1,365 @@ -ClientFrame.0=Cortar -ClientFrame.1=Copiar -ClientFrame.2=Pegar -ClientFrame.3=Cliente de Administraci\u00f3n eXist -ClientFrame.5=Ir a la colecci\u00f3n padre -ClientFrame.7=Refrescar la vista de la colecci\u00f3n -ClientFrame.9=Crear nueva colecci\u00f3n -ClientFrame.11=Almacena uno o m\u00e1s ficheros en la base de datos -ClientFrame.13=Borrar ficheros o colecciones seleccionados -ClientFrame.14=icons/Preferences24.gif -ClientFrame.15=Editar propietarios/permisos de los recursos seleccionados -ClientFrame.17=Crear copia de seguridad -ClientFrame.19=Restaurar ficheros desde una copia de seguridad -ClientFrame.20=icons/keyring-small.png -ClientFrame.21=Administrar usuarios -ClientFrame.23=Consultar la base de datos usando XPath -ClientFrame.24=Men\u00fa de Consola -ClientFrame.27=Cliente de Administraci\u00f3n de eXist conectado - -ClientFrame.31=Fichero -ClientFrame.32=Almacenar ficheros/directorios -ClientFrame.34=Crear colecci\u00f3n -ClientFrame.36=Crear documento vac\u00edo -ClientFrame.38=Nombre del recurso XML (inclu\u00edda la extensi\u00f3n) -ClientFrame.39= -ClientFrame.40=Eliminar -ClientFrame.42=Copiar -ClientFrame.44=Mover -ClientFrame.46=Renombrar -ClientFrame.47=Exportar recurso a fichero ... -ClientFrame.48=Reindexar colecci\u00f3n -ClientFrame.50=Propiedades del recurso -ClientFrame.52=Salir -ClientFrame.54=Herramientas -ClientFrame.55=Consulta -ClientFrame.57=Editar Usuarios -ClientFrame.59=Editar \u00cdndices -ClientFrame.60=Editar Triggers -ClientFrame.61=Editar Pol\u00edticas -ClientFrame.62a=Entrar en modo mantenimiento -ClientFrame.62b=Salir de modo mantenimiento -ClientFrame.63=Copia de seguridad -ClientFrame.64=Restauraci\u00f3n -ClientFrame.65=Conexi\u00f3n -ClientFrame.66=Desconectar -ClientFrame.67=desconectado\n -ClientFrame.69=Conectar -ClientFrame.70=Abrir panel de login para cambiar el servidor o identidad de la conexi\u00f3n. -ClientFrame.71=Cliente de Administraci\u00f3n de eXist conectado - -ClientFrame.75=\u00a1La conexi\u00f3n a -ClientFrame.77=\ fall\u00f3\! -ClientFrame.78=Imposible reconectar a -ClientFrame.80=Opciones -ClientFrame.81=Indentar -ClientFrame.82=s\u00ed -ClientFrame.83=s\u00ed -ClientFrame.84=no -ClientFrame.85=Expandir XIncludes -ClientFrame.86=s\u00ed -ClientFrame.87=s\u00ed -ClientFrame.88=no -ClientFrame.89=Ayuda -ClientFrame.90=Acerca de -ClientFrame.91=exist: -ClientFrame.92=\ -ClientFrame.93=Backspace -ClientFrame.94=cd ..\n -ClientFrame.96=Por favor, introduzca el nombre de la nueva colecci\u00f3n -ClientFrame.99=Por favor, introduzca una URI base XML:DB (sin -ClientFrame.100=la ruta a la colecci\u00f3n) -ClientFrame.102=\u00a1La conexi\u00f3n a -ClientFrame.103=\ fall\u00f3\! -ClientFrame.104=\u00bfEst\u00e1 seguro de que quiere eliminar los recursos -ClientFrame.105=seleccionados? -ClientFrame.106=Confirmar borrado -ClientFrame.107=Eliminaci\u00f3n en Progreso -ClientFrame.108= -ClientFrame.111=Seleccioar colecci\u00f3n de destino -ClientFrame.112=Copiar -ClientFrame.115=Moviendo -ClientFrame.116=\ a -ClientFrame.117=... -ClientFrame.118=Traslado completado. -ClientFrame.119=Por favor, introduzca un nuevo nombre de fichero -ClientFrame.120=Renombrar -ClientFrame.121=No pudo procesarse el nuevo nombre como una uri v\u00e1lidad: -ClientFrame.124=Renombrando -ClientFrame.125=\ a -ClientFrame.126=... -ClientFrame.127=Renombrado completado. -ClientFrame.128=Seleccionar colecci\u00f3n de destino -ClientFrame.129=Copiar -ClientFrame.132=Copiando -ClientFrame.133=\ a -ClientFrame.134=... -ClientFrame.135=Copia completada. -ClientFrame.136=S\u00f3lo se puede reindexar las colecciones. -ClientFrame.137=Error -ClientFrame.138=\u00bfEst\u00e1 seguro de que quiere reindexar las colecciones seleccionadas \ny todos los recursos dentro de ellas? -ClientFrame.139=Confirmar reindexado -ClientFrame.142=Reindexando colecci\u00f3n -ClientFrame.143=... -ClientFrame.144=Reindexado completado. -ClientFrame.145=working-dir -ClientFrame.146=Seleccionar los ficheros o directorios a almacenar -ClientFrame.147=XMLDBException: -ClientFrame.148=working-dir -ClientFrame.157=Crea Copia de Seguridad -ClientFrame.167=__contents__.xml -ClientFrame.168=__contents__.xml files -ClientFrame.169=Seleccionar el archivo de copia de seguridad a restaurar -ClientFrame.170=contrase\u00f1a de dba/admin a usar para el proceso de restauraci\u00f3n: -ClientFrame.171=Contrase\u00f1a de Administraci\u00f3n -ClientFrame.181=Exception: -ClientFrame.184=Editar Usuarios -ClientFrame.185=Fall\u00f3 recuperar UserManagementService -ClientFrame.186=Editar \u00cdndices -ClientFrame.187=No se pudo obtener la colecci\u00f3n del sistema -ClientFrame.190=XACML no est\u00e1 habilitado. Para habilitarlo, a\u00f1ade\n\n \n\na conf.xml y reinicia eXist. -ClientFrame.191=No se pudo contactar con el administraci\u00f3n de instancias de la base de datos para determinar si est\u00e1 habilitado XACML -ClientFrame.194=... -ClientFrame.195= -ClientFrame.196= -ClientFrame.197=XMLDB Exception: -ClientFrame.198=\n -ClientFrame.204=cd " -ClientFrame.205=\n -ClientFrame.206=Error XMLDB: -ClientFrame.207=Recurso -ClientFrame.208=Fecha -ClientFrame.209=Propietario -ClientFrame.210=Grupo -ClientFrame.211=Permisos -ClientFrame.212=Column does not eXist\! -ClientFrame.213=eXist Database Login -ClientFrame.214=Mensaje: -ClientFrame.215=Exception Stacktrace: -ClientFrame.216=Error -ClientFrame.217=Mensaje: -ClientFrame.218=Exception Stacktrace: -ClientFrame.219=Error -ClientFrame.220=Recursos binarios -ClientFrame.221=Ficheros XML -ClientFrame.222=Permission Denied - -LoginPanel.2=Nombre de usuario - -LoginPanel.1=favoritos - -LoginPanel.3=Contrase\u00f1a - -LoginPanel.4=Conexi\u00f3n -LoginPanel.5=Remota -LoginPanel.6=Embebida - -LoginPanel.8=Configuraci\u00f3n - -LoginPanel.9=Un fichero de configuraci\u00f3n eXist para una instancia embebida - -LoginPanel.10=Seleccionar - -LoginPanel.11=Selecciona un fichero de configuraci\u00f3n alternativo para el modo embebido. - -LoginPanel.12=URL - -LoginPanel.13=T\u00edtulo - -LoginPanel.14=Favoritos - -LoginPanel.15=Seleccionar - -LoginPanel.16=Selecciona los favoritos - -LoginPanel.17=Grabar - -LoginPanel.18=Graba la configuraci\u00f3n - -LoginPanel.19=Ya existe una conexi\u00f3n con este nombre. \u00bfQuiere sobrescribirla? - -LoginPanel.20=Conflicto - -LoginPanel.21=Eliminar - -LoginPanel.22=Eliminar favorito - -LoginPanel.23=Exportar - -LoginPanel.24=Exportar favoritos a un fichero - -LoginPanel.25=favourites.xml - -LoginPanel.26=No seleccion\u00f3 ning\u00fan fichero de favoritos - -LoginPanel.27=Error - -LoginPanel.28=No se puede escribir en el fichero seleccionado - -LoginPanel.29=Error - -LoginPanel.30=Importar - -LoginPanel.31=Importar favoritos desde fichero - -LoginPanel.33=No seleccion\u00f3 ning\u00fan fichero de favoritos - -LoginPanel.34=Error - -LoginPanel.35=No se puede leer del fichero seleccionado - -LoginPanel.36=Error - -LoginPanel.37=Seleccione un fichero de configuraci\u00f3n de instancia de eXist -#Leave this value -LoginPanel.42=name -#Leave this value -LoginPanel.43=username -#Leave this value -LoginPanel.44=password -#Leave this value -LoginPanel.45=url -#Leave this value -LoginPanel.46=configuration - -UploadDialog.0=Almacenando ficheros ... - -UploadDialog.1=Almacenado\: - -UploadDialog.2=Calculando tama\u00f1o de los ficheros ... - -UploadDialog.3=Directorio\: - -UploadDialog.4=Cargando fichero\: - -UploadDialog.5=Tama\u00f1o\: - -UploadDialog.6=0K - -UploadDialog.7=Progreso\: - -UploadDialog.9=Cancelar - -UploadDialog.20=Cerrar - -UploadDialog.11=Cerrar - -UploadDialog.12=K - -UploadDialog.13=Cerrar -#EMpty string -UploadDialog.14= -#\\n -UploadDialog.15=\n - -UploadDialog.16=Almacenando ... - -UploadDialog.17=Almacenando palabras - -UploadDialog.18=Almacenando elementos - -UploadDialog.19=Almacenando nodos - -DocumentView.0=Ver el Documento - -DocumentView.6=El recursos ya est\u00e1 bloqueado por el usuario - -DocumentView.7=. \u00bfDeber\u00eda intentar readquirir el bloqueo? - -DocumentView.8=Recurso bloqueado - -DocumentView.9=El recurso no puede ser bloqueado. Abriendo en s\u00f3lo lectura. - -DocumentView.10=XMLDB error\: - -DocumentView.13=Error - -DocumentView.16=Fichero - -DocumentView.17=Grabar - -DocumentView.20=Almacenar en la base de datos los datos modificados. - -DocumentView.22=Almacenar un nuevo documento en la base de datos. - -DocumentView.24=Exportar a fichero. - -DocumentView.26=Copiar selecci\u00f3n. - -DocumentView.28=Cortar selecci\u00f3n. - -DocumentView.30=Pegar selecci\u00f3n. - -DocumentView.32=Refrescar Documento. - -DocumentView.33=XML - -DocumentView.34=Cargando - -DocumentView.35= ... - -DocumentView.36=Almacenando - -DocumentView.37=XMLDBException\: - -DocumentView.38=Nombre del recurso XML (inclu\u00edda la extensi\u00f3n) - -DocumentView.39=Almacenando - -DocumentView.40=XMLDBException\: - -DocumentView.41=URISyntaxException\: - -DocumentView.44=Seleccione el fichero a exportar - -DocumentView.45=El fichero ya existe. \u00bfQuiere sobrescribirlo? - -DocumentView.46=\u00bfQuiere sobrescribir? - -DocumentView.48=XMLDBException\: - -DocumentView.52=Cargado - -DocumentView.53=\ desde - -QueryDialog.0=Di\u00e1logo de consulta -QueryDialog.opentooltip=Leer consulta desde fichero -QueryDialog.saveastooltip=Grabar consulta en fichero -QueryDialog.saveresultstooltip=Grabar resultados en fichero -QueryDialog.copytooltip=Copiar selecci\u00f3n -QueryDialog.cuttooltip=Cortar selecci\u00f3n -QueryDialog.pastetooltip=Pegar del portapapeles -QueryDialog.compiletooltip=S\u00f3lo compilar consulta -QueryDialog.submittooltip=Ejecutar consulta -QueryDialog.submitbutton=Ejecutar -QueryDialog.killtooltip=Detener consulta -QueryDialog.killbutton=Detener trabajo -QueryDialog.resultslabel=Resultados\: -QueryDialog.XMLtab=XML -QueryDialog.tracetab=Traza -QueryDialog.inputtab=Consulta de entrada\: -QueryDialog.historylabel=Historial\: -QueryDialog.contextlabel=Contexto\: -QueryDialog.collectionretrievalerrormessage=Error durante la obtenci\u00f3n de la lista de colecciones -QueryDialog.maxlabel=Mostrar m\u00e1x.\: -QueryDialog.opendialog=elegir fichero de consulta -QueryDialog.Error=Error -QueryDialog.cannotreadmessage=No se puede leer la consulta desde el fichero -QueryDialog.savedialogpre=Seleccione el fichero -QueryDialog.savedialogpost=donde grabar -QueryDialog.cannotsavemessagepre=Imposible escribir -QueryDialog.cannotsavemessageinf=al fichero -QueryDialog.savedialogconfirm=El fichero ya existe. \u00bfSobreesribir? -QueryDialog.compilemessage=Compilando consulta ... -QueryDialog.Compilation=Compilaci\u00f3n -QueryDialog.Execution=Ejecuci\u00f3n -QueryDialog.compilationerrormessage=Salt\u00f3 una excepci\u00f3n durante la compilaci\u00f3n de la consulta -QueryDialog.processingquerymessage=Procesando consulta ... -QueryDialog.retrievingmessage=Recuperando resultados ... -QueryDialog.retrievalerrormessage=Salt\u00f3 un error durante la recuperaci\u00f3n de resultados -QueryDialog.Found=Hallados -QueryDialog.items=resultados -QueryDialog.queryrunerrormessage=Salt\u00f3 una excepci\u00f3n durante la ejecuci\u00f3n de la consulta - -TriggersDialog.Collection=Collecci\u00f3n -TriggersDialog.Triggers=Triggers -TriggersDialog.addbutton=A\u00f1adir -TriggersDialog.deletebutton=Borrar +ClientFrame.0=Cortar +ClientFrame.1=Copiar +ClientFrame.2=Pegar +ClientFrame.3=Cliente de Administraci\u00f3n eXist +ClientFrame.5=Ir a la colecci\u00f3n padre +ClientFrame.7=Refrescar la vista de la colecci\u00f3n +ClientFrame.9=Crear nueva colecci\u00f3n +ClientFrame.11=Almacena uno o m\u00e1s ficheros en la base de datos +ClientFrame.13=Borrar ficheros o colecciones seleccionados +ClientFrame.14=icons/Preferences24.gif +ClientFrame.15=Editar propietarios/permisos de los recursos seleccionados +ClientFrame.17=Crear copia de seguridad +ClientFrame.19=Restaurar ficheros desde una copia de seguridad +ClientFrame.20=icons/keyring-small.png +ClientFrame.21=Administrar usuarios +ClientFrame.23=Consultar la base de datos usando XPath +ClientFrame.24=Men\u00fa de Consola +ClientFrame.27=Cliente de Administraci\u00f3n de eXist conectado - +ClientFrame.31=Fichero +ClientFrame.32=Almacenar ficheros/directorios +ClientFrame.34=Crear colecci\u00f3n +ClientFrame.36=Crear documento vac\u00edo +ClientFrame.38=Nombre del recurso XML (inclu\u00edda la extensi\u00f3n) +ClientFrame.39= +ClientFrame.40=Eliminar +ClientFrame.42=Copiar +ClientFrame.44=Mover +ClientFrame.46=Renombrar +ClientFrame.47=Exportar recurso a fichero ... +ClientFrame.48=Reindexar colecci\u00f3n +ClientFrame.50=Propiedades del recurso +ClientFrame.52=Salir +ClientFrame.54=Herramientas +ClientFrame.55=Consulta +ClientFrame.57=Editar Usuarios +ClientFrame.59=Editar \u00cdndices +ClientFrame.60=Editar Triggers +ClientFrame.61=Editar Pol\u00edticas +ClientFrame.62a=Entrar en modo mantenimiento +ClientFrame.62b=Salir de modo mantenimiento +ClientFrame.63=Copia de seguridad +ClientFrame.64=Restauraci\u00f3n +ClientFrame.65=Conexi\u00f3n +ClientFrame.66=Desconectar +ClientFrame.67=desconectado\n +ClientFrame.69=Conectar +ClientFrame.70=Abrir panel de login para cambiar el servidor o identidad de la conexi\u00f3n. +ClientFrame.71=Cliente de Administraci\u00f3n de eXist conectado - +ClientFrame.75=\u00a1La conexi\u00f3n a +ClientFrame.77=\ fall\u00f3\! +ClientFrame.78=Imposible reconectar a +ClientFrame.80=Opciones +ClientFrame.81=Indentar +ClientFrame.82=s\u00ed +ClientFrame.83=s\u00ed +ClientFrame.84=no +ClientFrame.85=Expandir XIncludes +ClientFrame.86=s\u00ed +ClientFrame.87=s\u00ed +ClientFrame.88=no +ClientFrame.89=Ayuda +ClientFrame.90=Acerca de +ClientFrame.91=exist: +ClientFrame.92=\ +ClientFrame.93=Backspace +ClientFrame.94=cd ..\n +ClientFrame.96=Por favor, introduzca el nombre de la nueva colecci\u00f3n +ClientFrame.99=Por favor, introduzca una URI base XML:DB (sin +ClientFrame.100=la ruta a la colecci\u00f3n) +ClientFrame.102=\u00a1La conexi\u00f3n a +ClientFrame.103=\ fall\u00f3\! +ClientFrame.104=\u00bfEst\u00e1 seguro de que quiere eliminar los recursos +ClientFrame.105=seleccionados? +ClientFrame.106=Confirmar borrado +ClientFrame.107=Eliminaci\u00f3n en Progreso +ClientFrame.108= +ClientFrame.111=Seleccioar colecci\u00f3n de destino +ClientFrame.112=Copiar +ClientFrame.115=Moviendo +ClientFrame.116=\ a +ClientFrame.117=... +ClientFrame.118=Traslado completado. +ClientFrame.119=Por favor, introduzca un nuevo nombre de fichero +ClientFrame.120=Renombrar +ClientFrame.121=No pudo procesarse el nuevo nombre como una uri v\u00e1lidad: +ClientFrame.124=Renombrando +ClientFrame.125=\ a +ClientFrame.126=... +ClientFrame.127=Renombrado completado. +ClientFrame.128=Seleccionar colecci\u00f3n de destino +ClientFrame.129=Copiar +ClientFrame.132=Copiando +ClientFrame.133=\ a +ClientFrame.134=... +ClientFrame.135=Copia completada. +ClientFrame.136=S\u00f3lo se puede reindexar las colecciones. +ClientFrame.137=Error +ClientFrame.138=\u00bfEst\u00e1 seguro de que quiere reindexar las colecciones seleccionadas \ny todos los recursos dentro de ellas? +ClientFrame.139=Confirmar reindexado +ClientFrame.142=Reindexando colecci\u00f3n +ClientFrame.143=... +ClientFrame.144=Reindexado completado. +ClientFrame.145=working-dir +ClientFrame.146=Seleccionar los ficheros o directorios a almacenar +ClientFrame.147=XMLDBException: +ClientFrame.148=working-dir +ClientFrame.157=Crea Copia de Seguridad +ClientFrame.167=__contents__.xml +ClientFrame.168=__contents__.xml files +ClientFrame.169=Seleccionar el archivo de copia de seguridad a restaurar +ClientFrame.170=contrase\u00f1a de dba/admin a usar para el proceso de restauraci\u00f3n: +ClientFrame.171=Contrase\u00f1a de Administraci\u00f3n +ClientFrame.181=Exception: +ClientFrame.184=Editar Usuarios +ClientFrame.185=Fall\u00f3 recuperar UserManagementService +ClientFrame.186=Editar \u00cdndices +ClientFrame.187=No se pudo obtener la colecci\u00f3n del sistema +ClientFrame.190=XACML no est\u00e1 habilitado. Para habilitarlo, a\u00f1ade\n\n \n\na conf.xml y reinicia eXist. +ClientFrame.191=No se pudo contactar con el administraci\u00f3n de instancias de la base de datos para determinar si est\u00e1 habilitado XACML +ClientFrame.194=... +ClientFrame.195= +ClientFrame.196= +ClientFrame.197=XMLDB Exception: +ClientFrame.198=\n +ClientFrame.204=cd " +ClientFrame.205=\n +ClientFrame.206=Error XMLDB: +ClientFrame.207=Recurso +ClientFrame.208=Fecha +ClientFrame.209=Propietario +ClientFrame.210=Grupo +ClientFrame.211=Permisos +ClientFrame.212=Column does not eXist\! +ClientFrame.213=eXist Database Login +ClientFrame.214=Mensaje: +ClientFrame.215=Exception Stacktrace: +ClientFrame.216=Error +ClientFrame.217=Mensaje: +ClientFrame.218=Exception Stacktrace: +ClientFrame.219=Error +ClientFrame.220=Recursos binarios +ClientFrame.221=Ficheros XML +ClientFrame.222=Permission Denied + +LoginPanel.2=Nombre de usuario + +LoginPanel.1=favoritos + +LoginPanel.3=Contrase\u00f1a + +LoginPanel.4=Conexi\u00f3n +LoginPanel.5=Remota +LoginPanel.6=Embebida + +LoginPanel.8=Configuraci\u00f3n + +LoginPanel.9=Un fichero de configuraci\u00f3n eXist para una instancia embebida + +LoginPanel.10=Seleccionar + +LoginPanel.11=Selecciona un fichero de configuraci\u00f3n alternativo para el modo embebido. + +LoginPanel.12=URL + +LoginPanel.13=T\u00edtulo + +LoginPanel.14=Favoritos + +LoginPanel.15=Seleccionar + +LoginPanel.16=Selecciona los favoritos + +LoginPanel.17=Grabar + +LoginPanel.18=Graba la configuraci\u00f3n + +LoginPanel.19=Ya existe una conexi\u00f3n con este nombre. \u00bfQuiere sobrescribirla? + +LoginPanel.20=Conflicto + +LoginPanel.21=Eliminar + +LoginPanel.22=Eliminar favorito + +LoginPanel.23=Exportar + +LoginPanel.24=Exportar favoritos a un fichero + +LoginPanel.25=favourites.xml + +LoginPanel.26=No seleccion\u00f3 ning\u00fan fichero de favoritos + +LoginPanel.27=Error + +LoginPanel.28=No se puede escribir en el fichero seleccionado + +LoginPanel.29=Error + +LoginPanel.30=Importar + +LoginPanel.31=Importar favoritos desde fichero + +LoginPanel.33=No seleccion\u00f3 ning\u00fan fichero de favoritos + +LoginPanel.34=Error + +LoginPanel.35=No se puede leer del fichero seleccionado + +LoginPanel.36=Error + +LoginPanel.37=Seleccione un fichero de configuraci\u00f3n de instancia de eXist +#Leave this value +LoginPanel.42=name +#Leave this value +LoginPanel.43=username +#Leave this value +LoginPanel.44=password +#Leave this value +LoginPanel.45=url +#Leave this value +LoginPanel.46=configuration + +UploadDialog.0=Almacenando ficheros ... + +UploadDialog.1=Almacenado\: + +UploadDialog.2=Calculando tama\u00f1o de los ficheros ... + +UploadDialog.3=Directorio\: + +UploadDialog.4=Cargando fichero\: + +UploadDialog.5=Tama\u00f1o\: + +UploadDialog.6=0K + +UploadDialog.7=Progreso\: + +UploadDialog.9=Cancelar + +UploadDialog.20=Cerrar + +UploadDialog.11=Cerrar + +UploadDialog.12=K + +UploadDialog.13=Cerrar +#EMpty string +UploadDialog.14= +#\\n +UploadDialog.15=\n + +UploadDialog.16=Almacenando ... + +UploadDialog.17=Almacenando palabras + +UploadDialog.18=Almacenando elementos + +UploadDialog.19=Almacenando nodos + +DocumentView.0=Ver el Documento + +DocumentView.6=El recursos ya est\u00e1 bloqueado por el usuario + +DocumentView.7=. \u00bfDeber\u00eda intentar readquirir el bloqueo? + +DocumentView.8=Recurso bloqueado + +DocumentView.9=El recurso no puede ser bloqueado. Abriendo en s\u00f3lo lectura. + +DocumentView.10=XMLDB error\: + +DocumentView.13=Error + +DocumentView.16=Fichero + +DocumentView.17=Grabar + +DocumentView.20=Almacenar en la base de datos los datos modificados. + +DocumentView.22=Almacenar un nuevo documento en la base de datos. + +DocumentView.24=Exportar a fichero. + +DocumentView.26=Copiar selecci\u00f3n. + +DocumentView.28=Cortar selecci\u00f3n. + +DocumentView.30=Pegar selecci\u00f3n. + +DocumentView.32=Refrescar Documento. + +DocumentView.33=XML + +DocumentView.34=Cargando + +DocumentView.35= ... + +DocumentView.36=Almacenando + +DocumentView.37=XMLDBException\: + +DocumentView.38=Nombre del recurso XML (inclu\u00edda la extensi\u00f3n) + +DocumentView.39=Almacenando + +DocumentView.40=XMLDBException\: + +DocumentView.41=URISyntaxException\: + +DocumentView.44=Seleccione el fichero a exportar + +DocumentView.45=El fichero ya existe. \u00bfQuiere sobrescribirlo? + +DocumentView.46=\u00bfQuiere sobrescribir? + +DocumentView.48=XMLDBException\: + +DocumentView.52=Cargado + +DocumentView.53=\ desde + +QueryDialog.0=Di\u00e1logo de consulta +QueryDialog.opentooltip=Leer consulta desde fichero +QueryDialog.saveastooltip=Grabar consulta en fichero +QueryDialog.saveresultstooltip=Grabar resultados en fichero +QueryDialog.copytooltip=Copiar selecci\u00f3n +QueryDialog.cuttooltip=Cortar selecci\u00f3n +QueryDialog.pastetooltip=Pegar del portapapeles +QueryDialog.compiletooltip=S\u00f3lo compilar consulta +QueryDialog.submittooltip=Ejecutar consulta +QueryDialog.submitbutton=Ejecutar +QueryDialog.killtooltip=Detener consulta +QueryDialog.killbutton=Detener trabajo +QueryDialog.resultslabel=Resultados\: +QueryDialog.XMLtab=XML +QueryDialog.tracetab=Traza +QueryDialog.inputtab=Consulta de entrada\: +QueryDialog.historylabel=Historial\: +QueryDialog.contextlabel=Contexto\: +QueryDialog.collectionretrievalerrormessage=Error durante la obtenci\u00f3n de la lista de colecciones +QueryDialog.maxlabel=Mostrar m\u00e1x.\: +QueryDialog.opendialog=elegir fichero de consulta +QueryDialog.Error=Error +QueryDialog.cannotreadmessage=No se puede leer la consulta desde el fichero +QueryDialog.savedialogpre=Seleccione el fichero +QueryDialog.savedialogpost=donde grabar +QueryDialog.cannotsavemessagepre=Imposible escribir +QueryDialog.cannotsavemessageinf=al fichero +QueryDialog.savedialogconfirm=El fichero ya existe. \u00bfSobreesribir? +QueryDialog.compilemessage=Compilando consulta ... +QueryDialog.Compilation=Compilaci\u00f3n +QueryDialog.Execution=Ejecuci\u00f3n +QueryDialog.compilationerrormessage=Salt\u00f3 una excepci\u00f3n durante la compilaci\u00f3n de la consulta +QueryDialog.processingquerymessage=Procesando consulta ... +QueryDialog.retrievingmessage=Recuperando resultados ... +QueryDialog.retrievalerrormessage=Salt\u00f3 un error durante la recuperaci\u00f3n de resultados +QueryDialog.Found=Hallados +QueryDialog.items=resultados +QueryDialog.queryrunerrormessage=Salt\u00f3 una excepci\u00f3n durante la ejecuci\u00f3n de la consulta + +TriggersDialog.Collection=Collecci\u00f3n +TriggersDialog.Triggers=Triggers +TriggersDialog.addbutton=A\u00f1adir +TriggersDialog.deletebutton=Borrar diff --git a/src/org/exist/client/messages_fr_FR.properties b/src/org/exist/client/messages_fr_FR.properties index 5c75b8b6883..d373a95aee9 100644 --- a/src/org/exist/client/messages_fr_FR.properties +++ b/src/org/exist/client/messages_fr_FR.properties @@ -1,294 +1,294 @@ -ClientFrame.0=Couper -ClientFrame.1=Copier -ClientFrame.2=Coller -ClientFrame.3=Client d'administration eXist -ClientFrame.5=Aller \u00e0 la collection parent -ClientFrame.7=Rafra\u00eechir la vue des collections -ClientFrame.9=Cr\u00e9er une nouvelle collection -ClientFrame.11=Charger un ou plusieurs fichiers dans la base de donn\u00e9es -ClientFrame.13=Supprimer les fichiers ou collections s\u00e9lectionn\u00e9s -ClientFrame.14=icons/Preferences24.gif -ClientFrame.15=Editer les propri\u00e9taires/permissions pour la ressource s\u00e9lectionn\u00e9e -ClientFrame.17=Cr\u00e9er une sauvegarde -ClientFrame.19=Restaurer les fichiers depuis une sauvegarde -ClientFrame.20=icons/keyring-small.png -ClientFrame.21=G\u00e9rer les utilisateurs -ClientFrame.23=Interroger la base de donn\u00e9es avec XQuery -ClientFrame.24=Menu de la console -ClientFrame.27=Client d'administration eXist connect\u00e9 - -ClientFrame.31=Fichier -ClientFrame.32=Charger des fichiers/r\u00e9pertoires... -ClientFrame.34=Cr\u00e9er une collection... -ClientFrame.36=Cr\u00e9er un document vide... -ClientFrame.38=Nom de la ressource (extension incluse) -ClientFrame.39= -ClientFrame.40=Supprimer... -ClientFrame.42=Copier... -ClientFrame.44=D\u00e9placer... -ClientFrame.46=Renommer... -ClientFrame.47=Exporter une ressource vers un fichier... -ClientFrame.48=R\u00e9indexer une collection -ClientFrame.50=Propri\u00e9t\u00e9s de la ressource -ClientFrame.52=Quitter -ClientFrame.54=Outils -ClientFrame.55=Recherche -ClientFrame.57=Editer les utilisateurs -ClientFrame.59=Editer les index -ClientFrame.60=Editer les triggers -ClientFrame.61=Editer les politiques de s\u00e9curit\u00e9 -ClientFrame.62a=Entrer en mode de service -ClientFrame.62b=sortir du mode de service -ClientFrame.63=Faire une copie de sauvegarde -ClientFrame.64=Restaurer une copie de sauvegarde -ClientFrame.65=Connexion -ClientFrame.66=Se d\u00e9connecter -ClientFrame.67=D\u00e9connection\n -ClientFrame.69=Se connecter... -ClientFrame.70=Ouvrir la console de connexion pour chnager de serveur ou d'identit\u00e9. -ClientFrame.71=Client d'administration eXist connect\u00e9 - -ClientFrame.75=Connexion \u00e0 -ClientFrame.77=\\u00e9chou\u00e9\! -ClientFrame.78=Impossible de se reconnecter \u00e0 -ClientFrame.80=Options -ClientFrame.81=Indenter -ClientFrame.82=oui -ClientFrame.83=oui -ClientFrame.84=non -ClientFrame.85=R\u00e9aliser les XIncludes -ClientFrame.86=oui -ClientFrame.87=oui -ClientFrame.88=non -ClientFrame.89=Aide -ClientFrame.90=A propos de... -ClientFrame.91=exist: -ClientFrame.92=\ -ClientFrame.93=Backspace -ClientFrame.94=cd ..\n -ClientFrame.96=Veuillez entrer un nom pour la nouvelle collection -ClientFrame.99=Veuillez entrer une URI XML:DB de base (sans -ClientFrame.100=le chemin de collection) -ClientFrame.102=Connection \u00e0 -ClientFrame.103=\ \u00e9chou\u00e9 ! -ClientFrame.104=Etes-vous s\u00fbr que vous voulez supprimer -ClientFrame.105=les ressources s\u00e9lectionn\u00e9es ? -ClientFrame.106=Confirmation de la supression -ClientFrame.107=Progression de la supression -ClientFrame.108= -ClientFrame.111=S\u00e9lectionnez la colection de destination -ClientFrame.112=Copie -ClientFrame.115=D\u00e9placement en cours -ClientFrame.116=\ vers -ClientFrame.117=... -ClientFrame.118=D\u00e9placement termin\u00e9. -ClientFrame.119=Entrez un nouveau nom de fichier -ClientFrame.120=Renommer -ClientFrame.121=Incapable de parser le nouveau nom en tant qu'URI valide : -ClientFrame.124=Renommage en cours -ClientFrame.125=\ vers -ClientFrame.126=... -ClientFrame.127=Renommage termin\u00e9 -ClientFrame.128=S\u00e9lectionnez la collection de destination -ClientFrame.129=Copier -ClientFrame.132=Copie en cours -ClientFrame.133=\ vers -ClientFrame.134=... -ClientFrame.135=Copie termin\u00e9e -ClientFrame.136=Seules les collections peuvent \u00eatre r\u00e9index\u00e9es -ClientFrame.137=Erreur -ClientFrame.138=Etes vous s\u00fbr que vous voulez r\u00e9indexer la collection s\u00e9lectionn\u00e9e\net toutes les resources qu'elle contient ? -ClientFrame.139=Confirmation de la r\u00e9indexation -ClientFrame.142=R\u00e9indexation de la collection -ClientFrame.143=... -ClientFrame.144=R\u00e9indexation termin\u00e9e -ClientFrame.145=r\u00e9pertoire de travail -ClientFrame.146=Selectionnez les fichiers ou r\u00e9petroires \u00e0 stocker -ClientFrame.147=XMLDBException: -ClientFrame.148=r\u00e9pertoire de travail -ClientFrame.157=Cr\u00e9er une copie de sauvegarde -ClientFrame.166=Compression des fichiers -ClientFrame.167=__contents__.xml -ClientFrame.168=__contents__.xml files -ClientFrame.169=S\u00e9lectionner une copie de sauvegarde \u00e0 restaurer -ClientFrame.170=Mot de passe dba/admin \u00e0 utiliser lors du processus de restauration: -ClientFrame.171=Mot de passe administrateur -ClientFrame.181=Exception: -ClientFrame.184=Editer les utilisateurs -ClientFrame.185=Impossible de trouver le service de gestion des utilisateurs -ClientFrame.186=Editer les index -ClientFrame.187=Impossible d'obtenir la collection syst\u00eame -ClientFrame.190=XACML n'est actuellement pas activ\u00e9. Pour l'activer, ajoutez\n\n\u00e0 conf.xml et red\u00e9marrez eXist. -ClientFrame.191=Impossible d'obtenir le gestionnaire d'instance de base de donn\u00e9es pour d\u00e9terminer l'\u00e9tat d'activation de XACML -ClientFrame.194=... -ClientFrame.195= -ClientFrame.196= -ClientFrame.197=Exception XMLDB : -ClientFrame.198=\n -ClientFrame.204=cd " -ClientFrame.205=\n -ClientFrame.206=Erreur XMLDB : -ClientFrame.207=Ressource -ClientFrame.208=Date -ClientFrame.209=Propri\u00e9taire -ClientFrame.210=Groupe -ClientFrame.211=Permissions -ClientFrame.212=La colonne n'existe pas\! -ClientFrame.213=Connexion \u00e0 une base de donn\u00e9es eXist -ClientFrame.214=Message: -ClientFrame.215=Pile d'exception : -ClientFrame.216=Erreur -ClientFrame.217=Message: -ClientFrame.218=Pile d'exception : -ClientFrame.219=Erreur -ClientFrame.220=Ressources binaires -ClientFrame.221=Fichiers XML -ClientFrame.222=Permission refus\u00e9e -LoginPanel.2=Nom d'utilisateur -LoginPanel.1=favoris -LoginPanel.3=Mot de passe -LoginPanel.4=Type -LoginPanel.5=Distant -LoginPanel.6=Local -LoginPanel.8=Configuration -LoginPanel.9=Fichier de configuration eXist pour l'instance locale -LoginPanel.10=S\u00e9lectionner -LoginPanel.11=S\u00e9lectionner un autre fichier de configuration pour l'instance locale -LoginPanel.12=URL -LoginPanel.13=Titre -LoginPanel.14=Favoris -LoginPanel.15=S\u00e9lectionner -LoginPanel.16=S\u00e9lectionner le favori -LoginPanel.17=Sauvegarder -LoginPanel.18=Sauvegarder les r\u00e9glages -LoginPanel.19=Une connection portant ce nom existe d\u00e9j\u00e0. Ecraser ? -LoginPanel.20=Conflit -LoginPanel.21=Supprimer -LoginPanel.22=Supprimer le favori -LoginPanel.23=Exporter -LoginPanel.24=Exporter les favoris vers un ficher -LoginPanel.25=favourites.xml -LoginPanel.26=Aucun fichier de favoris s\u00e9lectionn\u00e9 -LoginPanel.27=Erreur -LoginPanel.28=Impossible d'\u00e9crire le fichier s\u00e9lectionn\u00e9 -LoginPanel.29=Erreur -LoginPanel.30=Importer -LoginPanel.31=Importer des favoris depuis un fichier -LoginPanel.33=Aucun fichier de favoris s\u00e9lectionn\u00e9 -LoginPanel.34=Erreur -LoginPanel.35=Impossible de lire le fichier s\u00e9lectionn\u00e9 -LoginPanel.36=Erreur -LoginPanel.37=S\u00e9lectionner un fichier de configuration -#Leave this value -LoginPanel.42=name -#Leave this value -LoginPanel.43=username -#Leave this value -LoginPanel.44=password -#Leave this value -LoginPanel.45=url -#Leave this value -LoginPanel.46=configuration -LoginPanel.47=SSL -LoginPanel.48=Utiliser une connection s\u00e9curis\u00e9e HTTPS. -LoginPanel.49=Par d\u00e9faut, eXist-db re\u00e7oit les connections HTTPS sur le port 8443. Note : un (reverse) proxy ou \nun webcontainer comme Tomcat peut influencer la disponibilit\u00e9 de ce port.\n -UploadDialog.0=Chargement des fichiers... -UploadDialog.1=Stock\u00e9: -UploadDialog.2=Calcul des tailles de fichiers... -UploadDialog.3=R\u00e9pertoire\: -UploadDialog.4=Chargement du fichier...\: -UploadDialog.5=Taille\: -UploadDialog.6=0K -UploadDialog.7=Progression\: -UploadDialog.9=Annuler -UploadDialog.20=Fermer -UploadDialog.11=Fermer -UploadDialog.12=K -UploadDialog.13=Fermer -#Empty string -UploadDialog.14= -#\\n -UploadDialog.15=\n -UploadDialog.16=Stockage... -UploadDialog.17=Stockage des mots -UploadDialog.18=Stockage des \u00e9l\u00e9ments -UploadDialog.19=Stockage des noeuds -DocumentView.0=Voir le document -DocumentView.6=La ressource est d\u00e9j\u00e0 verrouill\u00e9e par l'utilisateur -DocumentView.7=. Dois-je essayer de la reverrouiller ? -DocumentView.8=Ressource verrouill\u00e9e -DocumentView.9=La ressource ne peut \u00eatre verrouill\u00e9e. Ouverture en lecture seule. -DocumentView.10=Erreur XMLDB : -DocumentView.13=Erreur -DocumentView.16=Fichier -DocumentView.17=Sauvegarder -DocumentView.20=Charger les donn\u00e9es modifi\u00e9es dans la base de donn\u00e9es -DocumentView.22=Charger un document dans la base de donn\u00e9es -DocumentView.24=Exporter vers un fichier -DocumentView.26=Copier la s\u00e9lection -DocumentView.28=Couper la s\u00e9lection -DocumentView.30=Coller la s\u00e9lection -DocumentView.32=Rafra\u00eechir le document -DocumentView.33=XML -DocumentView.34=Chargement en cours -DocumentView.35= ... -DocumentView.36=Stockage en cours -DocumentView.37=XMLDBException\: -DocumentView.38=Nom de la ressource XML (extension incluse) -DocumentView.39=Stockage en cours -DocumentView.40=XMLDBException\: -DocumentView.41=URISyntaxException\: -DocumentView.44=S\u00e9lectionner un fichier \u00e0 exporter -DocumentView.45=Le fichier existe. Ecraser ? -DocumentView.46=Ecraser ? -DocumentView.48=XMLDBException\: -DocumentView.52=Charg\u00e9 -DocumentView.53= depuis -CreateBackupDialog.1=Collection\: -CreateBackupDialog.2=Cible\: -CreateBackupDialog.3=Selectionner -CreateBackupDialog.4=Selectionner un fichier ZIP ou un r\u00e9pertoire. -CreateBackupDialog.5=Selectionner une cible pour la sauvegarde -CreateBackupDialog.6a=Cible -CreateBackupDialog.6b= existe. OK pour le d\u00e9truire ? -CreateBackupDialog.6c=Confirmer la suppression -QueryDialog.0=Dialogue de recherche -QueryDialog.opentooltip=Lire la requ\u00eate depuis un fichier. -QueryDialog.saveastooltip=Ecrire la requ\u00eate dans un fichier. -QueryDialog.saveresultstooltip=Ecrire le r\u00e9sultat dans un fichier. -QueryDialog.copytooltip=Copier la s\u00e9lection. -QueryDialog.cuttooltip=Couper la s\u00e9lection. -QueryDialog.pastetooltip=Coller la s\u00e9lection. -QueryDialog.compiletooltip=Compiler seulement la requ\u00eate. -QueryDialog.submittooltip=Ex\u00e9cuter la requ\u00eate. -QueryDialog.submitbutton=Ex\u00e9cuter -QueryDialog.killtooltip=Tuer la requ\u00eate. -QueryDialog.killbutton=Tuer le job -QueryDialog.resultslabel=Resultats\: -QueryDialog.XMLtab=XML -QueryDialog.tracetab=Trace -QueryDialog.inputtab=Texte de la requ\u00eate\: -QueryDialog.historylabel=Historique\: -QueryDialog.contextlabel=Contexte\: -QueryDialog.collectionretrievalerrormessage=Une erreur est survenue lors de la lecture de la liste de collections -QueryDialog.maxlabel=Afficher au maximum\: -QueryDialog.opendialog=Selectionner le fichier de requ\u00eate -QueryDialog.Error=Erreur -QueryDialog.cannotreadmessage=Impossible de lire la requ\u00eate depuis le fichier -QueryDialog.savedialogpre=S\u00e9lectionner un fichier pour -QueryDialog.savedialogpost=export -QueryDialog.cannotsavemessagepre=Impossible d'\u00e9crire -QueryDialog.cannotsavemessageinf=vers le fichier -QueryDialog.savedialogconfirm=Le fichier existe. Ecraser ? -QueryDialog.compilemessage=Compilaa tion de la requ\u00eate... -QueryDialog.Compilation=Compilation -QueryDialog.Execution=Ex\u00e9cution -QueryDialog.compilationerrormessage=Une exception est survenue pendant la compilation de la requ\u00eate -QueryDialog.processingquerymessage=Traitement de la requ\u00eate... -QueryDialog.retrievingmessage=Traitement des r\u00e9sultats... -QueryDialog.retrievalerrormessage=Une erreur est survenue lors du traitement des r\u00e9sultats -QueryDialog.Found=Trouv\u00e9 -QueryDialog.items=entr\u00e9es -QueryDialog.queryrunerrormessage=Une exception est survenue pendant l'ex\u00e9cution de la requ\u00eate -TriggersDialog.Collection=Collection -TriggersDialog.Triggers=Triggers -TriggersDialog.addbutton=Ajouter -TriggersDialog.deletebutton=Supprimer +ClientFrame.0=Couper +ClientFrame.1=Copier +ClientFrame.2=Coller +ClientFrame.3=Client d'administration eXist +ClientFrame.5=Aller \u00e0 la collection parent +ClientFrame.7=Rafra\u00eechir la vue des collections +ClientFrame.9=Cr\u00e9er une nouvelle collection +ClientFrame.11=Charger un ou plusieurs fichiers dans la base de donn\u00e9es +ClientFrame.13=Supprimer les fichiers ou collections s\u00e9lectionn\u00e9s +ClientFrame.14=icons/Preferences24.gif +ClientFrame.15=Editer les propri\u00e9taires/permissions pour la ressource s\u00e9lectionn\u00e9e +ClientFrame.17=Cr\u00e9er une sauvegarde +ClientFrame.19=Restaurer les fichiers depuis une sauvegarde +ClientFrame.20=icons/keyring-small.png +ClientFrame.21=G\u00e9rer les utilisateurs +ClientFrame.23=Interroger la base de donn\u00e9es avec XQuery +ClientFrame.24=Menu de la console +ClientFrame.27=Client d'administration eXist connect\u00e9 - +ClientFrame.31=Fichier +ClientFrame.32=Charger des fichiers/r\u00e9pertoires... +ClientFrame.34=Cr\u00e9er une collection... +ClientFrame.36=Cr\u00e9er un document vide... +ClientFrame.38=Nom de la ressource (extension incluse) +ClientFrame.39= +ClientFrame.40=Supprimer... +ClientFrame.42=Copier... +ClientFrame.44=D\u00e9placer... +ClientFrame.46=Renommer... +ClientFrame.47=Exporter une ressource vers un fichier... +ClientFrame.48=R\u00e9indexer une collection +ClientFrame.50=Propri\u00e9t\u00e9s de la ressource +ClientFrame.52=Quitter +ClientFrame.54=Outils +ClientFrame.55=Recherche +ClientFrame.57=Editer les utilisateurs +ClientFrame.59=Editer les index +ClientFrame.60=Editer les triggers +ClientFrame.61=Editer les politiques de s\u00e9curit\u00e9 +ClientFrame.62a=Entrer en mode de service +ClientFrame.62b=sortir du mode de service +ClientFrame.63=Faire une copie de sauvegarde +ClientFrame.64=Restaurer une copie de sauvegarde +ClientFrame.65=Connexion +ClientFrame.66=Se d\u00e9connecter +ClientFrame.67=D\u00e9connection\n +ClientFrame.69=Se connecter... +ClientFrame.70=Ouvrir la console de connexion pour chnager de serveur ou d'identit\u00e9. +ClientFrame.71=Client d'administration eXist connect\u00e9 - +ClientFrame.75=Connexion \u00e0 +ClientFrame.77=\\u00e9chou\u00e9\! +ClientFrame.78=Impossible de se reconnecter \u00e0 +ClientFrame.80=Options +ClientFrame.81=Indenter +ClientFrame.82=oui +ClientFrame.83=oui +ClientFrame.84=non +ClientFrame.85=R\u00e9aliser les XIncludes +ClientFrame.86=oui +ClientFrame.87=oui +ClientFrame.88=non +ClientFrame.89=Aide +ClientFrame.90=A propos de... +ClientFrame.91=exist: +ClientFrame.92=\ +ClientFrame.93=Backspace +ClientFrame.94=cd ..\n +ClientFrame.96=Veuillez entrer un nom pour la nouvelle collection +ClientFrame.99=Veuillez entrer une URI XML:DB de base (sans +ClientFrame.100=le chemin de collection) +ClientFrame.102=Connection \u00e0 +ClientFrame.103=\ \u00e9chou\u00e9 ! +ClientFrame.104=Etes-vous s\u00fbr que vous voulez supprimer +ClientFrame.105=les ressources s\u00e9lectionn\u00e9es ? +ClientFrame.106=Confirmation de la supression +ClientFrame.107=Progression de la supression +ClientFrame.108= +ClientFrame.111=S\u00e9lectionnez la colection de destination +ClientFrame.112=Copie +ClientFrame.115=D\u00e9placement en cours +ClientFrame.116=\ vers +ClientFrame.117=... +ClientFrame.118=D\u00e9placement termin\u00e9. +ClientFrame.119=Entrez un nouveau nom de fichier +ClientFrame.120=Renommer +ClientFrame.121=Incapable de parser le nouveau nom en tant qu'URI valide : +ClientFrame.124=Renommage en cours +ClientFrame.125=\ vers +ClientFrame.126=... +ClientFrame.127=Renommage termin\u00e9 +ClientFrame.128=S\u00e9lectionnez la collection de destination +ClientFrame.129=Copier +ClientFrame.132=Copie en cours +ClientFrame.133=\ vers +ClientFrame.134=... +ClientFrame.135=Copie termin\u00e9e +ClientFrame.136=Seules les collections peuvent \u00eatre r\u00e9index\u00e9es +ClientFrame.137=Erreur +ClientFrame.138=Etes vous s\u00fbr que vous voulez r\u00e9indexer la collection s\u00e9lectionn\u00e9e\net toutes les resources qu'elle contient ? +ClientFrame.139=Confirmation de la r\u00e9indexation +ClientFrame.142=R\u00e9indexation de la collection +ClientFrame.143=... +ClientFrame.144=R\u00e9indexation termin\u00e9e +ClientFrame.145=r\u00e9pertoire de travail +ClientFrame.146=Selectionnez les fichiers ou r\u00e9petroires \u00e0 stocker +ClientFrame.147=XMLDBException: +ClientFrame.148=r\u00e9pertoire de travail +ClientFrame.157=Cr\u00e9er une copie de sauvegarde +ClientFrame.166=Compression des fichiers +ClientFrame.167=__contents__.xml +ClientFrame.168=__contents__.xml files +ClientFrame.169=S\u00e9lectionner une copie de sauvegarde \u00e0 restaurer +ClientFrame.170=Mot de passe dba/admin \u00e0 utiliser lors du processus de restauration: +ClientFrame.171=Mot de passe administrateur +ClientFrame.181=Exception: +ClientFrame.184=Editer les utilisateurs +ClientFrame.185=Impossible de trouver le service de gestion des utilisateurs +ClientFrame.186=Editer les index +ClientFrame.187=Impossible d'obtenir la collection syst\u00eame +ClientFrame.190=XACML n'est actuellement pas activ\u00e9. Pour l'activer, ajoutez\n\n\u00e0 conf.xml et red\u00e9marrez eXist. +ClientFrame.191=Impossible d'obtenir le gestionnaire d'instance de base de donn\u00e9es pour d\u00e9terminer l'\u00e9tat d'activation de XACML +ClientFrame.194=... +ClientFrame.195= +ClientFrame.196= +ClientFrame.197=Exception XMLDB : +ClientFrame.198=\n +ClientFrame.204=cd " +ClientFrame.205=\n +ClientFrame.206=Erreur XMLDB : +ClientFrame.207=Ressource +ClientFrame.208=Date +ClientFrame.209=Propri\u00e9taire +ClientFrame.210=Groupe +ClientFrame.211=Permissions +ClientFrame.212=La colonne n'existe pas\! +ClientFrame.213=Connexion \u00e0 une base de donn\u00e9es eXist +ClientFrame.214=Message: +ClientFrame.215=Pile d'exception : +ClientFrame.216=Erreur +ClientFrame.217=Message: +ClientFrame.218=Pile d'exception : +ClientFrame.219=Erreur +ClientFrame.220=Ressources binaires +ClientFrame.221=Fichiers XML +ClientFrame.222=Permission refus\u00e9e +LoginPanel.2=Nom d'utilisateur +LoginPanel.1=favoris +LoginPanel.3=Mot de passe +LoginPanel.4=Type +LoginPanel.5=Distant +LoginPanel.6=Local +LoginPanel.8=Configuration +LoginPanel.9=Fichier de configuration eXist pour l'instance locale +LoginPanel.10=S\u00e9lectionner +LoginPanel.11=S\u00e9lectionner un autre fichier de configuration pour l'instance locale +LoginPanel.12=URL +LoginPanel.13=Titre +LoginPanel.14=Favoris +LoginPanel.15=S\u00e9lectionner +LoginPanel.16=S\u00e9lectionner le favori +LoginPanel.17=Sauvegarder +LoginPanel.18=Sauvegarder les r\u00e9glages +LoginPanel.19=Une connection portant ce nom existe d\u00e9j\u00e0. Ecraser ? +LoginPanel.20=Conflit +LoginPanel.21=Supprimer +LoginPanel.22=Supprimer le favori +LoginPanel.23=Exporter +LoginPanel.24=Exporter les favoris vers un ficher +LoginPanel.25=favourites.xml +LoginPanel.26=Aucun fichier de favoris s\u00e9lectionn\u00e9 +LoginPanel.27=Erreur +LoginPanel.28=Impossible d'\u00e9crire le fichier s\u00e9lectionn\u00e9 +LoginPanel.29=Erreur +LoginPanel.30=Importer +LoginPanel.31=Importer des favoris depuis un fichier +LoginPanel.33=Aucun fichier de favoris s\u00e9lectionn\u00e9 +LoginPanel.34=Erreur +LoginPanel.35=Impossible de lire le fichier s\u00e9lectionn\u00e9 +LoginPanel.36=Erreur +LoginPanel.37=S\u00e9lectionner un fichier de configuration +#Leave this value +LoginPanel.42=name +#Leave this value +LoginPanel.43=username +#Leave this value +LoginPanel.44=password +#Leave this value +LoginPanel.45=url +#Leave this value +LoginPanel.46=configuration +LoginPanel.47=SSL +LoginPanel.48=Utiliser une connection s\u00e9curis\u00e9e HTTPS. +LoginPanel.49=Par d\u00e9faut, eXist-db re\u00e7oit les connections HTTPS sur le port 8443. Note : un (reverse) proxy ou \nun webcontainer comme Tomcat peut influencer la disponibilit\u00e9 de ce port.\n +UploadDialog.0=Chargement des fichiers... +UploadDialog.1=Stock\u00e9: +UploadDialog.2=Calcul des tailles de fichiers... +UploadDialog.3=R\u00e9pertoire\: +UploadDialog.4=Chargement du fichier...\: +UploadDialog.5=Taille\: +UploadDialog.6=0K +UploadDialog.7=Progression\: +UploadDialog.9=Annuler +UploadDialog.20=Fermer +UploadDialog.11=Fermer +UploadDialog.12=K +UploadDialog.13=Fermer +#Empty string +UploadDialog.14= +#\\n +UploadDialog.15=\n +UploadDialog.16=Stockage... +UploadDialog.17=Stockage des mots +UploadDialog.18=Stockage des \u00e9l\u00e9ments +UploadDialog.19=Stockage des noeuds +DocumentView.0=Voir le document +DocumentView.6=La ressource est d\u00e9j\u00e0 verrouill\u00e9e par l'utilisateur +DocumentView.7=. Dois-je essayer de la reverrouiller ? +DocumentView.8=Ressource verrouill\u00e9e +DocumentView.9=La ressource ne peut \u00eatre verrouill\u00e9e. Ouverture en lecture seule. +DocumentView.10=Erreur XMLDB : +DocumentView.13=Erreur +DocumentView.16=Fichier +DocumentView.17=Sauvegarder +DocumentView.20=Charger les donn\u00e9es modifi\u00e9es dans la base de donn\u00e9es +DocumentView.22=Charger un document dans la base de donn\u00e9es +DocumentView.24=Exporter vers un fichier +DocumentView.26=Copier la s\u00e9lection +DocumentView.28=Couper la s\u00e9lection +DocumentView.30=Coller la s\u00e9lection +DocumentView.32=Rafra\u00eechir le document +DocumentView.33=XML +DocumentView.34=Chargement en cours +DocumentView.35= ... +DocumentView.36=Stockage en cours +DocumentView.37=XMLDBException\: +DocumentView.38=Nom de la ressource XML (extension incluse) +DocumentView.39=Stockage en cours +DocumentView.40=XMLDBException\: +DocumentView.41=URISyntaxException\: +DocumentView.44=S\u00e9lectionner un fichier \u00e0 exporter +DocumentView.45=Le fichier existe. Ecraser ? +DocumentView.46=Ecraser ? +DocumentView.48=XMLDBException\: +DocumentView.52=Charg\u00e9 +DocumentView.53= depuis +CreateBackupDialog.1=Collection\: +CreateBackupDialog.2=Cible\: +CreateBackupDialog.3=Selectionner +CreateBackupDialog.4=Selectionner un fichier ZIP ou un r\u00e9pertoire. +CreateBackupDialog.5=Selectionner une cible pour la sauvegarde +CreateBackupDialog.6a=Cible +CreateBackupDialog.6b= existe. OK pour le d\u00e9truire ? +CreateBackupDialog.6c=Confirmer la suppression +QueryDialog.0=Dialogue de recherche +QueryDialog.opentooltip=Lire la requ\u00eate depuis un fichier. +QueryDialog.saveastooltip=Ecrire la requ\u00eate dans un fichier. +QueryDialog.saveresultstooltip=Ecrire le r\u00e9sultat dans un fichier. +QueryDialog.copytooltip=Copier la s\u00e9lection. +QueryDialog.cuttooltip=Couper la s\u00e9lection. +QueryDialog.pastetooltip=Coller la s\u00e9lection. +QueryDialog.compiletooltip=Compiler seulement la requ\u00eate. +QueryDialog.submittooltip=Ex\u00e9cuter la requ\u00eate. +QueryDialog.submitbutton=Ex\u00e9cuter +QueryDialog.killtooltip=Tuer la requ\u00eate. +QueryDialog.killbutton=Tuer le job +QueryDialog.resultslabel=Resultats\: +QueryDialog.XMLtab=XML +QueryDialog.tracetab=Trace +QueryDialog.inputtab=Texte de la requ\u00eate\: +QueryDialog.historylabel=Historique\: +QueryDialog.contextlabel=Contexte\: +QueryDialog.collectionretrievalerrormessage=Une erreur est survenue lors de la lecture de la liste de collections +QueryDialog.maxlabel=Afficher au maximum\: +QueryDialog.opendialog=Selectionner le fichier de requ\u00eate +QueryDialog.Error=Erreur +QueryDialog.cannotreadmessage=Impossible de lire la requ\u00eate depuis le fichier +QueryDialog.savedialogpre=S\u00e9lectionner un fichier pour +QueryDialog.savedialogpost=export +QueryDialog.cannotsavemessagepre=Impossible d'\u00e9crire +QueryDialog.cannotsavemessageinf=vers le fichier +QueryDialog.savedialogconfirm=Le fichier existe. Ecraser ? +QueryDialog.compilemessage=Compilaa tion de la requ\u00eate... +QueryDialog.Compilation=Compilation +QueryDialog.Execution=Ex\u00e9cution +QueryDialog.compilationerrormessage=Une exception est survenue pendant la compilation de la requ\u00eate +QueryDialog.processingquerymessage=Traitement de la requ\u00eate... +QueryDialog.retrievingmessage=Traitement des r\u00e9sultats... +QueryDialog.retrievalerrormessage=Une erreur est survenue lors du traitement des r\u00e9sultats +QueryDialog.Found=Trouv\u00e9 +QueryDialog.items=entr\u00e9es +QueryDialog.queryrunerrormessage=Une exception est survenue pendant l'ex\u00e9cution de la requ\u00eate +TriggersDialog.Collection=Collection +TriggersDialog.Triggers=Triggers +TriggersDialog.addbutton=Ajouter +TriggersDialog.deletebutton=Supprimer diff --git a/src/org/exist/client/messages_it_IT.properties b/src/org/exist/client/messages_it_IT.properties index ce178102cc2..0389cc23f56 100644 --- a/src/org/exist/client/messages_it_IT.properties +++ b/src/org/exist/client/messages_it_IT.properties @@ -1,317 +1,317 @@ -ClientFrame.0=Taglia -ClientFrame.1=Copia -ClientFrame.2=Incolla -ClientFrame.3=eXist Admin Client -ClientFrame.5=Vai alla directory superiore -ClientFrame.7=Aggiorna la vista directory -ClientFrame.9=Crea una directory -ClientFrame.11=Memorizza uno o pi\u00c3\u00b9 file nel database -ClientFrame.13=Cancella i file o le directory selezionate -ClientFrame.14=icons/Preferences24.gif -ClientFrame.15=Edita il proprietario/i permessi per la risorsa selezionata -ClientFrame.17=Crea backup -ClientFrame.19=Ripristina i file da un backup -ClientFrame.20=icons/keyring-small.png -ClientFrame.21=Gestione utenti -ClientFrame.23=Interroga il database mediante XPath/Xquery -ClientFrame.24=Console Menu -ClientFrame.27=eXist Admin Client connesso - -ClientFrame.31=File -ClientFrame.32=Memorizza files/directory -ClientFrame.34=Crea una directory -ClientFrame.36=Crea un documento vuoto -ClientFrame.38=Nome della risorsa XML (estensione inclusa) -ClientFrame.39= -ClientFrame.40=Rimuovi -ClientFrame.42=Copia -ClientFrame.44=Sposta -ClientFrame.46=Rinomina -ClientFrame.48=Reindicizza la directory -ClientFrame.50=Propriet\u00c3\u00a0 della risorsa -ClientFrame.52=Esci -ClientFrame.54=Utilit\u00c3\u00a0 -ClientFrame.55=Trova -ClientFrame.57=Edita Utenti -ClientFrame.59=Edita Indici -ClientFrame.61=Edita Policies -ClientFrame.63=Backup -ClientFrame.64=Restore -ClientFrame.65=Connessione -ClientFrame.66=Shutdown -ClientFrame.67=shutdown\n -ClientFrame.69=Connetti -ClientFrame.70=Apre il pannello delle connessioni per cambiare server o identit\u00c3\u00a0. -ClientFrame.71=eXist Admin Client connesso - -ClientFrame.75=Connessione a -ClientFrame.77=\ fallita\! -ClientFrame.78=Impossibile riconnettersi a -ClientFrame.80=Opzioni -ClientFrame.81=Formatta output -ClientFrame.82=si -ClientFrame.83=si -ClientFrame.84=no -ClientFrame.85=Espandi-XIncludes -ClientFrame.86=si -ClientFrame.87=si -ClientFrame.88=no -ClientFrame.89=Aiuto -ClientFrame.90=Informazioni -ClientFrame.91=exist: -ClientFrame.92=\ -ClientFrame.93=Backspace -ClientFrame.94=cd ..\n -ClientFrame.96=Per piacere inserisci il nome della nuova directory -ClientFrame.99=Per piacere inscerisci un valido XML:DB URI (senza -ClientFrame.100=il percorso della directory) -ClientFrame.102=Connessione a -ClientFrame.103=\ fallita\! -ClientFrame.104=Sei sicuro di voler rimuovere la risorsa -ClientFrame.105=selezionata? -ClientFrame.106=Conferma la cancellazione -ClientFrame.107=Rimozione in corso -ClientFrame.108= -ClientFrame.111=Seleziona la directory di destinazione -ClientFrame.112=Copia -ClientFrame.115=Spostamento -ClientFrame.116=\ in -ClientFrame.117=... -ClientFrame.118=Spostamento completato. -ClientFrame.119=Per piacere inserisci un nuovo nome -ClientFrame.120=Rinomina -ClientFrame.121=Impossibile convertire il nuovo nome in una valida uri: -ClientFrame.124=Rinomina -ClientFrame.125=\ in -ClientFrame.126=... -ClientFrame.127=Rinomina completata. -ClientFrame.128=Selezionare la collezione di destinazione -ClientFrame.129=Copia -ClientFrame.132=Copia -ClientFrame.133=\ in -ClientFrame.134=... -ClientFrame.135=Copia completata. -ClientFrame.136=Solo le directory possono essere reindicizzate. -ClientFrame.137=Errore -ClientFrame.138=Sei sicuro di voler reindicizzare la directory selezionata \ne tutte le risorse in essa contenute? -ClientFrame.139=Conferma reindicizzazione -ClientFrame.142=Reindicizzazione directory -ClientFrame.143=... -ClientFrame.144=Reindicizzazione completata. -ClientFrame.145=working-dir -ClientFrame.146=Selezionare i file o le directory da memorizzare -ClientFrame.147=XMLDBException: -ClientFrame.148=working-dir -ClientFrame.157=Crea Backup -ClientFrame.167=__contents__.xml -ClientFrame.168=__contents__.xml files -ClientFrame.169=Selezionare un set di backup per il restore -ClientFrame.170=dba/admin password da usare per il processo di restore: -ClientFrame.171=Password Amministratore -ClientFrame.181=Exception: -ClientFrame.184=Edita Utenti -ClientFrame.185=Tentativo fallito di connesione a UserManagementService -ClientFrame.186=Edita Indici -ClientFrame.187=Impossibile recuperare la directory system -ClientFrame.190=XACML non \u00c3\u00a8 abilitato. Per abilitarlo, aggiungere\n\n \n\nal file conf.xml e riavviare eXist. -ClientFrame.191=Impossibile ottenere una istanza dal database manager per deter minare se XACML \u00c3\u00a8 attivo -ClientFrame.194=... -ClientFrame.195= -ClientFrame.196= -ClientFrame.197=XMLDB Exception: -ClientFrame.198=\n -ClientFrame.204=cd " -ClientFrame.205=\n -ClientFrame.206=errore XMLDB: -ClientFrame.207=Risorsa -ClientFrame.208=Data -ClientFrame.209=Proprietario -ClientFrame.210=Gruppo -ClientFrame.211=Permessi -ClientFrame.212=Column does not eXist\! -ClientFrame.213=eXist Database Login -ClientFrame.214=Messaggio: -ClientFrame.215=Exception Stacktrace: -ClientFrame.216=Errore -ClientFrame.217=Message: -ClientFrame.218=Exception Stacktrace: -ClientFrame.219=Errore -ClientFrame.220=Risorsa binaria -ClientFrame.221=XML files -ClientFrame.222=Permission Denied - -LoginPanel.2=Nome utente - -LoginPanel.1=favoriti - -LoginPanel.3=Password - -LoginPanel.4=Connessione -LoginPanel.5=Remote -LoginPanel.6=Embedded - -LoginPanel.8=Configurazione - -LoginPanel.9=Una configurazione per eXist in modalit\u00c3\u00a0 embed - -LoginPanel.10=Seleziona - -LoginPanel.11=Seleziona un file conf alternativo per la modalit\u00c3\u00a0 embed. - -LoginPanel.12=URL - -LoginPanel.13=Titolo - -LoginPanel.14=Favoriti - -LoginPanel.15=Seleziona - -LoginPanel.16=Seleziona un favorito - -LoginPanel.17=Salva - -LoginPanel.18=Salva le impostazioni - -LoginPanel.19=Una connessione con questo nome esiste gi\u00c3\u00a0. Sovrascriverla? - -LoginPanel.20=Conflitto - -LoginPanel.21=Rimuovi - -LoginPanel.22=Rimuovi favorito - -LoginPanel.23=Esporta - -LoginPanel.24=Esporta i favori in un file - -LoginPanel.25=favourites.xml - -LoginPanel.26=Non \u00c3\u00a8 stato selezionato alcun file per i favoriti - -LoginPanel.27=Errore - -LoginPanel.28=Impossibile scrivere il file selezionato - -LoginPanel.29=Errore - -LoginPanel.30=Importa - -LoginPanel.31=Importa i favoriti da un file - -LoginPanel.33=Non \u00c3\u00a8 stato selezionato alcun file per i favoriti - -LoginPanel.34=Errore - -LoginPanel.35=Impossibile leggere il file selezionato - -LoginPanel.36=Errore - -LoginPanel.37=Seleziona un file di configurazione per eXist -#Leave this value -LoginPanel.42=name -#Leave this value -LoginPanel.43=username -#Leave this value -LoginPanel.44=password -#Leave this value -LoginPanel.45=url -#Leave this value -LoginPanel.46=configuration - -UploadDialog.0=Memorizzazione file... - -UploadDialog.1=Stored\: - -UploadDialog.2=Calcolo dimensioni file ... - -UploadDialog.3=Directory\: - -UploadDialog.4=Uploading file\: - -UploadDialog.5=Dimensione\: - -UploadDialog.6=0K - -UploadDialog.7=Progress\: - -UploadDialog.9=Cancella - -UploadDialog.20=Chiudi - -UploadDialog.11=Chiudi - -UploadDialog.12=K - -UploadDialog.13=Chiudi -#EMpty string -UploadDialog.14= -#\\n -UploadDialog.15=\n - -UploadDialog.16=Memorizzazione ... - -UploadDialog.17=Memorizzazione parole - -UploadDialog.18=Memorizzazione elementi - -UploadDialog.19=Memorizzazione nodi - -DocumentView.0=Mostra il documento - -DocumentView.6=La risorsa \u00c3\u00a8 gi\u00c3\u00a0 bloccata da un altro utente - -DocumentView.7=. Nuovo tentativo di blocco? - -DocumentView.8=Risorsa bloccata - -DocumentView.9=La risorsa non pu\u00c3\u00b2 essere bloccata. Apertura in modalit\u00c3\u00a0 solo lettura. - -DocumentView.10=XMLDB error\: - -DocumentView.13=Errore - -DocumentView.16=File - -DocumentView.17=Salva - -DocumentView.20=Salva i dati modificati nel database. - -DocumentView.22=Memorizza un nuovo documento nel database. - -DocumentView.24=Esporta in un file. - -DocumentView.26=Copia selezione. - -DocumentView.28=Taglia selezione. - -DocumentView.30=Incolla selezione. - -DocumentView.32=Aggiorna documento - -DocumentView.33=XML - -DocumentView.34=Loading - -DocumentView.35= ... - -DocumentView.36=Memorizzazione - -DocumentView.37=XMLDBException\: - -DocumentView.38=Nome della risorsa XML (estensione inclusa) - -DocumentView.39=Memorizzazione - -DocumentView.40=XMLDBException\: - -DocumentView.41=URISyntaxException\: - -DocumentView.44=Seleziona la risorsa da esportare - -DocumentView.45=Il file esiste gi\u00c3\u00a0. Sovrascriverlo? - -DocumentView.46=Sovrascrivere? - -DocumentView.48=XMLDBException\: - -DocumentView.52=Caricato - -DocumentView.53= da +ClientFrame.0=Taglia +ClientFrame.1=Copia +ClientFrame.2=Incolla +ClientFrame.3=eXist Admin Client +ClientFrame.5=Vai alla directory superiore +ClientFrame.7=Aggiorna la vista directory +ClientFrame.9=Crea una directory +ClientFrame.11=Memorizza uno o pi\u00c3\u00b9 file nel database +ClientFrame.13=Cancella i file o le directory selezionate +ClientFrame.14=icons/Preferences24.gif +ClientFrame.15=Edita il proprietario/i permessi per la risorsa selezionata +ClientFrame.17=Crea backup +ClientFrame.19=Ripristina i file da un backup +ClientFrame.20=icons/keyring-small.png +ClientFrame.21=Gestione utenti +ClientFrame.23=Interroga il database mediante XPath/Xquery +ClientFrame.24=Console Menu +ClientFrame.27=eXist Admin Client connesso - +ClientFrame.31=File +ClientFrame.32=Memorizza files/directory +ClientFrame.34=Crea una directory +ClientFrame.36=Crea un documento vuoto +ClientFrame.38=Nome della risorsa XML (estensione inclusa) +ClientFrame.39= +ClientFrame.40=Rimuovi +ClientFrame.42=Copia +ClientFrame.44=Sposta +ClientFrame.46=Rinomina +ClientFrame.48=Reindicizza la directory +ClientFrame.50=Propriet\u00c3\u00a0 della risorsa +ClientFrame.52=Esci +ClientFrame.54=Utilit\u00c3\u00a0 +ClientFrame.55=Trova +ClientFrame.57=Edita Utenti +ClientFrame.59=Edita Indici +ClientFrame.61=Edita Policies +ClientFrame.63=Backup +ClientFrame.64=Restore +ClientFrame.65=Connessione +ClientFrame.66=Shutdown +ClientFrame.67=shutdown\n +ClientFrame.69=Connetti +ClientFrame.70=Apre il pannello delle connessioni per cambiare server o identit\u00c3\u00a0. +ClientFrame.71=eXist Admin Client connesso - +ClientFrame.75=Connessione a +ClientFrame.77=\ fallita\! +ClientFrame.78=Impossibile riconnettersi a +ClientFrame.80=Opzioni +ClientFrame.81=Formatta output +ClientFrame.82=si +ClientFrame.83=si +ClientFrame.84=no +ClientFrame.85=Espandi-XIncludes +ClientFrame.86=si +ClientFrame.87=si +ClientFrame.88=no +ClientFrame.89=Aiuto +ClientFrame.90=Informazioni +ClientFrame.91=exist: +ClientFrame.92=\ +ClientFrame.93=Backspace +ClientFrame.94=cd ..\n +ClientFrame.96=Per piacere inserisci il nome della nuova directory +ClientFrame.99=Per piacere inscerisci un valido XML:DB URI (senza +ClientFrame.100=il percorso della directory) +ClientFrame.102=Connessione a +ClientFrame.103=\ fallita\! +ClientFrame.104=Sei sicuro di voler rimuovere la risorsa +ClientFrame.105=selezionata? +ClientFrame.106=Conferma la cancellazione +ClientFrame.107=Rimozione in corso +ClientFrame.108= +ClientFrame.111=Seleziona la directory di destinazione +ClientFrame.112=Copia +ClientFrame.115=Spostamento +ClientFrame.116=\ in +ClientFrame.117=... +ClientFrame.118=Spostamento completato. +ClientFrame.119=Per piacere inserisci un nuovo nome +ClientFrame.120=Rinomina +ClientFrame.121=Impossibile convertire il nuovo nome in una valida uri: +ClientFrame.124=Rinomina +ClientFrame.125=\ in +ClientFrame.126=... +ClientFrame.127=Rinomina completata. +ClientFrame.128=Selezionare la collezione di destinazione +ClientFrame.129=Copia +ClientFrame.132=Copia +ClientFrame.133=\ in +ClientFrame.134=... +ClientFrame.135=Copia completata. +ClientFrame.136=Solo le directory possono essere reindicizzate. +ClientFrame.137=Errore +ClientFrame.138=Sei sicuro di voler reindicizzare la directory selezionata \ne tutte le risorse in essa contenute? +ClientFrame.139=Conferma reindicizzazione +ClientFrame.142=Reindicizzazione directory +ClientFrame.143=... +ClientFrame.144=Reindicizzazione completata. +ClientFrame.145=working-dir +ClientFrame.146=Selezionare i file o le directory da memorizzare +ClientFrame.147=XMLDBException: +ClientFrame.148=working-dir +ClientFrame.157=Crea Backup +ClientFrame.167=__contents__.xml +ClientFrame.168=__contents__.xml files +ClientFrame.169=Selezionare un set di backup per il restore +ClientFrame.170=dba/admin password da usare per il processo di restore: +ClientFrame.171=Password Amministratore +ClientFrame.181=Exception: +ClientFrame.184=Edita Utenti +ClientFrame.185=Tentativo fallito di connesione a UserManagementService +ClientFrame.186=Edita Indici +ClientFrame.187=Impossibile recuperare la directory system +ClientFrame.190=XACML non \u00c3\u00a8 abilitato. Per abilitarlo, aggiungere\n\n \n\nal file conf.xml e riavviare eXist. +ClientFrame.191=Impossibile ottenere una istanza dal database manager per deter minare se XACML \u00c3\u00a8 attivo +ClientFrame.194=... +ClientFrame.195= +ClientFrame.196= +ClientFrame.197=XMLDB Exception: +ClientFrame.198=\n +ClientFrame.204=cd " +ClientFrame.205=\n +ClientFrame.206=errore XMLDB: +ClientFrame.207=Risorsa +ClientFrame.208=Data +ClientFrame.209=Proprietario +ClientFrame.210=Gruppo +ClientFrame.211=Permessi +ClientFrame.212=Column does not eXist\! +ClientFrame.213=eXist Database Login +ClientFrame.214=Messaggio: +ClientFrame.215=Exception Stacktrace: +ClientFrame.216=Errore +ClientFrame.217=Message: +ClientFrame.218=Exception Stacktrace: +ClientFrame.219=Errore +ClientFrame.220=Risorsa binaria +ClientFrame.221=XML files +ClientFrame.222=Permission Denied + +LoginPanel.2=Nome utente + +LoginPanel.1=favoriti + +LoginPanel.3=Password + +LoginPanel.4=Connessione +LoginPanel.5=Remote +LoginPanel.6=Embedded + +LoginPanel.8=Configurazione + +LoginPanel.9=Una configurazione per eXist in modalit\u00c3\u00a0 embed + +LoginPanel.10=Seleziona + +LoginPanel.11=Seleziona un file conf alternativo per la modalit\u00c3\u00a0 embed. + +LoginPanel.12=URL + +LoginPanel.13=Titolo + +LoginPanel.14=Favoriti + +LoginPanel.15=Seleziona + +LoginPanel.16=Seleziona un favorito + +LoginPanel.17=Salva + +LoginPanel.18=Salva le impostazioni + +LoginPanel.19=Una connessione con questo nome esiste gi\u00c3\u00a0. Sovrascriverla? + +LoginPanel.20=Conflitto + +LoginPanel.21=Rimuovi + +LoginPanel.22=Rimuovi favorito + +LoginPanel.23=Esporta + +LoginPanel.24=Esporta i favori in un file + +LoginPanel.25=favourites.xml + +LoginPanel.26=Non \u00c3\u00a8 stato selezionato alcun file per i favoriti + +LoginPanel.27=Errore + +LoginPanel.28=Impossibile scrivere il file selezionato + +LoginPanel.29=Errore + +LoginPanel.30=Importa + +LoginPanel.31=Importa i favoriti da un file + +LoginPanel.33=Non \u00c3\u00a8 stato selezionato alcun file per i favoriti + +LoginPanel.34=Errore + +LoginPanel.35=Impossibile leggere il file selezionato + +LoginPanel.36=Errore + +LoginPanel.37=Seleziona un file di configurazione per eXist +#Leave this value +LoginPanel.42=name +#Leave this value +LoginPanel.43=username +#Leave this value +LoginPanel.44=password +#Leave this value +LoginPanel.45=url +#Leave this value +LoginPanel.46=configuration + +UploadDialog.0=Memorizzazione file... + +UploadDialog.1=Stored\: + +UploadDialog.2=Calcolo dimensioni file ... + +UploadDialog.3=Directory\: + +UploadDialog.4=Uploading file\: + +UploadDialog.5=Dimensione\: + +UploadDialog.6=0K + +UploadDialog.7=Progress\: + +UploadDialog.9=Cancella + +UploadDialog.20=Chiudi + +UploadDialog.11=Chiudi + +UploadDialog.12=K + +UploadDialog.13=Chiudi +#EMpty string +UploadDialog.14= +#\\n +UploadDialog.15=\n + +UploadDialog.16=Memorizzazione ... + +UploadDialog.17=Memorizzazione parole + +UploadDialog.18=Memorizzazione elementi + +UploadDialog.19=Memorizzazione nodi + +DocumentView.0=Mostra il documento + +DocumentView.6=La risorsa \u00c3\u00a8 gi\u00c3\u00a0 bloccata da un altro utente + +DocumentView.7=. Nuovo tentativo di blocco? + +DocumentView.8=Risorsa bloccata + +DocumentView.9=La risorsa non pu\u00c3\u00b2 essere bloccata. Apertura in modalit\u00c3\u00a0 solo lettura. + +DocumentView.10=XMLDB error\: + +DocumentView.13=Errore + +DocumentView.16=File + +DocumentView.17=Salva + +DocumentView.20=Salva i dati modificati nel database. + +DocumentView.22=Memorizza un nuovo documento nel database. + +DocumentView.24=Esporta in un file. + +DocumentView.26=Copia selezione. + +DocumentView.28=Taglia selezione. + +DocumentView.30=Incolla selezione. + +DocumentView.32=Aggiorna documento + +DocumentView.33=XML + +DocumentView.34=Loading + +DocumentView.35= ... + +DocumentView.36=Memorizzazione + +DocumentView.37=XMLDBException\: + +DocumentView.38=Nome della risorsa XML (estensione inclusa) + +DocumentView.39=Memorizzazione + +DocumentView.40=XMLDBException\: + +DocumentView.41=URISyntaxException\: + +DocumentView.44=Seleziona la risorsa da esportare + +DocumentView.45=Il file esiste gi\u00c3\u00a0. Sovrascriverlo? + +DocumentView.46=Sovrascrivere? + +DocumentView.48=XMLDBException\: + +DocumentView.52=Caricato + +DocumentView.53= da diff --git a/src/org/exist/client/messages_nl_NL.properties b/src/org/exist/client/messages_nl_NL.properties index 42678889b9a..767bbfed35d 100644 --- a/src/org/exist/client/messages_nl_NL.properties +++ b/src/org/exist/client/messages_nl_NL.properties @@ -1,287 +1,287 @@ -ClientFrame.0=Knippen -ClientFrame.1=Kopieren -ClientFrame.2=Plakken -ClientFrame.3=eXist Beheer Programma -ClientFrame.5=Naar bovenliggende verzameling -ClientFrame.7=Vernieuw collectie -ClientFrame.9=Maak nieuwe collectie -ClientFrame.11=Sla documenten op in database -ClientFrame.13=Verwijder documenten en/of verzamelingen -ClientFrame.14=icons/Preferences24.gif -ClientFrame.15=Verander eigenaar/eigenschappen voor geselecteerde resource -ClientFrame.17=Maak backup -ClientFrame.19=Zet backup terug -ClientFrame.20=icons/keyring-small.png -ClientFrame.21=Gebruikersbeheer -ClientFrame.23=Query de database met XPath en xQuery -ClientFrame.24=Hoofdscherm Menu -ClientFrame.27=eXist Beheer Programma verbonden - -ClientFrame.31=Bestand -ClientFrame.32=Bewaar bestanden/verzameling -ClientFrame.34=Maak verzameling -ClientFrame.36=Maak nieuw document -ClientFrame.38=Naam van XML document (met naam extentie) -ClientFrame.39= -ClientFrame.40=Verwijder -ClientFrame.42=Kopieer -ClientFrame.44=Verplaats -ClientFrame.46=Hernoem -ClientFrame.48=Herindexeer verzamelingen -ClientFrame.50=Resource eigenschappen -ClientFrame.52=Stop programma -ClientFrame.54=Hulpmiddelen -ClientFrame.55=Zoek -ClientFrame.57=Modificeer Gebruikers -ClientFrame.59=Modificeer Indexen -ClientFrame.61=Modificeer Policies -ClientFrame.63=Backup -ClientFrame.64=Herstel -ClientFrame.65=Verbinding -ClientFrame.66=Afsluiten -ClientFrame.67=afsluiten\n -ClientFrame.69=Verbinden -ClientFrame.70=Open inlog scherm om van database of gebruiker te veranderen. -ClientFrame.71=eXist Beheer Programma verbonden - -ClientFrame.75=Verbonden met -ClientFrame.77=\ mislukt\! -ClientFrame.78=Niet mogelijk te verbinden met -ClientFrame.80=Opties -ClientFrame.81=Inspringen -ClientFrame.82=ja -ClientFrame.83=ja -ClientFrame.84=nee -ClientFrame.85=Expandeer-XIncludes -ClientFrame.86=ja -ClientFrame.87=ja -ClientFrame.88=nee -ClientFrame.89=Help -ClientFrame.90=Over eXist... -ClientFrame.91=exist: -ClientFrame.92=\ -ClientFrame.93=Backspace -ClientFrame.94=cd ..\n -ClientFrame.96=Geef naam van verzameling -ClientFrame.99=Geef valide XML:DB base URI (zonder -ClientFrame.100=verzameling pad) -ClientFrame.102=Verbinding naar -ClientFrame.103=\ mislukt\! -ClientFrame.104=Weet U zeker dat U de geselecteerde resources -ClientFrame.105=wilt verwijderen? -ClientFrame.106=Bevestig verwijderen -ClientFrame.107=Voortgang verwijderen -ClientFrame.111=Selecteer bestemming -ClientFrame.112=Verplaats -ClientFrame.115=Verplaats -ClientFrame.116=\ naar -ClientFrame.117=... -ClientFrame.118=Verplaatsing gereed. -ClientFrame.119=Geef nieuwe documentnaam -ClientFrame.120=Hernoemen -ClientFrame.121=Nieuwe naam niet herkend als een valide uri: -ClientFrame.124=Hernoemen -ClientFrame.125=\ naar -ClientFrame.126=... -ClientFrame.127=Hernoeming gereed. -ClientFrame.128=Selecteer bestemming -ClientFrame.129=Kopieer -ClientFrame.132=Kopieer -ClientFrame.133=\ naar -ClientFrame.134=... -ClientFrame.135=Kopieren gereed. -ClientFrame.136=Slechts verzamelingen kunnen worden geherindexeerd. -ClientFrame.137=Fout -ClientFrame.138=Weet U zeker dat de geselecteerde verzamelingen mogen worden geherindexeerd? -ClientFrame.139=Bevestig herindexering -ClientFrame.142=Herindexeer verzameling -ClientFrame.143=... -ClientFrame.144=Herindexeren gereed. -ClientFrame.145=werk-directory -ClientFrame.146=Selecteer op te slaan documenten of folders -ClientFrame.147=XMLDBException: -ClientFrame.148=werk-directory -ClientFrame.157=Maak Backup -ClientFrame.167=__contents__.xml -ClientFrame.168=__contents__.xml files -ClientFrame.169=Selecteer backup bestand om mee te herstellen -ClientFrame.170=dba/admin password om het herstel proces uit te voeren: -ClientFrame.171=Admin Password -ClientFrame.181=Exception: -ClientFrame.184=Aanpassen Gebruikers -ClientFrame.185=Fout tijdens ophalen UserManagementService -ClientFrame.186=Aanpassen Indexen -ClientFrame.187=Kan systeem verzameling niet ophalen -ClientFrame.190=XACML is nog niet actief. Om deze te activeren, voeg toe\n\n \n\naan conf.xml and herstart eXist. -ClientFrame.191=Kan database instance manager niet ophalen om te bepalen of XACML actief is -ClientFrame.194=... -ClientFrame.197=XMLDB Exception: -ClientFrame.198=\n -ClientFrame.204=cd " -ClientFrame.205=\n -ClientFrame.206=XMLDB error: -ClientFrame.207=Resource -ClientFrame.208=Datum -ClientFrame.209=Eigenaar -ClientFrame.210=Groep -ClientFrame.211=Eigenschappen -ClientFrame.212=Kolom bestaat niet\! -ClientFrame.213=eXist Database Login -ClientFrame.214=Bericht: -ClientFrame.215=Exception Stacktrace: -ClientFrame.216=Fout -ClientFrame.217=Bericht: -ClientFrame.218=Exception Stacktrace: -ClientFrame.219=Fout -ClientFrame.220=Binaire documenten -ClientFrame.221=XML documenten -ClientFrame.222=Permission Denied - -LoginPanel.10=Selecteer - -LoginPanel.11=Selecteer alternatief configuratie bestand - -LoginPanel.13=Titel - -LoginPanel.14=Favorieten - -LoginPanel.15=Selecteer - -LoginPanel.16=Selecteer favouriet - -LoginPanel.17=Bewaar - -LoginPanel.18=Bewaar instellingen - -LoginPanel.19=Een verbinding met deze naam bestaat reeds. Ok om deze te overschrijven? - -LoginPanel.2=Gebruiker - -LoginPanel.21=Verwijderen - -LoginPanel.22=Verwijder favoriet - -LoginPanel.23=Exporteer - -LoginPanel.24=Exporteer favorieten naar bestand - -LoginPanel.26=Favorieten bestand niet geselecteerd - -LoginPanel.27=Fout - -LoginPanel.28=Kan geselecteerde bestand niet schrijven - -LoginPanel.29=Fout - -LoginPanel.30=Importeren - -LoginPanel.31=Importeer favorieten van bestand - -LoginPanel.33=Geen favorieten bestand geselecteerd - -LoginPanel.34=Fout - -LoginPanel.35=Kan geselecteerde bestand niet lezen - -LoginPanel.36=Fout - -LoginPanel.37=Selecteer een eXist configuratie bestand - - -LoginPanel.8=Configuratie - -LoginPanel.9=Een eXist configuratie bestand voor embedded gebruik. - -UploadDialog.0=Opslaan bestanden ... - -UploadDialog.1=Opgeslagen\: - -UploadDialog.11=Sluiten - -UploadDialog.13=Sluiten - -UploadDialog.20=Sluiten - -UploadDialog.16=Opslaan ... - -UploadDialog.17=Opslaan van woorden - -UploadDialog.18=Opslaan van elementen - -UploadDialog.19=Opslaan van nodes - -UploadDialog.2=Uitrekenen bestand groottes ... - -UploadDialog.3=Map\: - -UploadDialog.4=Versturen bestand\: - -UploadDialog.5=Grootte\: - -UploadDialog.7=Voortgang\: - -UploadDialog.9=Annuleren - -DocumentView.0=Bekijk Document - -DocumentView.13=Fout - -DocumentView.16=Bestand - -DocumentView.17=Bewaar - -DocumentView.20=Schrijf aangepaste gegevens terug in database. - -DocumentView.22=Bewaar nieuw document in database. - -DocumentView.24=Exporteer naar bestand. - -DocumentView.26=Kopieer geselecteerde tekst. - -DocumentView.28=Knip geselecteerde tekst. - -DocumentView.30=Plak geselecteerde tekst. - -DocumentView.32=Vernieuw document. - -DocumentView.34=Laden - -DocumentView.36=Bewaren - -DocumentView.38=Naam van XML bestand (met bestands extentie) - -DocumentView.39=Bewaren - -DocumentView.44=Selecteer te exporteren document - -DocumentView.45=Bestand bestaat. Overschrijven? - -DocumentView.46=Overschrijven? - -DocumentView.52=Geladen - -DocumentView.53=van - -DocumentView.6=Document is al gereserveerd door gebruiker - -DocumentView.7=. Proberen om reservering te verkrijgen? - -DocumentView.8=Document gereserveerd - -DocumentView.9=Document kan niet worden gereserveerd. Document wordt geopend met 'alleen lezen' - -CreateBackupDialog.1=Collectie\: - -CreateBackupDialog.2=Doel\: - -CreateBackupDialog.3=Selecteer - -CreateBackupDialog.4=Selecteer ZIP bestand of folder. - -CreateBackupDialog.5=Selecteer doel voor backup - -CreateBackupDialog.6a=Doel - -CreateBackupDialog.6b=bestaat. OK om te verwijderen? - -CreateBackupDialog.6c=Bevestig verwijderen -LoginPanel.48=Gebruik een veilige HTTPS verbinding. -LoginPanel.49=Normaal gespoken accepteert eXist-db HTTPS verbindingen op poort 8443. Let op: een "(reverse) proxy" of \neen webcontainer zoals Tomcat kan de beschikbaarheid van deze functie be\u00efnvloeden. +ClientFrame.0=Knippen +ClientFrame.1=Kopieren +ClientFrame.2=Plakken +ClientFrame.3=eXist Beheer Programma +ClientFrame.5=Naar bovenliggende verzameling +ClientFrame.7=Vernieuw collectie +ClientFrame.9=Maak nieuwe collectie +ClientFrame.11=Sla documenten op in database +ClientFrame.13=Verwijder documenten en/of verzamelingen +ClientFrame.14=icons/Preferences24.gif +ClientFrame.15=Verander eigenaar/eigenschappen voor geselecteerde resource +ClientFrame.17=Maak backup +ClientFrame.19=Zet backup terug +ClientFrame.20=icons/keyring-small.png +ClientFrame.21=Gebruikersbeheer +ClientFrame.23=Query de database met XPath en xQuery +ClientFrame.24=Hoofdscherm Menu +ClientFrame.27=eXist Beheer Programma verbonden - +ClientFrame.31=Bestand +ClientFrame.32=Bewaar bestanden/verzameling +ClientFrame.34=Maak verzameling +ClientFrame.36=Maak nieuw document +ClientFrame.38=Naam van XML document (met naam extentie) +ClientFrame.39= +ClientFrame.40=Verwijder +ClientFrame.42=Kopieer +ClientFrame.44=Verplaats +ClientFrame.46=Hernoem +ClientFrame.48=Herindexeer verzamelingen +ClientFrame.50=Resource eigenschappen +ClientFrame.52=Stop programma +ClientFrame.54=Hulpmiddelen +ClientFrame.55=Zoek +ClientFrame.57=Modificeer Gebruikers +ClientFrame.59=Modificeer Indexen +ClientFrame.61=Modificeer Policies +ClientFrame.63=Backup +ClientFrame.64=Herstel +ClientFrame.65=Verbinding +ClientFrame.66=Afsluiten +ClientFrame.67=afsluiten\n +ClientFrame.69=Verbinden +ClientFrame.70=Open inlog scherm om van database of gebruiker te veranderen. +ClientFrame.71=eXist Beheer Programma verbonden - +ClientFrame.75=Verbonden met +ClientFrame.77=\ mislukt\! +ClientFrame.78=Niet mogelijk te verbinden met +ClientFrame.80=Opties +ClientFrame.81=Inspringen +ClientFrame.82=ja +ClientFrame.83=ja +ClientFrame.84=nee +ClientFrame.85=Expandeer-XIncludes +ClientFrame.86=ja +ClientFrame.87=ja +ClientFrame.88=nee +ClientFrame.89=Help +ClientFrame.90=Over eXist... +ClientFrame.91=exist: +ClientFrame.92=\ +ClientFrame.93=Backspace +ClientFrame.94=cd ..\n +ClientFrame.96=Geef naam van verzameling +ClientFrame.99=Geef valide XML:DB base URI (zonder +ClientFrame.100=verzameling pad) +ClientFrame.102=Verbinding naar +ClientFrame.103=\ mislukt\! +ClientFrame.104=Weet U zeker dat U de geselecteerde resources +ClientFrame.105=wilt verwijderen? +ClientFrame.106=Bevestig verwijderen +ClientFrame.107=Voortgang verwijderen +ClientFrame.111=Selecteer bestemming +ClientFrame.112=Verplaats +ClientFrame.115=Verplaats +ClientFrame.116=\ naar +ClientFrame.117=... +ClientFrame.118=Verplaatsing gereed. +ClientFrame.119=Geef nieuwe documentnaam +ClientFrame.120=Hernoemen +ClientFrame.121=Nieuwe naam niet herkend als een valide uri: +ClientFrame.124=Hernoemen +ClientFrame.125=\ naar +ClientFrame.126=... +ClientFrame.127=Hernoeming gereed. +ClientFrame.128=Selecteer bestemming +ClientFrame.129=Kopieer +ClientFrame.132=Kopieer +ClientFrame.133=\ naar +ClientFrame.134=... +ClientFrame.135=Kopieren gereed. +ClientFrame.136=Slechts verzamelingen kunnen worden geherindexeerd. +ClientFrame.137=Fout +ClientFrame.138=Weet U zeker dat de geselecteerde verzamelingen mogen worden geherindexeerd? +ClientFrame.139=Bevestig herindexering +ClientFrame.142=Herindexeer verzameling +ClientFrame.143=... +ClientFrame.144=Herindexeren gereed. +ClientFrame.145=werk-directory +ClientFrame.146=Selecteer op te slaan documenten of folders +ClientFrame.147=XMLDBException: +ClientFrame.148=werk-directory +ClientFrame.157=Maak Backup +ClientFrame.167=__contents__.xml +ClientFrame.168=__contents__.xml files +ClientFrame.169=Selecteer backup bestand om mee te herstellen +ClientFrame.170=dba/admin password om het herstel proces uit te voeren: +ClientFrame.171=Admin Password +ClientFrame.181=Exception: +ClientFrame.184=Aanpassen Gebruikers +ClientFrame.185=Fout tijdens ophalen UserManagementService +ClientFrame.186=Aanpassen Indexen +ClientFrame.187=Kan systeem verzameling niet ophalen +ClientFrame.190=XACML is nog niet actief. Om deze te activeren, voeg toe\n\n \n\naan conf.xml and herstart eXist. +ClientFrame.191=Kan database instance manager niet ophalen om te bepalen of XACML actief is +ClientFrame.194=... +ClientFrame.197=XMLDB Exception: +ClientFrame.198=\n +ClientFrame.204=cd " +ClientFrame.205=\n +ClientFrame.206=XMLDB error: +ClientFrame.207=Resource +ClientFrame.208=Datum +ClientFrame.209=Eigenaar +ClientFrame.210=Groep +ClientFrame.211=Eigenschappen +ClientFrame.212=Kolom bestaat niet\! +ClientFrame.213=eXist Database Login +ClientFrame.214=Bericht: +ClientFrame.215=Exception Stacktrace: +ClientFrame.216=Fout +ClientFrame.217=Bericht: +ClientFrame.218=Exception Stacktrace: +ClientFrame.219=Fout +ClientFrame.220=Binaire documenten +ClientFrame.221=XML documenten +ClientFrame.222=Permission Denied + +LoginPanel.10=Selecteer + +LoginPanel.11=Selecteer alternatief configuratie bestand + +LoginPanel.13=Titel + +LoginPanel.14=Favorieten + +LoginPanel.15=Selecteer + +LoginPanel.16=Selecteer favouriet + +LoginPanel.17=Bewaar + +LoginPanel.18=Bewaar instellingen + +LoginPanel.19=Een verbinding met deze naam bestaat reeds. Ok om deze te overschrijven? + +LoginPanel.2=Gebruiker + +LoginPanel.21=Verwijderen + +LoginPanel.22=Verwijder favoriet + +LoginPanel.23=Exporteer + +LoginPanel.24=Exporteer favorieten naar bestand + +LoginPanel.26=Favorieten bestand niet geselecteerd + +LoginPanel.27=Fout + +LoginPanel.28=Kan geselecteerde bestand niet schrijven + +LoginPanel.29=Fout + +LoginPanel.30=Importeren + +LoginPanel.31=Importeer favorieten van bestand + +LoginPanel.33=Geen favorieten bestand geselecteerd + +LoginPanel.34=Fout + +LoginPanel.35=Kan geselecteerde bestand niet lezen + +LoginPanel.36=Fout + +LoginPanel.37=Selecteer een eXist configuratie bestand + + +LoginPanel.8=Configuratie + +LoginPanel.9=Een eXist configuratie bestand voor embedded gebruik. + +UploadDialog.0=Opslaan bestanden ... + +UploadDialog.1=Opgeslagen\: + +UploadDialog.11=Sluiten + +UploadDialog.13=Sluiten + +UploadDialog.20=Sluiten + +UploadDialog.16=Opslaan ... + +UploadDialog.17=Opslaan van woorden + +UploadDialog.18=Opslaan van elementen + +UploadDialog.19=Opslaan van nodes + +UploadDialog.2=Uitrekenen bestand groottes ... + +UploadDialog.3=Map\: + +UploadDialog.4=Versturen bestand\: + +UploadDialog.5=Grootte\: + +UploadDialog.7=Voortgang\: + +UploadDialog.9=Annuleren + +DocumentView.0=Bekijk Document + +DocumentView.13=Fout + +DocumentView.16=Bestand + +DocumentView.17=Bewaar + +DocumentView.20=Schrijf aangepaste gegevens terug in database. + +DocumentView.22=Bewaar nieuw document in database. + +DocumentView.24=Exporteer naar bestand. + +DocumentView.26=Kopieer geselecteerde tekst. + +DocumentView.28=Knip geselecteerde tekst. + +DocumentView.30=Plak geselecteerde tekst. + +DocumentView.32=Vernieuw document. + +DocumentView.34=Laden + +DocumentView.36=Bewaren + +DocumentView.38=Naam van XML bestand (met bestands extentie) + +DocumentView.39=Bewaren + +DocumentView.44=Selecteer te exporteren document + +DocumentView.45=Bestand bestaat. Overschrijven? + +DocumentView.46=Overschrijven? + +DocumentView.52=Geladen + +DocumentView.53=van + +DocumentView.6=Document is al gereserveerd door gebruiker + +DocumentView.7=. Proberen om reservering te verkrijgen? + +DocumentView.8=Document gereserveerd + +DocumentView.9=Document kan niet worden gereserveerd. Document wordt geopend met 'alleen lezen' + +CreateBackupDialog.1=Collectie\: + +CreateBackupDialog.2=Doel\: + +CreateBackupDialog.3=Selecteer + +CreateBackupDialog.4=Selecteer ZIP bestand of folder. + +CreateBackupDialog.5=Selecteer doel voor backup + +CreateBackupDialog.6a=Doel + +CreateBackupDialog.6b=bestaat. OK om te verwijderen? + +CreateBackupDialog.6c=Bevestig verwijderen +LoginPanel.48=Gebruik een veilige HTTPS verbinding. +LoginPanel.49=Normaal gespoken accepteert eXist-db HTTPS verbindingen op poort 8443. Let op: een "(reverse) proxy" of \neen webcontainer zoals Tomcat kan de beschikbaarheid van deze functie be\u00efnvloeden. diff --git a/src/org/exist/client/messages_no.properties b/src/org/exist/client/messages_no.properties index 7453ee5c94b..6c2b5294bbd 100644 --- a/src/org/exist/client/messages_no.properties +++ b/src/org/exist/client/messages_no.properties @@ -1,211 +1,211 @@ -ClientFrame.0=Klypp ut -ClientFrame.1=Kopier -ClientFrame.2=Lim inn -ClientFrame.3=eXist-administrasjonsklient -ClientFrame.5=G\u00c3\u00a5 til samlinga over -ClientFrame.7=Oppdater samlingslistinga -ClientFrame.9=Lag ny samling -ClientFrame.11=Legg til ein eller fleire filer til databasen -ClientFrame.13=Slett dei valde filene eller samlingane -ClientFrame.14=icons/Preferences24.gif -ClientFrame.15=Rediger eigar/rettar for dei valde filene eller samlingane -ClientFrame.17=Lag tryggingskopi -ClientFrame.19=Gjenoppbygg fr\u00c3\u00a5 tryggingskopi -ClientFrame.20=icons/keyring-small.png -ClientFrame.21=Administrer brukarar -ClientFrame.23=Opna vindauga for \u00c3\u00a5 s\u00c3\u00b8kja i db med XPath/XQuery -ClientFrame.24=Konsollmeny -ClientFrame.27=eXist-adminklienten tilkopla - -ClientFrame.31=Fil -ClientFrame.32=Legg til filer eller katalogar -ClientFrame.34=Lag samling -ClientFrame.36=Lag tomt dokument -ClientFrame.38=Namn p\u00c3\u00a5 XML-dokumentet (inklusive filtillegg) -ClientFrame.39= -ClientFrame.40=Slett -ClientFrame.42=Kopier -ClientFrame.44=Flytt -ClientFrame.46=Endra namn -ClientFrame.48=Indekser samlinga p\u00c3\u00a5 nytt -ClientFrame.50=Ressurseigenskapar -ClientFrame.52=Avslutt -ClientFrame.54=Verkty -ClientFrame.55=Finn -ClientFrame.57=Administrer brukarar -ClientFrame.59=Administrer indeksar -ClientFrame.61=Administrer policy for rettar -ClientFrame.63=Lag tryggingsskopi -ClientFrame.64=Gjenoppbygg fr\u00c3\u00a5 tryggingskopi -ClientFrame.65=Tilkopling -ClientFrame.66=Kopla fr\u00c3\u00a5 -ClientFrame.67=Kopla fr\u00c3\u00a5\n -ClientFrame.69=Kopla til -ClientFrame.70=Opna innloggingspanetet for \u00c3\u00a5 kopla til, byta servar, eller byta brukaridentitet. -ClientFrame.71=eXist-adminklienten tilkopla - -ClientFrame.75=Kopla til -ClientFrame.77=\ misslyktest\! -ClientFrame.78=Kan ikkje kopla til igjen til -ClientFrame.80=Innstillingar -ClientFrame.81=Innrykk -ClientFrame.82=ja -ClientFrame.83=ja -ClientFrame.84=nei -ClientFrame.85=Ekspander XIncludes (Expand-XIncludes) -ClientFrame.86=ja -ClientFrame.87=ja -ClientFrame.88=nei -ClientFrame.89=Hjelp -ClientFrame.90=Om -ClientFrame.91=exist: -ClientFrame.92=\ -ClientFrame.93=Backspace -ClientFrame.94=cd ..\n -ClientFrame.96=Gje namn p\u00c3\u00a5 ny samling -ClientFrame.99=Spesifiser ein gyldig XML:DB-base-URI (utan -ClientFrame.100=samlingsstig) -ClientFrame.102=Kopling til -ClientFrame.103=\ mislyktest\! -ClientFrame.104=Er du sikker p\u00c3\u00a5 at du vil sletta dei valde -ClientFrame.105=ressursane? -ClientFrame.106=Stadfest slettinga -ClientFrame.107=Held p\u00c3\u00a5 og slettar -ClientFrame.111=Vel m\u00c3\u00a5lsamling -ClientFrame.112=Kopier -ClientFrame.115=Flyttar -ClientFrame.116=\ til -ClientFrame.117=... -ClientFrame.118=Flyttinga komplett. -ClientFrame.119=Gje eit nytt filnamn -ClientFrame.120=Endra namn -ClientFrame.121=Kunne ikkje parsa det nye namnet som ein gyldig URI: -ClientFrame.124=Endrar namn -ClientFrame.125=\ til -ClientFrame.126=... -ClientFrame.127=Namneendringa ferdig. -ClientFrame.128=Vel m\u00c3\u00a5lsamlinga. -ClientFrame.129=Kopier -ClientFrame.132=Kopierer -ClientFrame.133=\ til -ClientFrame.134=... -ClientFrame.135=Kopieringa ferdig. -ClientFrame.136=Berre samlingar kan bli reindeksert. -ClientFrame.137=Feil -ClientFrame.138=Er du sikker p\u00c3\u00a5 at du vil reindeksera dei valde samlingane \n og alle ressursane under dei? -ClientFrame.139=Stadfest reindekseringa -ClientFrame.142=Reindekserer samlinga -ClientFrame.143=... -ClientFrame.144=Reindekseringa ferdig. -ClientFrame.145=working-dir -ClientFrame.146=Vel filer eller katalogar du vil leggja til -ClientFrame.147=XMLDB-unnatak: -ClientFrame.148=working-dir -ClientFrame.157=Lag tryggingskopi -ClientFrame.167=__contents__.xml -ClientFrame.168=__contents__.xml-filer -ClientFrame.169=Vel tryggingsfil for \u00c3\u00a5 gjenoppbygga -ClientFrame.170=dba/admin-passord som skal nyttast for gjennoppbygginga: -ClientFrame.171=Admin-passord -ClientFrame.181=Unnatak: -ClientFrame.184=Administrer brukarar -ClientFrame.185=Mislyktest med \u00c3\u00a5 n\u00c3\u00a5 brukaradministrasjonss\u00c3\u00b8rvisen (UserManagementService) -ClientFrame.186=Administrer indeksar -ClientFrame.187=Kunne ikkje f\u00c3\u00a5 tak i systemsamlinga -ClientFrame.190=XACML er ikkje sl\u00c3\u00a5tt p\u00c3\u00a5. For \u00c3\u00a5 sl\u00c3\u00a5 det p\u00c3\u00a5, legg til\n\n \n\ni conf.xml, og start eXist p\u00c3\u00a5 nytt. -ClientFrame.191=Kunne ikkje f\u00c3\u00a5 tak i databaseinstansehandteraren for \u00c3\u00a5 avgjera om XACML er sl\u00c3\u00a5tt p\u00c3\u00a5 -ClientFrame.194=... -ClientFrame.197=XMLDB-unnatak: -ClientFrame.198=\n -ClientFrame.204=cd " -ClientFrame.205=\n -ClientFrame.206=XMLDB-feil: -ClientFrame.207=Ressurs -ClientFrame.208=Dato -ClientFrame.209=Eigar -ClientFrame.210=Gruppe -ClientFrame.211=Rettar -ClientFrame.212=Kolonna eXist-erer ikkje\! -ClientFrame.213=Innlogging til eXist-databasen -ClientFrame.214=Melding: -ClientFrame.215=Unnataksspor: -ClientFrame.216=Feil -ClientFrame.217=Melding: -ClientFrame.218=Unnataksspor: -ClientFrame.219=Feil -ClientFrame.220=Bin\u00c3\u00a6re ressursar -ClientFrame.221=XML-filer -ClientFrame.222=Permission Denied - -DocumentView.0=Vis dokument -DocumentView.6=Dokumentet er l\u00c3\u00a5st av -DocumentView.7=Vil du pr\u00c3\u00b8va \u00c3\u00a5 l\u00c3\u00a5sa opp fila? -DocumentView.8=Dokumentet er l\u00c3\u00a5st -DocumentView.9=Dokumentet kan ikkje l\u00c3\u00a5sast. Det blir opna berre for lesing. -DocumentView.10=XMLDB-feil: -DocumentView.13=Feil -DocumentView.16=Fil -DocumentView.17=Lagra -DocumentView.20=Lagra det endra dokumentet tllbake i databasen. -DocumentView.22=Lagra det nye dokumentet i databasen. -DocumentView.24=Eksporter dokumentet til ei fil. -DocumentView.26=Kopier markeringa. -DocumentView.28=Klypp ut markeringa. -DocumentView.30=Lim inn utklyppet. -DocumentView.32=Les dokumentet p\u00c3\u00a5 nytt fr\u00c3\u00a5 databasen. -DocumentView.33=XML-ressurs -DocumentView.34=Les inn -DocumentView.35=\ ... -DocumentView.36=Lagrar -DocumentView.37=XMLDB-unnatak: -DocumentView.38=Gje namn p\u00c3\u00a5 XML-resursen (inklusive filtillegg) -DocumentView.39=Lagrar -DocumentView.40=XMLDB-unnatak: -DocumentView.41=URI-syntaksunnatak: -DocumentView.44=Spesifiser fil \u00c3\u00a5 eksportera til -DocumentView.45=Fila finst alt. Skriv over? -DocumentView.46=Skriv over? -DocumentView.48=XMLDB-unnatak: -DocumentView.52=Les inn -DocumentView.53=\ fr\u00c3\u00a5\ - -UploadDialog.0=Legg til filer -UploadDialog.1=Tillagde: -UploadDialog.2=Reknar ut dokumentstorleik ... -UploadDialog.3=Katalog: -UploadDialog.4=Legg til fil: -UploadDialog.5=Storleik: -UploadDialog.6=OK -UploadDialog.7=Framdrift: -UploadDialog.9=Avbryt -UploadDialog.11=Steng -UploadDialog.12=KB -UploadDialog.13=Steng -UploadDialog.16=Legg til ... -UploadDialog.17=Legg til ord -UploadDialog.18=Legg til element -UploadDialog.19=Legg til nodar -UploadDialog.20=Steng - -LoginPanel.9=Ei konfigurasjonsfil for ein innbygd eXist-instans -LoginPanel.11=Vel ei anna konfigurasjonsfil for ein innbygd eXist-instans. -LoginPanel.12=url -LoginPanel.16=Vel favoritt -LoginPanel.18=Lagra innstillingar -LoginPanel.22=Ta vekk favoritt -LoginPanel.24=Eksporter favorittar til fila -LoginPanel.25=favourites.xml -LoginPanel.26=Inga favorittfil er vald -LoginPanel.27=Feil -LoginPanel.28=Kan ikkje skriva til vald fil -LoginPanel.29=Feil -LoginPanel.30=Importer -LoginPanel.31=Importer favorittar fr\u00c3\u00a5 fil -LoginPanel.33=Inga favorittfil er vald -LoginPanel.34=Feil -LoginPanel.35=Kan ikkje lesa vald fil -LoginPanel.36=Feil -LoginPanel.37=Vel ei konfigurasjonsfil for ein eXist-instans -LoginPanel.42=name -LoginPanel.43=username -LoginPanel.44=password -LoginPanel.45=url -LoginPanel.46=configuration +ClientFrame.0=Klypp ut +ClientFrame.1=Kopier +ClientFrame.2=Lim inn +ClientFrame.3=eXist-administrasjonsklient +ClientFrame.5=G\u00c3\u00a5 til samlinga over +ClientFrame.7=Oppdater samlingslistinga +ClientFrame.9=Lag ny samling +ClientFrame.11=Legg til ein eller fleire filer til databasen +ClientFrame.13=Slett dei valde filene eller samlingane +ClientFrame.14=icons/Preferences24.gif +ClientFrame.15=Rediger eigar/rettar for dei valde filene eller samlingane +ClientFrame.17=Lag tryggingskopi +ClientFrame.19=Gjenoppbygg fr\u00c3\u00a5 tryggingskopi +ClientFrame.20=icons/keyring-small.png +ClientFrame.21=Administrer brukarar +ClientFrame.23=Opna vindauga for \u00c3\u00a5 s\u00c3\u00b8kja i db med XPath/XQuery +ClientFrame.24=Konsollmeny +ClientFrame.27=eXist-adminklienten tilkopla - +ClientFrame.31=Fil +ClientFrame.32=Legg til filer eller katalogar +ClientFrame.34=Lag samling +ClientFrame.36=Lag tomt dokument +ClientFrame.38=Namn p\u00c3\u00a5 XML-dokumentet (inklusive filtillegg) +ClientFrame.39= +ClientFrame.40=Slett +ClientFrame.42=Kopier +ClientFrame.44=Flytt +ClientFrame.46=Endra namn +ClientFrame.48=Indekser samlinga p\u00c3\u00a5 nytt +ClientFrame.50=Ressurseigenskapar +ClientFrame.52=Avslutt +ClientFrame.54=Verkty +ClientFrame.55=Finn +ClientFrame.57=Administrer brukarar +ClientFrame.59=Administrer indeksar +ClientFrame.61=Administrer policy for rettar +ClientFrame.63=Lag tryggingsskopi +ClientFrame.64=Gjenoppbygg fr\u00c3\u00a5 tryggingskopi +ClientFrame.65=Tilkopling +ClientFrame.66=Kopla fr\u00c3\u00a5 +ClientFrame.67=Kopla fr\u00c3\u00a5\n +ClientFrame.69=Kopla til +ClientFrame.70=Opna innloggingspanetet for \u00c3\u00a5 kopla til, byta servar, eller byta brukaridentitet. +ClientFrame.71=eXist-adminklienten tilkopla - +ClientFrame.75=Kopla til +ClientFrame.77=\ misslyktest\! +ClientFrame.78=Kan ikkje kopla til igjen til +ClientFrame.80=Innstillingar +ClientFrame.81=Innrykk +ClientFrame.82=ja +ClientFrame.83=ja +ClientFrame.84=nei +ClientFrame.85=Ekspander XIncludes (Expand-XIncludes) +ClientFrame.86=ja +ClientFrame.87=ja +ClientFrame.88=nei +ClientFrame.89=Hjelp +ClientFrame.90=Om +ClientFrame.91=exist: +ClientFrame.92=\ +ClientFrame.93=Backspace +ClientFrame.94=cd ..\n +ClientFrame.96=Gje namn p\u00c3\u00a5 ny samling +ClientFrame.99=Spesifiser ein gyldig XML:DB-base-URI (utan +ClientFrame.100=samlingsstig) +ClientFrame.102=Kopling til +ClientFrame.103=\ mislyktest\! +ClientFrame.104=Er du sikker p\u00c3\u00a5 at du vil sletta dei valde +ClientFrame.105=ressursane? +ClientFrame.106=Stadfest slettinga +ClientFrame.107=Held p\u00c3\u00a5 og slettar +ClientFrame.111=Vel m\u00c3\u00a5lsamling +ClientFrame.112=Kopier +ClientFrame.115=Flyttar +ClientFrame.116=\ til +ClientFrame.117=... +ClientFrame.118=Flyttinga komplett. +ClientFrame.119=Gje eit nytt filnamn +ClientFrame.120=Endra namn +ClientFrame.121=Kunne ikkje parsa det nye namnet som ein gyldig URI: +ClientFrame.124=Endrar namn +ClientFrame.125=\ til +ClientFrame.126=... +ClientFrame.127=Namneendringa ferdig. +ClientFrame.128=Vel m\u00c3\u00a5lsamlinga. +ClientFrame.129=Kopier +ClientFrame.132=Kopierer +ClientFrame.133=\ til +ClientFrame.134=... +ClientFrame.135=Kopieringa ferdig. +ClientFrame.136=Berre samlingar kan bli reindeksert. +ClientFrame.137=Feil +ClientFrame.138=Er du sikker p\u00c3\u00a5 at du vil reindeksera dei valde samlingane \n og alle ressursane under dei? +ClientFrame.139=Stadfest reindekseringa +ClientFrame.142=Reindekserer samlinga +ClientFrame.143=... +ClientFrame.144=Reindekseringa ferdig. +ClientFrame.145=working-dir +ClientFrame.146=Vel filer eller katalogar du vil leggja til +ClientFrame.147=XMLDB-unnatak: +ClientFrame.148=working-dir +ClientFrame.157=Lag tryggingskopi +ClientFrame.167=__contents__.xml +ClientFrame.168=__contents__.xml-filer +ClientFrame.169=Vel tryggingsfil for \u00c3\u00a5 gjenoppbygga +ClientFrame.170=dba/admin-passord som skal nyttast for gjennoppbygginga: +ClientFrame.171=Admin-passord +ClientFrame.181=Unnatak: +ClientFrame.184=Administrer brukarar +ClientFrame.185=Mislyktest med \u00c3\u00a5 n\u00c3\u00a5 brukaradministrasjonss\u00c3\u00b8rvisen (UserManagementService) +ClientFrame.186=Administrer indeksar +ClientFrame.187=Kunne ikkje f\u00c3\u00a5 tak i systemsamlinga +ClientFrame.190=XACML er ikkje sl\u00c3\u00a5tt p\u00c3\u00a5. For \u00c3\u00a5 sl\u00c3\u00a5 det p\u00c3\u00a5, legg til\n\n \n\ni conf.xml, og start eXist p\u00c3\u00a5 nytt. +ClientFrame.191=Kunne ikkje f\u00c3\u00a5 tak i databaseinstansehandteraren for \u00c3\u00a5 avgjera om XACML er sl\u00c3\u00a5tt p\u00c3\u00a5 +ClientFrame.194=... +ClientFrame.197=XMLDB-unnatak: +ClientFrame.198=\n +ClientFrame.204=cd " +ClientFrame.205=\n +ClientFrame.206=XMLDB-feil: +ClientFrame.207=Ressurs +ClientFrame.208=Dato +ClientFrame.209=Eigar +ClientFrame.210=Gruppe +ClientFrame.211=Rettar +ClientFrame.212=Kolonna eXist-erer ikkje\! +ClientFrame.213=Innlogging til eXist-databasen +ClientFrame.214=Melding: +ClientFrame.215=Unnataksspor: +ClientFrame.216=Feil +ClientFrame.217=Melding: +ClientFrame.218=Unnataksspor: +ClientFrame.219=Feil +ClientFrame.220=Bin\u00c3\u00a6re ressursar +ClientFrame.221=XML-filer +ClientFrame.222=Permission Denied + +DocumentView.0=Vis dokument +DocumentView.6=Dokumentet er l\u00c3\u00a5st av +DocumentView.7=Vil du pr\u00c3\u00b8va \u00c3\u00a5 l\u00c3\u00a5sa opp fila? +DocumentView.8=Dokumentet er l\u00c3\u00a5st +DocumentView.9=Dokumentet kan ikkje l\u00c3\u00a5sast. Det blir opna berre for lesing. +DocumentView.10=XMLDB-feil: +DocumentView.13=Feil +DocumentView.16=Fil +DocumentView.17=Lagra +DocumentView.20=Lagra det endra dokumentet tllbake i databasen. +DocumentView.22=Lagra det nye dokumentet i databasen. +DocumentView.24=Eksporter dokumentet til ei fil. +DocumentView.26=Kopier markeringa. +DocumentView.28=Klypp ut markeringa. +DocumentView.30=Lim inn utklyppet. +DocumentView.32=Les dokumentet p\u00c3\u00a5 nytt fr\u00c3\u00a5 databasen. +DocumentView.33=XML-ressurs +DocumentView.34=Les inn +DocumentView.35=\ ... +DocumentView.36=Lagrar +DocumentView.37=XMLDB-unnatak: +DocumentView.38=Gje namn p\u00c3\u00a5 XML-resursen (inklusive filtillegg) +DocumentView.39=Lagrar +DocumentView.40=XMLDB-unnatak: +DocumentView.41=URI-syntaksunnatak: +DocumentView.44=Spesifiser fil \u00c3\u00a5 eksportera til +DocumentView.45=Fila finst alt. Skriv over? +DocumentView.46=Skriv over? +DocumentView.48=XMLDB-unnatak: +DocumentView.52=Les inn +DocumentView.53=\ fr\u00c3\u00a5\ + +UploadDialog.0=Legg til filer +UploadDialog.1=Tillagde: +UploadDialog.2=Reknar ut dokumentstorleik ... +UploadDialog.3=Katalog: +UploadDialog.4=Legg til fil: +UploadDialog.5=Storleik: +UploadDialog.6=OK +UploadDialog.7=Framdrift: +UploadDialog.9=Avbryt +UploadDialog.11=Steng +UploadDialog.12=KB +UploadDialog.13=Steng +UploadDialog.16=Legg til ... +UploadDialog.17=Legg til ord +UploadDialog.18=Legg til element +UploadDialog.19=Legg til nodar +UploadDialog.20=Steng + +LoginPanel.9=Ei konfigurasjonsfil for ein innbygd eXist-instans +LoginPanel.11=Vel ei anna konfigurasjonsfil for ein innbygd eXist-instans. +LoginPanel.12=url +LoginPanel.16=Vel favoritt +LoginPanel.18=Lagra innstillingar +LoginPanel.22=Ta vekk favoritt +LoginPanel.24=Eksporter favorittar til fila +LoginPanel.25=favourites.xml +LoginPanel.26=Inga favorittfil er vald +LoginPanel.27=Feil +LoginPanel.28=Kan ikkje skriva til vald fil +LoginPanel.29=Feil +LoginPanel.30=Importer +LoginPanel.31=Importer favorittar fr\u00c3\u00a5 fil +LoginPanel.33=Inga favorittfil er vald +LoginPanel.34=Feil +LoginPanel.35=Kan ikkje lesa vald fil +LoginPanel.36=Feil +LoginPanel.37=Vel ei konfigurasjonsfil for ein eXist-instans +LoginPanel.42=name +LoginPanel.43=username +LoginPanel.44=password +LoginPanel.45=url +LoginPanel.46=configuration diff --git a/src/org/exist/client/messages_ru_RU.properties b/src/org/exist/client/messages_ru_RU.properties index 03e7fc9c3e1..c495d242d9e 100644 --- a/src/org/exist/client/messages_ru_RU.properties +++ b/src/org/exist/client/messages_ru_RU.properties @@ -1,264 +1,264 @@ -ClientFrame.0=\u0412\u044b\u0440\u0435\u0437\u0430\u0442\u044c -ClientFrame.1=\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c -ClientFrame.2=\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044c -ClientFrame.3=\u041f\u0430\u043d\u0435\u043b\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f eXist -ClientFrame.5=\u041f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0443\u044e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e -ClientFrame.7=\u041e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e -ClientFrame.9=\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e -ClientFrame.11=\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0444\u0430\u0439\u043b(\u044b) \u0432 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 -ClientFrame.13=\u0423\u0434\u0430\u043b\u0438\u0442\u044c \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0435 -ClientFrame.14=icons/Preferences24.gif -ClientFrame.15=\u0418\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0430/\u043f\u0440\u0430\u0432\u0430 -ClientFrame.17=\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u0443\u044e \u043a\u043e\u043f\u0438\u044e -ClientFrame.19=\u0412\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0438\u0437 \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u043e\u0439 \u043a\u043e\u043f\u0438\u0438 -ClientFrame.20=icons/keyring-small.png -ClientFrame.21=\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438 -ClientFrame.23=XPath \u0437\u0430\u043f\u0440\u043e\u0441 -ClientFrame.24=\u041a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0435 \u043c\u0435\u043d\u044e -ClientFrame.27=eXist \u043f\u0430\u043d\u0435\u043b\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0430 - -ClientFrame.31=\u0424\u0430\u0439\u043b -ClientFrame.32=\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0444\u0430\u0439\u043b\u044b/\u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0438 -ClientFrame.34=\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e -ClientFrame.36=\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 -ClientFrame.38=\u0418\u043c\u044f XML \u0440\u0435\u0441\u0443\u0440\u0441\u0430 (\u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435) -ClientFrame.39= -ClientFrame.40=\u0423\u0434\u0430\u043b\u0438\u0442\u044c -ClientFrame.42=\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c -ClientFrame.44=\u041f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c -ClientFrame.46=\u041f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u0442\u044c -ClientFrame.48=\u041f\u0435\u0440\u0435\u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e -ClientFrame.50=\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u0430 -ClientFrame.52=\u0412\u044b\u0445\u043e\u0434 -ClientFrame.54=\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b -ClientFrame.55=\u041f\u043e\u0438\u0441\u043a -ClientFrame.57=\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 -ClientFrame.59=\u0418\u043d\u0434\u0435\u043a\u0441\u044b -ClientFrame.61=\u041f\u043e\u043b\u0438\u0442\u0438\u043a\u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 -ClientFrame.63=\u0420\u0435\u0437\u0435\u0440\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c -ClientFrame.64=\u0412\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c -ClientFrame.65=\u0421\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 -ClientFrame.66=\u041e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c -ClientFrame.67=\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\n -ClientFrame.69=\u0421\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 -ClientFrame.70=\u0418\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440/\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. -ClientFrame.71=\u041f\u0430\u043d\u0435\u043b\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f eXist - \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e - -ClientFrame.75=\u0421\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 -ClientFrame.77=\ \u043e\u0431\u043e\u0440\u0432\u0430\u043d\u043e\! -ClientFrame.78=\u041d\u0435 \u043c\u043e\u0433\u0443 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f \u043a -ClientFrame.80=\u041e\u043f\u0446\u0438\u0438 -ClientFrame.81=\u041e\u0442\u0441\u0442\u0443\u043f -ClientFrame.82=\u0434\u0430 -ClientFrame.83=\u0434\u0430 -ClientFrame.84=\u043d\u0435\u0442 -ClientFrame.85=\u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c XIncludes -ClientFrame.86=\u0434\u0430 -ClientFrame.87=\u0434\u0430 -ClientFrame.88=\u043d\u0435\u0442 -ClientFrame.89=\u041f\u043e\u043c\u043e\u0449\u044c -ClientFrame.90=\u041e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 -ClientFrame.91=exist: -ClientFrame.92=\ -ClientFrame.93=\u041f\u0440\u043e\u0431\u0435\u043b -ClientFrame.94=cd ..\n -ClientFrame.96=\u0418\u043c\u044f \u043d\u043e\u0432\u043e\u0439 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 -ClientFrame.99=\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 XML:DB URI (\u0431\u0435\u0437 -ClientFrame.100=\u043f\u0443\u0442\u0438 \u0434\u043e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438) -ClientFrame.102=\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a -ClientFrame.103=\ \u043e\u0431\u043e\u0440\u0432\u0430\u043d\u043e\! -ClientFrame.104=\u0412\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0435 -ClientFrame.105=\u0440\u0435\u0441\u0443\u0440\u0441\u044b? -ClientFrame.106=\u041f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 -ClientFrame.107=\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435... -ClientFrame.108= -ClientFrame.111=\u0412 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e -ClientFrame.112=\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c -ClientFrame.115=\u041f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 -ClientFrame.116=\ \u0432 -ClientFrame.117=... -ClientFrame.118=\u041f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d\u043e. -ClientFrame.119=\u041d\u043e\u0432\u043e\u0435 \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430 -ClientFrame.120=\u041f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u0442\u044c -ClientFrame.121=\u041d\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 uri: -ClientFrame.124=\u041f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 -ClientFrame.125=\ \u0432 -ClientFrame.126=... -ClientFrame.127=\u041f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e. -ClientFrame.128=\u0412 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e -ClientFrame.129=\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c -ClientFrame.132=\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 -ClientFrame.133=\ \u0432 -ClientFrame.134=... -ClientFrame.135=\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e. -ClientFrame.136=\u0418\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438! -ClientFrame.137=\u041e\u0448\u0438\u0431\u043a\u0430 -ClientFrame.138=\u0412\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0438 \u0432\u0441\u0435 \u043f\u043e\u0434\u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0432 \u043d\u0438\u0445? -ClientFrame.139=\u041f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044e -ClientFrame.142=\u041f\u0435\u0440\u0435\u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 -ClientFrame.143=... -ClientFrame.144=\u041f\u0435\u0440\u0435\u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e. -ClientFrame.145=\u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 -ClientFrame.146=\u0412\u044b\u0431\u0435\u0440\u0435\u0442\u0435 \u0444\u0430\u0439\u043b\u044b/\u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0438 \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 -ClientFrame.147=XMLDBException: -ClientFrame.148=\u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 -ClientFrame.157=\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u0443\u044e \u043a\u043e\u043f\u0438\u044e -ClientFrame.167=__contents__.xml -ClientFrame.168=__contents__.xml files -ClientFrame.169=\u0412\u044b\u0431\u0435\u0440\u0435\u0442\u0435 \u0440\u0435\u0437\u0435\u0432\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0434\u043b\u044f \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f -ClientFrame.170=\u043f\u0430\u0440\u043e\u043b\u044c dba/admin \u0434\u043b\u044f \u0432\u043e\u0441\u0441\u0442\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445: -ClientFrame.171=\u041f\u0430\u0440\u043e\u043b\u044c \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430 -ClientFrame.181=Exception: -ClientFrame.184=\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 -ClientFrame.185=\u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c UserManagementService -ClientFrame.186=\u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441\u044b -ClientFrame.187=\u041d\u0435\u043c\u043e\u0433\u0443 \u043d\u0430\u0439\u0442\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u0443\u044e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e -ClientFrame.190=XACML \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0430. \u0427\u0442\u043e\u0431\u044b \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c, \u0434\u043e\u0431\u0430\u0432\u0442\u0435\n\n \n\\u0432 conf.xml \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 eXist. -ClientFrame.191=\u041d\u0435 \u043c\u043e\u0433\u0443 \u043d\u0430\u0439\u0442\u0438 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432\u043a\u043b\u044e\u0447\u0435\u043d \u043b\u0438 XACML -ClientFrame.194=... -ClientFrame.195= -ClientFrame.196= -ClientFrame.197=\u0418\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 XMLDB: -ClientFrame.198=\n -ClientFrame.204=cd " -ClientFrame.205=\n -ClientFrame.206=\u041e\u0448\u0438\u0431\u043a\u0430 XMLDB: -ClientFrame.207=\u0420\u0435\u0441\u0443\u0440\u0441 -ClientFrame.208=\u0414\u0430\u0442\u0430 -ClientFrame.209=\u0412\u043b\u0430\u0434\u0435\u043b\u0435\u0446 -ClientFrame.210=\u0413\u0440\u0443\u043f\u043f\u0430 -ClientFrame.211=\u041f\u0440\u0430\u0432\u0430 -ClientFrame.212=Column does not eXist\! -ClientFrame.213=\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a eXist -ClientFrame.214=\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435: -ClientFrame.215=\u0422\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f: -ClientFrame.216=\u041e\u0448\u0438\u0431\u043a\u0430 -ClientFrame.217=\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435: -ClientFrame.218=\u0422\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f: -ClientFrame.219=\u041e\u0448\u0438\u0431\u043a\u0430 -ClientFrame.220=\u0414\u0432\u043e\u0438\u0447\u043d\u044b\u0439 \u0440\u0435\u0441\u0443\u0440\u0441 -ClientFrame.221=XML \u0444\u0430\u0439\u043b\u044b -ClientFrame.222=Permission Denied -LoginPanel.2=\u041F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u0435\u043B\u044C -LoginPanel.1=favourites -LoginPanel.3=\u041F\u0430\u0440\u043E\u043B\u044C -LoginPanel.4=\u0422\u0438\u043F -LoginPanel.5=Remote -LoginPanel.6=Embedded -LoginPanel.8=\u041D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438 -LoginPanel.9=An eXist configuration file for an embed instance -LoginPanel.10=\u0412\u044B\u0431\u0440\u0430\u0442\u044C -LoginPanel.11=Select an alternate conf file for embed mode. -LoginPanel.13=\u041D\u0430\u0437\u0432\u0430\u043D\u0438\u0435 -LoginPanel.14=Favourites -LoginPanel.15=\u0412\u044B\u0431\u0440\u0430\u0442\u044C -LoginPanel.16=Select favourite -LoginPanel.17=\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C -LoginPanel.18=\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C \u043D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438 -LoginPanel.19=A connection with this name already exists. Ok to overwrite? -LoginPanel.20=\u041A\u043E\u043D\u0444\u043B\u0438\u043A\u0442 -LoginPanel.21=\u0423\u0434\u0430\u043B\u0438\u0442\u044C -LoginPanel.22=Remove favourite -LoginPanel.23=\u042D\u043A\u0441\u043F\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C -LoginPanel.24=Export favourites to file -LoginPanel.26=No favourites file selected -LoginPanel.27=\u041E\u0448\u0438\u0431\u043A\u0430 -LoginPanel.28=Cannot write selected file -LoginPanel.29=\u041E\u0448\u0438\u0431\u043A\u0430 -LoginPanel.30=\u0418\u043C\u043F\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C -LoginPanel.31=Import favourites from file -LoginPanel.33=No favourites file selected -LoginPanel.34=\u041E\u0448\u0438\u0431\u043A\u0430 -LoginPanel.35=Cannot read selected file -LoginPanel.36=\u041E\u0448\u0438\u0431\u043A\u0430 -LoginPanel.37=Select an Exist instance configuration file -LoginPanel.48=Use a secure HTTPS connection. -LoginPanel.49=By default eXist-db receives HTTPS connections on port 8443. Note: a (reverse) proxy or \na webcontainer like Tomcat might influence the availability of this port.\n -UploadDialog.0=Storing files ... -UploadDialog.1=Stored\: -UploadDialog.2=Calculating file sizes ... -UploadDialog.3=\u0414\u0438\u0440\u0440\u0435\u043A\u0442\u043E\u0440\u0438\u044F\: -UploadDialog.4=Uploading file\: -UploadDialog.5=\u0420\u0430\u0437\u043C\u0435\u0440\: -UploadDialog.6=0K -UploadDialog.7=Progress\: -UploadDialog.9=\u041E\u0442\u043C\u0435\u043D\u0430 -UploadDialog.20=\u0417\u0430\u043A\u0440\u044B\u0442\u044C -UploadDialog.11=\u0417\u0430\u043A\u0440\u044B\u0442\u044C -UploadDialog.12=K -UploadDialog.13=\u0417\u0430\u043A\u0440\u044B\u0442\u044C -UploadDialog.16=Storing ... -UploadDialog.17=Storing words -UploadDialog.18=Storing elements -UploadDialog.19=Storing nodes -DocumentView.0=View Document -DocumentView.6=Resource is already locked by user -DocumentView.7=. Should I try to relock it? -DocumentView.8=Resource locked -DocumentView.9=Resource cannot be locked. Opening read-only. -DocumentView.13=\u041E\u0448\u0438\u0431\u043A\u0430 -DocumentView.16=\u0424\u0430\u0439\u043B -DocumentView.17=\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C -DocumentView.20=Store the modified data back into the database. -DocumentView.22=Store a new document into the database. -DocumentView.24=Export to file. -DocumentView.26=Copy selection. -DocumentView.28=Cut selection. -DocumentView.30=Paste selection. -DocumentView.32=Refresh Document. -DocumentView.34=\u0427\u0442\u0435\u043D\u0438\u0435 -DocumentView.36=\u0421\u043E\u0445\u0440\u0430\u043D\u0435\u043D\u0438\u0435 -DocumentView.38=Name of the XML resource (extension incluse) -DocumentView.39=\u0421\u043E\u0445\u0440\u0430\u043D\u0435\u043D\u0438\u0435 -DocumentView.44=Select file for export -DocumentView.45=File exists. Overwrite? -DocumentView.46=Overwrite? -DocumentView.52=Loaded -DocumentView.53= from -CreateBackupDialog.1=Collection\: -CreateBackupDialog.2=Target\: -CreateBackupDialog.3=Select -CreateBackupDialog.4=Select ZIP file or directory. -CreateBackupDialog.5=Select target for backup -CreateBackupDialog.6a=Target -CreateBackupDialog.6b= exists. OK to delete? -CreateBackupDialog.6c=Confirm deletion -QueryDialog.0=Query Dialog -QueryDialog.opentooltip=Read query from file. -QueryDialog.saveastooltip=Write query to file. -QueryDialog.saveresultstooltip=Write result to file. -QueryDialog.copytooltip=Copy selection. -QueryDialog.cuttooltip=Cut selection. -QueryDialog.pastetooltip=Paste selection. -QueryDialog.compiletooltip=Compile only query. -QueryDialog.submittooltip=Submit query. -QueryDialog.submitbutton=Submit -QueryDialog.killtooltip=Kill query. -QueryDialog.killbutton=Kill job -QueryDialog.resultslabel=Results\: -QueryDialog.tracetab=Trace -QueryDialog.inputtab=Query Input\: -QueryDialog.historylabel=History\: -QueryDialog.contextlabel=Context\: -QueryDialog.collectionretrievalerrormessage=An error occurred while retrieving collections list -QueryDialog.maxlabel=Display max.\: -QueryDialog.opendialog=Select query file -QueryDialog.Error=\u041E\u0448\u0438\u0431\u043A\u0430 -QueryDialog.cannotreadmessage=Cannot read query from file -QueryDialog.savedialogpre=Select file for -QueryDialog.savedialogpost=export -QueryDialog.cannotsavemessagepre=Can not write -QueryDialog.cannotsavemessageinf=to file -QueryDialog.savedialogconfirm=File exists. Overwrite? -QueryDialog.compilemessage=Compiling query ... -QueryDialog.Compilation=Compilation -QueryDialog.Execution=Execution -QueryDialog.compilationerrormessage=An exception occurred during query compilation -QueryDialog.processingquerymessage=Processing query ... -QueryDialog.retrievingmessage=Retrieving results ... -QueryDialog.retrievalerrormessage=An error occurred while retrieving results -QueryDialog.Found=\u041D\u0430\u0439\u0434\u0435\u043D\u043E -QueryDialog.items=\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432 -QueryDialog.queryrunerrormessage=An exception occurred during query execution -TriggersDialog.Collection=\u041A\u043E\u043B\u043B\u0435\u043A\u0446\u0438\u044F -TriggersDialog.Triggers=\u0422\u0440\u0438\u0433\u0435\u0440\u0440\u044B -TriggersDialog.addbutton=\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C -TriggersDialog.deletebutton=\u0423\u0434\u0430\u043B\u0438\u0442\u044C +ClientFrame.0=\u0412\u044b\u0440\u0435\u0437\u0430\u0442\u044c +ClientFrame.1=\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c +ClientFrame.2=\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044c +ClientFrame.3=\u041f\u0430\u043d\u0435\u043b\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f eXist +ClientFrame.5=\u041f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0443\u044e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e +ClientFrame.7=\u041e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e +ClientFrame.9=\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e +ClientFrame.11=\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0444\u0430\u0439\u043b(\u044b) \u0432 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 +ClientFrame.13=\u0423\u0434\u0430\u043b\u0438\u0442\u044c \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0435 +ClientFrame.14=icons/Preferences24.gif +ClientFrame.15=\u0418\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0430/\u043f\u0440\u0430\u0432\u0430 +ClientFrame.17=\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u0443\u044e \u043a\u043e\u043f\u0438\u044e +ClientFrame.19=\u0412\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0438\u0437 \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u043e\u0439 \u043a\u043e\u043f\u0438\u0438 +ClientFrame.20=icons/keyring-small.png +ClientFrame.21=\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438 +ClientFrame.23=XPath \u0437\u0430\u043f\u0440\u043e\u0441 +ClientFrame.24=\u041a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0435 \u043c\u0435\u043d\u044e +ClientFrame.27=eXist \u043f\u0430\u043d\u0435\u043b\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0430 - +ClientFrame.31=\u0424\u0430\u0439\u043b +ClientFrame.32=\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0444\u0430\u0439\u043b\u044b/\u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0438 +ClientFrame.34=\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e +ClientFrame.36=\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 +ClientFrame.38=\u0418\u043c\u044f XML \u0440\u0435\u0441\u0443\u0440\u0441\u0430 (\u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435) +ClientFrame.39= +ClientFrame.40=\u0423\u0434\u0430\u043b\u0438\u0442\u044c +ClientFrame.42=\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c +ClientFrame.44=\u041f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c +ClientFrame.46=\u041f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u0442\u044c +ClientFrame.48=\u041f\u0435\u0440\u0435\u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e +ClientFrame.50=\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u0430 +ClientFrame.52=\u0412\u044b\u0445\u043e\u0434 +ClientFrame.54=\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b +ClientFrame.55=\u041f\u043e\u0438\u0441\u043a +ClientFrame.57=\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 +ClientFrame.59=\u0418\u043d\u0434\u0435\u043a\u0441\u044b +ClientFrame.61=\u041f\u043e\u043b\u0438\u0442\u0438\u043a\u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 +ClientFrame.63=\u0420\u0435\u0437\u0435\u0440\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c +ClientFrame.64=\u0412\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c +ClientFrame.65=\u0421\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 +ClientFrame.66=\u041e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c +ClientFrame.67=\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\n +ClientFrame.69=\u0421\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 +ClientFrame.70=\u0418\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440/\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. +ClientFrame.71=\u041f\u0430\u043d\u0435\u043b\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f eXist - \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e - +ClientFrame.75=\u0421\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 +ClientFrame.77=\ \u043e\u0431\u043e\u0440\u0432\u0430\u043d\u043e\! +ClientFrame.78=\u041d\u0435 \u043c\u043e\u0433\u0443 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f \u043a +ClientFrame.80=\u041e\u043f\u0446\u0438\u0438 +ClientFrame.81=\u041e\u0442\u0441\u0442\u0443\u043f +ClientFrame.82=\u0434\u0430 +ClientFrame.83=\u0434\u0430 +ClientFrame.84=\u043d\u0435\u0442 +ClientFrame.85=\u041e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c XIncludes +ClientFrame.86=\u0434\u0430 +ClientFrame.87=\u0434\u0430 +ClientFrame.88=\u043d\u0435\u0442 +ClientFrame.89=\u041f\u043e\u043c\u043e\u0449\u044c +ClientFrame.90=\u041e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 +ClientFrame.91=exist: +ClientFrame.92=\ +ClientFrame.93=\u041f\u0440\u043e\u0431\u0435\u043b +ClientFrame.94=cd ..\n +ClientFrame.96=\u0418\u043c\u044f \u043d\u043e\u0432\u043e\u0439 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 +ClientFrame.99=\u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 XML:DB URI (\u0431\u0435\u0437 +ClientFrame.100=\u043f\u0443\u0442\u0438 \u0434\u043e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438) +ClientFrame.102=\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a +ClientFrame.103=\ \u043e\u0431\u043e\u0440\u0432\u0430\u043d\u043e\! +ClientFrame.104=\u0412\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0435 +ClientFrame.105=\u0440\u0435\u0441\u0443\u0440\u0441\u044b? +ClientFrame.106=\u041f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 +ClientFrame.107=\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435... +ClientFrame.108= +ClientFrame.111=\u0412 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e +ClientFrame.112=\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c +ClientFrame.115=\u041f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 +ClientFrame.116=\ \u0432 +ClientFrame.117=... +ClientFrame.118=\u041f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d\u043e. +ClientFrame.119=\u041d\u043e\u0432\u043e\u0435 \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430 +ClientFrame.120=\u041f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u0442\u044c +ClientFrame.121=\u041d\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 uri: +ClientFrame.124=\u041f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 +ClientFrame.125=\ \u0432 +ClientFrame.126=... +ClientFrame.127=\u041f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e. +ClientFrame.128=\u0412 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e +ClientFrame.129=\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c +ClientFrame.132=\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 +ClientFrame.133=\ \u0432 +ClientFrame.134=... +ClientFrame.135=\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e. +ClientFrame.136=\u0418\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438! +ClientFrame.137=\u041e\u0448\u0438\u0431\u043a\u0430 +ClientFrame.138=\u0412\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0438 \u0432\u0441\u0435 \u043f\u043e\u0434\u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0432 \u043d\u0438\u0445? +ClientFrame.139=\u041f\u043e\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044e +ClientFrame.142=\u041f\u0435\u0440\u0435\u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044f \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 +ClientFrame.143=... +ClientFrame.144=\u041f\u0435\u0440\u0435\u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e. +ClientFrame.145=\u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 +ClientFrame.146=\u0412\u044b\u0431\u0435\u0440\u0435\u0442\u0435 \u0444\u0430\u0439\u043b\u044b/\u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0438 \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 +ClientFrame.147=XMLDBException: +ClientFrame.148=\u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 +ClientFrame.157=\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u0443\u044e \u043a\u043e\u043f\u0438\u044e +ClientFrame.167=__contents__.xml +ClientFrame.168=__contents__.xml files +ClientFrame.169=\u0412\u044b\u0431\u0435\u0440\u0435\u0442\u0435 \u0440\u0435\u0437\u0435\u0432\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u0434\u043b\u044f \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f +ClientFrame.170=\u043f\u0430\u0440\u043e\u043b\u044c dba/admin \u0434\u043b\u044f \u0432\u043e\u0441\u0441\u0442\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445: +ClientFrame.171=\u041f\u0430\u0440\u043e\u043b\u044c \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430 +ClientFrame.181=Exception: +ClientFrame.184=\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 +ClientFrame.185=\u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c UserManagementService +ClientFrame.186=\u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441\u044b +ClientFrame.187=\u041d\u0435\u043c\u043e\u0433\u0443 \u043d\u0430\u0439\u0442\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u0443\u044e \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e +ClientFrame.190=XACML \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0430. \u0427\u0442\u043e\u0431\u044b \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c, \u0434\u043e\u0431\u0430\u0432\u0442\u0435\n\n \n\\u0432 conf.xml \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 eXist. +ClientFrame.191=\u041d\u0435 \u043c\u043e\u0433\u0443 \u043d\u0430\u0439\u0442\u0438 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432\u043a\u043b\u044e\u0447\u0435\u043d \u043b\u0438 XACML +ClientFrame.194=... +ClientFrame.195= +ClientFrame.196= +ClientFrame.197=\u0418\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 XMLDB: +ClientFrame.198=\n +ClientFrame.204=cd " +ClientFrame.205=\n +ClientFrame.206=\u041e\u0448\u0438\u0431\u043a\u0430 XMLDB: +ClientFrame.207=\u0420\u0435\u0441\u0443\u0440\u0441 +ClientFrame.208=\u0414\u0430\u0442\u0430 +ClientFrame.209=\u0412\u043b\u0430\u0434\u0435\u043b\u0435\u0446 +ClientFrame.210=\u0413\u0440\u0443\u043f\u043f\u0430 +ClientFrame.211=\u041f\u0440\u0430\u0432\u0430 +ClientFrame.212=Column does not eXist\! +ClientFrame.213=\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a eXist +ClientFrame.214=\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435: +ClientFrame.215=\u0422\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f: +ClientFrame.216=\u041e\u0448\u0438\u0431\u043a\u0430 +ClientFrame.217=\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435: +ClientFrame.218=\u0422\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f: +ClientFrame.219=\u041e\u0448\u0438\u0431\u043a\u0430 +ClientFrame.220=\u0414\u0432\u043e\u0438\u0447\u043d\u044b\u0439 \u0440\u0435\u0441\u0443\u0440\u0441 +ClientFrame.221=XML \u0444\u0430\u0439\u043b\u044b +ClientFrame.222=Permission Denied +LoginPanel.2=\u041F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u0435\u043B\u044C +LoginPanel.1=favourites +LoginPanel.3=\u041F\u0430\u0440\u043E\u043B\u044C +LoginPanel.4=\u0422\u0438\u043F +LoginPanel.5=Remote +LoginPanel.6=Embedded +LoginPanel.8=\u041D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438 +LoginPanel.9=An eXist configuration file for an embed instance +LoginPanel.10=\u0412\u044B\u0431\u0440\u0430\u0442\u044C +LoginPanel.11=Select an alternate conf file for embed mode. +LoginPanel.13=\u041D\u0430\u0437\u0432\u0430\u043D\u0438\u0435 +LoginPanel.14=Favourites +LoginPanel.15=\u0412\u044B\u0431\u0440\u0430\u0442\u044C +LoginPanel.16=Select favourite +LoginPanel.17=\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C +LoginPanel.18=\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C \u043D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438 +LoginPanel.19=A connection with this name already exists. Ok to overwrite? +LoginPanel.20=\u041A\u043E\u043D\u0444\u043B\u0438\u043A\u0442 +LoginPanel.21=\u0423\u0434\u0430\u043B\u0438\u0442\u044C +LoginPanel.22=Remove favourite +LoginPanel.23=\u042D\u043A\u0441\u043F\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C +LoginPanel.24=Export favourites to file +LoginPanel.26=No favourites file selected +LoginPanel.27=\u041E\u0448\u0438\u0431\u043A\u0430 +LoginPanel.28=Cannot write selected file +LoginPanel.29=\u041E\u0448\u0438\u0431\u043A\u0430 +LoginPanel.30=\u0418\u043C\u043F\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C +LoginPanel.31=Import favourites from file +LoginPanel.33=No favourites file selected +LoginPanel.34=\u041E\u0448\u0438\u0431\u043A\u0430 +LoginPanel.35=Cannot read selected file +LoginPanel.36=\u041E\u0448\u0438\u0431\u043A\u0430 +LoginPanel.37=Select an Exist instance configuration file +LoginPanel.48=Use a secure HTTPS connection. +LoginPanel.49=By default eXist-db receives HTTPS connections on port 8443. Note: a (reverse) proxy or \na webcontainer like Tomcat might influence the availability of this port.\n +UploadDialog.0=Storing files ... +UploadDialog.1=Stored\: +UploadDialog.2=Calculating file sizes ... +UploadDialog.3=\u0414\u0438\u0440\u0440\u0435\u043A\u0442\u043E\u0440\u0438\u044F\: +UploadDialog.4=Uploading file\: +UploadDialog.5=\u0420\u0430\u0437\u043C\u0435\u0440\: +UploadDialog.6=0K +UploadDialog.7=Progress\: +UploadDialog.9=\u041E\u0442\u043C\u0435\u043D\u0430 +UploadDialog.20=\u0417\u0430\u043A\u0440\u044B\u0442\u044C +UploadDialog.11=\u0417\u0430\u043A\u0440\u044B\u0442\u044C +UploadDialog.12=K +UploadDialog.13=\u0417\u0430\u043A\u0440\u044B\u0442\u044C +UploadDialog.16=Storing ... +UploadDialog.17=Storing words +UploadDialog.18=Storing elements +UploadDialog.19=Storing nodes +DocumentView.0=View Document +DocumentView.6=Resource is already locked by user +DocumentView.7=. Should I try to relock it? +DocumentView.8=Resource locked +DocumentView.9=Resource cannot be locked. Opening read-only. +DocumentView.13=\u041E\u0448\u0438\u0431\u043A\u0430 +DocumentView.16=\u0424\u0430\u0439\u043B +DocumentView.17=\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C +DocumentView.20=Store the modified data back into the database. +DocumentView.22=Store a new document into the database. +DocumentView.24=Export to file. +DocumentView.26=Copy selection. +DocumentView.28=Cut selection. +DocumentView.30=Paste selection. +DocumentView.32=Refresh Document. +DocumentView.34=\u0427\u0442\u0435\u043D\u0438\u0435 +DocumentView.36=\u0421\u043E\u0445\u0440\u0430\u043D\u0435\u043D\u0438\u0435 +DocumentView.38=Name of the XML resource (extension incluse) +DocumentView.39=\u0421\u043E\u0445\u0440\u0430\u043D\u0435\u043D\u0438\u0435 +DocumentView.44=Select file for export +DocumentView.45=File exists. Overwrite? +DocumentView.46=Overwrite? +DocumentView.52=Loaded +DocumentView.53= from +CreateBackupDialog.1=Collection\: +CreateBackupDialog.2=Target\: +CreateBackupDialog.3=Select +CreateBackupDialog.4=Select ZIP file or directory. +CreateBackupDialog.5=Select target for backup +CreateBackupDialog.6a=Target +CreateBackupDialog.6b= exists. OK to delete? +CreateBackupDialog.6c=Confirm deletion +QueryDialog.0=Query Dialog +QueryDialog.opentooltip=Read query from file. +QueryDialog.saveastooltip=Write query to file. +QueryDialog.saveresultstooltip=Write result to file. +QueryDialog.copytooltip=Copy selection. +QueryDialog.cuttooltip=Cut selection. +QueryDialog.pastetooltip=Paste selection. +QueryDialog.compiletooltip=Compile only query. +QueryDialog.submittooltip=Submit query. +QueryDialog.submitbutton=Submit +QueryDialog.killtooltip=Kill query. +QueryDialog.killbutton=Kill job +QueryDialog.resultslabel=Results\: +QueryDialog.tracetab=Trace +QueryDialog.inputtab=Query Input\: +QueryDialog.historylabel=History\: +QueryDialog.contextlabel=Context\: +QueryDialog.collectionretrievalerrormessage=An error occurred while retrieving collections list +QueryDialog.maxlabel=Display max.\: +QueryDialog.opendialog=Select query file +QueryDialog.Error=\u041E\u0448\u0438\u0431\u043A\u0430 +QueryDialog.cannotreadmessage=Cannot read query from file +QueryDialog.savedialogpre=Select file for +QueryDialog.savedialogpost=export +QueryDialog.cannotsavemessagepre=Can not write +QueryDialog.cannotsavemessageinf=to file +QueryDialog.savedialogconfirm=File exists. Overwrite? +QueryDialog.compilemessage=Compiling query ... +QueryDialog.Compilation=Compilation +QueryDialog.Execution=Execution +QueryDialog.compilationerrormessage=An exception occurred during query compilation +QueryDialog.processingquerymessage=Processing query ... +QueryDialog.retrievingmessage=Retrieving results ... +QueryDialog.retrievalerrormessage=An error occurred while retrieving results +QueryDialog.Found=\u041D\u0430\u0439\u0434\u0435\u043D\u043E +QueryDialog.items=\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432 +QueryDialog.queryrunerrormessage=An exception occurred during query execution +TriggersDialog.Collection=\u041A\u043E\u043B\u043B\u0435\u043A\u0446\u0438\u044F +TriggersDialog.Triggers=\u0422\u0440\u0438\u0433\u0435\u0440\u0440\u044B +TriggersDialog.addbutton=\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C +TriggersDialog.deletebutton=\u0423\u0434\u0430\u043B\u0438\u0442\u044C diff --git a/src/org/exist/dom/AttrAtExist.java b/src/org/exist/dom/AttrAtExist.java index 683313250e8..53c83deb63a 100644 --- a/src/org/exist/dom/AttrAtExist.java +++ b/src/org/exist/dom/AttrAtExist.java @@ -1,33 +1,33 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2008-2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id$ - */ - -package org.exist.dom; - -import org.w3c.dom.Attr; - -/** - * @author Dmitriy Shabanov - * - */ -public interface AttrAtExist extends Attr { - //Nothing to do here -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2008-2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ + +package org.exist.dom; + +import org.w3c.dom.Attr; + +/** + * @author Dmitriy Shabanov + * + */ +public interface AttrAtExist extends Attr { + //Nothing to do here +} diff --git a/src/org/exist/dom/DocumentAtExist.java b/src/org/exist/dom/DocumentAtExist.java index f4dc8870369..79be0acb68f 100644 --- a/src/org/exist/dom/DocumentAtExist.java +++ b/src/org/exist/dom/DocumentAtExist.java @@ -1,68 +1,68 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2008-2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id$ - */ - -package org.exist.dom; - -import org.exist.Database; -import org.exist.xmldb.XmldbURI; -import org.w3c.dom.DOMException; -import org.w3c.dom.Document; -//import org.exist.collections.Collection; -//import org.exist.interpreter.ContextAtExist; -//import org.exist.security.User; -//import org.exist.storage.lock.Lock; - -/** - * @author Dmitriy Shabanov - * - */ -public interface DocumentAtExist extends NodeAtExist, Document { - -// public void setContext(ContextAtExist context); -// public ContextAtExist getContext(); - - public int getFirstChildFor(int nodeNumber); - - public NodeAtExist getNode(int nodeNr) throws DOMException; - - //memory - public int getNextNodeNumber(int nodeNr) throws DOMException; - - //memory - public boolean hasReferenceNodes(); - -// public boolean isLockedForWrite(); //synchronized -// public Lock getUpdateLock(); //final synchronized -// -// public void setUserLock(User user); -// public User getUserLock(); - -// public Collection getCollection(); - - public int getDocId(); - - public XmldbURI getURI(); - - public Database getDatabase(); - - public Object getUUID(); -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2008-2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ + +package org.exist.dom; + +import org.exist.Database; +import org.exist.xmldb.XmldbURI; +import org.w3c.dom.DOMException; +import org.w3c.dom.Document; +//import org.exist.collections.Collection; +//import org.exist.interpreter.ContextAtExist; +//import org.exist.security.User; +//import org.exist.storage.lock.Lock; + +/** + * @author Dmitriy Shabanov + * + */ +public interface DocumentAtExist extends NodeAtExist, Document { + +// public void setContext(ContextAtExist context); +// public ContextAtExist getContext(); + + public int getFirstChildFor(int nodeNumber); + + public NodeAtExist getNode(int nodeNr) throws DOMException; + + //memory + public int getNextNodeNumber(int nodeNr) throws DOMException; + + //memory + public boolean hasReferenceNodes(); + +// public boolean isLockedForWrite(); //synchronized +// public Lock getUpdateLock(); //final synchronized +// +// public void setUserLock(User user); +// public User getUserLock(); + +// public Collection getCollection(); + + public int getDocId(); + + public XmldbURI getURI(); + + public Database getDatabase(); + + public Object getUUID(); +} diff --git a/src/org/exist/dom/ElementAtExist.java b/src/org/exist/dom/ElementAtExist.java index 8c6810da7a0..74309b6d684 100644 --- a/src/org/exist/dom/ElementAtExist.java +++ b/src/org/exist/dom/ElementAtExist.java @@ -1,37 +1,37 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2008-2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id$ - */ - -package org.exist.dom; - -import java.util.Map; - -import org.w3c.dom.Element; - -/** - * @author Dmitriy Shabanov - * - */ -public interface ElementAtExist extends NodeAtExist, Element { - - public Map getNamespaceMap(); - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2008-2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ + +package org.exist.dom; + +import java.util.Map; + +import org.w3c.dom.Element; + +/** + * @author Dmitriy Shabanov + * + */ +public interface ElementAtExist extends NodeAtExist, Element { + + public Map getNamespaceMap(); + +} diff --git a/src/org/exist/dom/MutableDocumentSet.java b/src/org/exist/dom/MutableDocumentSet.java index 4e2da5e669b..52df50b6377 100644 --- a/src/org/exist/dom/MutableDocumentSet.java +++ b/src/org/exist/dom/MutableDocumentSet.java @@ -1,42 +1,42 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2000-2012 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.dom; - -import org.exist.collections.Collection; - -/** - * Manages a set of documents. - * - * @author wolf - */ -public interface MutableDocumentSet extends DocumentSet { - - void add(DocumentImpl doc); - - void add(DocumentImpl doc, boolean checkDuplicates); - - void addAll(DocumentSet other); - - void addCollection(Collection collection); - - void clear(); +/* + * eXist Open Source Native XML Database + * Copyright (C) 2000-2012 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.dom; + +import org.exist.collections.Collection; + +/** + * Manages a set of documents. + * + * @author wolf + */ +public interface MutableDocumentSet extends DocumentSet { + + void add(DocumentImpl doc); + + void add(DocumentImpl doc, boolean checkDuplicates); + + void addAll(DocumentSet other); + + void addCollection(Collection collection); + + void clear(); } \ No newline at end of file diff --git a/src/org/exist/dom/NamespaceNodeAtExist.java b/src/org/exist/dom/NamespaceNodeAtExist.java index 433d16f5350..a5fe3676a16 100644 --- a/src/org/exist/dom/NamespaceNodeAtExist.java +++ b/src/org/exist/dom/NamespaceNodeAtExist.java @@ -1,31 +1,31 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2008-2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id$ - */ - -package org.exist.dom; - -/** - * @author Dmitriy Shabanov - * - */ -public interface NamespaceNodeAtExist extends NodeAtExist, AttrAtExist { - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2008-2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ + +package org.exist.dom; + +/** + * @author Dmitriy Shabanov + * + */ +public interface NamespaceNodeAtExist extends NodeAtExist, AttrAtExist { + +} diff --git a/src/org/exist/dom/NodeAtExist.java b/src/org/exist/dom/NodeAtExist.java index f4db921b7f1..3e876c1e006 100644 --- a/src/org/exist/dom/NodeAtExist.java +++ b/src/org/exist/dom/NodeAtExist.java @@ -1,45 +1,45 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2008-2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id$ - */ - -package org.exist.dom; - -import org.exist.dom.QNameable; -import org.exist.numbering.NodeId; -//import org.exist.xquery.NodeTest; -//import org.exist.xquery.XPathException; -import org.w3c.dom.Node; - -/** - * @author Dmitriy Shabanov - * - */ -public interface NodeAtExist extends Node, QNameable, Comparable { - - public DocumentAtExist getDocumentAtExist(); - - //the document nodes' array index - public int getNodeNumber(); - - public NodeId getNodeId(); - -// public Boolean matchChildren(NodeTest test) throws XPathException; -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2008-2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ + +package org.exist.dom; + +import org.exist.dom.QNameable; +import org.exist.numbering.NodeId; +//import org.exist.xquery.NodeTest; +//import org.exist.xquery.XPathException; +import org.w3c.dom.Node; + +/** + * @author Dmitriy Shabanov + * + */ +public interface NodeAtExist extends Node, QNameable, Comparable { + + public DocumentAtExist getDocumentAtExist(); + + //the document nodes' array index + public int getNodeNumber(); + + public NodeId getNodeId(); + +// public Boolean matchChildren(NodeTest test) throws XPathException; +} diff --git a/src/org/exist/dom/NodeHandle.java b/src/org/exist/dom/NodeHandle.java index b3163d48c45..50df8d3ed00 100644 --- a/src/org/exist/dom/NodeHandle.java +++ b/src/org/exist/dom/NodeHandle.java @@ -1,22 +1,22 @@ -package org.exist.dom; - -import org.exist.numbering.NodeId; -import org.w3c.dom.Document; - -public interface NodeHandle { - - public NodeId getNodeId(); - - public void setNodeId(NodeId dln); - - public long getInternalAddress(); - - public void setInternalAddress(long internalAddress); - - public short getNodeType(); - - public Document getOwnerDocument(); - - public DocumentImpl getDocument(); - +package org.exist.dom; + +import org.exist.numbering.NodeId; +import org.w3c.dom.Document; + +public interface NodeHandle { + + public NodeId getNodeId(); + + public void setNodeId(NodeId dln); + + public long getInternalAddress(); + + public void setInternalAddress(long internalAddress); + + public short getNodeType(); + + public Document getOwnerDocument(); + + public DocumentImpl getDocument(); + } \ No newline at end of file diff --git a/src/org/exist/fulltext/FTMatchListener.java b/src/org/exist/fulltext/FTMatchListener.java index 44155470834..904f1823e75 100755 --- a/src/org/exist/fulltext/FTMatchListener.java +++ b/src/org/exist/fulltext/FTMatchListener.java @@ -1,222 +1,222 @@ -package org.exist.fulltext; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Stack; - -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.log4j.Logger; -import org.exist.dom.ExtArrayNodeSet; -import org.exist.dom.Match; -import org.exist.dom.NodeProxy; -import org.exist.dom.NodeSet; -import org.exist.dom.QName; -import org.exist.indexing.AbstractMatchListener; -import org.exist.numbering.NodeId; -import org.exist.stax.ExtendedXMLStreamReader; -import org.exist.storage.DBBroker; -import org.exist.util.FastQSort; -import org.exist.util.serializer.AttrList; -import org.xml.sax.SAXException; - -/** - * Implementation of {@link org.exist.indexing.MatchListener} for the fulltext index. - * Right now, the serializer will directly plug this into the listener pipeline. This will - * change once we move the fulltext index into its own module. - */ -public class FTMatchListener extends AbstractMatchListener { - - private final static Logger LOG = Logger.getLogger(FTMatchListener.class); - - private Match match; - private Stack offsetStack = null; - - public FTMatchListener(DBBroker broker, NodeProxy proxy) { - reset(broker, proxy); - } - - public boolean hasMatches(NodeProxy proxy) { - Match nextMatch = proxy.getMatches(); - while (nextMatch != null) { - if (nextMatch.getIndexId() == FTIndex.ID) { - return true; - } - nextMatch = nextMatch.getNextMatch(); - } - return false; - } - - protected void reset(DBBroker broker, NodeProxy proxy) { - this.match = proxy.getMatches(); - setNextInChain(null); - - /* Check if an index is defined on an ancestor of the current node. - * If yes, scan the ancestor to get the offset of the first character - * in the current node. For example, if the indexed node is <a>abc<b>de</b> - * and we query for //a[text:ngram-contains(., 'de')]/b, proxy will be a <b> node, but - * the offsets of the matches are relative to the start of <a>. - */ - NodeSet ancestors = null; - Match nextMatch = this.match; - while (nextMatch != null) { - if (proxy.getNodeId().isDescendantOf(nextMatch.getNodeId())) { - if (ancestors == null) - {ancestors = new ExtArrayNodeSet();} - ancestors.add(new NodeProxy(proxy.getDocument(), nextMatch.getNodeId())); - } - nextMatch = nextMatch.getNextMatch(); - } - if (ancestors != null && !ancestors.isEmpty()) { - for (final Iterator i = ancestors.iterator(); i.hasNext();) { - final NodeProxy p = i.next(); - int startOffset = 0; - try { - final XMLStreamReader reader = broker.getXMLStreamReader(p, false); - while (reader.hasNext()) { - final int ev = reader.next(); - final NodeId nodeId = (NodeId) reader.getProperty(ExtendedXMLStreamReader.PROPERTY_NODE_ID); - if (nodeId.equals(proxy.getNodeId())) - {break;} - if (ev == XMLStreamConstants.CHARACTERS) - {startOffset += reader.getText().length();} - } - } catch (final IOException e) { - LOG.warn("Problem found while serializing XML: " + e.getMessage(), e); - } catch (final XMLStreamException e) { - LOG.warn("Problem found while serializing XML: " + e.getMessage(), e); - } - if (offsetStack == null) - {offsetStack = new Stack();} - offsetStack.push(new NodeOffset(p.getNodeId(), startOffset)); - } - } - } - - @Override - public void startElement(QName qname, AttrList attribs) throws SAXException { - Match nextMatch = match; - // check if there are any matches in the current element - // if yes, push a NodeOffset object to the stack to track - // the node contents - while (nextMatch != null) { - if (nextMatch.getNodeId().equals(getCurrentNode().getNodeId())) { - if (offsetStack == null) - {offsetStack = new Stack();} - offsetStack.push(new NodeOffset(nextMatch.getNodeId())); - break; - } - nextMatch = nextMatch.getNextMatch(); - } - super.startElement(qname, attribs); - } - - @Override - public void endElement(QName qname) throws SAXException { - Match nextMatch = match; - // check if we need to pop the stack - while (nextMatch != null) { - if (nextMatch.getNodeId().equals(getCurrentNode().getNodeId())) { - offsetStack.pop(); - break; - } - nextMatch = nextMatch.getNextMatch(); - } - super.endElement(qname); - } - - @Override - public void characters(CharSequence seq) throws SAXException { - List offsets = null; // a list of offsets to process - if (offsetStack != null) { - // walk through the stack to find matches which start in - // the current string of text - for (int i = 0; i < offsetStack.size(); i++) { - final NodeOffset no = offsetStack.get(i); - int end = no.offset + seq.length(); - // scan all matches - Match next = match; - while (next != null) { - if (next.getIndexId() == FTIndex.ID && next.getNodeId().equals(no.nodeId)) { - final int freq = next.getFrequency(); - for (int j = 0; j < freq; j++) { - final Match.Offset offset = next.getOffset(j); - if (offset.getOffset() < end && - offset.getOffset() + offset.getLength() > no.offset) { - // add it to the list to be processed - if (offsets == null) { - offsets = new ArrayList(4); - } - // adjust the offset and add it to the list - int start = offset.getOffset() - no.offset; - int len = offset.getLength(); - if (start < 0) { - len = len - Math.abs(start); - start = 0; - } - if (start + len > seq.length()) - {len = seq.length() - start;} - offsets.add(new Match.Offset(start, len)); - } - } - } - next = next.getNextMatch(); - } - // add the length of the current text to the element content length - no.offset = end; - } - } - // walk through the matches a second time to find matches in the text node itself - Match next = match; - while (next != null) { - if (next.getIndexId() == FTIndex.ID && - next.getNodeId().equals(getCurrentNode().getNodeId())) { - if (offsets == null) - {offsets = new ArrayList();} - final int freq = next.getFrequency(); - for (int i = 0; i < freq; i++) { - offsets.add(next.getOffset(i)); - } - } - next = next.getNextMatch(); - } - // now print out the text, marking all matches with a match element - if (offsets != null) { - FastQSort.sort(offsets, 0, offsets.size() - 1); - final String s = seq.toString(); - int pos = 0; - for (int i = 0; i < offsets.size(); i++) { - final Match.Offset offset = offsets.get(i); - if (offset.getOffset() > pos) { - super.characters(s.substring(pos, pos + (offset.getOffset() - pos))); - } - super.startElement(MATCH_ELEMENT, null); - super.characters(s.substring(offset.getOffset(), offset.getOffset() + offset.getLength())); - super.endElement(MATCH_ELEMENT); - pos = offset.getOffset() + offset.getLength(); - } - if (pos < s.length()) { - super.characters(s.substring(pos)); - } - } else - {super.characters(seq);} - } - - private class NodeOffset { - NodeId nodeId; - int offset = 0; - - public NodeOffset(NodeId nodeId) { - this.nodeId = nodeId; - } - - public NodeOffset(NodeId nodeId, int offset) { - this.nodeId = nodeId; - this.offset = offset; - } - } -} +package org.exist.fulltext; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Stack; + +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import org.apache.log4j.Logger; +import org.exist.dom.ExtArrayNodeSet; +import org.exist.dom.Match; +import org.exist.dom.NodeProxy; +import org.exist.dom.NodeSet; +import org.exist.dom.QName; +import org.exist.indexing.AbstractMatchListener; +import org.exist.numbering.NodeId; +import org.exist.stax.ExtendedXMLStreamReader; +import org.exist.storage.DBBroker; +import org.exist.util.FastQSort; +import org.exist.util.serializer.AttrList; +import org.xml.sax.SAXException; + +/** + * Implementation of {@link org.exist.indexing.MatchListener} for the fulltext index. + * Right now, the serializer will directly plug this into the listener pipeline. This will + * change once we move the fulltext index into its own module. + */ +public class FTMatchListener extends AbstractMatchListener { + + private final static Logger LOG = Logger.getLogger(FTMatchListener.class); + + private Match match; + private Stack offsetStack = null; + + public FTMatchListener(DBBroker broker, NodeProxy proxy) { + reset(broker, proxy); + } + + public boolean hasMatches(NodeProxy proxy) { + Match nextMatch = proxy.getMatches(); + while (nextMatch != null) { + if (nextMatch.getIndexId() == FTIndex.ID) { + return true; + } + nextMatch = nextMatch.getNextMatch(); + } + return false; + } + + protected void reset(DBBroker broker, NodeProxy proxy) { + this.match = proxy.getMatches(); + setNextInChain(null); + + /* Check if an index is defined on an ancestor of the current node. + * If yes, scan the ancestor to get the offset of the first character + * in the current node. For example, if the indexed node is <a>abc<b>de</b> + * and we query for //a[text:ngram-contains(., 'de')]/b, proxy will be a <b> node, but + * the offsets of the matches are relative to the start of <a>. + */ + NodeSet ancestors = null; + Match nextMatch = this.match; + while (nextMatch != null) { + if (proxy.getNodeId().isDescendantOf(nextMatch.getNodeId())) { + if (ancestors == null) + {ancestors = new ExtArrayNodeSet();} + ancestors.add(new NodeProxy(proxy.getDocument(), nextMatch.getNodeId())); + } + nextMatch = nextMatch.getNextMatch(); + } + if (ancestors != null && !ancestors.isEmpty()) { + for (final Iterator i = ancestors.iterator(); i.hasNext();) { + final NodeProxy p = i.next(); + int startOffset = 0; + try { + final XMLStreamReader reader = broker.getXMLStreamReader(p, false); + while (reader.hasNext()) { + final int ev = reader.next(); + final NodeId nodeId = (NodeId) reader.getProperty(ExtendedXMLStreamReader.PROPERTY_NODE_ID); + if (nodeId.equals(proxy.getNodeId())) + {break;} + if (ev == XMLStreamConstants.CHARACTERS) + {startOffset += reader.getText().length();} + } + } catch (final IOException e) { + LOG.warn("Problem found while serializing XML: " + e.getMessage(), e); + } catch (final XMLStreamException e) { + LOG.warn("Problem found while serializing XML: " + e.getMessage(), e); + } + if (offsetStack == null) + {offsetStack = new Stack();} + offsetStack.push(new NodeOffset(p.getNodeId(), startOffset)); + } + } + } + + @Override + public void startElement(QName qname, AttrList attribs) throws SAXException { + Match nextMatch = match; + // check if there are any matches in the current element + // if yes, push a NodeOffset object to the stack to track + // the node contents + while (nextMatch != null) { + if (nextMatch.getNodeId().equals(getCurrentNode().getNodeId())) { + if (offsetStack == null) + {offsetStack = new Stack();} + offsetStack.push(new NodeOffset(nextMatch.getNodeId())); + break; + } + nextMatch = nextMatch.getNextMatch(); + } + super.startElement(qname, attribs); + } + + @Override + public void endElement(QName qname) throws SAXException { + Match nextMatch = match; + // check if we need to pop the stack + while (nextMatch != null) { + if (nextMatch.getNodeId().equals(getCurrentNode().getNodeId())) { + offsetStack.pop(); + break; + } + nextMatch = nextMatch.getNextMatch(); + } + super.endElement(qname); + } + + @Override + public void characters(CharSequence seq) throws SAXException { + List offsets = null; // a list of offsets to process + if (offsetStack != null) { + // walk through the stack to find matches which start in + // the current string of text + for (int i = 0; i < offsetStack.size(); i++) { + final NodeOffset no = offsetStack.get(i); + int end = no.offset + seq.length(); + // scan all matches + Match next = match; + while (next != null) { + if (next.getIndexId() == FTIndex.ID && next.getNodeId().equals(no.nodeId)) { + final int freq = next.getFrequency(); + for (int j = 0; j < freq; j++) { + final Match.Offset offset = next.getOffset(j); + if (offset.getOffset() < end && + offset.getOffset() + offset.getLength() > no.offset) { + // add it to the list to be processed + if (offsets == null) { + offsets = new ArrayList(4); + } + // adjust the offset and add it to the list + int start = offset.getOffset() - no.offset; + int len = offset.getLength(); + if (start < 0) { + len = len - Math.abs(start); + start = 0; + } + if (start + len > seq.length()) + {len = seq.length() - start;} + offsets.add(new Match.Offset(start, len)); + } + } + } + next = next.getNextMatch(); + } + // add the length of the current text to the element content length + no.offset = end; + } + } + // walk through the matches a second time to find matches in the text node itself + Match next = match; + while (next != null) { + if (next.getIndexId() == FTIndex.ID && + next.getNodeId().equals(getCurrentNode().getNodeId())) { + if (offsets == null) + {offsets = new ArrayList();} + final int freq = next.getFrequency(); + for (int i = 0; i < freq; i++) { + offsets.add(next.getOffset(i)); + } + } + next = next.getNextMatch(); + } + // now print out the text, marking all matches with a match element + if (offsets != null) { + FastQSort.sort(offsets, 0, offsets.size() - 1); + final String s = seq.toString(); + int pos = 0; + for (int i = 0; i < offsets.size(); i++) { + final Match.Offset offset = offsets.get(i); + if (offset.getOffset() > pos) { + super.characters(s.substring(pos, pos + (offset.getOffset() - pos))); + } + super.startElement(MATCH_ELEMENT, null); + super.characters(s.substring(offset.getOffset(), offset.getOffset() + offset.getLength())); + super.endElement(MATCH_ELEMENT); + pos = offset.getOffset() + offset.getLength(); + } + if (pos < s.length()) { + super.characters(s.substring(pos)); + } + } else + {super.characters(seq);} + } + + private class NodeOffset { + NodeId nodeId; + int offset = 0; + + public NodeOffset(NodeId nodeId) { + this.nodeId = nodeId; + } + + public NodeOffset(NodeId nodeId, int offset) { + this.nodeId = nodeId; + this.offset = offset; + } + } +} diff --git a/src/org/exist/http/run-xproc.xq b/src/org/exist/http/run-xproc.xq index e1dc8eb70d3..0d1433fdd33 100644 --- a/src/org/exist/http/run-xproc.xq +++ b/src/org/exist/http/run-xproc.xq @@ -1,28 +1,28 @@ -xquery version "1.0"; - -import module namespace xproc = "http://xproc.net/xproc"; - -declare variable $pipeline external; -declare variable $stdin external; -declare variable $debug external; -declare variable $bindings external; -declare variable $options external; -declare variable $autobind external; - -let $requestparams := if($autobind eq '1') then - for $binding in request:get-parameter-names() - return - if($binding eq 'stdin' or $binding eq 'debug' or $binding eq 'autobind') then - () - else - - {util:parse(request:get-parameter($binding,''))} - - else - () -let $xprocbindings := - {$requestparams} - {util:parse($bindings)//binding} - -return +xquery version "1.0"; + +import module namespace xproc = "http://xproc.net/xproc"; + +declare variable $pipeline external; +declare variable $stdin external; +declare variable $debug external; +declare variable $bindings external; +declare variable $options external; +declare variable $autobind external; + +let $requestparams := if($autobind eq '1') then + for $binding in request:get-parameter-names() + return + if($binding eq 'stdin' or $binding eq 'debug' or $binding eq 'autobind') then + () + else + + {util:parse(request:get-parameter($binding,''))} + + else + () +let $xprocbindings := + {$requestparams} + {util:parse($bindings)//binding} + +return xproc:run( doc($pipeline), doc($stdin), $debug, "0", $xprocbindings, util:parse($options)) \ No newline at end of file diff --git a/src/org/exist/indexing/AbstractIndex.java b/src/org/exist/indexing/AbstractIndex.java index 96402e43487..37d1994f13d 100644 --- a/src/org/exist/indexing/AbstractIndex.java +++ b/src/org/exist/indexing/AbstractIndex.java @@ -1,87 +1,87 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.indexing; - -import org.exist.storage.BrokerPool; -import org.exist.storage.DBBroker; -import org.exist.storage.btree.DBException; -import org.exist.util.DatabaseConfigurationException; -import org.w3c.dom.Element; - -public abstract class AbstractIndex implements Index { - - /** - * Holds an id which uniquely identifies this index. This is usually the class name. - */ - protected static String ID = "Give me an ID !"; - - public static String getID() { - return ID; - } - - protected BrokerPool pool; - //Probably not useful for every kind of index. Anyway... - private String dataDir = null; - protected String name = null; - - public void configure(BrokerPool pool, String dataDir, Element config) - throws DatabaseConfigurationException { - this.pool = pool; - this.dataDir = dataDir; - if (config != null && config.hasAttribute("id")) - {name = config.getAttribute("id");} - } - - public String getIndexId() { - return getID(); - } - - public String getIndexName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public BrokerPool getBrokerPool() { - return pool; - } - - //TODO : declare in interface ? - public String getDataDir() { - return dataDir; - } - - public abstract void open() throws DatabaseConfigurationException; - - public abstract void close() throws DBException; - - public abstract void sync() throws DBException; - - public abstract void remove() throws DBException; - - public abstract IndexWorker getWorker(DBBroker broker); - - public abstract boolean checkIndex(DBBroker broker); - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.indexing; + +import org.exist.storage.BrokerPool; +import org.exist.storage.DBBroker; +import org.exist.storage.btree.DBException; +import org.exist.util.DatabaseConfigurationException; +import org.w3c.dom.Element; + +public abstract class AbstractIndex implements Index { + + /** + * Holds an id which uniquely identifies this index. This is usually the class name. + */ + protected static String ID = "Give me an ID !"; + + public static String getID() { + return ID; + } + + protected BrokerPool pool; + //Probably not useful for every kind of index. Anyway... + private String dataDir = null; + protected String name = null; + + public void configure(BrokerPool pool, String dataDir, Element config) + throws DatabaseConfigurationException { + this.pool = pool; + this.dataDir = dataDir; + if (config != null && config.hasAttribute("id")) + {name = config.getAttribute("id");} + } + + public String getIndexId() { + return getID(); + } + + public String getIndexName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public BrokerPool getBrokerPool() { + return pool; + } + + //TODO : declare in interface ? + public String getDataDir() { + return dataDir; + } + + public abstract void open() throws DatabaseConfigurationException; + + public abstract void close() throws DBException; + + public abstract void sync() throws DBException; + + public abstract void remove() throws DBException; + + public abstract IndexWorker getWorker(DBBroker broker); + + public abstract boolean checkIndex(DBBroker broker); + +} diff --git a/src/org/exist/indexing/AbstractMatchListener.java b/src/org/exist/indexing/AbstractMatchListener.java index cacb7638477..04462253a4a 100644 --- a/src/org/exist/indexing/AbstractMatchListener.java +++ b/src/org/exist/indexing/AbstractMatchListener.java @@ -1,124 +1,124 @@ -package org.exist.indexing; - -import org.exist.dom.QName; -import org.exist.dom.StoredNode; -import org.exist.util.serializer.AttrList; -import org.exist.util.serializer.Receiver; -import org.w3c.dom.Document; -import org.xml.sax.SAXException; - -/** - * Utility implementation of interface {@link org.exist.indexing.MatchListener} which forwards all - * events to a second receiver. Subclass this class and overwrite the methods you are interested in. - * After processing an event, call the corresponding super method to forward it to the next receiver - * in the chain. - */ -public class AbstractMatchListener implements MatchListener { - - protected Receiver nextListener; - protected StoredNode currentNode = null; - - @Override - public void setNextInChain(Receiver next) { - this.nextListener = next; - } - - @Override - public Receiver getNextInChain() { - return nextListener; - } - - @Override - public Receiver getLastInChain() { - Receiver last = this, next = getNextInChain(); - while (next != null) { - last = next; - next = ((MatchListener)next).getNextInChain(); - } - return last; - } - - @Override - public void setCurrentNode(StoredNode node) { - this.currentNode = node; - if (nextListener != null) - {getNextInChain().setCurrentNode(node);} - } - - protected StoredNode getCurrentNode() { - return currentNode; - } - - @Override - public Document getDocument() { - //TODO return currentNode.getDocument() ? - return null; - } - - @Override - public void startDocument() throws SAXException { - if (nextListener != null) {nextListener.startDocument();} - } - - @Override - public void endDocument() throws SAXException { - if (nextListener != null) {nextListener.endDocument();} - } - - @Override - public void startPrefixMapping(String prefix, String namespaceURI) throws SAXException { - if (nextListener != null) {nextListener.startPrefixMapping(prefix, namespaceURI);} - } - - @Override - public void endPrefixMapping(String prefix) throws SAXException { - if (nextListener != null) {nextListener.endPrefixMapping(prefix);} - } - - @Override - public void startElement(QName qname, AttrList attribs) throws SAXException { - if (nextListener != null) {nextListener.startElement(qname, attribs);} - } - - @Override - public void endElement(QName qname) throws SAXException { - if (nextListener != null) {nextListener.endElement(qname);} - } - - @Override - public void characters(CharSequence seq) throws SAXException { - if (nextListener != null) {nextListener.characters(seq);} - } - - @Override - public void attribute(QName qname, String value) throws SAXException { - if (nextListener != null) {nextListener.attribute(qname, value);} - } - - @Override - public void comment(char[] ch, int start, int length) throws SAXException { - if (nextListener != null) {nextListener.comment(ch, start, length);} - } - - @Override - public void cdataSection(char[] ch, int start, int len) throws SAXException { - if (nextListener != null) {nextListener.cdataSection(ch, start, len);} - } - - @Override - public void processingInstruction(String target, String data) throws SAXException { - if (nextListener != null) {nextListener.processingInstruction(target, data);} - } - - @Override - public void documentType(String name, String publicId, String systemId) throws SAXException { - if (nextListener != null) {nextListener.documentType(name, publicId, systemId);} - } - - @Override - public void highlightText(CharSequence seq) throws SAXException { - if (nextListener != null) { - //Nothing to do - } - } -} +package org.exist.indexing; + +import org.exist.dom.QName; +import org.exist.dom.StoredNode; +import org.exist.util.serializer.AttrList; +import org.exist.util.serializer.Receiver; +import org.w3c.dom.Document; +import org.xml.sax.SAXException; + +/** + * Utility implementation of interface {@link org.exist.indexing.MatchListener} which forwards all + * events to a second receiver. Subclass this class and overwrite the methods you are interested in. + * After processing an event, call the corresponding super method to forward it to the next receiver + * in the chain. + */ +public class AbstractMatchListener implements MatchListener { + + protected Receiver nextListener; + protected StoredNode currentNode = null; + + @Override + public void setNextInChain(Receiver next) { + this.nextListener = next; + } + + @Override + public Receiver getNextInChain() { + return nextListener; + } + + @Override + public Receiver getLastInChain() { + Receiver last = this, next = getNextInChain(); + while (next != null) { + last = next; + next = ((MatchListener)next).getNextInChain(); + } + return last; + } + + @Override + public void setCurrentNode(StoredNode node) { + this.currentNode = node; + if (nextListener != null) + {getNextInChain().setCurrentNode(node);} + } + + protected StoredNode getCurrentNode() { + return currentNode; + } + + @Override + public Document getDocument() { + //TODO return currentNode.getDocument() ? + return null; + } + + @Override + public void startDocument() throws SAXException { + if (nextListener != null) {nextListener.startDocument();} + } + + @Override + public void endDocument() throws SAXException { + if (nextListener != null) {nextListener.endDocument();} + } + + @Override + public void startPrefixMapping(String prefix, String namespaceURI) throws SAXException { + if (nextListener != null) {nextListener.startPrefixMapping(prefix, namespaceURI);} + } + + @Override + public void endPrefixMapping(String prefix) throws SAXException { + if (nextListener != null) {nextListener.endPrefixMapping(prefix);} + } + + @Override + public void startElement(QName qname, AttrList attribs) throws SAXException { + if (nextListener != null) {nextListener.startElement(qname, attribs);} + } + + @Override + public void endElement(QName qname) throws SAXException { + if (nextListener != null) {nextListener.endElement(qname);} + } + + @Override + public void characters(CharSequence seq) throws SAXException { + if (nextListener != null) {nextListener.characters(seq);} + } + + @Override + public void attribute(QName qname, String value) throws SAXException { + if (nextListener != null) {nextListener.attribute(qname, value);} + } + + @Override + public void comment(char[] ch, int start, int length) throws SAXException { + if (nextListener != null) {nextListener.comment(ch, start, length);} + } + + @Override + public void cdataSection(char[] ch, int start, int len) throws SAXException { + if (nextListener != null) {nextListener.cdataSection(ch, start, len);} + } + + @Override + public void processingInstruction(String target, String data) throws SAXException { + if (nextListener != null) {nextListener.processingInstruction(target, data);} + } + + @Override + public void documentType(String name, String publicId, String systemId) throws SAXException { + if (nextListener != null) {nextListener.documentType(name, publicId, systemId);} + } + + @Override + public void highlightText(CharSequence seq) throws SAXException { + if (nextListener != null) { + //Nothing to do + } + } +} diff --git a/src/org/exist/indexing/AbstractStreamListener.java b/src/org/exist/indexing/AbstractStreamListener.java index 65d113b8ba8..2761be837b8 100644 --- a/src/org/exist/indexing/AbstractStreamListener.java +++ b/src/org/exist/indexing/AbstractStreamListener.java @@ -1,81 +1,81 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.indexing; - -import org.apache.log4j.Logger; -import org.exist.dom.AttrImpl; -import org.exist.dom.ElementImpl; -import org.exist.dom.CharacterDataImpl; -import org.exist.storage.NodePath; -import org.exist.storage.txn.Txn; - -/** - * Default implementation of a StreamListener. By default forwards all events to - * the next listener in the chain (if there is any). Overwrite methods to handle events - * (but don't forget to call the super method as well). - */ -public abstract class AbstractStreamListener implements StreamListener { - - protected final static Logger LOG = Logger.getLogger(AbstractStreamListener.class); - - private StreamListener next = null; - - @Override - public void setNextInChain(StreamListener listener) { - this.next = listener; - } - - @Override - public StreamListener getNextInChain() { - return next; - } - - @Override - public void startElement(Txn transaction, ElementImpl element, NodePath path) { - if (next != null) - {next.startElement(transaction, element, path);} - } - - @Override - public void attribute(Txn transaction, AttrImpl attrib, NodePath path) { - if (next != null) { - next.attribute(transaction, attrib, path); - } - } - - @Override - public void endElement(Txn transaction, ElementImpl element, NodePath path) { - if (next != null) { - next.endElement(transaction, element, path); - } - } - - @Override - public void characters(Txn transaction, CharacterDataImpl text, NodePath path) { - if (next != null) { - next.characters(transaction, text, path); - } - } - - @Override - public abstract IndexWorker getWorker(); -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.indexing; + +import org.apache.log4j.Logger; +import org.exist.dom.AttrImpl; +import org.exist.dom.ElementImpl; +import org.exist.dom.CharacterDataImpl; +import org.exist.storage.NodePath; +import org.exist.storage.txn.Txn; + +/** + * Default implementation of a StreamListener. By default forwards all events to + * the next listener in the chain (if there is any). Overwrite methods to handle events + * (but don't forget to call the super method as well). + */ +public abstract class AbstractStreamListener implements StreamListener { + + protected final static Logger LOG = Logger.getLogger(AbstractStreamListener.class); + + private StreamListener next = null; + + @Override + public void setNextInChain(StreamListener listener) { + this.next = listener; + } + + @Override + public StreamListener getNextInChain() { + return next; + } + + @Override + public void startElement(Txn transaction, ElementImpl element, NodePath path) { + if (next != null) + {next.startElement(transaction, element, path);} + } + + @Override + public void attribute(Txn transaction, AttrImpl attrib, NodePath path) { + if (next != null) { + next.attribute(transaction, attrib, path); + } + } + + @Override + public void endElement(Txn transaction, ElementImpl element, NodePath path) { + if (next != null) { + next.endElement(transaction, element, path); + } + } + + @Override + public void characters(Txn transaction, CharacterDataImpl text, NodePath path) { + if (next != null) { + next.characters(transaction, text, path); + } + } + + @Override + public abstract IndexWorker getWorker(); +} diff --git a/src/org/exist/indexing/Index.java b/src/org/exist/indexing/Index.java index 48c9d368219..1026da30b84 100644 --- a/src/org/exist/indexing/Index.java +++ b/src/org/exist/indexing/Index.java @@ -1,123 +1,123 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.indexing; - -import org.exist.storage.BrokerPool; -import org.exist.storage.DBBroker; -import org.exist.storage.btree.DBException; -import org.exist.util.DatabaseConfigurationException; -import org.w3c.dom.Element; - -/** - * Represents an arbitrary index structure that can be used by eXist. This is the - * main interface to be registered with the database instance. It provides methods - * to configure, open and close the index. These methods will be called by the main - * database instance during startup/shutdown. They don't need to be synchronized. - */ -public interface Index { - - /** - * Returns an id which uniquely identifies this index. This is usually the class name. - * @return a unique name identifying this index. - */ - String getIndexId(); - - /** - * Returns a human-readable name which uniquely identifies this index. This is configured by the user - * @return a unique name identifying this index. - */ - String getIndexName(); - - /** - * Returns the {@link org.exist.storage.BrokerPool} on with this Index operates. - * - * @return the broker pool - */ - BrokerPool getBrokerPool(); - - /** - * Configure the index and all resources associated with it. This method - * is called while the database instance is initializing and receives the - *
<module id="foo" class="bar"/>
- * section of the configuration file. - * - * @param pool the BrokerPool representing the current database instance. - * @param dataDir the main data directory where eXist stores its files (if relevant). - * @param config the module element which configures this index, as found in conf.xml - * @throws DatabaseConfigurationException - */ - void configure(BrokerPool pool, String dataDir, Element config) throws DatabaseConfigurationException; - - /** - * Opens the index for writing and reading. Will be called during initialization, but also - * if the database has to be restarted. - * - * @throws DatabaseConfigurationException - */ - void open() throws DatabaseConfigurationException; - - /** - * Closes the index and all associated resources. - * - * @throws DBException - */ - void close() throws DBException; - - /** - * Sync the index. This method should make sure that all index contents are written to disk. - * It will be called during checkpoint events and the system relies on the index to materialize - * all data. - * - * @throws DBException - */ - void sync() throws DBException; - - /** - * Closes the index and removes it completely, including all resources and files - * associated to it. This method is called during database repair before the - * db contents are re-indexed. - */ - void remove() throws DBException; - - /** - * Returns a new IndexWorker, which is used to access the index in a multi-threaded - * environment. - * - * Every database instance has a number of - * {@link org.exist.storage.DBBroker} objects. All operations on the db - * have to go through one of these brokers. Each DBBroker retrieves an - * IndexWorker for every index by calling this method. - * - * @param broker The DBBroker that owns this worker - * @return a new IndexWorker that can be used for concurrent access to the index. - */ - IndexWorker getWorker(DBBroker broker); - - /** - * Convenience method that allows to check index consistency. - * - * @param broker the broker that will perform the operation. - * @return whether or not the index is in a consistent state. - * The definition of "consistency" is left to the user. - */ - boolean checkIndex(DBBroker broker); +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.indexing; + +import org.exist.storage.BrokerPool; +import org.exist.storage.DBBroker; +import org.exist.storage.btree.DBException; +import org.exist.util.DatabaseConfigurationException; +import org.w3c.dom.Element; + +/** + * Represents an arbitrary index structure that can be used by eXist. This is the + * main interface to be registered with the database instance. It provides methods + * to configure, open and close the index. These methods will be called by the main + * database instance during startup/shutdown. They don't need to be synchronized. + */ +public interface Index { + + /** + * Returns an id which uniquely identifies this index. This is usually the class name. + * @return a unique name identifying this index. + */ + String getIndexId(); + + /** + * Returns a human-readable name which uniquely identifies this index. This is configured by the user + * @return a unique name identifying this index. + */ + String getIndexName(); + + /** + * Returns the {@link org.exist.storage.BrokerPool} on with this Index operates. + * + * @return the broker pool + */ + BrokerPool getBrokerPool(); + + /** + * Configure the index and all resources associated with it. This method + * is called while the database instance is initializing and receives the + *
<module id="foo" class="bar"/>
+ * section of the configuration file. + * + * @param pool the BrokerPool representing the current database instance. + * @param dataDir the main data directory where eXist stores its files (if relevant). + * @param config the module element which configures this index, as found in conf.xml + * @throws DatabaseConfigurationException + */ + void configure(BrokerPool pool, String dataDir, Element config) throws DatabaseConfigurationException; + + /** + * Opens the index for writing and reading. Will be called during initialization, but also + * if the database has to be restarted. + * + * @throws DatabaseConfigurationException + */ + void open() throws DatabaseConfigurationException; + + /** + * Closes the index and all associated resources. + * + * @throws DBException + */ + void close() throws DBException; + + /** + * Sync the index. This method should make sure that all index contents are written to disk. + * It will be called during checkpoint events and the system relies on the index to materialize + * all data. + * + * @throws DBException + */ + void sync() throws DBException; + + /** + * Closes the index and removes it completely, including all resources and files + * associated to it. This method is called during database repair before the + * db contents are re-indexed. + */ + void remove() throws DBException; + + /** + * Returns a new IndexWorker, which is used to access the index in a multi-threaded + * environment. + * + * Every database instance has a number of + * {@link org.exist.storage.DBBroker} objects. All operations on the db + * have to go through one of these brokers. Each DBBroker retrieves an + * IndexWorker for every index by calling this method. + * + * @param broker The DBBroker that owns this worker + * @return a new IndexWorker that can be used for concurrent access to the index. + */ + IndexWorker getWorker(DBBroker broker); + + /** + * Convenience method that allows to check index consistency. + * + * @param broker the broker that will perform the operation. + * @return whether or not the index is in a consistent state. + * The definition of "consistency" is left to the user. + */ + boolean checkIndex(DBBroker broker); } \ No newline at end of file diff --git a/src/org/exist/indexing/IndexController.java b/src/org/exist/indexing/IndexController.java index 1f85de73c3f..271e1d12bba 100644 --- a/src/org/exist/indexing/IndexController.java +++ b/src/org/exist/indexing/IndexController.java @@ -1,414 +1,414 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.indexing; - -import org.exist.collections.Collection; -import org.exist.dom.*; -import org.exist.storage.DBBroker; -import org.exist.storage.MetaStorage; -import org.exist.storage.MetaStreamListener; -import org.exist.storage.NodePath; -import org.exist.storage.txn.Txn; -import org.exist.util.DatabaseConfigurationException; -import org.exist.xquery.QueryRewriter; -import org.exist.xquery.XQueryContext; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.exist.security.PermissionDeniedException; - -/** - * Internally used to dispatch an operation to each of the - * registered indexes. An IndexController instance can be - * retrieved via {@link org.exist.storage.DBBroker#getIndexController()}. - * - */ -public class IndexController { - - protected Map indexWorkers = new HashMap(); - - protected DBBroker broker; - protected StreamListener listener = null; - protected DocumentImpl currentDoc = null; - protected int currentMode = StreamListener.UNKNOWN; - - public IndexController(DBBroker broker) { - this.broker = broker; - final List workers = broker.getBrokerPool().getIndexManager().getWorkers(broker); - for (final IndexWorker worker : workers) { - indexWorkers.put(worker.getIndexId(), worker); - } - } - - /** - * TODO: temporary method to plug in fulltext index. - * Remove once new fulltext index module is ready. - * - * @param worker - */ - public void addIndexWorker(IndexWorker worker) { - indexWorkers.put(worker.getIndexId(), worker); - } - - /** - * Configures all index workers registered with the db instance. - * - * @param configNodes lists the top-level child nodes below the <index> element in collection.xconf - * @param namespaces the active prefix/namespace map - * @return an arbitrary configuration object to be kept for this index in the collection configuration - * @throws DatabaseConfigurationException if a configuration error occurs - */ - public Map configure(NodeList configNodes, Map namespaces) throws DatabaseConfigurationException { - final Map map = new HashMap(); - Object conf; - for (final IndexWorker indexWorker : indexWorkers.values()) { - conf = indexWorker.configure(this, configNodes, namespaces); - if (conf != null) - {map.put(indexWorker.getIndexId(), conf);} - } - return map; - } - - /** - * Returns an {@link org.exist.indexing.IndexWorker} instance corresponding - * to the specified type of index in indexId. The indexId should be the same one - * as returned by {@link org.exist.indexing.IndexWorker#getIndexId()}. - * - * @param indexId - * @return instance of index worker - */ - public IndexWorker getWorkerByIndexId(String indexId) { - return indexWorkers.get(indexId); - } - - /** - * Returns an {@link org.exist.indexing.IndexWorker} instance corresponding - * to the specified index named by indexName. The indexName should be the same one - * as returned by {@link org.exist.indexing.IndexWorker#getIndexName()}. - * - * @param indexName - * @return instance of index worker - */ - public IndexWorker getWorkerByIndexName(String indexName) { - for (final IndexWorker worker : indexWorkers.values()) { - if (indexName.equals(worker.getIndexName())) - {return worker;} - } - return null; - } - - /** - * Sets the document for the next operation. - * - * @param doc the document - */ - public void setDocument(DocumentImpl doc) { - if (currentDoc != doc) - //Reset listener - {listener = null;} - currentDoc = doc; - for (final IndexWorker indexWorker : indexWorkers.values()) { - indexWorker.setDocument(currentDoc); - } - } - - /** - * Sets the the mode for the next operation. - * - * @param mode the mode, one of {@link StreamListener#UNKNOWN}, {@link StreamListener#STORE}, - * {@link StreamListener#REMOVE_SOME_NODES} or {@link StreamListener#REMOVE_ALL_NODES}. - */ - public void setMode(int mode) { - if (currentMode != mode) - //Reset listener - {listener = null;} - currentMode = mode; - for (final IndexWorker indexWorker : indexWorkers.values()) { - indexWorker.setMode(currentMode); - } - } - - /** - * Returns the document for the next operation. - * - * @return the document - */ - public DocumentImpl getDocument() { - return currentDoc; - } - - /** - * Returns the mode for the next operation. - * - * @return the document - */ - public int getMode() { - return currentMode; - } - - /** - * Sets the document and the mode for the next operation. - * - * @param doc the document - * @param mode the mode, one of {@link StreamListener#UNKNOWN}, {@link StreamListener#STORE}, - * {@link StreamListener#REMOVE_SOME_NODES} or {@link StreamListener#REMOVE_ALL_NODES}. - */ - public void setDocument(DocumentImpl doc, int mode) { - setDocument(doc); - setMode(mode); - } - - /** - * Flushes all index workers. - */ - public void flush() { - for (final IndexWorker indexWorker : indexWorkers.values()) { - indexWorker.flush(); - } - } - - /** - * Remove all indexes defined on the specified collection. - * - * @param collection the collection to remove - * @param broker the broker that will perform the operation - */ - public void removeCollection(Collection collection, DBBroker broker, boolean reindex) - throws PermissionDeniedException { - for (final IndexWorker indexWorker : indexWorkers.values()) { - indexWorker.removeCollection(collection, broker, reindex); - } - } - - /** - * Re-index all nodes below the specified root node, using the given mode. - * - * @param transaction the current transaction - * @param reindexRoot the node from which reindexing should occur - * @param mode the mode, one of {@link StreamListener#UNKNOWN}, {@link StreamListener#STORE}, - * {@link StreamListener#REMOVE_SOME_NODES} or {@link StreamListener#REMOVE_ALL_NODES}. - */ - public void reindex(Txn transaction, StoredNode reindexRoot, int mode) { - if (reindexRoot == null) - {return;} - reindexRoot = broker.objectWith(new NodeProxy(reindexRoot.getDocument(), reindexRoot.getNodeId())); - setDocument(reindexRoot.getDocument(), mode); - getStreamListener(); - IndexUtils.scanNode(broker, transaction, reindexRoot, listener); - flush(); - } - - /** - * When adding or removing nodes to or from the document tree, it might become - * necessary to re-index some parts of the tree, in particular if indexes are defined - * on mixed content nodes. This method will return the top-most root. - * - * @param node the node to be modified. - * @param path the NodePath of the node - * @return the top-most root node to be re-indexed - */ - public StoredNode getReindexRoot(StoredNode node, NodePath path, boolean insert) { - return getReindexRoot(node, path, insert, false); - } - - /** - * When adding or removing nodes to or from the document tree, it might become - * necessary to re-index some parts of the tree, in particular if indexes are defined - * on mixed content nodes. This method will return the top-most root. - * - * @param node the node to be modified. - * @param path path the NodePath of the node - * @param includeSelf if set to true, the current node itself will be included in the check - * @return the top-most root node to be re-indexed - */ - public StoredNode getReindexRoot(StoredNode node, NodePath path, boolean insert, boolean includeSelf) { - StoredNode next, top = null; - for (final IndexWorker indexWorker : indexWorkers.values()) { - next = indexWorker.getReindexRoot(node, path, insert, includeSelf); - if (next != null && (top == null || top.getNodeId().isDescendantOf(next.getNodeId()))) { - top = next; - } - } - if (top != null && top.getNodeId().equals(node.getNodeId())) - {top = node;} - return top; - } - - /** - * Returns a chain of {@link org.exist.indexing.StreamListener}, one - * for each index configured on the current document for the current mode. - * Note that the chain is reinitialized when the operating mode changes. - * That allows workers to return different {@link org.exist.indexing.StreamListener} - * for each mode. - * - * @return the first listener in the chain of StreamListeners - */ - public StreamListener getStreamListener() { - if (listener != null) { - StreamListener next = listener; - while (next != null) { - // wolf: setDocument() should have been called before - // next.getWorker().setDocument(currentDoc, currentMode); - next = next.getNextInChain(); - } - return listener; - } - StreamListener first = null; - StreamListener current, previous = null; - for (final IndexWorker worker : indexWorkers.values()) { - // wolf: setDocument() should have been called before - //worker.setDocument(currentDoc, currentMode); - current = worker.getListener(); - if (first == null) { - first = current; - } else { - if (current != null) - {previous.setNextInChain(current);} - } - if (current != null) - {previous = current;} - } - listener = first; - return listener; - } - - /** - * Helper method: index a single node which has been added during an XUpdate or XQuery update expression. - * - * @param transaction the current transaction - * @param node the node to index - * @param path the node's NodePath - * @param listener the StreamListener which receives the index events - */ - public void indexNode(Txn transaction, StoredNode node, NodePath path, StreamListener listener) { - if (listener != null) { - switch (node.getNodeType()) { - case Node.ELEMENT_NODE: - listener.startElement(transaction, (ElementImpl) node, path); - break; - case Node.TEXT_NODE : - case Node.CDATA_SECTION_NODE : - listener.characters(transaction, (CharacterDataImpl) node, path); - break; - case Node.ATTRIBUTE_NODE : - listener.attribute(transaction, (AttrImpl) node, path); - break; - } - } - } - - /** - * Helper method: index a single element node which has been added during an XUpdate or XQuery update expression. - * - * @param transaction the current transaction - * @param node the node to index - * @param path the node's NodePath - * @param listener the StreamListener which receives the index events - */ - public void startElement(Txn transaction, ElementImpl node, NodePath path, StreamListener listener) { - if (listener != null) - {listener.startElement(transaction, node, path);} - } - - /** - * Helper method: dispatch a single endElement event to the specified listener. - * - * @param transaction the current transaction - * @param node the node to index - * @param path the node's NodePath - * @param listener the StreamListener which receives index events - */ - public void endElement(Txn transaction, ElementImpl node, NodePath path, StreamListener listener) { - if (listener != null) - {listener.endElement(transaction, node, path);} - } - - /** - * Helper method: index a single attribute node which has been added during an XUpdate or XQuery update expression. - * - * @param transaction the current transaction - * @param node the node to index - * @param path the node's NodePath - * @param listener the StreamListener which receives the index events - */ - public void attribute(Txn transaction, AttrImpl node, NodePath path, StreamListener listener) { - if (listener != null) - {listener.attribute(transaction, node, path);} - } - - /** - * Helper method: index a single text node which has been added during an XUpdate or XQuery update expression. - * - * @param transaction the current transaction - * @param node the node to index - * @param path the node's NodePath - * @param listener the StreamListener which receives the index events - */ - public void characters(Txn transaction, TextImpl node, NodePath path, StreamListener listener) { - if (listener != null) - {listener.characters(transaction, node, path);} - } - - /** - * Returns the match listener for this node. - * - * @param proxy a proxy to the node. - * @return the MatchListener - */ - public MatchListener getMatchListener(NodeProxy proxy) { - MatchListener first = null; - MatchListener current, previous = null; - for (final IndexWorker worker : indexWorkers.values()) { - current = worker.getMatchListener(broker, proxy); - if (current != null) { - if (first == null) { - first = current; - } else { - previous.setNextInChain(current); - } - previous = current; - } - } - return first; - } - - public List getQueryRewriters(XQueryContext context) { - List rewriters = new ArrayList(5); - for (final IndexWorker indexWorker : indexWorkers.values()) { - QueryRewriter rewriter = indexWorker.getQueryRewriter(context); - if (rewriter != null) { - rewriters.add(rewriter); - } - } - return rewriters; - } - - public void streamMetas(MetaStreamListener listener) { - MetaStorage ms = broker.getDatabase().getMetaStorage(); - if (ms != null) - ms.streamMetas(currentDoc, listener); - } +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.indexing; + +import org.exist.collections.Collection; +import org.exist.dom.*; +import org.exist.storage.DBBroker; +import org.exist.storage.MetaStorage; +import org.exist.storage.MetaStreamListener; +import org.exist.storage.NodePath; +import org.exist.storage.txn.Txn; +import org.exist.util.DatabaseConfigurationException; +import org.exist.xquery.QueryRewriter; +import org.exist.xquery.XQueryContext; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.exist.security.PermissionDeniedException; + +/** + * Internally used to dispatch an operation to each of the + * registered indexes. An IndexController instance can be + * retrieved via {@link org.exist.storage.DBBroker#getIndexController()}. + * + */ +public class IndexController { + + protected Map indexWorkers = new HashMap(); + + protected DBBroker broker; + protected StreamListener listener = null; + protected DocumentImpl currentDoc = null; + protected int currentMode = StreamListener.UNKNOWN; + + public IndexController(DBBroker broker) { + this.broker = broker; + final List workers = broker.getBrokerPool().getIndexManager().getWorkers(broker); + for (final IndexWorker worker : workers) { + indexWorkers.put(worker.getIndexId(), worker); + } + } + + /** + * TODO: temporary method to plug in fulltext index. + * Remove once new fulltext index module is ready. + * + * @param worker + */ + public void addIndexWorker(IndexWorker worker) { + indexWorkers.put(worker.getIndexId(), worker); + } + + /** + * Configures all index workers registered with the db instance. + * + * @param configNodes lists the top-level child nodes below the <index> element in collection.xconf + * @param namespaces the active prefix/namespace map + * @return an arbitrary configuration object to be kept for this index in the collection configuration + * @throws DatabaseConfigurationException if a configuration error occurs + */ + public Map configure(NodeList configNodes, Map namespaces) throws DatabaseConfigurationException { + final Map map = new HashMap(); + Object conf; + for (final IndexWorker indexWorker : indexWorkers.values()) { + conf = indexWorker.configure(this, configNodes, namespaces); + if (conf != null) + {map.put(indexWorker.getIndexId(), conf);} + } + return map; + } + + /** + * Returns an {@link org.exist.indexing.IndexWorker} instance corresponding + * to the specified type of index in indexId. The indexId should be the same one + * as returned by {@link org.exist.indexing.IndexWorker#getIndexId()}. + * + * @param indexId + * @return instance of index worker + */ + public IndexWorker getWorkerByIndexId(String indexId) { + return indexWorkers.get(indexId); + } + + /** + * Returns an {@link org.exist.indexing.IndexWorker} instance corresponding + * to the specified index named by indexName. The indexName should be the same one + * as returned by {@link org.exist.indexing.IndexWorker#getIndexName()}. + * + * @param indexName + * @return instance of index worker + */ + public IndexWorker getWorkerByIndexName(String indexName) { + for (final IndexWorker worker : indexWorkers.values()) { + if (indexName.equals(worker.getIndexName())) + {return worker;} + } + return null; + } + + /** + * Sets the document for the next operation. + * + * @param doc the document + */ + public void setDocument(DocumentImpl doc) { + if (currentDoc != doc) + //Reset listener + {listener = null;} + currentDoc = doc; + for (final IndexWorker indexWorker : indexWorkers.values()) { + indexWorker.setDocument(currentDoc); + } + } + + /** + * Sets the the mode for the next operation. + * + * @param mode the mode, one of {@link StreamListener#UNKNOWN}, {@link StreamListener#STORE}, + * {@link StreamListener#REMOVE_SOME_NODES} or {@link StreamListener#REMOVE_ALL_NODES}. + */ + public void setMode(int mode) { + if (currentMode != mode) + //Reset listener + {listener = null;} + currentMode = mode; + for (final IndexWorker indexWorker : indexWorkers.values()) { + indexWorker.setMode(currentMode); + } + } + + /** + * Returns the document for the next operation. + * + * @return the document + */ + public DocumentImpl getDocument() { + return currentDoc; + } + + /** + * Returns the mode for the next operation. + * + * @return the document + */ + public int getMode() { + return currentMode; + } + + /** + * Sets the document and the mode for the next operation. + * + * @param doc the document + * @param mode the mode, one of {@link StreamListener#UNKNOWN}, {@link StreamListener#STORE}, + * {@link StreamListener#REMOVE_SOME_NODES} or {@link StreamListener#REMOVE_ALL_NODES}. + */ + public void setDocument(DocumentImpl doc, int mode) { + setDocument(doc); + setMode(mode); + } + + /** + * Flushes all index workers. + */ + public void flush() { + for (final IndexWorker indexWorker : indexWorkers.values()) { + indexWorker.flush(); + } + } + + /** + * Remove all indexes defined on the specified collection. + * + * @param collection the collection to remove + * @param broker the broker that will perform the operation + */ + public void removeCollection(Collection collection, DBBroker broker, boolean reindex) + throws PermissionDeniedException { + for (final IndexWorker indexWorker : indexWorkers.values()) { + indexWorker.removeCollection(collection, broker, reindex); + } + } + + /** + * Re-index all nodes below the specified root node, using the given mode. + * + * @param transaction the current transaction + * @param reindexRoot the node from which reindexing should occur + * @param mode the mode, one of {@link StreamListener#UNKNOWN}, {@link StreamListener#STORE}, + * {@link StreamListener#REMOVE_SOME_NODES} or {@link StreamListener#REMOVE_ALL_NODES}. + */ + public void reindex(Txn transaction, StoredNode reindexRoot, int mode) { + if (reindexRoot == null) + {return;} + reindexRoot = broker.objectWith(new NodeProxy(reindexRoot.getDocument(), reindexRoot.getNodeId())); + setDocument(reindexRoot.getDocument(), mode); + getStreamListener(); + IndexUtils.scanNode(broker, transaction, reindexRoot, listener); + flush(); + } + + /** + * When adding or removing nodes to or from the document tree, it might become + * necessary to re-index some parts of the tree, in particular if indexes are defined + * on mixed content nodes. This method will return the top-most root. + * + * @param node the node to be modified. + * @param path the NodePath of the node + * @return the top-most root node to be re-indexed + */ + public StoredNode getReindexRoot(StoredNode node, NodePath path, boolean insert) { + return getReindexRoot(node, path, insert, false); + } + + /** + * When adding or removing nodes to or from the document tree, it might become + * necessary to re-index some parts of the tree, in particular if indexes are defined + * on mixed content nodes. This method will return the top-most root. + * + * @param node the node to be modified. + * @param path path the NodePath of the node + * @param includeSelf if set to true, the current node itself will be included in the check + * @return the top-most root node to be re-indexed + */ + public StoredNode getReindexRoot(StoredNode node, NodePath path, boolean insert, boolean includeSelf) { + StoredNode next, top = null; + for (final IndexWorker indexWorker : indexWorkers.values()) { + next = indexWorker.getReindexRoot(node, path, insert, includeSelf); + if (next != null && (top == null || top.getNodeId().isDescendantOf(next.getNodeId()))) { + top = next; + } + } + if (top != null && top.getNodeId().equals(node.getNodeId())) + {top = node;} + return top; + } + + /** + * Returns a chain of {@link org.exist.indexing.StreamListener}, one + * for each index configured on the current document for the current mode. + * Note that the chain is reinitialized when the operating mode changes. + * That allows workers to return different {@link org.exist.indexing.StreamListener} + * for each mode. + * + * @return the first listener in the chain of StreamListeners + */ + public StreamListener getStreamListener() { + if (listener != null) { + StreamListener next = listener; + while (next != null) { + // wolf: setDocument() should have been called before + // next.getWorker().setDocument(currentDoc, currentMode); + next = next.getNextInChain(); + } + return listener; + } + StreamListener first = null; + StreamListener current, previous = null; + for (final IndexWorker worker : indexWorkers.values()) { + // wolf: setDocument() should have been called before + //worker.setDocument(currentDoc, currentMode); + current = worker.getListener(); + if (first == null) { + first = current; + } else { + if (current != null) + {previous.setNextInChain(current);} + } + if (current != null) + {previous = current;} + } + listener = first; + return listener; + } + + /** + * Helper method: index a single node which has been added during an XUpdate or XQuery update expression. + * + * @param transaction the current transaction + * @param node the node to index + * @param path the node's NodePath + * @param listener the StreamListener which receives the index events + */ + public void indexNode(Txn transaction, StoredNode node, NodePath path, StreamListener listener) { + if (listener != null) { + switch (node.getNodeType()) { + case Node.ELEMENT_NODE: + listener.startElement(transaction, (ElementImpl) node, path); + break; + case Node.TEXT_NODE : + case Node.CDATA_SECTION_NODE : + listener.characters(transaction, (CharacterDataImpl) node, path); + break; + case Node.ATTRIBUTE_NODE : + listener.attribute(transaction, (AttrImpl) node, path); + break; + } + } + } + + /** + * Helper method: index a single element node which has been added during an XUpdate or XQuery update expression. + * + * @param transaction the current transaction + * @param node the node to index + * @param path the node's NodePath + * @param listener the StreamListener which receives the index events + */ + public void startElement(Txn transaction, ElementImpl node, NodePath path, StreamListener listener) { + if (listener != null) + {listener.startElement(transaction, node, path);} + } + + /** + * Helper method: dispatch a single endElement event to the specified listener. + * + * @param transaction the current transaction + * @param node the node to index + * @param path the node's NodePath + * @param listener the StreamListener which receives index events + */ + public void endElement(Txn transaction, ElementImpl node, NodePath path, StreamListener listener) { + if (listener != null) + {listener.endElement(transaction, node, path);} + } + + /** + * Helper method: index a single attribute node which has been added during an XUpdate or XQuery update expression. + * + * @param transaction the current transaction + * @param node the node to index + * @param path the node's NodePath + * @param listener the StreamListener which receives the index events + */ + public void attribute(Txn transaction, AttrImpl node, NodePath path, StreamListener listener) { + if (listener != null) + {listener.attribute(transaction, node, path);} + } + + /** + * Helper method: index a single text node which has been added during an XUpdate or XQuery update expression. + * + * @param transaction the current transaction + * @param node the node to index + * @param path the node's NodePath + * @param listener the StreamListener which receives the index events + */ + public void characters(Txn transaction, TextImpl node, NodePath path, StreamListener listener) { + if (listener != null) + {listener.characters(transaction, node, path);} + } + + /** + * Returns the match listener for this node. + * + * @param proxy a proxy to the node. + * @return the MatchListener + */ + public MatchListener getMatchListener(NodeProxy proxy) { + MatchListener first = null; + MatchListener current, previous = null; + for (final IndexWorker worker : indexWorkers.values()) { + current = worker.getMatchListener(broker, proxy); + if (current != null) { + if (first == null) { + first = current; + } else { + previous.setNextInChain(current); + } + previous = current; + } + } + return first; + } + + public List getQueryRewriters(XQueryContext context) { + List rewriters = new ArrayList(5); + for (final IndexWorker indexWorker : indexWorkers.values()) { + QueryRewriter rewriter = indexWorker.getQueryRewriter(context); + if (rewriter != null) { + rewriters.add(rewriter); + } + } + return rewriters; + } + + public void streamMetas(MetaStreamListener listener) { + MetaStorage ms = broker.getDatabase().getMetaStorage(); + if (ms != null) + ms.streamMetas(currentDoc, listener); + } } \ No newline at end of file diff --git a/src/org/exist/indexing/IndexManager.java b/src/org/exist/indexing/IndexManager.java index 35783157b40..b15da776d84 100644 --- a/src/org/exist/indexing/IndexManager.java +++ b/src/org/exist/indexing/IndexManager.java @@ -1,242 +1,242 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.indexing; - -import org.apache.log4j.Logger; -import org.exist.backup.RawDataBackup; -import org.exist.storage.BrokerPool; -import org.exist.storage.DBBroker; -import org.exist.storage.btree.DBException; -import org.exist.util.Configuration; -import org.exist.util.DatabaseConfigurationException; -import org.w3c.dom.Element; - -import java.io.IOException; -import java.util.*; - -/** - * Manages all custom indexes registered with the database instance. - */ -public class IndexManager { - - private final static Logger LOG = Logger.getLogger(IndexManager.class); - - public static final String CONFIGURATION_ELEMENT_NAME = "modules"; - public static final String CONFIGURATION_MODULE_ELEMENT_NAME = "module"; - public static final String INDEXER_MODULES_CLASS_ATTRIBUTE = "class"; - public static final String INDEXER_MODULES_ID_ATTRIBUTE = "id"; - - public final static String PROPERTY_INDEXER_MODULES = "indexer.modules"; - - private BrokerPool pool; - - private Map indexers = new HashMap(); - - /** - * Constructs a new IndexManager and registers the indexes specified in - * the global configuration object, i.e. in the : - *
-     * <modules>
-     *   <module id="foo" class="bar" foo1="bar1" ... />
-     * </modules>
-     * 
- * section of the configuration file. - * - * @param pool the BrokerPool representing the current database instance - * @param config the configuration object - * @throws DatabaseConfigurationException - */ - public IndexManager(BrokerPool pool, Configuration config) throws DatabaseConfigurationException { - this.pool = pool; - final Configuration.IndexModuleConfig modConf[] = (Configuration.IndexModuleConfig[]) - config.getProperty(PROPERTY_INDEXER_MODULES); - final String dataDir = (String) config.getProperty(BrokerPool.PROPERTY_DATA_DIR); - if (modConf != null) { - for (int i = 0; i < modConf.length; i++) { - final String className = modConf[i].getClassName(); - initIndex(pool, modConf[i].getId(), modConf[i].getConfig(), dataDir, className); - } - } - // check if a structural index was configured. If not, create one based on default settings. - AbstractIndex structural = (AbstractIndex) indexers.get(StructuralIndex.STRUCTURAL_INDEX_ID); - if (structural == null) { - structural = initIndex(pool, StructuralIndex.STRUCTURAL_INDEX_ID, null, dataDir, StructuralIndex.DEFAULT_CLASS); - structural.setName(StructuralIndex.STRUCTURAL_INDEX_ID); - } - } - - private AbstractIndex initIndex(BrokerPool pool, String id, Element config, String dataDir, String className) throws DatabaseConfigurationException { - try { - final Class clazz = Class.forName(className); - if (!AbstractIndex.class.isAssignableFrom(clazz)) { - throw new DatabaseConfigurationException("Class " + className + " does not implement " + - AbstractIndex.class.getName()); - } - final AbstractIndex index = (AbstractIndex)clazz.newInstance(); - index.configure(pool, dataDir, config); - index.open(); - indexers.put(id, index); - if (LOG.isInfoEnabled()) - {LOG.info("Registered index " + className + " as " + id);} - return index; - } catch (final ClassNotFoundException e) { - LOG.warn("Class " + className + " not found. Cannot configure index."); - } catch (final IllegalAccessException e) { - LOG.warn("Exception while configuring index " + className + ": " + e.getMessage(), e); - } catch (final InstantiationException e) { - LOG.warn("Exception while configuring index " + className + ": " + e.getMessage(), e); - } - return null; - } - - public Index registerIndex(Index index) throws DatabaseConfigurationException { - index.open(); - indexers.put(index.getIndexId(), index); - if (LOG.isInfoEnabled()) - {LOG.info("Registered index " + index.getClass() + " as " + index.getIndexId());} - return index; - } - - /** - * Returns the {@link org.exist.storage.BrokerPool} on with this IndexManager operates. - * - * @return the broker pool - */ - public BrokerPool getBrokerPool() { - return pool; - } - - /** - * Returns an iterator over the registered indexes. - * - * @return the iterator - */ - protected Iterator iterator() { - return indexers.values().iterator(); - } - - /** - * Returns the index registered with the provided ID. - * - * @param indexId the ID - * @return the index - */ - public synchronized Index getIndexById(String indexId) { - for (final Iterator i = iterator(); i.hasNext(); ) { - final Index indexer = i.next(); - if (indexId.equals(indexer.getIndexId())) - {return indexer;} - } - return null; - } - - /** - * Returns the index registered with the provided human-readable name. - * @param indexName the name - * @return the index - */ - public synchronized Index getIndexByName(String indexName) { - return indexers.get(indexName); - } - - /** - * Returns a set of IndexWorkers, one for each registered index. The - * returned IndexWorkers are used by the DBBroker instances to perform the - * actual indexing work. - * - * @return set of IndexWorkers - */ - protected synchronized List getWorkers(DBBroker broker) { - final List workerList = new ArrayList(indexers.size()); - for (final Iterator i = indexers.values().iterator(); i.hasNext(); ) { - final Index index = i.next(); - final IndexWorker worker = index.getWorker(broker); - if (worker != null) - {workerList.add(worker);} - } - return workerList; - } - - /** - * Shutdowns all registered indexes by calling {@link org.exist.indexing.Index#close()} - * on them. - * - * @throws DBException - */ - public void shutdown() throws DBException { - Index index; - for (final Iterator i = iterator(); i.hasNext(); ) { - index = i.next(); - index.close(); - } - } - - /** - * Call indexes to flush all data to disk. - * - * @throws DBException - */ - public void sync() throws DBException { - Index index; - for (final Iterator i = iterator(); i.hasNext(); ) { - index = i.next(); - index.sync(); - } - } - - /** - * Physically destroy the registered indexes by calling {@link org.exist.indexing.Index#remove()} - * on them. - * - * @throws DBException - */ - public void removeIndexes() throws DBException { - Index index; - for (final Iterator i = iterator(); i.hasNext();) { - index = i.next(); - index.remove(); - } - } - - /** Reopens the registered index in case they have been closed by a previous operation - * such as {@link org.exist.indexing.Index#close()} by calling {@link org.exist.indexing.Index#open()} - * on them. - * - * @throws DatabaseConfigurationException - */ - public void reopenIndexes() throws DatabaseConfigurationException { - Index index; - for (final Iterator i = iterator(); i.hasNext();) { - index = i.next(); - index.open(); - } - } - - public void backupToArchive(RawDataBackup backup) throws IOException { - Index index; - for (final Iterator i = iterator(); i.hasNext();) { - index = i.next(); - if (index instanceof RawBackupSupport) - {((RawBackupSupport)index).backupToArchive(backup);} - } - } +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.indexing; + +import org.apache.log4j.Logger; +import org.exist.backup.RawDataBackup; +import org.exist.storage.BrokerPool; +import org.exist.storage.DBBroker; +import org.exist.storage.btree.DBException; +import org.exist.util.Configuration; +import org.exist.util.DatabaseConfigurationException; +import org.w3c.dom.Element; + +import java.io.IOException; +import java.util.*; + +/** + * Manages all custom indexes registered with the database instance. + */ +public class IndexManager { + + private final static Logger LOG = Logger.getLogger(IndexManager.class); + + public static final String CONFIGURATION_ELEMENT_NAME = "modules"; + public static final String CONFIGURATION_MODULE_ELEMENT_NAME = "module"; + public static final String INDEXER_MODULES_CLASS_ATTRIBUTE = "class"; + public static final String INDEXER_MODULES_ID_ATTRIBUTE = "id"; + + public final static String PROPERTY_INDEXER_MODULES = "indexer.modules"; + + private BrokerPool pool; + + private Map indexers = new HashMap(); + + /** + * Constructs a new IndexManager and registers the indexes specified in + * the global configuration object, i.e. in the : + *
+     * <modules>
+     *   <module id="foo" class="bar" foo1="bar1" ... />
+     * </modules>
+     * 
+ * section of the configuration file. + * + * @param pool the BrokerPool representing the current database instance + * @param config the configuration object + * @throws DatabaseConfigurationException + */ + public IndexManager(BrokerPool pool, Configuration config) throws DatabaseConfigurationException { + this.pool = pool; + final Configuration.IndexModuleConfig modConf[] = (Configuration.IndexModuleConfig[]) + config.getProperty(PROPERTY_INDEXER_MODULES); + final String dataDir = (String) config.getProperty(BrokerPool.PROPERTY_DATA_DIR); + if (modConf != null) { + for (int i = 0; i < modConf.length; i++) { + final String className = modConf[i].getClassName(); + initIndex(pool, modConf[i].getId(), modConf[i].getConfig(), dataDir, className); + } + } + // check if a structural index was configured. If not, create one based on default settings. + AbstractIndex structural = (AbstractIndex) indexers.get(StructuralIndex.STRUCTURAL_INDEX_ID); + if (structural == null) { + structural = initIndex(pool, StructuralIndex.STRUCTURAL_INDEX_ID, null, dataDir, StructuralIndex.DEFAULT_CLASS); + structural.setName(StructuralIndex.STRUCTURAL_INDEX_ID); + } + } + + private AbstractIndex initIndex(BrokerPool pool, String id, Element config, String dataDir, String className) throws DatabaseConfigurationException { + try { + final Class clazz = Class.forName(className); + if (!AbstractIndex.class.isAssignableFrom(clazz)) { + throw new DatabaseConfigurationException("Class " + className + " does not implement " + + AbstractIndex.class.getName()); + } + final AbstractIndex index = (AbstractIndex)clazz.newInstance(); + index.configure(pool, dataDir, config); + index.open(); + indexers.put(id, index); + if (LOG.isInfoEnabled()) + {LOG.info("Registered index " + className + " as " + id);} + return index; + } catch (final ClassNotFoundException e) { + LOG.warn("Class " + className + " not found. Cannot configure index."); + } catch (final IllegalAccessException e) { + LOG.warn("Exception while configuring index " + className + ": " + e.getMessage(), e); + } catch (final InstantiationException e) { + LOG.warn("Exception while configuring index " + className + ": " + e.getMessage(), e); + } + return null; + } + + public Index registerIndex(Index index) throws DatabaseConfigurationException { + index.open(); + indexers.put(index.getIndexId(), index); + if (LOG.isInfoEnabled()) + {LOG.info("Registered index " + index.getClass() + " as " + index.getIndexId());} + return index; + } + + /** + * Returns the {@link org.exist.storage.BrokerPool} on with this IndexManager operates. + * + * @return the broker pool + */ + public BrokerPool getBrokerPool() { + return pool; + } + + /** + * Returns an iterator over the registered indexes. + * + * @return the iterator + */ + protected Iterator iterator() { + return indexers.values().iterator(); + } + + /** + * Returns the index registered with the provided ID. + * + * @param indexId the ID + * @return the index + */ + public synchronized Index getIndexById(String indexId) { + for (final Iterator i = iterator(); i.hasNext(); ) { + final Index indexer = i.next(); + if (indexId.equals(indexer.getIndexId())) + {return indexer;} + } + return null; + } + + /** + * Returns the index registered with the provided human-readable name. + * @param indexName the name + * @return the index + */ + public synchronized Index getIndexByName(String indexName) { + return indexers.get(indexName); + } + + /** + * Returns a set of IndexWorkers, one for each registered index. The + * returned IndexWorkers are used by the DBBroker instances to perform the + * actual indexing work. + * + * @return set of IndexWorkers + */ + protected synchronized List getWorkers(DBBroker broker) { + final List workerList = new ArrayList(indexers.size()); + for (final Iterator i = indexers.values().iterator(); i.hasNext(); ) { + final Index index = i.next(); + final IndexWorker worker = index.getWorker(broker); + if (worker != null) + {workerList.add(worker);} + } + return workerList; + } + + /** + * Shutdowns all registered indexes by calling {@link org.exist.indexing.Index#close()} + * on them. + * + * @throws DBException + */ + public void shutdown() throws DBException { + Index index; + for (final Iterator i = iterator(); i.hasNext(); ) { + index = i.next(); + index.close(); + } + } + + /** + * Call indexes to flush all data to disk. + * + * @throws DBException + */ + public void sync() throws DBException { + Index index; + for (final Iterator i = iterator(); i.hasNext(); ) { + index = i.next(); + index.sync(); + } + } + + /** + * Physically destroy the registered indexes by calling {@link org.exist.indexing.Index#remove()} + * on them. + * + * @throws DBException + */ + public void removeIndexes() throws DBException { + Index index; + for (final Iterator i = iterator(); i.hasNext();) { + index = i.next(); + index.remove(); + } + } + + /** Reopens the registered index in case they have been closed by a previous operation + * such as {@link org.exist.indexing.Index#close()} by calling {@link org.exist.indexing.Index#open()} + * on them. + * + * @throws DatabaseConfigurationException + */ + public void reopenIndexes() throws DatabaseConfigurationException { + Index index; + for (final Iterator i = iterator(); i.hasNext();) { + index = i.next(); + index.open(); + } + } + + public void backupToArchive(RawDataBackup backup) throws IOException { + Index index; + for (final Iterator i = iterator(); i.hasNext();) { + index = i.next(); + if (index instanceof RawBackupSupport) + {((RawBackupSupport)index).backupToArchive(backup);} + } + } } \ No newline at end of file diff --git a/src/org/exist/indexing/IndexUtils.java b/src/org/exist/indexing/IndexUtils.java index a99b9543798..3a7045300b7 100644 --- a/src/org/exist/indexing/IndexUtils.java +++ b/src/org/exist/indexing/IndexUtils.java @@ -1,60 +1,60 @@ -package org.exist.indexing; - -import org.exist.dom.AttrImpl; -import org.exist.dom.ElementImpl; -import org.exist.dom.StoredNode; -import org.exist.dom.TextImpl; -import org.exist.storage.DBBroker; -import org.exist.storage.NodePath; -import org.exist.storage.txn.Txn; -import org.w3c.dom.Node; - -import java.util.Iterator; - -/** - * Various utility methods to be used by Index implementations. - */ -public class IndexUtils { - - public static void scanNode(DBBroker broker, Txn transaction, StoredNode node, StreamListener listener) { - final Iterator iterator = broker.getNodeIterator(node); - iterator.next(); - final NodePath path = node.getPath(); - scanNode(transaction, iterator, node, listener, path); - } - - private static void scanNode(Txn transaction, Iterator iterator, - StoredNode node, StreamListener listener, NodePath currentPath) { - switch (node.getNodeType()) { - case Node.ELEMENT_NODE: - if (listener != null) { - listener.startElement(transaction, (ElementImpl) node, currentPath); - } - if (node.hasChildNodes()) { - final int childCount = node.getChildCount(); - for (int i = 0; i < childCount; i++) { - final StoredNode child = iterator.next(); - if (child.getNodeType() == Node.ELEMENT_NODE) - {currentPath.addComponent(child.getQName());} - scanNode(transaction, iterator, child, listener, currentPath); - if (child.getNodeType() == Node.ELEMENT_NODE) - {currentPath.removeLastComponent();} - } - } - if (listener != null) { - listener.endElement(transaction, (ElementImpl) node, currentPath); - } - break; - case Node.TEXT_NODE : - if (listener != null) { - listener.characters(transaction, (TextImpl) node, currentPath); - } - break; - case Node.ATTRIBUTE_NODE : - if (listener != null) { - listener.attribute(transaction, (AttrImpl) node, currentPath); - } - break; - } - } -} +package org.exist.indexing; + +import org.exist.dom.AttrImpl; +import org.exist.dom.ElementImpl; +import org.exist.dom.StoredNode; +import org.exist.dom.TextImpl; +import org.exist.storage.DBBroker; +import org.exist.storage.NodePath; +import org.exist.storage.txn.Txn; +import org.w3c.dom.Node; + +import java.util.Iterator; + +/** + * Various utility methods to be used by Index implementations. + */ +public class IndexUtils { + + public static void scanNode(DBBroker broker, Txn transaction, StoredNode node, StreamListener listener) { + final Iterator iterator = broker.getNodeIterator(node); + iterator.next(); + final NodePath path = node.getPath(); + scanNode(transaction, iterator, node, listener, path); + } + + private static void scanNode(Txn transaction, Iterator iterator, + StoredNode node, StreamListener listener, NodePath currentPath) { + switch (node.getNodeType()) { + case Node.ELEMENT_NODE: + if (listener != null) { + listener.startElement(transaction, (ElementImpl) node, currentPath); + } + if (node.hasChildNodes()) { + final int childCount = node.getChildCount(); + for (int i = 0; i < childCount; i++) { + final StoredNode child = iterator.next(); + if (child.getNodeType() == Node.ELEMENT_NODE) + {currentPath.addComponent(child.getQName());} + scanNode(transaction, iterator, child, listener, currentPath); + if (child.getNodeType() == Node.ELEMENT_NODE) + {currentPath.removeLastComponent();} + } + } + if (listener != null) { + listener.endElement(transaction, (ElementImpl) node, currentPath); + } + break; + case Node.TEXT_NODE : + if (listener != null) { + listener.characters(transaction, (TextImpl) node, currentPath); + } + break; + case Node.ATTRIBUTE_NODE : + if (listener != null) { + listener.attribute(transaction, (AttrImpl) node, currentPath); + } + break; + } + } +} diff --git a/src/org/exist/indexing/IndexWorker.java b/src/org/exist/indexing/IndexWorker.java index 1da477782b3..43cd9332d4a 100644 --- a/src/org/exist/indexing/IndexWorker.java +++ b/src/org/exist/indexing/IndexWorker.java @@ -1,219 +1,219 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.indexing; - -import org.exist.collections.Collection; -import org.exist.dom.DocumentImpl; -import org.exist.dom.DocumentSet; -import org.exist.dom.NodeProxy; -import org.exist.dom.NodeSet; -import org.exist.dom.StoredNode; -import org.exist.storage.DBBroker; -import org.exist.storage.NodePath; -import org.exist.util.DatabaseConfigurationException; -import org.exist.util.Occurrences; -import org.exist.xquery.QueryRewriter; -import org.exist.xquery.XQueryContext; -import org.w3c.dom.NodeList; - -import java.util.Map; -import org.exist.security.PermissionDeniedException; - -/** - * Provide concurrent access to the index structure. Implements the core operations on the index. - * The methods in this class are used in a multi-threaded environment. Every thread accessing the - * database will have exactly one IndexWorker for every index. {@link org.exist.indexing.Index#getWorker(DBBroker)} - * should thus return a new IndexWorker whenever it is called. Implementations of IndexWorker have - * to take care of synchronizing access to shared resources. - */ -public interface IndexWorker { - - /** - * A key to a QName {@link java.util.List} "hint" to be used when the index scans its index entries - */ - public static final String VALUE_COUNT = "value_count"; - - /** - * Returns an ID which uniquely identifies this worker's index. - * @return a unique name identifying this worker's index. - */ - public String getIndexId(); - - /** - * Returns a name which uniquely identifies this worker's index. - * @return a unique name identifying this worker's index. - */ - public String getIndexName(); - - /** - * Read an index configuration from an collection.xconf configuration document. - * - * This method is called by the {@link org.exist.collections.CollectionConfiguration} while - * reading the collection.xconf configuration file for a given collection. The configNodes - * parameter lists all top-level child nodes below the <index> element in the - * collection.xconf. The IndexWorker should scan this list and handle those elements - * it understands. - * - * The returned Object will be stored in the collection configuration structure associated - * with each collection. It can later be retrieved from the collection configuration, e.g. to - * check if a given node should be indexed or not. - * - * @param configNodes lists the top-level child nodes below the <index> element in collection.xconf - * @param namespaces the active prefix/namespace map - * @return an arbitrary configuration object to be kept for this index in the collection configuration - * @throws DatabaseConfigurationException if a configuration error occurs - */ - Object configure(IndexController controller, NodeList configNodes, - Map namespaces) throws DatabaseConfigurationException; - - /** - * Notify this worker to operate on the specified document. - * - * @param doc the document which is processed - */ - void setDocument(DocumentImpl doc); - - /** - * Notify this worker to operate on the specified document, using the mode - * given. Mode will be one of {@link StreamListener#UNKNOWN}, {@link StreamListener#STORE}, - * {@link StreamListener#REMOVE_SOME_NODES} or {@link StreamListener#REMOVE_ALL_NODES}. - * - * @param doc the document which is processed - * @param mode the current operation mode - */ - void setDocument(DocumentImpl doc, int mode); - - /** - * Notify this worker to operate using the mode - * given. Mode will be one of {@link StreamListener#UNKNOWN}, {@link StreamListener#STORE}, - * {@link StreamListener#REMOVE_SOME_NODES} or {@link StreamListener#REMOVE_ALL_NODES}. - * - * @param mode the current operation mode - */ - void setMode(int mode); - - /** - * Returns the document for the next operation. - * - * @return the document - */ - DocumentImpl getDocument(); - - /** - * Returns the mode for the next operation. - * - * @return the document - */ - int getMode(); - - /** - * When adding or removing nodes to or from the document tree, it might become - * necessary to re-index some parts of the tree, in particular if indexes are defined - * on mixed content nodes. It will then return the top-most root. - * - * @param node the node to be modified. - * @param path path the NodePath of the node - * @param insert true if a node is being inserted or appended. In this case, the method - * will be called with the parent node as first argument. Usually a reindex is - * not required unless the index is defined on the parent node or an ancestor of it. - * @param includeSelf if set to true, the current node itself will be included in the check - * @return the top-most root node to be reindexed - */ - StoredNode getReindexRoot(StoredNode node, NodePath path, boolean insert, boolean includeSelf); - - /** - * Return a stream listener to index the current document in the current mode. - * There will never be more than one StreamListener being used per thread, so it is safe - * for the implementation to reuse a single StreamListener. - * - * Parameter mode specifies the type of the current operation. - * - * @return a StreamListener - */ - StreamListener getListener(); - - /** - * Returns a {@link org.exist.indexing.MatchListener}, which can be used to filter - * (and manipulate) the XML output generated by the serializer when serializing - * query results. The method should return null if the implementation is not interested - * in receiving serialization events. - * - * @param proxy the NodeProxy which is being serialized - * @return a MatchListener or null if the implementation does not want to receive - * serialization events - */ - MatchListener getMatchListener(DBBroker broker, NodeProxy proxy); - - /** - * Flush the index. This method will be called when indexing a document. The implementation should - * immediately process all data it has buffered (if there is any), release as many memory resources - * as it can and prepare for being reused for a different job. - */ - void flush(); - - /** - * Remove all indexes for the given collection, its subcollections and - * all resources.. - * - * @param collection The collection to remove - * @param broker The broker that will perform the operation - */ - void removeCollection(Collection collection, DBBroker broker, boolean reindex) throws PermissionDeniedException; - - /** - * Checking index could be delegated to a worker. Use this method to do so. - * @param broker The broker that will perform the operation - * @return Whether or not the index if in a suitable state - */ - boolean checkIndex(DBBroker broker); - - /** - * Return aggregated (on a document count basis) - * index entries for the specified document set. Aggregation can only occur if - * the index entries can be compared, i.e. if the index implements - * {@link org.exist.indexing.OrderedValuesIndex}, otherwise each entry will be considered - * as a single occurrence. - * @param context - * @param docs The documents to which the index entries belong - * @param contextSet - * @param hints Some "hints" for retrieving the index entries. See such hints in - * {@link org.exist.indexing.OrderedValuesIndex} and {@link org.exist.indexing.QNamedKeysIndex}. - * @return Occurrences objects that contain : - *
    - *
  1. a string representation of the index entry. This may change in the future.
  2. - *
  3. the number of occurrences for the index entry over all the documents
  4. - *
  5. the list of the documents in which the index entry is
  6. - *
- */ - public Occurrences[] scanIndex(XQueryContext context, DocumentSet docs, NodeSet contextSet, Map hints); - - /** - * Returns a {@link QueryRewriter} to be called by the query optimizer. - * - * @param context the current XQuery context - * @return the query rewriter or null if the index does no rewriting - */ - QueryRewriter getQueryRewriter(XQueryContext context); - - //TODO : a scanIndex() method that would return an unaggregated list of index entries ? - +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.indexing; + +import org.exist.collections.Collection; +import org.exist.dom.DocumentImpl; +import org.exist.dom.DocumentSet; +import org.exist.dom.NodeProxy; +import org.exist.dom.NodeSet; +import org.exist.dom.StoredNode; +import org.exist.storage.DBBroker; +import org.exist.storage.NodePath; +import org.exist.util.DatabaseConfigurationException; +import org.exist.util.Occurrences; +import org.exist.xquery.QueryRewriter; +import org.exist.xquery.XQueryContext; +import org.w3c.dom.NodeList; + +import java.util.Map; +import org.exist.security.PermissionDeniedException; + +/** + * Provide concurrent access to the index structure. Implements the core operations on the index. + * The methods in this class are used in a multi-threaded environment. Every thread accessing the + * database will have exactly one IndexWorker for every index. {@link org.exist.indexing.Index#getWorker(DBBroker)} + * should thus return a new IndexWorker whenever it is called. Implementations of IndexWorker have + * to take care of synchronizing access to shared resources. + */ +public interface IndexWorker { + + /** + * A key to a QName {@link java.util.List} "hint" to be used when the index scans its index entries + */ + public static final String VALUE_COUNT = "value_count"; + + /** + * Returns an ID which uniquely identifies this worker's index. + * @return a unique name identifying this worker's index. + */ + public String getIndexId(); + + /** + * Returns a name which uniquely identifies this worker's index. + * @return a unique name identifying this worker's index. + */ + public String getIndexName(); + + /** + * Read an index configuration from an collection.xconf configuration document. + * + * This method is called by the {@link org.exist.collections.CollectionConfiguration} while + * reading the collection.xconf configuration file for a given collection. The configNodes + * parameter lists all top-level child nodes below the <index> element in the + * collection.xconf. The IndexWorker should scan this list and handle those elements + * it understands. + * + * The returned Object will be stored in the collection configuration structure associated + * with each collection. It can later be retrieved from the collection configuration, e.g. to + * check if a given node should be indexed or not. + * + * @param configNodes lists the top-level child nodes below the <index> element in collection.xconf + * @param namespaces the active prefix/namespace map + * @return an arbitrary configuration object to be kept for this index in the collection configuration + * @throws DatabaseConfigurationException if a configuration error occurs + */ + Object configure(IndexController controller, NodeList configNodes, + Map namespaces) throws DatabaseConfigurationException; + + /** + * Notify this worker to operate on the specified document. + * + * @param doc the document which is processed + */ + void setDocument(DocumentImpl doc); + + /** + * Notify this worker to operate on the specified document, using the mode + * given. Mode will be one of {@link StreamListener#UNKNOWN}, {@link StreamListener#STORE}, + * {@link StreamListener#REMOVE_SOME_NODES} or {@link StreamListener#REMOVE_ALL_NODES}. + * + * @param doc the document which is processed + * @param mode the current operation mode + */ + void setDocument(DocumentImpl doc, int mode); + + /** + * Notify this worker to operate using the mode + * given. Mode will be one of {@link StreamListener#UNKNOWN}, {@link StreamListener#STORE}, + * {@link StreamListener#REMOVE_SOME_NODES} or {@link StreamListener#REMOVE_ALL_NODES}. + * + * @param mode the current operation mode + */ + void setMode(int mode); + + /** + * Returns the document for the next operation. + * + * @return the document + */ + DocumentImpl getDocument(); + + /** + * Returns the mode for the next operation. + * + * @return the document + */ + int getMode(); + + /** + * When adding or removing nodes to or from the document tree, it might become + * necessary to re-index some parts of the tree, in particular if indexes are defined + * on mixed content nodes. It will then return the top-most root. + * + * @param node the node to be modified. + * @param path path the NodePath of the node + * @param insert true if a node is being inserted or appended. In this case, the method + * will be called with the parent node as first argument. Usually a reindex is + * not required unless the index is defined on the parent node or an ancestor of it. + * @param includeSelf if set to true, the current node itself will be included in the check + * @return the top-most root node to be reindexed + */ + StoredNode getReindexRoot(StoredNode node, NodePath path, boolean insert, boolean includeSelf); + + /** + * Return a stream listener to index the current document in the current mode. + * There will never be more than one StreamListener being used per thread, so it is safe + * for the implementation to reuse a single StreamListener. + * + * Parameter mode specifies the type of the current operation. + * + * @return a StreamListener + */ + StreamListener getListener(); + + /** + * Returns a {@link org.exist.indexing.MatchListener}, which can be used to filter + * (and manipulate) the XML output generated by the serializer when serializing + * query results. The method should return null if the implementation is not interested + * in receiving serialization events. + * + * @param proxy the NodeProxy which is being serialized + * @return a MatchListener or null if the implementation does not want to receive + * serialization events + */ + MatchListener getMatchListener(DBBroker broker, NodeProxy proxy); + + /** + * Flush the index. This method will be called when indexing a document. The implementation should + * immediately process all data it has buffered (if there is any), release as many memory resources + * as it can and prepare for being reused for a different job. + */ + void flush(); + + /** + * Remove all indexes for the given collection, its subcollections and + * all resources.. + * + * @param collection The collection to remove + * @param broker The broker that will perform the operation + */ + void removeCollection(Collection collection, DBBroker broker, boolean reindex) throws PermissionDeniedException; + + /** + * Checking index could be delegated to a worker. Use this method to do so. + * @param broker The broker that will perform the operation + * @return Whether or not the index if in a suitable state + */ + boolean checkIndex(DBBroker broker); + + /** + * Return aggregated (on a document count basis) + * index entries for the specified document set. Aggregation can only occur if + * the index entries can be compared, i.e. if the index implements + * {@link org.exist.indexing.OrderedValuesIndex}, otherwise each entry will be considered + * as a single occurrence. + * @param context + * @param docs The documents to which the index entries belong + * @param contextSet + * @param hints Some "hints" for retrieving the index entries. See such hints in + * {@link org.exist.indexing.OrderedValuesIndex} and {@link org.exist.indexing.QNamedKeysIndex}. + * @return Occurrences objects that contain : + *
    + *
  1. a string representation of the index entry. This may change in the future.
  2. + *
  3. the number of occurrences for the index entry over all the documents
  4. + *
  5. the list of the documents in which the index entry is
  6. + *
+ */ + public Occurrences[] scanIndex(XQueryContext context, DocumentSet docs, NodeSet contextSet, Map hints); + + /** + * Returns a {@link QueryRewriter} to be called by the query optimizer. + * + * @param context the current XQuery context + * @return the query rewriter or null if the index does no rewriting + */ + QueryRewriter getQueryRewriter(XQueryContext context); + + //TODO : a scanIndex() method that would return an unaggregated list of index entries ? + } \ No newline at end of file diff --git a/src/org/exist/indexing/MatchListener.java b/src/org/exist/indexing/MatchListener.java index e5d02069335..dc9b146b068 100644 --- a/src/org/exist/indexing/MatchListener.java +++ b/src/org/exist/indexing/MatchListener.java @@ -1,37 +1,37 @@ -package org.exist.indexing; - -import org.exist.util.serializer.Receiver; - -/** - * Highlight matches in query results. Indexes can implement - * this interface to filter the output produced by the serializer - * when serializing query results. See - * {@link org.exist.indexing.IndexWorker#getMatchListener(org.exist.storage.DBBroker, org.exist.dom.NodeProxy)}. - * The interface basically extends {@link org.exist.util.serializer.Receiver}. The - * additional methods are used to chain multiple MatchListeners. Implementations should - * forward all events to the next receiver in the chain (if there is one). - * Class {@link org.exist.indexing.AbstractMatchListener} provides default implementations - * for all methods. - */ -public interface MatchListener extends Receiver { - - /** - * Register the next receiver in the chain. All - * events should be forwarded to this. - * - * @param next the next receiver in the chain. - */ - void setNextInChain(Receiver next); - - /** - * Returns the next receiver in the chain. - * @return the next receiver - */ - Receiver getNextInChain(); - - /** - * Walks the chain and returns the final receiver. - * @return the last receiver in the chain - */ - Receiver getLastInChain(); +package org.exist.indexing; + +import org.exist.util.serializer.Receiver; + +/** + * Highlight matches in query results. Indexes can implement + * this interface to filter the output produced by the serializer + * when serializing query results. See + * {@link org.exist.indexing.IndexWorker#getMatchListener(org.exist.storage.DBBroker, org.exist.dom.NodeProxy)}. + * The interface basically extends {@link org.exist.util.serializer.Receiver}. The + * additional methods are used to chain multiple MatchListeners. Implementations should + * forward all events to the next receiver in the chain (if there is one). + * Class {@link org.exist.indexing.AbstractMatchListener} provides default implementations + * for all methods. + */ +public interface MatchListener extends Receiver { + + /** + * Register the next receiver in the chain. All + * events should be forwarded to this. + * + * @param next the next receiver in the chain. + */ + void setNextInChain(Receiver next); + + /** + * Returns the next receiver in the chain. + * @return the next receiver + */ + Receiver getNextInChain(); + + /** + * Walks the chain and returns the final receiver. + * @return the last receiver in the chain + */ + Receiver getLastInChain(); } \ No newline at end of file diff --git a/src/org/exist/indexing/OrderedValuesIndex.java b/src/org/exist/indexing/OrderedValuesIndex.java index 4581f172e36..7a52815f8ec 100644 --- a/src/org/exist/indexing/OrderedValuesIndex.java +++ b/src/org/exist/indexing/OrderedValuesIndex.java @@ -1,22 +1,22 @@ -package org.exist.indexing; - -/** - * Indexes that store their values in a determinist way (whatever it is) should implement this interface. - * - * @author brihaye - * - */ -public interface OrderedValuesIndex extends IndexWorker { - - - /** - * A key to the value "hint" to start from when the index scans its index entries - */ - public static final String START_VALUE = "start_value"; - - /** - * A key to the value "hint" to end with when the index scans its index entries - */ - public static final String END_VALUE = "end_value"; - -} +package org.exist.indexing; + +/** + * Indexes that store their values in a determinist way (whatever it is) should implement this interface. + * + * @author brihaye + * + */ +public interface OrderedValuesIndex extends IndexWorker { + + + /** + * A key to the value "hint" to start from when the index scans its index entries + */ + public static final String START_VALUE = "start_value"; + + /** + * A key to the value "hint" to end with when the index scans its index entries + */ + public static final String END_VALUE = "end_value"; + +} diff --git a/src/org/exist/indexing/QNamedKeysIndex.java b/src/org/exist/indexing/QNamedKeysIndex.java index e240530323f..68ae23ed777 100644 --- a/src/org/exist/indexing/QNamedKeysIndex.java +++ b/src/org/exist/indexing/QNamedKeysIndex.java @@ -1,17 +1,17 @@ -package org.exist.indexing; - -/** - * Indexes that store their values with an information about the QName of their nodes - * should implement this interface. - * - * @author brihaye - * - */ -public interface QNamedKeysIndex extends IndexWorker { - - /** - * A key to a QName {@link java.util.List} "hint" to be used when the index scans its index entries - */ - public static final String QNAMES_KEY = "qnames_key"; - -} +package org.exist.indexing; + +/** + * Indexes that store their values with an information about the QName of their nodes + * should implement this interface. + * + * @author brihaye + * + */ +public interface QNamedKeysIndex extends IndexWorker { + + /** + * A key to a QName {@link java.util.List} "hint" to be used when the index scans its index entries + */ + public static final String QNAMES_KEY = "qnames_key"; + +} diff --git a/src/org/exist/indexing/StreamListener.java b/src/org/exist/indexing/StreamListener.java index 3840dd915bc..fcedeae98a7 100644 --- a/src/org/exist/indexing/StreamListener.java +++ b/src/org/exist/indexing/StreamListener.java @@ -1,115 +1,115 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.indexing; - -import org.exist.dom.AttrImpl; -import org.exist.dom.ElementImpl; -import org.exist.dom.CharacterDataImpl; -import org.exist.storage.NodePath; -import org.exist.storage.txn.Txn; - -/** - * Callback interface which receives index events. StreamListeners are chained; - * events should be forwarded to the next listener in the chain (if there is any). - */ -public interface StreamListener { - - /** - * Undefined mode - */ - public final static int UNKNOWN = -1; - - /** - * Mode for storing nodes of a document - */ - public final static int STORE = 0; - - /** - * Mode for removing all the nodes of a document - */ - public final static int REMOVE_ALL_NODES = 1; - - /** - * Mode for removing some nodes of a document - */ - public final static int REMOVE_SOME_NODES = 2; - - public final static int REMOVE_BINARY = 3; - - /** - * Returns the IndexWorker that owns this listener. - * - * @return the IndexWorker - */ - IndexWorker getWorker(); - - /** - * Set the next stream listener in the chain. Events should always be forwarded - * to the next listener. - * - * @param listener the next listener in the chain. - */ - void setNextInChain(StreamListener listener); - - /** - * Returns the next stream listener in the chain. This should usually be the one - * that was passed in from {@link #setNextInChain(StreamListener)}. - * - * @return the next listener in the chain. - */ - StreamListener getNextInChain(); - - /** - * Processed the opening tag of an element. - * - * @param transaction the current transaction - * @param element the element which has been stored to the db - * @param path the current node path - */ - void startElement(Txn transaction, ElementImpl element, NodePath path); - - /** - * An attribute has been stored. - * - * @param transaction the current transaction - * @param attrib the attribute which has been stored to the db - * @param path the current node path - */ - void attribute(Txn transaction, AttrImpl attrib, NodePath path); - - /** - * A text node has been stored. - * @param transaction the current transaction - * @param text the text node which has been stored to the db. - * @param path the current node path - */ - void characters(Txn transaction, CharacterDataImpl text, NodePath path); - - /** - * Processed the closing tag of an element. - * - * @param transaction the current transaction - * @param element the element which has been stored to the db - * @param path the current node path - */ - void endElement(Txn transaction, ElementImpl element, NodePath path); +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.indexing; + +import org.exist.dom.AttrImpl; +import org.exist.dom.ElementImpl; +import org.exist.dom.CharacterDataImpl; +import org.exist.storage.NodePath; +import org.exist.storage.txn.Txn; + +/** + * Callback interface which receives index events. StreamListeners are chained; + * events should be forwarded to the next listener in the chain (if there is any). + */ +public interface StreamListener { + + /** + * Undefined mode + */ + public final static int UNKNOWN = -1; + + /** + * Mode for storing nodes of a document + */ + public final static int STORE = 0; + + /** + * Mode for removing all the nodes of a document + */ + public final static int REMOVE_ALL_NODES = 1; + + /** + * Mode for removing some nodes of a document + */ + public final static int REMOVE_SOME_NODES = 2; + + public final static int REMOVE_BINARY = 3; + + /** + * Returns the IndexWorker that owns this listener. + * + * @return the IndexWorker + */ + IndexWorker getWorker(); + + /** + * Set the next stream listener in the chain. Events should always be forwarded + * to the next listener. + * + * @param listener the next listener in the chain. + */ + void setNextInChain(StreamListener listener); + + /** + * Returns the next stream listener in the chain. This should usually be the one + * that was passed in from {@link #setNextInChain(StreamListener)}. + * + * @return the next listener in the chain. + */ + StreamListener getNextInChain(); + + /** + * Processed the opening tag of an element. + * + * @param transaction the current transaction + * @param element the element which has been stored to the db + * @param path the current node path + */ + void startElement(Txn transaction, ElementImpl element, NodePath path); + + /** + * An attribute has been stored. + * + * @param transaction the current transaction + * @param attrib the attribute which has been stored to the db + * @param path the current node path + */ + void attribute(Txn transaction, AttrImpl attrib, NodePath path); + + /** + * A text node has been stored. + * @param transaction the current transaction + * @param text the text node which has been stored to the db. + * @param path the current node path + */ + void characters(Txn transaction, CharacterDataImpl text, NodePath path); + + /** + * Processed the closing tag of an element. + * + * @param transaction the current transaction + * @param element the element which has been stored to the db + * @param path the current node path + */ + void endElement(Txn transaction, ElementImpl element, NodePath path); } \ No newline at end of file diff --git a/src/org/exist/installer/Setup.java b/src/org/exist/installer/Setup.java index 267a5e22330..54204ee41af 100644 --- a/src/org/exist/installer/Setup.java +++ b/src/org/exist/installer/Setup.java @@ -1,202 +1,202 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ - -package org.exist.installer; - -import org.exist.EXistException; -import org.exist.repo.AutoDeploymentTrigger; -import org.exist.repo.ExistRepository; -import org.exist.security.Account; -import org.exist.storage.BrokerPool; -import org.exist.xmldb.DatabaseInstanceManager; -import org.exist.xmldb.UserManagementService; -import org.expath.pkg.repo.FileSystemStorage; -import org.expath.pkg.repo.Package; -import org.expath.pkg.repo.PackageException; -import org.expath.pkg.repo.UserInteractionStrategy; -import org.expath.pkg.repo.tui.BatchUserInteraction; -import org.xmldb.api.DatabaseManager; -import org.xmldb.api.base.Collection; -import org.xmldb.api.base.Database; -import org.xmldb.api.base.XMLDBException; -import org.xmldb.api.modules.XQueryService; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -/** - * Initial database setup: called from the installer to set the admin password. - */ -public class Setup { - - private final static String DRIVER = "org.exist.xmldb.DatabaseImpl"; - private final static String URI = "xmldb:exist:///db"; - - public static void main(String[] args) { - //TODO: I think this will never happen with the current setup. Class needs a little more cleanup. - if (args.length < 1) { - System.err.println("No password specified. Admin password will be empty."); - return; - } - int offset = 0; - String passwd = null; - if (args[0].startsWith("pass:")) { - passwd = args[0].substring(5); - offset = 1; - } - System.setProperty(AutoDeploymentTrigger.AUTODEPLOY_PROPERTY, "off"); - final XQueryService query = initDb(passwd); -// if (query != null) { -// try { -// installApps(query, args, offset); -// } catch (EXistException e) { -// System.err.println("An error occurred while installing apps: " + e.getMessage()); -// } -// } - shutdown(passwd); - } - - private static void installApps(XQueryService query, String[] args, int offset) throws EXistException { - final File home = getExistHome(); - final ExistRepository repository = getRepository(home); - - final List uris = new ArrayList(); - for (int i = offset; i < args.length; i++) { - final String name = args[i]; - try { - final File xar = findApp(home, name); - if (xar != null) { - System.out.println("Installing app package " + xar.getName()); - final UserInteractionStrategy interact = new BatchUserInteraction(); - final Package pkg = repository.getParentRepo().installPackage(xar, true, interact); - final String pkgName = pkg.getName(); - uris.add(pkgName); - } else { - System.err.println("App package not found: " + name + ". Skipping it."); - } - } catch (final PackageException e) { - System.err.println("Failed to install application package " + name + ": " + e.getMessage()); - } - } - - System.out.println("\n=== Starting the installation process for each application... ==="); - System.out.println("\nPLEASE DO NOT ABORT\n"); - - final String prolog = - "import module namespace repo=\"http://exist-db.org/xquery/repo\" " + - "at \"java:org.exist.xquery.modules.expathrepo.ExpathPackageModule\";\n"; - for (final String uri : uris) { - final StringBuilder xquery = new StringBuilder(prolog); - xquery.append(" repo:deploy(\"" + uri + "\")"); - System.out.print("Installing app package: " + uri + "... "); - try { - query.query(xquery.toString()); - } catch (final XMLDBException e) { - e.printStackTrace(); - System.err.println("An error occurred while deploying application: " + uri + - ". You can install it later using the package repository."); - } - System.out.println("DONE."); - } - - System.out.println("=== App installation completed. ==="); - } - - private static File getExistHome() throws EXistException { - return BrokerPool.getInstance().getConfiguration().getExistHome(); - } - - private static File findApp(File home, String app) { - final File apps = new File(home, "apps"); - System.out.println("Apps directory: " + apps.getAbsolutePath()); - if (apps.canRead() && apps.isDirectory()) { - final File[] files = apps.listFiles(); - for (final File file : files) { - if (file.getName().startsWith(app)) - {return file;} - } - } - return null; - } - - private static ExistRepository getRepository(File home) throws EXistException { - try { - if (home != null){ - final File repo_dir = new File(home, "webapp/WEB-INF/expathrepo"); - // ensure the dir exists - repo_dir.mkdir(); - final FileSystemStorage storage = new FileSystemStorage(repo_dir); - return new ExistRepository(storage); - }else{ - final File repo_dir = new File(System.getProperty("java.io.tmpdir") + "/expathrepo"); - // ensure the dir exists - repo_dir.mkdir(); - final FileSystemStorage storage = new FileSystemStorage(repo_dir); - return new ExistRepository(storage); - } - } - catch ( final PackageException ex ) { - // problem with pkg-repo.jar throwing exception - throw new EXistException("Problem setting expath repository", ex); - } - } - - private static XQueryService initDb(String adminPass) { - System.out.println("--- Starting embedded database instance ---"); - try { - final Class cl = Class.forName(DRIVER); - final Database database = (Database) cl.newInstance(); - database.setProperty("create-database", "true"); - DatabaseManager.registerDatabase(database); - Collection root = DatabaseManager.getCollection(URI, "admin", null); - if (adminPass != null) { - final UserManagementService service = - (UserManagementService) root.getService("UserManagementService", "1.0"); - final Account admin = service.getAccount("admin"); - admin.setPassword(adminPass); - System.out.println("Setting admin user password..."); - service.updateAccount(admin); - root = DatabaseManager.getCollection(URI, "admin", adminPass); - } - final XQueryService query = (XQueryService) root.getService("XQueryService", "1.0"); - return query; - } catch (final Exception e) { - System.err.println("Caught an exception while initializing db: " + e.getMessage()); - e.printStackTrace(); - } - return null; - } - - private static void shutdown(String adminPass) { - System.out.println("--- Initialization complete. Shutdown embedded database instance ---"); - try { - final Collection root = DatabaseManager.getCollection(URI, "admin", adminPass); - final DatabaseInstanceManager manager = (DatabaseInstanceManager) - root.getService("DatabaseInstanceManager", "1.0"); - manager.shutdown(); - } catch (final XMLDBException e) { - System.err.println("Caught an exception while initializing db: " + e.getMessage()); - e.printStackTrace(); - } - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ + +package org.exist.installer; + +import org.exist.EXistException; +import org.exist.repo.AutoDeploymentTrigger; +import org.exist.repo.ExistRepository; +import org.exist.security.Account; +import org.exist.storage.BrokerPool; +import org.exist.xmldb.DatabaseInstanceManager; +import org.exist.xmldb.UserManagementService; +import org.expath.pkg.repo.FileSystemStorage; +import org.expath.pkg.repo.Package; +import org.expath.pkg.repo.PackageException; +import org.expath.pkg.repo.UserInteractionStrategy; +import org.expath.pkg.repo.tui.BatchUserInteraction; +import org.xmldb.api.DatabaseManager; +import org.xmldb.api.base.Collection; +import org.xmldb.api.base.Database; +import org.xmldb.api.base.XMLDBException; +import org.xmldb.api.modules.XQueryService; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + * Initial database setup: called from the installer to set the admin password. + */ +public class Setup { + + private final static String DRIVER = "org.exist.xmldb.DatabaseImpl"; + private final static String URI = "xmldb:exist:///db"; + + public static void main(String[] args) { + //TODO: I think this will never happen with the current setup. Class needs a little more cleanup. + if (args.length < 1) { + System.err.println("No password specified. Admin password will be empty."); + return; + } + int offset = 0; + String passwd = null; + if (args[0].startsWith("pass:")) { + passwd = args[0].substring(5); + offset = 1; + } + System.setProperty(AutoDeploymentTrigger.AUTODEPLOY_PROPERTY, "off"); + final XQueryService query = initDb(passwd); +// if (query != null) { +// try { +// installApps(query, args, offset); +// } catch (EXistException e) { +// System.err.println("An error occurred while installing apps: " + e.getMessage()); +// } +// } + shutdown(passwd); + } + + private static void installApps(XQueryService query, String[] args, int offset) throws EXistException { + final File home = getExistHome(); + final ExistRepository repository = getRepository(home); + + final List uris = new ArrayList(); + for (int i = offset; i < args.length; i++) { + final String name = args[i]; + try { + final File xar = findApp(home, name); + if (xar != null) { + System.out.println("Installing app package " + xar.getName()); + final UserInteractionStrategy interact = new BatchUserInteraction(); + final Package pkg = repository.getParentRepo().installPackage(xar, true, interact); + final String pkgName = pkg.getName(); + uris.add(pkgName); + } else { + System.err.println("App package not found: " + name + ". Skipping it."); + } + } catch (final PackageException e) { + System.err.println("Failed to install application package " + name + ": " + e.getMessage()); + } + } + + System.out.println("\n=== Starting the installation process for each application... ==="); + System.out.println("\nPLEASE DO NOT ABORT\n"); + + final String prolog = + "import module namespace repo=\"http://exist-db.org/xquery/repo\" " + + "at \"java:org.exist.xquery.modules.expathrepo.ExpathPackageModule\";\n"; + for (final String uri : uris) { + final StringBuilder xquery = new StringBuilder(prolog); + xquery.append(" repo:deploy(\"" + uri + "\")"); + System.out.print("Installing app package: " + uri + "... "); + try { + query.query(xquery.toString()); + } catch (final XMLDBException e) { + e.printStackTrace(); + System.err.println("An error occurred while deploying application: " + uri + + ". You can install it later using the package repository."); + } + System.out.println("DONE."); + } + + System.out.println("=== App installation completed. ==="); + } + + private static File getExistHome() throws EXistException { + return BrokerPool.getInstance().getConfiguration().getExistHome(); + } + + private static File findApp(File home, String app) { + final File apps = new File(home, "apps"); + System.out.println("Apps directory: " + apps.getAbsolutePath()); + if (apps.canRead() && apps.isDirectory()) { + final File[] files = apps.listFiles(); + for (final File file : files) { + if (file.getName().startsWith(app)) + {return file;} + } + } + return null; + } + + private static ExistRepository getRepository(File home) throws EXistException { + try { + if (home != null){ + final File repo_dir = new File(home, "webapp/WEB-INF/expathrepo"); + // ensure the dir exists + repo_dir.mkdir(); + final FileSystemStorage storage = new FileSystemStorage(repo_dir); + return new ExistRepository(storage); + }else{ + final File repo_dir = new File(System.getProperty("java.io.tmpdir") + "/expathrepo"); + // ensure the dir exists + repo_dir.mkdir(); + final FileSystemStorage storage = new FileSystemStorage(repo_dir); + return new ExistRepository(storage); + } + } + catch ( final PackageException ex ) { + // problem with pkg-repo.jar throwing exception + throw new EXistException("Problem setting expath repository", ex); + } + } + + private static XQueryService initDb(String adminPass) { + System.out.println("--- Starting embedded database instance ---"); + try { + final Class cl = Class.forName(DRIVER); + final Database database = (Database) cl.newInstance(); + database.setProperty("create-database", "true"); + DatabaseManager.registerDatabase(database); + Collection root = DatabaseManager.getCollection(URI, "admin", null); + if (adminPass != null) { + final UserManagementService service = + (UserManagementService) root.getService("UserManagementService", "1.0"); + final Account admin = service.getAccount("admin"); + admin.setPassword(adminPass); + System.out.println("Setting admin user password..."); + service.updateAccount(admin); + root = DatabaseManager.getCollection(URI, "admin", adminPass); + } + final XQueryService query = (XQueryService) root.getService("XQueryService", "1.0"); + return query; + } catch (final Exception e) { + System.err.println("Caught an exception while initializing db: " + e.getMessage()); + e.printStackTrace(); + } + return null; + } + + private static void shutdown(String adminPass) { + System.out.println("--- Initialization complete. Shutdown embedded database instance ---"); + try { + final Collection root = DatabaseManager.getCollection(URI, "admin", adminPass); + final DatabaseInstanceManager manager = (DatabaseInstanceManager) + root.getService("DatabaseInstanceManager", "1.0"); + manager.shutdown(); + } catch (final XMLDBException e) { + System.err.println("Caught an exception while initializing db: " + e.getMessage()); + e.printStackTrace(); + } + } +} diff --git a/src/org/exist/management/client/JMXClient.java b/src/org/exist/management/client/JMXClient.java index 7c582a22852..608d7d95674 100755 --- a/src/org/exist/management/client/JMXClient.java +++ b/src/org/exist/management/client/JMXClient.java @@ -1,423 +1,423 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.management.client; - -import org.apache.avalon.excalibur.cli.CLArgsParser; -import org.apache.avalon.excalibur.cli.CLOption; -import org.apache.avalon.excalibur.cli.CLOptionDescriptor; -import org.apache.avalon.excalibur.cli.CLUtil; - -import javax.management.Attribute; -import javax.management.AttributeList; -import javax.management.AttributeNotFoundException; -import javax.management.InstanceNotFoundException; -import javax.management.MBeanException; -import javax.management.MBeanServerConnection; -import javax.management.MalformedObjectNameException; -import javax.management.ObjectName; -import javax.management.ReflectionException; -import javax.management.openmbean.CompositeData; -import javax.management.openmbean.TabularData; -import javax.management.remote.JMXConnector; -import javax.management.remote.JMXConnectorFactory; -import javax.management.remote.JMXServiceURL; -import java.io.IOException; -import java.util.Arrays; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - */ -public class JMXClient { - - private MBeanServerConnection connection; - private String instance; - - public JMXClient(String instanceName) { - this.instance = instanceName; - } - - public void connect(String address,int port) throws IOException { - final JMXServiceURL url = - new JMXServiceURL("service:jmx:rmi:///jndi/rmi://"+address+":" + port + "/jmxrmi"); - final Map env = new HashMap(); - final String[] creds = {"guest", "guest"}; - env.put(JMXConnector.CREDENTIALS, creds); - - final JMXConnector jmxc = JMXConnectorFactory.connect(url, env); - connection = jmxc.getMBeanServerConnection(); - echo("Connected to MBean server."); - } - - public void memoryStats() { - try { - final ObjectName name = new ObjectName("java.lang:type=Memory"); - final CompositeData composite = (CompositeData) connection.getAttribute(name, "HeapMemoryUsage"); - if (composite != null) { - echo("\nMEMORY:"); - echo(String.format("Current heap: %,12d k Committed memory: %,12d k", - ((Long)composite.get("used")) / 1024, ((Long)composite.get("committed")) / 1024)); - echo(String.format("Max memory: %,12d k", ((Long)composite.get("max")) / 1024)); - } - } catch (final Exception e) { - error(e); - } - } - - public void instanceStats() { - try { - echo("\nINSTANCE:"); - final ObjectName name = new ObjectName("org.exist.management." + instance + ":type=Database"); - final Long memReserved = (Long) connection.getAttribute(name, "ReservedMem"); - echo(String.format("%25s: %10d k", "Reserved memory", memReserved.longValue() / 1024)); - final Long memCache = (Long) connection.getAttribute(name, "CacheMem"); - echo(String.format("%25s: %10d k", "Cache memory", memCache.longValue() / 1024)); - final Long memCollCache = (Long) connection.getAttribute(name, "CollectionCacheMem"); - echo(String.format("%25s: %10d k", "Collection cache memory", memCollCache.longValue() / 1024)); - - final String cols[] = { "MaxBrokers", "AvailableBrokers", "ActiveBrokers" }; - echo(String.format("\n%17s %17s %17s", cols[0], cols[1], cols[2])); - final AttributeList attrs = connection.getAttributes(name, cols); - final Object values[] = getValues(attrs); - echo(String.format("%17d %17d %17d", values[0], values[1], values[2])); - - final TabularData table = (TabularData) connection.getAttribute(name, "ActiveBrokersMap"); - if (table.size() > 0) { - echo("\nCurrently active threads:"); - } - - for (final Iterator i = table.values().iterator(); i.hasNext(); ) { - final CompositeData data = (CompositeData) i.next(); - echo(String.format("\t%20s: %3d", data.get("owner"), data.get("referenceCount"))); - } - } catch (final Exception e) { - error(e); - } - } - - public void cacheStats() { - try { - ObjectName name = new ObjectName("org.exist.management." + instance + ":type=CacheManager"); - String cols[] = { "MaxTotal", "CurrentSize" }; - AttributeList attrs = connection.getAttributes(name, cols); - Object values[] = getValues(attrs); - echo(String.format("\nCACHE [%8d pages max. / %8d pages allocated]", values[0], values[1])); - - final Set beans = connection.queryNames(new ObjectName("org.exist.management." + instance + ":type=CacheManager.Cache,*"), null); - cols = new String[] {"Type", "FileName", "Size", "Used", "Hits", "Fails"}; - echo(String.format("%10s %20s %10s %10s %10s %10s", cols[0], cols[1], cols[2], cols[3], cols[4], cols[5])); - for (final Iterator i = beans.iterator(); i.hasNext();) { - name = i.next(); - attrs = connection.getAttributes(name, cols); - values = getValues(attrs); - echo(String.format("%10s %20s %,10d %,10d %,10d %,10d", values[0], values[1], values[2], values[3], values[4], values[5])); - } - - echo(""); - name = new ObjectName("org.exist.management." + instance + ":type=CollectionCacheManager"); - cols = new String[] { "MaxTotal", "CurrentSize" }; - attrs = connection.getAttributes(name, cols); - values = getValues(attrs); - echo(String.format("Collection Cache: %10d k max / %10d k allocated", - ((Long)values[0] / 1024), ((Long)values[1] / 1024))); - } catch (final Exception e) { - error(e); - } - } - - public void lockTable() { - echo("\nList of threads currently waiting for a lock:"); - echo("-----------------------------------------------"); - try { - final TabularData table = (TabularData) connection.getAttribute(new ObjectName("org.exist.management:type=LockManager"), "WaitingThreads"); - for (final Iterator i = table.values().iterator(); i.hasNext(); ) { - final CompositeData data = (CompositeData) i.next(); - echo("Thread " + data.get("waitingThread")); - echo(String.format("%20s: %s", "Lock type", data.get("lockType"))); - echo(String.format("%20s: %s", "Lock mode", data.get("lockMode"))); - echo(String.format("%20s: %s", "Lock id", data.get("id"))); - echo(String.format("%20s: %s", "Held by", Arrays.toString((String[]) data.get("owner")))); - final String[] readers = (String[]) data.get("waitingForRead"); - if (readers.length > 0) { - echo(String.format("%20s: %s", "Wait for read", Arrays.toString(readers))); - } - final String[] writers = (String[]) data.get("waitingForWrite"); - if (writers.length > 0) { - echo(String.format("%20s: %s", "Wait for write", Arrays.toString(writers))); - } - } - } catch (final MBeanException e) { - error(e); - } catch (final AttributeNotFoundException e) { - error(e); - } catch (final InstanceNotFoundException e) { - error(e); - } catch (final ReflectionException e) { - error(e); - } catch (final IOException e) { - error(e); - } catch (final MalformedObjectNameException e) { - error(e); - } - } - - public void sanityReport() { - echo("\nSanity report"); - echo("-----------------------------------------------"); - try { - final ObjectName name = new ObjectName("org.exist.management." + instance + ".tasks:type=SanityReport"); - final String status = (String) connection.getAttribute(name, "Status"); - final Date lastCheckStart = (Date) connection.getAttribute(name, "LastCheckStart"); - final Date lastCheckEnd = (Date) connection.getAttribute(name, "LastCheckEnd"); - echo(String.format("%22s: %s", "Status", status)); - echo(String.format("%22s: %s", "Last check start", lastCheckStart)); - echo(String.format("%22s: %s", "Last check end", lastCheckEnd)); - if (lastCheckStart != null && lastCheckEnd != null) - {echo(String.format("%22s: %dms", "Check took", (lastCheckEnd.getTime() - lastCheckStart.getTime())));} - - final TabularData table = (TabularData) - connection.getAttribute(name, "Errors"); - for (final Iterator i = table.values().iterator(); i.hasNext(); ) { - final CompositeData data = (CompositeData) i.next(); - echo(String.format("%22s: %s", "Error code", data.get("errcode"))); - echo(String.format("%22s: %s", "Description", data.get("description"))); - } - } catch (final MBeanException e) { - error(e); - } catch (final AttributeNotFoundException e) { - error(e); - } catch (final InstanceNotFoundException e) { - error(e); - } catch (final ReflectionException e) { - error(e); - } catch (final IOException e) { - error(e); - } catch (final MalformedObjectNameException e) { - error(e); - } - } - - public void jobReport() { - echo("\nRunning jobs report"); - echo("-----------------------------------------------"); - try { - final ObjectName name = new ObjectName("org.exist.management." + instance + ":type=ProcessReport"); - - TabularData table = (TabularData) - connection.getAttribute(name, "RunningJobs"); - String[] cols = new String[] { "ID", "Action", "Info" }; - echo(String.format("%15s %30s %30s", cols[0], cols[1], cols[2])); - for (final Iterator i = table.values().iterator(); i.hasNext(); ) { - final CompositeData data = (CompositeData) i.next(); - echo(String.format("%15s %30s %30s", data.get("id"), data.get("action"), data.get("info"))); - } - - echo("\nRunning queries"); - echo("-----------------------------------------------"); - table = (TabularData) - connection.getAttribute(name, "RunningQueries"); - cols = new String[] { "ID", "Type", "Key", "Terminating" }; - echo(String.format("%10s %10s %30s %s", cols[0], cols[1], cols[2], cols[3])); - for (final Iterator i = table.values().iterator(); i.hasNext(); ) { - final CompositeData data = (CompositeData) i.next(); - echo(String.format("%15s %15s %30s %6s", data.get("id"), data.get("sourceType"), data.get("sourceKey"), data.get("terminating"))); - } - } catch (final MBeanException e) { - error(e); - } catch (final AttributeNotFoundException e) { - error(e); - } catch (final InstanceNotFoundException e) { - error(e); - } catch (final ReflectionException e) { - error(e); - } catch (final IOException e) { - error(e); - } catch (final MalformedObjectNameException e) { - error(e); - } - } - - private Object[] getValues(AttributeList attribs) { - final Object[] v = new Object[attribs.size()]; - for (int i = 0; i < attribs.size(); i++) { - v[i] = ((Attribute)attribs.get(i)).getValue(); - } - return v; - } - - private void echo(String msg) { - System.out.println(msg); - } - - private void error(Exception e) { - System.err.println("ERROR: " + e.getMessage()); - e.printStackTrace(); - } - - private final static int HELP_OPT = 'h'; - private final static int CACHE_OPT = 'c'; - private final static int DB_OPT = 'd'; - private final static int WAIT_OPT = 'w'; - private final static int LOCK_OPT = 'l'; - private final static int MEMORY_OPT = 'm'; - private final static int PORT_OPT = 'p'; - private final static int INSTANCE_OPT = 'i'; - private final static int ADDRESS_OPT = 'a'; - private final static int SANITY_OPT = 's'; - private final static int JOBS_OPT = 'j'; - - private final static CLOptionDescriptor OPTIONS[] = new CLOptionDescriptor[] { - new CLOptionDescriptor( "help", CLOptionDescriptor.ARGUMENT_DISALLOWED, - HELP_OPT, "print help on command line options and exit." ), - new CLOptionDescriptor( "cache", CLOptionDescriptor.ARGUMENT_DISALLOWED, - CACHE_OPT, "displays server statistics on cache and memory usage." ), - new CLOptionDescriptor( "db", CLOptionDescriptor.ARGUMENT_DISALLOWED, - DB_OPT, "display general info about the db instance." ), - new CLOptionDescriptor( "wait", CLOptionDescriptor.ARGUMENT_REQUIRED, - WAIT_OPT, "while displaying server statistics: keep retrieving statistics, but wait the " + - "specified number of seconds between calls." ), - new CLOptionDescriptor( "locks", CLOptionDescriptor.ARGUMENT_DISALLOWED, - LOCK_OPT, "lock manager: display locking information on all threads currently waiting for a lock on a resource " + - "or collection. Useful to debug deadlocks. During normal operation, the list will usually be empty (means: no " + - "blocked threads)." ), - new CLOptionDescriptor( "memory", CLOptionDescriptor.ARGUMENT_DISALLOWED, - MEMORY_OPT, "display info on free and total memory. Can be combined with other parameters." ), - new CLOptionDescriptor( "port", CLOptionDescriptor.ARGUMENT_REQUIRED, - PORT_OPT, "RMI port of the server"), - new CLOptionDescriptor( "address", CLOptionDescriptor.ARGUMENT_REQUIRED, - ADDRESS_OPT, "RMI address of the server"), - new CLOptionDescriptor( "instance", CLOptionDescriptor.ARGUMENT_REQUIRED, - INSTANCE_OPT, "the ID of the database instance to connect to"), - new CLOptionDescriptor( "report", CLOptionDescriptor.ARGUMENT_DISALLOWED, - SANITY_OPT, "retrieve sanity check report from the db"), - new CLOptionDescriptor( "jobs", CLOptionDescriptor.ARGUMENT_DISALLOWED, - JOBS_OPT, "list currently running jobs") - }; - - private final static int MODE_STATS = 0; - private final static int MODE_LOCKS = 1; - - @SuppressWarnings("unchecked") - public static void main(String[] args) { - final CLArgsParser optParser = new CLArgsParser( args, OPTIONS ); - if(optParser.getErrorString() != null) { - System.err.println( "ERROR: " + optParser.getErrorString()); - return; - } - String dbInstance = "exist"; - long waitTime = 0; - final List opts = optParser.getArguments(); - int mode = -1; - int port = 1099; - String address = "localhost"; - boolean displayMem = false; - boolean displayInstance = false; - boolean displayReport = false; - boolean jobReport = false; - for(final CLOption option : opts) { - switch(option.getId()) { - case HELP_OPT : - System.out.println(CLUtil.describeOptions(OPTIONS).toString()); - return; - case WAIT_OPT : - try { - waitTime = Integer.parseInt( option.getArgument() ) * 1000; - } catch( final NumberFormatException e ) { - System.err.println("option -w|--wait requires a numeric argument"); - return; - } - break; - case CACHE_OPT: - mode = MODE_STATS; - break; - case LOCK_OPT : - mode = MODE_LOCKS; - break; - case PORT_OPT : - try { - port = Integer.parseInt(option.getArgument()); - } catch (final NumberFormatException e) { - System.err.println("option -p|--port requires a numeric argument"); - return; - } - break; - case ADDRESS_OPT : - try { - address = option.getArgument(); - } catch (final NumberFormatException e) { - System.err.println("option -a|--address requires a numeric argument"); - return; - } - break; - case MEMORY_OPT : - displayMem = true; - break; - case DB_OPT : - displayInstance = true; - break; - case INSTANCE_OPT : - dbInstance = option.getArgument(); - break; - case SANITY_OPT : - displayReport = true; - break; - case JOBS_OPT : - jobReport = true; - } - } - try { - final JMXClient stats = new JMXClient(dbInstance); - stats.connect(address,port); - stats.memoryStats(); - while (true) { - switch (mode) { - case MODE_STATS : - stats.cacheStats(); - break; - case MODE_LOCKS : - stats.lockTable(); - break; - } - if (displayInstance) {stats.instanceStats();} - if (displayMem) {stats.memoryStats();} - if (displayReport) {stats.sanityReport();} - if (jobReport) {stats.jobReport();} - if (waitTime > 0) { - synchronized (stats) { - try { - stats.wait(waitTime); - } catch (final InterruptedException e) { - System.err.println("INTERRUPTED: " + e.getMessage()); - } - } - } else - {return;} - } - } catch (final IOException e) { - e.printStackTrace(); - } - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.management.client; + +import org.apache.avalon.excalibur.cli.CLArgsParser; +import org.apache.avalon.excalibur.cli.CLOption; +import org.apache.avalon.excalibur.cli.CLOptionDescriptor; +import org.apache.avalon.excalibur.cli.CLUtil; + +import javax.management.Attribute; +import javax.management.AttributeList; +import javax.management.AttributeNotFoundException; +import javax.management.InstanceNotFoundException; +import javax.management.MBeanException; +import javax.management.MBeanServerConnection; +import javax.management.MalformedObjectNameException; +import javax.management.ObjectName; +import javax.management.ReflectionException; +import javax.management.openmbean.CompositeData; +import javax.management.openmbean.TabularData; +import javax.management.remote.JMXConnector; +import javax.management.remote.JMXConnectorFactory; +import javax.management.remote.JMXServiceURL; +import java.io.IOException; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + */ +public class JMXClient { + + private MBeanServerConnection connection; + private String instance; + + public JMXClient(String instanceName) { + this.instance = instanceName; + } + + public void connect(String address,int port) throws IOException { + final JMXServiceURL url = + new JMXServiceURL("service:jmx:rmi:///jndi/rmi://"+address+":" + port + "/jmxrmi"); + final Map env = new HashMap(); + final String[] creds = {"guest", "guest"}; + env.put(JMXConnector.CREDENTIALS, creds); + + final JMXConnector jmxc = JMXConnectorFactory.connect(url, env); + connection = jmxc.getMBeanServerConnection(); + echo("Connected to MBean server."); + } + + public void memoryStats() { + try { + final ObjectName name = new ObjectName("java.lang:type=Memory"); + final CompositeData composite = (CompositeData) connection.getAttribute(name, "HeapMemoryUsage"); + if (composite != null) { + echo("\nMEMORY:"); + echo(String.format("Current heap: %,12d k Committed memory: %,12d k", + ((Long)composite.get("used")) / 1024, ((Long)composite.get("committed")) / 1024)); + echo(String.format("Max memory: %,12d k", ((Long)composite.get("max")) / 1024)); + } + } catch (final Exception e) { + error(e); + } + } + + public void instanceStats() { + try { + echo("\nINSTANCE:"); + final ObjectName name = new ObjectName("org.exist.management." + instance + ":type=Database"); + final Long memReserved = (Long) connection.getAttribute(name, "ReservedMem"); + echo(String.format("%25s: %10d k", "Reserved memory", memReserved.longValue() / 1024)); + final Long memCache = (Long) connection.getAttribute(name, "CacheMem"); + echo(String.format("%25s: %10d k", "Cache memory", memCache.longValue() / 1024)); + final Long memCollCache = (Long) connection.getAttribute(name, "CollectionCacheMem"); + echo(String.format("%25s: %10d k", "Collection cache memory", memCollCache.longValue() / 1024)); + + final String cols[] = { "MaxBrokers", "AvailableBrokers", "ActiveBrokers" }; + echo(String.format("\n%17s %17s %17s", cols[0], cols[1], cols[2])); + final AttributeList attrs = connection.getAttributes(name, cols); + final Object values[] = getValues(attrs); + echo(String.format("%17d %17d %17d", values[0], values[1], values[2])); + + final TabularData table = (TabularData) connection.getAttribute(name, "ActiveBrokersMap"); + if (table.size() > 0) { + echo("\nCurrently active threads:"); + } + + for (final Iterator i = table.values().iterator(); i.hasNext(); ) { + final CompositeData data = (CompositeData) i.next(); + echo(String.format("\t%20s: %3d", data.get("owner"), data.get("referenceCount"))); + } + } catch (final Exception e) { + error(e); + } + } + + public void cacheStats() { + try { + ObjectName name = new ObjectName("org.exist.management." + instance + ":type=CacheManager"); + String cols[] = { "MaxTotal", "CurrentSize" }; + AttributeList attrs = connection.getAttributes(name, cols); + Object values[] = getValues(attrs); + echo(String.format("\nCACHE [%8d pages max. / %8d pages allocated]", values[0], values[1])); + + final Set beans = connection.queryNames(new ObjectName("org.exist.management." + instance + ":type=CacheManager.Cache,*"), null); + cols = new String[] {"Type", "FileName", "Size", "Used", "Hits", "Fails"}; + echo(String.format("%10s %20s %10s %10s %10s %10s", cols[0], cols[1], cols[2], cols[3], cols[4], cols[5])); + for (final Iterator i = beans.iterator(); i.hasNext();) { + name = i.next(); + attrs = connection.getAttributes(name, cols); + values = getValues(attrs); + echo(String.format("%10s %20s %,10d %,10d %,10d %,10d", values[0], values[1], values[2], values[3], values[4], values[5])); + } + + echo(""); + name = new ObjectName("org.exist.management." + instance + ":type=CollectionCacheManager"); + cols = new String[] { "MaxTotal", "CurrentSize" }; + attrs = connection.getAttributes(name, cols); + values = getValues(attrs); + echo(String.format("Collection Cache: %10d k max / %10d k allocated", + ((Long)values[0] / 1024), ((Long)values[1] / 1024))); + } catch (final Exception e) { + error(e); + } + } + + public void lockTable() { + echo("\nList of threads currently waiting for a lock:"); + echo("-----------------------------------------------"); + try { + final TabularData table = (TabularData) connection.getAttribute(new ObjectName("org.exist.management:type=LockManager"), "WaitingThreads"); + for (final Iterator i = table.values().iterator(); i.hasNext(); ) { + final CompositeData data = (CompositeData) i.next(); + echo("Thread " + data.get("waitingThread")); + echo(String.format("%20s: %s", "Lock type", data.get("lockType"))); + echo(String.format("%20s: %s", "Lock mode", data.get("lockMode"))); + echo(String.format("%20s: %s", "Lock id", data.get("id"))); + echo(String.format("%20s: %s", "Held by", Arrays.toString((String[]) data.get("owner")))); + final String[] readers = (String[]) data.get("waitingForRead"); + if (readers.length > 0) { + echo(String.format("%20s: %s", "Wait for read", Arrays.toString(readers))); + } + final String[] writers = (String[]) data.get("waitingForWrite"); + if (writers.length > 0) { + echo(String.format("%20s: %s", "Wait for write", Arrays.toString(writers))); + } + } + } catch (final MBeanException e) { + error(e); + } catch (final AttributeNotFoundException e) { + error(e); + } catch (final InstanceNotFoundException e) { + error(e); + } catch (final ReflectionException e) { + error(e); + } catch (final IOException e) { + error(e); + } catch (final MalformedObjectNameException e) { + error(e); + } + } + + public void sanityReport() { + echo("\nSanity report"); + echo("-----------------------------------------------"); + try { + final ObjectName name = new ObjectName("org.exist.management." + instance + ".tasks:type=SanityReport"); + final String status = (String) connection.getAttribute(name, "Status"); + final Date lastCheckStart = (Date) connection.getAttribute(name, "LastCheckStart"); + final Date lastCheckEnd = (Date) connection.getAttribute(name, "LastCheckEnd"); + echo(String.format("%22s: %s", "Status", status)); + echo(String.format("%22s: %s", "Last check start", lastCheckStart)); + echo(String.format("%22s: %s", "Last check end", lastCheckEnd)); + if (lastCheckStart != null && lastCheckEnd != null) + {echo(String.format("%22s: %dms", "Check took", (lastCheckEnd.getTime() - lastCheckStart.getTime())));} + + final TabularData table = (TabularData) + connection.getAttribute(name, "Errors"); + for (final Iterator i = table.values().iterator(); i.hasNext(); ) { + final CompositeData data = (CompositeData) i.next(); + echo(String.format("%22s: %s", "Error code", data.get("errcode"))); + echo(String.format("%22s: %s", "Description", data.get("description"))); + } + } catch (final MBeanException e) { + error(e); + } catch (final AttributeNotFoundException e) { + error(e); + } catch (final InstanceNotFoundException e) { + error(e); + } catch (final ReflectionException e) { + error(e); + } catch (final IOException e) { + error(e); + } catch (final MalformedObjectNameException e) { + error(e); + } + } + + public void jobReport() { + echo("\nRunning jobs report"); + echo("-----------------------------------------------"); + try { + final ObjectName name = new ObjectName("org.exist.management." + instance + ":type=ProcessReport"); + + TabularData table = (TabularData) + connection.getAttribute(name, "RunningJobs"); + String[] cols = new String[] { "ID", "Action", "Info" }; + echo(String.format("%15s %30s %30s", cols[0], cols[1], cols[2])); + for (final Iterator i = table.values().iterator(); i.hasNext(); ) { + final CompositeData data = (CompositeData) i.next(); + echo(String.format("%15s %30s %30s", data.get("id"), data.get("action"), data.get("info"))); + } + + echo("\nRunning queries"); + echo("-----------------------------------------------"); + table = (TabularData) + connection.getAttribute(name, "RunningQueries"); + cols = new String[] { "ID", "Type", "Key", "Terminating" }; + echo(String.format("%10s %10s %30s %s", cols[0], cols[1], cols[2], cols[3])); + for (final Iterator i = table.values().iterator(); i.hasNext(); ) { + final CompositeData data = (CompositeData) i.next(); + echo(String.format("%15s %15s %30s %6s", data.get("id"), data.get("sourceType"), data.get("sourceKey"), data.get("terminating"))); + } + } catch (final MBeanException e) { + error(e); + } catch (final AttributeNotFoundException e) { + error(e); + } catch (final InstanceNotFoundException e) { + error(e); + } catch (final ReflectionException e) { + error(e); + } catch (final IOException e) { + error(e); + } catch (final MalformedObjectNameException e) { + error(e); + } + } + + private Object[] getValues(AttributeList attribs) { + final Object[] v = new Object[attribs.size()]; + for (int i = 0; i < attribs.size(); i++) { + v[i] = ((Attribute)attribs.get(i)).getValue(); + } + return v; + } + + private void echo(String msg) { + System.out.println(msg); + } + + private void error(Exception e) { + System.err.println("ERROR: " + e.getMessage()); + e.printStackTrace(); + } + + private final static int HELP_OPT = 'h'; + private final static int CACHE_OPT = 'c'; + private final static int DB_OPT = 'd'; + private final static int WAIT_OPT = 'w'; + private final static int LOCK_OPT = 'l'; + private final static int MEMORY_OPT = 'm'; + private final static int PORT_OPT = 'p'; + private final static int INSTANCE_OPT = 'i'; + private final static int ADDRESS_OPT = 'a'; + private final static int SANITY_OPT = 's'; + private final static int JOBS_OPT = 'j'; + + private final static CLOptionDescriptor OPTIONS[] = new CLOptionDescriptor[] { + new CLOptionDescriptor( "help", CLOptionDescriptor.ARGUMENT_DISALLOWED, + HELP_OPT, "print help on command line options and exit." ), + new CLOptionDescriptor( "cache", CLOptionDescriptor.ARGUMENT_DISALLOWED, + CACHE_OPT, "displays server statistics on cache and memory usage." ), + new CLOptionDescriptor( "db", CLOptionDescriptor.ARGUMENT_DISALLOWED, + DB_OPT, "display general info about the db instance." ), + new CLOptionDescriptor( "wait", CLOptionDescriptor.ARGUMENT_REQUIRED, + WAIT_OPT, "while displaying server statistics: keep retrieving statistics, but wait the " + + "specified number of seconds between calls." ), + new CLOptionDescriptor( "locks", CLOptionDescriptor.ARGUMENT_DISALLOWED, + LOCK_OPT, "lock manager: display locking information on all threads currently waiting for a lock on a resource " + + "or collection. Useful to debug deadlocks. During normal operation, the list will usually be empty (means: no " + + "blocked threads)." ), + new CLOptionDescriptor( "memory", CLOptionDescriptor.ARGUMENT_DISALLOWED, + MEMORY_OPT, "display info on free and total memory. Can be combined with other parameters." ), + new CLOptionDescriptor( "port", CLOptionDescriptor.ARGUMENT_REQUIRED, + PORT_OPT, "RMI port of the server"), + new CLOptionDescriptor( "address", CLOptionDescriptor.ARGUMENT_REQUIRED, + ADDRESS_OPT, "RMI address of the server"), + new CLOptionDescriptor( "instance", CLOptionDescriptor.ARGUMENT_REQUIRED, + INSTANCE_OPT, "the ID of the database instance to connect to"), + new CLOptionDescriptor( "report", CLOptionDescriptor.ARGUMENT_DISALLOWED, + SANITY_OPT, "retrieve sanity check report from the db"), + new CLOptionDescriptor( "jobs", CLOptionDescriptor.ARGUMENT_DISALLOWED, + JOBS_OPT, "list currently running jobs") + }; + + private final static int MODE_STATS = 0; + private final static int MODE_LOCKS = 1; + + @SuppressWarnings("unchecked") + public static void main(String[] args) { + final CLArgsParser optParser = new CLArgsParser( args, OPTIONS ); + if(optParser.getErrorString() != null) { + System.err.println( "ERROR: " + optParser.getErrorString()); + return; + } + String dbInstance = "exist"; + long waitTime = 0; + final List opts = optParser.getArguments(); + int mode = -1; + int port = 1099; + String address = "localhost"; + boolean displayMem = false; + boolean displayInstance = false; + boolean displayReport = false; + boolean jobReport = false; + for(final CLOption option : opts) { + switch(option.getId()) { + case HELP_OPT : + System.out.println(CLUtil.describeOptions(OPTIONS).toString()); + return; + case WAIT_OPT : + try { + waitTime = Integer.parseInt( option.getArgument() ) * 1000; + } catch( final NumberFormatException e ) { + System.err.println("option -w|--wait requires a numeric argument"); + return; + } + break; + case CACHE_OPT: + mode = MODE_STATS; + break; + case LOCK_OPT : + mode = MODE_LOCKS; + break; + case PORT_OPT : + try { + port = Integer.parseInt(option.getArgument()); + } catch (final NumberFormatException e) { + System.err.println("option -p|--port requires a numeric argument"); + return; + } + break; + case ADDRESS_OPT : + try { + address = option.getArgument(); + } catch (final NumberFormatException e) { + System.err.println("option -a|--address requires a numeric argument"); + return; + } + break; + case MEMORY_OPT : + displayMem = true; + break; + case DB_OPT : + displayInstance = true; + break; + case INSTANCE_OPT : + dbInstance = option.getArgument(); + break; + case SANITY_OPT : + displayReport = true; + break; + case JOBS_OPT : + jobReport = true; + } + } + try { + final JMXClient stats = new JMXClient(dbInstance); + stats.connect(address,port); + stats.memoryStats(); + while (true) { + switch (mode) { + case MODE_STATS : + stats.cacheStats(); + break; + case MODE_LOCKS : + stats.lockTable(); + break; + } + if (displayInstance) {stats.instanceStats();} + if (displayMem) {stats.memoryStats();} + if (displayReport) {stats.sanityReport();} + if (jobReport) {stats.jobReport();} + if (waitTime > 0) { + synchronized (stats) { + try { + stats.wait(waitTime); + } catch (final InterruptedException e) { + System.err.println("INTERRUPTED: " + e.getMessage()); + } + } + } else + {return;} + } + } catch (final IOException e) { + e.printStackTrace(); + } + } +} diff --git a/src/org/exist/protocolhandler/eXistURLStreamHandlerFactory.java b/src/org/exist/protocolhandler/eXistURLStreamHandlerFactory.java index dc9f68fc878..bb3543e185a 100644 --- a/src/org/exist/protocolhandler/eXistURLStreamHandlerFactory.java +++ b/src/org/exist/protocolhandler/eXistURLStreamHandlerFactory.java @@ -1,101 +1,101 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id: eXistURLStreamHandlerFactory.java 189 2007-03-30 15:02:18Z dizzzz $ - */ - -package org.exist.protocolhandler; - -import java.net.URL; -import java.net.URLStreamHandler; -import java.net.URLStreamHandlerFactory; - -import org.apache.log4j.Logger; -import org.exist.protocolhandler.protocols.xmldb.Handler; - -/** - * Factory class for creating custom stream handlers for the 'xmldb' protocol. - * - * @see java.net.URLStreamHandler - * @see java.net.URLStreamHandlerFactory - * - * @author Dannes Wessels - */ -public class eXistURLStreamHandlerFactory implements URLStreamHandlerFactory { - - private final static Logger LOG = Logger.getLogger(eXistURLStreamHandlerFactory.class); - - public final static String JAVA_PROTOCOL_HANDLER_PKGS="java.protocol.handler.pkgs"; - public final static String EXIST_PROTOCOL_HANDLER="org.exist.protocolhandler.protocols"; - - public static void init(){ - - boolean initOK=false; - try { - URL.setURLStreamHandlerFactory(new eXistURLStreamHandlerFactory()); - initOK=true; - LOG.info("Succesfully registered eXistURLStreamHandlerFactory."); - } catch (final Error ex){ - LOG.warn("The JVM has already an URLStreamHandlerFactory registered, skipping..."); - } - - if(!initOK){ - String currentSystemProperty = System.getProperty(JAVA_PROTOCOL_HANDLER_PKGS); - - if(currentSystemProperty==null){ - // Nothing setup yet - LOG.info("Setting " + JAVA_PROTOCOL_HANDLER_PKGS + " to " - + EXIST_PROTOCOL_HANDLER); - System.setProperty( JAVA_PROTOCOL_HANDLER_PKGS, EXIST_PROTOCOL_HANDLER ); - - } else { - // java.protocol.handler.pkgs is already setup, preserving settings - if(currentSystemProperty.indexOf(EXIST_PROTOCOL_HANDLER)==-1){ - // eXist handler is not setup yet - currentSystemProperty=currentSystemProperty+"|"+EXIST_PROTOCOL_HANDLER; - LOG.info("Setting " + JAVA_PROTOCOL_HANDLER_PKGS + " to " + currentSystemProperty); - System.setProperty( JAVA_PROTOCOL_HANDLER_PKGS, currentSystemProperty ); - } else { - LOG.info( "System property " + JAVA_PROTOCOL_HANDLER_PKGS + " has not been updated."); - } - } - } - } - - /** - * Create Custom URL streamhandler for the xmldb protocol. - * - * @param protocol Protocol - * @return Custom Xmldb stream handler. - */ - public URLStreamHandler createURLStreamHandler(String protocol) { - - URLStreamHandler handler=null; - - if("xmldb".equals(protocol)){ - LOG.debug(protocol); - handler=new Handler(); - } else { - //LOG.error("Protocol should be xmldb, not "+protocol); - } - - return handler; - } - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id: eXistURLStreamHandlerFactory.java 189 2007-03-30 15:02:18Z dizzzz $ + */ + +package org.exist.protocolhandler; + +import java.net.URL; +import java.net.URLStreamHandler; +import java.net.URLStreamHandlerFactory; + +import org.apache.log4j.Logger; +import org.exist.protocolhandler.protocols.xmldb.Handler; + +/** + * Factory class for creating custom stream handlers for the 'xmldb' protocol. + * + * @see java.net.URLStreamHandler + * @see java.net.URLStreamHandlerFactory + * + * @author Dannes Wessels + */ +public class eXistURLStreamHandlerFactory implements URLStreamHandlerFactory { + + private final static Logger LOG = Logger.getLogger(eXistURLStreamHandlerFactory.class); + + public final static String JAVA_PROTOCOL_HANDLER_PKGS="java.protocol.handler.pkgs"; + public final static String EXIST_PROTOCOL_HANDLER="org.exist.protocolhandler.protocols"; + + public static void init(){ + + boolean initOK=false; + try { + URL.setURLStreamHandlerFactory(new eXistURLStreamHandlerFactory()); + initOK=true; + LOG.info("Succesfully registered eXistURLStreamHandlerFactory."); + } catch (final Error ex){ + LOG.warn("The JVM has already an URLStreamHandlerFactory registered, skipping..."); + } + + if(!initOK){ + String currentSystemProperty = System.getProperty(JAVA_PROTOCOL_HANDLER_PKGS); + + if(currentSystemProperty==null){ + // Nothing setup yet + LOG.info("Setting " + JAVA_PROTOCOL_HANDLER_PKGS + " to " + + EXIST_PROTOCOL_HANDLER); + System.setProperty( JAVA_PROTOCOL_HANDLER_PKGS, EXIST_PROTOCOL_HANDLER ); + + } else { + // java.protocol.handler.pkgs is already setup, preserving settings + if(currentSystemProperty.indexOf(EXIST_PROTOCOL_HANDLER)==-1){ + // eXist handler is not setup yet + currentSystemProperty=currentSystemProperty+"|"+EXIST_PROTOCOL_HANDLER; + LOG.info("Setting " + JAVA_PROTOCOL_HANDLER_PKGS + " to " + currentSystemProperty); + System.setProperty( JAVA_PROTOCOL_HANDLER_PKGS, currentSystemProperty ); + } else { + LOG.info( "System property " + JAVA_PROTOCOL_HANDLER_PKGS + " has not been updated."); + } + } + } + } + + /** + * Create Custom URL streamhandler for the xmldb protocol. + * + * @param protocol Protocol + * @return Custom Xmldb stream handler. + */ + public URLStreamHandler createURLStreamHandler(String protocol) { + + URLStreamHandler handler=null; + + if("xmldb".equals(protocol)){ + LOG.debug(protocol); + handler=new Handler(); + } else { + //LOG.error("Protocol should be xmldb, not "+protocol); + } + + return handler; + } + +} diff --git a/src/org/exist/protocolhandler/embedded/EmbeddedDownload.java b/src/org/exist/protocolhandler/embedded/EmbeddedDownload.java index 59bac68c2f0..7e1c79b004e 100644 --- a/src/org/exist/protocolhandler/embedded/EmbeddedDownload.java +++ b/src/org/exist/protocolhandler/embedded/EmbeddedDownload.java @@ -1,164 +1,164 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id: EmbeddedDownload.java 223 2007-04-21 22:13:05Z dizzzz $ - */ - -package org.exist.protocolhandler.embedded; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.Writer; - -import org.apache.log4j.Logger; - -import org.exist.collections.Collection; -import org.exist.dom.BinaryDocument; -import org.exist.dom.DocumentImpl; -import org.exist.protocolhandler.xmldb.XmldbURL; -import org.exist.security.Subject; -import org.exist.storage.BrokerPool; -import org.exist.storage.DBBroker; -import org.exist.storage.lock.Lock; -import org.exist.storage.serializers.EXistOutputKeys; -import org.exist.storage.serializers.Serializer; -import org.exist.xmldb.XmldbURI; - -/** - * Read document from an embedded database and write the data into an - * output stream. - * - * @author Dannes Wessels - */ -public class EmbeddedDownload { - - private final static Logger LOG = Logger.getLogger(EmbeddedDownload.class); - - private BrokerPool pool; - - /** - * Set brokerpool for in database resolve of resource. - * @param brokerPool - */ - public void setBrokerPool(BrokerPool brokerPool) { - this.pool = brokerPool; - } - - /** - * Write document referred by URL to an (output)stream. - * - * @param xmldbURL Document location in database. - * @param os Stream to which the document is written. - * @throws IOException - */ - public void stream(XmldbURL xmldbURL, OutputStream os) throws IOException { - stream(xmldbURL, os, null); - } - - /** - * Write document referred by URL to an (output)stream as specified user. - * - * @param user Effective user for operation. If NULL the user information - * is distilled from the URL. - * @param xmldbURL Document location in database. - * @param os Stream to which the document is written. - * @throws IOException - */ - public void stream(XmldbURL xmldbURL, OutputStream os, Subject user) throws IOException { - LOG.debug("Begin document download"); - - DocumentImpl resource = null; - Collection collection = null; - DBBroker broker = null; - - try { - final XmldbURI path = XmldbURI.create(xmldbURL.getPath()); - - if(pool==null){ - pool = BrokerPool.getInstance(); - } - - if(user==null){ - if(xmldbURL.hasUserInfo()){ - user=EmbeddedUser.authenticate(xmldbURL, pool); - if(user==null){ - throw new IOException("Unauthorized user "+xmldbURL.getUsername()); - } - - } else { - user=EmbeddedUser.getUserGuest(pool); - } - } - broker = pool.get(user); - - resource = broker.getXMLResource(path, Lock.READ_LOCK); - - if(resource == null) { - // Test for collection - collection = broker.openCollection(path, Lock.READ_LOCK); - if(collection == null){ - // No collection, no document - throw new IOException("Resource "+xmldbURL.getPath()+" not found."); - - } else { - // Collection - throw new IOException("Resource "+xmldbURL.getPath()+" is a collection."); - } - - } else { - if(resource.getResourceType() == DocumentImpl.XML_FILE) { - final Serializer serializer = broker.getSerializer(); - serializer.reset(); - - // Preserve doctype - serializer.setProperty(EXistOutputKeys.OUTPUT_DOCTYPE, "yes"); - final Writer w = new OutputStreamWriter(os,"UTF-8"); - serializer.serialize(resource,w); - w.close(); - - } else { - broker.readBinaryResource((BinaryDocument) resource, os); - } - } - } catch (final IOException ex) { - //ex.printStackTrace(); - LOG.error(ex); - throw ex; - - } catch (final Exception ex) { - //ex.printStackTrace(); - LOG.error(ex); - throw new IOException(ex.getMessage(), ex); - - } finally { - if(resource != null){ - resource.getUpdateLock().release(Lock.READ_LOCK); - } - - if(collection != null){ - collection.release(Lock.READ_LOCK); - } - - pool.release(broker); - - LOG.debug("End document download"); - } - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id: EmbeddedDownload.java 223 2007-04-21 22:13:05Z dizzzz $ + */ + +package org.exist.protocolhandler.embedded; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.Writer; + +import org.apache.log4j.Logger; + +import org.exist.collections.Collection; +import org.exist.dom.BinaryDocument; +import org.exist.dom.DocumentImpl; +import org.exist.protocolhandler.xmldb.XmldbURL; +import org.exist.security.Subject; +import org.exist.storage.BrokerPool; +import org.exist.storage.DBBroker; +import org.exist.storage.lock.Lock; +import org.exist.storage.serializers.EXistOutputKeys; +import org.exist.storage.serializers.Serializer; +import org.exist.xmldb.XmldbURI; + +/** + * Read document from an embedded database and write the data into an + * output stream. + * + * @author Dannes Wessels + */ +public class EmbeddedDownload { + + private final static Logger LOG = Logger.getLogger(EmbeddedDownload.class); + + private BrokerPool pool; + + /** + * Set brokerpool for in database resolve of resource. + * @param brokerPool + */ + public void setBrokerPool(BrokerPool brokerPool) { + this.pool = brokerPool; + } + + /** + * Write document referred by URL to an (output)stream. + * + * @param xmldbURL Document location in database. + * @param os Stream to which the document is written. + * @throws IOException + */ + public void stream(XmldbURL xmldbURL, OutputStream os) throws IOException { + stream(xmldbURL, os, null); + } + + /** + * Write document referred by URL to an (output)stream as specified user. + * + * @param user Effective user for operation. If NULL the user information + * is distilled from the URL. + * @param xmldbURL Document location in database. + * @param os Stream to which the document is written. + * @throws IOException + */ + public void stream(XmldbURL xmldbURL, OutputStream os, Subject user) throws IOException { + LOG.debug("Begin document download"); + + DocumentImpl resource = null; + Collection collection = null; + DBBroker broker = null; + + try { + final XmldbURI path = XmldbURI.create(xmldbURL.getPath()); + + if(pool==null){ + pool = BrokerPool.getInstance(); + } + + if(user==null){ + if(xmldbURL.hasUserInfo()){ + user=EmbeddedUser.authenticate(xmldbURL, pool); + if(user==null){ + throw new IOException("Unauthorized user "+xmldbURL.getUsername()); + } + + } else { + user=EmbeddedUser.getUserGuest(pool); + } + } + broker = pool.get(user); + + resource = broker.getXMLResource(path, Lock.READ_LOCK); + + if(resource == null) { + // Test for collection + collection = broker.openCollection(path, Lock.READ_LOCK); + if(collection == null){ + // No collection, no document + throw new IOException("Resource "+xmldbURL.getPath()+" not found."); + + } else { + // Collection + throw new IOException("Resource "+xmldbURL.getPath()+" is a collection."); + } + + } else { + if(resource.getResourceType() == DocumentImpl.XML_FILE) { + final Serializer serializer = broker.getSerializer(); + serializer.reset(); + + // Preserve doctype + serializer.setProperty(EXistOutputKeys.OUTPUT_DOCTYPE, "yes"); + final Writer w = new OutputStreamWriter(os,"UTF-8"); + serializer.serialize(resource,w); + w.close(); + + } else { + broker.readBinaryResource((BinaryDocument) resource, os); + } + } + } catch (final IOException ex) { + //ex.printStackTrace(); + LOG.error(ex); + throw ex; + + } catch (final Exception ex) { + //ex.printStackTrace(); + LOG.error(ex); + throw new IOException(ex.getMessage(), ex); + + } finally { + if(resource != null){ + resource.getUpdateLock().release(Lock.READ_LOCK); + } + + if(collection != null){ + collection.release(Lock.READ_LOCK); + } + + pool.release(broker); + + LOG.debug("End document download"); + } + } +} diff --git a/src/org/exist/protocolhandler/embedded/EmbeddedInputStream.java b/src/org/exist/protocolhandler/embedded/EmbeddedInputStream.java index 0b928fb700c..04b83f3ef07 100644 --- a/src/org/exist/protocolhandler/embedded/EmbeddedInputStream.java +++ b/src/org/exist/protocolhandler/embedded/EmbeddedInputStream.java @@ -1,119 +1,119 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id: EmbeddedInputStream.java 223 2007-04-21 22:13:05Z dizzzz $ - */ - -package org.exist.protocolhandler.embedded; - -import java.io.IOException; -import java.io.InputStream; -import java.io.PipedInputStream; -import java.io.PipedOutputStream; -import java.net.MalformedURLException; - -import org.apache.log4j.Logger; - -import org.exist.protocolhandler.xmldb.XmldbURL; -import org.exist.storage.BrokerPool; -import org.exist.storage.io.BlockingInputStream; -import org.exist.storage.io.BlockingOutputStream; - -/** - * Read document from embedded database as a (input)stream. - * - * @author Dannes Wessels - */ -public class EmbeddedInputStream extends InputStream { - - private final static Logger logger = Logger.getLogger(EmbeddedInputStream.class); - - private PipedInputStream bis; - private PipedOutputStream bos; - private EmbeddedDownloadThread rt; - - /** - * Constructor of EmbeddedInputStream. - * - * @param xmldbURL Location of document in database. - * @throws MalformedURLException Thrown for illegalillegal URLs. - */ - public EmbeddedInputStream(XmldbURL xmldbURL) throws IOException { - - this(null, xmldbURL); - } - - /** - * Constructor of EmbeddedInputStream. - * - * @param xmldbURL Location of document in database. - * @throws MalformedURLException Thrown for illegalillegal URLs. - */ - public EmbeddedInputStream(BrokerPool brokerPool, XmldbURL xmldbURL) throws IOException { - - logger.debug("Initializing EmbeddedInputStream"); - - bis = new PipedInputStream(2048); - bos = new PipedOutputStream(bis); - - rt = new EmbeddedDownloadThread(brokerPool, xmldbURL , bos); - - rt.start(); - - logger.debug("Initializing EmbeddedInputStream done"); - } - - - @Override - public int read(byte[] b, int off, int len) throws IOException { - return bis.read(b, off, len); - } - - @Override - public int read(byte[] b) throws IOException { - return bis.read(b, 0, b.length); - } - - @Override - public long skip(long n) throws IOException { - return bis.skip(n); - } - - @Override - public void reset() throws IOException { - bis.reset(); - } - - @Override - public int read() throws IOException { - - return bis.read(); - } - - @Override - public void close() throws IOException { - bis.close(); - } - - @Override - public int available() throws IOException { - return bis.available(); - } - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id: EmbeddedInputStream.java 223 2007-04-21 22:13:05Z dizzzz $ + */ + +package org.exist.protocolhandler.embedded; + +import java.io.IOException; +import java.io.InputStream; +import java.io.PipedInputStream; +import java.io.PipedOutputStream; +import java.net.MalformedURLException; + +import org.apache.log4j.Logger; + +import org.exist.protocolhandler.xmldb.XmldbURL; +import org.exist.storage.BrokerPool; +import org.exist.storage.io.BlockingInputStream; +import org.exist.storage.io.BlockingOutputStream; + +/** + * Read document from embedded database as a (input)stream. + * + * @author Dannes Wessels + */ +public class EmbeddedInputStream extends InputStream { + + private final static Logger logger = Logger.getLogger(EmbeddedInputStream.class); + + private PipedInputStream bis; + private PipedOutputStream bos; + private EmbeddedDownloadThread rt; + + /** + * Constructor of EmbeddedInputStream. + * + * @param xmldbURL Location of document in database. + * @throws MalformedURLException Thrown for illegalillegal URLs. + */ + public EmbeddedInputStream(XmldbURL xmldbURL) throws IOException { + + this(null, xmldbURL); + } + + /** + * Constructor of EmbeddedInputStream. + * + * @param xmldbURL Location of document in database. + * @throws MalformedURLException Thrown for illegalillegal URLs. + */ + public EmbeddedInputStream(BrokerPool brokerPool, XmldbURL xmldbURL) throws IOException { + + logger.debug("Initializing EmbeddedInputStream"); + + bis = new PipedInputStream(2048); + bos = new PipedOutputStream(bis); + + rt = new EmbeddedDownloadThread(brokerPool, xmldbURL , bos); + + rt.start(); + + logger.debug("Initializing EmbeddedInputStream done"); + } + + + @Override + public int read(byte[] b, int off, int len) throws IOException { + return bis.read(b, off, len); + } + + @Override + public int read(byte[] b) throws IOException { + return bis.read(b, 0, b.length); + } + + @Override + public long skip(long n) throws IOException { + return bis.skip(n); + } + + @Override + public void reset() throws IOException { + bis.reset(); + } + + @Override + public int read() throws IOException { + + return bis.read(); + } + + @Override + public void close() throws IOException { + bis.close(); + } + + @Override + public int available() throws IOException { + return bis.available(); + } + +} diff --git a/src/org/exist/protocolhandler/embedded/EmbeddedOutputStream.java b/src/org/exist/protocolhandler/embedded/EmbeddedOutputStream.java index 16b92360cf0..333ac0d7869 100644 --- a/src/org/exist/protocolhandler/embedded/EmbeddedOutputStream.java +++ b/src/org/exist/protocolhandler/embedded/EmbeddedOutputStream.java @@ -1,90 +1,90 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id: EmbeddedOutputStream.java 223 2007-04-21 22:13:05Z dizzzz $ - */ - -package org.exist.protocolhandler.embedded; - -import java.io.IOException; -import java.io.OutputStream; -import java.net.MalformedURLException; - -import org.apache.log4j.Logger; -import org.exist.protocolhandler.xmldb.XmldbURL; -import org.exist.storage.io.BlockingInputStream; - -/** - * Write document to local database (embedded) using output stream. - * - * @author Dannes Wessels - */ -public class EmbeddedOutputStream extends OutputStream { - - - private final static Logger logger = Logger.getLogger(EmbeddedOutputStream.class); - private BlockingInputStream bis; - private OutputStream bos; - private EmbeddedUploadThread rt; - - /** - * Constructor of EmbeddedOutputStream. - * - * @param xmldbURL Location of document in database. - * @throws MalformedURLException Thrown for illegal URLs. - */ - public EmbeddedOutputStream(XmldbURL xmldbURL) { - - logger.debug("Initializing EmbeddedUploadThread"); - - bis = new BlockingInputStream(); - bos = bis.getOutputStream(); - - rt = new EmbeddedUploadThread(xmldbURL, bis); - rt.start(); - - logger.debug("Initializing EmbeddedUploadThread done"); - } - - - @Override - public void write(int b) throws IOException { - bos.write(b); - } - - @Override - public void write(byte[] b) throws IOException { - bos.write(b,0,b.length); - } - - @Override - public void write(byte[] b, int off, int len) throws IOException { - bos.write(b,off,len); - } - - @Override - public void close() throws IOException { - bos.close(); - } - - @Override - public void flush() throws IOException { - bos.flush(); - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id: EmbeddedOutputStream.java 223 2007-04-21 22:13:05Z dizzzz $ + */ + +package org.exist.protocolhandler.embedded; + +import java.io.IOException; +import java.io.OutputStream; +import java.net.MalformedURLException; + +import org.apache.log4j.Logger; +import org.exist.protocolhandler.xmldb.XmldbURL; +import org.exist.storage.io.BlockingInputStream; + +/** + * Write document to local database (embedded) using output stream. + * + * @author Dannes Wessels + */ +public class EmbeddedOutputStream extends OutputStream { + + + private final static Logger logger = Logger.getLogger(EmbeddedOutputStream.class); + private BlockingInputStream bis; + private OutputStream bos; + private EmbeddedUploadThread rt; + + /** + * Constructor of EmbeddedOutputStream. + * + * @param xmldbURL Location of document in database. + * @throws MalformedURLException Thrown for illegal URLs. + */ + public EmbeddedOutputStream(XmldbURL xmldbURL) { + + logger.debug("Initializing EmbeddedUploadThread"); + + bis = new BlockingInputStream(); + bos = bis.getOutputStream(); + + rt = new EmbeddedUploadThread(xmldbURL, bis); + rt.start(); + + logger.debug("Initializing EmbeddedUploadThread done"); + } + + + @Override + public void write(int b) throws IOException { + bos.write(b); + } + + @Override + public void write(byte[] b) throws IOException { + bos.write(b,0,b.length); + } + + @Override + public void write(byte[] b, int off, int len) throws IOException { + bos.write(b,off,len); + } + + @Override + public void close() throws IOException { + bos.close(); + } + + @Override + public void flush() throws IOException { + bos.flush(); + } +} diff --git a/src/org/exist/protocolhandler/embedded/EmbeddedUser.java b/src/org/exist/protocolhandler/embedded/EmbeddedUser.java index 0cba71633db..81d36b89c96 100644 --- a/src/org/exist/protocolhandler/embedded/EmbeddedUser.java +++ b/src/org/exist/protocolhandler/embedded/EmbeddedUser.java @@ -1,71 +1,71 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2010 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id: EmbeddedUser.java 188 2007-03-30 14:59:28Z dizzzz $ - */ - -package org.exist.protocolhandler.embedded; - -import org.exist.protocolhandler.xmldb.XmldbURL; -import org.exist.security.AuthenticationException; -import org.exist.security.SecurityManager; -import org.exist.security.Subject; -import org.exist.storage.BrokerPool; - -/** - * Authenticate user with embedded eXist. - * - * @author @author Dannes Wessels - */ -public class EmbeddedUser { - - /** - * Authenticate user specified in URL with embedded database. - * - * @param xmldbURL URL formatted as xmldb:exist://username:passwd@...... - * @param pool Exist broker pool, provides access to database. - * @return USER when user exists and password is OK, or NULL - */ - public static Subject authenticate(XmldbURL xmldbURL, BrokerPool pool){ - - if(!xmldbURL.hasUserInfo()){ - return null; - } - - final SecurityManager secman = pool.getSecurityManager(); - try { - return secman.authenticate(xmldbURL.getUsername(), xmldbURL.getPassword()); - } catch (final AuthenticationException e) { - return null; // authentication is failed - } - } - - /** - * Get user GUEST from database. - * - * @param pool Exist broker pool, provides access to database. - * @return eXist GUEST user. - */ - public static Subject getUserGuest(BrokerPool pool){ - return pool.getSecurityManager().getGuestSubject(); - } - - - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2010 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id: EmbeddedUser.java 188 2007-03-30 14:59:28Z dizzzz $ + */ + +package org.exist.protocolhandler.embedded; + +import org.exist.protocolhandler.xmldb.XmldbURL; +import org.exist.security.AuthenticationException; +import org.exist.security.SecurityManager; +import org.exist.security.Subject; +import org.exist.storage.BrokerPool; + +/** + * Authenticate user with embedded eXist. + * + * @author @author Dannes Wessels + */ +public class EmbeddedUser { + + /** + * Authenticate user specified in URL with embedded database. + * + * @param xmldbURL URL formatted as xmldb:exist://username:passwd@...... + * @param pool Exist broker pool, provides access to database. + * @return USER when user exists and password is OK, or NULL + */ + public static Subject authenticate(XmldbURL xmldbURL, BrokerPool pool){ + + if(!xmldbURL.hasUserInfo()){ + return null; + } + + final SecurityManager secman = pool.getSecurityManager(); + try { + return secman.authenticate(xmldbURL.getUsername(), xmldbURL.getPassword()); + } catch (final AuthenticationException e) { + return null; // authentication is failed + } + } + + /** + * Get user GUEST from database. + * + * @param pool Exist broker pool, provides access to database. + * @return eXist GUEST user. + */ + public static Subject getUserGuest(BrokerPool pool){ + return pool.getSecurityManager().getGuestSubject(); + } + + + +} diff --git a/src/org/exist/protocolhandler/embedded/package.html b/src/org/exist/protocolhandler/embedded/package.html index 9e775c1ce28..1c6f1e74a31 100644 --- a/src/org/exist/protocolhandler/embedded/package.html +++ b/src/org/exist/protocolhandler/embedded/package.html @@ -1,5 +1,5 @@ - - -eXist-DB Custom protocol handler. - + + +eXist-DB Custom protocol handler. + \ No newline at end of file diff --git a/src/org/exist/protocolhandler/protocols/xmldb/Connection.java b/src/org/exist/protocolhandler/protocols/xmldb/Connection.java index 6c33e9a74a5..e2a9338ef18 100644 --- a/src/org/exist/protocolhandler/protocols/xmldb/Connection.java +++ b/src/org/exist/protocolhandler/protocols/xmldb/Connection.java @@ -1,107 +1,107 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id: Connection.java 189 2007-03-30 15:02:18Z dizzzz $ - */ - -package org.exist.protocolhandler.protocols.xmldb; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URL; -import java.net.URLConnection; - -import org.apache.log4j.Logger; -import org.exist.protocolhandler.embedded.EmbeddedInputStream; -import org.exist.protocolhandler.embedded.EmbeddedOutputStream; -import org.exist.protocolhandler.xmldb.XmldbURL; -import org.exist.protocolhandler.xmlrpc.XmlrpcInputStream; -import org.exist.protocolhandler.xmlrpc.XmlrpcOutputStream; - -/** - * A URLConnection object manages the translation of a URL object into a - * resource stream. - * - * @see A New Era for Java Protocol Handlers - * - * @see java.net.URLConnection - * - * @author Dannes Wessels - */ -public class Connection extends URLConnection { - - private final static Logger LOG = Logger.getLogger(Connection.class); - - /** - * Constructs a URL connection to the specified URL. - */ - protected Connection(URL url) { - super(url); - LOG.debug(url); - - setDoInput(true); - setDoOutput(true); - } - - /** - * @see java.net.URLConnection#connect - */ - public void connect() throws IOException { - LOG.debug(url) ; - } - - /** - * @see java.net.URLConnection#getInputStream - */ - public InputStream getInputStream() throws IOException { - LOG.debug(url) ; - - InputStream inputstream=null; - final XmldbURL xmldbURL = new XmldbURL(url); - - if(xmldbURL.isEmbedded()){ - inputstream = new EmbeddedInputStream( xmldbURL ); - } else { - inputstream = new XmlrpcInputStream( xmldbURL ); - } - - return inputstream; - } - - - /** - * @see java.net.URLConnection#getOutputStream - */ - public OutputStream getOutputStream() throws IOException { - LOG.debug(url) ; - - OutputStream outputstream=null; - final XmldbURL xmldbURL = new XmldbURL(url); - - if(xmldbURL.isEmbedded()){ - outputstream = new EmbeddedOutputStream( xmldbURL ); - } else { - outputstream = new XmlrpcOutputStream( xmldbURL ); - } - - return outputstream; - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id: Connection.java 189 2007-03-30 15:02:18Z dizzzz $ + */ + +package org.exist.protocolhandler.protocols.xmldb; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URL; +import java.net.URLConnection; + +import org.apache.log4j.Logger; +import org.exist.protocolhandler.embedded.EmbeddedInputStream; +import org.exist.protocolhandler.embedded.EmbeddedOutputStream; +import org.exist.protocolhandler.xmldb.XmldbURL; +import org.exist.protocolhandler.xmlrpc.XmlrpcInputStream; +import org.exist.protocolhandler.xmlrpc.XmlrpcOutputStream; + +/** + * A URLConnection object manages the translation of a URL object into a + * resource stream. + * + * @see A New Era for Java Protocol Handlers + * + * @see java.net.URLConnection + * + * @author Dannes Wessels + */ +public class Connection extends URLConnection { + + private final static Logger LOG = Logger.getLogger(Connection.class); + + /** + * Constructs a URL connection to the specified URL. + */ + protected Connection(URL url) { + super(url); + LOG.debug(url); + + setDoInput(true); + setDoOutput(true); + } + + /** + * @see java.net.URLConnection#connect + */ + public void connect() throws IOException { + LOG.debug(url) ; + } + + /** + * @see java.net.URLConnection#getInputStream + */ + public InputStream getInputStream() throws IOException { + LOG.debug(url) ; + + InputStream inputstream=null; + final XmldbURL xmldbURL = new XmldbURL(url); + + if(xmldbURL.isEmbedded()){ + inputstream = new EmbeddedInputStream( xmldbURL ); + } else { + inputstream = new XmlrpcInputStream( xmldbURL ); + } + + return inputstream; + } + + + /** + * @see java.net.URLConnection#getOutputStream + */ + public OutputStream getOutputStream() throws IOException { + LOG.debug(url) ; + + OutputStream outputstream=null; + final XmldbURL xmldbURL = new XmldbURL(url); + + if(xmldbURL.isEmbedded()){ + outputstream = new EmbeddedOutputStream( xmldbURL ); + } else { + outputstream = new XmlrpcOutputStream( xmldbURL ); + } + + return outputstream; + } +} diff --git a/src/org/exist/protocolhandler/protocols/xmldb/package.html b/src/org/exist/protocolhandler/protocols/xmldb/package.html index fcbc4b47aed..16d6e50eeb1 100644 --- a/src/org/exist/protocolhandler/protocols/xmldb/package.html +++ b/src/org/exist/protocolhandler/protocols/xmldb/package.html @@ -1,5 +1,5 @@ - - -Access eXist-DB in embedded mode. - + + +Access eXist-DB in embedded mode. + \ No newline at end of file diff --git a/src/org/exist/protocolhandler/xmldb/XmldbURL.java b/src/org/exist/protocolhandler/xmldb/XmldbURL.java index 68566b84503..7cc6698d335 100644 --- a/src/org/exist/protocolhandler/xmldb/XmldbURL.java +++ b/src/org/exist/protocolhandler/xmldb/XmldbURL.java @@ -1,369 +1,369 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id: XmldbURL.java 218 2007-04-13 15:06:43Z dizzzz $ - */ - -package org.exist.protocolhandler.xmldb; - -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URL; - -import org.exist.xmldb.XmldbURI; - -/** - * A utility class for xmldb URLs. Since, java.net.URL is final this class - * acts as a wrapper, convenience methods have been added.
- *
- * Example:
- * xmldb:exist://username:password@hostname:8080/exist/xmlrpc/db/collection/document.xml
- *
- * Note: A collection URL ends with a "/":
- * xmldb:exist://hostname:8080/exist/xmlrpc/db/collection/ - * - * @see java.net.URI - * @see java.net.URL - * @see org.exist.xmldb.XmldbURI - * - * @author Dannes Wessels - */ -public class XmldbURL { - - private static final int USERNAME=1; - private static final int PASSWORD=2; - - private URL myUrl; - - /** - * Creates a new instance of XmldbURL using an XmldbURI object. - * - * @param xmldbURI Resource location. - * @throws java.net.MalformedURLException - */ - public XmldbURL(XmldbURI xmldbURI) throws MalformedURLException { - this(xmldbURI.toURL()); - } - - /** - * Creates a new instance of XmldbURL using an URL object. - * @param url Resource location. - * @throws java.net.MalformedURLException - */ - public XmldbURL(URL url) throws MalformedURLException { - // check protocol - if("xmldb".equals(url.getProtocol())){ - myUrl = url; - } else { - throw new MalformedURLException("URL is not an \"xmldb:\" URL: "+url.toString() ); - } - } - - /** - * Creates a new instance of XmldbURL using an URI object. - * - * @param uri Resource location. - * @throws java.net.MalformedURLException - */ - public XmldbURL(URI uri) throws MalformedURLException { - this(uri.toURL()); - } - - /** - * Creates a new instance of XmldbURL using an String. - * @param txt Resource location. - * @throws java.net.MalformedURLException - */ - public XmldbURL(String txt) throws MalformedURLException { - this(new URL(txt)); - } - - /** - * xmldb:exist://username:password@hostname:8080/exist/xmlrpc/db/collection/document.xml - * @see java.net.URL#getUserInfo - * - * @return username:password - */ - public String getUserInfo() { - return myUrl.getUserInfo(); - } - - /** - * xmldb:exist://username:password@hostname:8080/exist/xmlrpc/db/collection/document.xml - * @return username - */ - public String getUsername(){ - return extractCredentials(USERNAME); - } - - /** - * xmldb:exist://username:password@hostname:8080/exist/xmlrpc/db/collection/document.xml - * @return password - */ - public String getPassword(){ - return extractCredentials(PASSWORD); - } - - /** - * @return URL representation of location. - */ - public URL getURL(){ - return myUrl; - } - - /** - * xmldb:exist://username:password@hostname:8080/exist/xmlrpc/db/collection/document.xml?query#fragment - * @see java.net.URL#getAuthority - * @return authority - */ - public String getAuthority() { - return myUrl.getAuthority(); - } - - /** - * xmldb:exist://username:password@hostname:8080/exist/xmlrpc/db/collection/document.xml?query#fragment - * Return context, null if not available. - */ - public String getContext() { - final String path = myUrl.getPath(); - final int dbPosition=path.indexOf("/db"); - String context=null; - - if(dbPosition!=-1){ - // since all paths begin with this pattern.. - context=path.substring(0,dbPosition); - } - - if(context!=null && "".equals(context)){ - context=null; - } - - return context; - } - - // /exist/xmlrpc/db/shakespeare/plays/macbeth.xml - // /exist/xmlrpc/db/shakespeare/plays/ - // /db/shakespeare/plays/macbeth.xml - // /db/shakespeare/plays/ - - - /** - * xmldb:exist://username:password@hostname:8080/exist/xmlrpc/db/collection/document.xml - * @return collection - */ - public String getCollection(){ - - String path=myUrl.getPath(); - String collectionName=null; - - final int dbLocation=path.indexOf("/db"); - - if(dbLocation!=-1){ - // found pattern "/db" - if(path.endsWith("/")){ - // -1 removes the slash - collectionName=path.substring(dbLocation, (path.length()-1) ); - } else { - final int lastSep=path.lastIndexOf('/'); - if(lastSep==0){ - collectionName="/"; - - } else if(lastSep!=-1){ - collectionName=path.substring(dbLocation, lastSep); - - } else { - collectionName=path; - } - } - - } else { // TODO not very well tested - // pattern not found, taking full path - if(path.endsWith("/")){ - // -1 removes the slash - collectionName=path.substring(0, (path.length()-1) ); - } else { - final int lastSep=path.lastIndexOf('/'); - if(lastSep!=-1){ - collectionName=path.substring(0, lastSep); - } else { - collectionName="/"; - } - } - } - - return collectionName; - } - - /** - * xmldb:exist://username:password@hostname:8080/exist/xmlrpc/db/collection/document.xml - * @return collection - */ - public String getDocumentName(){ - String serverPath=myUrl.getPath(); - String documentName=null; - if(!serverPath.endsWith("/")){ - final int lastSep=serverPath.lastIndexOf('/'); - if(lastSep==-1){ - documentName=serverPath; - } else { - documentName=serverPath.substring(lastSep+1); - } - } - return documentName; - } - - // Get username or password - private String extractCredentials(int part) { - - String userInfo = myUrl.getUserInfo(); - String username = null; - String password = null; - - if(userInfo!=null){ - final int separator = userInfo.indexOf(':'); - if(separator==-1){ - username=userInfo; - password=null; - } else { - username=userInfo.substring(0,separator); - password=userInfo.substring(separator+1); - } - } - - // Fix credentials. If not found (empty string) fill NULL - if(username!=null && "".equals(username)){ - username=null; - } - - // Fix credentials. If not found (empty string) fill NULL - if(password!=null && "".equals(password)){ - password=null; - } - - if(part==USERNAME){ - return username; - } else if(part==PASSWORD){ - return password; - } - return null; - } - - /** - * xmldb:exist://username:password@hostname:8080/exist/xmlrpc/db/collection/document.xml - * @see java.net.URL#getProtocol - * @return protocol - */ - public String getProtocol(){ - return myUrl.getProtocol(); - } - - /** - * xmldb:exist://username:password@hostname:8080/exist/xmlrpc/db/collection/document.xml - * @see java.net.URL#getProtocol - * @return protocol - */ - public String getHost(){ - final String hostname=myUrl.getHost(); - if("".equals(hostname)){ - return null; - } else { - return hostname; - } - } - - /** - * xmldb:exist://username:password@hostname:8080/exist/xmlrpc/db/collection/document.xml - * @see java.net.URL#getPort - * @return port - */ - public int getPort(){ - return myUrl.getPort(); - } - - /** - * xmldb:exist://username:password@hostname:8080:/exist/xmlrpc/db/collection/document.xml - * @see java.net.URL#getPath - * @return port - */ - public String getPath(){ - return myUrl.getPath(); - } - - /** - * xmldb:exist://username:password@hostname:8080/exist/xmlrpc/db/collection/document.xml?query#fragment - * @see java.net.URL#getQuery - * @return query - */ - public String getQuery(){ - return myUrl.getQuery(); - } - - /** - * xmldb:exist://username:password@hostname:8080:/exist/xmlrpc/db/collection/document.xml - * @return collectionpath - */ - public String getCollectionPath(){ - return myUrl.getPath().substring(13); - } - - /** - * Get http:// URL from xmldb:exist:// URL - * xmldb:exist://username:password@hostname:8080:/exist/xmlrpc/db/collection/document.xml - * @return http://username:password@hostname:8080:/exist/xmlrpc/db/collection/document.xml - */ - public String getXmlRpcURL(){ - return "http://" + myUrl.getAuthority() + getContext(); - } - - /** - * Does the URL have at least a username? - * @return TRUE when URL contains username - */ - public boolean hasUserInfo(){ - return (getUserInfo()!=null && getUsername()!=null); - } - - /** - * Get eXist instance name. - * - * @return eXist-db instance name, at this moment fixed to exist - */ - public String getInstanceName() { - return "exist"; // No other choice - } - - /** - * Get textual representation of URL. - * - * @see java.net.URL#toString - * @return Text representation of URL. - */ - public String toString(){ - return myUrl.toString(); - } - - /** - * Get information wether URL is an embedded URL. - * - * @return TRUE when URL refers to resource in embedded eXist-db. - */ - public boolean isEmbedded(){ - return (getHost()==null); - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id: XmldbURL.java 218 2007-04-13 15:06:43Z dizzzz $ + */ + +package org.exist.protocolhandler.xmldb; + +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URL; + +import org.exist.xmldb.XmldbURI; + +/** + * A utility class for xmldb URLs. Since, java.net.URL is final this class + * acts as a wrapper, convenience methods have been added.
+ *
+ * Example:
+ * xmldb:exist://username:password@hostname:8080/exist/xmlrpc/db/collection/document.xml
+ *
+ * Note: A collection URL ends with a "/":
+ * xmldb:exist://hostname:8080/exist/xmlrpc/db/collection/ + * + * @see java.net.URI + * @see java.net.URL + * @see org.exist.xmldb.XmldbURI + * + * @author Dannes Wessels + */ +public class XmldbURL { + + private static final int USERNAME=1; + private static final int PASSWORD=2; + + private URL myUrl; + + /** + * Creates a new instance of XmldbURL using an XmldbURI object. + * + * @param xmldbURI Resource location. + * @throws java.net.MalformedURLException + */ + public XmldbURL(XmldbURI xmldbURI) throws MalformedURLException { + this(xmldbURI.toURL()); + } + + /** + * Creates a new instance of XmldbURL using an URL object. + * @param url Resource location. + * @throws java.net.MalformedURLException + */ + public XmldbURL(URL url) throws MalformedURLException { + // check protocol + if("xmldb".equals(url.getProtocol())){ + myUrl = url; + } else { + throw new MalformedURLException("URL is not an \"xmldb:\" URL: "+url.toString() ); + } + } + + /** + * Creates a new instance of XmldbURL using an URI object. + * + * @param uri Resource location. + * @throws java.net.MalformedURLException + */ + public XmldbURL(URI uri) throws MalformedURLException { + this(uri.toURL()); + } + + /** + * Creates a new instance of XmldbURL using an String. + * @param txt Resource location. + * @throws java.net.MalformedURLException + */ + public XmldbURL(String txt) throws MalformedURLException { + this(new URL(txt)); + } + + /** + * xmldb:exist://username:password@hostname:8080/exist/xmlrpc/db/collection/document.xml + * @see java.net.URL#getUserInfo + * + * @return username:password + */ + public String getUserInfo() { + return myUrl.getUserInfo(); + } + + /** + * xmldb:exist://username:password@hostname:8080/exist/xmlrpc/db/collection/document.xml + * @return username + */ + public String getUsername(){ + return extractCredentials(USERNAME); + } + + /** + * xmldb:exist://username:password@hostname:8080/exist/xmlrpc/db/collection/document.xml + * @return password + */ + public String getPassword(){ + return extractCredentials(PASSWORD); + } + + /** + * @return URL representation of location. + */ + public URL getURL(){ + return myUrl; + } + + /** + * xmldb:exist://username:password@hostname:8080/exist/xmlrpc/db/collection/document.xml?query#fragment + * @see java.net.URL#getAuthority + * @return authority + */ + public String getAuthority() { + return myUrl.getAuthority(); + } + + /** + * xmldb:exist://username:password@hostname:8080/exist/xmlrpc/db/collection/document.xml?query#fragment + * Return context, null if not available. + */ + public String getContext() { + final String path = myUrl.getPath(); + final int dbPosition=path.indexOf("/db"); + String context=null; + + if(dbPosition!=-1){ + // since all paths begin with this pattern.. + context=path.substring(0,dbPosition); + } + + if(context!=null && "".equals(context)){ + context=null; + } + + return context; + } + + // /exist/xmlrpc/db/shakespeare/plays/macbeth.xml + // /exist/xmlrpc/db/shakespeare/plays/ + // /db/shakespeare/plays/macbeth.xml + // /db/shakespeare/plays/ + + + /** + * xmldb:exist://username:password@hostname:8080/exist/xmlrpc/db/collection/document.xml + * @return collection + */ + public String getCollection(){ + + String path=myUrl.getPath(); + String collectionName=null; + + final int dbLocation=path.indexOf("/db"); + + if(dbLocation!=-1){ + // found pattern "/db" + if(path.endsWith("/")){ + // -1 removes the slash + collectionName=path.substring(dbLocation, (path.length()-1) ); + } else { + final int lastSep=path.lastIndexOf('/'); + if(lastSep==0){ + collectionName="/"; + + } else if(lastSep!=-1){ + collectionName=path.substring(dbLocation, lastSep); + + } else { + collectionName=path; + } + } + + } else { // TODO not very well tested + // pattern not found, taking full path + if(path.endsWith("/")){ + // -1 removes the slash + collectionName=path.substring(0, (path.length()-1) ); + } else { + final int lastSep=path.lastIndexOf('/'); + if(lastSep!=-1){ + collectionName=path.substring(0, lastSep); + } else { + collectionName="/"; + } + } + } + + return collectionName; + } + + /** + * xmldb:exist://username:password@hostname:8080/exist/xmlrpc/db/collection/document.xml + * @return collection + */ + public String getDocumentName(){ + String serverPath=myUrl.getPath(); + String documentName=null; + if(!serverPath.endsWith("/")){ + final int lastSep=serverPath.lastIndexOf('/'); + if(lastSep==-1){ + documentName=serverPath; + } else { + documentName=serverPath.substring(lastSep+1); + } + } + return documentName; + } + + // Get username or password + private String extractCredentials(int part) { + + String userInfo = myUrl.getUserInfo(); + String username = null; + String password = null; + + if(userInfo!=null){ + final int separator = userInfo.indexOf(':'); + if(separator==-1){ + username=userInfo; + password=null; + } else { + username=userInfo.substring(0,separator); + password=userInfo.substring(separator+1); + } + } + + // Fix credentials. If not found (empty string) fill NULL + if(username!=null && "".equals(username)){ + username=null; + } + + // Fix credentials. If not found (empty string) fill NULL + if(password!=null && "".equals(password)){ + password=null; + } + + if(part==USERNAME){ + return username; + } else if(part==PASSWORD){ + return password; + } + return null; + } + + /** + * xmldb:exist://username:password@hostname:8080/exist/xmlrpc/db/collection/document.xml + * @see java.net.URL#getProtocol + * @return protocol + */ + public String getProtocol(){ + return myUrl.getProtocol(); + } + + /** + * xmldb:exist://username:password@hostname:8080/exist/xmlrpc/db/collection/document.xml + * @see java.net.URL#getProtocol + * @return protocol + */ + public String getHost(){ + final String hostname=myUrl.getHost(); + if("".equals(hostname)){ + return null; + } else { + return hostname; + } + } + + /** + * xmldb:exist://username:password@hostname:8080/exist/xmlrpc/db/collection/document.xml + * @see java.net.URL#getPort + * @return port + */ + public int getPort(){ + return myUrl.getPort(); + } + + /** + * xmldb:exist://username:password@hostname:8080:/exist/xmlrpc/db/collection/document.xml + * @see java.net.URL#getPath + * @return port + */ + public String getPath(){ + return myUrl.getPath(); + } + + /** + * xmldb:exist://username:password@hostname:8080/exist/xmlrpc/db/collection/document.xml?query#fragment + * @see java.net.URL#getQuery + * @return query + */ + public String getQuery(){ + return myUrl.getQuery(); + } + + /** + * xmldb:exist://username:password@hostname:8080:/exist/xmlrpc/db/collection/document.xml + * @return collectionpath + */ + public String getCollectionPath(){ + return myUrl.getPath().substring(13); + } + + /** + * Get http:// URL from xmldb:exist:// URL + * xmldb:exist://username:password@hostname:8080:/exist/xmlrpc/db/collection/document.xml + * @return http://username:password@hostname:8080:/exist/xmlrpc/db/collection/document.xml + */ + public String getXmlRpcURL(){ + return "http://" + myUrl.getAuthority() + getContext(); + } + + /** + * Does the URL have at least a username? + * @return TRUE when URL contains username + */ + public boolean hasUserInfo(){ + return (getUserInfo()!=null && getUsername()!=null); + } + + /** + * Get eXist instance name. + * + * @return eXist-db instance name, at this moment fixed to exist + */ + public String getInstanceName() { + return "exist"; // No other choice + } + + /** + * Get textual representation of URL. + * + * @see java.net.URL#toString + * @return Text representation of URL. + */ + public String toString(){ + return myUrl.toString(); + } + + /** + * Get information wether URL is an embedded URL. + * + * @return TRUE when URL refers to resource in embedded eXist-db. + */ + public boolean isEmbedded(){ + return (getHost()==null); + } +} diff --git a/src/org/exist/protocolhandler/xmldb/package.html b/src/org/exist/protocolhandler/xmldb/package.html index c9428277322..0e05f244661 100644 --- a/src/org/exist/protocolhandler/xmldb/package.html +++ b/src/org/exist/protocolhandler/xmldb/package.html @@ -1,5 +1,5 @@ - - -Xmldb URL classes. - + + +Xmldb URL classes. + \ No newline at end of file diff --git a/src/org/exist/protocolhandler/xmlrpc/XmlrpcDownload.java b/src/org/exist/protocolhandler/xmlrpc/XmlrpcDownload.java index 3d82485df03..054dd1cb79a 100644 --- a/src/org/exist/protocolhandler/xmlrpc/XmlrpcDownload.java +++ b/src/org/exist/protocolhandler/xmlrpc/XmlrpcDownload.java @@ -1,117 +1,117 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id: XmlrpcDownload.java 223 2007-04-21 22:13:05Z dizzzz $ - */ - -package org.exist.protocolhandler.xmlrpc; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.Hashtable; -import java.util.Vector; -import java.net.URL; - -import org.apache.log4j.Logger; -import org.apache.xmlrpc.client.XmlRpcClient; -import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; - -import org.exist.protocolhandler.xmldb.XmldbURL; - - -/** - * Read document from using XMLRPC from remote database and write the data - * into an output stream. - * - * @author Dannes Wessels - */ -public class XmlrpcDownload { - - private final static Logger LOG = Logger.getLogger(XmlrpcDownload.class); - - /** - * Write document referred by the URL to the output stream. - * - * - * @param xmldbURL Document location in database. - * @param os Stream to which the document is written. - * @throws ExistIOException - */ - public void stream(XmldbURL xmldbURL, OutputStream os) throws IOException { - LOG.debug("Begin document download"); - try { - final XmlRpcClient client = new XmlRpcClient(); - final XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); - config.setEncoding("UTF-8"); - config.setEnabledForExtensions(true); - config.setServerURL(new URL(xmldbURL.getXmlRpcURL())); - - // Setup client client - if(xmldbURL.hasUserInfo()) { - config.setBasicUserName(xmldbURL.getUsername()); - config.setBasicPassword(xmldbURL.getPassword()); - } - client.setConfig(config); - - // Setup xml serializer - final Hashtable options = new Hashtable(); - options.put("indent", "no"); - options.put("encoding", "UTF-8"); - - // Setup client parameters - final Vector params = new Vector(); - params.addElement( xmldbURL.getCollectionPath() ); - params.addElement( options ); - - // Shoot first method write data - Hashtable ht = (Hashtable) client.execute("getDocumentData", params); - int offset = ((Integer)ht.get("offset")).intValue(); - byte[]data= (byte[]) ht.get("data"); - final String handle = (String) ht.get("handle"); - os.write(data); - - // When there is more data to download - while(offset!=0){ - // Clean and re-setup client parameters - params.clear(); - params.addElement(handle); - params.addElement(Integer.valueOf(offset)); - - // Get and write next chunk - ht = (Hashtable) client.execute("getNextChunk", params); - data= (byte[]) ht.get("data"); - offset = ((Integer)ht.get("offset")).intValue(); - os.write(data); - } - - } catch (final IOException ex) { - LOG.error(ex); - throw ex; - - } catch (final Exception ex) { - LOG.error(ex); - throw new IOException(ex.getMessage(), ex); - - } finally { - LOG.debug("Finished document download"); - - } - } - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id: XmlrpcDownload.java 223 2007-04-21 22:13:05Z dizzzz $ + */ + +package org.exist.protocolhandler.xmlrpc; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.Hashtable; +import java.util.Vector; +import java.net.URL; + +import org.apache.log4j.Logger; +import org.apache.xmlrpc.client.XmlRpcClient; +import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; + +import org.exist.protocolhandler.xmldb.XmldbURL; + + +/** + * Read document from using XMLRPC from remote database and write the data + * into an output stream. + * + * @author Dannes Wessels + */ +public class XmlrpcDownload { + + private final static Logger LOG = Logger.getLogger(XmlrpcDownload.class); + + /** + * Write document referred by the URL to the output stream. + * + * + * @param xmldbURL Document location in database. + * @param os Stream to which the document is written. + * @throws ExistIOException + */ + public void stream(XmldbURL xmldbURL, OutputStream os) throws IOException { + LOG.debug("Begin document download"); + try { + final XmlRpcClient client = new XmlRpcClient(); + final XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); + config.setEncoding("UTF-8"); + config.setEnabledForExtensions(true); + config.setServerURL(new URL(xmldbURL.getXmlRpcURL())); + + // Setup client client + if(xmldbURL.hasUserInfo()) { + config.setBasicUserName(xmldbURL.getUsername()); + config.setBasicPassword(xmldbURL.getPassword()); + } + client.setConfig(config); + + // Setup xml serializer + final Hashtable options = new Hashtable(); + options.put("indent", "no"); + options.put("encoding", "UTF-8"); + + // Setup client parameters + final Vector params = new Vector(); + params.addElement( xmldbURL.getCollectionPath() ); + params.addElement( options ); + + // Shoot first method write data + Hashtable ht = (Hashtable) client.execute("getDocumentData", params); + int offset = ((Integer)ht.get("offset")).intValue(); + byte[]data= (byte[]) ht.get("data"); + final String handle = (String) ht.get("handle"); + os.write(data); + + // When there is more data to download + while(offset!=0){ + // Clean and re-setup client parameters + params.clear(); + params.addElement(handle); + params.addElement(Integer.valueOf(offset)); + + // Get and write next chunk + ht = (Hashtable) client.execute("getNextChunk", params); + data= (byte[]) ht.get("data"); + offset = ((Integer)ht.get("offset")).intValue(); + os.write(data); + } + + } catch (final IOException ex) { + LOG.error(ex); + throw ex; + + } catch (final Exception ex) { + LOG.error(ex); + throw new IOException(ex.getMessage(), ex); + + } finally { + LOG.debug("Finished document download"); + + } + } + +} diff --git a/src/org/exist/protocolhandler/xmlrpc/XmlrpcDownloadThread.java b/src/org/exist/protocolhandler/xmlrpc/XmlrpcDownloadThread.java index 8fbfa291ebb..b00cd4e02e9 100644 --- a/src/org/exist/protocolhandler/xmlrpc/XmlrpcDownloadThread.java +++ b/src/org/exist/protocolhandler/xmlrpc/XmlrpcDownloadThread.java @@ -1,77 +1,77 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id: XmlrpcDownloadThread.java 223 2007-04-21 22:13:05Z dizzzz $ - */ - -package org.exist.protocolhandler.xmlrpc; - -import java.io.IOException; - -import org.apache.log4j.Logger; -import org.exist.protocolhandler.xmldb.XmldbURL; -import org.exist.storage.io.BlockingOutputStream; - -/** - * Wrap XmlrpcDownload class into a thread for XmlrpcInputStream. - * - * @author Dannes Wessels - */ -public class XmlrpcDownloadThread extends Thread { - - private final static Logger logger = Logger.getLogger(XmlrpcDownloadThread.class); - private XmldbURL xmldbURL; - private BlockingOutputStream bos; - - /** - * Constructor of XmlrpcDownloadThread. - * - * @param url Document location in database. - * @param bos Stream to which the document is written. - */ - public XmlrpcDownloadThread(XmldbURL url, BlockingOutputStream bos) { - xmldbURL=url; - this.bos=bos; - } - - /** - * Write resource to the output stream. - */ - public void run() { - logger.debug("Thread started." ); - IOException exception=null; - try { - final XmlrpcDownload xuc = new XmlrpcDownload(); - xuc.stream(xmldbURL, bos); - - } catch (IOException ex) { - logger.error(ex); - exception = ex; - - } finally { - try { // NEEDED! - bos.close(exception); - } catch (final IOException ex) { - logger.debug(ex); - } - logger.debug("Thread stopped." ); - } - } - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id: XmlrpcDownloadThread.java 223 2007-04-21 22:13:05Z dizzzz $ + */ + +package org.exist.protocolhandler.xmlrpc; + +import java.io.IOException; + +import org.apache.log4j.Logger; +import org.exist.protocolhandler.xmldb.XmldbURL; +import org.exist.storage.io.BlockingOutputStream; + +/** + * Wrap XmlrpcDownload class into a thread for XmlrpcInputStream. + * + * @author Dannes Wessels + */ +public class XmlrpcDownloadThread extends Thread { + + private final static Logger logger = Logger.getLogger(XmlrpcDownloadThread.class); + private XmldbURL xmldbURL; + private BlockingOutputStream bos; + + /** + * Constructor of XmlrpcDownloadThread. + * + * @param url Document location in database. + * @param bos Stream to which the document is written. + */ + public XmlrpcDownloadThread(XmldbURL url, BlockingOutputStream bos) { + xmldbURL=url; + this.bos=bos; + } + + /** + * Write resource to the output stream. + */ + public void run() { + logger.debug("Thread started." ); + IOException exception=null; + try { + final XmlrpcDownload xuc = new XmlrpcDownload(); + xuc.stream(xmldbURL, bos); + + } catch (IOException ex) { + logger.error(ex); + exception = ex; + + } finally { + try { // NEEDED! + bos.close(exception); + } catch (final IOException ex) { + logger.debug(ex); + } + logger.debug("Thread stopped." ); + } + } + +} diff --git a/src/org/exist/protocolhandler/xmlrpc/XmlrpcInputStream.java b/src/org/exist/protocolhandler/xmlrpc/XmlrpcInputStream.java index b974239736c..780dd8a0e4b 100644 --- a/src/org/exist/protocolhandler/xmlrpc/XmlrpcInputStream.java +++ b/src/org/exist/protocolhandler/xmlrpc/XmlrpcInputStream.java @@ -1,95 +1,95 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id: XmlrpcInputStream.java 223 2007-04-21 22:13:05Z dizzzz $ - */ - -package org.exist.protocolhandler.xmlrpc; - -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; - -import org.apache.log4j.Logger; -import org.exist.protocolhandler.xmldb.XmldbURL; -import org.exist.storage.io.BlockingInputStream; -import org.exist.storage.io.BlockingOutputStream; - -/** - * Read document from remote database (using xmlrpc) as a input stream. - * - * @author Dannes Wessels - */ -public class XmlrpcInputStream extends InputStream { - - private final static Logger logger = Logger.getLogger(XmlrpcInputStream.class); - private BlockingInputStream bis; - private BlockingOutputStream bos; - private XmlrpcDownloadThread rt; - - /** - * Constructor of XmlrpcInputStream. - * - * @param xmldbURL Location of document in database. - * @throws MalformedURLException Thrown for illegalillegal URLs. - */ - public XmlrpcInputStream(XmldbURL xmldbURL) { - - logger.debug("Initializing ResourceInputStream"); - - bis = new BlockingInputStream(); - bos = bis.getOutputStream(); - - rt = new XmlrpcDownloadThread(xmldbURL , bos); - - rt.start(); - - logger.debug("Initializing ResourceInputStream done"); - - } - - public int read(byte[] b, int off, int len) throws IOException { - return bis.read(b, off, len); - } - - public int read(byte[] b) throws IOException { - return bis.read(b, 0, b.length); - } - - public long skip(long n) throws IOException { - return bis.skip(n); - } - - public void reset() throws IOException { - bis.reset(); - } - - public int read() throws IOException { - return bis.read(); - } - - public void close() throws IOException { - bis.close(); - } - - public int available() throws IOException { - return bis.available(); - } - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id: XmlrpcInputStream.java 223 2007-04-21 22:13:05Z dizzzz $ + */ + +package org.exist.protocolhandler.xmlrpc; + +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; + +import org.apache.log4j.Logger; +import org.exist.protocolhandler.xmldb.XmldbURL; +import org.exist.storage.io.BlockingInputStream; +import org.exist.storage.io.BlockingOutputStream; + +/** + * Read document from remote database (using xmlrpc) as a input stream. + * + * @author Dannes Wessels + */ +public class XmlrpcInputStream extends InputStream { + + private final static Logger logger = Logger.getLogger(XmlrpcInputStream.class); + private BlockingInputStream bis; + private BlockingOutputStream bos; + private XmlrpcDownloadThread rt; + + /** + * Constructor of XmlrpcInputStream. + * + * @param xmldbURL Location of document in database. + * @throws MalformedURLException Thrown for illegalillegal URLs. + */ + public XmlrpcInputStream(XmldbURL xmldbURL) { + + logger.debug("Initializing ResourceInputStream"); + + bis = new BlockingInputStream(); + bos = bis.getOutputStream(); + + rt = new XmlrpcDownloadThread(xmldbURL , bos); + + rt.start(); + + logger.debug("Initializing ResourceInputStream done"); + + } + + public int read(byte[] b, int off, int len) throws IOException { + return bis.read(b, off, len); + } + + public int read(byte[] b) throws IOException { + return bis.read(b, 0, b.length); + } + + public long skip(long n) throws IOException { + return bis.skip(n); + } + + public void reset() throws IOException { + bis.reset(); + } + + public int read() throws IOException { + return bis.read(); + } + + public void close() throws IOException { + bis.close(); + } + + public int available() throws IOException { + return bis.available(); + } + +} diff --git a/src/org/exist/protocolhandler/xmlrpc/XmlrpcOutputStream.java b/src/org/exist/protocolhandler/xmlrpc/XmlrpcOutputStream.java index fa6760b57d4..09c33560d76 100644 --- a/src/org/exist/protocolhandler/xmlrpc/XmlrpcOutputStream.java +++ b/src/org/exist/protocolhandler/xmlrpc/XmlrpcOutputStream.java @@ -1,86 +1,86 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id: XmlrpcOutputStream.java 223 2007-04-21 22:13:05Z dizzzz $ - */ - -package org.exist.protocolhandler.xmlrpc; - -import java.io.IOException; -import java.io.OutputStream; -import java.net.MalformedURLException; - -import org.apache.log4j.Logger; -import org.exist.protocolhandler.xmldb.XmldbURL; -import org.exist.storage.io.BlockingInputStream; -import org.exist.storage.io.BlockingOutputStream; - -/** - * Write document to remote database (using xmlrpc) using output stream. - * - * @author Dannes Wessels - */ -public class XmlrpcOutputStream extends OutputStream { - - - private final static Logger logger = Logger.getLogger(XmlrpcOutputStream.class); - private BlockingInputStream bis; - private BlockingOutputStream bos; - private XmlrpcUploadThread rt; - - /** - * Constructor of XmlrpcOutputStream. - * - * @param xmldbURL Location of document in database. - * @throws MalformedURLException Thrown for illegalillegal URLs. - */ - public XmlrpcOutputStream(XmldbURL xmldbURL) { - - logger.debug("Initializing XmlrpcOutputStream"); - - bis = new BlockingInputStream(); - bos = bis.getOutputStream(); - - rt = new XmlrpcUploadThread(xmldbURL, bis); - rt.start(); - - logger.debug("Initializing XmlrpcOutputStream done"); - } - - - public void write(int b) throws IOException { - bos.write(b); - } - - public void write(byte[] b) throws IOException { - bos.write(b,0,b.length); - } - - public void write(byte[] b, int off, int len) throws IOException { - bos.write(b,off,len); - } - - public void close() throws IOException { - bos.close(); - } - - public void flush() throws IOException { - bos.flush(); - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id: XmlrpcOutputStream.java 223 2007-04-21 22:13:05Z dizzzz $ + */ + +package org.exist.protocolhandler.xmlrpc; + +import java.io.IOException; +import java.io.OutputStream; +import java.net.MalformedURLException; + +import org.apache.log4j.Logger; +import org.exist.protocolhandler.xmldb.XmldbURL; +import org.exist.storage.io.BlockingInputStream; +import org.exist.storage.io.BlockingOutputStream; + +/** + * Write document to remote database (using xmlrpc) using output stream. + * + * @author Dannes Wessels + */ +public class XmlrpcOutputStream extends OutputStream { + + + private final static Logger logger = Logger.getLogger(XmlrpcOutputStream.class); + private BlockingInputStream bis; + private BlockingOutputStream bos; + private XmlrpcUploadThread rt; + + /** + * Constructor of XmlrpcOutputStream. + * + * @param xmldbURL Location of document in database. + * @throws MalformedURLException Thrown for illegalillegal URLs. + */ + public XmlrpcOutputStream(XmldbURL xmldbURL) { + + logger.debug("Initializing XmlrpcOutputStream"); + + bis = new BlockingInputStream(); + bos = bis.getOutputStream(); + + rt = new XmlrpcUploadThread(xmldbURL, bis); + rt.start(); + + logger.debug("Initializing XmlrpcOutputStream done"); + } + + + public void write(int b) throws IOException { + bos.write(b); + } + + public void write(byte[] b) throws IOException { + bos.write(b,0,b.length); + } + + public void write(byte[] b, int off, int len) throws IOException { + bos.write(b,off,len); + } + + public void close() throws IOException { + bos.close(); + } + + public void flush() throws IOException { + bos.flush(); + } +} diff --git a/src/org/exist/protocolhandler/xmlrpc/XmlrpcUpload.java b/src/org/exist/protocolhandler/xmlrpc/XmlrpcUpload.java index a4b3b9b2a28..76d11a7315b 100644 --- a/src/org/exist/protocolhandler/xmlrpc/XmlrpcUpload.java +++ b/src/org/exist/protocolhandler/xmlrpc/XmlrpcUpload.java @@ -1,132 +1,132 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id: XmlrpcUpload.java 223 2007-04-21 22:13:05Z dizzzz $ - */ - -package org.exist.protocolhandler.xmlrpc; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; -import java.net.URL; - -import org.apache.log4j.Logger; -import org.apache.xmlrpc.client.XmlRpcClient; -import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; - -import org.exist.protocolhandler.xmldb.XmldbURL; -import org.exist.util.MimeTable; -import org.exist.util.MimeType; - -/** - * Write document using XMLRPC to remote database and read the data - * from an input stream. - * - * Sends a document to an eXist-db server using XMLRPC. The document can be - * either XML or non-XML (binary). Chunked means that the document is send - * as smaller parts to the server, the servler glues the parts together. There - * is no limitation on the size of the documents that can be transported. - * - * @author Dannes Wessels - */ -public class XmlrpcUpload { - - private final static Logger LOG = Logger.getLogger(XmlrpcUpload.class); - - /** - * Write data from a (input)stream to the specified XMLRPC url and leave - * the input stream open. - * - * @param xmldbURL URL pointing to location on eXist-db server. - * @param is Document stream - * @throws Exception When something is wrong. - */ - public void stream(XmldbURL xmldbURL, InputStream is) - throws IOException { - LOG.debug("Begin document upload"); - try { - // Setup xmlrpc client - final XmlRpcClient client = new XmlRpcClient(); - final XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); - config.setEncoding("UTF-8"); - config.setEnabledForExtensions(true); - config.setServerURL(new URL(xmldbURL.getXmlRpcURL())); - - if(xmldbURL.hasUserInfo()) { - config.setBasicUserName(xmldbURL.getUsername()); - config.setBasicPassword(xmldbURL.getPassword()); - } - client.setConfig(config); - - String contentType=MimeType.BINARY_TYPE.getName(); - final MimeType mime - = MimeTable.getInstance().getContentTypeFor(xmldbURL.getDocumentName()); - if (mime != null){ - contentType = mime.getName(); - } - - // Initialize xmlrpc parameters - final List params = new ArrayList(5); - String handle=null; - - // Copy data from inputstream to database - final byte[] buf = new byte[4096]; - int len; - while ((len = is.read(buf)) > 0) { - params.clear(); - if(handle!=null){ - params.add(handle); - } - params.add(buf); - params.add(Integer.valueOf(len)); - handle = (String)client.execute("upload", params); - } - - // All data transported, now parse data on server - params.clear(); - params.add(handle); - params.add(xmldbURL.getCollectionPath() ); - params.add(Boolean.valueOf(true)); - params.add(contentType); - final Boolean result =(Boolean)client.execute("parseLocal", params); - - // Check XMLRPC result - if(result.booleanValue()){ - LOG.debug("Document stored."); - } else { - LOG.debug("Could not store document."); - throw new IOException("Could not store document."); - } - - } catch (final IOException ex) { - LOG.debug(ex); - throw ex; - - } catch (final Exception ex) { - LOG.debug(ex); - throw new IOException(ex.getMessage(), ex); - - } finally { - LOG.debug("Finished document upload"); - } - } - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id: XmlrpcUpload.java 223 2007-04-21 22:13:05Z dizzzz $ + */ + +package org.exist.protocolhandler.xmlrpc; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.net.URL; + +import org.apache.log4j.Logger; +import org.apache.xmlrpc.client.XmlRpcClient; +import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; + +import org.exist.protocolhandler.xmldb.XmldbURL; +import org.exist.util.MimeTable; +import org.exist.util.MimeType; + +/** + * Write document using XMLRPC to remote database and read the data + * from an input stream. + * + * Sends a document to an eXist-db server using XMLRPC. The document can be + * either XML or non-XML (binary). Chunked means that the document is send + * as smaller parts to the server, the servler glues the parts together. There + * is no limitation on the size of the documents that can be transported. + * + * @author Dannes Wessels + */ +public class XmlrpcUpload { + + private final static Logger LOG = Logger.getLogger(XmlrpcUpload.class); + + /** + * Write data from a (input)stream to the specified XMLRPC url and leave + * the input stream open. + * + * @param xmldbURL URL pointing to location on eXist-db server. + * @param is Document stream + * @throws Exception When something is wrong. + */ + public void stream(XmldbURL xmldbURL, InputStream is) + throws IOException { + LOG.debug("Begin document upload"); + try { + // Setup xmlrpc client + final XmlRpcClient client = new XmlRpcClient(); + final XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); + config.setEncoding("UTF-8"); + config.setEnabledForExtensions(true); + config.setServerURL(new URL(xmldbURL.getXmlRpcURL())); + + if(xmldbURL.hasUserInfo()) { + config.setBasicUserName(xmldbURL.getUsername()); + config.setBasicPassword(xmldbURL.getPassword()); + } + client.setConfig(config); + + String contentType=MimeType.BINARY_TYPE.getName(); + final MimeType mime + = MimeTable.getInstance().getContentTypeFor(xmldbURL.getDocumentName()); + if (mime != null){ + contentType = mime.getName(); + } + + // Initialize xmlrpc parameters + final List params = new ArrayList(5); + String handle=null; + + // Copy data from inputstream to database + final byte[] buf = new byte[4096]; + int len; + while ((len = is.read(buf)) > 0) { + params.clear(); + if(handle!=null){ + params.add(handle); + } + params.add(buf); + params.add(Integer.valueOf(len)); + handle = (String)client.execute("upload", params); + } + + // All data transported, now parse data on server + params.clear(); + params.add(handle); + params.add(xmldbURL.getCollectionPath() ); + params.add(Boolean.valueOf(true)); + params.add(contentType); + final Boolean result =(Boolean)client.execute("parseLocal", params); + + // Check XMLRPC result + if(result.booleanValue()){ + LOG.debug("Document stored."); + } else { + LOG.debug("Could not store document."); + throw new IOException("Could not store document."); + } + + } catch (final IOException ex) { + LOG.debug(ex); + throw ex; + + } catch (final Exception ex) { + LOG.debug(ex); + throw new IOException(ex.getMessage(), ex); + + } finally { + LOG.debug("Finished document upload"); + } + } + +} diff --git a/src/org/exist/protocolhandler/xmlrpc/XmlrpcUploadThread.java b/src/org/exist/protocolhandler/xmlrpc/XmlrpcUploadThread.java index 6c8988507aa..734843560a1 100644 --- a/src/org/exist/protocolhandler/xmlrpc/XmlrpcUploadThread.java +++ b/src/org/exist/protocolhandler/xmlrpc/XmlrpcUploadThread.java @@ -1,67 +1,67 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id: XmlrpcUploadThread.java 223 2007-04-21 22:13:05Z dizzzz $ - */ - -package org.exist.protocolhandler.xmlrpc; - -import java.io.IOException; - -import org.apache.log4j.Logger; -import org.exist.protocolhandler.xmldb.XmldbURL; -import org.exist.storage.io.BlockingInputStream; - -/** - * Wrap XmlrpcUpload class into a thread for XmlrpcOutputStream. - * - * @author Dannes Wessels - */ -public class XmlrpcUploadThread extends Thread { - - private final static Logger logger = Logger.getLogger(XmlrpcUploadThread.class); - private XmldbURL xmldbURL; - private BlockingInputStream bis; - - - public XmlrpcUploadThread(XmldbURL url, BlockingInputStream bis) { - xmldbURL=url; - this.bis=bis; - } - - /** - * Start Thread. - */ - public void run() { - logger.debug("Thread started." ); - Exception exception=null; - try { - final XmlrpcUpload uploader = new XmlrpcUpload(); - uploader.stream(xmldbURL, bis); - - } catch (IOException ex) { - logger.error(ex); - exception = ex; - - } finally { - bis.close(exception); - logger.debug("Thread stopped." ); - } - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id: XmlrpcUploadThread.java 223 2007-04-21 22:13:05Z dizzzz $ + */ + +package org.exist.protocolhandler.xmlrpc; + +import java.io.IOException; + +import org.apache.log4j.Logger; +import org.exist.protocolhandler.xmldb.XmldbURL; +import org.exist.storage.io.BlockingInputStream; + +/** + * Wrap XmlrpcUpload class into a thread for XmlrpcOutputStream. + * + * @author Dannes Wessels + */ +public class XmlrpcUploadThread extends Thread { + + private final static Logger logger = Logger.getLogger(XmlrpcUploadThread.class); + private XmldbURL xmldbURL; + private BlockingInputStream bis; + + + public XmlrpcUploadThread(XmldbURL url, BlockingInputStream bis) { + xmldbURL=url; + this.bis=bis; + } + + /** + * Start Thread. + */ + public void run() { + logger.debug("Thread started." ); + Exception exception=null; + try { + final XmlrpcUpload uploader = new XmlrpcUpload(); + uploader.stream(xmldbURL, bis); + + } catch (IOException ex) { + logger.error(ex); + exception = ex; + + } finally { + bis.close(exception); + logger.debug("Thread stopped." ); + } + } +} diff --git a/src/org/exist/protocolhandler/xmlrpc/package.html b/src/org/exist/protocolhandler/xmlrpc/package.html index d921fb2b157..f839470e55f 100644 --- a/src/org/exist/protocolhandler/xmlrpc/package.html +++ b/src/org/exist/protocolhandler/xmlrpc/package.html @@ -1,5 +1,5 @@ - - -Access eXist-DB on remote server using XMLRPC. - + + +Access eXist-DB on remote server using XMLRPC. + \ No newline at end of file diff --git a/src/org/exist/scheduler/JobDescription.java b/src/org/exist/scheduler/JobDescription.java index 6642bf50653..5f9ed593748 100644 --- a/src/org/exist/scheduler/JobDescription.java +++ b/src/org/exist/scheduler/JobDescription.java @@ -1,51 +1,51 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2006 The eXist team - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ -package org.exist.scheduler; - -/** - * Interface defined requirements for a Scheduleable job. - * - * @author Adam Retter - */ -public interface JobDescription { - - /** - * Get the name of the job. - * - * @return The job's name - */ - public String getName(); - - /** - * Set the name of the job. - * - * @param name The job's new name - */ - public void setName(final String name ); - - /** - * Get the name group for the job. - * - * @return The job's group name - */ - public String getGroup(); -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2006 The eXist team + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id$ + */ +package org.exist.scheduler; + +/** + * Interface defined requirements for a Scheduleable job. + * + * @author Adam Retter + */ +public interface JobDescription { + + /** + * Get the name of the job. + * + * @return The job's name + */ + public String getName(); + + /** + * Set the name of the job. + * + * @param name The job's new name + */ + public void setName(final String name ); + + /** + * Get the name group for the job. + * + * @return The job's group name + */ + public String getGroup(); +} diff --git a/src/org/exist/scheduler/JobException.java b/src/org/exist/scheduler/JobException.java index 21c3afda454..4d63eaea9ca 100644 --- a/src/org/exist/scheduler/JobException.java +++ b/src/org/exist/scheduler/JobException.java @@ -1,81 +1,81 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2006 The eXist team - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ -package org.exist.scheduler; - -import org.quartz.JobExecutionException; - - -/** - * Exception class can be thrown by implementations of org.exist.scheduler.Job. - * - *

Also provides a mechanism for cleaning up a job after failed execution

- * - * @author Adam Retter - */ -public class JobException extends Exception { - - private static final long serialVersionUID = 1567438994821964637L; - - public enum JobExceptionAction { - JOB_ABORT, //Abort this job, but continue scheduling - JOB_ABORT_THIS, //Abort this job and cancel this trigger - JOB_ABORT_ALL, //Abort this job and cancel all triggers - JOB_REFIRE //Refire this job now - } - - private final JobExceptionAction jobExceptionAction; - - public JobException(final JobExceptionAction jobExceptionAction, final String message ) { - super(message); - - this.jobExceptionAction = jobExceptionAction; - } - - /** - * Should be called after this exception is caught it cleans up the job, with regards to the scheduler. - * - *

Jobs may be removed, re-fired immediately or left for their next execution

- * - * @throws JobExecutionException DOCUMENT ME! - */ - public void cleanupJob() throws JobExecutionException { - switch(jobExceptionAction) { - - case JOB_REFIRE: - throw new JobExecutionException(getMessage(), true); - - case JOB_ABORT_THIS: - final JobExecutionException jat = new JobExecutionException(getMessage(), false); - jat.setUnscheduleFiringTrigger(true); - throw jat; - - case JOB_ABORT_ALL: - final JobExecutionException jaa = new JobExecutionException(getMessage(), false); - jaa.setUnscheduleAllTriggers(true); - throw jaa; - - case JOB_ABORT: - default: - throw new JobExecutionException(getMessage(), false); - } - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2006 The eXist team + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id$ + */ +package org.exist.scheduler; + +import org.quartz.JobExecutionException; + + +/** + * Exception class can be thrown by implementations of org.exist.scheduler.Job. + * + *

Also provides a mechanism for cleaning up a job after failed execution

+ * + * @author Adam Retter + */ +public class JobException extends Exception { + + private static final long serialVersionUID = 1567438994821964637L; + + public enum JobExceptionAction { + JOB_ABORT, //Abort this job, but continue scheduling + JOB_ABORT_THIS, //Abort this job and cancel this trigger + JOB_ABORT_ALL, //Abort this job and cancel all triggers + JOB_REFIRE //Refire this job now + } + + private final JobExceptionAction jobExceptionAction; + + public JobException(final JobExceptionAction jobExceptionAction, final String message ) { + super(message); + + this.jobExceptionAction = jobExceptionAction; + } + + /** + * Should be called after this exception is caught it cleans up the job, with regards to the scheduler. + * + *

Jobs may be removed, re-fired immediately or left for their next execution

+ * + * @throws JobExecutionException DOCUMENT ME! + */ + public void cleanupJob() throws JobExecutionException { + switch(jobExceptionAction) { + + case JOB_REFIRE: + throw new JobExecutionException(getMessage(), true); + + case JOB_ABORT_THIS: + final JobExecutionException jat = new JobExecutionException(getMessage(), false); + jat.setUnscheduleFiringTrigger(true); + throw jat; + + case JOB_ABORT_ALL: + final JobExecutionException jaa = new JobExecutionException(getMessage(), false); + jaa.setUnscheduleAllTriggers(true); + throw jaa; + + case JOB_ABORT: + default: + throw new JobExecutionException(getMessage(), false); + } + } +} diff --git a/src/org/exist/scheduler/ScheduledJobInfo.java b/src/org/exist/scheduler/ScheduledJobInfo.java index ded56ad7a59..079c3de8bf0 100644 --- a/src/org/exist/scheduler/ScheduledJobInfo.java +++ b/src/org/exist/scheduler/ScheduledJobInfo.java @@ -1,187 +1,187 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2006 The eXist team - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ -package org.exist.scheduler; - -import java.util.Date; -import org.quartz.CronTrigger; -import org.quartz.Scheduler; -import org.quartz.SchedulerException; -import org.quartz.SimpleTrigger; -import org.quartz.Trigger; - - -/** - * Information about a Scheduled Job. - * - * @author Adam Retter - */ -public class ScheduledJobInfo { - - public enum TriggerState { - ERROR, - NONE, - NORMAL, - PAUSED, - BLOCKED, - COMPLETE; - } - - private final Scheduler scheduler; - private final Trigger trigger; - - public ScheduledJobInfo(final Scheduler scheduler, final Trigger trigger) { - this.scheduler = scheduler; - this.trigger = trigger; - } - - /** - * Get the Job's Name. - * - * @return the Job's Name - */ - public String getName() { - return trigger.getJobKey().getName(); - } - - - /** - * Get the Job's Group. - * - * @return the Job's Group - */ - public String getGroup() { - return trigger.getJobKey().getGroup(); - } - - - /** - * Get the Name of the Job's Trigger. - * - * @return the Name of the Job's Trigger - */ - public String getTriggerName() { - return trigger.getKey().getName(); - } - - - /** - * Get the Start time of the Job. - * - * @return the Start time of the Job - */ - public Date getStartTime() { - return trigger.getStartTime(); - } - - - /** - * Get the End time of the Job. - * - * @return the End time of the Job, or null of the job is Scheduled forever - */ - public Date getEndTime() { - return trigger.getEndTime(); - } - - - /** - * Get the Previous Fired time of the Job. - * - * @return the time the Job was Previously Fired, or null if the job hasnt fired yet - */ - public Date getPreviousFireTime() { - return trigger.getPreviousFireTime(); - } - - - /** - * Get the Time the Job will Next be Fired. - * - * @return the time the Job will Next be Fired, or null if the job wont fire again - */ - public Date getNextFireTime() { - return trigger.getNextFireTime(); - } - - - /** - * Get the Final Time the Job will be Fired. - * - * @return the time the Job will be Fired for the Final time, or null if the job is Scheduled forever - */ - public Date getFinalFireTime() { - return trigger.getFinalFireTime(); - } - - - /** - * Get the Expression that was used to configure the Triggers firing pattern. - * - * @return The expression that was used to configure the Triggers firing pattern - */ - public String getTriggerExpression(){ - if(trigger instanceof CronTrigger) { - return ((CronTrigger)trigger).getCronExpression(); - } else if(trigger instanceof SimpleTrigger) { - return String.valueOf(((SimpleTrigger)trigger).getRepeatInterval()); - } - - return null; - } - - - /** - * Get the State of the Job's Trigger. - * - * @return the TRIGGER_STATE_* - */ - public TriggerState getTriggerState() { - try { - switch(scheduler.getTriggerState(trigger.getKey())) { - - - case ERROR: - return TriggerState.ERROR; - - case NONE: - return TriggerState.NONE; - - case NORMAL: - return TriggerState.NORMAL; - - case PAUSED: - return TriggerState.PAUSED; - - case BLOCKED: - return TriggerState.BLOCKED; - - case COMPLETE: - return TriggerState.COMPLETE; - - default: - return TriggerState.ERROR; - } - } catch(final SchedulerException se) { - return TriggerState.ERROR; - } - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2006 The eXist team + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id$ + */ +package org.exist.scheduler; + +import java.util.Date; +import org.quartz.CronTrigger; +import org.quartz.Scheduler; +import org.quartz.SchedulerException; +import org.quartz.SimpleTrigger; +import org.quartz.Trigger; + + +/** + * Information about a Scheduled Job. + * + * @author Adam Retter + */ +public class ScheduledJobInfo { + + public enum TriggerState { + ERROR, + NONE, + NORMAL, + PAUSED, + BLOCKED, + COMPLETE; + } + + private final Scheduler scheduler; + private final Trigger trigger; + + public ScheduledJobInfo(final Scheduler scheduler, final Trigger trigger) { + this.scheduler = scheduler; + this.trigger = trigger; + } + + /** + * Get the Job's Name. + * + * @return the Job's Name + */ + public String getName() { + return trigger.getJobKey().getName(); + } + + + /** + * Get the Job's Group. + * + * @return the Job's Group + */ + public String getGroup() { + return trigger.getJobKey().getGroup(); + } + + + /** + * Get the Name of the Job's Trigger. + * + * @return the Name of the Job's Trigger + */ + public String getTriggerName() { + return trigger.getKey().getName(); + } + + + /** + * Get the Start time of the Job. + * + * @return the Start time of the Job + */ + public Date getStartTime() { + return trigger.getStartTime(); + } + + + /** + * Get the End time of the Job. + * + * @return the End time of the Job, or null of the job is Scheduled forever + */ + public Date getEndTime() { + return trigger.getEndTime(); + } + + + /** + * Get the Previous Fired time of the Job. + * + * @return the time the Job was Previously Fired, or null if the job hasnt fired yet + */ + public Date getPreviousFireTime() { + return trigger.getPreviousFireTime(); + } + + + /** + * Get the Time the Job will Next be Fired. + * + * @return the time the Job will Next be Fired, or null if the job wont fire again + */ + public Date getNextFireTime() { + return trigger.getNextFireTime(); + } + + + /** + * Get the Final Time the Job will be Fired. + * + * @return the time the Job will be Fired for the Final time, or null if the job is Scheduled forever + */ + public Date getFinalFireTime() { + return trigger.getFinalFireTime(); + } + + + /** + * Get the Expression that was used to configure the Triggers firing pattern. + * + * @return The expression that was used to configure the Triggers firing pattern + */ + public String getTriggerExpression(){ + if(trigger instanceof CronTrigger) { + return ((CronTrigger)trigger).getCronExpression(); + } else if(trigger instanceof SimpleTrigger) { + return String.valueOf(((SimpleTrigger)trigger).getRepeatInterval()); + } + + return null; + } + + + /** + * Get the State of the Job's Trigger. + * + * @return the TRIGGER_STATE_* + */ + public TriggerState getTriggerState() { + try { + switch(scheduler.getTriggerState(trigger.getKey())) { + + + case ERROR: + return TriggerState.ERROR; + + case NONE: + return TriggerState.NONE; + + case NORMAL: + return TriggerState.NORMAL; + + case PAUSED: + return TriggerState.PAUSED; + + case BLOCKED: + return TriggerState.BLOCKED; + + case COMPLETE: + return TriggerState.COMPLETE; + + default: + return TriggerState.ERROR; + } + } catch(final SchedulerException se) { + return TriggerState.ERROR; + } + } +} diff --git a/src/org/exist/scheduler/UserJavaJob.java b/src/org/exist/scheduler/UserJavaJob.java index e031e6b3ad9..a14efe119bf 100644 --- a/src/org/exist/scheduler/UserJavaJob.java +++ b/src/org/exist/scheduler/UserJavaJob.java @@ -1,76 +1,76 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2006 The eXist team - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ -package org.exist.scheduler; - -import java.util.Map; -import org.exist.storage.BrokerPool; -import org.quartz.JobDataMap; -import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; - - -/** - * Class to represent a User's Java Job. - * - *

Should be extended by all classes wishing to schedule as a Job that perform user defined functionality

- * - * @author Adam Retter - */ -public abstract class UserJavaJob extends UserJob { - /** - * The execute method as called by the Quartz Scheduler. - * - * @param jec The execution context of the executing job - * - * @throws JobExecutionException if there was a problem with the job, this also describes to Quartz how to cleanup the job - */ - @Override - public final void execute(final JobExecutionContext jec) throws JobExecutionException { - final JobDataMap jobDataMap = jec.getJobDetail().getJobDataMap(); - - //get the brokerpool from the data map - final BrokerPool pool = (BrokerPool)jobDataMap.get("brokerpool"); - - //get any parameters from the data map - final Map params = (Map)jobDataMap.get("params"); - - try { - //execute the job - execute(pool, params); - } catch(final JobException je ) { - //cleanup the job - je.cleanupJob(); - } - } - - - /** - * Function that is executed by the Scheduler. - * - * @param brokerpool The BrokerPool for the Scheduler of this job - * @param params Any parameters passed to the job or null otherwise - * - * @throws JobException if there is a problem with the job. cleanupJob() should then be called, which will adjust the jobs scheduling - * appropriately - */ - public abstract void execute(BrokerPool brokerpool, Map params) throws JobException; -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2006 The eXist team + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id$ + */ +package org.exist.scheduler; + +import java.util.Map; +import org.exist.storage.BrokerPool; +import org.quartz.JobDataMap; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + + +/** + * Class to represent a User's Java Job. + * + *

Should be extended by all classes wishing to schedule as a Job that perform user defined functionality

+ * + * @author Adam Retter + */ +public abstract class UserJavaJob extends UserJob { + /** + * The execute method as called by the Quartz Scheduler. + * + * @param jec The execution context of the executing job + * + * @throws JobExecutionException if there was a problem with the job, this also describes to Quartz how to cleanup the job + */ + @Override + public final void execute(final JobExecutionContext jec) throws JobExecutionException { + final JobDataMap jobDataMap = jec.getJobDetail().getJobDataMap(); + + //get the brokerpool from the data map + final BrokerPool pool = (BrokerPool)jobDataMap.get("brokerpool"); + + //get any parameters from the data map + final Map params = (Map)jobDataMap.get("params"); + + try { + //execute the job + execute(pool, params); + } catch(final JobException je ) { + //cleanup the job + je.cleanupJob(); + } + } + + + /** + * Function that is executed by the Scheduler. + * + * @param brokerpool The BrokerPool for the Scheduler of this job + * @param params Any parameters passed to the job or null otherwise + * + * @throws JobException if there is a problem with the job. cleanupJob() should then be called, which will adjust the jobs scheduling + * appropriately + */ + public abstract void execute(BrokerPool brokerpool, Map params) throws JobException; +} diff --git a/src/org/exist/scheduler/UserJob.java b/src/org/exist/scheduler/UserJob.java index 9eed936f42e..5a9920e680f 100644 --- a/src/org/exist/scheduler/UserJob.java +++ b/src/org/exist/scheduler/UserJob.java @@ -1,39 +1,39 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2006 The eXist team - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ -package org.exist.scheduler; - -/** - * Class to represent a User's Job Should be extended by all classes wishing to schedule as a Job that perform user defined functions. - * - *

Classes extending UserJob may have multiple instances executing within the scheduler at once

- * - * @author Adam Retter - */ -public abstract class UserJob implements JobDescription, org.quartz.Job { - - public static String JOB_GROUP = "eXist.User"; - - @Override - public final String getGroup() { - return JOB_GROUP; - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2006 The eXist team + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id$ + */ +package org.exist.scheduler; + +/** + * Class to represent a User's Job Should be extended by all classes wishing to schedule as a Job that perform user defined functions. + * + *

Classes extending UserJob may have multiple instances executing within the scheduler at once

+ * + * @author Adam Retter + */ +public abstract class UserJob implements JobDescription, org.quartz.Job { + + public static String JOB_GROUP = "eXist.User"; + + @Override + public final String getGroup() { + return JOB_GROUP; + } +} diff --git a/src/org/exist/scheduler/UserXQueryJob.java b/src/org/exist/scheduler/UserXQueryJob.java index ee4f4337253..db9b66e1701 100644 --- a/src/org/exist/scheduler/UserXQueryJob.java +++ b/src/org/exist/scheduler/UserXQueryJob.java @@ -1,266 +1,266 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2011 The eXist-db team - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ -package org.exist.scheduler; - -import java.io.IOException; -import java.net.MalformedURLException; -import java.util.Map.Entry; -import java.util.Properties; -import org.apache.log4j.Logger; -import org.exist.EXistException; -import org.exist.dom.BinaryDocument; -import org.exist.dom.DocumentImpl; -import org.exist.security.PermissionDeniedException; -import org.exist.security.Subject; -import org.exist.security.xacml.AccessContext; -import org.exist.source.DBSource; -import org.exist.source.Source; -import org.exist.source.SourceFactory; -import org.exist.storage.BrokerPool; -import org.exist.storage.DBBroker; -import org.exist.storage.XQueryPool; -import org.exist.storage.lock.Lock; -import org.exist.xmldb.XmldbURI; -import org.exist.xquery.CompiledXQuery; -import org.exist.xquery.XPathException; -import org.exist.xquery.XQuery; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.value.StringValue; -import org.quartz.JobDataMap; -import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; - - -/** - * Class to represent a User's XQuery Job Extends UserJob. - * - * @author Adam Retter - * @author Andrzej Taramina - */ -public class UserXQueryJob extends UserJob { - - protected final static Logger LOG = Logger.getLogger(UserXQueryJob.class); - - private final String DEFAULT_JOB_NAME_PREFIX = "XQuery"; - - private String name; - private final String xqueryResource; - private final Subject user; - - /** - * Default Constructor for Quartz. - */ - public UserXQueryJob(){ - xqueryResource = null; - user = null; - } - - - /** - * Constructor for Creating a new XQuery User Job. - * - * @param jobName The name of the job - * @param xqueryResource The XQuery itself - * @param user The user under which the xquery should be executed - */ - public UserXQueryJob(final String jobName, final String xqueryResource, final Subject user) { - this.xqueryResource = xqueryResource; - this.user = user; - - if(jobName == null) { - this.name = DEFAULT_JOB_NAME_PREFIX + ": " + xqueryResource; - } else { - this.name = jobName; - } - } - - @Override - public final String getName() { - return name ; - } - - @Override - public void setName(final String name) { - this.name = name; - } - - /** - * Returns the XQuery Resource for this Job. - * - * @return The XQuery Resource for this Job - */ - public String getXQueryResource() { - return xqueryResource; - } - - /** - * Returns the User for this Job. - * - * @return The User for this Job - */ - public Subject getUser() { - return user; - } - - @Override - public final void execute(final JobExecutionContext jec) throws JobExecutionException { - - final JobDataMap jobDataMap = jec.getJobDetail().getJobDataMap(); - - //TODO why are these values not used from the class members? - final String xqueryresource = (String)jobDataMap.get("xqueryresource"); - final Subject user = (Subject)jobDataMap.get("user"); - - final BrokerPool pool = (BrokerPool)jobDataMap.get("brokerpool"); - final Properties params = (Properties)jobDataMap.get("params"); - final boolean unschedule = ((Boolean)jobDataMap.get("unschedule")).booleanValue(); - - //if invalid arguments then abort - if((pool == null) || (xqueryresource == null) || (user == null)) { - abort("BrokerPool or XQueryResource or User was null!"); - } - - DBBroker broker = null; - DocumentImpl resource = null; - Source source = null; - XQueryPool xqPool = null; - CompiledXQuery compiled = null; - XQueryContext context = null; - - try { - - //get the xquery - broker = pool.get(user); - - if(xqueryresource.indexOf(':') > 0) { - source = SourceFactory.getSource(broker, "", xqueryresource, true); - } else { - final XmldbURI pathUri = XmldbURI.create(xqueryresource); - resource = broker.getXMLResource(pathUri, Lock.READ_LOCK); - - if(resource != null) { - source = new DBSource(broker, (BinaryDocument)resource, true); - } - } - - if(source != null) { - - //execute the xquery - final XQuery xquery = broker.getXQueryService(); - xqPool = xquery.getXQueryPool(); - - //try and get a pre-compiled query from the pool - compiled = xqPool.borrowCompiledXQuery(broker, source); - - if(compiled == null) { - context = xquery.newContext(AccessContext.REST); //TODO should probably have its own AccessContext.SCHEDULER - } else { - context = compiled.getContext(); - } - - //TODO: don't hardcode this? - if(resource != null) { - context.setModuleLoadPath(XmldbURI.EMBEDDED_SERVER_URI.append(resource.getCollection().getURI()).toString()); - context.setStaticallyKnownDocuments(new XmldbURI[] { - resource.getCollection().getURI() - }); - } - - if(compiled == null) { - - try { - compiled = xquery.compile(context, source); - } - catch(final IOException e) { - abort("Failed to read query from " + xqueryresource); - } - } - - //declare any parameters as external variables - if(params != null) { - String bindingPrefix = params.getProperty("bindingPrefix"); - - if(bindingPrefix == null) { - bindingPrefix = "local"; - } - - - for(final Entry param : params.entrySet()) { - final String key = (String)param.getKey(); - final String value = (String)param.getValue(); - context.declareVariable( bindingPrefix + ":" + key, new StringValue(value)); - } - } - - xquery.execute(compiled, null); - - } else { - LOG.warn("XQuery User Job not found: " + xqueryresource + ", job not scheduled"); - } - } catch(final EXistException ee) { - abort("Could not get DBBroker!"); - } catch(final PermissionDeniedException pde) { - abort("Permission denied for the scheduling user: " + user.getName() + "!"); - } catch(final XPathException xpe) { - abort("XPathException in the Job: " + xpe.getMessage() + "!", unschedule); - } catch(final MalformedURLException e) { - abort("Could not load XQuery: " + e.getMessage()); - } catch(final IOException e) { - abort("Could not load XQuery: " + e.getMessage()); - } finally { - - if(context != null) { - context.runCleanupTasks(); - } - - //return the compiled query to the pool - if(xqPool != null && source != null && compiled != null) { - xqPool.returnCompiledXQuery(source, compiled); - } - - //release the lock on the xquery resource - if(resource != null) { - resource.getUpdateLock().release(Lock.READ_LOCK); - } - - // Release the DBBroker - if(pool != null && broker != null) { - pool.release(broker); - } - } - - } - - private void abort(final String message) throws JobExecutionException { - abort(message, true); - } - - - private void abort(final String message, final boolean unschedule) throws JobExecutionException { - final JobExecutionException jaa = new JobExecutionException("UserXQueryJob Failed: " + message + (unschedule ? " Unscheduling UserXQueryJob." : ""), false); - - //abort all triggers for this job if specified that we should unschedule the job - jaa.setUnscheduleAllTriggers(unschedule); - - throw jaa; - } +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2011 The eXist-db team + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id$ + */ +package org.exist.scheduler; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.util.Map.Entry; +import java.util.Properties; +import org.apache.log4j.Logger; +import org.exist.EXistException; +import org.exist.dom.BinaryDocument; +import org.exist.dom.DocumentImpl; +import org.exist.security.PermissionDeniedException; +import org.exist.security.Subject; +import org.exist.security.xacml.AccessContext; +import org.exist.source.DBSource; +import org.exist.source.Source; +import org.exist.source.SourceFactory; +import org.exist.storage.BrokerPool; +import org.exist.storage.DBBroker; +import org.exist.storage.XQueryPool; +import org.exist.storage.lock.Lock; +import org.exist.xmldb.XmldbURI; +import org.exist.xquery.CompiledXQuery; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQuery; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.value.StringValue; +import org.quartz.JobDataMap; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + + +/** + * Class to represent a User's XQuery Job Extends UserJob. + * + * @author Adam Retter + * @author Andrzej Taramina + */ +public class UserXQueryJob extends UserJob { + + protected final static Logger LOG = Logger.getLogger(UserXQueryJob.class); + + private final String DEFAULT_JOB_NAME_PREFIX = "XQuery"; + + private String name; + private final String xqueryResource; + private final Subject user; + + /** + * Default Constructor for Quartz. + */ + public UserXQueryJob(){ + xqueryResource = null; + user = null; + } + + + /** + * Constructor for Creating a new XQuery User Job. + * + * @param jobName The name of the job + * @param xqueryResource The XQuery itself + * @param user The user under which the xquery should be executed + */ + public UserXQueryJob(final String jobName, final String xqueryResource, final Subject user) { + this.xqueryResource = xqueryResource; + this.user = user; + + if(jobName == null) { + this.name = DEFAULT_JOB_NAME_PREFIX + ": " + xqueryResource; + } else { + this.name = jobName; + } + } + + @Override + public final String getName() { + return name ; + } + + @Override + public void setName(final String name) { + this.name = name; + } + + /** + * Returns the XQuery Resource for this Job. + * + * @return The XQuery Resource for this Job + */ + public String getXQueryResource() { + return xqueryResource; + } + + /** + * Returns the User for this Job. + * + * @return The User for this Job + */ + public Subject getUser() { + return user; + } + + @Override + public final void execute(final JobExecutionContext jec) throws JobExecutionException { + + final JobDataMap jobDataMap = jec.getJobDetail().getJobDataMap(); + + //TODO why are these values not used from the class members? + final String xqueryresource = (String)jobDataMap.get("xqueryresource"); + final Subject user = (Subject)jobDataMap.get("user"); + + final BrokerPool pool = (BrokerPool)jobDataMap.get("brokerpool"); + final Properties params = (Properties)jobDataMap.get("params"); + final boolean unschedule = ((Boolean)jobDataMap.get("unschedule")).booleanValue(); + + //if invalid arguments then abort + if((pool == null) || (xqueryresource == null) || (user == null)) { + abort("BrokerPool or XQueryResource or User was null!"); + } + + DBBroker broker = null; + DocumentImpl resource = null; + Source source = null; + XQueryPool xqPool = null; + CompiledXQuery compiled = null; + XQueryContext context = null; + + try { + + //get the xquery + broker = pool.get(user); + + if(xqueryresource.indexOf(':') > 0) { + source = SourceFactory.getSource(broker, "", xqueryresource, true); + } else { + final XmldbURI pathUri = XmldbURI.create(xqueryresource); + resource = broker.getXMLResource(pathUri, Lock.READ_LOCK); + + if(resource != null) { + source = new DBSource(broker, (BinaryDocument)resource, true); + } + } + + if(source != null) { + + //execute the xquery + final XQuery xquery = broker.getXQueryService(); + xqPool = xquery.getXQueryPool(); + + //try and get a pre-compiled query from the pool + compiled = xqPool.borrowCompiledXQuery(broker, source); + + if(compiled == null) { + context = xquery.newContext(AccessContext.REST); //TODO should probably have its own AccessContext.SCHEDULER + } else { + context = compiled.getContext(); + } + + //TODO: don't hardcode this? + if(resource != null) { + context.setModuleLoadPath(XmldbURI.EMBEDDED_SERVER_URI.append(resource.getCollection().getURI()).toString()); + context.setStaticallyKnownDocuments(new XmldbURI[] { + resource.getCollection().getURI() + }); + } + + if(compiled == null) { + + try { + compiled = xquery.compile(context, source); + } + catch(final IOException e) { + abort("Failed to read query from " + xqueryresource); + } + } + + //declare any parameters as external variables + if(params != null) { + String bindingPrefix = params.getProperty("bindingPrefix"); + + if(bindingPrefix == null) { + bindingPrefix = "local"; + } + + + for(final Entry param : params.entrySet()) { + final String key = (String)param.getKey(); + final String value = (String)param.getValue(); + context.declareVariable( bindingPrefix + ":" + key, new StringValue(value)); + } + } + + xquery.execute(compiled, null); + + } else { + LOG.warn("XQuery User Job not found: " + xqueryresource + ", job not scheduled"); + } + } catch(final EXistException ee) { + abort("Could not get DBBroker!"); + } catch(final PermissionDeniedException pde) { + abort("Permission denied for the scheduling user: " + user.getName() + "!"); + } catch(final XPathException xpe) { + abort("XPathException in the Job: " + xpe.getMessage() + "!", unschedule); + } catch(final MalformedURLException e) { + abort("Could not load XQuery: " + e.getMessage()); + } catch(final IOException e) { + abort("Could not load XQuery: " + e.getMessage()); + } finally { + + if(context != null) { + context.runCleanupTasks(); + } + + //return the compiled query to the pool + if(xqPool != null && source != null && compiled != null) { + xqPool.returnCompiledXQuery(source, compiled); + } + + //release the lock on the xquery resource + if(resource != null) { + resource.getUpdateLock().release(Lock.READ_LOCK); + } + + // Release the DBBroker + if(pool != null && broker != null) { + pool.release(broker); + } + } + + } + + private void abort(final String message) throws JobExecutionException { + abort(message, true); + } + + + private void abort(final String message, final boolean unschedule) throws JobExecutionException { + final JobExecutionException jaa = new JobExecutionException("UserXQueryJob Failed: " + message + (unschedule ? " Unscheduling UserXQueryJob." : ""), false); + + //abort all triggers for this job if specified that we should unschedule the job + jaa.setUnscheduleAllTriggers(unschedule); + + throw jaa; + } } \ No newline at end of file diff --git a/src/org/exist/scheduler/impl/SystemTaskJobImpl.java b/src/org/exist/scheduler/impl/SystemTaskJobImpl.java index 10e6a2d2628..00ea6cbabdf 100644 --- a/src/org/exist/scheduler/impl/SystemTaskJobImpl.java +++ b/src/org/exist/scheduler/impl/SystemTaskJobImpl.java @@ -1,117 +1,117 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2006 The eXist team - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ -package org.exist.scheduler.impl; - -import org.exist.scheduler.SystemTaskJob; -import org.exist.storage.BrokerPool; -import org.exist.storage.SystemTask; -import org.quartz.JobDataMap; -import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; -import org.quartz.StatefulJob; - - -/** - * Class to represent a SystemTask Job Can be used by SystemTasks to schedule themselves as job's. - * - *

SystemTaskJobs may only have a Single Instance running in the scheduler at once, intersecting schedules will be queued.

- * - * @author Adam Retter - */ -public class SystemTaskJobImpl implements SystemTaskJob, StatefulJob { - - private final static String JOB_GROUP = "eXist.System"; - private String name = "SystemTask"; - - private SystemTask task = null; - - /** - * Default Constructor for Quartz. - */ - public SystemTaskJobImpl() { - } - - - /** - * Constructor for Creating a new SystemTask Job. - * - * @param jobName DOCUMENT ME! - * @param task DOCUMENT ME! - */ - public SystemTaskJobImpl(final String jobName, final SystemTask task) { - this.task = task; - - if(jobName == null) { - this.name += ": " + task.getClass().getName(); - } else { - this.name = jobName; - } - } - - @Override - public final String getName() { - return name; - } - - - @Override - public final void setName(final String name) - { - this.name = name; - } - - - @Override - public final String getGroup() { - return JOB_GROUP; - } - - - /** - * Returns the SystemTask for this Job. - * - * @return The SystemTask for this Job - */ - protected SystemTask getSystemTask() { - return task; - } - - - @Override - public final void execute(final JobExecutionContext jec) throws JobExecutionException { - final JobDataMap jobDataMap = jec.getJobDetail().getJobDataMap(); - final BrokerPool pool = (BrokerPool)jobDataMap.get("brokerpool"); - final SystemTask task = ( SystemTask )jobDataMap.get("systemtask"); - - //if invalid arguments then abort - if((pool == null) || (task == null)) { - - //abort all triggers for this job - final JobExecutionException jaa = new JobExecutionException("SystemTaskJob Failed: BrokerPool or SystemTask was null! Unscheduling SystemTask", false); - jaa.setUnscheduleAllTriggers( true ); - throw jaa; - } - - //trigger the system task - pool.triggerSystemTask(task); - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2006 The eXist team + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id$ + */ +package org.exist.scheduler.impl; + +import org.exist.scheduler.SystemTaskJob; +import org.exist.storage.BrokerPool; +import org.exist.storage.SystemTask; +import org.quartz.JobDataMap; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; +import org.quartz.StatefulJob; + + +/** + * Class to represent a SystemTask Job Can be used by SystemTasks to schedule themselves as job's. + * + *

SystemTaskJobs may only have a Single Instance running in the scheduler at once, intersecting schedules will be queued.

+ * + * @author Adam Retter + */ +public class SystemTaskJobImpl implements SystemTaskJob, StatefulJob { + + private final static String JOB_GROUP = "eXist.System"; + private String name = "SystemTask"; + + private SystemTask task = null; + + /** + * Default Constructor for Quartz. + */ + public SystemTaskJobImpl() { + } + + + /** + * Constructor for Creating a new SystemTask Job. + * + * @param jobName DOCUMENT ME! + * @param task DOCUMENT ME! + */ + public SystemTaskJobImpl(final String jobName, final SystemTask task) { + this.task = task; + + if(jobName == null) { + this.name += ": " + task.getClass().getName(); + } else { + this.name = jobName; + } + } + + @Override + public final String getName() { + return name; + } + + + @Override + public final void setName(final String name) + { + this.name = name; + } + + + @Override + public final String getGroup() { + return JOB_GROUP; + } + + + /** + * Returns the SystemTask for this Job. + * + * @return The SystemTask for this Job + */ + protected SystemTask getSystemTask() { + return task; + } + + + @Override + public final void execute(final JobExecutionContext jec) throws JobExecutionException { + final JobDataMap jobDataMap = jec.getJobDetail().getJobDataMap(); + final BrokerPool pool = (BrokerPool)jobDataMap.get("brokerpool"); + final SystemTask task = ( SystemTask )jobDataMap.get("systemtask"); + + //if invalid arguments then abort + if((pool == null) || (task == null)) { + + //abort all triggers for this job + final JobExecutionException jaa = new JobExecutionException("SystemTaskJob Failed: BrokerPool or SystemTask was null! Unscheduling SystemTask", false); + jaa.setUnscheduleAllTriggers( true ); + throw jaa; + } + + //trigger the system task + pool.triggerSystemTask(task); + } +} diff --git a/src/org/exist/security/UUIDGenerator.java b/src/org/exist/security/UUIDGenerator.java index 03a430215a8..346bde57bf2 100644 --- a/src/org/exist/security/UUIDGenerator.java +++ b/src/org/exist/security/UUIDGenerator.java @@ -1,71 +1,71 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2011 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id$ - */ -package org.exist.security; - -import java.util.UUID; - -import org.apache.log4j.Logger; - -/** - * UUID or GUID generator. The random code is generated by java's - * UUID-class. - * - * - * @author Dannes Wessels - */ -//TODO: move to utils ? -shabanovd -public class UUIDGenerator { - - @SuppressWarnings("unused") - private final static Logger LOG = Logger.getLogger(UUIDGenerator.class); - - /** - * Generate random UUID code. - * - * @return UUID code, formatted as f271ec43-bf1f-4030-a269-b11576538f71 - */ - public static String getUUID(){ - - return getUUIDversion4(); - } - - /** - * Return version 4 UUID code (random). - * Check Wikipedia - */ - public static String getUUIDversion4(){ - return UUID.randomUUID().toString(); - } - - /** - * Return version 3 UUID code (derived from value). - * Check Wikipedia - * @param value Initialization value. - */ - public static String getUUIDversion3(String value){ - return UUID.nameUUIDFromBytes(value.getBytes()).toString(); - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2011 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ +package org.exist.security; + +import java.util.UUID; + +import org.apache.log4j.Logger; + +/** + * UUID or GUID generator. The random code is generated by java's + * UUID-class. + * + * + * @author Dannes Wessels + */ +//TODO: move to utils ? -shabanovd +public class UUIDGenerator { + + @SuppressWarnings("unused") + private final static Logger LOG = Logger.getLogger(UUIDGenerator.class); + + /** + * Generate random UUID code. + * + * @return UUID code, formatted as f271ec43-bf1f-4030-a269-b11576538f71 + */ + public static String getUUID(){ + + return getUUIDversion4(); + } + + /** + * Return version 4 UUID code (random). + * Check Wikipedia + */ + public static String getUUIDversion4(){ + return UUID.randomUUID().toString(); + } + + /** + * Return version 3 UUID code (derived from value). + * Check Wikipedia + * @param value Initialization value. + */ + public static String getUUIDversion3(String value){ + return UUID.nameUUIDFromBytes(value.getBytes()).toString(); + } +} diff --git a/src/org/exist/security/internal/EventAuthentication.java b/src/org/exist/security/internal/EventAuthentication.java index a2f998067ce..feb22fba5a4 100644 --- a/src/org/exist/security/internal/EventAuthentication.java +++ b/src/org/exist/security/internal/EventAuthentication.java @@ -1,69 +1,69 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2012 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.security.internal; - -import org.exist.EventListener; -import org.exist.config.Configurable; -import org.exist.config.Configuration; -import org.exist.config.Configurator; -import org.exist.config.annotation.ConfigurationClass; -import org.exist.dom.QName; -import org.exist.security.Subject; - -/** - * @author Dmitriy Shabanov - * - */ -@ConfigurationClass("authentication") -public class EventAuthentication implements EventListener, Configurable { - - protected final static QName functionName = new QName("authentication", SMEvents.NAMESPACE_URI); - - //XXX: @ConfigurationFieldAsText - private String script = ""; - - private SMEvents em; - - private Configuration configuration = null; - - public EventAuthentication(SMEvents em, Configuration config) { - this.em = em; - - configuration = Configurator.configure(this, config); - } - - @Override - public void onEvent(Subject subject) { - em.runScript(subject, null, script, functionName, null); - } - - @Override - public boolean isConfigured() { - return configuration != null; - } - - @Override - public Configuration getConfiguration() { - return configuration; - } - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2012 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.security.internal; + +import org.exist.EventListener; +import org.exist.config.Configurable; +import org.exist.config.Configuration; +import org.exist.config.Configurator; +import org.exist.config.annotation.ConfigurationClass; +import org.exist.dom.QName; +import org.exist.security.Subject; + +/** + * @author Dmitriy Shabanov + * + */ +@ConfigurationClass("authentication") +public class EventAuthentication implements EventListener, Configurable { + + protected final static QName functionName = new QName("authentication", SMEvents.NAMESPACE_URI); + + //XXX: @ConfigurationFieldAsText + private String script = ""; + + private SMEvents em; + + private Configuration configuration = null; + + public EventAuthentication(SMEvents em, Configuration config) { + this.em = em; + + configuration = Configurator.configure(this, config); + } + + @Override + public void onEvent(Subject subject) { + em.runScript(subject, null, script, functionName, null); + } + + @Override + public boolean isConfigured() { + return configuration != null; + } + + @Override + public Configuration getConfiguration() { + return configuration; + } + +} diff --git a/src/org/exist/security/internal/SMEvents.java b/src/org/exist/security/internal/SMEvents.java index 5bce70a2881..b1f001a34da 100644 --- a/src/org/exist/security/internal/SMEvents.java +++ b/src/org/exist/security/internal/SMEvents.java @@ -1,193 +1,193 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2012 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.security.internal; - -import java.util.List; - -import org.exist.Database; -import org.exist.config.Configurable; -import org.exist.config.Configuration; -import org.exist.config.Configurator; -import org.exist.config.annotation.ConfigurationClass; -import org.exist.config.annotation.ConfigurationFieldAsAttribute; -import org.exist.config.annotation.ConfigurationFieldAsElement; -import org.exist.dom.BinaryDocument; -import org.exist.dom.DocumentImpl; -import org.exist.dom.NodeSet; -import org.exist.dom.QName; -import org.exist.security.PermissionDeniedException; -import org.exist.security.SecurityManager; -import org.exist.security.Subject; -import org.exist.security.xacml.AccessContext; -import org.exist.source.DBSource; -import org.exist.source.Source; -import org.exist.source.StringSource; -import org.exist.storage.DBBroker; -import org.exist.storage.ProcessMonitor; -import org.exist.storage.lock.Lock; -import org.exist.xmldb.XmldbURI; -import org.exist.xquery.AnalyzeContextInfo; -import org.exist.xquery.CompiledXQuery; -import org.exist.xquery.Expression; -import org.exist.xquery.FunctionCall; -import org.exist.xquery.UserDefinedFunction; -import org.exist.xquery.XPathException; -import org.exist.xquery.XQuery; -import org.exist.xquery.XQueryContext; - -/** - * @author Dmitriy Shabanov - * - */ -@ConfigurationClass("events") -public class SMEvents implements Configurable { - - public final static String NAMESPACE_URI = "http://exist-db.org/security/events"; - public final static String PREFIX = "sec-ev"; //security-events //secev //sev - - @ConfigurationFieldAsAttribute("script-uri") - protected String scriptURI = ""; - - @ConfigurationFieldAsElement("authentication") - protected EventAuthentication authentication = null; - - protected SecurityManager sm; - - private Configuration configuration = null; - - public SMEvents(SecurityManagerImpl sm, Configuration config) { - this.sm = sm; - - configuration = Configurator.configure(this, config); - } - - public Database getDatabase() { - return sm.getDatabase(); - } - - public SecurityManager getSecurityManager() { - return sm; - } - - protected void authenticated(Subject subject) { - if (authentication == null) { -// List args = new ArrayList(2); -// args.add(new LiteralValue(context, new StringValue(subject.getRealmId()) )); -// args.add(new LiteralValue(context, new StringValue(subject.getName()) )); - runScript(subject, scriptURI, null, EventAuthentication.functionName, null); - } else { - authentication.onEvent(subject); - } - } - - protected void runScript(Subject subject, String scriptURI, String script, QName functionName, List args) { - - final Database db = getDatabase(); - DBBroker broker = null; - try { - broker = db.get(subject); - - final Source source = getQuerySource(broker, scriptURI, script); - if(source == null) {return;} - - final XQuery xquery = broker.getXQueryService(); - final XQueryContext context = xquery.newContext(AccessContext.XMLDB); - - final CompiledXQuery compiled = xquery.compile(context, source); - -// Sequence result = xquery.execute(compiled, subject.getName()); - - final ProcessMonitor pm = db.getProcessMonitor(); - - //execute the XQuery - try { - final UserDefinedFunction function = context.resolveFunction(functionName, 0); - if (function != null) { - context.getProfiler().traceQueryStart(); - pm.queryStarted(context.getWatchDog()); - - final FunctionCall call = new FunctionCall(context, function); - if (args != null) - {call.setArguments(args);} - call.analyze(new AnalyzeContextInfo()); - call.eval(NodeSet.EMPTY_SET); - } - } catch(final XPathException e) { - //XXX: log - e.printStackTrace(); - } finally { - if (pm != null) { - context.getProfiler().traceQueryEnd(context); - pm.queryCompleted(context.getWatchDog()); - } - compiled.reset(); - context.reset(); - } - - } catch (final Exception e) { - //XXX: log - e.printStackTrace(); - } finally { - db.release(broker); - } - } - - private Source getQuerySource(DBBroker broker, String scriptURI, String script) { - if(scriptURI != null) { - DocumentImpl resource = null; - try { - final XmldbURI pathUri = XmldbURI.create(scriptURI); - - resource = broker.getXMLResource(pathUri, Lock.READ_LOCK); - if (resource != null) - {return new DBSource(broker, (BinaryDocument)resource, true);} - - } catch (final PermissionDeniedException e) { - //XXX: log - e.printStackTrace(); - } finally { - if(resource != null) - {resource.getUpdateLock().release(Lock.READ_LOCK);} - } - -// try { -// querySource = SourceFactory.getSource(broker, null, scriptURI, false); -// } catch(Exception e) { -// //LOG.error(e); -// } - } else if(script != null && !script.isEmpty()) { - return new StringSource(script); - } - - return null; - } - - @Override - public boolean isConfigured() { - return configuration != null; - } - - @Override - public Configuration getConfiguration() { - return configuration; - } +/* + * eXist Open Source Native XML Database + * Copyright (C) 2012 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.security.internal; + +import java.util.List; + +import org.exist.Database; +import org.exist.config.Configurable; +import org.exist.config.Configuration; +import org.exist.config.Configurator; +import org.exist.config.annotation.ConfigurationClass; +import org.exist.config.annotation.ConfigurationFieldAsAttribute; +import org.exist.config.annotation.ConfigurationFieldAsElement; +import org.exist.dom.BinaryDocument; +import org.exist.dom.DocumentImpl; +import org.exist.dom.NodeSet; +import org.exist.dom.QName; +import org.exist.security.PermissionDeniedException; +import org.exist.security.SecurityManager; +import org.exist.security.Subject; +import org.exist.security.xacml.AccessContext; +import org.exist.source.DBSource; +import org.exist.source.Source; +import org.exist.source.StringSource; +import org.exist.storage.DBBroker; +import org.exist.storage.ProcessMonitor; +import org.exist.storage.lock.Lock; +import org.exist.xmldb.XmldbURI; +import org.exist.xquery.AnalyzeContextInfo; +import org.exist.xquery.CompiledXQuery; +import org.exist.xquery.Expression; +import org.exist.xquery.FunctionCall; +import org.exist.xquery.UserDefinedFunction; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQuery; +import org.exist.xquery.XQueryContext; + +/** + * @author Dmitriy Shabanov + * + */ +@ConfigurationClass("events") +public class SMEvents implements Configurable { + + public final static String NAMESPACE_URI = "http://exist-db.org/security/events"; + public final static String PREFIX = "sec-ev"; //security-events //secev //sev + + @ConfigurationFieldAsAttribute("script-uri") + protected String scriptURI = ""; + + @ConfigurationFieldAsElement("authentication") + protected EventAuthentication authentication = null; + + protected SecurityManager sm; + + private Configuration configuration = null; + + public SMEvents(SecurityManagerImpl sm, Configuration config) { + this.sm = sm; + + configuration = Configurator.configure(this, config); + } + + public Database getDatabase() { + return sm.getDatabase(); + } + + public SecurityManager getSecurityManager() { + return sm; + } + + protected void authenticated(Subject subject) { + if (authentication == null) { +// List args = new ArrayList(2); +// args.add(new LiteralValue(context, new StringValue(subject.getRealmId()) )); +// args.add(new LiteralValue(context, new StringValue(subject.getName()) )); + runScript(subject, scriptURI, null, EventAuthentication.functionName, null); + } else { + authentication.onEvent(subject); + } + } + + protected void runScript(Subject subject, String scriptURI, String script, QName functionName, List args) { + + final Database db = getDatabase(); + DBBroker broker = null; + try { + broker = db.get(subject); + + final Source source = getQuerySource(broker, scriptURI, script); + if(source == null) {return;} + + final XQuery xquery = broker.getXQueryService(); + final XQueryContext context = xquery.newContext(AccessContext.XMLDB); + + final CompiledXQuery compiled = xquery.compile(context, source); + +// Sequence result = xquery.execute(compiled, subject.getName()); + + final ProcessMonitor pm = db.getProcessMonitor(); + + //execute the XQuery + try { + final UserDefinedFunction function = context.resolveFunction(functionName, 0); + if (function != null) { + context.getProfiler().traceQueryStart(); + pm.queryStarted(context.getWatchDog()); + + final FunctionCall call = new FunctionCall(context, function); + if (args != null) + {call.setArguments(args);} + call.analyze(new AnalyzeContextInfo()); + call.eval(NodeSet.EMPTY_SET); + } + } catch(final XPathException e) { + //XXX: log + e.printStackTrace(); + } finally { + if (pm != null) { + context.getProfiler().traceQueryEnd(context); + pm.queryCompleted(context.getWatchDog()); + } + compiled.reset(); + context.reset(); + } + + } catch (final Exception e) { + //XXX: log + e.printStackTrace(); + } finally { + db.release(broker); + } + } + + private Source getQuerySource(DBBroker broker, String scriptURI, String script) { + if(scriptURI != null) { + DocumentImpl resource = null; + try { + final XmldbURI pathUri = XmldbURI.create(scriptURI); + + resource = broker.getXMLResource(pathUri, Lock.READ_LOCK); + if (resource != null) + {return new DBSource(broker, (BinaryDocument)resource, true);} + + } catch (final PermissionDeniedException e) { + //XXX: log + e.printStackTrace(); + } finally { + if(resource != null) + {resource.getUpdateLock().release(Lock.READ_LOCK);} + } + +// try { +// querySource = SourceFactory.getSource(broker, null, scriptURI, false); +// } catch(Exception e) { +// //LOG.error(e); +// } + } else if(script != null && !script.isEmpty()) { + return new StringSource(script); + } + + return null; + } + + @Override + public boolean isConfigured() { + return configuration != null; + } + + @Override + public Configuration getConfiguration() { + return configuration; + } } \ No newline at end of file diff --git a/src/org/exist/soap/admin.wsdl b/src/org/exist/soap/admin.wsdl index cceb29ee1cb..47649944f8c 100644 --- a/src/org/exist/soap/admin.wsdl +++ b/src/org/exist/soap/admin.wsdl @@ -1,127 +1,127 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -173,8 +173,8 @@ Built on Jun 14, 2005 (09:15:57 EDT)--> - + @@ -427,8 +427,8 @@ Built on Jun 14, 2005 (09:15:57 EDT)--> - + @@ -474,8 +474,8 @@ Built on Jun 14, 2005 (09:15:57 EDT)--> - + @@ -491,8 +491,8 @@ Built on Jun 14, 2005 (09:15:57 EDT)--> - @@ -506,366 +506,366 @@ Built on Jun 14, 2005 (09:15:57 EDT)--> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -933,8 +933,8 @@ Built on Jun 14, 2005 (09:15:57 EDT)--> - + @@ -949,156 +949,156 @@ Built on Jun 14, 2005 (09:15:57 EDT)--> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1119,16 +1119,16 @@ Built on Jun 14, 2005 (09:15:57 EDT)--> - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/src/org/exist/soap/deployAdmin.wsdd b/src/org/exist/soap/deployAdmin.wsdd index bf57d3d2e9a..c3b01c24136 100644 --- a/src/org/exist/soap/deployAdmin.wsdd +++ b/src/org/exist/soap/deployAdmin.wsdd @@ -1,123 +1,123 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org/exist/soap/deployQuery.wsdd b/src/org/exist/soap/deployQuery.wsdd index 6f7ed8c41ce..1a286127703 100644 --- a/src/org/exist/soap/deployQuery.wsdd +++ b/src/org/exist/soap/deployQuery.wsdd @@ -1,91 +1,91 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org/exist/soap/query.wsdl b/src/org/exist/soap/query.wsdl index dee0a2fbcd8..e97a06ca3f2 100644 --- a/src/org/exist/soap/query.wsdl +++ b/src/org/exist/soap/query.wsdl @@ -1,620 +1,620 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org/exist/soap/undeployAdmin.wsdd b/src/org/exist/soap/undeployAdmin.wsdd index 4f8119d7905..badaea3c232 100644 --- a/src/org/exist/soap/undeployAdmin.wsdd +++ b/src/org/exist/soap/undeployAdmin.wsdd @@ -1,15 +1,15 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/src/org/exist/soap/undeployQuery.wsdd b/src/org/exist/soap/undeployQuery.wsdd index 69d92f41d6d..efae6e33fae 100644 --- a/src/org/exist/soap/undeployQuery.wsdd +++ b/src/org/exist/soap/undeployQuery.wsdd @@ -1,15 +1,15 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/src/org/exist/source/StringSourceWithMapKey.java b/src/org/exist/source/StringSourceWithMapKey.java index 25932bba08a..f155e471d2b 100644 --- a/src/org/exist/source/StringSourceWithMapKey.java +++ b/src/org/exist/source/StringSourceWithMapKey.java @@ -1,49 +1,49 @@ -package org.exist.source; - -import java.io.*; -import java.util.Map; - -import org.exist.security.PermissionDeniedException; -import org.exist.security.Subject; -import org.exist.storage.DBBroker; - -/** - * A simple source object wrapping a single query string, but associating it with a specific - * map (e.g., of namespace bindings). This prevents two textually equal queries with different - * maps from getting aliased in the query pool. - * - * @author Piotr Kaminski - */ -public class StringSourceWithMapKey extends AbstractSource { - private final Map map; - - /** - * Create a new source for the given content and namespace map (string to string). - * The map will be taken over and modified by the source, so make a copy first if - * you're passing a shared one. - * - * @param content the content of the query - * @param map the map of prefixes to namespace URIs - */ - public StringSourceWithMapKey(String content, Map map) { - this.map = map; - this.map.put("", content); - } - - public Object getKey() {return map;} - public int isValid(DBBroker broker) {return Source.VALID;} - public int isValid(Source other) {return Source.VALID;} - public Reader getReader() throws IOException {return new StringReader(map.get(""));} - - public InputStream getInputStream() throws IOException { - // not implemented - return null; - } - - public String getContent() throws IOException {return map.get("");} - - @Override - public void validate(Subject subject, int perm) throws PermissionDeniedException { - // TODO protected? - } +package org.exist.source; + +import java.io.*; +import java.util.Map; + +import org.exist.security.PermissionDeniedException; +import org.exist.security.Subject; +import org.exist.storage.DBBroker; + +/** + * A simple source object wrapping a single query string, but associating it with a specific + * map (e.g., of namespace bindings). This prevents two textually equal queries with different + * maps from getting aliased in the query pool. + * + * @author Piotr Kaminski + */ +public class StringSourceWithMapKey extends AbstractSource { + private final Map map; + + /** + * Create a new source for the given content and namespace map (string to string). + * The map will be taken over and modified by the source, so make a copy first if + * you're passing a shared one. + * + * @param content the content of the query + * @param map the map of prefixes to namespace URIs + */ + public StringSourceWithMapKey(String content, Map map) { + this.map = map; + this.map.put("", content); + } + + public Object getKey() {return map;} + public int isValid(DBBroker broker) {return Source.VALID;} + public int isValid(Source other) {return Source.VALID;} + public Reader getReader() throws IOException {return new StringReader(map.get(""));} + + public InputStream getInputStream() throws IOException { + // not implemented + return null; + } + + public String getContent() throws IOException {return map.get("");} + + @Override + public void validate(Subject subject, int perm) throws PermissionDeniedException { + // TODO protected? + } } \ No newline at end of file diff --git a/src/org/exist/start/LatestFileResolver.java b/src/org/exist/start/LatestFileResolver.java index b4d08d97af6..894875f8e05 100644 --- a/src/org/exist/start/LatestFileResolver.java +++ b/src/org/exist/start/LatestFileResolver.java @@ -1,113 +1,113 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-06 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ - -package org.exist.start; - -import java.io.File; -import java.io.FilenameFilter; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * This class uses regex pattern matching to find the latest version of a - * particular jar file. - * - * @see LatestFileResolver#getResolvedFileName(String) - * - * @author Ben Schmaus (exist@benschmaus.com) - * @version $Revision$ - */ -public class LatestFileResolver { - - // Pattern that can be used to indicate that the - // latest version of a particular file should be added to the classpath. - // E.g., commons-fileupload-%latest%.jar would resolve to something like - // commons-fileupload-1.1.jar. - private final static Pattern latestVersionPattern = Pattern.compile( - "(%latest%)" - ); - - // Set debug mode for each file resolver instance based on whether or - // not the system was started with debugging turned on. - private static boolean _debug = Boolean.getBoolean("exist.start.debug"); - - /** - * If the passed file name contains a %latest% token, - * find the latest version of that file. Otherwise, return - * the passed file name unmodified. - * - * @param filename Path relative to exist home dir of - * a jar file that should be added to the classpath. - */ - public String getResolvedFileName(String filename) { - final Matcher matches = latestVersionPattern.matcher(filename); - if (!matches.find()) { - return filename; - } - final String[] fileinfo = filename.split("%latest%"); - // Path of file up to the beginning of the %latest% token. - final String uptoToken = fileinfo[0]; - - // Dir that should contain our jar. - final String containerDirName = uptoToken.substring( - 0, uptoToken.lastIndexOf(File.separatorChar) - ); - - final File containerDir = new File(containerDirName); - - // 0-9 . - and _ are valid chars that can occur where the %latest% token - // was (maybe allow letters too?). - final String patternString = uptoToken.substring( - uptoToken.lastIndexOf(File.separatorChar) + 1 - ) + "([\\d\\.\\-_]+)" + fileinfo[1]; - final Pattern pattern = Pattern.compile("^" + patternString + "$"); - - final File[] jars = containerDir.listFiles(new FilenameFilter() { - public boolean accept(File dir, String name) { - Matcher matches = pattern.matcher(name); - return matches.find(); - } - }); - - if(jars==null){ - System.err.println("ERROR: No jars found in "+containerDir.getAbsolutePath()); - - } else if (jars.length > 0) { - final String actualFileName = jars[0].getAbsolutePath(); - if (_debug) { - System.err.println( - "Found match: " + actualFileName - + " for jar file pattern: " + filename - ); - } - return actualFileName; - } else { - if (_debug) { - System.err.println( - "WARN: No latest version found for JAR file: '" - + filename + "'" - ); - } - } - return filename; - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-06 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ + +package org.exist.start; + +import java.io.File; +import java.io.FilenameFilter; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * This class uses regex pattern matching to find the latest version of a + * particular jar file. + * + * @see LatestFileResolver#getResolvedFileName(String) + * + * @author Ben Schmaus (exist@benschmaus.com) + * @version $Revision$ + */ +public class LatestFileResolver { + + // Pattern that can be used to indicate that the + // latest version of a particular file should be added to the classpath. + // E.g., commons-fileupload-%latest%.jar would resolve to something like + // commons-fileupload-1.1.jar. + private final static Pattern latestVersionPattern = Pattern.compile( + "(%latest%)" + ); + + // Set debug mode for each file resolver instance based on whether or + // not the system was started with debugging turned on. + private static boolean _debug = Boolean.getBoolean("exist.start.debug"); + + /** + * If the passed file name contains a %latest% token, + * find the latest version of that file. Otherwise, return + * the passed file name unmodified. + * + * @param filename Path relative to exist home dir of + * a jar file that should be added to the classpath. + */ + public String getResolvedFileName(String filename) { + final Matcher matches = latestVersionPattern.matcher(filename); + if (!matches.find()) { + return filename; + } + final String[] fileinfo = filename.split("%latest%"); + // Path of file up to the beginning of the %latest% token. + final String uptoToken = fileinfo[0]; + + // Dir that should contain our jar. + final String containerDirName = uptoToken.substring( + 0, uptoToken.lastIndexOf(File.separatorChar) + ); + + final File containerDir = new File(containerDirName); + + // 0-9 . - and _ are valid chars that can occur where the %latest% token + // was (maybe allow letters too?). + final String patternString = uptoToken.substring( + uptoToken.lastIndexOf(File.separatorChar) + 1 + ) + "([\\d\\.\\-_]+)" + fileinfo[1]; + final Pattern pattern = Pattern.compile("^" + patternString + "$"); + + final File[] jars = containerDir.listFiles(new FilenameFilter() { + public boolean accept(File dir, String name) { + Matcher matches = pattern.matcher(name); + return matches.find(); + } + }); + + if(jars==null){ + System.err.println("ERROR: No jars found in "+containerDir.getAbsolutePath()); + + } else if (jars.length > 0) { + final String actualFileName = jars[0].getAbsolutePath(); + if (_debug) { + System.err.println( + "Found match: " + actualFileName + + " for jar file pattern: " + filename + ); + } + return actualFileName; + } else { + if (_debug) { + System.err.println( + "WARN: No latest version found for JAR file: '" + + filename + "'" + ); + } + } + return filename; + } +} diff --git a/src/org/exist/stax/EmbeddedXMLStreamReader.java b/src/org/exist/stax/EmbeddedXMLStreamReader.java index 93a1b54ad8a..f7bcd4d4911 100644 --- a/src/org/exist/stax/EmbeddedXMLStreamReader.java +++ b/src/org/exist/stax/EmbeddedXMLStreamReader.java @@ -1,687 +1,687 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2007 The eXist team - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ -package org.exist.stax; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.NoSuchElementException; -import java.util.Stack; - -import javax.xml.namespace.NamespaceContext; -import javax.xml.namespace.QName; -import javax.xml.stream.Location; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.StreamFilter; - -import org.apache.log4j.Logger; -import org.exist.dom.AttrImpl; -import org.exist.dom.CharacterDataImpl; -import org.exist.dom.DocumentImpl; -import org.exist.dom.ElementImpl; -import org.exist.dom.NodeHandle; -import org.exist.dom.StoredNode; -import org.exist.numbering.NodeId; -import org.exist.storage.DBBroker; -import org.exist.storage.Signatures; -import org.exist.storage.btree.Value; -import org.exist.storage.dom.RawNodeIterator; -import org.exist.util.ByteConversion; -import org.exist.util.XMLString; -import org.exist.util.serializer.AttrList; -import org.w3c.dom.Node; -import org.w3c.dom.ProcessingInstruction; - -/** - * Lazy implementation of a StAX {@link javax.xml.stream.XMLStreamReader}, which directly reads - * information from the persistent DOM. The class is optimized to support fast scanning of the DOM, where only - * a few selected node properties are requested. Node properties are extracted on demand. For example, the QName of - * an element will not be read unless {@link #getText()} is called. - */ -public class EmbeddedXMLStreamReader implements ExtendedXMLStreamReader { - - private static final Logger LOG = Logger.getLogger(EmbeddedXMLStreamReader.class); - - private RawNodeIterator iterator; - - private Value current = null; - - private Value previous = null; - - private Stack elementStack = new Stack(); - - private int state = START_DOCUMENT; - - private boolean beforeRoot = false; - - private DocumentImpl document; - - private NodeId nodeId; - - private NodeHandle origin; - - private QName qname = null; - - private XMLString text = new XMLString(256); - - private List namespaces = new ArrayList(6); - private boolean nsRead = false; - - private AttrList attributes = null; - - private boolean reportAttribs = false; - - private DBBroker broker; - - /** - * Construct an EmbeddedXMLStreamReader. - * - * @param doc the document to which the start node belongs. - * @param iterator a RawNodeIterator positioned on the start node. - * @param origin an optional NodeHandle whose nodeId should match the first node in the stream - * (or null if no need to check) - * @param reportAttributes if set to true, attributes will be reported as top-level events. - * @throws XMLStreamException - */ - public EmbeddedXMLStreamReader(DBBroker broker, DocumentImpl doc, RawNodeIterator iterator, NodeHandle origin, boolean reportAttributes) - throws XMLStreamException { - this.broker = broker; - this.document = doc; - this.iterator = iterator; - this.reportAttribs = reportAttributes; - this.origin = origin; - } - - public void filter(StreamFilter filter) throws XMLStreamException { - while (hasNext()) { - next(); - if (!filter.accept(this)) - {break;} - } - } - - /** - * Reposition the stream reader to another start node, maybe in a different document. - * - * @param node the new start node. - * @param reportAttributes if set to true, attributes will be reported as top-level events. - * @throws IOException - */ - public void reposition(DBBroker broker, NodeHandle node, boolean reportAttributes) throws IOException { - this.broker = broker; - // Seeking to a node with unknown address will reuse this reader, so do it before setting all - // the fields otherwise they could get overwritten. - iterator.seek(node); - reset(); - this.current = null; - this.previous = null; - this.elementStack.clear(); - this.state = START_DOCUMENT; - this.reportAttribs = reportAttributes; - this.document = (DocumentImpl) node.getOwnerDocument(); - this.origin = node; - } - - public short getNodeType() { - return Signatures.getType(current.data()[current.start()]); - } - - private void initNode() { - final short type = Signatures.getType(current.data()[current.start()]); // TODO: remove potential NPE - if (state == START_DOCUMENT && type != Node.ELEMENT_NODE) - {beforeRoot = true;} - switch (type) { - case Node.ELEMENT_NODE : - state = START_ELEMENT; - elementStack.push(new ElementEvent(current)); - beforeRoot = false; - break; - case Node.ATTRIBUTE_NODE : - state = ATTRIBUTE; - break; - case Node.TEXT_NODE : - state = CHARACTERS; - break; - case Node.COMMENT_NODE: - state = COMMENT; - break; - case Node.CDATA_SECTION_NODE: - state = CDATA; - break; - case Node.PROCESSING_INSTRUCTION_NODE: - state = PROCESSING_INSTRUCTION; - break; - } - reset(); - readNodeId(); - } - - public int getChildCount() { - if (state == START_ELEMENT) - {return elementStack.peek().getChildCount();} - return 0; - } - - private void skipAttributes() throws XMLStreamException { - if (attributes == null) { - // attributes were not yet read. skip them... - final ElementEvent parent = elementStack.peek(); - final int attrs = getAttributeCount(); - for (int i = 0; i < attrs; i++) { - iterator.next(); - parent.incrementChild(); - } - } - } - - private void readAttributes() { - if (attributes == null) { - final ElementEvent parent = elementStack.peek(); - final int count = getAttributeCount(); - attributes = new AttrList(); - for (int i = 0; i < count; i++) { - final Value v = iterator.next(); - AttrImpl.addToList(broker, v.data(), v.start(), v.getLength(), attributes); - parent.incrementChild(); - } - } - } - - private void readNodeId() { - int offset = current.start() + StoredNode.LENGTH_SIGNATURE_LENGTH; - if (state == START_ELEMENT || state == END_ELEMENT) - {offset += ElementImpl.LENGTH_ELEMENT_CHILD_COUNT;} - final int dlnLen = ByteConversion.byteToShort(current.data(), offset); - offset += NodeId.LENGTH_NODE_ID_UNITS; - nodeId = broker.getBrokerPool().getNodeFactory().createFromData(dlnLen, current.data(), offset); - } - - public int next() throws XMLStreamException { - if (state != END_ELEMENT) - {previous = current;} - if (state == START_ELEMENT && !reportAttribs) - {skipAttributes();} - if (!elementStack.isEmpty()) { - final ElementEvent parent = elementStack.peek(); - if (parent.getChildCount() == parent.getCurrentChild()) { - elementStack.pop(); - state = END_ELEMENT; - current = parent.data; - reset(); - return state; - } else { - parent.incrementChild(); - } - } else if (state != START_DOCUMENT && !beforeRoot) - {throw new NoSuchElementException();} - final boolean first = state == START_DOCUMENT; - current = iterator.next(); - initNode(); - if (first && origin != null) { - verifyOriginNodeId(); - origin = null; - } - return state; - } - - private void verifyOriginNodeId() throws XMLStreamException { - if (!nodeId.equals(origin.getNodeId())) { - // Node got moved, we had the wrong address. Resync iterator by nodeid. - LOG.warn("expected node id " + origin.getNodeId() + ", got " + nodeId + "; resyncing address"); - origin.setInternalAddress(StoredNode.UNKNOWN_NODE_IMPL_ADDRESS); - boolean reportAttribsBackup = reportAttribs; - DocumentImpl documentBackup = document; - try { - iterator.seek(origin); - } catch (final IOException e) { - throw new XMLStreamException(e); - } - // Seeking the iterator might've reused this reader, so reset all fields. - reset(); - previous = null; - elementStack.clear(); - reportAttribs = reportAttribsBackup; - document = documentBackup; - current = iterator.next(); - initNode(); - origin.setInternalAddress(iterator.currentAddress()); - } - } - - private void reset() { - nodeId = null; - qname = null; - attributes = null; - text.reuse(); - if (state != END_ELEMENT) { - namespaces.clear(); - nsRead = false; - } - } - - public void require(int i, String string, String string1) throws XMLStreamException { - throw new UnsupportedOperationException(); - } - - public String getElementText() throws XMLStreamException { - if(getEventType() != START_ELEMENT) { - throw new XMLStreamException( - "parser must be on START_ELEMENT to read next text"); - } - int eventType = next(); - final StringBuffer content = new StringBuffer(); - while(eventType != END_ELEMENT ) { - if(eventType == CHARACTERS - || eventType == CDATA - || eventType == SPACE - || eventType == ENTITY_REFERENCE) { - content.append(getText()); - } else if(eventType == PROCESSING_INSTRUCTION - || eventType == COMMENT) { - // skipping - } else if(eventType == END_DOCUMENT) { - throw new XMLStreamException("unexpected end of document when reading element text content"); - } else if(eventType == START_ELEMENT) { - throw new XMLStreamException( - "element text content may not contain START_ELEMENT"); - } else { - throw new XMLStreamException( - "Unexpected event type "+eventType); - } - eventType = next(); - } - return content.toString(); - } - - public Object getProperty(String string) throws IllegalArgumentException { - if (string.equals(PROPERTY_NODE_ID)) { - if (nodeId == null) - {readNodeId();} - return nodeId; - } - return null; - } - - public int nextTag() throws XMLStreamException { - throw new UnsupportedOperationException(); - } - - public boolean hasNext() throws XMLStreamException { - return state == START_DOCUMENT || beforeRoot || !elementStack.isEmpty(); - } - - public void close() throws XMLStreamException { - iterator.closeDocument(); - } - - public boolean isStartElement() { - return state == START_ELEMENT; - } - - public boolean isEndElement() { - return state == END_ELEMENT; - } - - public boolean isCharacters() { - return state == CHARACTERS; - } - - public boolean isWhiteSpace() { - return false; - } - - public String getAttributeValue(String namespaceURI, String localName) { - readAttributes(); - for (int i = 0; i < attributes.getLength(); i++) { - final org.exist.dom.QName qn = attributes.getQName(i); - if (qn.getNamespaceURI().equals(namespaceURI) && qn.getLocalName().equals(localName)) - {return attributes.getValue(i);} - } - return null; - } - - public int getAttributeCount() { - final int offset = current.start() + StoredNode.LENGTH_SIGNATURE_LENGTH + ElementImpl.LENGTH_ELEMENT_CHILD_COUNT + NodeId.LENGTH_NODE_ID_UNITS + nodeId.size(); - return ByteConversion.byteToShort(current.data(), offset); - } - - public QName getAttributeName(int i) { - if (state != START_ELEMENT) - {throw new IllegalStateException("Cursor is not at an element");} - readAttributes(); - if (i > attributes.getLength()) - {throw new ArrayIndexOutOfBoundsException("index should be < " + attributes.getLength());} - return attributes.getQName(i).toJavaQName(); - } - - public org.exist.dom.QName getAttributeQName(int i) { - if (state != START_ELEMENT) - {throw new IllegalStateException("Cursor is not at an element");} - readAttributes(); - if (i > attributes.getLength()) - {throw new ArrayIndexOutOfBoundsException("index should be < " + attributes.getLength());} - return attributes.getQName(i); - } - - public String getAttributeNamespace(int i) { - if (state != START_ELEMENT) - {throw new IllegalStateException("Cursor is not at an element");} - readAttributes(); - if (i > attributes.getLength()) - {throw new ArrayIndexOutOfBoundsException("index should be < " + attributes.getLength());} - return attributes.getQName(i).getNamespaceURI(); - } - - public String getAttributeLocalName(int i) { - if (state != START_ELEMENT) - {throw new IllegalStateException("Cursor is not at an element");} - readAttributes(); - if (i > attributes.getLength()) - {throw new ArrayIndexOutOfBoundsException("index should be < " + attributes.getLength());} - return attributes.getQName(i).getLocalName(); - } - - public String getAttributePrefix(int i) { - if (state != START_ELEMENT) - {throw new IllegalStateException("Cursor is not at an element");} - readAttributes(); - if (i > attributes.getLength()) - {throw new ArrayIndexOutOfBoundsException("index should be < " + attributes.getLength());} - return attributes.getQName(i).getPrefix(); - } - - public String getAttributeType(int i) { - if (state != START_ELEMENT) - {throw new IllegalStateException("Cursor is not at an element");} - readAttributes(); - if (i > attributes.getLength()) - {throw new ArrayIndexOutOfBoundsException("index should be < " + attributes.getLength());} - final int type = attributes.getType(i); - return AttrImpl.getAttributeType(type); - } - - public String getAttributeValue(int i) { - if (state != START_ELEMENT) - {throw new IllegalStateException("Cursor is not at an element");} - readAttributes(); - if (i > attributes.getLength()) - {throw new ArrayIndexOutOfBoundsException("index should be < " + attributes.getLength());} - return attributes.getValue(i); - } - - public NodeId getAttributeId(int i) { - if (state != START_ELEMENT) - {throw new IllegalStateException("Cursor is not at an element");} - readAttributes(); - if (i > attributes.getLength()) - {throw new ArrayIndexOutOfBoundsException("index should be < " + attributes.getLength());} - return attributes.getNodeId(i); - } - - public boolean isAttributeSpecified(int i) { - return false; - } - - public int getNamespaceCount() { - readNamespaceDecls(); - return namespaces.size(); - } - - public String getNamespacePrefix(int i) { - readNamespaceDecls(); - if (i < 0 || i > namespaces.size()) - {return null;} - final String[] decl = namespaces.get(i); - return decl[0]; - } - - public String getNamespaceURI(int i) { - readNamespaceDecls(); - if (i < 0 || i > namespaces.size()) - {return null;} - final String[] decl = namespaces.get(i); - return decl[1]; - } - - public NamespaceContext getNamespaceContext() { - throw new UnsupportedOperationException(); - } - - public int getEventType() { - return state; - } - - public XMLString getXMLText() { - if (state == CHARACTERS || state == COMMENT || state == CDATA) { - if (text.length() == 0) { - CharacterDataImpl.readData(nodeId, current, text); - } - return text; - } - return new XMLString(); - } - - public String getText() { - return getXMLText().toString(); - } - - public char[] getTextCharacters() { - final String s = getText(); - final char[] dst = new char[s.length()]; - s.getChars(0, dst.length, dst, 0); - return dst; - } - - public int getTextCharacters(int sourceStart, char[] chars, int targetStart, int length) throws XMLStreamException { - throw new UnsupportedOperationException(); - } - - public int getTextStart() { - throw new UnsupportedOperationException(); - } - - public int getTextLength() { - if (state == CHARACTERS || state == COMMENT || state == CDATA) { - if (text.length() == 0) - {return CharacterDataImpl.getStringLength(nodeId, current);} - return text.length(); - } - return 0; - } - - public String getEncoding() { - throw new UnsupportedOperationException(); - } - - public boolean hasText() { - return state == CHARACTERS || state == COMMENT || state == CDATA; - } - - public Location getLocation() { - throw new UnsupportedOperationException(); - } - - public String getNamespaceURI(String string) { - return null; - } - - public QName getName() { - if (qname != null) - {return qname;} - if (state == START_ELEMENT || state == END_ELEMENT) { - if (nodeId == null) - {readNodeId();} - qname = ElementImpl.readQName(current, document, nodeId).toJavaQName(); - } - return qname; - } - - public org.exist.dom.QName getQName() { - if (state == START_ELEMENT || state == END_ELEMENT) { - if (nodeId == null) - {readNodeId();} - return ElementImpl.readQName(current, document, nodeId); - } - return null; - } - - /** - * Read all namespace declarations defined on the current element. - * Cache them in the namespaces map. - */ - private void readNamespaceDecls() { - if (nsRead) - {return;} - if (state == START_ELEMENT || state == END_ELEMENT) { - if (nodeId == null) - {readNodeId();} - ElementImpl.readNamespaceDecls(namespaces, current, document, nodeId); - } - nsRead = true; - } - - public String getPrefix() { - return getName().getPrefix(); - } - - public String getLocalName() { - return getName().getLocalPart(); - } - - public String getNamespaceURI() { - return getName().getNamespaceURI(); - } - - public boolean hasName() { - return (state == START_ELEMENT || state == END_ELEMENT); - } - - /** - * Deserialize the node at the current position of the cursor and return - * it as a {@link org.exist.dom.StoredNode}. - * - * @return the node at the current position. - */ - public StoredNode getNode() { - final StoredNode node = StoredNode.deserialize(current.data(), current.start(), current.getLength(), document); - node.setOwnerDocument(document); - node.setInternalAddress(current.getAddress()); - return node; - } - - /** - * Returns the last node in document sequence that occurs before the - * current node. Usually used to find the last child before an END_ELEMENT - * event. - * - * @return the last node in document sequence before the current node - */ - public StoredNode getPreviousNode() { - final StoredNode node = StoredNode.deserialize(previous.data(), previous.start(), previous.getLength(), document); - node.setOwnerDocument(document); - node.setInternalAddress(previous.getAddress()); - return node; - } - - /** - * Returns the (internal) address of the node at the cursor's current - * position. - * - * @return internal address of node - */ - public long getCurrentPosition() { - return iterator.currentAddress(); - } - - public String getVersion() { - return "1.0"; - } - - public boolean isStandalone() { - return false; - } - - public boolean standaloneSet() { - return false; - } - - public String getCharacterEncodingScheme() { - return null; - } - - public String getPITarget() { - readPI(); - return qname.getLocalPart(); - } - - public String getPIData() { - readPI(); - return text.toString(); - } - - private void readPI() { - if (qname == null) { - if (state != PROCESSING_INSTRUCTION) - {throw new IllegalStateException("Cursor is not at a processing instruction");} - final ProcessingInstruction pi = (ProcessingInstruction) - StoredNode.deserialize(current.data(), current.start(), current.getLength(), document); - qname = new QName("", pi.getTarget(), ""); - text.append(pi.getData()); - } - } - - private static class ElementEvent { - - private Value data; - - private int childCount = 0; - - private int currentChild = 0; - - public ElementEvent(Value data) { - this.data = data; - childCount = ByteConversion.byteToInt(data.data(), data.start() + StoredNode.LENGTH_SIGNATURE_LENGTH); - } - - @SuppressWarnings("unused") - public Value getData() { - return data; - } - - public int getChildCount() { - return childCount; - } - - public int getCurrentChild() { - return currentChild; - } - - @SuppressWarnings("unused") - public void setCurrentChild(int currentChild) { - this.currentChild = currentChild; - } - - public void incrementChild() { - currentChild++; - } - } +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2007 The eXist team + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id$ + */ +package org.exist.stax; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.Stack; + +import javax.xml.namespace.NamespaceContext; +import javax.xml.namespace.QName; +import javax.xml.stream.Location; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.StreamFilter; + +import org.apache.log4j.Logger; +import org.exist.dom.AttrImpl; +import org.exist.dom.CharacterDataImpl; +import org.exist.dom.DocumentImpl; +import org.exist.dom.ElementImpl; +import org.exist.dom.NodeHandle; +import org.exist.dom.StoredNode; +import org.exist.numbering.NodeId; +import org.exist.storage.DBBroker; +import org.exist.storage.Signatures; +import org.exist.storage.btree.Value; +import org.exist.storage.dom.RawNodeIterator; +import org.exist.util.ByteConversion; +import org.exist.util.XMLString; +import org.exist.util.serializer.AttrList; +import org.w3c.dom.Node; +import org.w3c.dom.ProcessingInstruction; + +/** + * Lazy implementation of a StAX {@link javax.xml.stream.XMLStreamReader}, which directly reads + * information from the persistent DOM. The class is optimized to support fast scanning of the DOM, where only + * a few selected node properties are requested. Node properties are extracted on demand. For example, the QName of + * an element will not be read unless {@link #getText()} is called. + */ +public class EmbeddedXMLStreamReader implements ExtendedXMLStreamReader { + + private static final Logger LOG = Logger.getLogger(EmbeddedXMLStreamReader.class); + + private RawNodeIterator iterator; + + private Value current = null; + + private Value previous = null; + + private Stack elementStack = new Stack(); + + private int state = START_DOCUMENT; + + private boolean beforeRoot = false; + + private DocumentImpl document; + + private NodeId nodeId; + + private NodeHandle origin; + + private QName qname = null; + + private XMLString text = new XMLString(256); + + private List namespaces = new ArrayList(6); + private boolean nsRead = false; + + private AttrList attributes = null; + + private boolean reportAttribs = false; + + private DBBroker broker; + + /** + * Construct an EmbeddedXMLStreamReader. + * + * @param doc the document to which the start node belongs. + * @param iterator a RawNodeIterator positioned on the start node. + * @param origin an optional NodeHandle whose nodeId should match the first node in the stream + * (or null if no need to check) + * @param reportAttributes if set to true, attributes will be reported as top-level events. + * @throws XMLStreamException + */ + public EmbeddedXMLStreamReader(DBBroker broker, DocumentImpl doc, RawNodeIterator iterator, NodeHandle origin, boolean reportAttributes) + throws XMLStreamException { + this.broker = broker; + this.document = doc; + this.iterator = iterator; + this.reportAttribs = reportAttributes; + this.origin = origin; + } + + public void filter(StreamFilter filter) throws XMLStreamException { + while (hasNext()) { + next(); + if (!filter.accept(this)) + {break;} + } + } + + /** + * Reposition the stream reader to another start node, maybe in a different document. + * + * @param node the new start node. + * @param reportAttributes if set to true, attributes will be reported as top-level events. + * @throws IOException + */ + public void reposition(DBBroker broker, NodeHandle node, boolean reportAttributes) throws IOException { + this.broker = broker; + // Seeking to a node with unknown address will reuse this reader, so do it before setting all + // the fields otherwise they could get overwritten. + iterator.seek(node); + reset(); + this.current = null; + this.previous = null; + this.elementStack.clear(); + this.state = START_DOCUMENT; + this.reportAttribs = reportAttributes; + this.document = (DocumentImpl) node.getOwnerDocument(); + this.origin = node; + } + + public short getNodeType() { + return Signatures.getType(current.data()[current.start()]); + } + + private void initNode() { + final short type = Signatures.getType(current.data()[current.start()]); // TODO: remove potential NPE + if (state == START_DOCUMENT && type != Node.ELEMENT_NODE) + {beforeRoot = true;} + switch (type) { + case Node.ELEMENT_NODE : + state = START_ELEMENT; + elementStack.push(new ElementEvent(current)); + beforeRoot = false; + break; + case Node.ATTRIBUTE_NODE : + state = ATTRIBUTE; + break; + case Node.TEXT_NODE : + state = CHARACTERS; + break; + case Node.COMMENT_NODE: + state = COMMENT; + break; + case Node.CDATA_SECTION_NODE: + state = CDATA; + break; + case Node.PROCESSING_INSTRUCTION_NODE: + state = PROCESSING_INSTRUCTION; + break; + } + reset(); + readNodeId(); + } + + public int getChildCount() { + if (state == START_ELEMENT) + {return elementStack.peek().getChildCount();} + return 0; + } + + private void skipAttributes() throws XMLStreamException { + if (attributes == null) { + // attributes were not yet read. skip them... + final ElementEvent parent = elementStack.peek(); + final int attrs = getAttributeCount(); + for (int i = 0; i < attrs; i++) { + iterator.next(); + parent.incrementChild(); + } + } + } + + private void readAttributes() { + if (attributes == null) { + final ElementEvent parent = elementStack.peek(); + final int count = getAttributeCount(); + attributes = new AttrList(); + for (int i = 0; i < count; i++) { + final Value v = iterator.next(); + AttrImpl.addToList(broker, v.data(), v.start(), v.getLength(), attributes); + parent.incrementChild(); + } + } + } + + private void readNodeId() { + int offset = current.start() + StoredNode.LENGTH_SIGNATURE_LENGTH; + if (state == START_ELEMENT || state == END_ELEMENT) + {offset += ElementImpl.LENGTH_ELEMENT_CHILD_COUNT;} + final int dlnLen = ByteConversion.byteToShort(current.data(), offset); + offset += NodeId.LENGTH_NODE_ID_UNITS; + nodeId = broker.getBrokerPool().getNodeFactory().createFromData(dlnLen, current.data(), offset); + } + + public int next() throws XMLStreamException { + if (state != END_ELEMENT) + {previous = current;} + if (state == START_ELEMENT && !reportAttribs) + {skipAttributes();} + if (!elementStack.isEmpty()) { + final ElementEvent parent = elementStack.peek(); + if (parent.getChildCount() == parent.getCurrentChild()) { + elementStack.pop(); + state = END_ELEMENT; + current = parent.data; + reset(); + return state; + } else { + parent.incrementChild(); + } + } else if (state != START_DOCUMENT && !beforeRoot) + {throw new NoSuchElementException();} + final boolean first = state == START_DOCUMENT; + current = iterator.next(); + initNode(); + if (first && origin != null) { + verifyOriginNodeId(); + origin = null; + } + return state; + } + + private void verifyOriginNodeId() throws XMLStreamException { + if (!nodeId.equals(origin.getNodeId())) { + // Node got moved, we had the wrong address. Resync iterator by nodeid. + LOG.warn("expected node id " + origin.getNodeId() + ", got " + nodeId + "; resyncing address"); + origin.setInternalAddress(StoredNode.UNKNOWN_NODE_IMPL_ADDRESS); + boolean reportAttribsBackup = reportAttribs; + DocumentImpl documentBackup = document; + try { + iterator.seek(origin); + } catch (final IOException e) { + throw new XMLStreamException(e); + } + // Seeking the iterator might've reused this reader, so reset all fields. + reset(); + previous = null; + elementStack.clear(); + reportAttribs = reportAttribsBackup; + document = documentBackup; + current = iterator.next(); + initNode(); + origin.setInternalAddress(iterator.currentAddress()); + } + } + + private void reset() { + nodeId = null; + qname = null; + attributes = null; + text.reuse(); + if (state != END_ELEMENT) { + namespaces.clear(); + nsRead = false; + } + } + + public void require(int i, String string, String string1) throws XMLStreamException { + throw new UnsupportedOperationException(); + } + + public String getElementText() throws XMLStreamException { + if(getEventType() != START_ELEMENT) { + throw new XMLStreamException( + "parser must be on START_ELEMENT to read next text"); + } + int eventType = next(); + final StringBuffer content = new StringBuffer(); + while(eventType != END_ELEMENT ) { + if(eventType == CHARACTERS + || eventType == CDATA + || eventType == SPACE + || eventType == ENTITY_REFERENCE) { + content.append(getText()); + } else if(eventType == PROCESSING_INSTRUCTION + || eventType == COMMENT) { + // skipping + } else if(eventType == END_DOCUMENT) { + throw new XMLStreamException("unexpected end of document when reading element text content"); + } else if(eventType == START_ELEMENT) { + throw new XMLStreamException( + "element text content may not contain START_ELEMENT"); + } else { + throw new XMLStreamException( + "Unexpected event type "+eventType); + } + eventType = next(); + } + return content.toString(); + } + + public Object getProperty(String string) throws IllegalArgumentException { + if (string.equals(PROPERTY_NODE_ID)) { + if (nodeId == null) + {readNodeId();} + return nodeId; + } + return null; + } + + public int nextTag() throws XMLStreamException { + throw new UnsupportedOperationException(); + } + + public boolean hasNext() throws XMLStreamException { + return state == START_DOCUMENT || beforeRoot || !elementStack.isEmpty(); + } + + public void close() throws XMLStreamException { + iterator.closeDocument(); + } + + public boolean isStartElement() { + return state == START_ELEMENT; + } + + public boolean isEndElement() { + return state == END_ELEMENT; + } + + public boolean isCharacters() { + return state == CHARACTERS; + } + + public boolean isWhiteSpace() { + return false; + } + + public String getAttributeValue(String namespaceURI, String localName) { + readAttributes(); + for (int i = 0; i < attributes.getLength(); i++) { + final org.exist.dom.QName qn = attributes.getQName(i); + if (qn.getNamespaceURI().equals(namespaceURI) && qn.getLocalName().equals(localName)) + {return attributes.getValue(i);} + } + return null; + } + + public int getAttributeCount() { + final int offset = current.start() + StoredNode.LENGTH_SIGNATURE_LENGTH + ElementImpl.LENGTH_ELEMENT_CHILD_COUNT + NodeId.LENGTH_NODE_ID_UNITS + nodeId.size(); + return ByteConversion.byteToShort(current.data(), offset); + } + + public QName getAttributeName(int i) { + if (state != START_ELEMENT) + {throw new IllegalStateException("Cursor is not at an element");} + readAttributes(); + if (i > attributes.getLength()) + {throw new ArrayIndexOutOfBoundsException("index should be < " + attributes.getLength());} + return attributes.getQName(i).toJavaQName(); + } + + public org.exist.dom.QName getAttributeQName(int i) { + if (state != START_ELEMENT) + {throw new IllegalStateException("Cursor is not at an element");} + readAttributes(); + if (i > attributes.getLength()) + {throw new ArrayIndexOutOfBoundsException("index should be < " + attributes.getLength());} + return attributes.getQName(i); + } + + public String getAttributeNamespace(int i) { + if (state != START_ELEMENT) + {throw new IllegalStateException("Cursor is not at an element");} + readAttributes(); + if (i > attributes.getLength()) + {throw new ArrayIndexOutOfBoundsException("index should be < " + attributes.getLength());} + return attributes.getQName(i).getNamespaceURI(); + } + + public String getAttributeLocalName(int i) { + if (state != START_ELEMENT) + {throw new IllegalStateException("Cursor is not at an element");} + readAttributes(); + if (i > attributes.getLength()) + {throw new ArrayIndexOutOfBoundsException("index should be < " + attributes.getLength());} + return attributes.getQName(i).getLocalName(); + } + + public String getAttributePrefix(int i) { + if (state != START_ELEMENT) + {throw new IllegalStateException("Cursor is not at an element");} + readAttributes(); + if (i > attributes.getLength()) + {throw new ArrayIndexOutOfBoundsException("index should be < " + attributes.getLength());} + return attributes.getQName(i).getPrefix(); + } + + public String getAttributeType(int i) { + if (state != START_ELEMENT) + {throw new IllegalStateException("Cursor is not at an element");} + readAttributes(); + if (i > attributes.getLength()) + {throw new ArrayIndexOutOfBoundsException("index should be < " + attributes.getLength());} + final int type = attributes.getType(i); + return AttrImpl.getAttributeType(type); + } + + public String getAttributeValue(int i) { + if (state != START_ELEMENT) + {throw new IllegalStateException("Cursor is not at an element");} + readAttributes(); + if (i > attributes.getLength()) + {throw new ArrayIndexOutOfBoundsException("index should be < " + attributes.getLength());} + return attributes.getValue(i); + } + + public NodeId getAttributeId(int i) { + if (state != START_ELEMENT) + {throw new IllegalStateException("Cursor is not at an element");} + readAttributes(); + if (i > attributes.getLength()) + {throw new ArrayIndexOutOfBoundsException("index should be < " + attributes.getLength());} + return attributes.getNodeId(i); + } + + public boolean isAttributeSpecified(int i) { + return false; + } + + public int getNamespaceCount() { + readNamespaceDecls(); + return namespaces.size(); + } + + public String getNamespacePrefix(int i) { + readNamespaceDecls(); + if (i < 0 || i > namespaces.size()) + {return null;} + final String[] decl = namespaces.get(i); + return decl[0]; + } + + public String getNamespaceURI(int i) { + readNamespaceDecls(); + if (i < 0 || i > namespaces.size()) + {return null;} + final String[] decl = namespaces.get(i); + return decl[1]; + } + + public NamespaceContext getNamespaceContext() { + throw new UnsupportedOperationException(); + } + + public int getEventType() { + return state; + } + + public XMLString getXMLText() { + if (state == CHARACTERS || state == COMMENT || state == CDATA) { + if (text.length() == 0) { + CharacterDataImpl.readData(nodeId, current, text); + } + return text; + } + return new XMLString(); + } + + public String getText() { + return getXMLText().toString(); + } + + public char[] getTextCharacters() { + final String s = getText(); + final char[] dst = new char[s.length()]; + s.getChars(0, dst.length, dst, 0); + return dst; + } + + public int getTextCharacters(int sourceStart, char[] chars, int targetStart, int length) throws XMLStreamException { + throw new UnsupportedOperationException(); + } + + public int getTextStart() { + throw new UnsupportedOperationException(); + } + + public int getTextLength() { + if (state == CHARACTERS || state == COMMENT || state == CDATA) { + if (text.length() == 0) + {return CharacterDataImpl.getStringLength(nodeId, current);} + return text.length(); + } + return 0; + } + + public String getEncoding() { + throw new UnsupportedOperationException(); + } + + public boolean hasText() { + return state == CHARACTERS || state == COMMENT || state == CDATA; + } + + public Location getLocation() { + throw new UnsupportedOperationException(); + } + + public String getNamespaceURI(String string) { + return null; + } + + public QName getName() { + if (qname != null) + {return qname;} + if (state == START_ELEMENT || state == END_ELEMENT) { + if (nodeId == null) + {readNodeId();} + qname = ElementImpl.readQName(current, document, nodeId).toJavaQName(); + } + return qname; + } + + public org.exist.dom.QName getQName() { + if (state == START_ELEMENT || state == END_ELEMENT) { + if (nodeId == null) + {readNodeId();} + return ElementImpl.readQName(current, document, nodeId); + } + return null; + } + + /** + * Read all namespace declarations defined on the current element. + * Cache them in the namespaces map. + */ + private void readNamespaceDecls() { + if (nsRead) + {return;} + if (state == START_ELEMENT || state == END_ELEMENT) { + if (nodeId == null) + {readNodeId();} + ElementImpl.readNamespaceDecls(namespaces, current, document, nodeId); + } + nsRead = true; + } + + public String getPrefix() { + return getName().getPrefix(); + } + + public String getLocalName() { + return getName().getLocalPart(); + } + + public String getNamespaceURI() { + return getName().getNamespaceURI(); + } + + public boolean hasName() { + return (state == START_ELEMENT || state == END_ELEMENT); + } + + /** + * Deserialize the node at the current position of the cursor and return + * it as a {@link org.exist.dom.StoredNode}. + * + * @return the node at the current position. + */ + public StoredNode getNode() { + final StoredNode node = StoredNode.deserialize(current.data(), current.start(), current.getLength(), document); + node.setOwnerDocument(document); + node.setInternalAddress(current.getAddress()); + return node; + } + + /** + * Returns the last node in document sequence that occurs before the + * current node. Usually used to find the last child before an END_ELEMENT + * event. + * + * @return the last node in document sequence before the current node + */ + public StoredNode getPreviousNode() { + final StoredNode node = StoredNode.deserialize(previous.data(), previous.start(), previous.getLength(), document); + node.setOwnerDocument(document); + node.setInternalAddress(previous.getAddress()); + return node; + } + + /** + * Returns the (internal) address of the node at the cursor's current + * position. + * + * @return internal address of node + */ + public long getCurrentPosition() { + return iterator.currentAddress(); + } + + public String getVersion() { + return "1.0"; + } + + public boolean isStandalone() { + return false; + } + + public boolean standaloneSet() { + return false; + } + + public String getCharacterEncodingScheme() { + return null; + } + + public String getPITarget() { + readPI(); + return qname.getLocalPart(); + } + + public String getPIData() { + readPI(); + return text.toString(); + } + + private void readPI() { + if (qname == null) { + if (state != PROCESSING_INSTRUCTION) + {throw new IllegalStateException("Cursor is not at a processing instruction");} + final ProcessingInstruction pi = (ProcessingInstruction) + StoredNode.deserialize(current.data(), current.start(), current.getLength(), document); + qname = new QName("", pi.getTarget(), ""); + text.append(pi.getData()); + } + } + + private static class ElementEvent { + + private Value data; + + private int childCount = 0; + + private int currentChild = 0; + + public ElementEvent(Value data) { + this.data = data; + childCount = ByteConversion.byteToInt(data.data(), data.start() + StoredNode.LENGTH_SIGNATURE_LENGTH); + } + + @SuppressWarnings("unused") + public Value getData() { + return data; + } + + public int getChildCount() { + return childCount; + } + + public int getCurrentChild() { + return currentChild; + } + + @SuppressWarnings("unused") + public void setCurrentChild(int currentChild) { + this.currentChild = currentChild; + } + + public void incrementChild() { + currentChild++; + } + } } \ No newline at end of file diff --git a/src/org/exist/storage/BackupSystemTask.java b/src/org/exist/storage/BackupSystemTask.java index 5120cf858e4..e829fdaffdd 100644 --- a/src/org/exist/storage/BackupSystemTask.java +++ b/src/org/exist/storage/BackupSystemTask.java @@ -1,167 +1,167 @@ -package org.exist.storage; - -import org.apache.log4j.Logger; -import org.exist.EXistException; -import org.exist.backup.Backup; -import org.exist.util.Configuration; -import org.exist.xmldb.XmldbURI; -import org.xml.sax.SAXException; -import org.xmldb.api.base.XMLDBException; - -import java.io.File; -import java.io.IOException; -import java.util.Calendar; -import java.util.Iterator; -import java.util.Map; -import java.util.Properties; -import java.util.Set; -import java.util.TreeMap; - -/** - * BackupSystemTask creates an XML backup of the current database into a directory - * or zip file. Running the backup as a system task guarantees a consistent backup. No - * other transactions will be allowed while the backup is in progress. - * - * The following properties can be used to configure the backup task if passed to the - * {@link #configure(org.exist.util.Configuration, java.util.Properties)} method: - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
collectionthe collection to backup, specified as an absolute path into the db, e.g. /db/back-me-up
usera valid user for writing the backup. Usually, this needs to be a user in the dba - * database admin group.
passwordthe password for the user
dirthe output directory where the backup will be written
prefixa prefix for the generated file name. the final file name will consist of - * prefix + current-dateTime + suffix
suffixa suffix for the generated file name. If it ends with .zip, BackupSystemTask will - * directly write the backup into a zip file. Otherwise, it will write into a plain directory.
- */ -public class BackupSystemTask implements SystemTask { - - private static final Logger LOG = Logger.getLogger(BackupSystemTask.class); - - private String user; - private String password; - private File directory; - private String suffix; - private XmldbURI collection; - private String prefix; - // purge old zip backup files - private int zipFilesMax = -1; - - public void configure(Configuration config, Properties properties) throws EXistException { - user = properties.getProperty("user", "guest"); - password = properties.getProperty("password", "guest"); - String collName = properties.getProperty("collection", "xmldb:exist:///db"); - if (!collName.startsWith("xmldb:exist:")) - {collName = "xmldb:exist://" + collName;} - collection = XmldbURI.create(collName); - LOG.debug("Collection to backup: " + collection.toString() + ". User: " + user); - - suffix = properties.getProperty("suffix", ""); - prefix = properties.getProperty("prefix", ""); - - String dir = properties.getProperty("dir", "backup"); - directory = new File(dir); - if (!directory.isAbsolute()) { - dir = (String)config.getProperty(BrokerPool.PROPERTY_DATA_DIR) + - File.separatorChar + dir; - directory = new File(dir); - } - directory.mkdirs(); - - // check for max zip files - final String filesMaxStr = properties.getProperty("zip-files-max"); - if (LOG.isDebugEnabled()) {LOG.debug("zip-files-max: " + filesMaxStr);} - if (null != filesMaxStr) - try - { - zipFilesMax = new Integer(filesMaxStr).intValue(); - } - catch (final NumberFormatException e) {LOG.debug("zip-files-max property error", e);} - } - - - public void execute(DBBroker broker) throws EXistException { - final String dateTime = DataBackup.creationDateFormat.format(Calendar.getInstance().getTime()); - final String dest = directory.getAbsolutePath() + File.separatorChar + prefix + dateTime + suffix; - - final Backup backup = new Backup(user, password, dest, collection); - try { - backup.backup(false, null); - } catch (final XMLDBException e) { - LOG.debug(e.getMessage(), e); - throw new EXistException(e.getMessage(), e); - } catch (final IOException e) { - LOG.debug(e.getMessage(), e); - throw new EXistException(e.getMessage(), e); - } catch (final SAXException e) { - LOG.debug(e.getMessage(), e); - throw new EXistException(e.getMessage(), e); - } - - // see if old zip files need to be purged - if (".zip".equals(suffix) && zipFilesMax > 0) {purgeZipFiles();} - } - - public void purgeZipFiles() - { - if (LOG.isDebugEnabled()) {LOG.debug("starting purgeZipFiles()");} - - // get all files in target directory - final File[] files = directory.listFiles(); - - if (files.length > 0) - { - final Map sorted = new TreeMap(); - for (int i=0; i < files.length; i++) - { - //check for prefix and suffix match - if (files[i].getName().startsWith(prefix) && files[i].getName().endsWith(suffix)) - { - sorted.put(Long.toString(files[i].lastModified()), files[i]); - } - } - if (sorted.size() > zipFilesMax) - { - final Set keys = sorted.keySet(); - final Iterator ki = keys.iterator(); - int i = sorted.size() - zipFilesMax; - while (ki.hasNext()) - { - final File f = sorted.get(ki.next()); - if (i > 0) - { - if (LOG.isDebugEnabled()) {LOG.debug("Purging backup : " + f.getName());} - f.delete(); - } - i--; - } - } - } - } - - @Override - public boolean afterCheckpoint() { - return false; - } -} +package org.exist.storage; + +import org.apache.log4j.Logger; +import org.exist.EXistException; +import org.exist.backup.Backup; +import org.exist.util.Configuration; +import org.exist.xmldb.XmldbURI; +import org.xml.sax.SAXException; +import org.xmldb.api.base.XMLDBException; + +import java.io.File; +import java.io.IOException; +import java.util.Calendar; +import java.util.Iterator; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.TreeMap; + +/** + * BackupSystemTask creates an XML backup of the current database into a directory + * or zip file. Running the backup as a system task guarantees a consistent backup. No + * other transactions will be allowed while the backup is in progress. + * + * The following properties can be used to configure the backup task if passed to the + * {@link #configure(org.exist.util.Configuration, java.util.Properties)} method: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
collectionthe collection to backup, specified as an absolute path into the db, e.g. /db/back-me-up
usera valid user for writing the backup. Usually, this needs to be a user in the dba + * database admin group.
passwordthe password for the user
dirthe output directory where the backup will be written
prefixa prefix for the generated file name. the final file name will consist of + * prefix + current-dateTime + suffix
suffixa suffix for the generated file name. If it ends with .zip, BackupSystemTask will + * directly write the backup into a zip file. Otherwise, it will write into a plain directory.
+ */ +public class BackupSystemTask implements SystemTask { + + private static final Logger LOG = Logger.getLogger(BackupSystemTask.class); + + private String user; + private String password; + private File directory; + private String suffix; + private XmldbURI collection; + private String prefix; + // purge old zip backup files + private int zipFilesMax = -1; + + public void configure(Configuration config, Properties properties) throws EXistException { + user = properties.getProperty("user", "guest"); + password = properties.getProperty("password", "guest"); + String collName = properties.getProperty("collection", "xmldb:exist:///db"); + if (!collName.startsWith("xmldb:exist:")) + {collName = "xmldb:exist://" + collName;} + collection = XmldbURI.create(collName); + LOG.debug("Collection to backup: " + collection.toString() + ". User: " + user); + + suffix = properties.getProperty("suffix", ""); + prefix = properties.getProperty("prefix", ""); + + String dir = properties.getProperty("dir", "backup"); + directory = new File(dir); + if (!directory.isAbsolute()) { + dir = (String)config.getProperty(BrokerPool.PROPERTY_DATA_DIR) + + File.separatorChar + dir; + directory = new File(dir); + } + directory.mkdirs(); + + // check for max zip files + final String filesMaxStr = properties.getProperty("zip-files-max"); + if (LOG.isDebugEnabled()) {LOG.debug("zip-files-max: " + filesMaxStr);} + if (null != filesMaxStr) + try + { + zipFilesMax = new Integer(filesMaxStr).intValue(); + } + catch (final NumberFormatException e) {LOG.debug("zip-files-max property error", e);} + } + + + public void execute(DBBroker broker) throws EXistException { + final String dateTime = DataBackup.creationDateFormat.format(Calendar.getInstance().getTime()); + final String dest = directory.getAbsolutePath() + File.separatorChar + prefix + dateTime + suffix; + + final Backup backup = new Backup(user, password, dest, collection); + try { + backup.backup(false, null); + } catch (final XMLDBException e) { + LOG.debug(e.getMessage(), e); + throw new EXistException(e.getMessage(), e); + } catch (final IOException e) { + LOG.debug(e.getMessage(), e); + throw new EXistException(e.getMessage(), e); + } catch (final SAXException e) { + LOG.debug(e.getMessage(), e); + throw new EXistException(e.getMessage(), e); + } + + // see if old zip files need to be purged + if (".zip".equals(suffix) && zipFilesMax > 0) {purgeZipFiles();} + } + + public void purgeZipFiles() + { + if (LOG.isDebugEnabled()) {LOG.debug("starting purgeZipFiles()");} + + // get all files in target directory + final File[] files = directory.listFiles(); + + if (files.length > 0) + { + final Map sorted = new TreeMap(); + for (int i=0; i < files.length; i++) + { + //check for prefix and suffix match + if (files[i].getName().startsWith(prefix) && files[i].getName().endsWith(suffix)) + { + sorted.put(Long.toString(files[i].lastModified()), files[i]); + } + } + if (sorted.size() > zipFilesMax) + { + final Set keys = sorted.keySet(); + final Iterator ki = keys.iterator(); + int i = sorted.size() - zipFilesMax; + while (ki.hasNext()) + { + final File f = sorted.get(ki.next()); + if (i > 0) + { + if (LOG.isDebugEnabled()) {LOG.debug("Purging backup : " + f.getName());} + f.delete(); + } + i--; + } + } + } + } + + @Override + public boolean afterCheckpoint() { + return false; + } +} diff --git a/src/org/exist/storage/DBBroker.java b/src/org/exist/storage/DBBroker.java index 417d723c547..d686b65d55d 100644 --- a/src/org/exist/storage/DBBroker.java +++ b/src/org/exist/storage/DBBroker.java @@ -840,7 +840,6 @@ public abstract EmbeddedXMLStreamReader newXMLStreamReader(NodeHandle node, bool public abstract void readCollectionEntry(SubCollectionEntry entry); - @Override public void close() throws Exception { pool.release(this); } diff --git a/src/org/exist/storage/btree/SetPageLinkLoggable.java b/src/org/exist/storage/btree/SetPageLinkLoggable.java index 09f4e2097c7..2a9c6314a8c 100644 --- a/src/org/exist/storage/btree/SetPageLinkLoggable.java +++ b/src/org/exist/storage/btree/SetPageLinkLoggable.java @@ -1,77 +1,77 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.storage.btree; - -import java.nio.ByteBuffer; - -import org.exist.storage.DBBroker; -import org.exist.storage.journal.LogException; -import org.exist.storage.txn.Txn; - -/** - * Created by IntelliJ IDEA. - * User: wolf - * Date: 17.03.2007 - * Time: 21:55:45 - * To change this template use File | Settings | File Templates. - */ -public class SetPageLinkLoggable extends BTAbstractLoggable { - - protected long nextPage; - protected long pageNum; - - public SetPageLinkLoggable(Txn transaction, byte fileId, long pageNum, long nextPage) { - super(BTree.LOG_SET_LINK, fileId, transaction); - this.pageNum = pageNum; - this.nextPage = nextPage; - } - - - public SetPageLinkLoggable(DBBroker broker, long transactionId) { - super(BTree.LOG_SET_LINK, broker, transactionId); - } - - - public void read(ByteBuffer in) { - super.read(in); - pageNum = in.getLong(); - nextPage = in.getLong(); - } - - public void write(ByteBuffer out) { - super.write(out); - out.putLong(pageNum); - out.putLong(nextPage); - } - - public int getLogSize() { - return super.getLogSize() + 16; - } - - public void redo() throws LogException { - getStorage().redoSetPageLink(this); - } - - public String dump() { - return super.dump() + " - set next page link for page: " + pageNum + ": " + nextPage; - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.storage.btree; + +import java.nio.ByteBuffer; + +import org.exist.storage.DBBroker; +import org.exist.storage.journal.LogException; +import org.exist.storage.txn.Txn; + +/** + * Created by IntelliJ IDEA. + * User: wolf + * Date: 17.03.2007 + * Time: 21:55:45 + * To change this template use File | Settings | File Templates. + */ +public class SetPageLinkLoggable extends BTAbstractLoggable { + + protected long nextPage; + protected long pageNum; + + public SetPageLinkLoggable(Txn transaction, byte fileId, long pageNum, long nextPage) { + super(BTree.LOG_SET_LINK, fileId, transaction); + this.pageNum = pageNum; + this.nextPage = nextPage; + } + + + public SetPageLinkLoggable(DBBroker broker, long transactionId) { + super(BTree.LOG_SET_LINK, broker, transactionId); + } + + + public void read(ByteBuffer in) { + super.read(in); + pageNum = in.getLong(); + nextPage = in.getLong(); + } + + public void write(ByteBuffer out) { + super.write(out); + out.putLong(pageNum); + out.putLong(nextPage); + } + + public int getLogSize() { + return super.getLogSize() + 16; + } + + public void redo() throws LogException { + getStorage().redoSetPageLink(this); + } + + public String dump() { + return super.dump() + " - set next page link for page: " + pageNum + ": " + nextPage; + } +} diff --git a/src/org/exist/storage/btree/TreeMetrics.java b/src/org/exist/storage/btree/TreeMetrics.java index 7b6c631cd8a..efd89fe193d 100644 --- a/src/org/exist/storage/btree/TreeMetrics.java +++ b/src/org/exist/storage/btree/TreeMetrics.java @@ -1,74 +1,74 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.storage.btree; - -import java.io.PrintWriter; -import java.io.StringWriter; - -/** - * - */ -public class TreeMetrics { - - private int leafPages = 0; - private int innerPages = 0; - private int dataPages = 0; - private String btreeName; - - public TreeMetrics(String name) { - this.btreeName = name; - } - - public void addPage(int status) { - if (status == BTree.BRANCH) - {addInnerPage();} - else - {addLeafPage();} - } - - public void addLeafPage() { - ++leafPages; - } - - public void addInnerPage() { - ++innerPages; - } - - public void addDataPage() { - ++dataPages; - } - - public void print(PrintWriter writer) { - writer.println("BTree tree metrics for " + btreeName); - writer.println("# inner pages: " + innerPages); - writer.println("# leaf pages: " + leafPages); - writer.println("# data pages: " + dataPages); - } - - public void toLogger() { - final StringWriter sw = new StringWriter(); - final PrintWriter writer = new PrintWriter(sw); - print(writer); - if (BTree.LOG.isDebugEnabled()) - {BTree.LOG.debug(sw.toString());} - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.storage.btree; + +import java.io.PrintWriter; +import java.io.StringWriter; + +/** + * + */ +public class TreeMetrics { + + private int leafPages = 0; + private int innerPages = 0; + private int dataPages = 0; + private String btreeName; + + public TreeMetrics(String name) { + this.btreeName = name; + } + + public void addPage(int status) { + if (status == BTree.BRANCH) + {addInnerPage();} + else + {addLeafPage();} + } + + public void addLeafPage() { + ++leafPages; + } + + public void addInnerPage() { + ++innerPages; + } + + public void addDataPage() { + ++dataPages; + } + + public void print(PrintWriter writer) { + writer.println("BTree tree metrics for " + btreeName); + writer.println("# inner pages: " + innerPages); + writer.println("# leaf pages: " + leafPages); + writer.println("# data pages: " + dataPages); + } + + public void toLogger() { + final StringWriter sw = new StringWriter(); + final PrintWriter writer = new PrintWriter(sw); + print(writer); + if (BTree.LOG.isDebugEnabled()) + {BTree.LOG.debug(sw.toString());} + } +} diff --git a/src/org/exist/storage/dom/RawNodeIterator.java b/src/org/exist/storage/dom/RawNodeIterator.java index 59a3d75d0b0..ea3b238b4fe 100644 --- a/src/org/exist/storage/dom/RawNodeIterator.java +++ b/src/org/exist/storage/dom/RawNodeIterator.java @@ -1,224 +1,224 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2007 The eXist team - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ -package org.exist.storage.dom; - -import org.apache.log4j.Logger; -import org.exist.dom.NodeHandle; -import org.exist.dom.NodeProxy; -import org.exist.storage.DBBroker; -import org.exist.storage.StorageAddress; -import org.exist.storage.btree.BTree; -import org.exist.storage.btree.BTreeException; -import org.exist.storage.btree.Paged; -import org.exist.storage.btree.Value; -import org.exist.storage.lock.Lock; -import org.exist.util.ByteConversion; -import org.exist.util.LockException; -import org.exist.util.sanity.SanityCheck; - -import java.io.IOException; - -/** - * An iterator that walks through the raw node data items in a document. The class - * keeps reading data items from the document's sequence of data pages until it encounters - * the end of the document. Each returned value contains the data of one node in the - * document. - */ -public class RawNodeIterator { - - private final static Logger LOG = Logger.getLogger(RawNodeIterator.class); - - private DOMFile db = null; - private int offset; - private short lastTupleID = ItemId.UNKNOWN_ID; - private DOMFile.DOMPage page = null; - private long pageNum; - private DBBroker broker; - - /** - * Construct the iterator. The iterator will be positioned before the specified - * start node. - * - * @param broker the owner object used to acquire a lock on the underlying data file (usually a DBBroker) - * @param db the underlying data file - * @param node the start node where the iterator will be positioned. - * @throws IOException - */ - public RawNodeIterator(DBBroker broker, DOMFile db, NodeHandle node) throws IOException { - this.db = db; - this.broker = broker; - seek(node); - } - - /** - * Reposition the iterator to the start of the specified node. - * - * @param node the start node where the iterator will be positioned. - * @throws IOException - */ - public void seek(NodeHandle node) throws IOException { - final Lock lock = db.getLock(); - try { - lock.acquire(Lock.READ_LOCK); - RecordPos rec = null; - if (StorageAddress.hasAddress(node.getInternalAddress())) - {rec = db.findRecord(node.getInternalAddress());} - if (rec == null) { - try { - final long address = db.findValue(broker, new NodeProxy(node)); - if (address == BTree.KEY_NOT_FOUND) - {throw new IOException("Node not found.");} - rec = db.findRecord(address); - } catch (final BTreeException e) { - throw new IOException("Node not found: " + e.getMessage()); - } - } - pageNum = rec.getPage().getPageNum(); - //Position the stream at the very beginning of the record - offset = rec.offset - DOMFile.LENGTH_TID; - page = rec.getPage(); - } catch (final LockException e) { - throw new IOException("Exception while scanning document: " + e.getMessage()); - } finally { - lock.release(Lock.READ_LOCK); - } - } - - /** - * Returns the raw data of the next node in document order. - * @return the raw data of the node - */ - public Value next() { - Value nextValue = null; - final Lock lock = db.getLock(); - try { - try { - lock.acquire(Lock.READ_LOCK); - } catch (final LockException e) { - LOG.error("Failed to acquire read lock on " + db.getFile().getName()); - //TODO : throw exception here ? -pb - return null; - } - db.setOwnerObject(broker); - long backLink = 0; - do { - final DOMFile.DOMFilePageHeader pageHeader = page.getPageHeader(); - //Next value larger than length of the current page? - if (offset >= pageHeader.getDataLength()) { - //Load next page in chain - long nextPage = pageHeader.getNextDataPage(); - if (nextPage == Paged.Page.NO_PAGE) { - SanityCheck.TRACE("Bad link to next page " + page.page.getPageInfo() + - "; previous: " + pageHeader.getPreviousDataPage() + - "; offset = " + offset + "; lastTupleID = " + lastTupleID); - //TODO : throw exception here ? -pb - return null; - } - pageNum = nextPage; - page = db.getDOMPage(nextPage); - db.addToBuffer(page); - offset = 0; - } - //Extract the tuple id - lastTupleID = ByteConversion.byteToShort(page.data, offset); - offset += DOMFile.LENGTH_TID; - //Check if this is just a link to a relocated node - if(ItemId.isLink(lastTupleID)) { - //Skip this - offset += DOMFile.LENGTH_FORWARD_LOCATION; - continue; - } - //Read data length - short valueLength = ByteConversion.byteToShort(page.data, offset); - offset += DOMFile.LENGTH_DATA_LENGTH; - if (valueLength < 0) { - LOG.error("Got negative length" + valueLength + " at offset " + offset + "!!!"); - LOG.debug(db.debugPageContents(page)); - //TODO : throw an exception right now ? - } - if (ItemId.isRelocated(lastTupleID)) { - // found a relocated node. Read the original address - backLink = ByteConversion.byteToLong(page.data, offset); - offset += DOMFile.LENGTH_ORIGINAL_LOCATION; - } - //Overflow page? load the overflow value - if (valueLength == DOMFile.OVERFLOW) { - valueLength = DOMFile.LENGTH_OVERFLOW_LOCATION; - final long overflow = ByteConversion.byteToLong(page.data, offset); - offset += DOMFile.LENGTH_OVERFLOW_LOCATION; - try { - final byte[] odata = db.getOverflowValue(overflow); - nextValue = new Value(odata); - } catch(final Exception e) { - LOG.error("Exception while loading overflow value: " + e.getMessage() + - "; originating page: " + page.page.getPageInfo()); - } - // normal node - } else { - try { - nextValue = new Value(page.data, offset, valueLength); - offset += valueLength; - } catch(final Exception e) { - LOG.error("Error while deserializing node: " + e.getMessage(), e); - LOG.error("Reading from offset: " + offset + "; len = " + valueLength); - LOG.debug(db.debugPageContents(page)); - throw new RuntimeException(e); - } - } - if (nextValue == null) { - LOG.error("illegal node on page " + page.getPageNum() + - "; tupleID = " + ItemId.getId(lastTupleID) + - "; next = " + page.getPageHeader().getNextDataPage() + - "; prev = " + page.getPageHeader().getPreviousDataPage() + - "; offset = " + (offset - valueLength) + - "; len = " + page.getPageHeader().getDataLength()); - //TODO : throw exception here ? -pb - return null; - } - if (ItemId.isRelocated(lastTupleID)) { - nextValue.setAddress(backLink); - } else { - nextValue.setAddress(StorageAddress.createPointer((int) pageNum, - ItemId.getId(lastTupleID)) - ); - } - } while (nextValue == null); - return nextValue; - } finally { - lock.release(Lock.READ_LOCK); - } - } - - public void closeDocument() { - db.closeDocument(); - } - - /** - * Returns the internal virtual storage address of the node at the cursor's current - * position. - * - * @return internal virtual storage address of the node - */ - public long currentAddress() { - return StorageAddress.createPointer((int) pageNum, ItemId.getId(lastTupleID)); - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2007 The eXist team + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id$ + */ +package org.exist.storage.dom; + +import org.apache.log4j.Logger; +import org.exist.dom.NodeHandle; +import org.exist.dom.NodeProxy; +import org.exist.storage.DBBroker; +import org.exist.storage.StorageAddress; +import org.exist.storage.btree.BTree; +import org.exist.storage.btree.BTreeException; +import org.exist.storage.btree.Paged; +import org.exist.storage.btree.Value; +import org.exist.storage.lock.Lock; +import org.exist.util.ByteConversion; +import org.exist.util.LockException; +import org.exist.util.sanity.SanityCheck; + +import java.io.IOException; + +/** + * An iterator that walks through the raw node data items in a document. The class + * keeps reading data items from the document's sequence of data pages until it encounters + * the end of the document. Each returned value contains the data of one node in the + * document. + */ +public class RawNodeIterator { + + private final static Logger LOG = Logger.getLogger(RawNodeIterator.class); + + private DOMFile db = null; + private int offset; + private short lastTupleID = ItemId.UNKNOWN_ID; + private DOMFile.DOMPage page = null; + private long pageNum; + private DBBroker broker; + + /** + * Construct the iterator. The iterator will be positioned before the specified + * start node. + * + * @param broker the owner object used to acquire a lock on the underlying data file (usually a DBBroker) + * @param db the underlying data file + * @param node the start node where the iterator will be positioned. + * @throws IOException + */ + public RawNodeIterator(DBBroker broker, DOMFile db, NodeHandle node) throws IOException { + this.db = db; + this.broker = broker; + seek(node); + } + + /** + * Reposition the iterator to the start of the specified node. + * + * @param node the start node where the iterator will be positioned. + * @throws IOException + */ + public void seek(NodeHandle node) throws IOException { + final Lock lock = db.getLock(); + try { + lock.acquire(Lock.READ_LOCK); + RecordPos rec = null; + if (StorageAddress.hasAddress(node.getInternalAddress())) + {rec = db.findRecord(node.getInternalAddress());} + if (rec == null) { + try { + final long address = db.findValue(broker, new NodeProxy(node)); + if (address == BTree.KEY_NOT_FOUND) + {throw new IOException("Node not found.");} + rec = db.findRecord(address); + } catch (final BTreeException e) { + throw new IOException("Node not found: " + e.getMessage()); + } + } + pageNum = rec.getPage().getPageNum(); + //Position the stream at the very beginning of the record + offset = rec.offset - DOMFile.LENGTH_TID; + page = rec.getPage(); + } catch (final LockException e) { + throw new IOException("Exception while scanning document: " + e.getMessage()); + } finally { + lock.release(Lock.READ_LOCK); + } + } + + /** + * Returns the raw data of the next node in document order. + * @return the raw data of the node + */ + public Value next() { + Value nextValue = null; + final Lock lock = db.getLock(); + try { + try { + lock.acquire(Lock.READ_LOCK); + } catch (final LockException e) { + LOG.error("Failed to acquire read lock on " + db.getFile().getName()); + //TODO : throw exception here ? -pb + return null; + } + db.setOwnerObject(broker); + long backLink = 0; + do { + final DOMFile.DOMFilePageHeader pageHeader = page.getPageHeader(); + //Next value larger than length of the current page? + if (offset >= pageHeader.getDataLength()) { + //Load next page in chain + long nextPage = pageHeader.getNextDataPage(); + if (nextPage == Paged.Page.NO_PAGE) { + SanityCheck.TRACE("Bad link to next page " + page.page.getPageInfo() + + "; previous: " + pageHeader.getPreviousDataPage() + + "; offset = " + offset + "; lastTupleID = " + lastTupleID); + //TODO : throw exception here ? -pb + return null; + } + pageNum = nextPage; + page = db.getDOMPage(nextPage); + db.addToBuffer(page); + offset = 0; + } + //Extract the tuple id + lastTupleID = ByteConversion.byteToShort(page.data, offset); + offset += DOMFile.LENGTH_TID; + //Check if this is just a link to a relocated node + if(ItemId.isLink(lastTupleID)) { + //Skip this + offset += DOMFile.LENGTH_FORWARD_LOCATION; + continue; + } + //Read data length + short valueLength = ByteConversion.byteToShort(page.data, offset); + offset += DOMFile.LENGTH_DATA_LENGTH; + if (valueLength < 0) { + LOG.error("Got negative length" + valueLength + " at offset " + offset + "!!!"); + LOG.debug(db.debugPageContents(page)); + //TODO : throw an exception right now ? + } + if (ItemId.isRelocated(lastTupleID)) { + // found a relocated node. Read the original address + backLink = ByteConversion.byteToLong(page.data, offset); + offset += DOMFile.LENGTH_ORIGINAL_LOCATION; + } + //Overflow page? load the overflow value + if (valueLength == DOMFile.OVERFLOW) { + valueLength = DOMFile.LENGTH_OVERFLOW_LOCATION; + final long overflow = ByteConversion.byteToLong(page.data, offset); + offset += DOMFile.LENGTH_OVERFLOW_LOCATION; + try { + final byte[] odata = db.getOverflowValue(overflow); + nextValue = new Value(odata); + } catch(final Exception e) { + LOG.error("Exception while loading overflow value: " + e.getMessage() + + "; originating page: " + page.page.getPageInfo()); + } + // normal node + } else { + try { + nextValue = new Value(page.data, offset, valueLength); + offset += valueLength; + } catch(final Exception e) { + LOG.error("Error while deserializing node: " + e.getMessage(), e); + LOG.error("Reading from offset: " + offset + "; len = " + valueLength); + LOG.debug(db.debugPageContents(page)); + throw new RuntimeException(e); + } + } + if (nextValue == null) { + LOG.error("illegal node on page " + page.getPageNum() + + "; tupleID = " + ItemId.getId(lastTupleID) + + "; next = " + page.getPageHeader().getNextDataPage() + + "; prev = " + page.getPageHeader().getPreviousDataPage() + + "; offset = " + (offset - valueLength) + + "; len = " + page.getPageHeader().getDataLength()); + //TODO : throw exception here ? -pb + return null; + } + if (ItemId.isRelocated(lastTupleID)) { + nextValue.setAddress(backLink); + } else { + nextValue.setAddress(StorageAddress.createPointer((int) pageNum, + ItemId.getId(lastTupleID)) + ); + } + } while (nextValue == null); + return nextValue; + } finally { + lock.release(Lock.READ_LOCK); + } + } + + public void closeDocument() { + db.closeDocument(); + } + + /** + * Returns the internal virtual storage address of the node at the cursor's current + * position. + * + * @return internal virtual storage address of the node + */ + public long currentAddress() { + return StorageAddress.createPointer((int) pageNum, ItemId.getId(lastTupleID)); + } +} diff --git a/src/org/exist/storage/dom/RecordPos.java b/src/org/exist/storage/dom/RecordPos.java index c694b9ae1ee..b5c97a0d0fe 100644 --- a/src/org/exist/storage/dom/RecordPos.java +++ b/src/org/exist/storage/dom/RecordPos.java @@ -1,65 +1,65 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2007 the eXist team - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -package org.exist.storage.dom; - -import org.exist.storage.dom.DOMFile.DOMPage; - -public final class RecordPos { - - private DOMPage page; - int offset; - private short tupleID; - private boolean isLink = false; - - public RecordPos(int offset, DOMPage page, short tupleID) { - this.offset = offset; - this.page = page; - this.tupleID = tupleID; - } - - public RecordPos(int offset, DOMPage page, short tupleID, boolean isLink) { - this.offset = offset; - this.page = page; - this.tupleID = tupleID; - this.isLink = isLink; - } - - public DOMPage getPage() { - return page; - } - - public void setPage(DOMPage page) { - this.page = page; - } - - public short getTupleID() { - return tupleID; - } - - //Strange : only one call to this method - public void setTupleID(short tupleID) { - this.tupleID = tupleID; - } - - public boolean isLink() { - return isLink; - } +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2007 the eXist team + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +package org.exist.storage.dom; + +import org.exist.storage.dom.DOMFile.DOMPage; + +public final class RecordPos { + + private DOMPage page; + int offset; + private short tupleID; + private boolean isLink = false; + + public RecordPos(int offset, DOMPage page, short tupleID) { + this.offset = offset; + this.page = page; + this.tupleID = tupleID; + } + + public RecordPos(int offset, DOMPage page, short tupleID, boolean isLink) { + this.offset = offset; + this.page = page; + this.tupleID = tupleID; + this.isLink = isLink; + } + + public DOMPage getPage() { + return page; + } + + public void setPage(DOMPage page) { + this.page = page; + } + + public short getTupleID() { + return tupleID; + } + + //Strange : only one call to this method + public void setTupleID(short tupleID) { + this.tupleID = tupleID; + } + + public boolean isLink() { + return isLink; + } } \ No newline at end of file diff --git a/src/org/exist/storage/io/BlockingInputStream.java b/src/org/exist/storage/io/BlockingInputStream.java index 56bfa06674d..cac8bfb08b7 100644 --- a/src/org/exist/storage/io/BlockingInputStream.java +++ b/src/org/exist/storage/io/BlockingInputStream.java @@ -1,382 +1,382 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id: BlockingInputStream.java 223 2007-04-21 22:13:05Z dizzzz $ - */ - -package org.exist.storage.io; - -import java.io.IOException; -import java.io.InputStream; - -/** - * BlockingInputStream is a combination of an input stream and - * an output stream, connected through a (circular) buffer in memory. - * It is intended for coupling producer threads to consumer threads via a - * (byte) stream. - * When the buffer is full producer threads will be blocked until the buffer - * has some free space again. When the buffer is empty the consumer threads will - * be blocked until some bytes are available again. - * Closing of the output stream will block until the inputstream is closed. - * A special version of the close function enables the consumer threads to - * specify that an exception has occurred. This will cause producer calls to - * be unblocked and throw an IOException containing this exception as cause. - * - * @author Chris Offerman - */ -public class BlockingInputStream extends InputStream { - - private final static int EOS = -1; - private static final int CAPACITY = 8192; - private static final int SIZE = CAPACITY + 1; - - private byte[] buffer = new byte[SIZE]; // Circular queue. - private int head; // First full buffer position. - private int tail; // First empty buffer position. - private boolean inClosed; // Is the input stream closed? - private boolean outClosed; // Is the output stream closed? - private Exception inException; // Specified when closing input. - private Exception outException; // Specified when closing output. - - private BlockingOutputStream bos = new BlockingOutputStream(this); - - /** - * BlockingOutputStream adapter for this BlockingInputStream. - */ - public BlockingOutputStream getOutputStream() { - return bos; - } - - /** Is a stream closed? */ - private boolean closed() { - return inClosed || outClosed; - } - - /* InputStream methods */ - - /** - * Reads the next byte of data from the input stream. The value byte is - * returned as an int in the range 0 to - * 255. If no byte is available because the end of the stream - * has been reached, the value -1 is returned. This method - * blocks until input data is available, the end of the stream is detected, - * or an exception is thrown. - * - * - * @return the next byte of data, or -1 if the end of the - * stream is reached. - * @throws IOException if an I/O error occurs. - */ - @Override - public synchronized int read() throws IOException { - final byte bb[] = new byte[1]; - return (read(bb, 0, 1) == EOS) ? EOS : bb[0]; - } - - /** - * Reads up to len bytes of data from the input stream into - * an array of bytes. An attempt is made to read as many as - * len bytes, but a smaller number may be read. - * The number of bytes actually read is returned as an integer. - * - *

This method blocks until input data is available, end of file is - * detected, or an exception is thrown. - * - * - * @param b the buffer into which the data is read. - * @param off the start offset in array b - * at which the data is written. - * @param len the maximum number of bytes to read. - * @return the total number of bytes read into the buffer, or - * -1 if there is no more data because the end of - * the stream has been reached. - * @throws IOException if an I/O error occurs. - * @throws NullPointerException if b is null. - */ - @Override - public synchronized int read(byte b[], int off, int len) throws IOException { - if (b == null) { - throw new NullPointerException(); - } else if ((off < 0) || (off > b.length) || (len < 0) || - ((off + len) > b.length) || ((off + len) < 0)) { - throw new IndexOutOfBoundsException(); - } else if (len == 0) { - return 0; - } - int count = EOS; - try { - while (empty() && !closed()) wait(); - if (outException != null) {throw new IOException( - "BlockingOutputStream closed with an exception.", outException);} - else if (!closed()) { - count = Math.min(len, available()); - final int count1 = Math.min(count, availablePart1()); - System.arraycopy(buffer, head, b, off, count1); - final int count2 = count - count1; - if (count2 > 0) { - System.arraycopy(buffer, 0, b, off + count1, count2); - } - head = next(head, count); - if (empty()) {head = tail = 0;} // Reset to optimal situation. - } - } catch (final InterruptedException e) { - throw new IOException("Read operation interrupted.", e); - } finally { - notifyAll(); - } - return count; - } - - /** - * Closes this input stream and releases the buffer associated - * with this stream. - */ - @Override - public synchronized void close() { - inClosed = true; - buffer = null; - notifyAll(); - } - - /** - * Closes this input stream, specifying that an exception has occurred. - * This will cause all producer calls to be unblocked and throw an - * ExistIOException with this exception as its cause. - * Releases the buffer associated with this stream. - * BlockingInputStream specific method. - */ - public synchronized void close(Exception ex) { - inException = ex; - close(); - } - - /** - * The number of bytes that can be read (or skipped over) from - * this input stream without blocking by the next caller of a method for - * this input stream. - * - * - * @return the number of bytes that can be read from this input stream - * without blocking. - * @throws ExistIOException if an I/O error occurs. - */ - @Override - public synchronized int available() { - return (tail - head + SIZE) % SIZE; - } - - private int availablePart1() { - return (tail >= head) ? tail - head : SIZE - head; - } - - // DWES Never called? - @SuppressWarnings("unused") - private int availablePart2() { - return (tail >= head) ? 0 : tail; - } - - /* OutputStream methods */ - - /** - * Writes the specified byte to this output stream. The general - * contract for write is that one byte is written - * to the output stream. The byte to be written is the eight - * low-order bits of the argument b. The 24 - * high-order bits of b are ignored. - * - * - * @param b the byte. - * @throws ExistIOException if an I/O error occurs. In particular, - * an ExistIOException may be thrown if the - * output stream has been closed. - */ - synchronized void writeOutputStream(int b) throws IOException { - final byte bb[] = { (byte) b }; - writeOutputStream(bb, 0, 1); - } - - /** - * Writes len bytes from the specified byte array - * starting at offset off to this output stream. - * The general contract for write(b, off, len) is that - * some of the bytes in the array b are written to the - * output stream in order; element b[off] is the first - * byte written and b[off+len-1] is the last byte written - * by this operation. - * - * - * @param b the data. - * @param off the start offset in the data. - * @param len the number of bytes to write. - * @throws IOException if an I/O error occurs. In particular, - * an IOException is thrown if the output - * stream is closed. - */ - synchronized void writeOutputStream(byte b[], int off, int len) throws IOException { - if (b == null) { - throw new NullPointerException(); - } else if ((off < 0) || (off > b.length) || (len < 0) || - ((off + len) > b.length) || ((off + len) < 0)) { - throw new IndexOutOfBoundsException(); - } - while (len > 0) { - int count; - try { - while (full() && !closed()) wait(); - if (inException != null) {throw new IOException( - "BlockingInputStream closed with exception.", inException);} - else if (closed()) {throw new IOException( - "Writing to closed stream", inException);} - count = Math.min(len, free()); - final int count1 = Math.min(count, freePart1()); - System.arraycopy(b, off, buffer, tail, count1); - final int count2 = count - count1; - if (count2 > 0) { - System.arraycopy(b, off + count1, buffer, 0, count2); - } - tail = next(tail, count); - } catch (final InterruptedException e) { - throw new IOException("Write operation interrupted.", e); - } finally { - notifyAll(); - } - off += count; - len -= count; - } - } - - /** - * Equivalent of the close() method of an output stream. - * Renamed to solve the name clash with the close() method - * of the input stream also implemented by this class. - * Closes this output stream. - * A closed stream cannot perform output operations and cannot be reopened. - *

- * This method blocks its caller until the corresponding input stream is - * closed or an exception occurs. - * - * @throws IOException if an I/O error occurs. - */ - synchronized void closeOutputStream() throws IOException { - if (outException == null) {flushOutputStream();} - outClosed = true; - notifyAll(); - try { - while(!inClosed) wait(); - if (inException != null) {throw new IOException( - "BlockingInputStream closed with an exception.", inException);} - else if (!empty()) {throw new IOException( - "Closing non empty closed stream.", inException);} - } catch (final InterruptedException e) { - throw new IOException( - "Close OutputStream operation interrupted.", e); - } - } - - /** - * Closes this output stream, specifying that an exception has occurred. - * This will cause all consumer calls to be unblocked and throw an - * IOException with this exception as its cause. - * BlockingInputStream specific method. - - * @throws IOException if an I/O error occurs. - */ - synchronized void closeOutputStream(Exception ex) throws IOException { - outException = ex; - closeOutputStream(); - } - - /** - * Flushes this output stream and forces any buffered output bytes - * to be written out. - *

- * This methods blocks its caller until all buffered bytes are actually - * read by the consuming threads. - * - * - * @throws IOException if an I/O error occurs. - */ - synchronized void flushOutputStream() throws IOException { - try { - while(!empty() && !closed()) wait(); - if (inException != null) {throw new IOException( - "BlockingInputStream closed with an exception.", inException);} - else if (!empty()) {throw new IOException( - "Flushing non empty closed stream.", inException);} - } catch (final InterruptedException e) { - throw new IOException("Flush operation interrupted.", e); - } finally { - notifyAll(); - } - } - - /** - * The number of bytes that can be written to - * this output stream without blocking by the next caller of a method for - * this output stream. - * - * - * @return the number of bytes that can be written to this output stream - * without blocking. - * @throws IOException if an I/O error occurs. - */ - private synchronized int free() { - final int prevhead = prev(head); - return (prevhead - tail + SIZE) % SIZE; - } - - private int freePart1() { - final int prevhead = prev(head); - return (prevhead >= tail) ? prevhead - tail : SIZE - tail; - } - - // DWES Never called? - @SuppressWarnings("unused") - private int freePart2() { - final int prevhead = prev(head); - return (prevhead >= tail) ? 0 : prevhead; - } - - /* Buffer management methods */ - - private boolean empty() { - return head == tail; - } - - private boolean full() { - return next(tail) == head; - } - - private static int next(int pos) { - return next(pos, 1); - } - - private static int next(int pos, int incr) { - return (pos + incr) % SIZE; - } - - private static int prev(int pos) { - return prev(pos, 1); - } - - private static int prev(int pos, int decr) { - return (pos - decr + SIZE) % SIZE; - } -} - +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id: BlockingInputStream.java 223 2007-04-21 22:13:05Z dizzzz $ + */ + +package org.exist.storage.io; + +import java.io.IOException; +import java.io.InputStream; + +/** + * BlockingInputStream is a combination of an input stream and + * an output stream, connected through a (circular) buffer in memory. + * It is intended for coupling producer threads to consumer threads via a + * (byte) stream. + * When the buffer is full producer threads will be blocked until the buffer + * has some free space again. When the buffer is empty the consumer threads will + * be blocked until some bytes are available again. + * Closing of the output stream will block until the inputstream is closed. + * A special version of the close function enables the consumer threads to + * specify that an exception has occurred. This will cause producer calls to + * be unblocked and throw an IOException containing this exception as cause. + * + * @author Chris Offerman + */ +public class BlockingInputStream extends InputStream { + + private final static int EOS = -1; + private static final int CAPACITY = 8192; + private static final int SIZE = CAPACITY + 1; + + private byte[] buffer = new byte[SIZE]; // Circular queue. + private int head; // First full buffer position. + private int tail; // First empty buffer position. + private boolean inClosed; // Is the input stream closed? + private boolean outClosed; // Is the output stream closed? + private Exception inException; // Specified when closing input. + private Exception outException; // Specified when closing output. + + private BlockingOutputStream bos = new BlockingOutputStream(this); + + /** + * BlockingOutputStream adapter for this BlockingInputStream. + */ + public BlockingOutputStream getOutputStream() { + return bos; + } + + /** Is a stream closed? */ + private boolean closed() { + return inClosed || outClosed; + } + + /* InputStream methods */ + + /** + * Reads the next byte of data from the input stream. The value byte is + * returned as an int in the range 0 to + * 255. If no byte is available because the end of the stream + * has been reached, the value -1 is returned. This method + * blocks until input data is available, the end of the stream is detected, + * or an exception is thrown. + * + * + * @return the next byte of data, or -1 if the end of the + * stream is reached. + * @throws IOException if an I/O error occurs. + */ + @Override + public synchronized int read() throws IOException { + final byte bb[] = new byte[1]; + return (read(bb, 0, 1) == EOS) ? EOS : bb[0]; + } + + /** + * Reads up to len bytes of data from the input stream into + * an array of bytes. An attempt is made to read as many as + * len bytes, but a smaller number may be read. + * The number of bytes actually read is returned as an integer. + * + *

This method blocks until input data is available, end of file is + * detected, or an exception is thrown. + * + * + * @param b the buffer into which the data is read. + * @param off the start offset in array b + * at which the data is written. + * @param len the maximum number of bytes to read. + * @return the total number of bytes read into the buffer, or + * -1 if there is no more data because the end of + * the stream has been reached. + * @throws IOException if an I/O error occurs. + * @throws NullPointerException if b is null. + */ + @Override + public synchronized int read(byte b[], int off, int len) throws IOException { + if (b == null) { + throw new NullPointerException(); + } else if ((off < 0) || (off > b.length) || (len < 0) || + ((off + len) > b.length) || ((off + len) < 0)) { + throw new IndexOutOfBoundsException(); + } else if (len == 0) { + return 0; + } + int count = EOS; + try { + while (empty() && !closed()) wait(); + if (outException != null) {throw new IOException( + "BlockingOutputStream closed with an exception.", outException);} + else if (!closed()) { + count = Math.min(len, available()); + final int count1 = Math.min(count, availablePart1()); + System.arraycopy(buffer, head, b, off, count1); + final int count2 = count - count1; + if (count2 > 0) { + System.arraycopy(buffer, 0, b, off + count1, count2); + } + head = next(head, count); + if (empty()) {head = tail = 0;} // Reset to optimal situation. + } + } catch (final InterruptedException e) { + throw new IOException("Read operation interrupted.", e); + } finally { + notifyAll(); + } + return count; + } + + /** + * Closes this input stream and releases the buffer associated + * with this stream. + */ + @Override + public synchronized void close() { + inClosed = true; + buffer = null; + notifyAll(); + } + + /** + * Closes this input stream, specifying that an exception has occurred. + * This will cause all producer calls to be unblocked and throw an + * ExistIOException with this exception as its cause. + * Releases the buffer associated with this stream. + * BlockingInputStream specific method. + */ + public synchronized void close(Exception ex) { + inException = ex; + close(); + } + + /** + * The number of bytes that can be read (or skipped over) from + * this input stream without blocking by the next caller of a method for + * this input stream. + * + * + * @return the number of bytes that can be read from this input stream + * without blocking. + * @throws ExistIOException if an I/O error occurs. + */ + @Override + public synchronized int available() { + return (tail - head + SIZE) % SIZE; + } + + private int availablePart1() { + return (tail >= head) ? tail - head : SIZE - head; + } + + // DWES Never called? + @SuppressWarnings("unused") + private int availablePart2() { + return (tail >= head) ? 0 : tail; + } + + /* OutputStream methods */ + + /** + * Writes the specified byte to this output stream. The general + * contract for write is that one byte is written + * to the output stream. The byte to be written is the eight + * low-order bits of the argument b. The 24 + * high-order bits of b are ignored. + * + * + * @param b the byte. + * @throws ExistIOException if an I/O error occurs. In particular, + * an ExistIOException may be thrown if the + * output stream has been closed. + */ + synchronized void writeOutputStream(int b) throws IOException { + final byte bb[] = { (byte) b }; + writeOutputStream(bb, 0, 1); + } + + /** + * Writes len bytes from the specified byte array + * starting at offset off to this output stream. + * The general contract for write(b, off, len) is that + * some of the bytes in the array b are written to the + * output stream in order; element b[off] is the first + * byte written and b[off+len-1] is the last byte written + * by this operation. + * + * + * @param b the data. + * @param off the start offset in the data. + * @param len the number of bytes to write. + * @throws IOException if an I/O error occurs. In particular, + * an IOException is thrown if the output + * stream is closed. + */ + synchronized void writeOutputStream(byte b[], int off, int len) throws IOException { + if (b == null) { + throw new NullPointerException(); + } else if ((off < 0) || (off > b.length) || (len < 0) || + ((off + len) > b.length) || ((off + len) < 0)) { + throw new IndexOutOfBoundsException(); + } + while (len > 0) { + int count; + try { + while (full() && !closed()) wait(); + if (inException != null) {throw new IOException( + "BlockingInputStream closed with exception.", inException);} + else if (closed()) {throw new IOException( + "Writing to closed stream", inException);} + count = Math.min(len, free()); + final int count1 = Math.min(count, freePart1()); + System.arraycopy(b, off, buffer, tail, count1); + final int count2 = count - count1; + if (count2 > 0) { + System.arraycopy(b, off + count1, buffer, 0, count2); + } + tail = next(tail, count); + } catch (final InterruptedException e) { + throw new IOException("Write operation interrupted.", e); + } finally { + notifyAll(); + } + off += count; + len -= count; + } + } + + /** + * Equivalent of the close() method of an output stream. + * Renamed to solve the name clash with the close() method + * of the input stream also implemented by this class. + * Closes this output stream. + * A closed stream cannot perform output operations and cannot be reopened. + *

+ * This method blocks its caller until the corresponding input stream is + * closed or an exception occurs. + * + * @throws IOException if an I/O error occurs. + */ + synchronized void closeOutputStream() throws IOException { + if (outException == null) {flushOutputStream();} + outClosed = true; + notifyAll(); + try { + while(!inClosed) wait(); + if (inException != null) {throw new IOException( + "BlockingInputStream closed with an exception.", inException);} + else if (!empty()) {throw new IOException( + "Closing non empty closed stream.", inException);} + } catch (final InterruptedException e) { + throw new IOException( + "Close OutputStream operation interrupted.", e); + } + } + + /** + * Closes this output stream, specifying that an exception has occurred. + * This will cause all consumer calls to be unblocked and throw an + * IOException with this exception as its cause. + * BlockingInputStream specific method. + + * @throws IOException if an I/O error occurs. + */ + synchronized void closeOutputStream(Exception ex) throws IOException { + outException = ex; + closeOutputStream(); + } + + /** + * Flushes this output stream and forces any buffered output bytes + * to be written out. + *

+ * This methods blocks its caller until all buffered bytes are actually + * read by the consuming threads. + * + * + * @throws IOException if an I/O error occurs. + */ + synchronized void flushOutputStream() throws IOException { + try { + while(!empty() && !closed()) wait(); + if (inException != null) {throw new IOException( + "BlockingInputStream closed with an exception.", inException);} + else if (!empty()) {throw new IOException( + "Flushing non empty closed stream.", inException);} + } catch (final InterruptedException e) { + throw new IOException("Flush operation interrupted.", e); + } finally { + notifyAll(); + } + } + + /** + * The number of bytes that can be written to + * this output stream without blocking by the next caller of a method for + * this output stream. + * + * + * @return the number of bytes that can be written to this output stream + * without blocking. + * @throws IOException if an I/O error occurs. + */ + private synchronized int free() { + final int prevhead = prev(head); + return (prevhead - tail + SIZE) % SIZE; + } + + private int freePart1() { + final int prevhead = prev(head); + return (prevhead >= tail) ? prevhead - tail : SIZE - tail; + } + + // DWES Never called? + @SuppressWarnings("unused") + private int freePart2() { + final int prevhead = prev(head); + return (prevhead >= tail) ? 0 : prevhead; + } + + /* Buffer management methods */ + + private boolean empty() { + return head == tail; + } + + private boolean full() { + return next(tail) == head; + } + + private static int next(int pos) { + return next(pos, 1); + } + + private static int next(int pos, int incr) { + return (pos + incr) % SIZE; + } + + private static int prev(int pos) { + return prev(pos, 1); + } + + private static int prev(int pos, int decr) { + return (pos - decr + SIZE) % SIZE; + } +} + diff --git a/src/org/exist/storage/io/BlockingOutputStream.java b/src/org/exist/storage/io/BlockingOutputStream.java index a8771ec24a8..a32bdb9a20f 100644 --- a/src/org/exist/storage/io/BlockingOutputStream.java +++ b/src/org/exist/storage/io/BlockingOutputStream.java @@ -1,131 +1,131 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id: BlockingOutputStream.java 223 2007-04-21 22:13:05Z dizzzz $ - */ - -package org.exist.storage.io; - -import java.io.IOException; -import java.io.OutputStream; - -/** - * Output stream adapter for a BlockingInputStream. - * - * @author Chris Offerman - */ -public class BlockingOutputStream extends OutputStream { - - private BlockingInputStream bis; - - /** Create a new BlockingOutputStream adapter. - * - *@param stream The BlockingInputStream to adapt. - */ - public BlockingOutputStream(BlockingInputStream stream) { - bis = stream; - } - - /** - * BlockingInputStream of this BlockingOutputStream. - */ - public BlockingInputStream getInputStream() { - return bis; - } - - /** - * Writes the specified byte to this output stream. The general - * contract for write is that one byte is written - * to the output stream. The byte to be written is the eight - * low-order bits of the argument b. The 24 - * high-order bits of b are ignored. - * - * - * @param b the byte. - * @throws ExistIOException if an I/O error occurs. In particular, - * an ExistIOException may be thrown if the - * output stream has been closed. - */ - @Override - public void write(int b) throws IOException { - bis.writeOutputStream(b); - } - - /** - * Writes len bytes from the specified byte array - * starting at offset off to this output stream. - * The general contract for write(b, off, len) is that - * some of the bytes in the array b are written to the - * output stream in order; element b[off] is the first - * byte written and b[off+len-1] is the last byte written - * by this operation. - * - * - * @param b the data. - * @param off the start offset in the data. - * @param len the number of bytes to write. - * @throws IOException if an I/O error occurs. In particular, - * an IOException is thrown if the output - * stream is closed. - */ - @Override - public void write(byte b[], int off, int len) throws IOException { - bis.writeOutputStream(b, off, len); - } - - /** - * Closes this output stream. - * A closed stream cannot perform output operations and cannot be reopened. - *

- * This method blocks its caller until the corresponding input stream is - * closed or an exception occurs. - * - * @throws IOException if an I/O error occurs. - */ - @Override - public void close() throws IOException { - bis.closeOutputStream(); - } - - /** - * Closes this output stream, specifying that an exception has occurred. - * This will cause all consumer calls to be unblocked and throw an - * IOException with this exception as its cause. - * BlockingInputStream specific method. - * @throws IOException if an I/O error occurs. - */ - public void close(Exception ex) throws IOException { - bis.closeOutputStream(ex); - } - - /** - * Flushes this output stream and forces any buffered output bytes - * to be written out. - *

- * This methods blocks its caller until all buffered bytes are actually - * read by the consuming threads. - * - * - * @throws IOException if an I/O error occurs. - */ - @Override - public void flush() throws IOException { - bis.flushOutputStream(); - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id: BlockingOutputStream.java 223 2007-04-21 22:13:05Z dizzzz $ + */ + +package org.exist.storage.io; + +import java.io.IOException; +import java.io.OutputStream; + +/** + * Output stream adapter for a BlockingInputStream. + * + * @author Chris Offerman + */ +public class BlockingOutputStream extends OutputStream { + + private BlockingInputStream bis; + + /** Create a new BlockingOutputStream adapter. + * + *@param stream The BlockingInputStream to adapt. + */ + public BlockingOutputStream(BlockingInputStream stream) { + bis = stream; + } + + /** + * BlockingInputStream of this BlockingOutputStream. + */ + public BlockingInputStream getInputStream() { + return bis; + } + + /** + * Writes the specified byte to this output stream. The general + * contract for write is that one byte is written + * to the output stream. The byte to be written is the eight + * low-order bits of the argument b. The 24 + * high-order bits of b are ignored. + * + * + * @param b the byte. + * @throws ExistIOException if an I/O error occurs. In particular, + * an ExistIOException may be thrown if the + * output stream has been closed. + */ + @Override + public void write(int b) throws IOException { + bis.writeOutputStream(b); + } + + /** + * Writes len bytes from the specified byte array + * starting at offset off to this output stream. + * The general contract for write(b, off, len) is that + * some of the bytes in the array b are written to the + * output stream in order; element b[off] is the first + * byte written and b[off+len-1] is the last byte written + * by this operation. + * + * + * @param b the data. + * @param off the start offset in the data. + * @param len the number of bytes to write. + * @throws IOException if an I/O error occurs. In particular, + * an IOException is thrown if the output + * stream is closed. + */ + @Override + public void write(byte b[], int off, int len) throws IOException { + bis.writeOutputStream(b, off, len); + } + + /** + * Closes this output stream. + * A closed stream cannot perform output operations and cannot be reopened. + *

+ * This method blocks its caller until the corresponding input stream is + * closed or an exception occurs. + * + * @throws IOException if an I/O error occurs. + */ + @Override + public void close() throws IOException { + bis.closeOutputStream(); + } + + /** + * Closes this output stream, specifying that an exception has occurred. + * This will cause all consumer calls to be unblocked and throw an + * IOException with this exception as its cause. + * BlockingInputStream specific method. + * @throws IOException if an I/O error occurs. + */ + public void close(Exception ex) throws IOException { + bis.closeOutputStream(ex); + } + + /** + * Flushes this output stream and forces any buffered output bytes + * to be written out. + *

+ * This methods blocks its caller until all buffered bytes are actually + * read by the consuming threads. + * + * + * @throws IOException if an I/O error occurs. + */ + @Override + public void flush() throws IOException { + bis.flushOutputStream(); + } +} diff --git a/src/org/exist/storage/lock/FileLockHeartBeat.java b/src/org/exist/storage/lock/FileLockHeartBeat.java index 61fdfc967e8..14bbd021670 100644 --- a/src/org/exist/storage/lock/FileLockHeartBeat.java +++ b/src/org/exist/storage/lock/FileLockHeartBeat.java @@ -1,77 +1,77 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2006-2007 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ -package org.exist.storage.lock; - -import org.exist.scheduler.JobDescription; -import org.quartz.Job; -import org.quartz.JobDataMap; -import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; - -import java.io.IOException; -import java.util.Map; - -/** - * Provides a Scheduled HeartBeat for the FileLock - */ -public class FileLockHeartBeat implements JobDescription, Job { - - private String JOB_NAME = "FileLockHeartBeat"; - - public FileLockHeartBeat() { - //Nothing to do - } - - public FileLockHeartBeat(String lockName) { - JOB_NAME += ": " + lockName; - } - - public String getName() { - return JOB_NAME; - } - - public void setName(String name) { - //Nothing to do - } - - public String getGroup() { - return "eXist.internal"; - } - - public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { - //get the file lock - final JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap(); - final Map params = (Map) jobDataMap.get("params"); - final FileLock lock = params.get(FileLock.class.getName()); - if(lock != null) { - try { - lock.save(); - } catch(final IOException e) { - lock.message("Caught exception while trying to write lock file", e); - } - } else { - //abort this job - final JobExecutionException jat = new JobExecutionException("Unable to write heart-beat: lock was null"); - jat.setUnscheduleFiringTrigger(true); - } - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2006-2007 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id$ + */ +package org.exist.storage.lock; + +import org.exist.scheduler.JobDescription; +import org.quartz.Job; +import org.quartz.JobDataMap; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +import java.io.IOException; +import java.util.Map; + +/** + * Provides a Scheduled HeartBeat for the FileLock + */ +public class FileLockHeartBeat implements JobDescription, Job { + + private String JOB_NAME = "FileLockHeartBeat"; + + public FileLockHeartBeat() { + //Nothing to do + } + + public FileLockHeartBeat(String lockName) { + JOB_NAME += ": " + lockName; + } + + public String getName() { + return JOB_NAME; + } + + public void setName(String name) { + //Nothing to do + } + + public String getGroup() { + return "eXist.internal"; + } + + public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + //get the file lock + final JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap(); + final Map params = (Map) jobDataMap.get("params"); + final FileLock lock = params.get(FileLock.class.getName()); + if(lock != null) { + try { + lock.save(); + } catch(final IOException e) { + lock.message("Caught exception while trying to write lock file", e); + } + } else { + //abort this job + final JobExecutionException jat = new JobExecutionException("Unable to write heart-beat: lock was null"); + jat.setUnscheduleFiringTrigger(true); + } + } +} diff --git a/src/org/exist/storage/lock/LockOwner.java b/src/org/exist/storage/lock/LockOwner.java index 74db21ed3f4..4dd6cb790bc 100644 --- a/src/org/exist/storage/lock/LockOwner.java +++ b/src/org/exist/storage/lock/LockOwner.java @@ -1,52 +1,52 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.storage.lock; - -/** - * Used to track acquired locks, mainly for debugging. - */ -public class LockOwner { - - /** - * Global flag: set to true to receive debugging output, in particular, - * to see where a lock was acquired. Note: it adds some considerable - * processing overhead. - */ - public static boolean DEBUG = false; - - private final Thread owner; - private Throwable stack = null; - - public LockOwner(Thread owner) { - this.owner = owner; - if (DEBUG) - {this.stack = new Throwable().fillInStackTrace();} - } - - public final Thread getOwner() { - return owner; - } - - public final Throwable getStack() { - return stack; - } +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.storage.lock; + +/** + * Used to track acquired locks, mainly for debugging. + */ +public class LockOwner { + + /** + * Global flag: set to true to receive debugging output, in particular, + * to see where a lock was acquired. Note: it adds some considerable + * processing overhead. + */ + public static boolean DEBUG = false; + + private final Thread owner; + private Throwable stack = null; + + public LockOwner(Thread owner) { + this.owner = owner; + if (DEBUG) + {this.stack = new Throwable().fillInStackTrace();} + } + + public final Thread getOwner() { + return owner; + } + + public final Throwable getStack() { + return stack; + } } \ No newline at end of file diff --git a/src/org/exist/storage/lock/LockedDocumentMap.java b/src/org/exist/storage/lock/LockedDocumentMap.java index f20ff5cfc7d..07d6ca52ced 100644 --- a/src/org/exist/storage/lock/LockedDocumentMap.java +++ b/src/org/exist/storage/lock/LockedDocumentMap.java @@ -1,113 +1,113 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2007 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ -package org.exist.storage.lock; - -import org.exist.collections.Collection; -import org.exist.dom.DefaultDocumentSet; -import org.exist.dom.DocumentImpl; -import org.exist.dom.DocumentSet; -import org.exist.dom.MutableDocumentSet; -import org.exist.util.hashtable.Int2ObjectHashMap; - -/** - * This map is used by the XQuery engine to track how many read locks were - * acquired for a document during query execution. - */ -public class LockedDocumentMap extends Int2ObjectHashMap { - - public LockedDocumentMap() { - super(29, 1.75); - } - - public void add(DocumentImpl document) { - LockedDocument entry = (LockedDocument) get(document.getDocId()); - if (entry == null) { - entry = new LockedDocument(document); - put(document.getDocId(), entry); - } - entry.locksAcquired++; - } - - public MutableDocumentSet toDocumentSet() { - final MutableDocumentSet docs = new DefaultDocumentSet(size()); - LockedDocument lockedDocument; - for(int idx = 0; idx < tabSize; idx++) { - if(values[idx] == null || values[idx] == REMOVED) - {continue;} - lockedDocument = (LockedDocument) values[idx]; - docs.add(lockedDocument.document); - } - return docs; - } - - public DocumentSet getDocsByCollection(Collection collection, - boolean includeSubColls, MutableDocumentSet targetSet) { - if (targetSet == null) - {targetSet = new DefaultDocumentSet(size());} - LockedDocument lockedDocument; - for(int idx = 0; idx < tabSize; idx++) { - if(values[idx] == null || values[idx] == REMOVED) - {continue;} - lockedDocument = (LockedDocument) values[idx]; - if (lockedDocument.document.getCollection().getURI().startsWith(collection.getURI())) - {targetSet.add(lockedDocument.document);} - } - return targetSet; - } - - public void unlock() { - LockedDocument lockedDocument; - for(int idx = 0; idx < tabSize; idx++) { - if(values[idx] == null || values[idx] == REMOVED) - {continue;} - lockedDocument = (LockedDocument) values[idx]; - unlockDocument(lockedDocument); - } - } - - public LockedDocumentMap unlockSome(DocumentSet keep) { - LockedDocument lockedDocument; - for(int idx = 0; idx < tabSize; idx++) { - if(values[idx] == null || values[idx] == REMOVED) - {continue;} - lockedDocument = (LockedDocument) values[idx]; - if (!keep.contains(lockedDocument.document.getDocId())) { - values[idx] = REMOVED; - unlockDocument(lockedDocument); - } - } - return this; - } - - private void unlockDocument(LockedDocument lockedDocument) { - final Lock documentLock = lockedDocument.document.getUpdateLock(); - documentLock.release(Lock.WRITE_LOCK, lockedDocument.locksAcquired); - } - - private static class LockedDocument { - private DocumentImpl document; - private int locksAcquired = 0; - public LockedDocument(DocumentImpl document) { - this.document = document; - } - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2007 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id$ + */ +package org.exist.storage.lock; + +import org.exist.collections.Collection; +import org.exist.dom.DefaultDocumentSet; +import org.exist.dom.DocumentImpl; +import org.exist.dom.DocumentSet; +import org.exist.dom.MutableDocumentSet; +import org.exist.util.hashtable.Int2ObjectHashMap; + +/** + * This map is used by the XQuery engine to track how many read locks were + * acquired for a document during query execution. + */ +public class LockedDocumentMap extends Int2ObjectHashMap { + + public LockedDocumentMap() { + super(29, 1.75); + } + + public void add(DocumentImpl document) { + LockedDocument entry = (LockedDocument) get(document.getDocId()); + if (entry == null) { + entry = new LockedDocument(document); + put(document.getDocId(), entry); + } + entry.locksAcquired++; + } + + public MutableDocumentSet toDocumentSet() { + final MutableDocumentSet docs = new DefaultDocumentSet(size()); + LockedDocument lockedDocument; + for(int idx = 0; idx < tabSize; idx++) { + if(values[idx] == null || values[idx] == REMOVED) + {continue;} + lockedDocument = (LockedDocument) values[idx]; + docs.add(lockedDocument.document); + } + return docs; + } + + public DocumentSet getDocsByCollection(Collection collection, + boolean includeSubColls, MutableDocumentSet targetSet) { + if (targetSet == null) + {targetSet = new DefaultDocumentSet(size());} + LockedDocument lockedDocument; + for(int idx = 0; idx < tabSize; idx++) { + if(values[idx] == null || values[idx] == REMOVED) + {continue;} + lockedDocument = (LockedDocument) values[idx]; + if (lockedDocument.document.getCollection().getURI().startsWith(collection.getURI())) + {targetSet.add(lockedDocument.document);} + } + return targetSet; + } + + public void unlock() { + LockedDocument lockedDocument; + for(int idx = 0; idx < tabSize; idx++) { + if(values[idx] == null || values[idx] == REMOVED) + {continue;} + lockedDocument = (LockedDocument) values[idx]; + unlockDocument(lockedDocument); + } + } + + public LockedDocumentMap unlockSome(DocumentSet keep) { + LockedDocument lockedDocument; + for(int idx = 0; idx < tabSize; idx++) { + if(values[idx] == null || values[idx] == REMOVED) + {continue;} + lockedDocument = (LockedDocument) values[idx]; + if (!keep.contains(lockedDocument.document.getDocId())) { + values[idx] = REMOVED; + unlockDocument(lockedDocument); + } + } + return this; + } + + private void unlockDocument(LockedDocument lockedDocument) { + final Lock documentLock = lockedDocument.document.getUpdateLock(); + documentLock.release(Lock.WRITE_LOCK, lockedDocument.locksAcquired); + } + + private static class LockedDocument { + private DocumentImpl document; + private int locksAcquired = 0; + public LockedDocument(DocumentImpl document) { + this.document = document; + } + } +} diff --git a/src/org/exist/storage/md/Meta.java b/src/org/exist/storage/md/Meta.java index 2f5c759635f..ec869d3a644 100644 --- a/src/org/exist/storage/md/Meta.java +++ b/src/org/exist/storage/md/Meta.java @@ -1,39 +1,39 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2012 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.storage.md; - -/** - * @author Dmitriy Shabanov - * - */ -public interface Meta { - - public String getUUID(); - - public String getKey(); - - public Object getValue(); - - public String getObject(); - - public void delete(); +/* + * eXist Open Source Native XML Database + * Copyright (C) 2012 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.storage.md; + +/** + * @author Dmitriy Shabanov + * + */ +public interface Meta { + + public String getUUID(); + + public String getKey(); + + public Object getValue(); + + public String getObject(); + + public void delete(); } \ No newline at end of file diff --git a/src/org/exist/storage/md/MetaData.java b/src/org/exist/storage/md/MetaData.java index 49eec06a49d..4d0e2899ddd 100644 --- a/src/org/exist/storage/md/MetaData.java +++ b/src/org/exist/storage/md/MetaData.java @@ -1,86 +1,86 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2012 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.storage.md; - -import java.util.List; - -import org.apache.log4j.Logger; -import org.exist.EXistException; -import org.exist.collections.Collection; -import org.exist.dom.DocumentAtExist; -import org.exist.dom.DocumentImpl; -import org.exist.security.PermissionDeniedException; -import org.exist.storage.MetaStorage; -import org.exist.xmldb.XmldbURI; - -/** - * @author Dmitriy Shabanov - * - */ -public abstract class MetaData implements MetaStorage { - - protected static MetaData _ = null; - - public static MetaData get() { - return _; - } - - protected final static Logger LOG = Logger.getLogger(MetaData.class); - - public abstract DocumentImpl getDocument(String uuid) throws EXistException, PermissionDeniedException; - public abstract Collection getCollection(String uuid) throws EXistException, PermissionDeniedException; - - public abstract List matchDocuments(String key, String value) throws EXistException, PermissionDeniedException; - public abstract List matchDocumentsByKey(String key) throws EXistException, PermissionDeniedException; - public abstract List matchDocumentsByValue(String value) throws EXistException, PermissionDeniedException; - - public abstract Metas addMetas(DocumentAtExist doc); - public abstract Metas addMetas(Collection col); - - public abstract Meta getMeta(String uuid); - - //low level - protected abstract Meta _addMeta(Metas metas, String uuid, String key, String value); - protected abstract Metas _addMetas(String uri, String uuid); - protected abstract Metas replaceMetas(XmldbURI uri, String uuid); - - public abstract Metas getMetas(DocumentAtExist doc); - public abstract Metas getMetas(XmldbURI uri); - - public abstract void copyMetas(XmldbURI oldDoc, DocumentImpl newDoc); - public abstract void copyMetas(XmldbURI oldDoc, Collection newCol); - - public abstract void moveMetas(XmldbURI oldUri, XmldbURI newUri); - - public abstract void delMetas(XmldbURI uri); - - public abstract void sync(); - public abstract void close(); - - public abstract XmldbURI UUIDtoURI(String uuid); - public abstract String URItoUUID(XmldbURI uri); - -// public abstract void indexMetas(Metas metas); - -// public abstract NodeImpl search(String queryText, List toBeMatchedURIs) throws XPathException; -// public abstract List searchDocuments(String queryText, List toBeMatchedURIs) throws XPathException; -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2012 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.storage.md; + +import java.util.List; + +import org.apache.log4j.Logger; +import org.exist.EXistException; +import org.exist.collections.Collection; +import org.exist.dom.DocumentAtExist; +import org.exist.dom.DocumentImpl; +import org.exist.security.PermissionDeniedException; +import org.exist.storage.MetaStorage; +import org.exist.xmldb.XmldbURI; + +/** + * @author Dmitriy Shabanov + * + */ +public abstract class MetaData implements MetaStorage { + + protected static MetaData _ = null; + + public static MetaData get() { + return _; + } + + protected final static Logger LOG = Logger.getLogger(MetaData.class); + + public abstract DocumentImpl getDocument(String uuid) throws EXistException, PermissionDeniedException; + public abstract Collection getCollection(String uuid) throws EXistException, PermissionDeniedException; + + public abstract List matchDocuments(String key, String value) throws EXistException, PermissionDeniedException; + public abstract List matchDocumentsByKey(String key) throws EXistException, PermissionDeniedException; + public abstract List matchDocumentsByValue(String value) throws EXistException, PermissionDeniedException; + + public abstract Metas addMetas(DocumentAtExist doc); + public abstract Metas addMetas(Collection col); + + public abstract Meta getMeta(String uuid); + + //low level + protected abstract Meta _addMeta(Metas metas, String uuid, String key, String value); + protected abstract Metas _addMetas(String uri, String uuid); + protected abstract Metas replaceMetas(XmldbURI uri, String uuid); + + public abstract Metas getMetas(DocumentAtExist doc); + public abstract Metas getMetas(XmldbURI uri); + + public abstract void copyMetas(XmldbURI oldDoc, DocumentImpl newDoc); + public abstract void copyMetas(XmldbURI oldDoc, Collection newCol); + + public abstract void moveMetas(XmldbURI oldUri, XmldbURI newUri); + + public abstract void delMetas(XmldbURI uri); + + public abstract void sync(); + public abstract void close(); + + public abstract XmldbURI UUIDtoURI(String uuid); + public abstract String URItoUUID(XmldbURI uri); + +// public abstract void indexMetas(Metas metas); + +// public abstract NodeImpl search(String queryText, List toBeMatchedURIs) throws XPathException; +// public abstract List searchDocuments(String queryText, List toBeMatchedURIs) throws XPathException; +} diff --git a/src/org/exist/storage/md/Metas.java b/src/org/exist/storage/md/Metas.java index 22bd26f6ed0..0a8ab418231 100644 --- a/src/org/exist/storage/md/Metas.java +++ b/src/org/exist/storage/md/Metas.java @@ -1,45 +1,45 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2012 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.storage.md; - -import java.util.List; - -/** - * @author Dmitriy Shabanov - * - */ -public interface Metas { - - public String getUUID(); - - public String getURI(); - - public Meta get(String key); - - public Meta put(String key, Object value); - - public void delete(String key); - - public List metas(); - - public void delete(); -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2012 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.storage.md; + +import java.util.List; + +/** + * @author Dmitriy Shabanov + * + */ +public interface Metas { + + public String getUUID(); + + public String getURI(); + + public Meta get(String key); + + public Meta put(String key, Object value); + + public void delete(String key); + + public List metas(); + + public void delete(); +} diff --git a/src/org/exist/storage/sync/Sync.java b/src/org/exist/storage/sync/Sync.java index b15a7b93f34..c3b3383b22c 100644 --- a/src/org/exist/storage/sync/Sync.java +++ b/src/org/exist/storage/sync/Sync.java @@ -1,34 +1,34 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-06 Wolfgang M. Meier - * wolfgang@exist-db.org - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id$ - */ -package org.exist.storage.sync; - - -/** - * It will periodically trigger a cache sync to write - * cached pages to disk. - */ -public interface Sync { - - public final static int MINOR_SYNC = 0; - public final static int MAJOR_SYNC = 1; -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-06 Wolfgang M. Meier + * wolfgang@exist-db.org + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ +package org.exist.storage.sync; + + +/** + * It will periodically trigger a cache sync to write + * cached pages to disk. + */ +public interface Sync { + + public final static int MINOR_SYNC = 0; + public final static int MAJOR_SYNC = 1; +} diff --git a/src/org/exist/util/Base64Decoder.java b/src/org/exist/util/Base64Decoder.java index 8ab605d6a24..955d28607df 100644 --- a/src/org/exist/util/Base64Decoder.java +++ b/src/org/exist/util/Base64Decoder.java @@ -1,236 +1,236 @@ -/* - * - * The contents of this [class] are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1999 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ -package org.exist.util; - -import org.apache.commons.io.output.ByteArrayOutputStream; - -/** - * Base 64 text to byte decoder. To produce the binary array from - * base 64 encoding call {@link #translate} for each sequence of - * characters and {@link #getByteArray} to mark closure of the - * character stream and retrieve the binary contents. - * - * @author Based on code from the Mozilla Directory SDK - */ - -public final class Base64Decoder { - private ByteArrayOutputStream out = new ByteArrayOutputStream(); - - private byte token[] = new byte[4]; // input buffer - - private byte bytes[] = new byte[3]; // output buffer - - private int token_length = 0; // input buffer length - - private static final byte NUL = 127; // must be out of range 0-64 - - private static final byte EOF = 126; // must be out of range 0-64 - - private static final byte SP = 125; // must be out of range 0-64 - - private static final byte[] map = { - NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // x00 - x07 - NUL, SP, SP, NUL, NUL, SP, NUL, NUL, // x08 - x0F - NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // x10 - x17 - NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // x18 - x1F - SP, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // x20 - x2F !"#$%&' - NUL, NUL, NUL, 62, NUL, NUL, NUL, 63, // 050-057 ()*+,-./ - 52, 53, 54, 55, 56, 57, 58, 59, // 060-067 01234567 - 60, 61, NUL, NUL, NUL, EOF, NUL, NUL, // 070-077 89:;<=>? - - NUL, 0, 1, 2, 3, 4, 5, 6, // 100-107 @ABCDEFG - 7, 8, 9, 10, 11, 12, 13, 14, // 110-117 HIJKLMNO - 15, 16, 17, 18, 19, 20, 21, 22, // 120-127 PQRSTUVW - 23, 24, 25, NUL, NUL, NUL, NUL, NUL, // 130-137 XYZ[\]^_ - NUL, 26, 27, 28, 29, 30, 31, 32, // 140-147 `abcdefg - 33, 34, 35, 36, 37, 38, 39, 40, // 150-157 hijklmno - 41, 42, 43, 44, 45, 46, 47, 48, // 160-167 pqrstuvw - 49, 50, 51, NUL, NUL, NUL, NUL, NUL, // 170-177 xyz{|}~ - - NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 200-207 - NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 210-217 - NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 220-227 - NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 230-237 - NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 240-247 - NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 250-257 - NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 260-267 - NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 270-277 - - NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 300-307 - NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 310-317 - NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 320-327 - NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 330-337 - NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 340-347 - NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 350-357 - NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 360-367 - NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 370-377 - }; - - - // Fast routine that assumes full 4-char tokens with no '=' in them. - // - private void decode_token() { - final int num = ((token[0] << 18) | - (token[1] << 12) | - (token[2] << 6) | - (token[3])); - - bytes[0] = (byte)(0xFF & (num >> 16)); - bytes[1] = (byte)(0xFF & (num >> 8)); - bytes[2] = (byte)(0xFF & num); - - out.write(bytes, 0, 3); - } - - - // Hairier routine that deals with the final token, which can have fewer - // than four characters, and that might be padded with '='. - // - private void decode_final_token() { - - byte b0 = token[0]; - byte b1 = token[1]; - byte b2 = token[2]; - byte b3 = token[3]; - - int eq_count = 0; - - if (b0 == EOF) { - b0 = 0; - eq_count++; - } - if (b1 == EOF) { - b1 = 0; - eq_count++; - } - if (b2 == EOF) { - b2 = 0; - eq_count++; - } - if (b3 == EOF) { - b3 = 0; - eq_count++; - } - - if (eq_count > 2) { - throw new IllegalArgumentException("The number of '=' signs at the end of a base64 value must not exceed 2"); - } - if (eq_count == 2 && (b1 & 0x0F) != 0) { - throw new IllegalArgumentException("In base64, if the value ends with '==' then the last character must be one of [AQgw]"); - } - if (eq_count == 1 && (b2 & 0x03) != 0) { - throw new IllegalArgumentException("In base64, if the value ends with '=' then the last character must be one of [AEIMQUYcgkosw048]"); - } - - final int num = ((b0 << 18) | (b1 << 12) | (b2 << 6) | (b3)); - - // eq_count will be 0, 1, or 2. - // No "=" padding means 4 bytes mapped to 3, the normal case, - // not handled in this routine. - // "xxx=" means 3 bytes mapped to 2. - // "xx==" means 2 bytes mapped to 1. - // "x===" can't happen, because "x" would then be encoding - // only 6 bits, not 8, the minimum possible. - - out.write((byte)(num >> 16)); // byte 1, count = 0 or 1 or 2 - if (eq_count <= 1) { - out.write((byte)((num >> 8) & 0xFF)); // byte 2, count = 0 or 1 - if (eq_count == 0) { - out.write((byte)(num & 0xFF)); // byte 3, count = 0 - } - } - } - - /** - * Decode the base 64 string into a byte array (which can subsequently be accessed using getByteArray() - * @param str the base 64 string - * @throws IllegalArgumentException if the base64 string is incorrectly formatted - */ - - public final void translate(CharSequence str) throws IllegalArgumentException { - if (token == null) // already saw eof marker? - {return;} - final int length = str.length(); - int lengthAtEOF; - int found_eq = 0; - for (int i = 0; i < length; i++) { - final char c = str.charAt(i); - if (c > 127) { - throw new IllegalArgumentException("non-ASCII character in Base64 value (at offset " + i + ')'); - } - byte t = map[c]; - if (t == NUL) { - throw new IllegalArgumentException("invalid character '" + c + "' in Base64 value (at offset " + i + ')'); - } - if (found_eq > 0 && t != EOF && t != SP) { - throw new IllegalArgumentException("In Base64, an '=' character can appear only at the end"); - } - if (t == EOF) { - if (found_eq > 0) { - found_eq++; - if (found_eq > 2) { - throw new IllegalArgumentException("Base64 value can contain at most two '=' characters"); - } - token_length = (token_length + 1) % 4; - } else { - found_eq = 1; - lengthAtEOF = token_length; - eof(); - token_length = (lengthAtEOF + 1) % 4; - } - } else if (t != SP) { - token[token_length++] = t; - if (token_length == 4) { - if (found_eq == 0) { - decode_token(); - } - token_length = 0; - } - } - } - if (token_length != 0) { - throw new IllegalArgumentException("Base64 input must be a multiple of four characters"); - } - } - - private void eof() { - if (token != null && token_length != 0) { - while (token_length < 4) { - token[token_length++] = EOF; - } - decode_final_token(); - } - token_length = 0; - token = new byte[4]; - bytes = new byte[3]; - } - - public byte[] getByteArray() { - eof(); - return out.toByteArray(); - } - - public void reset() { - out.reset(); - } - -} +/* + * + * The contents of this [class] are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1999 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ +package org.exist.util; + +import org.apache.commons.io.output.ByteArrayOutputStream; + +/** + * Base 64 text to byte decoder. To produce the binary array from + * base 64 encoding call {@link #translate} for each sequence of + * characters and {@link #getByteArray} to mark closure of the + * character stream and retrieve the binary contents. + * + * @author Based on code from the Mozilla Directory SDK + */ + +public final class Base64Decoder { + private ByteArrayOutputStream out = new ByteArrayOutputStream(); + + private byte token[] = new byte[4]; // input buffer + + private byte bytes[] = new byte[3]; // output buffer + + private int token_length = 0; // input buffer length + + private static final byte NUL = 127; // must be out of range 0-64 + + private static final byte EOF = 126; // must be out of range 0-64 + + private static final byte SP = 125; // must be out of range 0-64 + + private static final byte[] map = { + NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // x00 - x07 + NUL, SP, SP, NUL, NUL, SP, NUL, NUL, // x08 - x0F + NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // x10 - x17 + NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // x18 - x1F + SP, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // x20 - x2F !"#$%&' + NUL, NUL, NUL, 62, NUL, NUL, NUL, 63, // 050-057 ()*+,-./ + 52, 53, 54, 55, 56, 57, 58, 59, // 060-067 01234567 + 60, 61, NUL, NUL, NUL, EOF, NUL, NUL, // 070-077 89:;<=>? + + NUL, 0, 1, 2, 3, 4, 5, 6, // 100-107 @ABCDEFG + 7, 8, 9, 10, 11, 12, 13, 14, // 110-117 HIJKLMNO + 15, 16, 17, 18, 19, 20, 21, 22, // 120-127 PQRSTUVW + 23, 24, 25, NUL, NUL, NUL, NUL, NUL, // 130-137 XYZ[\]^_ + NUL, 26, 27, 28, 29, 30, 31, 32, // 140-147 `abcdefg + 33, 34, 35, 36, 37, 38, 39, 40, // 150-157 hijklmno + 41, 42, 43, 44, 45, 46, 47, 48, // 160-167 pqrstuvw + 49, 50, 51, NUL, NUL, NUL, NUL, NUL, // 170-177 xyz{|}~ + + NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 200-207 + NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 210-217 + NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 220-227 + NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 230-237 + NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 240-247 + NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 250-257 + NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 260-267 + NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 270-277 + + NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 300-307 + NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 310-317 + NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 320-327 + NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 330-337 + NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 340-347 + NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 350-357 + NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 360-367 + NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, // 370-377 + }; + + + // Fast routine that assumes full 4-char tokens with no '=' in them. + // + private void decode_token() { + final int num = ((token[0] << 18) | + (token[1] << 12) | + (token[2] << 6) | + (token[3])); + + bytes[0] = (byte)(0xFF & (num >> 16)); + bytes[1] = (byte)(0xFF & (num >> 8)); + bytes[2] = (byte)(0xFF & num); + + out.write(bytes, 0, 3); + } + + + // Hairier routine that deals with the final token, which can have fewer + // than four characters, and that might be padded with '='. + // + private void decode_final_token() { + + byte b0 = token[0]; + byte b1 = token[1]; + byte b2 = token[2]; + byte b3 = token[3]; + + int eq_count = 0; + + if (b0 == EOF) { + b0 = 0; + eq_count++; + } + if (b1 == EOF) { + b1 = 0; + eq_count++; + } + if (b2 == EOF) { + b2 = 0; + eq_count++; + } + if (b3 == EOF) { + b3 = 0; + eq_count++; + } + + if (eq_count > 2) { + throw new IllegalArgumentException("The number of '=' signs at the end of a base64 value must not exceed 2"); + } + if (eq_count == 2 && (b1 & 0x0F) != 0) { + throw new IllegalArgumentException("In base64, if the value ends with '==' then the last character must be one of [AQgw]"); + } + if (eq_count == 1 && (b2 & 0x03) != 0) { + throw new IllegalArgumentException("In base64, if the value ends with '=' then the last character must be one of [AEIMQUYcgkosw048]"); + } + + final int num = ((b0 << 18) | (b1 << 12) | (b2 << 6) | (b3)); + + // eq_count will be 0, 1, or 2. + // No "=" padding means 4 bytes mapped to 3, the normal case, + // not handled in this routine. + // "xxx=" means 3 bytes mapped to 2. + // "xx==" means 2 bytes mapped to 1. + // "x===" can't happen, because "x" would then be encoding + // only 6 bits, not 8, the minimum possible. + + out.write((byte)(num >> 16)); // byte 1, count = 0 or 1 or 2 + if (eq_count <= 1) { + out.write((byte)((num >> 8) & 0xFF)); // byte 2, count = 0 or 1 + if (eq_count == 0) { + out.write((byte)(num & 0xFF)); // byte 3, count = 0 + } + } + } + + /** + * Decode the base 64 string into a byte array (which can subsequently be accessed using getByteArray() + * @param str the base 64 string + * @throws IllegalArgumentException if the base64 string is incorrectly formatted + */ + + public final void translate(CharSequence str) throws IllegalArgumentException { + if (token == null) // already saw eof marker? + {return;} + final int length = str.length(); + int lengthAtEOF; + int found_eq = 0; + for (int i = 0; i < length; i++) { + final char c = str.charAt(i); + if (c > 127) { + throw new IllegalArgumentException("non-ASCII character in Base64 value (at offset " + i + ')'); + } + byte t = map[c]; + if (t == NUL) { + throw new IllegalArgumentException("invalid character '" + c + "' in Base64 value (at offset " + i + ')'); + } + if (found_eq > 0 && t != EOF && t != SP) { + throw new IllegalArgumentException("In Base64, an '=' character can appear only at the end"); + } + if (t == EOF) { + if (found_eq > 0) { + found_eq++; + if (found_eq > 2) { + throw new IllegalArgumentException("Base64 value can contain at most two '=' characters"); + } + token_length = (token_length + 1) % 4; + } else { + found_eq = 1; + lengthAtEOF = token_length; + eof(); + token_length = (lengthAtEOF + 1) % 4; + } + } else if (t != SP) { + token[token_length++] = t; + if (token_length == 4) { + if (found_eq == 0) { + decode_token(); + } + token_length = 0; + } + } + } + if (token_length != 0) { + throw new IllegalArgumentException("Base64 input must be a multiple of four characters"); + } + } + + private void eof() { + if (token != null && token_length != 0) { + while (token_length < 4) { + token[token_length++] = EOF; + } + decode_final_token(); + } + token_length = 0; + token = new byte[4]; + bytes = new byte[3]; + } + + public byte[] getByteArray() { + eof(); + return out.toByteArray(); + } + + public void reset() { + out.reset(); + } + +} diff --git a/src/org/exist/util/Base64Encoder.java b/src/org/exist/util/Base64Encoder.java index 5536494fd2c..7fa69b3b5f7 100644 --- a/src/org/exist/util/Base64Encoder.java +++ b/src/org/exist/util/Base64Encoder.java @@ -1,150 +1,150 @@ -/* - * - * The contents of this [class] are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1999 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ -package org.exist.util; - - /** - * Byte to text encoder using base 64 encoding. To create a base 64 - * encoding of a byte stream call {@link #translate} for every - * sequence of bytes and {@link #getCharArray} to mark closure of - * the byte stream and retrieve the text presentation. - * - * @author Based on code from the Mozilla Directory SDK - */ -public final class Base64Encoder { - - private FastStringBuffer out = new FastStringBuffer(256); - - private int buf = 0; // a 24-bit quantity - - private int buf_bytes = 0; // how many octets are set in it - - private char line[] = new char[74]; // output buffer - - private int line_length = 0; // output buffer fill pointer - - //static private final byte crlf[] = "\r\n".getBytes(); - - private static final char map[] = { - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', // 0-7 - 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', // 8-15 - 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', // 16-23 - 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', // 24-31 - 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', // 32-39 - 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', // 40-47 - 'w', 'x', 'y', 'z', '0', '1', '2', '3', // 48-55 - '4', '5', '6', '7', '8', '9', '+', '/', // 56-63 - }; - - - private void encode_token() { - final int i = line_length; - line[i] = map[0x3F & (buf >> 18)]; // sextet 1 (octet 1) - line[i + 1] = map[0x3F & (buf >> 12)]; // sextet 2 (octet 1 and 2) - line[i + 2] = map[0x3F & (buf >> 6)]; // sextet 3 (octet 2 and 3) - line[i + 3] = map[0x3F & buf]; // sextet 4 (octet 3) - line_length += 4; - buf = 0; - buf_bytes = 0; - } - - - private void encode_partial_token() { - final int i = line_length; - line[i] = map[0x3F & (buf >> 18)]; // sextet 1 (octet 1) - line[i + 1] = map[0x3F & (buf >> 12)]; // sextet 2 (octet 1 and 2) - - if (buf_bytes == 1) - {line[i + 2] = '=';} - else - {line[i + 2] = map[0x3F & (buf >> 6)];} // sextet 3 (octet 2 and 3) - - if (buf_bytes <= 2) - {line[i + 3] = '=';} - else - {line[i + 3] = map[0x3F & buf];} // sextet 4 (octet 3) - line_length += 4; - buf = 0; - buf_bytes = 0; - } - - - private void flush_line() { - out.append(line, 0, line_length); - line_length = 0; - } - - - /** - * Given a sequence of input bytes, produces a sequence of output bytes - * using the base64 encoding. If there are bytes in `out' already, the - * new bytes are appended, so the caller should do `out.setLength(0)' - * first if that's desired. - */ - public final void translate(byte[] in) { - final int in_length = in.length; - - for (int i = 0; i < in_length; i++) { - if (buf_bytes == 0) - {buf = (buf & 0x00FFFF) | (in[i] << 16);} - else if (buf_bytes == 1) - {buf = (buf & 0xFF00FF) | ((in[i] << 8) & 0x00FFFF);} - else - {buf = (buf & 0xFFFF00) | (in[i] & 0x0000FF);} - - if ((++buf_bytes) == 3) { - encode_token(); - if (line_length >= 72) { - flush_line(); - } - } - - if (i == (in_length - 1)) { - if ((buf_bytes > 0) && (buf_bytes < 3)) - {encode_partial_token();} - if (line_length > 0) - {flush_line();} - } - } - - for (int i = 0; i < line.length; i++) - line[i] = 0; - } - - - public char[] getCharArray() { - char[] ch; - - if (buf_bytes != 0) - {encode_partial_token();} - flush_line(); - for (int i = 0; i < line.length; i++) - line[i] = 0; - ch = new char[out.length()]; - if (out.length() > 0) - {out.getChars(0, out.length(), ch, 0);} - return ch; - } - - public void reset() { - out.setLength(0); - } +/* + * + * The contents of this [class] are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1999 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ +package org.exist.util; + + /** + * Byte to text encoder using base 64 encoding. To create a base 64 + * encoding of a byte stream call {@link #translate} for every + * sequence of bytes and {@link #getCharArray} to mark closure of + * the byte stream and retrieve the text presentation. + * + * @author Based on code from the Mozilla Directory SDK + */ +public final class Base64Encoder { + + private FastStringBuffer out = new FastStringBuffer(256); + + private int buf = 0; // a 24-bit quantity + + private int buf_bytes = 0; // how many octets are set in it + + private char line[] = new char[74]; // output buffer + + private int line_length = 0; // output buffer fill pointer + + //static private final byte crlf[] = "\r\n".getBytes(); + + private static final char map[] = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', // 0-7 + 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', // 8-15 + 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', // 16-23 + 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', // 24-31 + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', // 32-39 + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', // 40-47 + 'w', 'x', 'y', 'z', '0', '1', '2', '3', // 48-55 + '4', '5', '6', '7', '8', '9', '+', '/', // 56-63 + }; + + + private void encode_token() { + final int i = line_length; + line[i] = map[0x3F & (buf >> 18)]; // sextet 1 (octet 1) + line[i + 1] = map[0x3F & (buf >> 12)]; // sextet 2 (octet 1 and 2) + line[i + 2] = map[0x3F & (buf >> 6)]; // sextet 3 (octet 2 and 3) + line[i + 3] = map[0x3F & buf]; // sextet 4 (octet 3) + line_length += 4; + buf = 0; + buf_bytes = 0; + } + + + private void encode_partial_token() { + final int i = line_length; + line[i] = map[0x3F & (buf >> 18)]; // sextet 1 (octet 1) + line[i + 1] = map[0x3F & (buf >> 12)]; // sextet 2 (octet 1 and 2) + + if (buf_bytes == 1) + {line[i + 2] = '=';} + else + {line[i + 2] = map[0x3F & (buf >> 6)];} // sextet 3 (octet 2 and 3) + + if (buf_bytes <= 2) + {line[i + 3] = '=';} + else + {line[i + 3] = map[0x3F & buf];} // sextet 4 (octet 3) + line_length += 4; + buf = 0; + buf_bytes = 0; + } + + + private void flush_line() { + out.append(line, 0, line_length); + line_length = 0; + } + + + /** + * Given a sequence of input bytes, produces a sequence of output bytes + * using the base64 encoding. If there are bytes in `out' already, the + * new bytes are appended, so the caller should do `out.setLength(0)' + * first if that's desired. + */ + public final void translate(byte[] in) { + final int in_length = in.length; + + for (int i = 0; i < in_length; i++) { + if (buf_bytes == 0) + {buf = (buf & 0x00FFFF) | (in[i] << 16);} + else if (buf_bytes == 1) + {buf = (buf & 0xFF00FF) | ((in[i] << 8) & 0x00FFFF);} + else + {buf = (buf & 0xFFFF00) | (in[i] & 0x0000FF);} + + if ((++buf_bytes) == 3) { + encode_token(); + if (line_length >= 72) { + flush_line(); + } + } + + if (i == (in_length - 1)) { + if ((buf_bytes > 0) && (buf_bytes < 3)) + {encode_partial_token();} + if (line_length > 0) + {flush_line();} + } + } + + for (int i = 0; i < line.length; i++) + line[i] = 0; + } + + + public char[] getCharArray() { + char[] ch; + + if (buf_bytes != 0) + {encode_partial_token();} + flush_line(); + for (int i = 0; i < line.length; i++) + line[i] = 0; + ch = new char[out.length()]; + if (out.length() > 0) + {out.getChars(0, out.length(), ch, 0);} + return ch; + } + + public void reset() { + out.setLength(0); + } } \ No newline at end of file diff --git a/src/org/exist/util/FloatingPointConverter.java b/src/org/exist/util/FloatingPointConverter.java index 52617be2169..d607497ea70 100644 --- a/src/org/exist/util/FloatingPointConverter.java +++ b/src/org/exist/util/FloatingPointConverter.java @@ -1,648 +1,648 @@ -package org.exist.util; - -import java.math.BigInteger; - -/** - * This is a utility class that handles formatting of numbers as strings. - *

- * The algorithm for converting a floating point number to a string is taken from Guy L. Steele and - * Jon L. White, How to Print Floating-Point Numbers Accurately, ACM SIGPLAN 1990. It is algorithm - * (FPP)2 from that paper. There are three separate implementations of the algorithm: - *

    - *
  • One using long arithmetic and generating non-exponential output representations - *
  • One using BigInteger arithmetic and generating non-exponential output representation - *
  • One using BigInteger arithmetic and generating exponential output representations - *
- *

- * The choice of method depends on the value of the number being formatted. - *

- * The module contains some residual code (mainly the routine for formatting integers) from the class - * AppenderHelper by Jack Shirazi in the O'Reilly book Java Performance Tuning. The floating point routines - * in that module were found to be unsuitable, since they used floating point arithmetic which introduces - * rounding errors. - *

- * There are several reasons for doing this conversion within Saxon, rather than leaving it all to Java. - * Firstly, there are differences in the required output format, notably the absence of ".0" when formatting - * whole numbers, and the different rules for the range of numbers where exponential notation is used. - * Secondly, there are bugs in some Java implementations, for example JDK outputs 0.001 as 0.0010, and - * IKVM/GNU gets things very wrong sometimes. Finally, this implementation is faster for "everyday" numbers, - * though it is slower for more extreme numbers. It would probably be reasonable to hand over formatting - * to the Java platform (at least when running the Sun JDK) for exponents outside the range -7 to +7. - */ - -public class FloatingPointConverter { - - public static FloatingPointConverter THE_INSTANCE = new FloatingPointConverter(); - - private FloatingPointConverter(){} - - /** - * char array holding the characters for the string "-Infinity". - */ - private static final char[] NEGATIVE_INFINITY = {'-', 'I', 'N', 'F'}; - /** - * char array holding the characters for the string "Infinity". - */ - private static final char[] POSITIVE_INFINITY = {'I', 'N', 'F'}; - /** - * char array holding the characters for the string "NaN". - */ - private static final char[] NaN = {'N', 'a', 'N'}; - - private static final char[] charForDigit = { - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' - }; - - private static final long doubleSignMask = 0x8000000000000000L; - private static final long doubleExpMask = 0x7ff0000000000000L; - private static final int doubleExpShift = 52; - private static final int doubleExpBias = 1023; - private static final long doubleFractMask = 0xfffffffffffffL; - private static final int floatSignMask = 0x80000000; - private static final int floatExpMask = 0x7f800000; - private static final int floatExpShift = 23; - private static final int floatExpBias = 127; - private static final int floatFractMask = 0x7fffff; - - private static final BigInteger TEN = BigInteger.valueOf(10); - private static final BigInteger NINE = BigInteger.valueOf(9); - - /** - * Format an integer, appending the string representation of the integer to a string buffer - * @param s the string buffer - * @param i the integer to be formatted - * @return the supplied string buffer, containing the appended integer - */ - - public static FastStringBuffer appendInt(FastStringBuffer s, int i) { - if (i < 0) { - if (i == Integer.MIN_VALUE) { - //cannot make this positive due to integer overflow - s.append("-2147483648"); - return s; - } - s.append('-'); - i = -i; - } - int c; - if (i < 10) { - //one digit - s.append(charForDigit[i]); - return s; - } else if (i < 100) { - //two digits - s.append(charForDigit[i / 10]); - s.append(charForDigit[i % 10]); - return s; - } else if (i < 1000) { - //three digits - s.append(charForDigit[i / 100]); - s.append(charForDigit[(c = i % 100) / 10]); - s.append(charForDigit[c % 10]); - return s; - } else if (i < 10000) { - //four digits - s.append(charForDigit[i / 1000]); - s.append(charForDigit[(c = i % 1000) / 100]); - s.append(charForDigit[(c %= 100) / 10]); - s.append(charForDigit[c % 10]); - return s; - } else if (i < 100000) { - //five digits - s.append(charForDigit[i / 10000]); - s.append(charForDigit[(c = i % 10000) / 1000]); - s.append(charForDigit[(c %= 1000) / 100]); - s.append(charForDigit[(c %= 100) / 10]); - s.append(charForDigit[c % 10]); - return s; - } else if (i < 1000000) { - //six digits - s.append(charForDigit[i / 100000]); - s.append(charForDigit[(c = i % 100000) / 10000]); - s.append(charForDigit[(c %= 10000) / 1000]); - s.append(charForDigit[(c %= 1000) / 100]); - s.append(charForDigit[(c %= 100) / 10]); - s.append(charForDigit[c % 10]); - return s; - } else if (i < 10000000) { - //seven digits - s.append(charForDigit[i / 1000000]); - s.append(charForDigit[(c = i % 1000000) / 100000]); - s.append(charForDigit[(c %= 100000) / 10000]); - s.append(charForDigit[(c %= 10000) / 1000]); - s.append(charForDigit[(c %= 1000) / 100]); - s.append(charForDigit[(c %= 100) / 10]); - s.append(charForDigit[c % 10]); - return s; - } else if (i < 100000000) { - //eight digits - s.append(charForDigit[i / 10000000]); - s.append(charForDigit[(c = i % 10000000) / 1000000]); - s.append(charForDigit[(c %= 1000000) / 100000]); - s.append(charForDigit[(c %= 100000) / 10000]); - s.append(charForDigit[(c %= 10000) / 1000]); - s.append(charForDigit[(c %= 1000) / 100]); - s.append(charForDigit[(c %= 100) / 10]); - s.append(charForDigit[c % 10]); - return s; - } else if (i < 1000000000) { - //nine digits - s.append(charForDigit[i / 100000000]); - s.append(charForDigit[(c = i % 100000000) / 10000000]); - s.append(charForDigit[(c %= 10000000) / 1000000]); - s.append(charForDigit[(c %= 1000000) / 100000]); - s.append(charForDigit[(c %= 100000) / 10000]); - s.append(charForDigit[(c %= 10000) / 1000]); - s.append(charForDigit[(c %= 1000) / 100]); - s.append(charForDigit[(c %= 100) / 10]); - s.append(charForDigit[c % 10]); - return s; - } else { - //ten digits - s.append(charForDigit[i / 1000000000]); - s.append(charForDigit[(c = i % 1000000000) / 100000000]); - s.append(charForDigit[(c %= 100000000) / 10000000]); - s.append(charForDigit[(c %= 10000000) / 1000000]); - s.append(charForDigit[(c %= 1000000) / 100000]); - s.append(charForDigit[(c %= 100000) / 10000]); - s.append(charForDigit[(c %= 10000) / 1000]); - s.append(charForDigit[(c %= 1000) / 100]); - s.append(charForDigit[(c %= 100) / 10]); - s.append(charForDigit[c % 10]); - return s; - } - } - - /** - * Implementation of the (FPP)2 algorithm from Steele and White, for doubles in the range - * 0.01 to 1000000, and floats in the range 0.000001 to 1000000. - * In this range (a) XPath requires that the output should not be in exponential - * notation, and (b) the arithmetic can be handled using longs rather than BigIntegers - * @param sb the string buffer to which the formatted result is to be appended - * @param e the exponent of the floating point number - * @param f the fraction part of the floating point number, such that the "real" value of the - * number is f * 2^(e-p), with p>=0 and 0 lt f lt 2^p - * @param p the precision - */ - - private static void fppfpp(FastStringBuffer sb, int e, long f, int p) { - long R = f << Math.max(e-p, 0); - long S = 1L << Math.max(0, -(e-p)); - long Mminus = 1L << Math.max(e-p, 0); - long Mplus = Mminus; - boolean initial = true; - - // simpleFixup - - if (f == 1L << (p-1)) { - Mplus = Mplus << 1; - R = R << 1; - S = S << 1; - } - int k = 0; - while (R < (S+9)/10) { // (S+9)/10 == ceiling(S/10) - k--; - R = R*10; - Mminus = Mminus * 10; - Mplus = Mplus * 10; - } - while (2*R + Mplus >= 2*S) { - S = S*10; - k++; - } - - for (int z=k; z<0; z++) { - if (initial) { - sb.append("0."); - } - initial = false; - sb.append('0'); - } - - // end simpleFixup - - //int H = k-1; - - boolean low; - boolean high; - int U; - while (true) { - k--; - U = (int)(R*10 / S); - R = R*10 % S; - Mminus = Mminus * 10; - Mplus = Mplus * 10; - low = 2*R < Mminus; - high = 2*R > 2*S - Mplus; - if (low || high) {break;} - if (k == -1) { - if (initial) { - sb.append('0'); - } - sb.append('.'); - } - sb.append(charForDigit[U]); - initial = false; - } - if (high && (!low || 2*R > S)) { - U++; - } - if (k == -1) { - if (initial) { - sb.append('0'); - } - sb.append('.'); - } - sb.append(charForDigit[U]); - for (int z=0; z=0 and 0 lt f lt 2^p - * @param p the precision - */ - - private static void fppfppBig(FastStringBuffer sb, int e, long f, int p) { - //long R = f << Math.max(e-p, 0); - BigInteger R = BigInteger.valueOf(f).shiftLeft(Math.max(e-p, 0)); - - //long S = 1L << Math.max(0, -(e-p)); - BigInteger S = BigInteger.ONE.shiftLeft(Math.max(0, -(e-p))); - - //long Mminus = 1 << Math.max(e-p, 0); - BigInteger Mminus = BigInteger.ONE.shiftLeft(Math.max(e-p, 0)); - - //long Mplus = Mminus; - BigInteger Mplus = Mminus; - - boolean initial = true; - - // simpleFixup - - if (f == 1L << (p-1)) { - Mplus = Mplus.shiftLeft(1); - R = R.shiftLeft(1); - S = S.shiftLeft(1); - } - int k = 0; - while (R.compareTo(S.add(NINE).divide(TEN)) < 0) { // (S+9)/10 == ceiling(S/10) - k--; - R = R.multiply(TEN); - Mminus = Mminus.multiply(TEN); - Mplus = Mplus.multiply(TEN); - } - while (R.shiftLeft(1).add(Mplus).compareTo(S.shiftLeft(1)) >= 0) { - S = S.multiply(TEN); - k++; - } - - for (int z=k; z<0; z++) { - if (initial) { - sb.append("0."); - } - initial = false; - sb.append('0'); - } - - // end simpleFixup - - //int H = k-1; - - boolean low; - boolean high; - int U; - while (true) { - k--; - final BigInteger R10 = R.multiply(TEN); - U = R10.divide(S).intValue(); - R = R10.mod(S); - Mminus = Mminus.multiply(TEN); - Mplus = Mplus.multiply(TEN); - final BigInteger R2 = R.shiftLeft(1); - low = R2.compareTo(Mminus) < 0; - high = R2.compareTo(S.shiftLeft(1).subtract(Mplus)) > 0; - if (low || high) {break;} - if (k == -1) { - if (initial) { - sb.append('0'); - } - sb.append('.'); - } - sb.append(charForDigit[U]); - initial = false; - } - if (high && (!low || R.shiftLeft(1).compareTo(S) > 0)) { - U++; - } - if (k == -1) { - if (initial) { - sb.append('0'); - } - sb.append('.'); - } - sb.append(charForDigit[U]); - for (int z=0; z=0 and 0 lt f lt 2^p - * @param p the precision - */ - - private static void fppfppExponential(FastStringBuffer sb, int e, long f, int p) { - //long R = f << Math.max(e-p, 0); - BigInteger R = BigInteger.valueOf(f).shiftLeft(Math.max(e-p, 0)); - - //long S = 1L << Math.max(0, -(e-p)); - BigInteger S = BigInteger.ONE.shiftLeft(Math.max(0, -(e-p))); - - //long Mminus = 1 << Math.max(e-p, 0); - BigInteger Mminus = BigInteger.ONE.shiftLeft(Math.max(e-p, 0)); - - //long Mplus = Mminus; - BigInteger Mplus = Mminus; - - boolean initial = true; - boolean doneDot = false; - - // simpleFixup - - if (f == 1L << (p-1)) { - Mplus = Mplus.shiftLeft(1); - R = R.shiftLeft(1); - S = S.shiftLeft(1); - } - int k = 0; - while (R.compareTo(S.add(NINE).divide(TEN)) < 0) { // (S+9)/10 == ceiling(S/10) - k--; - R = R.multiply(TEN); - Mminus = Mminus.multiply(TEN); - Mplus = Mplus.multiply(TEN); - } - while (R.shiftLeft(1).add(Mplus).compareTo(S.shiftLeft(1)) >= 0) { - S = S.multiply(TEN); - k++; - } - - // end simpleFixup - - final int H = k-1; - - boolean low; - boolean high; - int U; - while (true) { - k--; - final BigInteger R10 = R.multiply(TEN); - U = R10.divide(S).intValue(); - R = R10.mod(S); - Mminus = Mminus.multiply(TEN); - Mplus = Mplus.multiply(TEN); - final BigInteger R2 = R.shiftLeft(1); - low = R2.compareTo(Mminus) < 0; - high = R2.compareTo(S.shiftLeft(1).subtract(Mplus)) > 0; - if (low || high) {break;} - - sb.append(charForDigit[U]); - if (initial) { - sb.append('.'); - doneDot = true; - } - initial = false; - } - if (high && (!low || R.shiftLeft(1).compareTo(S) > 0)) { - U++; - } - sb.append(charForDigit[U]); - - if (!doneDot) { - sb.append(".0"); - } - sb.append('E'); - appendInt(sb, H); - - } - - /** - * Append a string representation of a double value to a string buffer - * @param s the string buffer to which the result will be appended - * @param value the double to be formatted - * @return the original string buffer, now containing the string representation of the supplied double - */ - - public static FastStringBuffer appendDouble(FastStringBuffer s, double value) { - double d = value; - if (d == Double.NEGATIVE_INFINITY) { - s.append(NEGATIVE_INFINITY); - } else if (d == Double.POSITIVE_INFINITY) { - s.append(POSITIVE_INFINITY); - } else if (d != d) { - s.append(NaN); - } else if (d == 0.0) { - if ((Double.doubleToLongBits(d) & doubleSignMask) != 0) { - s.append('-'); - } - s.append('0'); - } else if (d == Double.MAX_VALUE) { - s.append("1.7976931348623157E308"); - } else if (d == -Double.MAX_VALUE) { - s.append("-1.7976931348623157E308"); - } else if (d == Double.MIN_VALUE) { - s.append("4.9E-324"); - } else if (d == -Double.MIN_VALUE) { - s.append("-4.9E-324"); - } else { - if (d < 0) { - s.append('-'); - d = -d; - } - final boolean exponential = (d >= 1000000 || d < 0.000001); - final long bits = Double.doubleToLongBits(d); - final long fraction = (1L<<52) | (bits & doubleFractMask); - final long rawExp = (bits & doubleExpMask) >> doubleExpShift; - final int exp = (int)rawExp - doubleExpBias; - if (rawExp == 0) { - // don't know how to handle this currently: hand it over to Java to deal with - s.append(Double.toString(value)); - return s; - } - if (exponential) { - fppfppExponential(s, exp, fraction, 52); - } else { - if (d <= 0.01) { - fppfppBig(s, exp, fraction, 52); - } else { - fppfpp(s, exp, fraction, 52); - } - } - - // test code -// try { -// if (Double.parseDouble(s.toString()) != value) { -// System.err.println("*** Round-trip failed: input " + value + -// '(' + Double.doubleToLongBits(value) + ')' + -// " != output " + s.toString() + -// '(' + Double.doubleToLongBits(Double.parseDouble(s.toString())) + ')' ); -// } -// } catch (NumberFormatException e) { -// System.err.println("*** Bad float " + s.toString() + " for input " + value); -// } - } - return s; - } - - /** - * Append a string representation of a float value to a string buffer - * @param s the string buffer to which the result will be appended - * @param value the float to be formatted - * @return the original string buffer, now containing the string representation of the supplied float - */ - - public static FastStringBuffer appendFloat(FastStringBuffer s, float value) { - float f = value; - if (f == Float.NEGATIVE_INFINITY) { - s.append(NEGATIVE_INFINITY); - } else if (f == Float.POSITIVE_INFINITY) { - s.append(POSITIVE_INFINITY); - } else if (f != f) { - s.append(NaN); - } else if (f == 0.0) { - if ((Float.floatToIntBits(f) & floatSignMask) != 0) { - s.append('-'); - } - s.append('0'); - } else if (f == Float.MAX_VALUE) { - s.append("3.4028235E38"); - } else if (f == -Float.MAX_VALUE) { - s.append("-3.4028235E38"); - } else if (f == Float.MIN_VALUE) { - s.append("1.4E-45"); - } else if (f == -Float.MIN_VALUE) { - s.append("-1.4E-45"); - } else { - if (f < 0) { - s.append('-'); - f = -f; - } - final boolean exponential = (f >= 1000000 || f < 0.000001F); - final int bits = Float.floatToIntBits(f); - final int fraction = (1<<23) | (bits & floatFractMask); - final int rawExp = ((bits & floatExpMask) >> floatExpShift); - final int exp = rawExp - floatExpBias; - final int precision = 23; - if (rawExp == 0) { - // don't know how to handle this currently: hand it over to Java to deal with - s.append(Float.toString(value)); - return s; - } - if (exponential) { - fppfppExponential(s, exp, fraction, precision); - } else { - fppfpp(s, exp, fraction, precision); - } - - // test code -// try { -// if (Float.parseFloat(s.toString()) != value) { -// System.err.println("*** Round-trip failed: input " + value + -// '(' + Float.floatToIntBits(value) + ')' + -// " != output " + s.toString() + -// '(' + Float.floatToIntBits(Float.parseFloat(s.toString())) + ')' ); -// } -// } catch (NumberFormatException e) { -// System.err.println("*** Bad float " + s.toString() + " for input " + value); -// } - } - return s; - } - -// public static void main(String[] args) { -// if (args.length > 0 && args[0].equals("F")) { -// if (args.length == 2) { -// StringTokenizer tok = new StringTokenizer(args[1], ","); -// while (tok.hasMoreElements()) { -// String input = tok.nextToken(); -// float f = Float.parseFloat(input); -// FastStringBuffer sb = new FastStringBuffer(20); -// appendFloat(sb, f); -// System.err.println("input: " + input + " output: " + sb.toString() + " java: " + f); -// } -// } else { -// Random gen = new Random(); -// for (int i=1; i<1000; i++) { -// int p=gen.nextInt(999*i*i); -// int q=gen.nextInt(999*i*i); -// String input = (p + "." + q); -// float f = Float.parseFloat(input); -// FastStringBuffer sb = new FastStringBuffer(20); -// appendFloat(sb, f); -// System.err.println("input: " + input + " output: " + sb.toString() + " java: " + f); -// } -// } -// } else { -// if (args.length == 2) { -// StringTokenizer tok = new StringTokenizer(args[1], ","); -// while (tok.hasMoreElements()) { -// String input = tok.nextToken(); -// double f = Double.parseDouble(input); -// FastStringBuffer sb = new FastStringBuffer(20); -// appendDouble(sb, f); -// System.err.println("input: " + input + " output: " + sb.toString() + " java: " + f); -// } -// } else { -// long start = System.currentTimeMillis(); -// Random gen = new Random(); -// for (int i=1; i<100000; i++) { -// //int p=gen.nextInt(999*i*i); -// int q=gen.nextInt(999*i); -// //String input = (p + "." + q); -// String input = "0.000" + q; -// double f = Double.parseDouble(input); -// FastStringBuffer sb = new FastStringBuffer(20); -// appendDouble(sb, f); -// //System.err.println("input: " + input + " output: " + sb.toString() + " java: " + f); -// } -// System.err.println("** elapsed time " + (System.currentTimeMillis() - start)); -// } -// } -// } - - - -} - - -// -// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License"); -// you may not use this file except in compliance with the License. You may obtain a copy of the -// License at http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" basis, -// WITHOUT WARRANTY OF ANY KIND, either express or implied. -// See the License for the specific language governing rights and limitations under the License. -// -// The Original Code is: all this file. -// -// The Initial Developer of the Original Code is Michael H. Kay, based on a published algorithm by -// Guy L. Steele and Jon L. White. -// -// Contributor(s): the appendInt routine, and some of the constant declarations (and some of the ideas) are -// from the class AppenderHelper by Jack Shirazi in the O'Reilly book Java Performance Tuning.. -// +package org.exist.util; + +import java.math.BigInteger; + +/** + * This is a utility class that handles formatting of numbers as strings. + *

+ * The algorithm for converting a floating point number to a string is taken from Guy L. Steele and + * Jon L. White, How to Print Floating-Point Numbers Accurately, ACM SIGPLAN 1990. It is algorithm + * (FPP)2 from that paper. There are three separate implementations of the algorithm: + *

    + *
  • One using long arithmetic and generating non-exponential output representations + *
  • One using BigInteger arithmetic and generating non-exponential output representation + *
  • One using BigInteger arithmetic and generating exponential output representations + *
+ *

+ * The choice of method depends on the value of the number being formatted. + *

+ * The module contains some residual code (mainly the routine for formatting integers) from the class + * AppenderHelper by Jack Shirazi in the O'Reilly book Java Performance Tuning. The floating point routines + * in that module were found to be unsuitable, since they used floating point arithmetic which introduces + * rounding errors. + *

+ * There are several reasons for doing this conversion within Saxon, rather than leaving it all to Java. + * Firstly, there are differences in the required output format, notably the absence of ".0" when formatting + * whole numbers, and the different rules for the range of numbers where exponential notation is used. + * Secondly, there are bugs in some Java implementations, for example JDK outputs 0.001 as 0.0010, and + * IKVM/GNU gets things very wrong sometimes. Finally, this implementation is faster for "everyday" numbers, + * though it is slower for more extreme numbers. It would probably be reasonable to hand over formatting + * to the Java platform (at least when running the Sun JDK) for exponents outside the range -7 to +7. + */ + +public class FloatingPointConverter { + + public static FloatingPointConverter THE_INSTANCE = new FloatingPointConverter(); + + private FloatingPointConverter(){} + + /** + * char array holding the characters for the string "-Infinity". + */ + private static final char[] NEGATIVE_INFINITY = {'-', 'I', 'N', 'F'}; + /** + * char array holding the characters for the string "Infinity". + */ + private static final char[] POSITIVE_INFINITY = {'I', 'N', 'F'}; + /** + * char array holding the characters for the string "NaN". + */ + private static final char[] NaN = {'N', 'a', 'N'}; + + private static final char[] charForDigit = { + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' + }; + + private static final long doubleSignMask = 0x8000000000000000L; + private static final long doubleExpMask = 0x7ff0000000000000L; + private static final int doubleExpShift = 52; + private static final int doubleExpBias = 1023; + private static final long doubleFractMask = 0xfffffffffffffL; + private static final int floatSignMask = 0x80000000; + private static final int floatExpMask = 0x7f800000; + private static final int floatExpShift = 23; + private static final int floatExpBias = 127; + private static final int floatFractMask = 0x7fffff; + + private static final BigInteger TEN = BigInteger.valueOf(10); + private static final BigInteger NINE = BigInteger.valueOf(9); + + /** + * Format an integer, appending the string representation of the integer to a string buffer + * @param s the string buffer + * @param i the integer to be formatted + * @return the supplied string buffer, containing the appended integer + */ + + public static FastStringBuffer appendInt(FastStringBuffer s, int i) { + if (i < 0) { + if (i == Integer.MIN_VALUE) { + //cannot make this positive due to integer overflow + s.append("-2147483648"); + return s; + } + s.append('-'); + i = -i; + } + int c; + if (i < 10) { + //one digit + s.append(charForDigit[i]); + return s; + } else if (i < 100) { + //two digits + s.append(charForDigit[i / 10]); + s.append(charForDigit[i % 10]); + return s; + } else if (i < 1000) { + //three digits + s.append(charForDigit[i / 100]); + s.append(charForDigit[(c = i % 100) / 10]); + s.append(charForDigit[c % 10]); + return s; + } else if (i < 10000) { + //four digits + s.append(charForDigit[i / 1000]); + s.append(charForDigit[(c = i % 1000) / 100]); + s.append(charForDigit[(c %= 100) / 10]); + s.append(charForDigit[c % 10]); + return s; + } else if (i < 100000) { + //five digits + s.append(charForDigit[i / 10000]); + s.append(charForDigit[(c = i % 10000) / 1000]); + s.append(charForDigit[(c %= 1000) / 100]); + s.append(charForDigit[(c %= 100) / 10]); + s.append(charForDigit[c % 10]); + return s; + } else if (i < 1000000) { + //six digits + s.append(charForDigit[i / 100000]); + s.append(charForDigit[(c = i % 100000) / 10000]); + s.append(charForDigit[(c %= 10000) / 1000]); + s.append(charForDigit[(c %= 1000) / 100]); + s.append(charForDigit[(c %= 100) / 10]); + s.append(charForDigit[c % 10]); + return s; + } else if (i < 10000000) { + //seven digits + s.append(charForDigit[i / 1000000]); + s.append(charForDigit[(c = i % 1000000) / 100000]); + s.append(charForDigit[(c %= 100000) / 10000]); + s.append(charForDigit[(c %= 10000) / 1000]); + s.append(charForDigit[(c %= 1000) / 100]); + s.append(charForDigit[(c %= 100) / 10]); + s.append(charForDigit[c % 10]); + return s; + } else if (i < 100000000) { + //eight digits + s.append(charForDigit[i / 10000000]); + s.append(charForDigit[(c = i % 10000000) / 1000000]); + s.append(charForDigit[(c %= 1000000) / 100000]); + s.append(charForDigit[(c %= 100000) / 10000]); + s.append(charForDigit[(c %= 10000) / 1000]); + s.append(charForDigit[(c %= 1000) / 100]); + s.append(charForDigit[(c %= 100) / 10]); + s.append(charForDigit[c % 10]); + return s; + } else if (i < 1000000000) { + //nine digits + s.append(charForDigit[i / 100000000]); + s.append(charForDigit[(c = i % 100000000) / 10000000]); + s.append(charForDigit[(c %= 10000000) / 1000000]); + s.append(charForDigit[(c %= 1000000) / 100000]); + s.append(charForDigit[(c %= 100000) / 10000]); + s.append(charForDigit[(c %= 10000) / 1000]); + s.append(charForDigit[(c %= 1000) / 100]); + s.append(charForDigit[(c %= 100) / 10]); + s.append(charForDigit[c % 10]); + return s; + } else { + //ten digits + s.append(charForDigit[i / 1000000000]); + s.append(charForDigit[(c = i % 1000000000) / 100000000]); + s.append(charForDigit[(c %= 100000000) / 10000000]); + s.append(charForDigit[(c %= 10000000) / 1000000]); + s.append(charForDigit[(c %= 1000000) / 100000]); + s.append(charForDigit[(c %= 100000) / 10000]); + s.append(charForDigit[(c %= 10000) / 1000]); + s.append(charForDigit[(c %= 1000) / 100]); + s.append(charForDigit[(c %= 100) / 10]); + s.append(charForDigit[c % 10]); + return s; + } + } + + /** + * Implementation of the (FPP)2 algorithm from Steele and White, for doubles in the range + * 0.01 to 1000000, and floats in the range 0.000001 to 1000000. + * In this range (a) XPath requires that the output should not be in exponential + * notation, and (b) the arithmetic can be handled using longs rather than BigIntegers + * @param sb the string buffer to which the formatted result is to be appended + * @param e the exponent of the floating point number + * @param f the fraction part of the floating point number, such that the "real" value of the + * number is f * 2^(e-p), with p>=0 and 0 lt f lt 2^p + * @param p the precision + */ + + private static void fppfpp(FastStringBuffer sb, int e, long f, int p) { + long R = f << Math.max(e-p, 0); + long S = 1L << Math.max(0, -(e-p)); + long Mminus = 1L << Math.max(e-p, 0); + long Mplus = Mminus; + boolean initial = true; + + // simpleFixup + + if (f == 1L << (p-1)) { + Mplus = Mplus << 1; + R = R << 1; + S = S << 1; + } + int k = 0; + while (R < (S+9)/10) { // (S+9)/10 == ceiling(S/10) + k--; + R = R*10; + Mminus = Mminus * 10; + Mplus = Mplus * 10; + } + while (2*R + Mplus >= 2*S) { + S = S*10; + k++; + } + + for (int z=k; z<0; z++) { + if (initial) { + sb.append("0."); + } + initial = false; + sb.append('0'); + } + + // end simpleFixup + + //int H = k-1; + + boolean low; + boolean high; + int U; + while (true) { + k--; + U = (int)(R*10 / S); + R = R*10 % S; + Mminus = Mminus * 10; + Mplus = Mplus * 10; + low = 2*R < Mminus; + high = 2*R > 2*S - Mplus; + if (low || high) {break;} + if (k == -1) { + if (initial) { + sb.append('0'); + } + sb.append('.'); + } + sb.append(charForDigit[U]); + initial = false; + } + if (high && (!low || 2*R > S)) { + U++; + } + if (k == -1) { + if (initial) { + sb.append('0'); + } + sb.append('.'); + } + sb.append(charForDigit[U]); + for (int z=0; z=0 and 0 lt f lt 2^p + * @param p the precision + */ + + private static void fppfppBig(FastStringBuffer sb, int e, long f, int p) { + //long R = f << Math.max(e-p, 0); + BigInteger R = BigInteger.valueOf(f).shiftLeft(Math.max(e-p, 0)); + + //long S = 1L << Math.max(0, -(e-p)); + BigInteger S = BigInteger.ONE.shiftLeft(Math.max(0, -(e-p))); + + //long Mminus = 1 << Math.max(e-p, 0); + BigInteger Mminus = BigInteger.ONE.shiftLeft(Math.max(e-p, 0)); + + //long Mplus = Mminus; + BigInteger Mplus = Mminus; + + boolean initial = true; + + // simpleFixup + + if (f == 1L << (p-1)) { + Mplus = Mplus.shiftLeft(1); + R = R.shiftLeft(1); + S = S.shiftLeft(1); + } + int k = 0; + while (R.compareTo(S.add(NINE).divide(TEN)) < 0) { // (S+9)/10 == ceiling(S/10) + k--; + R = R.multiply(TEN); + Mminus = Mminus.multiply(TEN); + Mplus = Mplus.multiply(TEN); + } + while (R.shiftLeft(1).add(Mplus).compareTo(S.shiftLeft(1)) >= 0) { + S = S.multiply(TEN); + k++; + } + + for (int z=k; z<0; z++) { + if (initial) { + sb.append("0."); + } + initial = false; + sb.append('0'); + } + + // end simpleFixup + + //int H = k-1; + + boolean low; + boolean high; + int U; + while (true) { + k--; + final BigInteger R10 = R.multiply(TEN); + U = R10.divide(S).intValue(); + R = R10.mod(S); + Mminus = Mminus.multiply(TEN); + Mplus = Mplus.multiply(TEN); + final BigInteger R2 = R.shiftLeft(1); + low = R2.compareTo(Mminus) < 0; + high = R2.compareTo(S.shiftLeft(1).subtract(Mplus)) > 0; + if (low || high) {break;} + if (k == -1) { + if (initial) { + sb.append('0'); + } + sb.append('.'); + } + sb.append(charForDigit[U]); + initial = false; + } + if (high && (!low || R.shiftLeft(1).compareTo(S) > 0)) { + U++; + } + if (k == -1) { + if (initial) { + sb.append('0'); + } + sb.append('.'); + } + sb.append(charForDigit[U]); + for (int z=0; z=0 and 0 lt f lt 2^p + * @param p the precision + */ + + private static void fppfppExponential(FastStringBuffer sb, int e, long f, int p) { + //long R = f << Math.max(e-p, 0); + BigInteger R = BigInteger.valueOf(f).shiftLeft(Math.max(e-p, 0)); + + //long S = 1L << Math.max(0, -(e-p)); + BigInteger S = BigInteger.ONE.shiftLeft(Math.max(0, -(e-p))); + + //long Mminus = 1 << Math.max(e-p, 0); + BigInteger Mminus = BigInteger.ONE.shiftLeft(Math.max(e-p, 0)); + + //long Mplus = Mminus; + BigInteger Mplus = Mminus; + + boolean initial = true; + boolean doneDot = false; + + // simpleFixup + + if (f == 1L << (p-1)) { + Mplus = Mplus.shiftLeft(1); + R = R.shiftLeft(1); + S = S.shiftLeft(1); + } + int k = 0; + while (R.compareTo(S.add(NINE).divide(TEN)) < 0) { // (S+9)/10 == ceiling(S/10) + k--; + R = R.multiply(TEN); + Mminus = Mminus.multiply(TEN); + Mplus = Mplus.multiply(TEN); + } + while (R.shiftLeft(1).add(Mplus).compareTo(S.shiftLeft(1)) >= 0) { + S = S.multiply(TEN); + k++; + } + + // end simpleFixup + + final int H = k-1; + + boolean low; + boolean high; + int U; + while (true) { + k--; + final BigInteger R10 = R.multiply(TEN); + U = R10.divide(S).intValue(); + R = R10.mod(S); + Mminus = Mminus.multiply(TEN); + Mplus = Mplus.multiply(TEN); + final BigInteger R2 = R.shiftLeft(1); + low = R2.compareTo(Mminus) < 0; + high = R2.compareTo(S.shiftLeft(1).subtract(Mplus)) > 0; + if (low || high) {break;} + + sb.append(charForDigit[U]); + if (initial) { + sb.append('.'); + doneDot = true; + } + initial = false; + } + if (high && (!low || R.shiftLeft(1).compareTo(S) > 0)) { + U++; + } + sb.append(charForDigit[U]); + + if (!doneDot) { + sb.append(".0"); + } + sb.append('E'); + appendInt(sb, H); + + } + + /** + * Append a string representation of a double value to a string buffer + * @param s the string buffer to which the result will be appended + * @param value the double to be formatted + * @return the original string buffer, now containing the string representation of the supplied double + */ + + public static FastStringBuffer appendDouble(FastStringBuffer s, double value) { + double d = value; + if (d == Double.NEGATIVE_INFINITY) { + s.append(NEGATIVE_INFINITY); + } else if (d == Double.POSITIVE_INFINITY) { + s.append(POSITIVE_INFINITY); + } else if (d != d) { + s.append(NaN); + } else if (d == 0.0) { + if ((Double.doubleToLongBits(d) & doubleSignMask) != 0) { + s.append('-'); + } + s.append('0'); + } else if (d == Double.MAX_VALUE) { + s.append("1.7976931348623157E308"); + } else if (d == -Double.MAX_VALUE) { + s.append("-1.7976931348623157E308"); + } else if (d == Double.MIN_VALUE) { + s.append("4.9E-324"); + } else if (d == -Double.MIN_VALUE) { + s.append("-4.9E-324"); + } else { + if (d < 0) { + s.append('-'); + d = -d; + } + final boolean exponential = (d >= 1000000 || d < 0.000001); + final long bits = Double.doubleToLongBits(d); + final long fraction = (1L<<52) | (bits & doubleFractMask); + final long rawExp = (bits & doubleExpMask) >> doubleExpShift; + final int exp = (int)rawExp - doubleExpBias; + if (rawExp == 0) { + // don't know how to handle this currently: hand it over to Java to deal with + s.append(Double.toString(value)); + return s; + } + if (exponential) { + fppfppExponential(s, exp, fraction, 52); + } else { + if (d <= 0.01) { + fppfppBig(s, exp, fraction, 52); + } else { + fppfpp(s, exp, fraction, 52); + } + } + + // test code +// try { +// if (Double.parseDouble(s.toString()) != value) { +// System.err.println("*** Round-trip failed: input " + value + +// '(' + Double.doubleToLongBits(value) + ')' + +// " != output " + s.toString() + +// '(' + Double.doubleToLongBits(Double.parseDouble(s.toString())) + ')' ); +// } +// } catch (NumberFormatException e) { +// System.err.println("*** Bad float " + s.toString() + " for input " + value); +// } + } + return s; + } + + /** + * Append a string representation of a float value to a string buffer + * @param s the string buffer to which the result will be appended + * @param value the float to be formatted + * @return the original string buffer, now containing the string representation of the supplied float + */ + + public static FastStringBuffer appendFloat(FastStringBuffer s, float value) { + float f = value; + if (f == Float.NEGATIVE_INFINITY) { + s.append(NEGATIVE_INFINITY); + } else if (f == Float.POSITIVE_INFINITY) { + s.append(POSITIVE_INFINITY); + } else if (f != f) { + s.append(NaN); + } else if (f == 0.0) { + if ((Float.floatToIntBits(f) & floatSignMask) != 0) { + s.append('-'); + } + s.append('0'); + } else if (f == Float.MAX_VALUE) { + s.append("3.4028235E38"); + } else if (f == -Float.MAX_VALUE) { + s.append("-3.4028235E38"); + } else if (f == Float.MIN_VALUE) { + s.append("1.4E-45"); + } else if (f == -Float.MIN_VALUE) { + s.append("-1.4E-45"); + } else { + if (f < 0) { + s.append('-'); + f = -f; + } + final boolean exponential = (f >= 1000000 || f < 0.000001F); + final int bits = Float.floatToIntBits(f); + final int fraction = (1<<23) | (bits & floatFractMask); + final int rawExp = ((bits & floatExpMask) >> floatExpShift); + final int exp = rawExp - floatExpBias; + final int precision = 23; + if (rawExp == 0) { + // don't know how to handle this currently: hand it over to Java to deal with + s.append(Float.toString(value)); + return s; + } + if (exponential) { + fppfppExponential(s, exp, fraction, precision); + } else { + fppfpp(s, exp, fraction, precision); + } + + // test code +// try { +// if (Float.parseFloat(s.toString()) != value) { +// System.err.println("*** Round-trip failed: input " + value + +// '(' + Float.floatToIntBits(value) + ')' + +// " != output " + s.toString() + +// '(' + Float.floatToIntBits(Float.parseFloat(s.toString())) + ')' ); +// } +// } catch (NumberFormatException e) { +// System.err.println("*** Bad float " + s.toString() + " for input " + value); +// } + } + return s; + } + +// public static void main(String[] args) { +// if (args.length > 0 && args[0].equals("F")) { +// if (args.length == 2) { +// StringTokenizer tok = new StringTokenizer(args[1], ","); +// while (tok.hasMoreElements()) { +// String input = tok.nextToken(); +// float f = Float.parseFloat(input); +// FastStringBuffer sb = new FastStringBuffer(20); +// appendFloat(sb, f); +// System.err.println("input: " + input + " output: " + sb.toString() + " java: " + f); +// } +// } else { +// Random gen = new Random(); +// for (int i=1; i<1000; i++) { +// int p=gen.nextInt(999*i*i); +// int q=gen.nextInt(999*i*i); +// String input = (p + "." + q); +// float f = Float.parseFloat(input); +// FastStringBuffer sb = new FastStringBuffer(20); +// appendFloat(sb, f); +// System.err.println("input: " + input + " output: " + sb.toString() + " java: " + f); +// } +// } +// } else { +// if (args.length == 2) { +// StringTokenizer tok = new StringTokenizer(args[1], ","); +// while (tok.hasMoreElements()) { +// String input = tok.nextToken(); +// double f = Double.parseDouble(input); +// FastStringBuffer sb = new FastStringBuffer(20); +// appendDouble(sb, f); +// System.err.println("input: " + input + " output: " + sb.toString() + " java: " + f); +// } +// } else { +// long start = System.currentTimeMillis(); +// Random gen = new Random(); +// for (int i=1; i<100000; i++) { +// //int p=gen.nextInt(999*i*i); +// int q=gen.nextInt(999*i); +// //String input = (p + "." + q); +// String input = "0.000" + q; +// double f = Double.parseDouble(input); +// FastStringBuffer sb = new FastStringBuffer(20); +// appendDouble(sb, f); +// //System.err.println("input: " + input + " output: " + sb.toString() + " java: " + f); +// } +// System.err.println("** elapsed time " + (System.currentTimeMillis() - start)); +// } +// } +// } + + + +} + + +// +// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License"); +// you may not use this file except in compliance with the License. You may obtain a copy of the +// License at http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" basis, +// WITHOUT WARRANTY OF ANY KIND, either express or implied. +// See the License for the specific language governing rights and limitations under the License. +// +// The Original Code is: all this file. +// +// The Initial Developer of the Original Code is Michael H. Kay, based on a published algorithm by +// Guy L. Steele and Jon L. White. +// +// Contributor(s): the appendInt routine, and some of the constant declarations (and some of the ideas) are +// from the class AppenderHelper by Jack Shirazi in the O'Reilly book Java Performance Tuning.. +// diff --git a/src/org/exist/util/SingleInstanceConfiguration.java b/src/org/exist/util/SingleInstanceConfiguration.java index 81bddf00a3e..4991186063b 100644 --- a/src/org/exist/util/SingleInstanceConfiguration.java +++ b/src/org/exist/util/SingleInstanceConfiguration.java @@ -1,139 +1,139 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-06 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id: Configuration.java 5400 2007-02-25 13:20:15Z wolfgang_m $ - */ -package org.exist.util; - -import java.io.File; -import java.io.IOException; - -import org.apache.log4j.Logger; - -public class SingleInstanceConfiguration extends Configuration { - - /* FIXME: It's not clear whether this class is meant to be a singleton (due to the static - * file and existHome fields and static methods), or if we should allow many instances to - * run around in the system. Right now, any attempts to create multiple instances will - * likely get the system confused. Let's decide which one it should be and fix it properly. - * - * This class cannot be a singleton as it is possible to run multiple instances of the database - * on the same system. - */ - - @SuppressWarnings("unused") - private final static Logger LOG = Logger.getLogger(SingleInstanceConfiguration.class); //Logger - protected static String _configFile = null; //config file (conf.xml by default) - protected static File _existHome = null; - - - public SingleInstanceConfiguration() throws DatabaseConfigurationException { - this("conf.xml", null); - } - - public SingleInstanceConfiguration(String configFilename) throws DatabaseConfigurationException { - this(configFilename, null); - } - - public SingleInstanceConfiguration(String configFilename, String existHomeDirname) throws DatabaseConfigurationException { - super(configFilename, existHomeDirname); - _configFile = configFilePath; - _existHome = existHome; - } - - /** - * Returns the absolute path to the configuration file. - * - * @return the path to the configuration file - */ - public static String getPath() { - if (_configFile == null) { - final File f = ConfigurationHelper.lookup("conf.xml"); - return f.getAbsolutePath(); - } - return _configFile; - } - - /** - * Check wether exist runs in Servlet container (as war file). - * @return TRUE if exist runs in servlet container. - */ - public static boolean isInWarFile(){ - - boolean retVal =true; - - // if existHome is not set,try to do so. - if (_existHome == null){ - ConfigurationHelper.getExistHome(); - } - - if( new File(_existHome, "lib/core").isDirectory() ) { - retVal=false; - } - return retVal; - } - - /** - * Get folder in which the exist webapplications are found. - * For default install ("jar install") and in webcontainer ("war install") - * the location is different. (EXIST_HOME/webapps vs. TOMCAT/webapps/exist) - * - * @return folder. - */ - public static File getWebappHome(){ - File webappFolder =null; - - // if existHome is not set,try to do so. - if (_existHome == null){ - ConfigurationHelper.getExistHome(); - } - - if(isInWarFile()){ - webappFolder= new File(_existHome, ".."); - } else { - webappFolder= new File(_existHome, "webapp"); - } - - // convert to real path - try { - File tmpFolder = webappFolder.getCanonicalFile(); - webappFolder=tmpFolder; - } catch (final IOException ex) { - // oops ; use previous path - } - - return webappFolder; - } - - /** - * Returns true if the directory dir contains a file - * named conf.xml. - * - * @param dir the directory - * @return true if the directory contains a configuration file - */ - @SuppressWarnings("unused") - private static boolean containsConfig(File dir, String config) { - if (dir != null && dir.exists() && dir.isDirectory() && dir.canRead()) { - final File c = new File(dir, config); - return c.exists() && c.isFile() && c.canRead(); - } - return false; - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-06 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id: Configuration.java 5400 2007-02-25 13:20:15Z wolfgang_m $ + */ +package org.exist.util; + +import java.io.File; +import java.io.IOException; + +import org.apache.log4j.Logger; + +public class SingleInstanceConfiguration extends Configuration { + + /* FIXME: It's not clear whether this class is meant to be a singleton (due to the static + * file and existHome fields and static methods), or if we should allow many instances to + * run around in the system. Right now, any attempts to create multiple instances will + * likely get the system confused. Let's decide which one it should be and fix it properly. + * + * This class cannot be a singleton as it is possible to run multiple instances of the database + * on the same system. + */ + + @SuppressWarnings("unused") + private final static Logger LOG = Logger.getLogger(SingleInstanceConfiguration.class); //Logger + protected static String _configFile = null; //config file (conf.xml by default) + protected static File _existHome = null; + + + public SingleInstanceConfiguration() throws DatabaseConfigurationException { + this("conf.xml", null); + } + + public SingleInstanceConfiguration(String configFilename) throws DatabaseConfigurationException { + this(configFilename, null); + } + + public SingleInstanceConfiguration(String configFilename, String existHomeDirname) throws DatabaseConfigurationException { + super(configFilename, existHomeDirname); + _configFile = configFilePath; + _existHome = existHome; + } + + /** + * Returns the absolute path to the configuration file. + * + * @return the path to the configuration file + */ + public static String getPath() { + if (_configFile == null) { + final File f = ConfigurationHelper.lookup("conf.xml"); + return f.getAbsolutePath(); + } + return _configFile; + } + + /** + * Check wether exist runs in Servlet container (as war file). + * @return TRUE if exist runs in servlet container. + */ + public static boolean isInWarFile(){ + + boolean retVal =true; + + // if existHome is not set,try to do so. + if (_existHome == null){ + ConfigurationHelper.getExistHome(); + } + + if( new File(_existHome, "lib/core").isDirectory() ) { + retVal=false; + } + return retVal; + } + + /** + * Get folder in which the exist webapplications are found. + * For default install ("jar install") and in webcontainer ("war install") + * the location is different. (EXIST_HOME/webapps vs. TOMCAT/webapps/exist) + * + * @return folder. + */ + public static File getWebappHome(){ + File webappFolder =null; + + // if existHome is not set,try to do so. + if (_existHome == null){ + ConfigurationHelper.getExistHome(); + } + + if(isInWarFile()){ + webappFolder= new File(_existHome, ".."); + } else { + webappFolder= new File(_existHome, "webapp"); + } + + // convert to real path + try { + File tmpFolder = webappFolder.getCanonicalFile(); + webappFolder=tmpFolder; + } catch (final IOException ex) { + // oops ; use previous path + } + + return webappFolder; + } + + /** + * Returns true if the directory dir contains a file + * named conf.xml. + * + * @param dir the directory + * @return true if the directory contains a configuration file + */ + @SuppressWarnings("unused") + private static boolean containsConfig(File dir, String config) { + if (dir != null && dir.exists() && dir.isDirectory() && dir.canRead()) { + final File c = new File(dir, config); + return c.exists() && c.isFile() && c.canRead(); + } + return false; + } +} diff --git a/src/org/exist/util/hashtable/MapRWLock.java b/src/org/exist/util/hashtable/MapRWLock.java index 06678e6d909..ba10fa12bf4 100644 --- a/src/org/exist/util/hashtable/MapRWLock.java +++ b/src/org/exist/util/hashtable/MapRWLock.java @@ -1,174 +1,174 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2012 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.util.hashtable; - -import java.util.Collection; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.locks.ReentrantReadWriteLock; -import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock; -import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock; - -/** - * @author Dmitriy Shabanov - * - */ -public class MapRWLock implements Map { - - private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); - private final ReadLock readLock = lock.readLock(); - private final WriteLock writeLock = lock.writeLock(); - - private Map map; - - public MapRWLock(Map map) { - this.map = map; - } - - @Override - public int size() { - readLock.lock(); - try { - return map.size(); - } finally { - readLock.unlock(); - } - } - - @Override - public boolean isEmpty() { - readLock.lock(); - try { - return map.isEmpty(); - } finally { - readLock.unlock(); - } - } - - @Override - public boolean containsKey(Object key) { - readLock.lock(); - try { - return map.containsKey(key); - } finally { - readLock.unlock(); - } - } - - @Override - public boolean containsValue(Object value) { - readLock.lock(); - try { - return map.containsValue(value); - } finally { - readLock.unlock(); - } - } - - @Override - public V get(Object key) { - readLock.lock(); - try { - return map.get(key); - } finally { - readLock.unlock(); - } - } - - @Override - public V put(K key, V value) { - writeLock.lock(); - try { - return map.put(key, value); - } finally { - writeLock.unlock(); - } - } - - @Override - public V remove(Object key) { - writeLock.lock(); - try { - return map.remove(key); - } finally { - writeLock.unlock(); - } - } - - @Override - public void putAll(Map m) { - writeLock.lock(); - try { - map.putAll(m); - } finally { - writeLock.unlock(); - } - } - - @Override - public void clear() { - writeLock.lock(); - try { - map.clear(); - } finally { - writeLock.unlock(); - } - } - - @Override - public Set keySet() { - throw new UnsupportedOperationException("keySet method is not atomic operation."); - } - - @Override - public Collection values() { - throw new UnsupportedOperationException("values method is not atomic operation."); - } - - @Override - public Set> entrySet() { - throw new UnsupportedOperationException("entrySet method is not atomic operation."); - } - - public void readOperation(final LongOperation readOp) { - readLock.lock(); - try { - readOp.execute(map); - } finally { - readLock.unlock(); - } - } - - public void writeOperation(final LongOperation writeOp) { - writeLock.lock(); - try { - writeOp.execute(map); - } finally { - writeLock.unlock(); - } - } - - public interface LongOperation { - public void execute(Map map); - } - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2012 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.util.hashtable; + +import java.util.Collection; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.locks.ReentrantReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock; +import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock; + +/** + * @author Dmitriy Shabanov + * + */ +public class MapRWLock implements Map { + + private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); + private final ReadLock readLock = lock.readLock(); + private final WriteLock writeLock = lock.writeLock(); + + private Map map; + + public MapRWLock(Map map) { + this.map = map; + } + + @Override + public int size() { + readLock.lock(); + try { + return map.size(); + } finally { + readLock.unlock(); + } + } + + @Override + public boolean isEmpty() { + readLock.lock(); + try { + return map.isEmpty(); + } finally { + readLock.unlock(); + } + } + + @Override + public boolean containsKey(Object key) { + readLock.lock(); + try { + return map.containsKey(key); + } finally { + readLock.unlock(); + } + } + + @Override + public boolean containsValue(Object value) { + readLock.lock(); + try { + return map.containsValue(value); + } finally { + readLock.unlock(); + } + } + + @Override + public V get(Object key) { + readLock.lock(); + try { + return map.get(key); + } finally { + readLock.unlock(); + } + } + + @Override + public V put(K key, V value) { + writeLock.lock(); + try { + return map.put(key, value); + } finally { + writeLock.unlock(); + } + } + + @Override + public V remove(Object key) { + writeLock.lock(); + try { + return map.remove(key); + } finally { + writeLock.unlock(); + } + } + + @Override + public void putAll(Map m) { + writeLock.lock(); + try { + map.putAll(m); + } finally { + writeLock.unlock(); + } + } + + @Override + public void clear() { + writeLock.lock(); + try { + map.clear(); + } finally { + writeLock.unlock(); + } + } + + @Override + public Set keySet() { + throw new UnsupportedOperationException("keySet method is not atomic operation."); + } + + @Override + public Collection values() { + throw new UnsupportedOperationException("values method is not atomic operation."); + } + + @Override + public Set> entrySet() { + throw new UnsupportedOperationException("entrySet method is not atomic operation."); + } + + public void readOperation(final LongOperation readOp) { + readLock.lock(); + try { + readOp.execute(map); + } finally { + readLock.unlock(); + } + } + + public void writeOperation(final LongOperation writeOp) { + writeLock.lock(); + try { + writeOp.execute(map); + } finally { + writeLock.unlock(); + } + } + + public interface LongOperation { + public void execute(Map map); + } + +} diff --git a/src/org/exist/util/io/TemporaryFileManager.java b/src/org/exist/util/io/TemporaryFileManager.java index 9717f6edf36..b056d5ce6f6 100644 --- a/src/org/exist/util/io/TemporaryFileManager.java +++ b/src/org/exist/util/io/TemporaryFileManager.java @@ -1,152 +1,152 @@ -/* -Copyright (c) 2012, Adam Retter -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of Adam Retter Consulting nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL Adam Retter BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package org.exist.util.io; - -import java.io.File; -import java.io.FileFilter; -import java.io.IOException; -import java.util.Stack; -import java.util.UUID; -import org.apache.commons.io.FileUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Temporary File Manager - * - * Attempts to create and delete temporary files - * working around the issues of some JDK platforms - * (e.g. Windows). Where deleting files is impossible, - * used but finished with temporary files will be re-used - * where possible if they cannot be deleted. - * - * @version 1.0 - * - * @author Adam Retter - */ -public class TemporaryFileManager { - - private final static Log LOG = LogFactory.getLog(TemporaryFileManager.class); - - private final static String FOLDER_PREFIX = "_mmtfm_"; - private final Stack available = new Stack(); - private final File tmpFolder; - - private final static TemporaryFileManager instance = new TemporaryFileManager(); - - public static TemporaryFileManager getInstance() { - return instance; - } - - private TemporaryFileManager() { - final String tmpDir = System.getProperty("java.io.tmpdir"); - final File t = new File(tmpDir); - - cleanupOldTempFolders(t); - - this.tmpFolder = new File(t, FOLDER_PREFIX + UUID.randomUUID().toString()); - if(!tmpFolder.mkdir()) { - throw new RuntimeException("Unable to use temporary folder: " + tmpFolder.getAbsolutePath()); - } - - LOG.info("Temporary folder is: " + tmpFolder.getAbsolutePath()); - } - - public final File getTemporaryFile() throws IOException { - - File tempFile = null; - - synchronized(available) { - if(!available.empty()) { - tempFile = available.pop(); - } - } - - if(tempFile == null) { - tempFile = File.createTempFile("mmtf_" + System.currentTimeMillis(), ".tmp", tmpFolder); - - //add hook to JVM to delete the file on exit - //unfortunately this does not always work on all (e.g. Windows) platforms - tempFile.deleteOnExit(); - } - - return tempFile; - } - - public void returnTemporaryFile(final File tempFile) { - - //attempt to delete the temporary file - final boolean deleted = tempFile.delete(); - - if(deleted) { - LOG.debug("Deleted temporary file: " + tempFile.getAbsolutePath()); - } else { - LOG.debug("Could not delete temporary file: " + tempFile.getAbsolutePath() + ". Returning to stack for re-use."); - - //if we couldnt delete it, add it to the stack of available files - //for reuse in the future. - //Typically there are problems deleting these files on Windows - //platforms which is why this facility was added - synchronized(available) { - available.push(tempFile); - } - } - } - - private void cleanupOldTempFolders(final File t) { - final File oldFolders[] = t.listFiles(new FileFilter(){ - @Override - public boolean accept(File f) { - return f.isDirectory() && f.getName().startsWith(FOLDER_PREFIX); - } - }); - - for(final File oldFolder : oldFolders) { - deleteFolder(oldFolder); - } - } - - private void deleteFolder(final File folder) { - try { - FileUtils.deleteDirectory(folder); - LOG.debug("Deleted temporary folder: " + folder.getAbsolutePath()); - } catch(final IOException ioe) { - LOG.warn("Unable to delete temporary folder: " + folder.getAbsolutePath(), ioe); - } - } - - @Override - protected void finalize() throws Throwable { - super.finalize(); - - //remove references to available files - available.clear(); - - //try and remove our temporary folder - deleteFolder(tmpFolder); - } +/* +Copyright (c) 2012, Adam Retter +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of Adam Retter Consulting nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL Adam Retter BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.exist.util.io; + +import java.io.File; +import java.io.FileFilter; +import java.io.IOException; +import java.util.Stack; +import java.util.UUID; +import org.apache.commons.io.FileUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Temporary File Manager + * + * Attempts to create and delete temporary files + * working around the issues of some JDK platforms + * (e.g. Windows). Where deleting files is impossible, + * used but finished with temporary files will be re-used + * where possible if they cannot be deleted. + * + * @version 1.0 + * + * @author Adam Retter + */ +public class TemporaryFileManager { + + private final static Log LOG = LogFactory.getLog(TemporaryFileManager.class); + + private final static String FOLDER_PREFIX = "_mmtfm_"; + private final Stack available = new Stack(); + private final File tmpFolder; + + private final static TemporaryFileManager instance = new TemporaryFileManager(); + + public static TemporaryFileManager getInstance() { + return instance; + } + + private TemporaryFileManager() { + final String tmpDir = System.getProperty("java.io.tmpdir"); + final File t = new File(tmpDir); + + cleanupOldTempFolders(t); + + this.tmpFolder = new File(t, FOLDER_PREFIX + UUID.randomUUID().toString()); + if(!tmpFolder.mkdir()) { + throw new RuntimeException("Unable to use temporary folder: " + tmpFolder.getAbsolutePath()); + } + + LOG.info("Temporary folder is: " + tmpFolder.getAbsolutePath()); + } + + public final File getTemporaryFile() throws IOException { + + File tempFile = null; + + synchronized(available) { + if(!available.empty()) { + tempFile = available.pop(); + } + } + + if(tempFile == null) { + tempFile = File.createTempFile("mmtf_" + System.currentTimeMillis(), ".tmp", tmpFolder); + + //add hook to JVM to delete the file on exit + //unfortunately this does not always work on all (e.g. Windows) platforms + tempFile.deleteOnExit(); + } + + return tempFile; + } + + public void returnTemporaryFile(final File tempFile) { + + //attempt to delete the temporary file + final boolean deleted = tempFile.delete(); + + if(deleted) { + LOG.debug("Deleted temporary file: " + tempFile.getAbsolutePath()); + } else { + LOG.debug("Could not delete temporary file: " + tempFile.getAbsolutePath() + ". Returning to stack for re-use."); + + //if we couldnt delete it, add it to the stack of available files + //for reuse in the future. + //Typically there are problems deleting these files on Windows + //platforms which is why this facility was added + synchronized(available) { + available.push(tempFile); + } + } + } + + private void cleanupOldTempFolders(final File t) { + final File oldFolders[] = t.listFiles(new FileFilter(){ + @Override + public boolean accept(File f) { + return f.isDirectory() && f.getName().startsWith(FOLDER_PREFIX); + } + }); + + for(final File oldFolder : oldFolders) { + deleteFolder(oldFolder); + } + } + + private void deleteFolder(final File folder) { + try { + FileUtils.deleteDirectory(folder); + LOG.debug("Deleted temporary folder: " + folder.getAbsolutePath()); + } catch(final IOException ioe) { + LOG.warn("Unable to delete temporary folder: " + folder.getAbsolutePath(), ioe); + } + } + + @Override + protected void finalize() throws Throwable { + super.finalize(); + + //remove references to available files + available.clear(); + + //try and remove our temporary folder + deleteFolder(tmpFolder); + } } \ No newline at end of file diff --git a/src/org/exist/util/pool/NodePool.java b/src/org/exist/util/pool/NodePool.java index bcf48a61cd0..45ac94e15fe 100644 --- a/src/org/exist/util/pool/NodePool.java +++ b/src/org/exist/util/pool/NodePool.java @@ -1,121 +1,121 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2010 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.util.pool; - -import java.util.LinkedList; - -import org.exist.dom.AttrImpl; -import org.exist.dom.CDATASectionImpl; -import org.exist.dom.CommentImpl; -import org.exist.dom.ElementImpl; -import org.exist.dom.NodeImpl; -import org.exist.dom.ProcessingInstructionImpl; -import org.exist.dom.TextImpl; -import org.exist.util.hashtable.Int2ObjectHashMap; -import org.w3c.dom.Node; - -/** - * A pool of node objects. Storing a resource creates many, short-lived DOM node - * objects. To reduce garbage collection, we use a pool to cache a certain number - * of objects. - */ -public class NodePool { - - public final static int MAX_OBJECTS = 20; - - public static NodePool getInstance() { - return pools.get(); - } - - private static class PoolThreadLocal extends ThreadLocal { - - protected NodePool initialValue() { - return new NodePool(MAX_OBJECTS); - } - } - - private static ThreadLocal pools = new PoolThreadLocal(); - - - private int maxActive; - private Int2ObjectHashMap poolMap = new Int2ObjectHashMap(17); - - public NodePool(int maxObjects) { - this.maxActive = maxObjects; - } - - public NodeImpl borrowNode(short key) { - Pool pool = (Pool) poolMap.get(key); - if (pool == null) { - pool = new Pool(); - poolMap.put(key, pool); - } - return pool.borrowNode(key); - } - - public void returnNode(NodeImpl node) { - final Pool pool = (Pool) poolMap.get(node.getNodeType()); - if (pool != null) - {pool.returnNode(node);} - } - - public int getSize(short key) { - final Pool pool = (Pool) poolMap.get(key); - return pool.stack.size(); - } - - private NodeImpl makeObject(short key) { - switch (key) { - case Node.ELEMENT_NODE: - return new ElementImpl(); - case Node.TEXT_NODE: - return new TextImpl(); - case Node.ATTRIBUTE_NODE: - return new AttrImpl(); - case Node.CDATA_SECTION_NODE: - return new CDATASectionImpl(); - case Node.PROCESSING_INSTRUCTION_NODE: - return new ProcessingInstructionImpl(); - case Node.COMMENT_NODE: - return new CommentImpl(); - } - throw new IllegalStateException("Unable to create object of type " + key); - } - - private class Pool { - - private LinkedList stack = new LinkedList(); - - public NodeImpl borrowNode(short key) { - if (stack.isEmpty()) { - return makeObject(key); - } - return stack.removeLast(); - } - - public void returnNode(NodeImpl node) { - // Only cache up to maxActive nodes - if (stack.size() < maxActive) - {stack.addLast(node);} - } - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2010 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.util.pool; + +import java.util.LinkedList; + +import org.exist.dom.AttrImpl; +import org.exist.dom.CDATASectionImpl; +import org.exist.dom.CommentImpl; +import org.exist.dom.ElementImpl; +import org.exist.dom.NodeImpl; +import org.exist.dom.ProcessingInstructionImpl; +import org.exist.dom.TextImpl; +import org.exist.util.hashtable.Int2ObjectHashMap; +import org.w3c.dom.Node; + +/** + * A pool of node objects. Storing a resource creates many, short-lived DOM node + * objects. To reduce garbage collection, we use a pool to cache a certain number + * of objects. + */ +public class NodePool { + + public final static int MAX_OBJECTS = 20; + + public static NodePool getInstance() { + return pools.get(); + } + + private static class PoolThreadLocal extends ThreadLocal { + + protected NodePool initialValue() { + return new NodePool(MAX_OBJECTS); + } + } + + private static ThreadLocal pools = new PoolThreadLocal(); + + + private int maxActive; + private Int2ObjectHashMap poolMap = new Int2ObjectHashMap(17); + + public NodePool(int maxObjects) { + this.maxActive = maxObjects; + } + + public NodeImpl borrowNode(short key) { + Pool pool = (Pool) poolMap.get(key); + if (pool == null) { + pool = new Pool(); + poolMap.put(key, pool); + } + return pool.borrowNode(key); + } + + public void returnNode(NodeImpl node) { + final Pool pool = (Pool) poolMap.get(node.getNodeType()); + if (pool != null) + {pool.returnNode(node);} + } + + public int getSize(short key) { + final Pool pool = (Pool) poolMap.get(key); + return pool.stack.size(); + } + + private NodeImpl makeObject(short key) { + switch (key) { + case Node.ELEMENT_NODE: + return new ElementImpl(); + case Node.TEXT_NODE: + return new TextImpl(); + case Node.ATTRIBUTE_NODE: + return new AttrImpl(); + case Node.CDATA_SECTION_NODE: + return new CDATASectionImpl(); + case Node.PROCESSING_INSTRUCTION_NODE: + return new ProcessingInstructionImpl(); + case Node.COMMENT_NODE: + return new CommentImpl(); + } + throw new IllegalStateException("Unable to create object of type " + key); + } + + private class Pool { + + private LinkedList stack = new LinkedList(); + + public NodeImpl borrowNode(short key) { + if (stack.isEmpty()) { + return makeObject(key); + } + return stack.removeLast(); + } + + public void returnNode(NodeImpl node) { + // Only cache up to maxActive nodes + if (stack.size() < maxActive) + {stack.addLast(node);} + } + } +} diff --git a/src/org/exist/util/serializer/EXISerializer.java b/src/org/exist/util/serializer/EXISerializer.java index a4a785127cb..12393b24939 100644 --- a/src/org/exist/util/serializer/EXISerializer.java +++ b/src/org/exist/util/serializer/EXISerializer.java @@ -1,203 +1,203 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2011 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -package org.exist.util.serializer; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import org.exist.dom.QName; -import org.exist.dom.StoredNode; -import org.w3c.dom.Document; -import org.xml.sax.Attributes; -import org.xml.sax.ContentHandler; -import org.xml.sax.Locator; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.AttributesImpl; - -import com.siemens.ct.exi.EXIFactory; -import com.siemens.ct.exi.GrammarFactory; -import com.siemens.ct.exi.api.sax.SAXEncoder; -import com.siemens.ct.exi.exceptions.EXIException; -import com.siemens.ct.exi.grammar.Grammar; -import com.siemens.ct.exi.helpers.DefaultEXIFactory; - -public class EXISerializer implements ContentHandler, Receiver { - - static final String UNKNOWN_TYPE = ""; - - private SAXEncoder encoder; - - public EXISerializer(OutputStream exiOutputStream) throws EXIException, IOException { - final EXIFactory exiFactory = DefaultEXIFactory.newInstance(); - encoder = new SAXEncoder(exiFactory); - encoder.setOutputStream(exiOutputStream); - } - - public EXISerializer(OutputStream exiOutputStream, InputStream xsdInputStream) throws EXIException, IOException { - final EXIFactory exiFactory = DefaultEXIFactory.newInstance(); - final GrammarFactory grammarFactory = GrammarFactory.newInstance(); - final Grammar g = grammarFactory.createGrammar(xsdInputStream); - exiFactory.setGrammar(g); - encoder = new SAXEncoder(exiFactory); - encoder.setOutputStream(exiOutputStream); - } - - public void startDocument() throws SAXException { - encoder.startDocument(); - } - - public void endDocument() throws SAXException { - encoder.endDocument(); - } - - @Override - public void startPrefixMapping(String prefix, String namespaceURI) - throws SAXException { - encoder.startPrefixMapping(prefix, namespaceURI); - } - - @Override - public void endPrefixMapping(String prefix) throws SAXException { - encoder.endPrefixMapping(prefix); - } - - @Override - public void startElement(QName qname, AttrList attribs) throws SAXException { - AttributesImpl attributes = null; - if(attribs != null) { - attributes = new AttributesImpl(); - for(int x=0; x < attribs.size; x++) { - final QName attribQName = attribs.getQName(x); - attributes.addAttribute(attribQName.getNamespaceURI(), - attribQName.getLocalName(), - attribQName.getStringValue(), - UNKNOWN_TYPE, - attribs.getValue(x)); - } - } - encoder.startElement(qname.getNamespaceURI(), qname.getLocalName(), null, attributes); - - } - - @Override - public void endElement(QName qname) throws SAXException { - encoder.endElement(qname.getNamespaceURI(), qname.getLocalName(), null); - - } - - @Override - public void characters(CharSequence seq) throws SAXException { - final String sequence = seq.toString(); - encoder.characters(sequence.toCharArray(), 0, sequence.length()); - } - - @Override - public void attribute(QName qname, String value) throws SAXException { - // TODO Auto-generated method stub - - } - - @Override - public void comment(char[] ch, int start, int length) throws SAXException { - // TODO Auto-generated method stub - } - - @Override - public void cdataSection(char[] ch, int start, int len) throws SAXException { - // TODO Auto-generated method stub - } - - @Override - public void processingInstruction(String target, String data) - throws SAXException { - // TODO Auto-generated method stub - } - - @Override - public void documentType(String name, String publicId, String systemId) - throws SAXException { - // TODO Auto-generated method stub - - } - - @Override - public void highlightText(CharSequence seq) throws SAXException { - // TODO Auto-generated method stub - - } - - @Override - public void setCurrentNode(StoredNode node) { - // TODO Auto-generated method stub - - } - - @Override - public Document getDocument() { - // TODO Auto-generated method stub - return null; - } - - @Override - public void setDocumentLocator(Locator locator) { - // TODO Auto-generated method stub - - } - - @Override - public void startElement(String uri, String localName, String qName, - Attributes atts) throws SAXException { - encoder.startElement(uri, localName, null, atts); - - } - - @Override - public void endElement(String uri, String localName, String qName) - throws SAXException { - encoder.endElement(uri, localName, null); - - } - - @Override - public void characters(char[] ch, int start, int length) - throws SAXException { - encoder.characters(ch, start, length); - - } - - @Override - public void ignorableWhitespace(char[] ch, int start, int length) - throws SAXException { - // TODO Auto-generated method stub - - } - - @Override - public void skippedEntity(String name) throws SAXException { - // TODO Auto-generated method stub - - } - - void setEncoder(SAXEncoder encoder) { - this.encoder = encoder; - } - +/* + * eXist Open Source Native XML Database + * Copyright (C) 2011 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +package org.exist.util.serializer; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import org.exist.dom.QName; +import org.exist.dom.StoredNode; +import org.w3c.dom.Document; +import org.xml.sax.Attributes; +import org.xml.sax.ContentHandler; +import org.xml.sax.Locator; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.AttributesImpl; + +import com.siemens.ct.exi.EXIFactory; +import com.siemens.ct.exi.GrammarFactory; +import com.siemens.ct.exi.api.sax.SAXEncoder; +import com.siemens.ct.exi.exceptions.EXIException; +import com.siemens.ct.exi.grammar.Grammar; +import com.siemens.ct.exi.helpers.DefaultEXIFactory; + +public class EXISerializer implements ContentHandler, Receiver { + + static final String UNKNOWN_TYPE = ""; + + private SAXEncoder encoder; + + public EXISerializer(OutputStream exiOutputStream) throws EXIException, IOException { + final EXIFactory exiFactory = DefaultEXIFactory.newInstance(); + encoder = new SAXEncoder(exiFactory); + encoder.setOutputStream(exiOutputStream); + } + + public EXISerializer(OutputStream exiOutputStream, InputStream xsdInputStream) throws EXIException, IOException { + final EXIFactory exiFactory = DefaultEXIFactory.newInstance(); + final GrammarFactory grammarFactory = GrammarFactory.newInstance(); + final Grammar g = grammarFactory.createGrammar(xsdInputStream); + exiFactory.setGrammar(g); + encoder = new SAXEncoder(exiFactory); + encoder.setOutputStream(exiOutputStream); + } + + public void startDocument() throws SAXException { + encoder.startDocument(); + } + + public void endDocument() throws SAXException { + encoder.endDocument(); + } + + @Override + public void startPrefixMapping(String prefix, String namespaceURI) + throws SAXException { + encoder.startPrefixMapping(prefix, namespaceURI); + } + + @Override + public void endPrefixMapping(String prefix) throws SAXException { + encoder.endPrefixMapping(prefix); + } + + @Override + public void startElement(QName qname, AttrList attribs) throws SAXException { + AttributesImpl attributes = null; + if(attribs != null) { + attributes = new AttributesImpl(); + for(int x=0; x < attribs.size; x++) { + final QName attribQName = attribs.getQName(x); + attributes.addAttribute(attribQName.getNamespaceURI(), + attribQName.getLocalName(), + attribQName.getStringValue(), + UNKNOWN_TYPE, + attribs.getValue(x)); + } + } + encoder.startElement(qname.getNamespaceURI(), qname.getLocalName(), null, attributes); + + } + + @Override + public void endElement(QName qname) throws SAXException { + encoder.endElement(qname.getNamespaceURI(), qname.getLocalName(), null); + + } + + @Override + public void characters(CharSequence seq) throws SAXException { + final String sequence = seq.toString(); + encoder.characters(sequence.toCharArray(), 0, sequence.length()); + } + + @Override + public void attribute(QName qname, String value) throws SAXException { + // TODO Auto-generated method stub + + } + + @Override + public void comment(char[] ch, int start, int length) throws SAXException { + // TODO Auto-generated method stub + } + + @Override + public void cdataSection(char[] ch, int start, int len) throws SAXException { + // TODO Auto-generated method stub + } + + @Override + public void processingInstruction(String target, String data) + throws SAXException { + // TODO Auto-generated method stub + } + + @Override + public void documentType(String name, String publicId, String systemId) + throws SAXException { + // TODO Auto-generated method stub + + } + + @Override + public void highlightText(CharSequence seq) throws SAXException { + // TODO Auto-generated method stub + + } + + @Override + public void setCurrentNode(StoredNode node) { + // TODO Auto-generated method stub + + } + + @Override + public Document getDocument() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void setDocumentLocator(Locator locator) { + // TODO Auto-generated method stub + + } + + @Override + public void startElement(String uri, String localName, String qName, + Attributes atts) throws SAXException { + encoder.startElement(uri, localName, null, atts); + + } + + @Override + public void endElement(String uri, String localName, String qName) + throws SAXException { + encoder.endElement(uri, localName, null); + + } + + @Override + public void characters(char[] ch, int start, int length) + throws SAXException { + encoder.characters(ch, start, length); + + } + + @Override + public void ignorableWhitespace(char[] ch, int start, int length) + throws SAXException { + // TODO Auto-generated method stub + + } + + @Override + public void skippedEntity(String name) throws SAXException { + // TODO Auto-generated method stub + + } + + void setEncoder(SAXEncoder encoder) { + this.encoder = encoder; + } + } \ No newline at end of file diff --git a/src/org/exist/validation/ValidationReportItem.java b/src/org/exist/validation/ValidationReportItem.java index 40912e82f5f..a7259392078 100644 --- a/src/org/exist/validation/ValidationReportItem.java +++ b/src/org/exist/validation/ValidationReportItem.java @@ -1,116 +1,116 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2010 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.validation; - -public class ValidationReportItem { - - public static final int WARNING = 1; - public static final int ERROR = 2; - public static final int FATAL = 4; - - private int type = -1; - private int lineNumber = -1; - private int columnNumber = -1; - private String publicId = null; - private String systemId = null; - private String message =""; - private int repeat=1; - - public void setType(int type){ - this.type=type; - } - - public int getType(){ - return type; - } - - public void setLineNumber(int nr){ - this.lineNumber=nr; - } - - public int getLineNumber(){ - return this.lineNumber; - } - - public void setColumnNumber(int nr){ - this.columnNumber=nr; - } - - public int getColumnNumber(){ - return this.columnNumber; - } - - public void setMessage(String message){ - this.message=message; - } - - public String getMessage(){ - return this.message; - } - - public void setPublicId(String publicId){ - this.publicId=publicId; - } - - public String getPublicId(){ - return this.publicId; - } - - public void setSystemId(String systemId){ - this.systemId=systemId; - } - - public String getSystemId(){ - return this.systemId; - } - - public String getTypeText(){ - - String reportType="UNKNOWN"; - - switch (type) { - case WARNING: reportType="Warning"; break; - case ERROR: reportType="Error"; break; - case FATAL: reportType="Fatal"; break; - default: reportType="Unknown Error type"; break; - } - - return reportType; - } - - public String toString(){ - - final String reportType=getTypeText(); - - return (reportType - + " (" + lineNumber +","+ columnNumber + ") : " + message); - } - - public void increaseRepeat(){ - repeat++; - } - - public int getRepeat(){ - return repeat; - } -} - +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2010 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.validation; + +public class ValidationReportItem { + + public static final int WARNING = 1; + public static final int ERROR = 2; + public static final int FATAL = 4; + + private int type = -1; + private int lineNumber = -1; + private int columnNumber = -1; + private String publicId = null; + private String systemId = null; + private String message =""; + private int repeat=1; + + public void setType(int type){ + this.type=type; + } + + public int getType(){ + return type; + } + + public void setLineNumber(int nr){ + this.lineNumber=nr; + } + + public int getLineNumber(){ + return this.lineNumber; + } + + public void setColumnNumber(int nr){ + this.columnNumber=nr; + } + + public int getColumnNumber(){ + return this.columnNumber; + } + + public void setMessage(String message){ + this.message=message; + } + + public String getMessage(){ + return this.message; + } + + public void setPublicId(String publicId){ + this.publicId=publicId; + } + + public String getPublicId(){ + return this.publicId; + } + + public void setSystemId(String systemId){ + this.systemId=systemId; + } + + public String getSystemId(){ + return this.systemId; + } + + public String getTypeText(){ + + String reportType="UNKNOWN"; + + switch (type) { + case WARNING: reportType="Warning"; break; + case ERROR: reportType="Error"; break; + case FATAL: reportType="Fatal"; break; + default: reportType="Unknown Error type"; break; + } + + return reportType; + } + + public String toString(){ + + final String reportType=getTypeText(); + + return (reportType + + " (" + lineNumber +","+ columnNumber + ") : " + message); + } + + public void increaseRepeat(){ + repeat++; + } + + public int getRepeat(){ + return repeat; + } +} + diff --git a/src/org/exist/validation/XmlLibraryChecker.java b/src/org/exist/validation/XmlLibraryChecker.java index 06a90ff6a8b..5e5b3dd9af2 100644 --- a/src/org/exist/validation/XmlLibraryChecker.java +++ b/src/org/exist/validation/XmlLibraryChecker.java @@ -1,368 +1,368 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2010 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.validation; - -import java.lang.reflect.Method; -import java.util.ServiceLoader; - -import javax.xml.parsers.SAXParserFactory; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; - -import org.apache.log4j.Logger; - -import org.exist.util.ExistSAXParserFactory; - -import org.xml.sax.XMLReader; - -/** - * Class for checking dependencies with XML libraries. - * - * @author Adam Retter - */ -public class XmlLibraryChecker { - - /** - * Possible XML Parsers, at least one must be valid - */ - private final static ClassVersion[] validParsers = { - new ClassVersion("Xerces", "Xerces-J 2.10.0", "org.apache.xerces.impl.Version.getVersion()") - }; - - /** - * Possible XML Transformers, at least one must be valid - */ - private final static ClassVersion[] validTransformers = { - new ClassVersion("Saxon", "8.9.0", "net.sf.saxon.Version.getProductVersion()"), - new ClassVersion("Xalan", "Xalan Java 2.7.1", "org.apache.xalan.Version.getVersion()"), - }; - - /** - * Possible XML resolvers, at least one must be valid - */ - private final static ClassVersion[] validResolvers = { - new ClassVersion("Resolver", "XmlResolver 1.2", "org.apache.xml.resolver.Version.getVersion()"), - }; - - - private final static Logger logger = Logger.getLogger( XmlLibraryChecker.class ); - - - /** - * Remove "@" from string. - */ - private static String getClassName(String classid) { - String className; - - final int lastChar = classid.lastIndexOf("@"); - if (lastChar == -1) { - className = classid; - } else { - className = classid.substring(0, lastChar); - } - return className; - } - - /** - * Determine the class that is actually used as XML parser. - * - * @return Full classname of parser. - */ - private static String determineActualParserClass() { - - String parserClass = "Unable to determine parser class"; - try { - final SAXParserFactory factory = ExistSAXParserFactory.getSAXParserFactory(); - final XMLReader xmlReader = factory.newSAXParser().getXMLReader(); - final String classId = xmlReader.toString(); - parserClass = getClassName(classId); - - } catch (final Exception ex) { - logger.error(ex.getMessage()); - } - return parserClass; - } - - - /** - * Determine the class that is actually used as XML transformer. - * - * @return Full classname of transformer. - */ - private static String determineActualTransformerClass(){ - String transformerClass = "Unable to determine transformer class"; - try { - final TransformerFactory factory = TransformerFactory.newInstance(); - final Transformer transformer = factory.newTransformer(); - final String classId = transformer.toString(); - transformerClass = getClassName(classId); - - } catch (final Exception ex) { - logger.error(ex.getMessage()); - } - return transformerClass; - } - - /** - * Perform checks on parsers, transformers and resolvers. - */ - public static void check() { - - StringBuilder message = new StringBuilder(); - - /* - * Parser - */ - message = new StringBuilder(); - final ServiceLoader allSax = ServiceLoader.load(SAXParserFactory.class); - for(final SAXParserFactory sax : allSax){ - message.append(getClassName(sax.toString())); - message.append(" "); - } - logger.debug("Detected SAXParserFactory classes: " + message.toString()); - - - message = new StringBuilder(); - - boolean invalidVersionFound = false; - - if( hasValidClassVersion( "Parser", validParsers, message ) ) { - logger.info( message.toString() ); - } else { - logger.warn( message.toString() ); - System.err.println( message.toString() ); - invalidVersionFound = true; - } - - /* - * Transformer - */ - message = new StringBuilder(); - - final ServiceLoader allXsl = ServiceLoader.load(TransformerFactory.class); - for(final TransformerFactory xsl : allXsl){ - message.append(getClassName(xsl.toString())); - message.append(" "); - } - logger.debug("Detected TransformerFactory classes: " + message.toString()); - - - message = new StringBuilder(); - - if( hasValidClassVersion( "Transformer", validTransformers, message ) ) { - logger.info( message.toString() ); - } else { - logger.warn( message.toString() ); - System.err.println( message.toString() ); - invalidVersionFound = true; - } - - /* - * Resolver - */ - message = new StringBuilder(); - if( hasValidClassVersion( "Resolver", validResolvers, message ) ) { - logger.info( message.toString() ); - } else { - logger.warn( message.toString() ); - System.err.println( message.toString() ); - invalidVersionFound = true; - } - - logger.info( "Using parser " + determineActualParserClass() ); - logger.info( "Using transformer " + determineActualTransformerClass() ); - - if( invalidVersionFound ) { - System.err.println( "Using parser " + determineActualParserClass() ); - System.err.println( "Using transformer " + determineActualTransformerClass() ); - System.err.println(); - } - } - - /** - * Check if for the specified service object one of the required - * classes is available. - * - * @param type Parser, Transformer or Resolver, used for reporting only. - * @param validClasses Array of valid classes. - * @param message Output message of detecting classes. - * @return TRUE if valid class has been found, otherwise FALSE. - */ - public static boolean hasValidClassVersion(String type, - ClassVersion[] validClasses, StringBuilder message) { - - final String sep = System.getProperty("line.separator"); - - message.append("Looking for a valid ").append(type).append("...").append(sep); - - for (final ClassVersion validClass : validClasses) { - final String actualVersion = validClass.getActualVersion(); - - message.append("Checking for ").append(validClass.getSimpleName()); - - if (actualVersion != null) { - message.append(", found version ").append(actualVersion); - - if (actualVersion.compareToIgnoreCase( - validClass.getRequiredVersion()) >= 0) { - message.append(sep).append("OK!").append(sep); - return true; - } else { - message.append(" needed version ").append(validClass.getRequiredVersion()).append(sep); - } - - } else { - message.append(", not found!").append(sep); - } - } - - message.append("Warning: Failed find a valid ").append(type).append("!").append(sep); - message.append(sep).append("Please add an appropriate ").append(type) - .append(" to the " + "class-path, e.g. in the 'endorsed' folder of " - + "the servlet container or in the 'endorsed' folder of the JRE.") - .append(sep); - - return false; - } - - /** - * Checks to see if a valid XML Parser exists - * - * @return boolean true indicates a valid Parser was found, false otherwise - */ - public static boolean hasValidParser() { - return hasValidParser(new StringBuilder()); - } - - /** - * Checks to see if a valid XML Parser exists - * - * @param message Messages about the status of available Parser's will - * be appended to this buffer - * - * @return boolean true indicates a valid Parser was found, false otherwise - */ - public static boolean hasValidParser(StringBuilder message) { - return hasValidClassVersion("Parser", validParsers, message); - } - - /** - * Checks to see if a valid XML Transformer exists - * - * @return boolean true indicates a valid Transformer was found, - * false otherwise - */ - public static boolean hasValidTransformer() { - return hasValidTransformer(new StringBuilder()); - } - - /** - * Checks to see if a valid XML Transformer exists - * - * @param message Messages about the status of available Transformer's - * will be appended to this buffer - * - * @return boolean true indicates a valid Transformer was found, - * false otherwise - */ - public static boolean hasValidTransformer(StringBuilder message) { - return hasValidClassVersion("Transformer", validTransformers, message); - } - - /** - * Simple class to describe a class, its required version and how to - * obtain the actual version - */ - public static class ClassVersion { - - private String simpleName; - private String requiredVersion; - private String versionFunction; - - /** - * Default Constructor - * - * @param simpleName The simple name for the class (just a - * descriptor really) - * @param requiredVersion The required version of the class - * @param versionFunction The function to be invoked to obtain the - * actual version of the class, must be fully - * qualified (i.e. includes the package name) - */ - ClassVersion(String simpleName, String requiredVersion, String versionFunction) { - this.simpleName = simpleName; - this.requiredVersion = requiredVersion; - this.versionFunction = versionFunction; - } - - /** - * @return the simple name of the class - */ - public String getSimpleName() { - return simpleName; - } - - /** - * @return the required version of the class - */ - public String getRequiredVersion() { - return requiredVersion; - } - - /** - * Invokes the specified versionFunction using reflection to get the - * actual version of the class - * - * @return the actual version of the class - */ - public String getActualVersion() { - String actualVersion = null; - - //get the class name from the specifiec version function string - final String versionClassName = versionFunction - .substring(0, versionFunction.lastIndexOf('.')); - - //get the function name from the specifiec version function string - final String versionFunctionName = versionFunction.substring( - versionFunction.lastIndexOf('.') + 1, versionFunction.lastIndexOf('(')); - - try { - //get the class - final Class versionClass = Class.forName(versionClassName); - - //get the method - final Method getVersionMethod = versionClass - .getMethod(versionFunctionName, (Class[]) null); - - //invoke the method on the class - actualVersion = (String) getVersionMethod - .invoke(versionClass, (Object[]) null); - - } catch (final Exception ex) { - logger.debug(ex.getMessage()); - } - - //return the actual version - return actualVersion; - } - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2010 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.validation; + +import java.lang.reflect.Method; +import java.util.ServiceLoader; + +import javax.xml.parsers.SAXParserFactory; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; + +import org.apache.log4j.Logger; + +import org.exist.util.ExistSAXParserFactory; + +import org.xml.sax.XMLReader; + +/** + * Class for checking dependencies with XML libraries. + * + * @author Adam Retter + */ +public class XmlLibraryChecker { + + /** + * Possible XML Parsers, at least one must be valid + */ + private final static ClassVersion[] validParsers = { + new ClassVersion("Xerces", "Xerces-J 2.10.0", "org.apache.xerces.impl.Version.getVersion()") + }; + + /** + * Possible XML Transformers, at least one must be valid + */ + private final static ClassVersion[] validTransformers = { + new ClassVersion("Saxon", "8.9.0", "net.sf.saxon.Version.getProductVersion()"), + new ClassVersion("Xalan", "Xalan Java 2.7.1", "org.apache.xalan.Version.getVersion()"), + }; + + /** + * Possible XML resolvers, at least one must be valid + */ + private final static ClassVersion[] validResolvers = { + new ClassVersion("Resolver", "XmlResolver 1.2", "org.apache.xml.resolver.Version.getVersion()"), + }; + + + private final static Logger logger = Logger.getLogger( XmlLibraryChecker.class ); + + + /** + * Remove "@" from string. + */ + private static String getClassName(String classid) { + String className; + + final int lastChar = classid.lastIndexOf("@"); + if (lastChar == -1) { + className = classid; + } else { + className = classid.substring(0, lastChar); + } + return className; + } + + /** + * Determine the class that is actually used as XML parser. + * + * @return Full classname of parser. + */ + private static String determineActualParserClass() { + + String parserClass = "Unable to determine parser class"; + try { + final SAXParserFactory factory = ExistSAXParserFactory.getSAXParserFactory(); + final XMLReader xmlReader = factory.newSAXParser().getXMLReader(); + final String classId = xmlReader.toString(); + parserClass = getClassName(classId); + + } catch (final Exception ex) { + logger.error(ex.getMessage()); + } + return parserClass; + } + + + /** + * Determine the class that is actually used as XML transformer. + * + * @return Full classname of transformer. + */ + private static String determineActualTransformerClass(){ + String transformerClass = "Unable to determine transformer class"; + try { + final TransformerFactory factory = TransformerFactory.newInstance(); + final Transformer transformer = factory.newTransformer(); + final String classId = transformer.toString(); + transformerClass = getClassName(classId); + + } catch (final Exception ex) { + logger.error(ex.getMessage()); + } + return transformerClass; + } + + /** + * Perform checks on parsers, transformers and resolvers. + */ + public static void check() { + + StringBuilder message = new StringBuilder(); + + /* + * Parser + */ + message = new StringBuilder(); + final ServiceLoader allSax = ServiceLoader.load(SAXParserFactory.class); + for(final SAXParserFactory sax : allSax){ + message.append(getClassName(sax.toString())); + message.append(" "); + } + logger.debug("Detected SAXParserFactory classes: " + message.toString()); + + + message = new StringBuilder(); + + boolean invalidVersionFound = false; + + if( hasValidClassVersion( "Parser", validParsers, message ) ) { + logger.info( message.toString() ); + } else { + logger.warn( message.toString() ); + System.err.println( message.toString() ); + invalidVersionFound = true; + } + + /* + * Transformer + */ + message = new StringBuilder(); + + final ServiceLoader allXsl = ServiceLoader.load(TransformerFactory.class); + for(final TransformerFactory xsl : allXsl){ + message.append(getClassName(xsl.toString())); + message.append(" "); + } + logger.debug("Detected TransformerFactory classes: " + message.toString()); + + + message = new StringBuilder(); + + if( hasValidClassVersion( "Transformer", validTransformers, message ) ) { + logger.info( message.toString() ); + } else { + logger.warn( message.toString() ); + System.err.println( message.toString() ); + invalidVersionFound = true; + } + + /* + * Resolver + */ + message = new StringBuilder(); + if( hasValidClassVersion( "Resolver", validResolvers, message ) ) { + logger.info( message.toString() ); + } else { + logger.warn( message.toString() ); + System.err.println( message.toString() ); + invalidVersionFound = true; + } + + logger.info( "Using parser " + determineActualParserClass() ); + logger.info( "Using transformer " + determineActualTransformerClass() ); + + if( invalidVersionFound ) { + System.err.println( "Using parser " + determineActualParserClass() ); + System.err.println( "Using transformer " + determineActualTransformerClass() ); + System.err.println(); + } + } + + /** + * Check if for the specified service object one of the required + * classes is available. + * + * @param type Parser, Transformer or Resolver, used for reporting only. + * @param validClasses Array of valid classes. + * @param message Output message of detecting classes. + * @return TRUE if valid class has been found, otherwise FALSE. + */ + public static boolean hasValidClassVersion(String type, + ClassVersion[] validClasses, StringBuilder message) { + + final String sep = System.getProperty("line.separator"); + + message.append("Looking for a valid ").append(type).append("...").append(sep); + + for (final ClassVersion validClass : validClasses) { + final String actualVersion = validClass.getActualVersion(); + + message.append("Checking for ").append(validClass.getSimpleName()); + + if (actualVersion != null) { + message.append(", found version ").append(actualVersion); + + if (actualVersion.compareToIgnoreCase( + validClass.getRequiredVersion()) >= 0) { + message.append(sep).append("OK!").append(sep); + return true; + } else { + message.append(" needed version ").append(validClass.getRequiredVersion()).append(sep); + } + + } else { + message.append(", not found!").append(sep); + } + } + + message.append("Warning: Failed find a valid ").append(type).append("!").append(sep); + message.append(sep).append("Please add an appropriate ").append(type) + .append(" to the " + "class-path, e.g. in the 'endorsed' folder of " + + "the servlet container or in the 'endorsed' folder of the JRE.") + .append(sep); + + return false; + } + + /** + * Checks to see if a valid XML Parser exists + * + * @return boolean true indicates a valid Parser was found, false otherwise + */ + public static boolean hasValidParser() { + return hasValidParser(new StringBuilder()); + } + + /** + * Checks to see if a valid XML Parser exists + * + * @param message Messages about the status of available Parser's will + * be appended to this buffer + * + * @return boolean true indicates a valid Parser was found, false otherwise + */ + public static boolean hasValidParser(StringBuilder message) { + return hasValidClassVersion("Parser", validParsers, message); + } + + /** + * Checks to see if a valid XML Transformer exists + * + * @return boolean true indicates a valid Transformer was found, + * false otherwise + */ + public static boolean hasValidTransformer() { + return hasValidTransformer(new StringBuilder()); + } + + /** + * Checks to see if a valid XML Transformer exists + * + * @param message Messages about the status of available Transformer's + * will be appended to this buffer + * + * @return boolean true indicates a valid Transformer was found, + * false otherwise + */ + public static boolean hasValidTransformer(StringBuilder message) { + return hasValidClassVersion("Transformer", validTransformers, message); + } + + /** + * Simple class to describe a class, its required version and how to + * obtain the actual version + */ + public static class ClassVersion { + + private String simpleName; + private String requiredVersion; + private String versionFunction; + + /** + * Default Constructor + * + * @param simpleName The simple name for the class (just a + * descriptor really) + * @param requiredVersion The required version of the class + * @param versionFunction The function to be invoked to obtain the + * actual version of the class, must be fully + * qualified (i.e. includes the package name) + */ + ClassVersion(String simpleName, String requiredVersion, String versionFunction) { + this.simpleName = simpleName; + this.requiredVersion = requiredVersion; + this.versionFunction = versionFunction; + } + + /** + * @return the simple name of the class + */ + public String getSimpleName() { + return simpleName; + } + + /** + * @return the required version of the class + */ + public String getRequiredVersion() { + return requiredVersion; + } + + /** + * Invokes the specified versionFunction using reflection to get the + * actual version of the class + * + * @return the actual version of the class + */ + public String getActualVersion() { + String actualVersion = null; + + //get the class name from the specifiec version function string + final String versionClassName = versionFunction + .substring(0, versionFunction.lastIndexOf('.')); + + //get the function name from the specifiec version function string + final String versionFunctionName = versionFunction.substring( + versionFunction.lastIndexOf('.') + 1, versionFunction.lastIndexOf('(')); + + try { + //get the class + final Class versionClass = Class.forName(versionClassName); + + //get the method + final Method getVersionMethod = versionClass + .getMethod(versionFunctionName, (Class[]) null); + + //invoke the method on the class + actualVersion = (String) getVersionMethod + .invoke(versionClass, (Object[]) null); + + } catch (final Exception ex) { + logger.debug(ex.getMessage()); + } + + //return the actual version + return actualVersion; + } + } +} diff --git a/src/org/exist/validation/internal/DatabaseResources.java b/src/org/exist/validation/internal/DatabaseResources.java index 3e105b93e44..5fe1021b37a 100644 --- a/src/org/exist/validation/internal/DatabaseResources.java +++ b/src/org/exist/validation/internal/DatabaseResources.java @@ -1,221 +1,221 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ - -package org.exist.validation.internal; - -import org.apache.log4j.Logger; -import org.exist.security.Subject; -import org.exist.security.xacml.AccessContext; -import org.exist.source.ClassLoaderSource; -import org.exist.storage.BrokerPool; -import org.exist.storage.DBBroker; -import org.exist.xquery.CompiledXQuery; -import org.exist.xquery.XPathException; -import org.exist.xquery.XQuery; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.value.Sequence; -import org.exist.xquery.value.SequenceIterator; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Helper class for accessing grammars. - * - * @author Dannes Wessels (dizzzz@exist-db.org) - */ -public class DatabaseResources { - - public final static String QUERY_LOCATION = "org/exist/validation/internal/query/"; - - public final static String FIND_XSD = QUERY_LOCATION + "find_schema_by_targetNamespace.xq"; - - public final static String FIND_CATALOGS_WITH_DTD = QUERY_LOCATION + "find_catalogs_with_dtd.xq"; - - public final static String PUBLICID = "publicId"; - - public final static String TARGETNAMESPACE = "targetNamespace"; - - public final static String CATALOG = "catalog"; - - public final static String COLLECTION = "collection"; - - /** Local reference to database */ - private BrokerPool brokerPool = null; - - /** Local logger */ - private final static Logger logger = Logger.getLogger(DatabaseResources.class); - - - /** - * Convert sequence into list of strings. - * - * @param sequence Result of query. - * @return List containing String objects. - */ - public List getAllResults(Sequence sequence){ - List result = new ArrayList(); - - try { - final SequenceIterator i = sequence.iterate(); - while(i.hasNext()){ - final String path = i.nextItem().getStringValue(); - result.add(path); - } - - } catch (final XPathException ex) { - logger.error("xQuery issue.", ex); - result=null; - } - - return result; - } - - /** - * Get first entry of sequence as String. - * - * @param sequence Result of query. - * @return String containing representation of 1st entry of sequence. - */ - public String getFirstResult(Sequence sequence){ - String result = null; - - try { - final SequenceIterator i = sequence.iterate(); - if(i.hasNext()){ - result= i.nextItem().getStringValue(); - - logger.debug("Single query result: '"+result+"'."); - - } else { - logger.debug("No query result."); - } - - } catch (final XPathException ex) { - logger.error("xQuery issue ", ex); - } - - return result; - } - - - public Sequence executeQuery(String queryPath, Map params, Subject user){ - - final String namespace = params.get(TARGETNAMESPACE); - final String publicId = params.get(PUBLICID); - final String catalogPath = params.get(CATALOG); - final String collection = params.get(COLLECTION); - - if(logger.isDebugEnabled()) { - logger.debug("collection=" + collection + " namespace=" + namespace - + " publicId="+publicId + " catalogPath="+catalogPath); - } - - DBBroker broker = null; - Sequence result= null; - try { - broker = brokerPool.get(user); - - CompiledXQuery compiled =null; - final XQuery xquery = broker.getXQueryService(); - final XQueryContext context = xquery.newContext(AccessContext.INTERNAL_PREFIX_LOOKUP); - - if(collection!=null){ - context.declareVariable(COLLECTION, collection); - } - - if(namespace!=null){ - context.declareVariable(TARGETNAMESPACE, namespace); - } - - if(publicId!=null){ - context.declareVariable(PUBLICID, publicId); - } - - if(catalogPath!=null){ - context.declareVariable(CATALOG, catalogPath); - } - - compiled = xquery.compile(context, new ClassLoaderSource(queryPath) ); - - result = xquery.execute(compiled, null); - - } catch (final Exception ex) { - logger.error("Problem executing xquery", ex); - result= null; - - } finally{ - if(brokerPool!=null){ - brokerPool.release(broker); - } - } - return result; - } - - - /** - * Creates a new instance of DatabaseResources. - * - * - * - * @param pool Instance shared broker pool. - */ - public DatabaseResources(BrokerPool pool) { - - logger.info("Initializing DatabaseResources"); - this.brokerPool = pool; - - } - - public String findXSD(String collection, String targetNamespace, Subject user){ - - if(logger.isDebugEnabled()) { - logger.debug("Find schema with namespace '"+targetNamespace+"' in '"+collection+"'."); - } - - final Map params = new HashMap(); - params.put(COLLECTION, collection); - params.put(TARGETNAMESPACE, targetNamespace); - - final Sequence result = executeQuery(FIND_XSD, params, user ); - - return getFirstResult(result); - } - - public String findCatalogWithDTD(String collection, String publicId, Subject user){ - - if(logger.isDebugEnabled()) { - logger.debug("Find DTD with public '"+publicId+"' in '"+collection+"'."); - } - - final Map params = new HashMap(); - params.put(COLLECTION, collection); - params.put(PUBLICID, publicId); - - final Sequence result = executeQuery(FIND_CATALOGS_WITH_DTD, params, user ); - - return getFirstResult(result); - } - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ + +package org.exist.validation.internal; + +import org.apache.log4j.Logger; +import org.exist.security.Subject; +import org.exist.security.xacml.AccessContext; +import org.exist.source.ClassLoaderSource; +import org.exist.storage.BrokerPool; +import org.exist.storage.DBBroker; +import org.exist.xquery.CompiledXQuery; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQuery; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.value.Sequence; +import org.exist.xquery.value.SequenceIterator; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Helper class for accessing grammars. + * + * @author Dannes Wessels (dizzzz@exist-db.org) + */ +public class DatabaseResources { + + public final static String QUERY_LOCATION = "org/exist/validation/internal/query/"; + + public final static String FIND_XSD = QUERY_LOCATION + "find_schema_by_targetNamespace.xq"; + + public final static String FIND_CATALOGS_WITH_DTD = QUERY_LOCATION + "find_catalogs_with_dtd.xq"; + + public final static String PUBLICID = "publicId"; + + public final static String TARGETNAMESPACE = "targetNamespace"; + + public final static String CATALOG = "catalog"; + + public final static String COLLECTION = "collection"; + + /** Local reference to database */ + private BrokerPool brokerPool = null; + + /** Local logger */ + private final static Logger logger = Logger.getLogger(DatabaseResources.class); + + + /** + * Convert sequence into list of strings. + * + * @param sequence Result of query. + * @return List containing String objects. + */ + public List getAllResults(Sequence sequence){ + List result = new ArrayList(); + + try { + final SequenceIterator i = sequence.iterate(); + while(i.hasNext()){ + final String path = i.nextItem().getStringValue(); + result.add(path); + } + + } catch (final XPathException ex) { + logger.error("xQuery issue.", ex); + result=null; + } + + return result; + } + + /** + * Get first entry of sequence as String. + * + * @param sequence Result of query. + * @return String containing representation of 1st entry of sequence. + */ + public String getFirstResult(Sequence sequence){ + String result = null; + + try { + final SequenceIterator i = sequence.iterate(); + if(i.hasNext()){ + result= i.nextItem().getStringValue(); + + logger.debug("Single query result: '"+result+"'."); + + } else { + logger.debug("No query result."); + } + + } catch (final XPathException ex) { + logger.error("xQuery issue ", ex); + } + + return result; + } + + + public Sequence executeQuery(String queryPath, Map params, Subject user){ + + final String namespace = params.get(TARGETNAMESPACE); + final String publicId = params.get(PUBLICID); + final String catalogPath = params.get(CATALOG); + final String collection = params.get(COLLECTION); + + if(logger.isDebugEnabled()) { + logger.debug("collection=" + collection + " namespace=" + namespace + + " publicId="+publicId + " catalogPath="+catalogPath); + } + + DBBroker broker = null; + Sequence result= null; + try { + broker = brokerPool.get(user); + + CompiledXQuery compiled =null; + final XQuery xquery = broker.getXQueryService(); + final XQueryContext context = xquery.newContext(AccessContext.INTERNAL_PREFIX_LOOKUP); + + if(collection!=null){ + context.declareVariable(COLLECTION, collection); + } + + if(namespace!=null){ + context.declareVariable(TARGETNAMESPACE, namespace); + } + + if(publicId!=null){ + context.declareVariable(PUBLICID, publicId); + } + + if(catalogPath!=null){ + context.declareVariable(CATALOG, catalogPath); + } + + compiled = xquery.compile(context, new ClassLoaderSource(queryPath) ); + + result = xquery.execute(compiled, null); + + } catch (final Exception ex) { + logger.error("Problem executing xquery", ex); + result= null; + + } finally{ + if(brokerPool!=null){ + brokerPool.release(broker); + } + } + return result; + } + + + /** + * Creates a new instance of DatabaseResources. + * + * + * + * @param pool Instance shared broker pool. + */ + public DatabaseResources(BrokerPool pool) { + + logger.info("Initializing DatabaseResources"); + this.brokerPool = pool; + + } + + public String findXSD(String collection, String targetNamespace, Subject user){ + + if(logger.isDebugEnabled()) { + logger.debug("Find schema with namespace '"+targetNamespace+"' in '"+collection+"'."); + } + + final Map params = new HashMap(); + params.put(COLLECTION, collection); + params.put(TARGETNAMESPACE, targetNamespace); + + final Sequence result = executeQuery(FIND_XSD, params, user ); + + return getFirstResult(result); + } + + public String findCatalogWithDTD(String collection, String publicId, Subject user){ + + if(logger.isDebugEnabled()) { + logger.debug("Find DTD with public '"+publicId+"' in '"+collection+"'."); + } + + final Map params = new HashMap(); + params.put(COLLECTION, collection); + params.put(PUBLICID, publicId); + + final Sequence result = executeQuery(FIND_CATALOGS_WITH_DTD, params, user ); + + return getFirstResult(result); + } + +} diff --git a/src/org/exist/validation/internal/node/NodeInputStream.java b/src/org/exist/validation/internal/node/NodeInputStream.java index 1ddba6f75e8..71432095758 100644 --- a/src/org/exist/validation/internal/node/NodeInputStream.java +++ b/src/org/exist/validation/internal/node/NodeInputStream.java @@ -1,88 +1,88 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2010 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ - -package org.exist.validation.internal.node; - -import java.io.IOException; -import java.io.InputStream; - -import org.apache.log4j.Logger; -import org.exist.storage.io.BlockingInputStream; -import org.exist.storage.io.BlockingOutputStream; -import org.exist.storage.serializers.Serializer; -import org.exist.xquery.value.NodeValue; - -/** - * @author Dannes Wessels (dizzzz@exist-db.org) - */ -public class NodeInputStream extends InputStream{ - - private final static Logger logger = Logger.getLogger(NodeInputStream.class); - - private BlockingInputStream bis; - private BlockingOutputStream bos; - private NodeSerializerThread rt; - - - /** Creates a new instance of NodeInputStream */ - public NodeInputStream(Serializer serializer, NodeValue node) { - logger.debug("Initializing NodeInputStream"); - - bis = new BlockingInputStream(); - bos = bis.getOutputStream(); - - rt = new NodeSerializerThread(serializer, node , bos); - - rt.start(); - - logger.debug("Initializing NodeInputStream done"); - } - - public int read(byte[] b, int off, int len) throws IOException { - return bis.read(b, off, len); - } - - public int read(byte[] b) throws IOException { - return bis.read(b, 0, b.length); - } - - public long skip(long n) throws IOException { - return bis.skip(n); - } - - public void reset() throws IOException { - bis.reset(); - } - - public int read() throws IOException { - return bis.read(); - } - - public void close() throws IOException { - bis.close(); - } - - public int available() throws IOException { - return bis.available(); - } - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2010 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ + +package org.exist.validation.internal.node; + +import java.io.IOException; +import java.io.InputStream; + +import org.apache.log4j.Logger; +import org.exist.storage.io.BlockingInputStream; +import org.exist.storage.io.BlockingOutputStream; +import org.exist.storage.serializers.Serializer; +import org.exist.xquery.value.NodeValue; + +/** + * @author Dannes Wessels (dizzzz@exist-db.org) + */ +public class NodeInputStream extends InputStream{ + + private final static Logger logger = Logger.getLogger(NodeInputStream.class); + + private BlockingInputStream bis; + private BlockingOutputStream bos; + private NodeSerializerThread rt; + + + /** Creates a new instance of NodeInputStream */ + public NodeInputStream(Serializer serializer, NodeValue node) { + logger.debug("Initializing NodeInputStream"); + + bis = new BlockingInputStream(); + bos = bis.getOutputStream(); + + rt = new NodeSerializerThread(serializer, node , bos); + + rt.start(); + + logger.debug("Initializing NodeInputStream done"); + } + + public int read(byte[] b, int off, int len) throws IOException { + return bis.read(b, off, len); + } + + public int read(byte[] b) throws IOException { + return bis.read(b, 0, b.length); + } + + public long skip(long n) throws IOException { + return bis.skip(n); + } + + public void reset() throws IOException { + bis.reset(); + } + + public int read() throws IOException { + return bis.read(); + } + + public void close() throws IOException { + bis.close(); + } + + public int available() throws IOException { + return bis.available(); + } + +} diff --git a/src/org/exist/validation/internal/node/NodeSerializer.java b/src/org/exist/validation/internal/node/NodeSerializer.java index cc8faee317d..f074e23f1c2 100644 --- a/src/org/exist/validation/internal/node/NodeSerializer.java +++ b/src/org/exist/validation/internal/node/NodeSerializer.java @@ -1,84 +1,84 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2010 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.validation.internal.node; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.Writer; -import java.util.Properties; - -import javax.xml.transform.OutputKeys; - -import org.apache.log4j.Logger; - -import org.exist.storage.serializers.Serializer; -import org.exist.util.serializer.SAXSerializer; -import org.exist.util.serializer.SerializerPool; -import org.exist.xquery.value.NodeValue; - -/** - * @author Dannes Wessels (dizzzz@exist-db.org) - */ -public class NodeSerializer { - - private final static Logger LOG = Logger.getLogger(NodeSerializer.class); - - public static void serialize(Serializer serializer, NodeValue node, - Properties outputProperties, OutputStream os) throws IOException { - - LOG.debug("Serializing started."); - final SAXSerializer sax = (SAXSerializer) SerializerPool.getInstance().borrowObject(SAXSerializer.class); - try { - final String encoding = outputProperties.getProperty(OutputKeys.ENCODING, "UTF-8"); - final Writer writer = new OutputStreamWriter(os, encoding); - sax.setOutput(writer, outputProperties); - - serializer.reset(); - serializer.setProperties(outputProperties); - serializer.setSAXHandlers(sax, sax); - - - sax.startDocument(); - serializer.toSAX(node); - -// while(node.hasNext()) { -// NodeValue next = (NodeValue)node.nextItem(); -// serializer.toSAX(next); -// } - - sax.endDocument(); - writer.close(); - - } catch(final Exception e) { - final String txt = "A problem occurred while serializing the node set"; - LOG.debug(txt+".", e); - throw new IOException(txt+": " + e.getMessage(), e); - - } finally { - LOG.debug("Serializing done."); - SerializerPool.getInstance().returnObject(sax); - } - } - - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2010 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.validation.internal.node; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.Writer; +import java.util.Properties; + +import javax.xml.transform.OutputKeys; + +import org.apache.log4j.Logger; + +import org.exist.storage.serializers.Serializer; +import org.exist.util.serializer.SAXSerializer; +import org.exist.util.serializer.SerializerPool; +import org.exist.xquery.value.NodeValue; + +/** + * @author Dannes Wessels (dizzzz@exist-db.org) + */ +public class NodeSerializer { + + private final static Logger LOG = Logger.getLogger(NodeSerializer.class); + + public static void serialize(Serializer serializer, NodeValue node, + Properties outputProperties, OutputStream os) throws IOException { + + LOG.debug("Serializing started."); + final SAXSerializer sax = (SAXSerializer) SerializerPool.getInstance().borrowObject(SAXSerializer.class); + try { + final String encoding = outputProperties.getProperty(OutputKeys.ENCODING, "UTF-8"); + final Writer writer = new OutputStreamWriter(os, encoding); + sax.setOutput(writer, outputProperties); + + serializer.reset(); + serializer.setProperties(outputProperties); + serializer.setSAXHandlers(sax, sax); + + + sax.startDocument(); + serializer.toSAX(node); + +// while(node.hasNext()) { +// NodeValue next = (NodeValue)node.nextItem(); +// serializer.toSAX(next); +// } + + sax.endDocument(); + writer.close(); + + } catch(final Exception e) { + final String txt = "A problem occurred while serializing the node set"; + LOG.debug(txt+".", e); + throw new IOException(txt+": " + e.getMessage(), e); + + } finally { + LOG.debug("Serializing done."); + SerializerPool.getInstance().returnObject(sax); + } + } + + +} diff --git a/src/org/exist/validation/internal/node/NodeSerializerThread.java b/src/org/exist/validation/internal/node/NodeSerializerThread.java index a739bd25715..c0decc0b47f 100644 --- a/src/org/exist/validation/internal/node/NodeSerializerThread.java +++ b/src/org/exist/validation/internal/node/NodeSerializerThread.java @@ -1,84 +1,84 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2010 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ - -package org.exist.validation.internal.node; - -import java.io.IOException; -import java.util.Properties; - -import javax.xml.transform.OutputKeys; - -import org.apache.log4j.Logger; -import org.exist.storage.io.BlockingOutputStream; -import org.exist.storage.serializers.Serializer; -import org.exist.xquery.value.NodeValue; - -/** - * @author Dannes Wessels (dizzzz@exist-db.org) - */ -public class NodeSerializerThread extends Thread{ - - private final static Logger logger = Logger.getLogger(NodeSerializerThread.class); - - private Serializer serializer; - private NodeValue node; - private BlockingOutputStream bos; - - /** - * Creates a new instance of NodeSerializerThread - */ - public NodeSerializerThread(Serializer serializer, NodeValue node, BlockingOutputStream bos) { - this.serializer=serializer; - this.node=node; - this.bos=bos; - } - - /** - * Write resource to the output stream. - */ - public void run() { - logger.debug("Thread started." ); - IOException exception=null; - try { - //parse serialization options - final Properties outputProperties = new Properties(); - outputProperties.setProperty(OutputKeys.INDENT, "yes"); - outputProperties.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); - - NodeSerializer.serialize(serializer, node, outputProperties, bos); - - } catch (IOException ex) { - logger.error(ex); - exception = ex; - - } finally { - try { // NEEDED! - bos.close(exception); - } catch (final IOException ex) { - logger.debug(ex); - } - logger.debug("Thread stopped." ); - } - } - - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2010 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ + +package org.exist.validation.internal.node; + +import java.io.IOException; +import java.util.Properties; + +import javax.xml.transform.OutputKeys; + +import org.apache.log4j.Logger; +import org.exist.storage.io.BlockingOutputStream; +import org.exist.storage.serializers.Serializer; +import org.exist.xquery.value.NodeValue; + +/** + * @author Dannes Wessels (dizzzz@exist-db.org) + */ +public class NodeSerializerThread extends Thread{ + + private final static Logger logger = Logger.getLogger(NodeSerializerThread.class); + + private Serializer serializer; + private NodeValue node; + private BlockingOutputStream bos; + + /** + * Creates a new instance of NodeSerializerThread + */ + public NodeSerializerThread(Serializer serializer, NodeValue node, BlockingOutputStream bos) { + this.serializer=serializer; + this.node=node; + this.bos=bos; + } + + /** + * Write resource to the output stream. + */ + public void run() { + logger.debug("Thread started." ); + IOException exception=null; + try { + //parse serialization options + final Properties outputProperties = new Properties(); + outputProperties.setProperty(OutputKeys.INDENT, "yes"); + outputProperties.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); + + NodeSerializer.serialize(serializer, node, outputProperties, bos); + + } catch (IOException ex) { + logger.error(ex); + exception = ex; + + } finally { + try { // NEEDED! + bos.close(exception); + } catch (final IOException ex) { + logger.debug(ex); + } + logger.debug("Thread stopped." ); + } + } + + +} diff --git a/src/org/exist/validation/internal/query/find_catalogs_with_dtd.xq b/src/org/exist/validation/internal/query/find_catalogs_with_dtd.xq index 1ccbb497560..182a7ae650b 100644 --- a/src/org/exist/validation/internal/query/find_catalogs_with_dtd.xq +++ b/src/org/exist/validation/internal/query/find_catalogs_with_dtd.xq @@ -1,15 +1,15 @@ -(: - Search for DTD in catalogs of database. - - Parameters: - - $collection top level collection to start searching - - $PublicId public identifier of DTD - - Returns: - Sequence of document-uris. - - $Id$ -:) -declare namespace ctlg='urn:oasis:names:tc:entity:xmlns:xml:catalog'; -for $uri in collection($collection)//ctlg:catalog/ctlg:public[@publicId = $publicId]/@uri/root() +(: + Search for DTD in catalogs of database. + + Parameters: + - $collection top level collection to start searching + - $PublicId public identifier of DTD + + Returns: + Sequence of document-uris. + + $Id$ +:) +declare namespace ctlg='urn:oasis:names:tc:entity:xmlns:xml:catalog'; +for $uri in collection($collection)//ctlg:catalog/ctlg:public[@publicId = $publicId]/@uri/root() return document-uri($uri) \ No newline at end of file diff --git a/src/org/exist/validation/internal/query/find_schema_by_targetNamespace.xq b/src/org/exist/validation/internal/query/find_schema_by_targetNamespace.xq index 556be7d4d1b..171121ba4df 100644 --- a/src/org/exist/validation/internal/query/find_schema_by_targetNamespace.xq +++ b/src/org/exist/validation/internal/query/find_schema_by_targetNamespace.xq @@ -1,14 +1,14 @@ -(: - Search for XML schemas in database. - - Parameters: - - $collection top level collection to start searching - - $targetNamespace target namespace of schema - - Returns: - Sequence of document-uris. - - $Id$ -:) -for $schema in collection($collection)//xs:schema[@targetNamespace = $targetNamespace ]/root() +(: + Search for XML schemas in database. + + Parameters: + - $collection top level collection to start searching + - $targetNamespace target namespace of schema + + Returns: + Sequence of document-uris. + + $Id$ +:) +for $schema in collection($collection)//xs:schema[@targetNamespace = $targetNamespace ]/root() return document-uri($schema) \ No newline at end of file diff --git a/src/org/exist/validation/resolver/AnyUriResolver.java b/src/org/exist/validation/resolver/AnyUriResolver.java index 33371e21db9..3002a813d23 100644 --- a/src/org/exist/validation/resolver/AnyUriResolver.java +++ b/src/org/exist/validation/resolver/AnyUriResolver.java @@ -1,152 +1,152 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2010 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ - -package org.exist.validation.resolver; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; - -import org.apache.log4j.Logger; - -import org.apache.xerces.xni.XMLResourceIdentifier; -import org.apache.xerces.xni.XNIException; -import org.apache.xerces.xni.parser.XMLEntityResolver; -import org.apache.xerces.xni.parser.XMLInputSource; - -import org.exist.protocolhandler.embedded.EmbeddedInputStream; -import org.exist.protocolhandler.xmldb.XmldbURL; -import org.exist.protocolhandler.xmlrpc.XmlrpcInputStream; - -/** - * Resolve a resource specified by xs:anyURI. First time the - * resource is resolved by the URL as specified in the constructor, - * the second the URL of the ExpandedSystemId is used. - * - * @author Dannes Wessels (dizzzz@exist-db.org) - */ -public class AnyUriResolver implements XMLEntityResolver { - private final static Logger LOG = Logger.getLogger(AnyUriResolver.class); - - private String docPath; - private String parentURI; - - private boolean firstTime=true; - - /** Creates a new instance of AnyUriResolver */ - public AnyUriResolver(String path) { - docPath=path; - if(docPath.startsWith("/")){ - docPath="xmldb:exist://"+docPath; - } - LOG.debug("Specified path="+path); - - if(path.lastIndexOf('/')!=-1){ - parentURI=path.substring(0, path.lastIndexOf('/')); - LOG.debug("parentURI="+parentURI); - } else { - parentURI=""; - } - } - - - @Override - public XMLInputSource resolveEntity(XMLResourceIdentifier xri) throws XNIException, IOException { - - if(xri.getExpandedSystemId()==null && xri.getLiteralSystemId()==null && - xri.getNamespace()==null && xri.getPublicId()==null){ - - // quick fail - return null; - } - - if(LOG.isDebugEnabled()) { - LOG.debug("Resolving XMLResourceIdentifier: "+getXriDetails(xri)); - } - - String resourcePath=null; - String baseSystemId=null; - - if(firstTime){ - // First time use constructor supplied path - resourcePath = docPath; - baseSystemId = parentURI; - xri.setExpandedSystemId(docPath); - firstTime=false; - - } else { - resourcePath=xri.getExpandedSystemId(); - } - xri.setBaseSystemId(docPath); - - LOG.debug("resourcePath='"+resourcePath+"'"); - - // prevent NPE - if(resourcePath==null){ - return null; - } - - InputStream is = null; - if(resourcePath.startsWith("xmldb:")){ - final XmldbURL xmldbURL = new XmldbURL(resourcePath); - if(xmldbURL.isEmbedded()){ - is = new EmbeddedInputStream( xmldbURL ); - - } else { - is = new XmlrpcInputStream( xmldbURL ); - } - - } else { - is = new URL(resourcePath).openStream(); - } - - final XMLInputSource xis = new XMLInputSource(xri.getPublicId(), resourcePath, - baseSystemId, is, "UTF-8"); - - if(LOG.isDebugEnabled()) { - LOG.debug( "XMLInputSource: "+getXisDetails(xis) ); - } - - return xis; - - } - - private String getXriDetails(XMLResourceIdentifier xrid){ - final StringBuilder sb = new StringBuilder(); - sb.append("PublicId='").append(xrid.getPublicId()).append("' "); - sb.append("BaseSystemId='").append(xrid.getBaseSystemId()).append("' "); - sb.append("ExpandedSystemId='").append(xrid.getExpandedSystemId()).append("' "); - sb.append("LiteralSystemId='").append(xrid.getLiteralSystemId()).append("' "); - sb.append("Namespace='").append(xrid.getNamespace()).append("' "); - return sb.toString(); - } - - private String getXisDetails(XMLInputSource xis){ - final StringBuilder sb = new StringBuilder(); - sb.append("PublicId='").append(xis.getPublicId()).append("' "); - sb.append("SystemId='").append(xis.getSystemId()).append("' "); - sb.append("BaseSystemId='").append(xis.getBaseSystemId()).append("' "); - sb.append("Encoding='").append(xis.getEncoding()).append("' "); - return sb.toString(); - } - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2010 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ + +package org.exist.validation.resolver; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; + +import org.apache.log4j.Logger; + +import org.apache.xerces.xni.XMLResourceIdentifier; +import org.apache.xerces.xni.XNIException; +import org.apache.xerces.xni.parser.XMLEntityResolver; +import org.apache.xerces.xni.parser.XMLInputSource; + +import org.exist.protocolhandler.embedded.EmbeddedInputStream; +import org.exist.protocolhandler.xmldb.XmldbURL; +import org.exist.protocolhandler.xmlrpc.XmlrpcInputStream; + +/** + * Resolve a resource specified by xs:anyURI. First time the + * resource is resolved by the URL as specified in the constructor, + * the second the URL of the ExpandedSystemId is used. + * + * @author Dannes Wessels (dizzzz@exist-db.org) + */ +public class AnyUriResolver implements XMLEntityResolver { + private final static Logger LOG = Logger.getLogger(AnyUriResolver.class); + + private String docPath; + private String parentURI; + + private boolean firstTime=true; + + /** Creates a new instance of AnyUriResolver */ + public AnyUriResolver(String path) { + docPath=path; + if(docPath.startsWith("/")){ + docPath="xmldb:exist://"+docPath; + } + LOG.debug("Specified path="+path); + + if(path.lastIndexOf('/')!=-1){ + parentURI=path.substring(0, path.lastIndexOf('/')); + LOG.debug("parentURI="+parentURI); + } else { + parentURI=""; + } + } + + + @Override + public XMLInputSource resolveEntity(XMLResourceIdentifier xri) throws XNIException, IOException { + + if(xri.getExpandedSystemId()==null && xri.getLiteralSystemId()==null && + xri.getNamespace()==null && xri.getPublicId()==null){ + + // quick fail + return null; + } + + if(LOG.isDebugEnabled()) { + LOG.debug("Resolving XMLResourceIdentifier: "+getXriDetails(xri)); + } + + String resourcePath=null; + String baseSystemId=null; + + if(firstTime){ + // First time use constructor supplied path + resourcePath = docPath; + baseSystemId = parentURI; + xri.setExpandedSystemId(docPath); + firstTime=false; + + } else { + resourcePath=xri.getExpandedSystemId(); + } + xri.setBaseSystemId(docPath); + + LOG.debug("resourcePath='"+resourcePath+"'"); + + // prevent NPE + if(resourcePath==null){ + return null; + } + + InputStream is = null; + if(resourcePath.startsWith("xmldb:")){ + final XmldbURL xmldbURL = new XmldbURL(resourcePath); + if(xmldbURL.isEmbedded()){ + is = new EmbeddedInputStream( xmldbURL ); + + } else { + is = new XmlrpcInputStream( xmldbURL ); + } + + } else { + is = new URL(resourcePath).openStream(); + } + + final XMLInputSource xis = new XMLInputSource(xri.getPublicId(), resourcePath, + baseSystemId, is, "UTF-8"); + + if(LOG.isDebugEnabled()) { + LOG.debug( "XMLInputSource: "+getXisDetails(xis) ); + } + + return xis; + + } + + private String getXriDetails(XMLResourceIdentifier xrid){ + final StringBuilder sb = new StringBuilder(); + sb.append("PublicId='").append(xrid.getPublicId()).append("' "); + sb.append("BaseSystemId='").append(xrid.getBaseSystemId()).append("' "); + sb.append("ExpandedSystemId='").append(xrid.getExpandedSystemId()).append("' "); + sb.append("LiteralSystemId='").append(xrid.getLiteralSystemId()).append("' "); + sb.append("Namespace='").append(xrid.getNamespace()).append("' "); + return sb.toString(); + } + + private String getXisDetails(XMLInputSource xis){ + final StringBuilder sb = new StringBuilder(); + sb.append("PublicId='").append(xis.getPublicId()).append("' "); + sb.append("SystemId='").append(xis.getSystemId()).append("' "); + sb.append("BaseSystemId='").append(xis.getBaseSystemId()).append("' "); + sb.append("Encoding='").append(xis.getEncoding()).append("' "); + return sb.toString(); + } + +} diff --git a/src/org/exist/validation/resolver/SearchResourceResolver.java b/src/org/exist/validation/resolver/SearchResourceResolver.java index e9e597da9d4..100a965c7bf 100644 --- a/src/org/exist/validation/resolver/SearchResourceResolver.java +++ b/src/org/exist/validation/resolver/SearchResourceResolver.java @@ -1,164 +1,164 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2010 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ - -package org.exist.validation.resolver; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; - -import org.apache.log4j.Logger; -import org.apache.xerces.xni.XMLResourceIdentifier; -import org.apache.xerces.xni.XNIException; -import org.apache.xerces.xni.parser.XMLEntityResolver; -import org.apache.xerces.xni.parser.XMLInputSource; -import org.exist.security.Subject; -import org.exist.storage.BrokerPool; -import org.exist.validation.internal.DatabaseResources; -import org.xml.sax.InputSource; - -/** - * Resolve a resource by searching in database. Schema's are queried - * directly, DTD are searched in catalog files. - * - * @author Dannes Wessels (dizzzz@exist-db.org) - */ -public class SearchResourceResolver implements XMLEntityResolver { - private final static Logger LOG = Logger.getLogger(SearchResourceResolver.class); - - private String collection=null; - private BrokerPool brokerPool = null; - - /** Creates a new instance of StoredResourceResolver */ - public SearchResourceResolver(String collectionPath, BrokerPool pool) { - LOG.debug("Specified collectionPath="+collectionPath); - collection=collectionPath; - brokerPool=pool; - } - - /** - * - */ - public XMLInputSource resolveEntity(XMLResourceIdentifier xri) throws XNIException, IOException { - - if(xri.getExpandedSystemId()==null && xri.getLiteralSystemId()==null && - xri.getNamespace()==null && xri.getPublicId()==null){ - - // quick fail - return null; - } - - if(LOG.isDebugEnabled()) { - LOG.debug("Resolving XMLResourceIdentifier: "+getXriDetails(xri)); - } - - - String resourcePath = null; - - final DatabaseResources databaseResources = new DatabaseResources(brokerPool); - - //UNDERSTAND: why using guest account, it can be disabled - final Subject user = brokerPool.getSecurityManager().getGuestSubject(); - - if( xri.getNamespace() !=null ){ - - // XML Schema search - LOG.debug("Searching namespace '"+xri.getNamespace()+"' in database from "+collection+"..."); - - resourcePath = databaseResources.findXSD(collection, xri.getNamespace(), user); - - // DIZZZ: set systemid? - - } else if ( xri.getPublicId() !=null ){ - - // Catalog search - LOG.debug("Searching publicId '"+xri.getPublicId()+"' in catalogs in database from "+collection+"..."); - - String catalogPath = databaseResources.findCatalogWithDTD(collection, xri.getPublicId(), user); - LOG.debug("Found publicId in catalog '"+catalogPath+"'"); - if(catalogPath!=null && catalogPath.startsWith("/")){ - catalogPath="xmldb:exist://"+catalogPath; - } - - final eXistXMLCatalogResolver resolver = new eXistXMLCatalogResolver(); - resolver.setCatalogList(new String[]{catalogPath}); - try { - final InputSource source = resolver.resolveEntity(xri.getPublicId(), ""); - if(source!=null){ - resourcePath=source.getSystemId(); - } - } catch (final Exception ex) { - LOG.debug(ex); - ex.printStackTrace(); - } - - // set systemid? - - } else { - // Fast escape; no logging, otherwise validation is slow! - return null; - } - - // Another escape route - if(resourcePath==null){ - LOG.debug("resourcePath=null"); - return null; - } - - if(resourcePath.startsWith("/")){ - resourcePath="xmldb:exist://"+resourcePath; - } - - LOG.debug("resourcePath='"+resourcePath+"'"); - - final InputStream is = new URL(resourcePath).openStream(); - - final XMLInputSource xis = new XMLInputSource(xri.getPublicId(), - xri.getExpandedSystemId(), xri.getBaseSystemId(), is, "UTF-8"); - - if(LOG.isDebugEnabled()) { - LOG.debug( "XMLInputSource: "+getXisDetails(xis) ); - } - - return xis; - } - - private String getXriDetails(XMLResourceIdentifier xrid){ - final StringBuilder sb = new StringBuilder(); - sb.append("PublicId='").append(xrid.getPublicId()).append("' "); - sb.append("BaseSystemId='").append(xrid.getBaseSystemId()).append("' "); - sb.append("ExpandedSystemId='").append(xrid.getExpandedSystemId()).append("' "); - sb.append("LiteralSystemId='").append(xrid.getLiteralSystemId()).append("' "); - sb.append("Namespace='").append(xrid.getNamespace()).append("' "); - return sb.toString(); - } - - private String getXisDetails(XMLInputSource xis){ - final StringBuilder sb = new StringBuilder(); - sb.append("PublicId='").append(xis.getPublicId()).append("' "); - sb.append("SystemId='").append(xis.getSystemId()).append("' "); - sb.append("BaseSystemId='").append(xis.getBaseSystemId()).append("' "); - sb.append("Encoding='").append(xis.getEncoding()).append("' "); - return sb.toString(); - } - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2010 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ + +package org.exist.validation.resolver; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; + +import org.apache.log4j.Logger; +import org.apache.xerces.xni.XMLResourceIdentifier; +import org.apache.xerces.xni.XNIException; +import org.apache.xerces.xni.parser.XMLEntityResolver; +import org.apache.xerces.xni.parser.XMLInputSource; +import org.exist.security.Subject; +import org.exist.storage.BrokerPool; +import org.exist.validation.internal.DatabaseResources; +import org.xml.sax.InputSource; + +/** + * Resolve a resource by searching in database. Schema's are queried + * directly, DTD are searched in catalog files. + * + * @author Dannes Wessels (dizzzz@exist-db.org) + */ +public class SearchResourceResolver implements XMLEntityResolver { + private final static Logger LOG = Logger.getLogger(SearchResourceResolver.class); + + private String collection=null; + private BrokerPool brokerPool = null; + + /** Creates a new instance of StoredResourceResolver */ + public SearchResourceResolver(String collectionPath, BrokerPool pool) { + LOG.debug("Specified collectionPath="+collectionPath); + collection=collectionPath; + brokerPool=pool; + } + + /** + * + */ + public XMLInputSource resolveEntity(XMLResourceIdentifier xri) throws XNIException, IOException { + + if(xri.getExpandedSystemId()==null && xri.getLiteralSystemId()==null && + xri.getNamespace()==null && xri.getPublicId()==null){ + + // quick fail + return null; + } + + if(LOG.isDebugEnabled()) { + LOG.debug("Resolving XMLResourceIdentifier: "+getXriDetails(xri)); + } + + + String resourcePath = null; + + final DatabaseResources databaseResources = new DatabaseResources(brokerPool); + + //UNDERSTAND: why using guest account, it can be disabled + final Subject user = brokerPool.getSecurityManager().getGuestSubject(); + + if( xri.getNamespace() !=null ){ + + // XML Schema search + LOG.debug("Searching namespace '"+xri.getNamespace()+"' in database from "+collection+"..."); + + resourcePath = databaseResources.findXSD(collection, xri.getNamespace(), user); + + // DIZZZ: set systemid? + + } else if ( xri.getPublicId() !=null ){ + + // Catalog search + LOG.debug("Searching publicId '"+xri.getPublicId()+"' in catalogs in database from "+collection+"..."); + + String catalogPath = databaseResources.findCatalogWithDTD(collection, xri.getPublicId(), user); + LOG.debug("Found publicId in catalog '"+catalogPath+"'"); + if(catalogPath!=null && catalogPath.startsWith("/")){ + catalogPath="xmldb:exist://"+catalogPath; + } + + final eXistXMLCatalogResolver resolver = new eXistXMLCatalogResolver(); + resolver.setCatalogList(new String[]{catalogPath}); + try { + final InputSource source = resolver.resolveEntity(xri.getPublicId(), ""); + if(source!=null){ + resourcePath=source.getSystemId(); + } + } catch (final Exception ex) { + LOG.debug(ex); + ex.printStackTrace(); + } + + // set systemid? + + } else { + // Fast escape; no logging, otherwise validation is slow! + return null; + } + + // Another escape route + if(resourcePath==null){ + LOG.debug("resourcePath=null"); + return null; + } + + if(resourcePath.startsWith("/")){ + resourcePath="xmldb:exist://"+resourcePath; + } + + LOG.debug("resourcePath='"+resourcePath+"'"); + + final InputStream is = new URL(resourcePath).openStream(); + + final XMLInputSource xis = new XMLInputSource(xri.getPublicId(), + xri.getExpandedSystemId(), xri.getBaseSystemId(), is, "UTF-8"); + + if(LOG.isDebugEnabled()) { + LOG.debug( "XMLInputSource: "+getXisDetails(xis) ); + } + + return xis; + } + + private String getXriDetails(XMLResourceIdentifier xrid){ + final StringBuilder sb = new StringBuilder(); + sb.append("PublicId='").append(xrid.getPublicId()).append("' "); + sb.append("BaseSystemId='").append(xrid.getBaseSystemId()).append("' "); + sb.append("ExpandedSystemId='").append(xrid.getExpandedSystemId()).append("' "); + sb.append("LiteralSystemId='").append(xrid.getLiteralSystemId()).append("' "); + sb.append("Namespace='").append(xrid.getNamespace()).append("' "); + return sb.toString(); + } + + private String getXisDetails(XMLInputSource xis){ + final StringBuilder sb = new StringBuilder(); + sb.append("PublicId='").append(xis.getPublicId()).append("' "); + sb.append("SystemId='").append(xis.getSystemId()).append("' "); + sb.append("BaseSystemId='").append(xis.getBaseSystemId()).append("' "); + sb.append("Encoding='").append(xis.getEncoding()).append("' "); + return sb.toString(); + } + +} diff --git a/src/org/exist/validation/resolver/eXistXMLCatalogResolver.java b/src/org/exist/validation/resolver/eXistXMLCatalogResolver.java index 7cfc3831114..5178c1b0074 100644 --- a/src/org/exist/validation/resolver/eXistXMLCatalogResolver.java +++ b/src/org/exist/validation/resolver/eXistXMLCatalogResolver.java @@ -1,235 +1,235 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2010 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ - -package org.exist.validation.resolver; - -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.util.List; - -import org.apache.log4j.Logger; -import org.apache.xerces.util.XMLCatalogResolver; -import org.apache.xerces.xni.XMLResourceIdentifier; -import org.apache.xerces.xni.XNIException; -import org.apache.xerces.xni.parser.XMLInputSource; -import org.w3c.dom.ls.LSInput; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -/** - * Wrapper around xerces2's - * XMLCatalogresolver - * @author Dannes Wessels (dizzzz@exist-db.org) - */ -public class eXistXMLCatalogResolver extends XMLCatalogResolver { - - public eXistXMLCatalogResolver(){ - super(); - LOG.debug("Initializing"); - } - - public eXistXMLCatalogResolver(java.lang.String[] catalogs){ - super(catalogs); - LOG.debug("Initializing using catalogs"); - } - - eXistXMLCatalogResolver(java.lang.String[] catalogs, boolean preferPublic){ - super(catalogs, preferPublic); - LOG.debug("Initializing using catalogs, preferPublic="+preferPublic); - } - - private final static Logger LOG = Logger.getLogger(eXistXMLCatalogResolver.class); - - /** - * Constructs a catalog resolver with the given list of entry files. - * - * @param catalogs List of Strings - * - * TODO: check for non-String and NULL values. - */ - public void setCatalogs(List catalogs){ - - if(catalogs!=null && catalogs.size()>0){ - final String[] allCatalogs = new String[catalogs.size()]; - int counter=0; - for (String element : catalogs) { - allCatalogs[counter]=element; - counter++; - } - super.setCatalogList(allCatalogs); - } - } - - /** - * @see org.apache.xerces.util.XMLCatalogResolver#resolveEntity(String, String) - */ - public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { - LOG.debug("Resolving publicId='"+publicId+"', systemId='"+systemId+"'"); - InputSource retValue = super.resolveEntity(publicId, systemId); - - if(retValue == null) - { - retValue = resolveEntityFallback(publicId, systemId); - } - - LOG.debug("Resolved " + (retValue!=null)); - if(retValue!=null){ - LOG.debug("PublicId='" + retValue.getPublicId() + "' SystemId=" + retValue.getSystemId()); - } - return retValue; - } - - /** moved from Collection.resolveEntity() revision 6144 */ - private InputSource resolveEntityFallback(String publicId, String systemId) throws SAXException, IOException - { - //if resolution failed and publicId == null, - // try to make absolute file names relative and retry - LOG.debug("Resolve failed, fallback scenario"); - if(publicId != null) - { - return null; - } - - final URL url = new URL(systemId); - if("file".equals(url.getProtocol())) - { - final String path = url.getPath(); - final File f = new File(path); - if(!f.canRead()) - { - return resolveEntity(null, f.getName()); - } - else - { - return new InputSource(f.getAbsolutePath()); - } - } - else - { - return new InputSource(url.openStream()); - } - } - - /** - * @see org.apache.xerces.util.XMLCatalogResolver#resolveResource(String, String, String, String, String) - */ - public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) { - LOG.debug("Resolving type='"+type+"', namespaceURI='"+namespaceURI+"', publicId='"+publicId+"', systemId='"+systemId+"', baseURI='"+baseURI+"'"); - final LSInput retValue= super.resolveResource(type, namespaceURI, publicId, systemId, baseURI); - - LOG.debug("Resolved " + (retValue!=null)); - if(retValue!=null){ - LOG.debug("PublicId='" + retValue.getPublicId() + "' SystemId='" - + retValue.getSystemId() + "' BaseURI='" + retValue.getBaseURI() +"'"); - } - - return retValue; - } - - /** - * @see org.apache.xerces.util.XMLCatalogResolver#resolveEntity(String, String, String, String) - */ - public InputSource resolveEntity(String name, String publicId, String baseURI, String systemId) throws SAXException, IOException { - LOG.debug("Resolving name='"+name+"', publicId='"+publicId+"', baseURI='"+baseURI+"', systemId='"+systemId+"'"); - final InputSource retValue = super.resolveEntity(name, publicId, baseURI, systemId); - - LOG.debug("Resolved " + (retValue!=null)); - if(retValue!=null){ - LOG.debug("PublicId='" + retValue.getPublicId() + "' SystemId='" - + retValue.getSystemId() +"'"); - } - - return retValue; - } - - /** - * @see org.apache.xerces.util.XMLCatalogResolver#resolveIdentifier(XMLResourceIdentifier) - */ - public String resolveIdentifier(XMLResourceIdentifier xri) throws IOException, XNIException { - - if(xri.getExpandedSystemId()==null && xri.getLiteralSystemId()==null && - xri.getNamespace()==null && xri.getPublicId()==null){ - - // quick fail - return null; - } - - if(LOG.isDebugEnabled()) { - LOG.debug("Resolving XMLResourceIdentifier: "+getXriDetails(xri)); - } - - final String retValue = super.resolveIdentifier(xri); - LOG.debug("Resolved " + (retValue!=null)); - if(retValue!=null){ - LOG.debug("Identifier='" + retValue +"'"); - } - return retValue; - } - - /** - * @see org.apache.xerces.util.XMLCatalogResolver#resolveEntity(XMLResourceIdentifier) - */ - public XMLInputSource resolveEntity(XMLResourceIdentifier xri) throws XNIException, IOException { - if(xri.getExpandedSystemId()==null && xri.getLiteralSystemId()==null && - xri.getNamespace()==null && xri.getPublicId()==null){ - - // quick fail - return null; - } - - if(LOG.isDebugEnabled()) { - LOG.debug("Resolving XMLResourceIdentifier: " + getXriDetails(xri)); - } - final XMLInputSource retValue = super.resolveEntity(xri); - - - - LOG.debug("Resolved " + (retValue!=null)); - if(retValue!=null){ - LOG.debug("PublicId='" + retValue.getPublicId() + "' SystemId='" - + retValue.getSystemId() +"' BaseSystemId=" + retValue.getBaseSystemId()); - } - - return retValue; - } - - /** - * @see org.apache.xerces.util.XMLCatalogResolver#getExternalSubset(String, String) - */ - public InputSource getExternalSubset(String name, String baseURI) throws SAXException, IOException { - LOG.debug("name='"+name+"' baseURI='"+baseURI+"'"); - return super.getExternalSubset(name, baseURI); - } - - private String getXriDetails(XMLResourceIdentifier xrid){ - final StringBuilder sb = new StringBuilder(); - sb.append("PublicId='").append(xrid.getPublicId()).append("' "); - sb.append("BaseSystemId='").append(xrid.getBaseSystemId()).append("' "); - sb.append("ExpandedSystemId='").append(xrid.getExpandedSystemId()).append("' "); - sb.append("LiteralSystemId='").append(xrid.getLiteralSystemId()).append("' "); - sb.append("Namespace='").append(xrid.getNamespace()).append("' "); - return sb.toString(); - } - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2010 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ + +package org.exist.validation.resolver; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.List; + +import org.apache.log4j.Logger; +import org.apache.xerces.util.XMLCatalogResolver; +import org.apache.xerces.xni.XMLResourceIdentifier; +import org.apache.xerces.xni.XNIException; +import org.apache.xerces.xni.parser.XMLInputSource; +import org.w3c.dom.ls.LSInput; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +/** + * Wrapper around xerces2's + * XMLCatalogresolver + * @author Dannes Wessels (dizzzz@exist-db.org) + */ +public class eXistXMLCatalogResolver extends XMLCatalogResolver { + + public eXistXMLCatalogResolver(){ + super(); + LOG.debug("Initializing"); + } + + public eXistXMLCatalogResolver(java.lang.String[] catalogs){ + super(catalogs); + LOG.debug("Initializing using catalogs"); + } + + eXistXMLCatalogResolver(java.lang.String[] catalogs, boolean preferPublic){ + super(catalogs, preferPublic); + LOG.debug("Initializing using catalogs, preferPublic="+preferPublic); + } + + private final static Logger LOG = Logger.getLogger(eXistXMLCatalogResolver.class); + + /** + * Constructs a catalog resolver with the given list of entry files. + * + * @param catalogs List of Strings + * + * TODO: check for non-String and NULL values. + */ + public void setCatalogs(List catalogs){ + + if(catalogs!=null && catalogs.size()>0){ + final String[] allCatalogs = new String[catalogs.size()]; + int counter=0; + for (String element : catalogs) { + allCatalogs[counter]=element; + counter++; + } + super.setCatalogList(allCatalogs); + } + } + + /** + * @see org.apache.xerces.util.XMLCatalogResolver#resolveEntity(String, String) + */ + public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { + LOG.debug("Resolving publicId='"+publicId+"', systemId='"+systemId+"'"); + InputSource retValue = super.resolveEntity(publicId, systemId); + + if(retValue == null) + { + retValue = resolveEntityFallback(publicId, systemId); + } + + LOG.debug("Resolved " + (retValue!=null)); + if(retValue!=null){ + LOG.debug("PublicId='" + retValue.getPublicId() + "' SystemId=" + retValue.getSystemId()); + } + return retValue; + } + + /** moved from Collection.resolveEntity() revision 6144 */ + private InputSource resolveEntityFallback(String publicId, String systemId) throws SAXException, IOException + { + //if resolution failed and publicId == null, + // try to make absolute file names relative and retry + LOG.debug("Resolve failed, fallback scenario"); + if(publicId != null) + { + return null; + } + + final URL url = new URL(systemId); + if("file".equals(url.getProtocol())) + { + final String path = url.getPath(); + final File f = new File(path); + if(!f.canRead()) + { + return resolveEntity(null, f.getName()); + } + else + { + return new InputSource(f.getAbsolutePath()); + } + } + else + { + return new InputSource(url.openStream()); + } + } + + /** + * @see org.apache.xerces.util.XMLCatalogResolver#resolveResource(String, String, String, String, String) + */ + public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) { + LOG.debug("Resolving type='"+type+"', namespaceURI='"+namespaceURI+"', publicId='"+publicId+"', systemId='"+systemId+"', baseURI='"+baseURI+"'"); + final LSInput retValue= super.resolveResource(type, namespaceURI, publicId, systemId, baseURI); + + LOG.debug("Resolved " + (retValue!=null)); + if(retValue!=null){ + LOG.debug("PublicId='" + retValue.getPublicId() + "' SystemId='" + + retValue.getSystemId() + "' BaseURI='" + retValue.getBaseURI() +"'"); + } + + return retValue; + } + + /** + * @see org.apache.xerces.util.XMLCatalogResolver#resolveEntity(String, String, String, String) + */ + public InputSource resolveEntity(String name, String publicId, String baseURI, String systemId) throws SAXException, IOException { + LOG.debug("Resolving name='"+name+"', publicId='"+publicId+"', baseURI='"+baseURI+"', systemId='"+systemId+"'"); + final InputSource retValue = super.resolveEntity(name, publicId, baseURI, systemId); + + LOG.debug("Resolved " + (retValue!=null)); + if(retValue!=null){ + LOG.debug("PublicId='" + retValue.getPublicId() + "' SystemId='" + + retValue.getSystemId() +"'"); + } + + return retValue; + } + + /** + * @see org.apache.xerces.util.XMLCatalogResolver#resolveIdentifier(XMLResourceIdentifier) + */ + public String resolveIdentifier(XMLResourceIdentifier xri) throws IOException, XNIException { + + if(xri.getExpandedSystemId()==null && xri.getLiteralSystemId()==null && + xri.getNamespace()==null && xri.getPublicId()==null){ + + // quick fail + return null; + } + + if(LOG.isDebugEnabled()) { + LOG.debug("Resolving XMLResourceIdentifier: "+getXriDetails(xri)); + } + + final String retValue = super.resolveIdentifier(xri); + LOG.debug("Resolved " + (retValue!=null)); + if(retValue!=null){ + LOG.debug("Identifier='" + retValue +"'"); + } + return retValue; + } + + /** + * @see org.apache.xerces.util.XMLCatalogResolver#resolveEntity(XMLResourceIdentifier) + */ + public XMLInputSource resolveEntity(XMLResourceIdentifier xri) throws XNIException, IOException { + if(xri.getExpandedSystemId()==null && xri.getLiteralSystemId()==null && + xri.getNamespace()==null && xri.getPublicId()==null){ + + // quick fail + return null; + } + + if(LOG.isDebugEnabled()) { + LOG.debug("Resolving XMLResourceIdentifier: " + getXriDetails(xri)); + } + final XMLInputSource retValue = super.resolveEntity(xri); + + + + LOG.debug("Resolved " + (retValue!=null)); + if(retValue!=null){ + LOG.debug("PublicId='" + retValue.getPublicId() + "' SystemId='" + + retValue.getSystemId() +"' BaseSystemId=" + retValue.getBaseSystemId()); + } + + return retValue; + } + + /** + * @see org.apache.xerces.util.XMLCatalogResolver#getExternalSubset(String, String) + */ + public InputSource getExternalSubset(String name, String baseURI) throws SAXException, IOException { + LOG.debug("name='"+name+"' baseURI='"+baseURI+"'"); + return super.getExternalSubset(name, baseURI); + } + + private String getXriDetails(XMLResourceIdentifier xrid){ + final StringBuilder sb = new StringBuilder(); + sb.append("PublicId='").append(xrid.getPublicId()).append("' "); + sb.append("BaseSystemId='").append(xrid.getBaseSystemId()).append("' "); + sb.append("ExpandedSystemId='").append(xrid.getExpandedSystemId()).append("' "); + sb.append("LiteralSystemId='").append(xrid.getLiteralSystemId()).append("' "); + sb.append("Namespace='").append(xrid.getNamespace()).append("' "); + return sb.toString(); + } + +} diff --git a/src/org/exist/webstart/package.html b/src/org/exist/webstart/package.html index 4b0fdddef53..b9d1ab045ff 100644 --- a/src/org/exist/webstart/package.html +++ b/src/org/exist/webstart/package.html @@ -1,5 +1,5 @@ - - - Classes for starting the Interactive Client using Java Webstart. - - + + + Classes for starting the Interactive Client using Java Webstart. + + diff --git a/src/org/exist/xmldb/ExtendedResource.java b/src/org/exist/xmldb/ExtendedResource.java index 7141b399fae..410ae709e1e 100644 --- a/src/org/exist/xmldb/ExtendedResource.java +++ b/src/org/exist/xmldb/ExtendedResource.java @@ -1,65 +1,65 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-08 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ - -package org.exist.xmldb; - -import java.io.File; -import java.io.InputStream; -import java.io.OutputStream; - -import org.xmldb.api.base.XMLDBException; - -/** - * An extension to BinaryResource interface, which adds the - * common methods needed by LocalBinaryResource and RemoteBinaryResource, - * so they can be streamlined. - * @author jmfernandez - * - */ -public interface ExtendedResource -{ - /** - * It returns an object representing the content, in the representation - * which needs less memory. - */ - public Object getExtendedContent() throws XMLDBException; - /** - * It returns an stream to the content, whichever it is its origin - */ - public InputStream getStreamContent() throws XMLDBException; - /** - * It returns the length of the content, whichever it is its origin - */ - public long getStreamLength() throws XMLDBException; - - /** - * It saves the resource to the local file given as input parameter. - * Do NOT confuse with set content. - */ - public void getContentIntoAFile(File localfile) throws XMLDBException; - - /** - * It saves the resource to the local stream given as input parameter. - * Do NOT confuse with set content. - */ - public void getContentIntoAStream(OutputStream os) throws XMLDBException; -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-08 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ + +package org.exist.xmldb; + +import java.io.File; +import java.io.InputStream; +import java.io.OutputStream; + +import org.xmldb.api.base.XMLDBException; + +/** + * An extension to BinaryResource interface, which adds the + * common methods needed by LocalBinaryResource and RemoteBinaryResource, + * so they can be streamlined. + * @author jmfernandez + * + */ +public interface ExtendedResource +{ + /** + * It returns an object representing the content, in the representation + * which needs less memory. + */ + public Object getExtendedContent() throws XMLDBException; + /** + * It returns an stream to the content, whichever it is its origin + */ + public InputStream getStreamContent() throws XMLDBException; + /** + * It returns the length of the content, whichever it is its origin + */ + public long getStreamLength() throws XMLDBException; + + /** + * It saves the resource to the local file given as input parameter. + * Do NOT confuse with set content. + */ + public void getContentIntoAFile(File localfile) throws XMLDBException; + + /** + * It saves the resource to the local stream given as input parameter. + * Do NOT confuse with set content. + */ + public void getContentIntoAStream(OutputStream os) throws XMLDBException; +} diff --git a/src/org/exist/xquery/AnnotationTrigger.java b/src/org/exist/xquery/AnnotationTrigger.java index cbd95a7d111..82c62971ac1 100644 --- a/src/org/exist/xquery/AnnotationTrigger.java +++ b/src/org/exist/xquery/AnnotationTrigger.java @@ -1,30 +1,30 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2012 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.xquery; - -/** - * @author Dmitriy Shabanov - * - */ -public interface AnnotationTrigger { - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2012 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.xquery; + +/** + * @author Dmitriy Shabanov + * + */ +public interface AnnotationTrigger { + +} diff --git a/src/org/exist/xquery/AnnotationTriggerOnResult.java b/src/org/exist/xquery/AnnotationTriggerOnResult.java index 8fde36e96dc..223da2eb5c6 100644 --- a/src/org/exist/xquery/AnnotationTriggerOnResult.java +++ b/src/org/exist/xquery/AnnotationTriggerOnResult.java @@ -1,34 +1,34 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2012 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.xquery; - -import org.exist.xquery.value.Sequence; - -/** - * @author Dmitriy Shabanov - * - */ -public interface AnnotationTriggerOnResult extends AnnotationTrigger { - - public void trigger(Sequence seq) throws XPathException; - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2012 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.xquery; + +import org.exist.xquery.value.Sequence; + +/** + * @author Dmitriy Shabanov + * + */ +public interface AnnotationTriggerOnResult extends AnnotationTrigger { + + public void trigger(Sequence seq) throws XPathException; + +} diff --git a/src/org/exist/xquery/Annotations.java b/src/org/exist/xquery/Annotations.java index 709589faa89..71258543927 100644 --- a/src/org/exist/xquery/Annotations.java +++ b/src/org/exist/xquery/Annotations.java @@ -1,58 +1,58 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2012 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.xquery; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author Dmitriy Shabanov - * - */ -public abstract class Annotations { - - private final static Map ns = new HashMap(); - - //workaround - static { - try { - final Class clazz = Class.forName("org.exist.xquery.xUnit.Annotations"); - clazz.newInstance(); - } catch (final Exception e) { - } - } - - public static void register(String namespace, Annotations anns) { - ns.put(namespace, anns); - } - - public static AnnotationTrigger getTrigger(Annotation ann) { - final Annotations anns = ns.get(ann.getName().getNamespaceURI()); - - if (anns == null) {return null;} - - return anns.getTrigger(ann.getName().getLocalName(), ann); - } - - public abstract AnnotationTrigger getTrigger(String name, Annotation ann); - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2012 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.xquery; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Dmitriy Shabanov + * + */ +public abstract class Annotations { + + private final static Map ns = new HashMap(); + + //workaround + static { + try { + final Class clazz = Class.forName("org.exist.xquery.xUnit.Annotations"); + clazz.newInstance(); + } catch (final Exception e) { + } + } + + public static void register(String namespace, Annotations anns) { + ns.put(namespace, anns); + } + + public static AnnotationTrigger getTrigger(Annotation ann) { + final Annotations anns = ns.get(ann.getName().getNamespaceURI()); + + if (anns == null) {return null;} + + return anns.getTrigger(ann.getName().getLocalName(), ann); + } + + public abstract AnnotationTrigger getTrigger(String name, Annotation ann); + +} diff --git a/src/org/exist/xquery/DefaultExpressionVisitor.java b/src/org/exist/xquery/DefaultExpressionVisitor.java index 46883df33a7..6b8f16e3fc5 100644 --- a/src/org/exist/xquery/DefaultExpressionVisitor.java +++ b/src/org/exist/xquery/DefaultExpressionVisitor.java @@ -1,163 +1,163 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.xquery; - -import java.util.Iterator; -import java.util.List; - -/** - * An {@link org.exist.xquery.ExpressionVisitor} which traverses the entire - * expression tree. Methods may be overwritten by subclasses to filter out the - * events they need. - */ -public class DefaultExpressionVisitor extends BasicExpressionVisitor { - - public void visitPathExpr(PathExpr expression) { - for (int i = 0; i < expression.getLength(); i++) { - final Expression next = expression.getExpression(i); - next.accept(this); - } - } - - public void visitUserFunction(UserDefinedFunction function) { - function.getFunctionBody().accept(this); - } - - public void visitBuiltinFunction(Function function) { - for (int i = 0; i < function.getArgumentCount(); i++) { - final Expression arg = function.getArgument(i); - arg.accept(this); - } - } - - @Override - public void visitFunctionCall(FunctionCall call) { - // forward to the called function - for(int i = 0; i < call.getArgumentCount(); i++) { - call.getArgument(i).accept(this); - } - call.getFunction().accept(this); - } - - public void visitForExpression(ForExpr forExpr) { - forExpr.getInputSequence().accept(this); - final Expression where = forExpr.getWhereExpression(); - if (where != null) { - where.accept(this); - } - for (OrderSpec orderSpec: forExpr.getOrderSpecs()) { - orderSpec.getSortExpression().accept(this); - } - for (GroupSpec groupSpec: forExpr.getGroupSpecs()) { - groupSpec.getGroupExpression().accept(this); - } - forExpr.getReturnExpression().accept(this); - } - - public void visitLetExpression(LetExpr letExpr) { - letExpr.getInputSequence().accept(this); - final Expression where = letExpr.getWhereExpression(); - if (where != null) { - where.accept(this); - } - for (OrderSpec orderSpec: letExpr.getOrderSpecs()) { - orderSpec.getSortExpression().accept(this); - } - for (GroupSpec groupSpec: letExpr.getGroupSpecs()) { - groupSpec.getGroupExpression().accept(this); - } - letExpr.getReturnExpression().accept(this); - } - - public void visitConditional(ConditionalExpression conditional) { - conditional.getTestExpr().accept(this); - conditional.getThenExpr().accept(this); - conditional.getElseExpr().accept(this); - } - - public void visitLocationStep(LocationStep locationStep) { - final List predicates = locationStep.getPredicates(); - for (final Predicate pred : predicates) { - pred.accept(this); - } - } - - public void visitPredicate(Predicate predicate) { - predicate.getExpression(0).accept(this); - } - - public void visitDocumentConstructor(DocumentConstructor constructor) { - constructor.getContent().accept(this); - } - - public void visitElementConstructor(ElementConstructor constructor) { - constructor.getNameExpr().accept(this); - if (constructor.getAttributes() != null) { - for (AttributeConstructor attrConstr: constructor.getAttributes()) { - attrConstr.accept(this); - } - } - if (constructor.getContent() != null) - {constructor.getContent().accept(this);} - } - - public void visitTextConstructor(DynamicTextConstructor constructor) { - constructor.getContent().accept(this); - } - - public void visitAttribConstructor(AttributeConstructor constructor) { - for (final Iterator i = constructor.contentIterator(); i.hasNext(); ) { - final Object next = i.next(); - if (next instanceof Expression) - {((Expression)next).accept(this);} - } - } - - public void visitAttribConstructor(DynamicAttributeConstructor constructor) { - constructor.getNameExpr().accept(this); - if (constructor.getContentExpr() != null) - {constructor.getContentExpr().accept(this);} - } - - public void visitUnionExpr(Union union) { - union.left.accept(this); - union.right.accept(this); - } - - public void visitIntersectionExpr(Intersection intersect) { - intersect.left.accept(this); - intersect.right.accept(this); - } - - @Override - public void visitVariableDeclaration(VariableDeclaration decl) { - decl.getExpression().accept(this); - } - - @Override - public void visitTryCatch(TryCatchExpression tryCatch) { - tryCatch.getTryTargetExpr().accept(this); - for (TryCatchExpression.CatchClause clause : tryCatch.getCatchClauses()) { - clause.getCatchExpr().accept(this); - } - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.xquery; + +import java.util.Iterator; +import java.util.List; + +/** + * An {@link org.exist.xquery.ExpressionVisitor} which traverses the entire + * expression tree. Methods may be overwritten by subclasses to filter out the + * events they need. + */ +public class DefaultExpressionVisitor extends BasicExpressionVisitor { + + public void visitPathExpr(PathExpr expression) { + for (int i = 0; i < expression.getLength(); i++) { + final Expression next = expression.getExpression(i); + next.accept(this); + } + } + + public void visitUserFunction(UserDefinedFunction function) { + function.getFunctionBody().accept(this); + } + + public void visitBuiltinFunction(Function function) { + for (int i = 0; i < function.getArgumentCount(); i++) { + final Expression arg = function.getArgument(i); + arg.accept(this); + } + } + + @Override + public void visitFunctionCall(FunctionCall call) { + // forward to the called function + for(int i = 0; i < call.getArgumentCount(); i++) { + call.getArgument(i).accept(this); + } + call.getFunction().accept(this); + } + + public void visitForExpression(ForExpr forExpr) { + forExpr.getInputSequence().accept(this); + final Expression where = forExpr.getWhereExpression(); + if (where != null) { + where.accept(this); + } + for (OrderSpec orderSpec: forExpr.getOrderSpecs()) { + orderSpec.getSortExpression().accept(this); + } + for (GroupSpec groupSpec: forExpr.getGroupSpecs()) { + groupSpec.getGroupExpression().accept(this); + } + forExpr.getReturnExpression().accept(this); + } + + public void visitLetExpression(LetExpr letExpr) { + letExpr.getInputSequence().accept(this); + final Expression where = letExpr.getWhereExpression(); + if (where != null) { + where.accept(this); + } + for (OrderSpec orderSpec: letExpr.getOrderSpecs()) { + orderSpec.getSortExpression().accept(this); + } + for (GroupSpec groupSpec: letExpr.getGroupSpecs()) { + groupSpec.getGroupExpression().accept(this); + } + letExpr.getReturnExpression().accept(this); + } + + public void visitConditional(ConditionalExpression conditional) { + conditional.getTestExpr().accept(this); + conditional.getThenExpr().accept(this); + conditional.getElseExpr().accept(this); + } + + public void visitLocationStep(LocationStep locationStep) { + final List predicates = locationStep.getPredicates(); + for (final Predicate pred : predicates) { + pred.accept(this); + } + } + + public void visitPredicate(Predicate predicate) { + predicate.getExpression(0).accept(this); + } + + public void visitDocumentConstructor(DocumentConstructor constructor) { + constructor.getContent().accept(this); + } + + public void visitElementConstructor(ElementConstructor constructor) { + constructor.getNameExpr().accept(this); + if (constructor.getAttributes() != null) { + for (AttributeConstructor attrConstr: constructor.getAttributes()) { + attrConstr.accept(this); + } + } + if (constructor.getContent() != null) + {constructor.getContent().accept(this);} + } + + public void visitTextConstructor(DynamicTextConstructor constructor) { + constructor.getContent().accept(this); + } + + public void visitAttribConstructor(AttributeConstructor constructor) { + for (final Iterator i = constructor.contentIterator(); i.hasNext(); ) { + final Object next = i.next(); + if (next instanceof Expression) + {((Expression)next).accept(this);} + } + } + + public void visitAttribConstructor(DynamicAttributeConstructor constructor) { + constructor.getNameExpr().accept(this); + if (constructor.getContentExpr() != null) + {constructor.getContentExpr().accept(this);} + } + + public void visitUnionExpr(Union union) { + union.left.accept(this); + union.right.accept(this); + } + + public void visitIntersectionExpr(Intersection intersect) { + intersect.left.accept(this); + intersect.right.accept(this); + } + + @Override + public void visitVariableDeclaration(VariableDeclaration decl) { + decl.getExpression().accept(this); + } + + @Override + public void visitTryCatch(TryCatchExpression tryCatch) { + tryCatch.getTryTargetExpr().accept(this); + for (TryCatchExpression.CatchClause clause : tryCatch.getCatchClauses()) { + clause.getCatchExpr().accept(this); + } + } +} diff --git a/src/org/exist/xquery/GroupSpec.java b/src/org/exist/xquery/GroupSpec.java index ba24960227b..a726a891c0f 100644 --- a/src/org/exist/xquery/GroupSpec.java +++ b/src/org/exist/xquery/GroupSpec.java @@ -1,89 +1,89 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-06 The eXist Project - * http://exist-db.org - * http://exist.sourceforge.net - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id$ - */ -package org.exist.xquery; - -import org.exist.util.Collations; -import org.exist.xquery.util.ExpressionDumper; - -/** - * A XQuery grouping specifier as specified in an "group by" clause (based on - * {@link org.exist.xquery.OrderSpec}). - * - * Used by {@link org.exist.xquery.BindingExpression}. - * - * @author boris - * @author Wolfgang - */ - -public class GroupSpec { - - @SuppressWarnings("unused") - private final XQueryContext context; - private Expression expression; - private String keyVarName = null; - private String collation = Collations.CODEPOINT; - - public GroupSpec(XQueryContext context, Expression groupExpr, String keyVarName) { - if (groupExpr == null) { - // Spec: "If the GroupingSpec does not contain an ExprSingle, an implicit - // expression is created, consisting of a variable reference with the - // same name as the grouping variable." - groupExpr = new VariableReference(context, keyVarName); - } - this.expression = groupExpr; - this.context = context; - this.keyVarName = keyVarName; - } - - public void setCollation(String collation) { - this.collation = collation; - } - - public void analyze(AnalyzeContextInfo contextInfo) throws XPathException { - expression.analyze(contextInfo); - } - - public Expression getGroupExpression() { - return expression; - } - - public String getKeyVarName(){ - return this.keyVarName; - } - - public String toString() { - final StringBuilder buf = new StringBuilder(); - buf.append(ExpressionDumper.dump(expression)); - return buf.toString(); - } - - public void resetState(boolean postOptimization) { - expression.resetState(postOptimization); - } - - public void replace(Expression oldExpr, Expression newExpr) { - if (expression == oldExpr) { - expression = newExpr; - } - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-06 The eXist Project + * http://exist-db.org + * http://exist.sourceforge.net + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ +package org.exist.xquery; + +import org.exist.util.Collations; +import org.exist.xquery.util.ExpressionDumper; + +/** + * A XQuery grouping specifier as specified in an "group by" clause (based on + * {@link org.exist.xquery.OrderSpec}). + * + * Used by {@link org.exist.xquery.BindingExpression}. + * + * @author boris + * @author Wolfgang + */ + +public class GroupSpec { + + @SuppressWarnings("unused") + private final XQueryContext context; + private Expression expression; + private String keyVarName = null; + private String collation = Collations.CODEPOINT; + + public GroupSpec(XQueryContext context, Expression groupExpr, String keyVarName) { + if (groupExpr == null) { + // Spec: "If the GroupingSpec does not contain an ExprSingle, an implicit + // expression is created, consisting of a variable reference with the + // same name as the grouping variable." + groupExpr = new VariableReference(context, keyVarName); + } + this.expression = groupExpr; + this.context = context; + this.keyVarName = keyVarName; + } + + public void setCollation(String collation) { + this.collation = collation; + } + + public void analyze(AnalyzeContextInfo contextInfo) throws XPathException { + expression.analyze(contextInfo); + } + + public Expression getGroupExpression() { + return expression; + } + + public String getKeyVarName(){ + return this.keyVarName; + } + + public String toString() { + final StringBuilder buf = new StringBuilder(); + buf.append(ExpressionDumper.dump(expression)); + return buf.toString(); + } + + public void resetState(boolean postOptimization) { + expression.resetState(postOptimization); + } + + public void replace(Expression oldExpr, Expression newExpr) { + if (expression == oldExpr) { + expression = newExpr; + } + } +} diff --git a/src/org/exist/xquery/IndexUseReporter.java b/src/org/exist/xquery/IndexUseReporter.java index 99daa277d48..dceacdd685b 100644 --- a/src/org/exist/xquery/IndexUseReporter.java +++ b/src/org/exist/xquery/IndexUseReporter.java @@ -1,38 +1,38 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2007 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - * - * @author Pierrick Brihaye - */ -package org.exist.xquery; - -/** Expressions that use an index to speed-up their evaluation may implement this interface. - * Tt will help index-related pragmas like (# exist:force-index-use #) { foo } - * - * Probably to be merged with org.exist.xquery.Optimizable in the future. - * - * @author brihaye - * - */ -public interface IndexUseReporter { - - public boolean hasUsedIndex(); - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2007 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + * + * @author Pierrick Brihaye + */ +package org.exist.xquery; + +/** Expressions that use an index to speed-up their evaluation may implement this interface. + * Tt will help index-related pragmas like (# exist:force-index-use #) { foo } + * + * Probably to be merged with org.exist.xquery.Optimizable in the future. + * + * @author brihaye + * + */ +public interface IndexUseReporter { + + public boolean hasUsedIndex(); + +} diff --git a/src/org/exist/xquery/Optimizer.java b/src/org/exist/xquery/Optimizer.java index 28aa172966c..377004540d2 100644 --- a/src/org/exist/xquery/Optimizer.java +++ b/src/org/exist/xquery/Optimizer.java @@ -1,368 +1,368 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.xquery; - -import org.exist.xquery.pragmas.Optimize; -import org.apache.log4j.Logger; -import org.exist.xquery.functions.fn.ExtFulltext; -import org.exist.xquery.util.ExpressionDumper; - -import java.util.ArrayList; -import java.util.List; - -/** - * Analyzes the query and marks optimizable expressions for the query engine. - * This class just searches for potentially optimizable expressions in the query tree and - * encloses those expressions with an (#exist:optimize#) pragma. The real optimization - * work is not done by this class but by the pragma (see {@link org.exist.xquery.pragmas.Optimize}). - * The pragma may also decide that the optimization is not applicable and just execute - * the expression without any optimization. - * - * Currently, the optimizer is disabled by default. To enable it, set attribute enable-query-rewriting - * to yes in conf.xml: - * - * <xquery enable-java-binding="no" enable-query-rewriting="yes">... - * - * To enable/disable the optimizer for a single query, use an option: - * - *
declare option exist:optimize "enable=yes|no";
- * - */ -public class Optimizer extends DefaultExpressionVisitor { - - private static final Logger LOG = Logger.getLogger(Optimizer.class); - - private XQueryContext context; - - private int predicates = 0; - - private boolean hasOptimized = false; - - private List rewriters = new ArrayList(5); - - public Optimizer(XQueryContext context) { - this.context = context; - this.rewriters = context.getBroker().getIndexController().getQueryRewriters(context); - } - - public boolean hasOptimized() { - return hasOptimized; - } - - public void visitLocationStep(LocationStep locationStep) { - super.visitLocationStep(locationStep); - // check query rewriters if they want to rewrite the location step - Pragma optimizePragma = null; - for (QueryRewriter rewriter : rewriters) { - try { - optimizePragma = rewriter.rewriteLocationStep(locationStep); - if (optimizePragma != null) { - // expression was rewritten: return - hasOptimized = true; - break; - } - } catch (XPathException e) { - LOG.warn("Exception called while rewriting location step: " + e.getMessage(), e); - } - } - - boolean optimize = false; - // only location steps with predicates can be optimized: - if (locationStep.hasPredicates()) { - final List preds = locationStep.getPredicates(); - // walk through the predicates attached to the current location step. - // try to find a predicate containing an expression which is an instance - // of Optimizable. - for (final Predicate pred : preds) { - final FindOptimizable find = new FindOptimizable(); - pred.accept(find); - final List list = find.getOptimizables(); - if (list.size() > 0 && canOptimize(list)) { - optimize = true; - break; - } - } - } - - final Expression parent = locationStep.getParentExpression(); - - if (optimize) { - // we found at least one Optimizable. Rewrite the whole expression and - // enclose it in an (#exist:optimize#) pragma. - if (!(parent instanceof RewritableExpression)) { - if (LOG.isTraceEnabled()) - {LOG.trace("Parent expression of step is not a PathExpr: " + parent);} - return; - } - hasOptimized = true; - final RewritableExpression path = (RewritableExpression) parent; - try { - // Create the pragma - final ExtensionExpression extension = new ExtensionExpression(context); - if (optimizePragma != null) { - extension.addPragma(optimizePragma); - } - extension.addPragma(new Optimize(context, Optimize.OPTIMIZE_PRAGMA, null, false)); - extension.setExpression(locationStep); - - // Replace the old expression with the pragma - path.replace(locationStep, extension); - - // Check if there are additional steps before the optimizable expression and - // rewrite them to use the ancestor axis. This will change //a/b//c[d = "D"] into - // //c[d = "D"][ancestor::b/parent::a] - int reverseAxis = reverseAxis(locationStep.getAxis()); - Expression previous = path.getPrevious(extension); - if (previous != null && reverseAxis != Constants.UNKNOWN_AXIS) { - final List prevSteps = new ArrayList(); - while (previous != null && previous != path.getFirst() && previous instanceof Step) { - final Step prevStep = (Step) previous; - if (prevStep.getAxis() == Constants.CHILD_AXIS && !(path.getPrevious(prevStep) instanceof LocationStep)) { - // Do not rewrite this step if it is the first step after a root step and - // the axis is the child axis! - break; - } - reverseAxis = reverseAxis(prevStep.getAxis()); - if (reverseAxis != Constants.UNKNOWN_AXIS && !prevStep.hasPredicates() && - !prevStep.getTest().isWildcardTest()) { - prevSteps.add(prevStep); - previous = path.getPrevious(prevStep); - path.remove(prevStep); - } else - {break;} - } - - if (prevSteps.size() > 0) { - reverseAxis = reverseAxis(locationStep.getAxis()); - final Predicate predicate = new Predicate(context); - for (final Step expr : prevSteps) { - final int axis = expr.getAxis(); - expr.setAxis(reverseAxis); - reverseAxis = reverseAxis(axis); - predicate.add(expr); - } - locationStep.setAxis(Constants.DESCENDANT_AXIS); - locationStep.addPredicate(predicate); - } - } - if (LOG.isTraceEnabled()) - {LOG.trace("Rewritten expression: " + ExpressionDumper.dump(parent));} - } catch (final XPathException e) { - LOG.warn("Failed to optimize expression: " + locationStep + ": " + e.getMessage(), e); - } - } else if (optimizePragma != null) { - final ExtensionExpression extension = new ExtensionExpression(context); - extension.addPragma(optimizePragma); - extension.setExpression(locationStep); - - // Replace the old expression with the pragma - final RewritableExpression path = (RewritableExpression) parent; - path.replace(locationStep, extension); - } - } - - public void visitFilteredExpr(FilteredExpression filtered) { - super.visitFilteredExpr(filtered); - boolean optimize = false; - final List preds = filtered.getPredicates(); - // walk through the predicates attached to the current location step. - // try to find a predicate containing an expression which is an instance - // of Optimizable. - for (final Predicate pred : preds) { - final FindOptimizable find = new FindOptimizable(); - pred.accept(find); - final List list = find.getOptimizables(); - if (list.size() > 0 && canOptimize(list)) { - optimize = true; - break; - } - } - if (optimize) { - // we found at least one Optimizable. Rewrite the whole expression and - // enclose it in an (#exist:optimize#) pragma. - final Expression parent = filtered.getParent(); - if (!(parent instanceof RewritableExpression)) { - if (LOG.isTraceEnabled()) - {LOG.trace("Parent expression: " + parent.getClass().getName() + " of step does not implement RewritableExpression");} - return; - } - if (LOG.isTraceEnabled()) - {LOG.trace("Rewriting expression: " + ExpressionDumper.dump(filtered));} - hasOptimized = true; - final RewritableExpression path = (RewritableExpression) parent; - try { - // Create the pragma - final ExtensionExpression extension = new ExtensionExpression(context); - extension.addPragma(new Optimize(context, Optimize.OPTIMIZE_PRAGMA, null, false)); - extension.setExpression(filtered); - // Replace the old expression with the pragma - path.replace(filtered, extension); - } catch (final XPathException e) { - LOG.warn("Failed to optimize expression: " + filtered + ": " + e.getMessage(), e); - } - } - } - - public void visitAndExpr(OpAnd and) { - if (predicates > 0) { - // inside a filter expression, we can often replace a logical and with - // a chain of filters, which can then be further optimized - Expression parent = and.getParent(); - if (!(parent instanceof PathExpr)) { - if (LOG.isTraceEnabled()) - {LOG.trace("Parent expression of boolean operator is not a PathExpr: " + parent);} - return; - } - PathExpr path; - Predicate predicate; - if (parent instanceof Predicate) { - predicate = (Predicate) parent; - path = predicate; - } else { - path = (PathExpr) parent; - parent = path.getParent(); - if (!(parent instanceof Predicate) || path.getLength() > 1) { - LOG.debug("Boolean operator is not a top-level expression in the predicate: " + (parent == null ? "?" : parent.getClass().getName())); - return; - } - predicate = (Predicate) parent; - } - if (LOG.isTraceEnabled()) - {LOG.trace("Rewriting boolean expression: " + ExpressionDumper.dump(and));} - hasOptimized = true; - final LocationStep step = (LocationStep) predicate.getParent(); - final Predicate newPred = new Predicate(context); - newPred.add(simplifyPath(and.getRight())); - step.insertPredicate(predicate, newPred); - path.replace(and, simplifyPath(and.getLeft())); - } else if (and.isRewritable()) { - and.getLeft().accept(this); - and.getRight().accept(this); - } - } - - public void visitOrExpr(OpOr or) { - if (or.isRewritable()) { - or.getLeft().accept(this); - or.getRight().accept(this); - } - } - - @Override - public void visitGeneralComparison(GeneralComparison comparison) { - // Check if the left operand is a path expression ending in a - // text() step. This step is unnecessary and makes it hard - // to further optimize the expression. We thus try to remove - // the extra text() step automatically. - // TODO should insert a pragma instead of removing the step - // we don't know at this point if there's an index to use -// Expression expr = comparison.getLeft(); -// if (expr instanceof PathExpr) { -// PathExpr pathExpr = (PathExpr) expr; -// Expression last = pathExpr.getLastExpression(); -// if (pathExpr.getLength() > 1 && last instanceof Step && ((Step)last).getTest().getType() == Type.TEXT) { -// pathExpr.remove(last); -// } -// } - comparison.getLeft().accept(this); - comparison.getRight().accept(this); - } - - public void visitPredicate(Predicate predicate) { - ++predicates; - super.visitPredicate(predicate); - --predicates; - } - - private boolean canOptimize(List list) { - for (final Optimizable optimizable : list) { - final int axis = optimizable.getOptimizeAxis(); - if (!(axis == Constants.CHILD_AXIS || axis == Constants.DESCENDANT_AXIS || - axis == Constants.DESCENDANT_SELF_AXIS || axis == Constants.ATTRIBUTE_AXIS || - axis == Constants.DESCENDANT_ATTRIBUTE_AXIS || axis == Constants.SELF_AXIS - )) { - return false; - } - } - return true; - } - - private int reverseAxis(int axis) { - switch (axis) { - case Constants.CHILD_AXIS: - return Constants.PARENT_AXIS; - case Constants.DESCENDANT_AXIS: - return Constants.ANCESTOR_AXIS; - case Constants.DESCENDANT_SELF_AXIS: - return Constants.ANCESTOR_SELF_AXIS; - } - return Constants.UNKNOWN_AXIS; - } - - private Expression simplifyPath(Expression expression) { - if (!(expression instanceof PathExpr)) { - return expression; - } - final PathExpr path = (PathExpr) expression; - if (path.getLength() != 1) { - return path; - } - return path.getExpression(0); - } - - /** - * Try to find an expression object implementing interface Optimizable. - */ - public static class FindOptimizable extends BasicExpressionVisitor { - - List optimizables = new ArrayList(); - - public List getOptimizables() { - return optimizables; - } - - public void visitPathExpr(PathExpr expression) { - for (int i = 0; i < expression.getLength(); i++) { - final Expression next = expression.getExpression(i); - next.accept(this); - } - } - - public void visitFtExpression(ExtFulltext fulltext) { - optimizables.add(fulltext); - } - - public void visitGeneralComparison(GeneralComparison comparison) { - optimizables.add(comparison); - } - - public void visitPredicate(Predicate predicate) { - predicate.getExpression(0).accept(this); - } - - public void visitBuiltinFunction(Function function) { - if (function instanceof Optimizable) { - optimizables.add((Optimizable) function); - } - } - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.xquery; + +import org.exist.xquery.pragmas.Optimize; +import org.apache.log4j.Logger; +import org.exist.xquery.functions.fn.ExtFulltext; +import org.exist.xquery.util.ExpressionDumper; + +import java.util.ArrayList; +import java.util.List; + +/** + * Analyzes the query and marks optimizable expressions for the query engine. + * This class just searches for potentially optimizable expressions in the query tree and + * encloses those expressions with an (#exist:optimize#) pragma. The real optimization + * work is not done by this class but by the pragma (see {@link org.exist.xquery.pragmas.Optimize}). + * The pragma may also decide that the optimization is not applicable and just execute + * the expression without any optimization. + * + * Currently, the optimizer is disabled by default. To enable it, set attribute enable-query-rewriting + * to yes in conf.xml: + * + * <xquery enable-java-binding="no" enable-query-rewriting="yes">... + * + * To enable/disable the optimizer for a single query, use an option: + * + *
declare option exist:optimize "enable=yes|no";
+ * + */ +public class Optimizer extends DefaultExpressionVisitor { + + private static final Logger LOG = Logger.getLogger(Optimizer.class); + + private XQueryContext context; + + private int predicates = 0; + + private boolean hasOptimized = false; + + private List rewriters = new ArrayList(5); + + public Optimizer(XQueryContext context) { + this.context = context; + this.rewriters = context.getBroker().getIndexController().getQueryRewriters(context); + } + + public boolean hasOptimized() { + return hasOptimized; + } + + public void visitLocationStep(LocationStep locationStep) { + super.visitLocationStep(locationStep); + // check query rewriters if they want to rewrite the location step + Pragma optimizePragma = null; + for (QueryRewriter rewriter : rewriters) { + try { + optimizePragma = rewriter.rewriteLocationStep(locationStep); + if (optimizePragma != null) { + // expression was rewritten: return + hasOptimized = true; + break; + } + } catch (XPathException e) { + LOG.warn("Exception called while rewriting location step: " + e.getMessage(), e); + } + } + + boolean optimize = false; + // only location steps with predicates can be optimized: + if (locationStep.hasPredicates()) { + final List preds = locationStep.getPredicates(); + // walk through the predicates attached to the current location step. + // try to find a predicate containing an expression which is an instance + // of Optimizable. + for (final Predicate pred : preds) { + final FindOptimizable find = new FindOptimizable(); + pred.accept(find); + final List list = find.getOptimizables(); + if (list.size() > 0 && canOptimize(list)) { + optimize = true; + break; + } + } + } + + final Expression parent = locationStep.getParentExpression(); + + if (optimize) { + // we found at least one Optimizable. Rewrite the whole expression and + // enclose it in an (#exist:optimize#) pragma. + if (!(parent instanceof RewritableExpression)) { + if (LOG.isTraceEnabled()) + {LOG.trace("Parent expression of step is not a PathExpr: " + parent);} + return; + } + hasOptimized = true; + final RewritableExpression path = (RewritableExpression) parent; + try { + // Create the pragma + final ExtensionExpression extension = new ExtensionExpression(context); + if (optimizePragma != null) { + extension.addPragma(optimizePragma); + } + extension.addPragma(new Optimize(context, Optimize.OPTIMIZE_PRAGMA, null, false)); + extension.setExpression(locationStep); + + // Replace the old expression with the pragma + path.replace(locationStep, extension); + + // Check if there are additional steps before the optimizable expression and + // rewrite them to use the ancestor axis. This will change //a/b//c[d = "D"] into + // //c[d = "D"][ancestor::b/parent::a] + int reverseAxis = reverseAxis(locationStep.getAxis()); + Expression previous = path.getPrevious(extension); + if (previous != null && reverseAxis != Constants.UNKNOWN_AXIS) { + final List prevSteps = new ArrayList(); + while (previous != null && previous != path.getFirst() && previous instanceof Step) { + final Step prevStep = (Step) previous; + if (prevStep.getAxis() == Constants.CHILD_AXIS && !(path.getPrevious(prevStep) instanceof LocationStep)) { + // Do not rewrite this step if it is the first step after a root step and + // the axis is the child axis! + break; + } + reverseAxis = reverseAxis(prevStep.getAxis()); + if (reverseAxis != Constants.UNKNOWN_AXIS && !prevStep.hasPredicates() && + !prevStep.getTest().isWildcardTest()) { + prevSteps.add(prevStep); + previous = path.getPrevious(prevStep); + path.remove(prevStep); + } else + {break;} + } + + if (prevSteps.size() > 0) { + reverseAxis = reverseAxis(locationStep.getAxis()); + final Predicate predicate = new Predicate(context); + for (final Step expr : prevSteps) { + final int axis = expr.getAxis(); + expr.setAxis(reverseAxis); + reverseAxis = reverseAxis(axis); + predicate.add(expr); + } + locationStep.setAxis(Constants.DESCENDANT_AXIS); + locationStep.addPredicate(predicate); + } + } + if (LOG.isTraceEnabled()) + {LOG.trace("Rewritten expression: " + ExpressionDumper.dump(parent));} + } catch (final XPathException e) { + LOG.warn("Failed to optimize expression: " + locationStep + ": " + e.getMessage(), e); + } + } else if (optimizePragma != null) { + final ExtensionExpression extension = new ExtensionExpression(context); + extension.addPragma(optimizePragma); + extension.setExpression(locationStep); + + // Replace the old expression with the pragma + final RewritableExpression path = (RewritableExpression) parent; + path.replace(locationStep, extension); + } + } + + public void visitFilteredExpr(FilteredExpression filtered) { + super.visitFilteredExpr(filtered); + boolean optimize = false; + final List preds = filtered.getPredicates(); + // walk through the predicates attached to the current location step. + // try to find a predicate containing an expression which is an instance + // of Optimizable. + for (final Predicate pred : preds) { + final FindOptimizable find = new FindOptimizable(); + pred.accept(find); + final List list = find.getOptimizables(); + if (list.size() > 0 && canOptimize(list)) { + optimize = true; + break; + } + } + if (optimize) { + // we found at least one Optimizable. Rewrite the whole expression and + // enclose it in an (#exist:optimize#) pragma. + final Expression parent = filtered.getParent(); + if (!(parent instanceof RewritableExpression)) { + if (LOG.isTraceEnabled()) + {LOG.trace("Parent expression: " + parent.getClass().getName() + " of step does not implement RewritableExpression");} + return; + } + if (LOG.isTraceEnabled()) + {LOG.trace("Rewriting expression: " + ExpressionDumper.dump(filtered));} + hasOptimized = true; + final RewritableExpression path = (RewritableExpression) parent; + try { + // Create the pragma + final ExtensionExpression extension = new ExtensionExpression(context); + extension.addPragma(new Optimize(context, Optimize.OPTIMIZE_PRAGMA, null, false)); + extension.setExpression(filtered); + // Replace the old expression with the pragma + path.replace(filtered, extension); + } catch (final XPathException e) { + LOG.warn("Failed to optimize expression: " + filtered + ": " + e.getMessage(), e); + } + } + } + + public void visitAndExpr(OpAnd and) { + if (predicates > 0) { + // inside a filter expression, we can often replace a logical and with + // a chain of filters, which can then be further optimized + Expression parent = and.getParent(); + if (!(parent instanceof PathExpr)) { + if (LOG.isTraceEnabled()) + {LOG.trace("Parent expression of boolean operator is not a PathExpr: " + parent);} + return; + } + PathExpr path; + Predicate predicate; + if (parent instanceof Predicate) { + predicate = (Predicate) parent; + path = predicate; + } else { + path = (PathExpr) parent; + parent = path.getParent(); + if (!(parent instanceof Predicate) || path.getLength() > 1) { + LOG.debug("Boolean operator is not a top-level expression in the predicate: " + (parent == null ? "?" : parent.getClass().getName())); + return; + } + predicate = (Predicate) parent; + } + if (LOG.isTraceEnabled()) + {LOG.trace("Rewriting boolean expression: " + ExpressionDumper.dump(and));} + hasOptimized = true; + final LocationStep step = (LocationStep) predicate.getParent(); + final Predicate newPred = new Predicate(context); + newPred.add(simplifyPath(and.getRight())); + step.insertPredicate(predicate, newPred); + path.replace(and, simplifyPath(and.getLeft())); + } else if (and.isRewritable()) { + and.getLeft().accept(this); + and.getRight().accept(this); + } + } + + public void visitOrExpr(OpOr or) { + if (or.isRewritable()) { + or.getLeft().accept(this); + or.getRight().accept(this); + } + } + + @Override + public void visitGeneralComparison(GeneralComparison comparison) { + // Check if the left operand is a path expression ending in a + // text() step. This step is unnecessary and makes it hard + // to further optimize the expression. We thus try to remove + // the extra text() step automatically. + // TODO should insert a pragma instead of removing the step + // we don't know at this point if there's an index to use +// Expression expr = comparison.getLeft(); +// if (expr instanceof PathExpr) { +// PathExpr pathExpr = (PathExpr) expr; +// Expression last = pathExpr.getLastExpression(); +// if (pathExpr.getLength() > 1 && last instanceof Step && ((Step)last).getTest().getType() == Type.TEXT) { +// pathExpr.remove(last); +// } +// } + comparison.getLeft().accept(this); + comparison.getRight().accept(this); + } + + public void visitPredicate(Predicate predicate) { + ++predicates; + super.visitPredicate(predicate); + --predicates; + } + + private boolean canOptimize(List list) { + for (final Optimizable optimizable : list) { + final int axis = optimizable.getOptimizeAxis(); + if (!(axis == Constants.CHILD_AXIS || axis == Constants.DESCENDANT_AXIS || + axis == Constants.DESCENDANT_SELF_AXIS || axis == Constants.ATTRIBUTE_AXIS || + axis == Constants.DESCENDANT_ATTRIBUTE_AXIS || axis == Constants.SELF_AXIS + )) { + return false; + } + } + return true; + } + + private int reverseAxis(int axis) { + switch (axis) { + case Constants.CHILD_AXIS: + return Constants.PARENT_AXIS; + case Constants.DESCENDANT_AXIS: + return Constants.ANCESTOR_AXIS; + case Constants.DESCENDANT_SELF_AXIS: + return Constants.ANCESTOR_SELF_AXIS; + } + return Constants.UNKNOWN_AXIS; + } + + private Expression simplifyPath(Expression expression) { + if (!(expression instanceof PathExpr)) { + return expression; + } + final PathExpr path = (PathExpr) expression; + if (path.getLength() != 1) { + return path; + } + return path.getExpression(0); + } + + /** + * Try to find an expression object implementing interface Optimizable. + */ + public static class FindOptimizable extends BasicExpressionVisitor { + + List optimizables = new ArrayList(); + + public List getOptimizables() { + return optimizables; + } + + public void visitPathExpr(PathExpr expression) { + for (int i = 0; i < expression.getLength(); i++) { + final Expression next = expression.getExpression(i); + next.accept(this); + } + } + + public void visitFtExpression(ExtFulltext fulltext) { + optimizables.add(fulltext); + } + + public void visitGeneralComparison(GeneralComparison comparison) { + optimizables.add(comparison); + } + + public void visitPredicate(Predicate predicate) { + predicate.getExpression(0).accept(this); + } + + public void visitBuiltinFunction(Function function) { + if (function instanceof Optimizable) { + optimizables.add((Optimizable) function); + } + } + } +} diff --git a/src/org/exist/xquery/functions/fn/FnFormatNumbers.java b/src/org/exist/xquery/functions/fn/FnFormatNumbers.java index 20d62ac5403..2fb2aeab672 100644 --- a/src/org/exist/xquery/functions/fn/FnFormatNumbers.java +++ b/src/org/exist/xquery/functions/fn/FnFormatNumbers.java @@ -1,408 +1,408 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2012 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.xquery.functions.fn; - -import org.exist.dom.QName; -import org.exist.xquery.*; -import org.exist.xquery.value.*; - -import java.lang.String; -import java.math.BigDecimal; - -/** - * fn:format-number($value as numeric?, $picture as xs:string) as xs:string - * fn:format-number($value as numeric?, $picture as xs:string, $decimal-format-name as xs:string) as xs:string - * - * @author Dmitriy Shabanov - * - */ -public class FnFormatNumbers extends BasicFunction { - - private static final SequenceType NUMBER_PARAMETER = new FunctionParameterSequenceType("value", Type.NUMBER, Cardinality.ZERO_OR_ONE, "The number to format"); - - private static final SequenceType PICTURE = new FunctionParameterSequenceType("picture", Type.STRING, Cardinality.EXACTLY_ONE, "The format pattern string. Please see the JavaDoc for java.text.DecimalFormat to get the specifics of this format string."); - private static final String PICTURE_DESCRIPTION = "The formatting of a number is controlled by a picture string. The picture string is a sequence of ·characters·, in which the characters assigned to the variables decimal-separator-sign, grouping-sign, decimal-digit-family, optional-digit-sign and pattern-separator-sign are classified as active characters, and all other characters (including the percent-sign and per-mille-sign) are classified as passive characters."; - - private static final SequenceType DECIMAL_FORMAT = new FunctionParameterSequenceType("decimal-format-name", Type.STRING, Cardinality.EXACTLY_ONE, "The decimal-format name must be a QName, which is expanded as described in [2.4 Qualified Names]. It is an error if the stylesheet does not contain a declaration of the decimal-format with the specified expanded-name."); - private static final String DECIMAL_FORMAT_DESCRIPTION = ""; - - private static final FunctionReturnSequenceType FUNCTION_RETURN_TYPE = new FunctionReturnSequenceType(Type.STRING, Cardinality.ONE, "the formatted string"); - - public final static FunctionSignature signatures[] = { - new FunctionSignature( - new QName("format-number", Function.BUILTIN_FUNCTION_NS, FnModule.PREFIX), - PICTURE_DESCRIPTION, - new SequenceType[] {NUMBER_PARAMETER, PICTURE}, - FUNCTION_RETURN_TYPE - ), - new FunctionSignature( - new QName("format-number", Function.BUILTIN_FUNCTION_NS, FnModule.PREFIX), - DECIMAL_FORMAT_DESCRIPTION, - new SequenceType[] {NUMBER_PARAMETER, PICTURE, DECIMAL_FORMAT}, - FUNCTION_RETURN_TYPE - ) - }; - - /** - * @param context - */ - public FnFormatNumbers(XQueryContext context, FunctionSignature signature) { - super(context, signature); - } - - @Override - public Sequence eval(Sequence[] args, Sequence contextSequence) - throws XPathException { - - if (args[0].isEmpty()) { - return Sequence.EMPTY_SEQUENCE; - } - - final NumericValue numericValue = (NumericValue)args[0].itemAt(0); - - try { - final Formatter[] formatters = prepare(args[1].getStringValue()); - final String value = format(formatters[0], numericValue); - return new StringValue(value); - } catch (final java.lang.IllegalArgumentException e) { - e.printStackTrace(); - throw new XPathException(e.getMessage()); - } - } - - private String format(Formatter f, NumericValue numericValue) throws XPathException { - if (numericValue.isNaN()) { - return NaN; - } - - final String minuSign = numericValue.isNegative()? String.valueOf(MINUS_SIGN) : ""; - if (numericValue.isInfinite()) { - return minuSign + f.prefix + INFINITY + f.suffix; - } - - NumericValue factor = null; - if (f.isPercent) { - factor = new IntegerValue(100); - } else if (f.isPerMille) { - factor = new IntegerValue(1000); - } - - if (factor != null) { - try { - numericValue = (NumericValue) numericValue.mult(factor); - } catch (final XPathException e) { - e.printStackTrace(); - throw e; - } - } - - int pl = 0; - - final StringBuilder sb = new StringBuilder(); - - if (numericValue.hasFractionalPart()) { - - BigDecimal val = ((DecimalValue)numericValue.convertTo(Type.DECIMAL)).getValue(); - - val = val.setScale(f.flMAX, BigDecimal.ROUND_HALF_EVEN); - - final String number = val.toPlainString(); - - sb.append(number); - - pl = number.indexOf('.'); - if (pl < 0) { - sb.append('.'); - for (int i = 0; i < f.flMIN; i++) { - sb.append('0'); - } - } else { - - } - - } else { - final String str = numericValue.getStringValue(); - pl = str.length(); - formatInt(str, sb, f); - } - - if (f.mg != 0) { - int pos = pl - f.mg; - while (pos > 0) { - sb.insert(pos, ','); - pos -= f.mg; - } - } - - return sb.toString(); - } - - private void formatInt(String number, StringBuilder sb, Formatter f) { - final int leadingZ = f.mlMIN - number.length(); - for (int i = 0; i < leadingZ; i++) { - sb.append('0'); - } - sb.append(number); - if (f.flMIN > 0) { - sb.append("."); - for (int i = 0; i < f.mlMIN; i++) { - sb.append('0'); - } - } - } - - private final char DECIMAL_SEPARATOR_SIGN = '.'; - private final char GROUPING_SEPARATOR_SIGN = ','; - private final String INFINITY = "Infinity"; - private final char MINUS_SIGN = '-'; - private final String NaN = "NaN"; - private final char PERCENT_SIGN = '%'; - private final char PER_MILLE_SIGN = '\u2030'; - private final char MANDATORY_DIGIT_SIGN = '0'; - private final char OPTIONAL_DIGIT_SIGN = '#'; - private final char PATTERN_SEPARATOR_SIGN = ';'; - - private Formatter[] prepare(String picture) throws XPathException { - if (picture.length() == 0) - {throw new XPathException(this, ErrorCodes.XTDE1310, "format-number() picture is zero-length");} - - final String[] pics = picture.split(String.valueOf(PATTERN_SEPARATOR_SIGN)); - - final Formatter[] formatters = new Formatter[2]; - for (int i = 0; i < pics.length; i++) { - formatters[i] = new Formatter(pics[i]); - } - - return formatters; - } - - class Formatter { - - String prefix = "", suffix = ""; - - boolean ds = false, isPercent = false, isPerMille = false; - int mlMAX = 0, flMAX = 0; - int mlMIN = 0, flMIN = 0; - - int mg = 0, fg = 0; - - public Formatter(String picture) throws XPathException { - if ( ! ( - picture.contains(String.valueOf(OPTIONAL_DIGIT_SIGN)) - || picture.contains(String.valueOf(MANDATORY_DIGIT_SIGN)) - ) - ) { - - throw new XPathException(FnFormatNumbers.this, ErrorCodes.XTDE1310, - "A sub-picture must contain at least one character that is an optional-digit-sign or a member of the decimal-digit-family."); - } - - int bmg = -1, bfg = -1; - - // 0 - beginning passive-chars - // 1 - digit signs - // 2 - zero signs - // 3 - fractional zero signs - // 4 - fractional digit signs - // 5 - ending passive-chars - short phase = 0; - - for (int i = 0; i < picture.length(); i++) { - char ch = picture.charAt(i); - - switch (ch) { - case OPTIONAL_DIGIT_SIGN: - - switch (phase) { - case 0: - case 1: - mlMAX++; - phase = 1; - break; - - case 2: - throw new XPathException(FnFormatNumbers.this, ErrorCodes.XTDE1310, - ""); - - case 3: - case 4: - flMAX++; - phase = 4; - break; - - case 5: - throw new XPathException(FnFormatNumbers.this, ErrorCodes.XTDE1310, - "A sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character. " + - "Found at optional-digit-sign."); - } - - break; - - case MANDATORY_DIGIT_SIGN: - - switch (phase) { - case 0: - case 1: - case 2: - mlMIN++; - mlMAX++; - phase = 2; - break; - - case 3: - flMIN++; - flMAX++; - break; - - case 4: - throw new XPathException(FnFormatNumbers.this, ErrorCodes.XTDE1310, - ""); - - case 5: - throw new XPathException(FnFormatNumbers.this, ErrorCodes.XTDE1310, - "A sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character. " + - "Found at mandatory-digit-sign."); - } - - break; - - case GROUPING_SEPARATOR_SIGN: - - switch (phase) { - case 0: - case 1: - case 2: - if (bmg == -1) { - bmg = i; - } else { - mg = i - bmg; - bmg = -1; - } - break; - - case 3: - case 4: - if (bfg == -1) { - bfg = i; - } else { - fg = i - bfg; - bfg = -1; - } - break; - case 5: - throw new XPathException(FnFormatNumbers.this, ErrorCodes.XTDE1310, - "A sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character. " + - "Found at grouping-separator-sign."); - } - - break; - - case DECIMAL_SEPARATOR_SIGN: - - switch (phase) { - case 0: - case 1: - case 2: - if (bmg != -1) { - mg = i - bmg - 1; - bmg = -1; - } - ds = true; - phase = 3; - break; - - case 3: - case 4: - case 5: - if (ds) - {throw new XPathException(FnFormatNumbers.this, ErrorCodes.XTDE1310, - "A sub-picture must not contain more than one decimal-separator-sign.");} - - throw new XPathException(FnFormatNumbers.this, ErrorCodes.XTDE1310, - "A sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character. " + - "Found at decimal-separator-sign."); - } - - break; - - case PERCENT_SIGN: - case PER_MILLE_SIGN: - if (isPercent || isPerMille) - {throw new XPathException(FnFormatNumbers.this, ErrorCodes.XTDE1310, - "A sub-picture must not contain more than one percent-sign or per-mille-sign, and it must not contain one of each.");} - - isPercent = ch == PERCENT_SIGN; - isPerMille = ch == PER_MILLE_SIGN; - - switch (phase) { - case 0: - prefix += ch; - break; - case 1: - case 2: - case 3: - case 4: - case 5: - phase = 5; - suffix += ch; - break; - } - - break; - - default: - //passive chars - switch (phase) { - case 0: - prefix += ch; - break; - case 1: - case 2: - case 3: - case 4: - case 5: - if (bmg != -1) { - mg = i - bmg - 1; - bmg = -1; - } - suffix += ch; - phase = 5; - break; - } - break; - } - } - - if (mlMIN == 0 && !ds) {mlMIN = 1;} - -// System.out.println("prefix = "+prefix); -// System.out.println("suffix = "+suffix); -// System.out.println("ds = "+ds); -// System.out.println("isPercent = "+isPercent); -// System.out.println("isPerMille = "+isPerMille); -// System.out.println("ml = "+mlMAX); -// System.out.println("fl = "+flMAX); -// System.out.println("mg = "+mg); -// System.out.println("fg = "+fg); - } - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2012 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.xquery.functions.fn; + +import org.exist.dom.QName; +import org.exist.xquery.*; +import org.exist.xquery.value.*; + +import java.lang.String; +import java.math.BigDecimal; + +/** + * fn:format-number($value as numeric?, $picture as xs:string) as xs:string + * fn:format-number($value as numeric?, $picture as xs:string, $decimal-format-name as xs:string) as xs:string + * + * @author Dmitriy Shabanov + * + */ +public class FnFormatNumbers extends BasicFunction { + + private static final SequenceType NUMBER_PARAMETER = new FunctionParameterSequenceType("value", Type.NUMBER, Cardinality.ZERO_OR_ONE, "The number to format"); + + private static final SequenceType PICTURE = new FunctionParameterSequenceType("picture", Type.STRING, Cardinality.EXACTLY_ONE, "The format pattern string. Please see the JavaDoc for java.text.DecimalFormat to get the specifics of this format string."); + private static final String PICTURE_DESCRIPTION = "The formatting of a number is controlled by a picture string. The picture string is a sequence of ·characters·, in which the characters assigned to the variables decimal-separator-sign, grouping-sign, decimal-digit-family, optional-digit-sign and pattern-separator-sign are classified as active characters, and all other characters (including the percent-sign and per-mille-sign) are classified as passive characters."; + + private static final SequenceType DECIMAL_FORMAT = new FunctionParameterSequenceType("decimal-format-name", Type.STRING, Cardinality.EXACTLY_ONE, "The decimal-format name must be a QName, which is expanded as described in [2.4 Qualified Names]. It is an error if the stylesheet does not contain a declaration of the decimal-format with the specified expanded-name."); + private static final String DECIMAL_FORMAT_DESCRIPTION = ""; + + private static final FunctionReturnSequenceType FUNCTION_RETURN_TYPE = new FunctionReturnSequenceType(Type.STRING, Cardinality.ONE, "the formatted string"); + + public final static FunctionSignature signatures[] = { + new FunctionSignature( + new QName("format-number", Function.BUILTIN_FUNCTION_NS, FnModule.PREFIX), + PICTURE_DESCRIPTION, + new SequenceType[] {NUMBER_PARAMETER, PICTURE}, + FUNCTION_RETURN_TYPE + ), + new FunctionSignature( + new QName("format-number", Function.BUILTIN_FUNCTION_NS, FnModule.PREFIX), + DECIMAL_FORMAT_DESCRIPTION, + new SequenceType[] {NUMBER_PARAMETER, PICTURE, DECIMAL_FORMAT}, + FUNCTION_RETURN_TYPE + ) + }; + + /** + * @param context + */ + public FnFormatNumbers(XQueryContext context, FunctionSignature signature) { + super(context, signature); + } + + @Override + public Sequence eval(Sequence[] args, Sequence contextSequence) + throws XPathException { + + if (args[0].isEmpty()) { + return Sequence.EMPTY_SEQUENCE; + } + + final NumericValue numericValue = (NumericValue)args[0].itemAt(0); + + try { + final Formatter[] formatters = prepare(args[1].getStringValue()); + final String value = format(formatters[0], numericValue); + return new StringValue(value); + } catch (final java.lang.IllegalArgumentException e) { + e.printStackTrace(); + throw new XPathException(e.getMessage()); + } + } + + private String format(Formatter f, NumericValue numericValue) throws XPathException { + if (numericValue.isNaN()) { + return NaN; + } + + final String minuSign = numericValue.isNegative()? String.valueOf(MINUS_SIGN) : ""; + if (numericValue.isInfinite()) { + return minuSign + f.prefix + INFINITY + f.suffix; + } + + NumericValue factor = null; + if (f.isPercent) { + factor = new IntegerValue(100); + } else if (f.isPerMille) { + factor = new IntegerValue(1000); + } + + if (factor != null) { + try { + numericValue = (NumericValue) numericValue.mult(factor); + } catch (final XPathException e) { + e.printStackTrace(); + throw e; + } + } + + int pl = 0; + + final StringBuilder sb = new StringBuilder(); + + if (numericValue.hasFractionalPart()) { + + BigDecimal val = ((DecimalValue)numericValue.convertTo(Type.DECIMAL)).getValue(); + + val = val.setScale(f.flMAX, BigDecimal.ROUND_HALF_EVEN); + + final String number = val.toPlainString(); + + sb.append(number); + + pl = number.indexOf('.'); + if (pl < 0) { + sb.append('.'); + for (int i = 0; i < f.flMIN; i++) { + sb.append('0'); + } + } else { + + } + + } else { + final String str = numericValue.getStringValue(); + pl = str.length(); + formatInt(str, sb, f); + } + + if (f.mg != 0) { + int pos = pl - f.mg; + while (pos > 0) { + sb.insert(pos, ','); + pos -= f.mg; + } + } + + return sb.toString(); + } + + private void formatInt(String number, StringBuilder sb, Formatter f) { + final int leadingZ = f.mlMIN - number.length(); + for (int i = 0; i < leadingZ; i++) { + sb.append('0'); + } + sb.append(number); + if (f.flMIN > 0) { + sb.append("."); + for (int i = 0; i < f.mlMIN; i++) { + sb.append('0'); + } + } + } + + private final char DECIMAL_SEPARATOR_SIGN = '.'; + private final char GROUPING_SEPARATOR_SIGN = ','; + private final String INFINITY = "Infinity"; + private final char MINUS_SIGN = '-'; + private final String NaN = "NaN"; + private final char PERCENT_SIGN = '%'; + private final char PER_MILLE_SIGN = '\u2030'; + private final char MANDATORY_DIGIT_SIGN = '0'; + private final char OPTIONAL_DIGIT_SIGN = '#'; + private final char PATTERN_SEPARATOR_SIGN = ';'; + + private Formatter[] prepare(String picture) throws XPathException { + if (picture.length() == 0) + {throw new XPathException(this, ErrorCodes.XTDE1310, "format-number() picture is zero-length");} + + final String[] pics = picture.split(String.valueOf(PATTERN_SEPARATOR_SIGN)); + + final Formatter[] formatters = new Formatter[2]; + for (int i = 0; i < pics.length; i++) { + formatters[i] = new Formatter(pics[i]); + } + + return formatters; + } + + class Formatter { + + String prefix = "", suffix = ""; + + boolean ds = false, isPercent = false, isPerMille = false; + int mlMAX = 0, flMAX = 0; + int mlMIN = 0, flMIN = 0; + + int mg = 0, fg = 0; + + public Formatter(String picture) throws XPathException { + if ( ! ( + picture.contains(String.valueOf(OPTIONAL_DIGIT_SIGN)) + || picture.contains(String.valueOf(MANDATORY_DIGIT_SIGN)) + ) + ) { + + throw new XPathException(FnFormatNumbers.this, ErrorCodes.XTDE1310, + "A sub-picture must contain at least one character that is an optional-digit-sign or a member of the decimal-digit-family."); + } + + int bmg = -1, bfg = -1; + + // 0 - beginning passive-chars + // 1 - digit signs + // 2 - zero signs + // 3 - fractional zero signs + // 4 - fractional digit signs + // 5 - ending passive-chars + short phase = 0; + + for (int i = 0; i < picture.length(); i++) { + char ch = picture.charAt(i); + + switch (ch) { + case OPTIONAL_DIGIT_SIGN: + + switch (phase) { + case 0: + case 1: + mlMAX++; + phase = 1; + break; + + case 2: + throw new XPathException(FnFormatNumbers.this, ErrorCodes.XTDE1310, + ""); + + case 3: + case 4: + flMAX++; + phase = 4; + break; + + case 5: + throw new XPathException(FnFormatNumbers.this, ErrorCodes.XTDE1310, + "A sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character. " + + "Found at optional-digit-sign."); + } + + break; + + case MANDATORY_DIGIT_SIGN: + + switch (phase) { + case 0: + case 1: + case 2: + mlMIN++; + mlMAX++; + phase = 2; + break; + + case 3: + flMIN++; + flMAX++; + break; + + case 4: + throw new XPathException(FnFormatNumbers.this, ErrorCodes.XTDE1310, + ""); + + case 5: + throw new XPathException(FnFormatNumbers.this, ErrorCodes.XTDE1310, + "A sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character. " + + "Found at mandatory-digit-sign."); + } + + break; + + case GROUPING_SEPARATOR_SIGN: + + switch (phase) { + case 0: + case 1: + case 2: + if (bmg == -1) { + bmg = i; + } else { + mg = i - bmg; + bmg = -1; + } + break; + + case 3: + case 4: + if (bfg == -1) { + bfg = i; + } else { + fg = i - bfg; + bfg = -1; + } + break; + case 5: + throw new XPathException(FnFormatNumbers.this, ErrorCodes.XTDE1310, + "A sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character. " + + "Found at grouping-separator-sign."); + } + + break; + + case DECIMAL_SEPARATOR_SIGN: + + switch (phase) { + case 0: + case 1: + case 2: + if (bmg != -1) { + mg = i - bmg - 1; + bmg = -1; + } + ds = true; + phase = 3; + break; + + case 3: + case 4: + case 5: + if (ds) + {throw new XPathException(FnFormatNumbers.this, ErrorCodes.XTDE1310, + "A sub-picture must not contain more than one decimal-separator-sign.");} + + throw new XPathException(FnFormatNumbers.this, ErrorCodes.XTDE1310, + "A sub-picture must not contain a passive character that is preceded by an active character and that is followed by another active character. " + + "Found at decimal-separator-sign."); + } + + break; + + case PERCENT_SIGN: + case PER_MILLE_SIGN: + if (isPercent || isPerMille) + {throw new XPathException(FnFormatNumbers.this, ErrorCodes.XTDE1310, + "A sub-picture must not contain more than one percent-sign or per-mille-sign, and it must not contain one of each.");} + + isPercent = ch == PERCENT_SIGN; + isPerMille = ch == PER_MILLE_SIGN; + + switch (phase) { + case 0: + prefix += ch; + break; + case 1: + case 2: + case 3: + case 4: + case 5: + phase = 5; + suffix += ch; + break; + } + + break; + + default: + //passive chars + switch (phase) { + case 0: + prefix += ch; + break; + case 1: + case 2: + case 3: + case 4: + case 5: + if (bmg != -1) { + mg = i - bmg - 1; + bmg = -1; + } + suffix += ch; + phase = 5; + break; + } + break; + } + } + + if (mlMIN == 0 && !ds) {mlMIN = 1;} + +// System.out.println("prefix = "+prefix); +// System.out.println("suffix = "+suffix); +// System.out.println("ds = "+ds); +// System.out.println("isPercent = "+isPercent); +// System.out.println("isPerMille = "+isPerMille); +// System.out.println("ml = "+mlMAX); +// System.out.println("fl = "+flMAX); +// System.out.println("mg = "+mg); +// System.out.println("fg = "+fg); + } + } +} diff --git a/src/org/exist/xquery/functions/fn/FunCodepointEqual.java b/src/org/exist/xquery/functions/fn/FunCodepointEqual.java index 19b315b8691..8fe567f159b 100644 --- a/src/org/exist/xquery/functions/fn/FunCodepointEqual.java +++ b/src/org/exist/xquery/functions/fn/FunCodepointEqual.java @@ -1,93 +1,93 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2006-2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ -package org.exist.xquery.functions.fn; - -import org.exist.dom.QName; -import org.exist.util.Collations; -import org.exist.xquery.BasicFunction; -import org.exist.xquery.Cardinality; -import org.exist.xquery.Constants; -import org.exist.xquery.Dependency; -import org.exist.xquery.Function; -import org.exist.xquery.FunctionSignature; -import org.exist.xquery.Profiler; -import org.exist.xquery.XPathException; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.value.BooleanValue; -import org.exist.xquery.value.FunctionReturnSequenceType; -import org.exist.xquery.value.FunctionParameterSequenceType; -import org.exist.xquery.value.Sequence; -import org.exist.xquery.value.SequenceType; -import org.exist.xquery.value.Type; - -/** - * - * @author perig - * - */ -public class FunCodepointEqual extends BasicFunction { - - public final static FunctionSignature signature = - new FunctionSignature( - new QName("codepoint-equal", Function.BUILTIN_FUNCTION_NS, FnModule.PREFIX), - "Returns true or false depending on whether the value of $string-1 " + - "is equal to the value of $string-2, according to the Unicode " + - "code point collation.", - new SequenceType[] { - new FunctionParameterSequenceType("string-1", Type.STRING, - Cardinality.ZERO_OR_ONE, "The first string"), - new FunctionParameterSequenceType("string-2", Type.STRING, - Cardinality.ZERO_OR_ONE, "The second string"), - }, - new FunctionReturnSequenceType(Type.BOOLEAN, Cardinality.ZERO_OR_ONE, - "true() if the codepoints are equal, false() otherwise")); - - public FunCodepointEqual(XQueryContext context) { - super(context, signature); - } - - public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { - if (context.getProfiler().isEnabled()) { - context.getProfiler().start(this); - context.getProfiler().message(this, Profiler.DEPENDENCIES, - "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies())); - if (contextSequence != null) - {context.getProfiler().message(this, Profiler.START_SEQUENCES, - "CONTEXT SEQUENCE", contextSequence);} - } - Sequence result; - if (args[0].isEmpty()) - {result = Sequence.EMPTY_SEQUENCE;} - else if (args[1].isEmpty()) - {result = Sequence.EMPTY_SEQUENCE;} - else { - result = new BooleanValue(Collations.compare( - //TODO : how ugly ! We should be able to use Collations.CODEPOINT here ! -pb - context.getDefaultCollator(), - getArgument(0).eval(contextSequence).getStringValue(), - getArgument(1).eval(contextSequence).getStringValue()) - == Constants.EQUAL); - } - if (context.getProfiler().isEnabled()) - {context.getProfiler().end(this, "", result);} - return result; - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2006-2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +package org.exist.xquery.functions.fn; + +import org.exist.dom.QName; +import org.exist.util.Collations; +import org.exist.xquery.BasicFunction; +import org.exist.xquery.Cardinality; +import org.exist.xquery.Constants; +import org.exist.xquery.Dependency; +import org.exist.xquery.Function; +import org.exist.xquery.FunctionSignature; +import org.exist.xquery.Profiler; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.value.BooleanValue; +import org.exist.xquery.value.FunctionReturnSequenceType; +import org.exist.xquery.value.FunctionParameterSequenceType; +import org.exist.xquery.value.Sequence; +import org.exist.xquery.value.SequenceType; +import org.exist.xquery.value.Type; + +/** + * + * @author perig + * + */ +public class FunCodepointEqual extends BasicFunction { + + public final static FunctionSignature signature = + new FunctionSignature( + new QName("codepoint-equal", Function.BUILTIN_FUNCTION_NS, FnModule.PREFIX), + "Returns true or false depending on whether the value of $string-1 " + + "is equal to the value of $string-2, according to the Unicode " + + "code point collation.", + new SequenceType[] { + new FunctionParameterSequenceType("string-1", Type.STRING, + Cardinality.ZERO_OR_ONE, "The first string"), + new FunctionParameterSequenceType("string-2", Type.STRING, + Cardinality.ZERO_OR_ONE, "The second string"), + }, + new FunctionReturnSequenceType(Type.BOOLEAN, Cardinality.ZERO_OR_ONE, + "true() if the codepoints are equal, false() otherwise")); + + public FunCodepointEqual(XQueryContext context) { + super(context, signature); + } + + public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { + if (context.getProfiler().isEnabled()) { + context.getProfiler().start(this); + context.getProfiler().message(this, Profiler.DEPENDENCIES, + "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies())); + if (contextSequence != null) + {context.getProfiler().message(this, Profiler.START_SEQUENCES, + "CONTEXT SEQUENCE", contextSequence);} + } + Sequence result; + if (args[0].isEmpty()) + {result = Sequence.EMPTY_SEQUENCE;} + else if (args[1].isEmpty()) + {result = Sequence.EMPTY_SEQUENCE;} + else { + result = new BooleanValue(Collations.compare( + //TODO : how ugly ! We should be able to use Collations.CODEPOINT here ! -pb + context.getDefaultCollator(), + getArgument(0).eval(contextSequence).getStringValue(), + getArgument(1).eval(contextSequence).getStringValue()) + == Constants.EQUAL); + } + if (context.getProfiler().isEnabled()) + {context.getProfiler().end(this, "", result);} + return result; + } +} diff --git a/src/org/exist/xquery/functions/fn/FunDateTime.java b/src/org/exist/xquery/functions/fn/FunDateTime.java index e5b2303e8d5..6bb8bea239c 100644 --- a/src/org/exist/xquery/functions/fn/FunDateTime.java +++ b/src/org/exist/xquery/functions/fn/FunDateTime.java @@ -1,137 +1,137 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2007-2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ -package org.exist.xquery.functions.fn; - -import org.exist.dom.QName; -import org.exist.xquery.BasicFunction; -import org.exist.xquery.Cardinality; -import org.exist.xquery.Constants; -import org.exist.xquery.Dependency; -import org.exist.xquery.ErrorCodes; -import org.exist.xquery.Function; -import org.exist.xquery.FunctionSignature; -import org.exist.xquery.Profiler; -import org.exist.xquery.XPathException; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.value.DateTimeValue; -import org.exist.xquery.value.DateValue; -import org.exist.xquery.value.DayTimeDurationValue; -import org.exist.xquery.value.FunctionReturnSequenceType; -import org.exist.xquery.value.FunctionParameterSequenceType; -import org.exist.xquery.value.Sequence; -import org.exist.xquery.value.SequenceType; -import org.exist.xquery.value.TimeValue; -import org.exist.xquery.value.Type; -import org.exist.xquery.value.ValueSequence; - -/** - * - * @author perig - * - */ -public class FunDateTime extends BasicFunction { - - public final static FunctionSignature signature = - new FunctionSignature( - new QName("dateTime", Function.BUILTIN_FUNCTION_NS, FnModule.PREFIX), - "Creates an xs:dateTime from an xs:date, $date, and an xs:time, $time.", - new SequenceType[] { - new FunctionParameterSequenceType("date", Type.DATE, - Cardinality.ZERO_OR_ONE, "The date as xs:date"), - new FunctionParameterSequenceType("time", Type.TIME, - Cardinality.ZERO_OR_ONE, "The time as xs:time") - }, - new FunctionReturnSequenceType(Type.DATE_TIME, - Cardinality.ZERO_OR_ONE, "the combined date and time as xs:dateTime") - ); - - public FunDateTime(XQueryContext context) { - super(context, signature); - } - - public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { - if (context.getProfiler().isEnabled()) { - context.getProfiler().start(this); - context.getProfiler().message(this, Profiler.DEPENDENCIES, - "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies())); - if (contextSequence != null) - {context.getProfiler().message(this, Profiler.START_SEQUENCES, - "CONTEXT SEQUENCE", contextSequence);} - } - Sequence result; - if (args[0].isEmpty() || args[1].isEmpty()) { - result = Sequence.EMPTY_SEQUENCE; - } else if (args[0].hasMany()) { - throw new XPathException(this, ErrorCodes.XPTY0004, - "Expected at most one xs:date", args[0]); - } else if (args[1].hasMany()) { - throw new XPathException(this, ErrorCodes.XPTY0004, - "Expected at most one xs:time", args[1]); - } else { - final DateValue dv = (DateValue)args[0].itemAt(0); - final TimeValue tv = (TimeValue)args[1].itemAt(0); - if (!dv.getTimezone().isEmpty()) { - if (!tv.getTimezone().isEmpty()) { - if (!((DayTimeDurationValue)dv.getTimezone().itemAt(0)) - .compareTo(null, Constants.EQ, - ((DayTimeDurationValue)tv.getTimezone().itemAt(0)))) { - - final ValueSequence argsSeq = new ValueSequence(); - argsSeq.add(dv); - argsSeq.add(tv); - - throw new XPathException(this, ErrorCodes.FORG0008, - "Operands have different timezones", argsSeq); - } - } - } - String dtv = ((DateTimeValue)dv.convertTo(Type.DATE_TIME)).getTrimmedCalendar().toXMLFormat(); - - if (dv.getTimezone().isEmpty()) { - dtv = dtv.substring(0, dtv.length() - 8); - result = new DateTimeValue(dtv + tv.getStringValue()); - - } else if ("PT0S".equals(((DayTimeDurationValue)dv.getTimezone().itemAt(0)).getStringValue())) { - dtv = dtv.substring(0, dtv.length() - 9); - if (tv.getTimezone().isEmpty()) { - result = new DateTimeValue(dtv + tv.getStringValue() + "Z"); - } else { - result = new DateTimeValue(dtv + tv.getStringValue()); - } - - } else { - if (tv.getTimezone().isEmpty()) { - final String tz = dtv.substring(19); - dtv = dtv.substring(0, dtv.length() - 14); - result = new DateTimeValue(dtv + tv.getStringValue() + tz); - - } else { - dtv = dtv.substring(0, dtv.length() - 14); - result = new DateTimeValue(dtv + tv.getStringValue()); - } - } - } - if (context.getProfiler().isEnabled()) - {context.getProfiler().end(this, "", result);} - return result; - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2007-2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id$ + */ +package org.exist.xquery.functions.fn; + +import org.exist.dom.QName; +import org.exist.xquery.BasicFunction; +import org.exist.xquery.Cardinality; +import org.exist.xquery.Constants; +import org.exist.xquery.Dependency; +import org.exist.xquery.ErrorCodes; +import org.exist.xquery.Function; +import org.exist.xquery.FunctionSignature; +import org.exist.xquery.Profiler; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.value.DateTimeValue; +import org.exist.xquery.value.DateValue; +import org.exist.xquery.value.DayTimeDurationValue; +import org.exist.xquery.value.FunctionReturnSequenceType; +import org.exist.xquery.value.FunctionParameterSequenceType; +import org.exist.xquery.value.Sequence; +import org.exist.xquery.value.SequenceType; +import org.exist.xquery.value.TimeValue; +import org.exist.xquery.value.Type; +import org.exist.xquery.value.ValueSequence; + +/** + * + * @author perig + * + */ +public class FunDateTime extends BasicFunction { + + public final static FunctionSignature signature = + new FunctionSignature( + new QName("dateTime", Function.BUILTIN_FUNCTION_NS, FnModule.PREFIX), + "Creates an xs:dateTime from an xs:date, $date, and an xs:time, $time.", + new SequenceType[] { + new FunctionParameterSequenceType("date", Type.DATE, + Cardinality.ZERO_OR_ONE, "The date as xs:date"), + new FunctionParameterSequenceType("time", Type.TIME, + Cardinality.ZERO_OR_ONE, "The time as xs:time") + }, + new FunctionReturnSequenceType(Type.DATE_TIME, + Cardinality.ZERO_OR_ONE, "the combined date and time as xs:dateTime") + ); + + public FunDateTime(XQueryContext context) { + super(context, signature); + } + + public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { + if (context.getProfiler().isEnabled()) { + context.getProfiler().start(this); + context.getProfiler().message(this, Profiler.DEPENDENCIES, + "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies())); + if (contextSequence != null) + {context.getProfiler().message(this, Profiler.START_SEQUENCES, + "CONTEXT SEQUENCE", contextSequence);} + } + Sequence result; + if (args[0].isEmpty() || args[1].isEmpty()) { + result = Sequence.EMPTY_SEQUENCE; + } else if (args[0].hasMany()) { + throw new XPathException(this, ErrorCodes.XPTY0004, + "Expected at most one xs:date", args[0]); + } else if (args[1].hasMany()) { + throw new XPathException(this, ErrorCodes.XPTY0004, + "Expected at most one xs:time", args[1]); + } else { + final DateValue dv = (DateValue)args[0].itemAt(0); + final TimeValue tv = (TimeValue)args[1].itemAt(0); + if (!dv.getTimezone().isEmpty()) { + if (!tv.getTimezone().isEmpty()) { + if (!((DayTimeDurationValue)dv.getTimezone().itemAt(0)) + .compareTo(null, Constants.EQ, + ((DayTimeDurationValue)tv.getTimezone().itemAt(0)))) { + + final ValueSequence argsSeq = new ValueSequence(); + argsSeq.add(dv); + argsSeq.add(tv); + + throw new XPathException(this, ErrorCodes.FORG0008, + "Operands have different timezones", argsSeq); + } + } + } + String dtv = ((DateTimeValue)dv.convertTo(Type.DATE_TIME)).getTrimmedCalendar().toXMLFormat(); + + if (dv.getTimezone().isEmpty()) { + dtv = dtv.substring(0, dtv.length() - 8); + result = new DateTimeValue(dtv + tv.getStringValue()); + + } else if ("PT0S".equals(((DayTimeDurationValue)dv.getTimezone().itemAt(0)).getStringValue())) { + dtv = dtv.substring(0, dtv.length() - 9); + if (tv.getTimezone().isEmpty()) { + result = new DateTimeValue(dtv + tv.getStringValue() + "Z"); + } else { + result = new DateTimeValue(dtv + tv.getStringValue()); + } + + } else { + if (tv.getTimezone().isEmpty()) { + final String tz = dtv.substring(19); + dtv = dtv.substring(0, dtv.length() - 14); + result = new DateTimeValue(dtv + tv.getStringValue() + tz); + + } else { + dtv = dtv.substring(0, dtv.length() - 14); + result = new DateTimeValue(dtv + tv.getStringValue()); + } + } + } + if (context.getProfiler().isEnabled()) + {context.getProfiler().end(this, "", result);} + return result; + } +} diff --git a/src/org/exist/xquery/functions/fn/FunDefaultCollation.java b/src/org/exist/xquery/functions/fn/FunDefaultCollation.java index d8321682ba2..ba7fbb61e21 100644 --- a/src/org/exist/xquery/functions/fn/FunDefaultCollation.java +++ b/src/org/exist/xquery/functions/fn/FunDefaultCollation.java @@ -1,73 +1,73 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2007-2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ -package org.exist.xquery.functions.fn; - -import org.exist.dom.QName; -import org.exist.xquery.BasicFunction; -import org.exist.xquery.Cardinality; -import org.exist.xquery.Dependency; -import org.exist.xquery.Function; -import org.exist.xquery.FunctionSignature; -import org.exist.xquery.Profiler; -import org.exist.xquery.XPathException; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.value.FunctionReturnSequenceType; -import org.exist.xquery.value.Sequence; -import org.exist.xquery.value.StringValue; -import org.exist.xquery.value.Type; - -/** - * Built-in function fn:default-collation(). - * - * @author perig - */ -public class FunDefaultCollation extends BasicFunction { - - public final static FunctionSignature signature = - new FunctionSignature( - new QName("default-collation", Function.BUILTIN_FUNCTION_NS), - "Returns the context's default collation. E.g. http://www.w3.org/" + - "2005/xpath-functions/collation/codepoint.", - null, - new FunctionReturnSequenceType(Type.STRING, Cardinality.EXACTLY_ONE, - "the default collation from the context")); - - public FunDefaultCollation(XQueryContext context) { - super(context, signature); - } - - public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { - if (context.getProfiler().isEnabled()) { - context.getProfiler().start(this); - context.getProfiler().message(this, Profiler.DEPENDENCIES, - "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies())); - if (contextSequence != null) - {context.getProfiler().message(this, Profiler.START_SEQUENCES, - "CONTEXT SEQUENCE", contextSequence);} - } - final Sequence result = new StringValue(context.getDefaultCollation()); - if (context.getProfiler().isEnabled()) - {context.getProfiler().end(this, "", result);} - return result; - - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2007-2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id$ + */ +package org.exist.xquery.functions.fn; + +import org.exist.dom.QName; +import org.exist.xquery.BasicFunction; +import org.exist.xquery.Cardinality; +import org.exist.xquery.Dependency; +import org.exist.xquery.Function; +import org.exist.xquery.FunctionSignature; +import org.exist.xquery.Profiler; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.value.FunctionReturnSequenceType; +import org.exist.xquery.value.Sequence; +import org.exist.xquery.value.StringValue; +import org.exist.xquery.value.Type; + +/** + * Built-in function fn:default-collation(). + * + * @author perig + */ +public class FunDefaultCollation extends BasicFunction { + + public final static FunctionSignature signature = + new FunctionSignature( + new QName("default-collation", Function.BUILTIN_FUNCTION_NS), + "Returns the context's default collation. E.g. http://www.w3.org/" + + "2005/xpath-functions/collation/codepoint.", + null, + new FunctionReturnSequenceType(Type.STRING, Cardinality.EXACTLY_ONE, + "the default collation from the context")); + + public FunDefaultCollation(XQueryContext context) { + super(context, signature); + } + + public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { + if (context.getProfiler().isEnabled()) { + context.getProfiler().start(this); + context.getProfiler().message(this, Profiler.DEPENDENCIES, + "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies())); + if (contextSequence != null) + {context.getProfiler().message(this, Profiler.START_SEQUENCES, + "CONTEXT SEQUENCE", contextSequence);} + } + final Sequence result = new StringValue(context.getDefaultCollation()); + if (context.getProfiler().isEnabled()) + {context.getProfiler().end(this, "", result);} + return result; + + } +} diff --git a/src/org/exist/xquery/functions/fn/FunEquals.java b/src/org/exist/xquery/functions/fn/FunEquals.java index 74a0e977adc..c6ba760e923 100644 --- a/src/org/exist/xquery/functions/fn/FunEquals.java +++ b/src/org/exist/xquery/functions/fn/FunEquals.java @@ -1,129 +1,129 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id: FunContains.java 9768 2009-08-10 15:42:19Z ixitar $ - */ -package org.exist.xquery.functions.fn; - -import java.text.Collator; - -import org.exist.dom.QName; -import org.exist.util.Collations; -import org.exist.xquery.Cardinality; -import org.exist.xquery.Dependency; -import org.exist.xquery.Function; -import org.exist.xquery.FunctionSignature; -import org.exist.xquery.Profiler; -import org.exist.xquery.XPathException; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.functions.fn.CollatingFunction; -import org.exist.xquery.value.BooleanValue; -import org.exist.xquery.value.FunctionReturnSequenceType; -import org.exist.xquery.value.FunctionParameterSequenceType; -import org.exist.xquery.value.Item; -import org.exist.xquery.value.Sequence; -import org.exist.xquery.value.SequenceType; -import org.exist.xquery.value.Type; - -public class FunEquals extends CollatingFunction { - - public final static FunctionSignature signatures[] = { - new FunctionSignature( - new QName("equals", Function.BUILTIN_FUNCTION_NS), - "Returns an xs:boolean indicating whether or not the value of " + - "$source-string equals the collation units in the value of " + - "$substring, according to the default collation. " + - "This function is similar to the '=' expression, except that " + - "it uses the default collation for comparisons.", - new SequenceType[] { - new FunctionParameterSequenceType("source-string", Type.STRING, - Cardinality.ZERO_OR_ONE, "The source-string"), - new FunctionParameterSequenceType("substring", Type.STRING, - Cardinality.ZERO_OR_ONE, "The substring") - }, - new FunctionReturnSequenceType(Type.BOOLEAN, Cardinality.ONE, - "true() if $source-string equals $substring, false() otherwise") - ), - new FunctionSignature( - new QName("equals", Function.BUILTIN_FUNCTION_NS), - "Returns an xs:boolean indicating whether or not the value of " + - "$source-string equals the collation units in the value of " + - "$substring, according to the collation that is specified in " + - "$collation-uri. This function is similar to the '=' expression, " + - "except that it uses the specified collation for comparisons." + - THIRD_REL_COLLATION_ARG_EXAMPLE, - new SequenceType[] { - new FunctionParameterSequenceType("source-string", Type.STRING, - Cardinality.ZERO_OR_ONE, "The source-string"), - new FunctionParameterSequenceType("substring", Type.STRING, - Cardinality.ZERO_OR_ONE, "The substring"), - new FunctionParameterSequenceType("collation-uri", Type.STRING, - Cardinality.EXACTLY_ONE, "The collation URI") - }, - new FunctionReturnSequenceType(Type.BOOLEAN, Cardinality.ONE, - "true() if $source-string equals $substring, false() otherwise")) - }; - - public FunEquals(XQueryContext context, FunctionSignature signature) { - super(context, signature); - } - - public int returnsType() { - return Type.BOOLEAN; - } - - public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathException { - if (context.getProfiler().isEnabled()) { - context.getProfiler().start(this); - context.getProfiler().message(this, Profiler.DEPENDENCIES, - "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies())); - if (contextSequence != null) - {context.getProfiler().message(this, Profiler.START_SEQUENCES, - "CONTEXT SEQUENCE", contextSequence);} - if (contextItem != null) - {context.getProfiler().message(this, Profiler.START_SEQUENCES, - "CONTEXT ITEM", contextItem.toSequence());} - } - Sequence result; - final String s1 = getArgument(0).eval(contextSequence, contextItem).getStringValue(); - final String s2 = getArgument(1).eval(contextSequence, contextItem).getStringValue(); - if (s1.length() == 0 || s2.length() == 0 ) { - if (s1.length() == 0 && s2.length() == 0 ) { - result = BooleanValue.TRUE; - } else { - result = Sequence.EMPTY_SEQUENCE; - } - } else { - Collator collator = getCollator(contextSequence, contextItem, 3); - // Make sure we have a collator! - if (collator == null) { - //TODO : raise exception ? -pb - collator = Collations.getCollationFromURI(context, "?strength=identical"); - } - if (Collations.equals(collator, s1, s2)) { - result = BooleanValue.TRUE; - } else { - result = BooleanValue.FALSE; - } - } - if (context.getProfiler().isEnabled()) - {context.getProfiler().end(this, "", result);} - return result; - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id: FunContains.java 9768 2009-08-10 15:42:19Z ixitar $ + */ +package org.exist.xquery.functions.fn; + +import java.text.Collator; + +import org.exist.dom.QName; +import org.exist.util.Collations; +import org.exist.xquery.Cardinality; +import org.exist.xquery.Dependency; +import org.exist.xquery.Function; +import org.exist.xquery.FunctionSignature; +import org.exist.xquery.Profiler; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.functions.fn.CollatingFunction; +import org.exist.xquery.value.BooleanValue; +import org.exist.xquery.value.FunctionReturnSequenceType; +import org.exist.xquery.value.FunctionParameterSequenceType; +import org.exist.xquery.value.Item; +import org.exist.xquery.value.Sequence; +import org.exist.xquery.value.SequenceType; +import org.exist.xquery.value.Type; + +public class FunEquals extends CollatingFunction { + + public final static FunctionSignature signatures[] = { + new FunctionSignature( + new QName("equals", Function.BUILTIN_FUNCTION_NS), + "Returns an xs:boolean indicating whether or not the value of " + + "$source-string equals the collation units in the value of " + + "$substring, according to the default collation. " + + "This function is similar to the '=' expression, except that " + + "it uses the default collation for comparisons.", + new SequenceType[] { + new FunctionParameterSequenceType("source-string", Type.STRING, + Cardinality.ZERO_OR_ONE, "The source-string"), + new FunctionParameterSequenceType("substring", Type.STRING, + Cardinality.ZERO_OR_ONE, "The substring") + }, + new FunctionReturnSequenceType(Type.BOOLEAN, Cardinality.ONE, + "true() if $source-string equals $substring, false() otherwise") + ), + new FunctionSignature( + new QName("equals", Function.BUILTIN_FUNCTION_NS), + "Returns an xs:boolean indicating whether or not the value of " + + "$source-string equals the collation units in the value of " + + "$substring, according to the collation that is specified in " + + "$collation-uri. This function is similar to the '=' expression, " + + "except that it uses the specified collation for comparisons." + + THIRD_REL_COLLATION_ARG_EXAMPLE, + new SequenceType[] { + new FunctionParameterSequenceType("source-string", Type.STRING, + Cardinality.ZERO_OR_ONE, "The source-string"), + new FunctionParameterSequenceType("substring", Type.STRING, + Cardinality.ZERO_OR_ONE, "The substring"), + new FunctionParameterSequenceType("collation-uri", Type.STRING, + Cardinality.EXACTLY_ONE, "The collation URI") + }, + new FunctionReturnSequenceType(Type.BOOLEAN, Cardinality.ONE, + "true() if $source-string equals $substring, false() otherwise")) + }; + + public FunEquals(XQueryContext context, FunctionSignature signature) { + super(context, signature); + } + + public int returnsType() { + return Type.BOOLEAN; + } + + public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathException { + if (context.getProfiler().isEnabled()) { + context.getProfiler().start(this); + context.getProfiler().message(this, Profiler.DEPENDENCIES, + "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies())); + if (contextSequence != null) + {context.getProfiler().message(this, Profiler.START_SEQUENCES, + "CONTEXT SEQUENCE", contextSequence);} + if (contextItem != null) + {context.getProfiler().message(this, Profiler.START_SEQUENCES, + "CONTEXT ITEM", contextItem.toSequence());} + } + Sequence result; + final String s1 = getArgument(0).eval(contextSequence, contextItem).getStringValue(); + final String s2 = getArgument(1).eval(contextSequence, contextItem).getStringValue(); + if (s1.length() == 0 || s2.length() == 0 ) { + if (s1.length() == 0 && s2.length() == 0 ) { + result = BooleanValue.TRUE; + } else { + result = Sequence.EMPTY_SEQUENCE; + } + } else { + Collator collator = getCollator(contextSequence, contextItem, 3); + // Make sure we have a collator! + if (collator == null) { + //TODO : raise exception ? -pb + collator = Collations.getCollationFromURI(context, "?strength=identical"); + } + if (Collations.equals(collator, s1, s2)) { + result = BooleanValue.TRUE; + } else { + result = BooleanValue.FALSE; + } + } + if (context.getProfiler().isEnabled()) + {context.getProfiler().end(this, "", result);} + return result; + } +} diff --git a/src/org/exist/xquery/functions/fn/FunGetDurationComponent.java b/src/org/exist/xquery/functions/fn/FunGetDurationComponent.java index 2d3c7818b50..95dd38a5bdb 100644 --- a/src/org/exist/xquery/functions/fn/FunGetDurationComponent.java +++ b/src/org/exist/xquery/functions/fn/FunGetDurationComponent.java @@ -1,169 +1,169 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ -package org.exist.xquery.functions.fn; - -import java.math.BigDecimal; - -import javax.xml.datatype.DatatypeConstants; - -import org.apache.log4j.Logger; - -import org.exist.dom.QName; -import org.exist.xquery.BasicFunction; -import org.exist.xquery.Cardinality; -import org.exist.xquery.Dependency; -import org.exist.xquery.Function; -import org.exist.xquery.FunctionSignature; -import org.exist.xquery.Profiler; -import org.exist.xquery.XPathException; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.value.DecimalValue; -import org.exist.xquery.value.DurationValue; -import org.exist.xquery.value.FunctionReturnSequenceType; -import org.exist.xquery.value.FunctionParameterSequenceType; -import org.exist.xquery.value.IntegerValue; -import org.exist.xquery.value.Sequence; -import org.exist.xquery.value.SequenceType; -import org.exist.xquery.value.Type; - -/** - * - * @author wolf - * @author piotr kaminski - * - */ -public class FunGetDurationComponent extends BasicFunction { - protected static final Logger logger = Logger.getLogger(FunGetDurationComponent.class); - public final static FunctionParameterSequenceType DAYTIME_DURA_01_PARAM = new FunctionParameterSequenceType("duration", Type.DAY_TIME_DURATION, Cardinality.ZERO_OR_ONE, "The duration as xs:dayTimeDuration"); - public final static FunctionParameterSequenceType YEARMONTH_DURA_01_PARAM = new FunctionParameterSequenceType("duration", Type.YEAR_MONTH_DURATION, Cardinality.ZERO_OR_ONE, "The duration as xs:yearMonthDuration"); - - public final static FunctionSignature fnDaysFromDuration = - new FunctionSignature( - new QName("days-from-duration", Function.BUILTIN_FUNCTION_NS), - "Returns an xs:integer representing the days component in the canonical lexical " + - "representation of the value of $duration. The result may be negative.", - new SequenceType[] { - DAYTIME_DURA_01_PARAM - }, - new FunctionReturnSequenceType(Type.INTEGER, Cardinality.ZERO_OR_ONE, "the days component of $duration")); - - public final static FunctionSignature fnHoursFromDuration = - new FunctionSignature( - new QName("hours-from-duration", Function.BUILTIN_FUNCTION_NS), - "Returns an xs:integer representing the hours component in the canonical lexical " + - "representation of the value of $duration. The result may be negative.", - new SequenceType[] { - DAYTIME_DURA_01_PARAM - }, - new FunctionReturnSequenceType(Type.INTEGER, Cardinality.ZERO_OR_ONE, "the hours component of $duration")); - - public final static FunctionSignature fnMinutesFromDuration = - new FunctionSignature( - new QName("minutes-from-duration", Function.BUILTIN_FUNCTION_NS), - "Returns an xs:integer representing the minutes component in the canonical " + - "lexical representation of the value of $duration. The result may be negative.", - new SequenceType[] { - DAYTIME_DURA_01_PARAM - }, - new FunctionReturnSequenceType(Type.INTEGER, Cardinality.ZERO_OR_ONE, "the minutes component of $duration")); - - public final static FunctionSignature fnSecondsFromDuration = - new FunctionSignature( - new QName("seconds-from-duration", Function.BUILTIN_FUNCTION_NS), - "Returns an xs:decimal representing the seconds component in the canonical lexical " + - "representation of the value of $duration. The result may be negative", - new SequenceType[] { - DAYTIME_DURA_01_PARAM - }, - new FunctionReturnSequenceType(Type.DECIMAL, Cardinality.ZERO_OR_ONE, "the seconds component of $duration")); - - public final static FunctionSignature fnMonthsFromDuration = new FunctionSignature( - new QName("months-from-duration", Function.BUILTIN_FUNCTION_NS), - "Returns an xs:integer representing the months component in the canonical lexical " + - "representation of the value of $duration. The result may be negative.", - new SequenceType[] { - YEARMONTH_DURA_01_PARAM - }, - new FunctionReturnSequenceType(Type.INTEGER, Cardinality.ZERO_OR_ONE, "the months component of $duration")); - - public final static FunctionSignature fnYearsFromDuration = new FunctionSignature( - new QName("years-from-duration", Function.BUILTIN_FUNCTION_NS), - "Returns an xs:integer representing the years component in the canonical lexical " + - "representation of the value of $duration. The result may be negative.", - new SequenceType[] { - YEARMONTH_DURA_01_PARAM - }, - new FunctionReturnSequenceType(Type.INTEGER, Cardinality.ZERO_OR_ONE, "the years component of $duration")); - - - public FunGetDurationComponent(XQueryContext context, FunctionSignature signature) { - super(context, signature); - } - - public Sequence eval(Sequence[] args, Sequence contextSequence) - throws XPathException { - if (context.getProfiler().isEnabled()) { - context.getProfiler().start(this); - context.getProfiler().message(this, Profiler.DEPENDENCIES, "DEPENDENCIES", - Dependency.getDependenciesName(this.getDependencies())); - if (contextSequence != null) - {context.getProfiler().message(this, Profiler.START_SEQUENCES, - "CONTEXT SEQUENCE", contextSequence);} - } - - Sequence result; - if (args.length == 0 || args[0].isEmpty()) { - result = Sequence.EMPTY_SEQUENCE; - } else { - final Sequence arg = args[0]; - final DurationValue duration = new DurationValue(((DurationValue) arg.itemAt(0)).getCanonicalDuration()); - if (isCalledAs("days-from-duration")) { - result = new IntegerValue(duration.getPart(DurationValue.DAY)); - } else if (isCalledAs("hours-from-duration")) { - result = new IntegerValue(duration.getPart(DurationValue.HOUR)); - } else if (isCalledAs("minutes-from-duration")) { - result = new IntegerValue(duration.getPart(DurationValue.MINUTE)); - } else if (isCalledAs("seconds-from-duration")) { - if (duration.getCanonicalDuration().getField(DatatypeConstants.SECONDS) == null) - {result = new DecimalValue(0);} - else - {result = new DecimalValue((BigDecimal)duration.getCanonicalDuration().getField(DatatypeConstants.SECONDS));} - if (duration.getCanonicalDuration().getSign() < 0) - {result = ((DecimalValue)result).negate();} - } else if (isCalledAs("months-from-duration")) { - result = new IntegerValue(duration.getPart(DurationValue.MONTH)); - } else if (isCalledAs("years-from-duration")) { - result = new IntegerValue(duration.getPart(DurationValue.YEAR)); - } else { - logger.error("can't handle function " + mySignature.getName().getLocalName()); - throw new Error("can't handle function " + mySignature.getName().getLocalName()); - } - } - - if (context.getProfiler().isEnabled()) - {context.getProfiler().end(this, "", result);} - - return result; - - } - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id$ + */ +package org.exist.xquery.functions.fn; + +import java.math.BigDecimal; + +import javax.xml.datatype.DatatypeConstants; + +import org.apache.log4j.Logger; + +import org.exist.dom.QName; +import org.exist.xquery.BasicFunction; +import org.exist.xquery.Cardinality; +import org.exist.xquery.Dependency; +import org.exist.xquery.Function; +import org.exist.xquery.FunctionSignature; +import org.exist.xquery.Profiler; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.value.DecimalValue; +import org.exist.xquery.value.DurationValue; +import org.exist.xquery.value.FunctionReturnSequenceType; +import org.exist.xquery.value.FunctionParameterSequenceType; +import org.exist.xquery.value.IntegerValue; +import org.exist.xquery.value.Sequence; +import org.exist.xquery.value.SequenceType; +import org.exist.xquery.value.Type; + +/** + * + * @author wolf + * @author piotr kaminski + * + */ +public class FunGetDurationComponent extends BasicFunction { + protected static final Logger logger = Logger.getLogger(FunGetDurationComponent.class); + public final static FunctionParameterSequenceType DAYTIME_DURA_01_PARAM = new FunctionParameterSequenceType("duration", Type.DAY_TIME_DURATION, Cardinality.ZERO_OR_ONE, "The duration as xs:dayTimeDuration"); + public final static FunctionParameterSequenceType YEARMONTH_DURA_01_PARAM = new FunctionParameterSequenceType("duration", Type.YEAR_MONTH_DURATION, Cardinality.ZERO_OR_ONE, "The duration as xs:yearMonthDuration"); + + public final static FunctionSignature fnDaysFromDuration = + new FunctionSignature( + new QName("days-from-duration", Function.BUILTIN_FUNCTION_NS), + "Returns an xs:integer representing the days component in the canonical lexical " + + "representation of the value of $duration. The result may be negative.", + new SequenceType[] { + DAYTIME_DURA_01_PARAM + }, + new FunctionReturnSequenceType(Type.INTEGER, Cardinality.ZERO_OR_ONE, "the days component of $duration")); + + public final static FunctionSignature fnHoursFromDuration = + new FunctionSignature( + new QName("hours-from-duration", Function.BUILTIN_FUNCTION_NS), + "Returns an xs:integer representing the hours component in the canonical lexical " + + "representation of the value of $duration. The result may be negative.", + new SequenceType[] { + DAYTIME_DURA_01_PARAM + }, + new FunctionReturnSequenceType(Type.INTEGER, Cardinality.ZERO_OR_ONE, "the hours component of $duration")); + + public final static FunctionSignature fnMinutesFromDuration = + new FunctionSignature( + new QName("minutes-from-duration", Function.BUILTIN_FUNCTION_NS), + "Returns an xs:integer representing the minutes component in the canonical " + + "lexical representation of the value of $duration. The result may be negative.", + new SequenceType[] { + DAYTIME_DURA_01_PARAM + }, + new FunctionReturnSequenceType(Type.INTEGER, Cardinality.ZERO_OR_ONE, "the minutes component of $duration")); + + public final static FunctionSignature fnSecondsFromDuration = + new FunctionSignature( + new QName("seconds-from-duration", Function.BUILTIN_FUNCTION_NS), + "Returns an xs:decimal representing the seconds component in the canonical lexical " + + "representation of the value of $duration. The result may be negative", + new SequenceType[] { + DAYTIME_DURA_01_PARAM + }, + new FunctionReturnSequenceType(Type.DECIMAL, Cardinality.ZERO_OR_ONE, "the seconds component of $duration")); + + public final static FunctionSignature fnMonthsFromDuration = new FunctionSignature( + new QName("months-from-duration", Function.BUILTIN_FUNCTION_NS), + "Returns an xs:integer representing the months component in the canonical lexical " + + "representation of the value of $duration. The result may be negative.", + new SequenceType[] { + YEARMONTH_DURA_01_PARAM + }, + new FunctionReturnSequenceType(Type.INTEGER, Cardinality.ZERO_OR_ONE, "the months component of $duration")); + + public final static FunctionSignature fnYearsFromDuration = new FunctionSignature( + new QName("years-from-duration", Function.BUILTIN_FUNCTION_NS), + "Returns an xs:integer representing the years component in the canonical lexical " + + "representation of the value of $duration. The result may be negative.", + new SequenceType[] { + YEARMONTH_DURA_01_PARAM + }, + new FunctionReturnSequenceType(Type.INTEGER, Cardinality.ZERO_OR_ONE, "the years component of $duration")); + + + public FunGetDurationComponent(XQueryContext context, FunctionSignature signature) { + super(context, signature); + } + + public Sequence eval(Sequence[] args, Sequence contextSequence) + throws XPathException { + if (context.getProfiler().isEnabled()) { + context.getProfiler().start(this); + context.getProfiler().message(this, Profiler.DEPENDENCIES, "DEPENDENCIES", + Dependency.getDependenciesName(this.getDependencies())); + if (contextSequence != null) + {context.getProfiler().message(this, Profiler.START_SEQUENCES, + "CONTEXT SEQUENCE", contextSequence);} + } + + Sequence result; + if (args.length == 0 || args[0].isEmpty()) { + result = Sequence.EMPTY_SEQUENCE; + } else { + final Sequence arg = args[0]; + final DurationValue duration = new DurationValue(((DurationValue) arg.itemAt(0)).getCanonicalDuration()); + if (isCalledAs("days-from-duration")) { + result = new IntegerValue(duration.getPart(DurationValue.DAY)); + } else if (isCalledAs("hours-from-duration")) { + result = new IntegerValue(duration.getPart(DurationValue.HOUR)); + } else if (isCalledAs("minutes-from-duration")) { + result = new IntegerValue(duration.getPart(DurationValue.MINUTE)); + } else if (isCalledAs("seconds-from-duration")) { + if (duration.getCanonicalDuration().getField(DatatypeConstants.SECONDS) == null) + {result = new DecimalValue(0);} + else + {result = new DecimalValue((BigDecimal)duration.getCanonicalDuration().getField(DatatypeConstants.SECONDS));} + if (duration.getCanonicalDuration().getSign() < 0) + {result = ((DecimalValue)result).negate();} + } else if (isCalledAs("months-from-duration")) { + result = new IntegerValue(duration.getPart(DurationValue.MONTH)); + } else if (isCalledAs("years-from-duration")) { + result = new IntegerValue(duration.getPart(DurationValue.YEAR)); + } else { + logger.error("can't handle function " + mySignature.getName().getLocalName()); + throw new Error("can't handle function " + mySignature.getName().getLocalName()); + } + } + + if (context.getProfiler().isEnabled()) + {context.getProfiler().end(this, "", result);} + + return result; + + } + +} diff --git a/src/org/exist/xquery/functions/fn/FunIdRef.java b/src/org/exist/xquery/functions/fn/FunIdRef.java index b72d13cd1d7..93ebaa4de93 100644 --- a/src/org/exist/xquery/functions/fn/FunIdRef.java +++ b/src/org/exist/xquery/functions/fn/FunIdRef.java @@ -1,208 +1,208 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2007-2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ -package org.exist.xquery.functions.fn; - -import org.apache.log4j.Logger; - -import org.exist.dom.DefaultDocumentSet; -import org.exist.dom.DocumentSet; -import org.exist.dom.ExtArrayNodeSet; -import org.exist.dom.MutableDocumentSet; -import org.exist.dom.NodeProxy; -import org.exist.dom.NodeSet; -import org.exist.dom.QName; -import org.exist.util.XMLChar; -import org.exist.xquery.Cardinality; -import org.exist.xquery.Constants; -import org.exist.xquery.Dependency; -import org.exist.xquery.ErrorCodes; -import org.exist.xquery.Expression; -import org.exist.xquery.Function; -import org.exist.xquery.FunctionSignature; -import org.exist.xquery.Profiler; -import org.exist.xquery.XPathException; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.value.FunctionReturnSequenceType; -import org.exist.xquery.value.FunctionParameterSequenceType; -import org.exist.xquery.value.Item; -import org.exist.xquery.value.NodeValue; -import org.exist.xquery.value.Sequence; -import org.exist.xquery.value.SequenceIterator; -import org.exist.xquery.value.SequenceType; -import org.exist.xquery.value.StringValue; -import org.exist.xquery.value.Type; -import org.exist.xquery.value.ValueSequence; -import org.w3c.dom.Node; - -import java.util.Set; -import java.util.TreeSet; - -/** - * - * @author perig - * @author piotr kaminski - * - */ -public class FunIdRef extends Function { - protected static final Logger logger = Logger.getLogger(FunIdRef.class); - public final static FunctionSignature signature[] = { - new FunctionSignature( - new QName("idref", Function.BUILTIN_FUNCTION_NS), - "Returns the sequence of element or attributes nodes with an IDREF value matching the " + - "value of one or more of the ID values supplied in $ids. " + - "If none is matching or $ids is the empty sequence, returns the empty sequence.", - new SequenceType[] { - new FunctionParameterSequenceType("ids", Type.STRING, Cardinality.ZERO_OR_MORE, "The ID sequence"), - }, - new FunctionReturnSequenceType(Type.NODE, Cardinality.ZERO_OR_MORE, "the elements with matching IDREF values from IDs in $ids")), - - new FunctionSignature( - new QName("idref", Function.BUILTIN_FUNCTION_NS), - "Returns the sequence of element or attributes nodes with an IDREF value matching the " + - "value of one or more of the ID values supplied in $ids. " + - "If none is matching or $ids is the empty sequence, returns the empty sequence.", - new SequenceType[] { - new FunctionParameterSequenceType("ids", Type.STRING, Cardinality.ZERO_OR_MORE, "The ID sequence"), - new FunctionParameterSequenceType("node-in-document", Type.NODE, Cardinality.EXACTLY_ONE, "The node in document") - }, - new FunctionReturnSequenceType(Type.NODE, Cardinality.ZERO_OR_MORE, "the elements with matching IDREF values from IDs in $ids in the same document as $node-in-document")) - }; - - /** - * Constructor for FunId. - */ - public FunIdRef(XQueryContext context, FunctionSignature signature) { - super(context, signature); - } - - /** - * @see org.exist.xquery.Expression#eval(Sequence, Item) - */ - public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathException { - if (context.getProfiler().isEnabled()) { - context.getProfiler().start(this); - context.getProfiler().message(this, Profiler.DEPENDENCIES, "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies())); - if (contextSequence != null) - {context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence);} - if (contextItem != null) - {context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT ITEM", contextItem.toSequence());} - } - - if (getArgumentCount() < 1) - {throw new XPathException(this, ErrorCodes.XPST0017, "function id requires one argument");} - - if(contextItem != null) - {contextSequence = contextItem.toSequence();} - - Sequence result; - boolean processInMem = false; - final Expression arg = getArgument(0); - final Sequence idrefval = arg.eval(contextSequence); - if(idrefval.isEmpty()) - {result = Sequence.EMPTY_SEQUENCE;} - else { - String nextId; - DocumentSet docs = null; - if (getArgumentCount() == 2) { - // second argument should be a node, whose owner document will be - // searched for the id - final Sequence nodes = getArgument(1).eval(contextSequence); - if (nodes.isEmpty()) - {throw new XPathException(this, ErrorCodes.XPDY0002, - "no node or context item for fn:idref");} - - if (!Type.subTypeOf(nodes.itemAt(0).getType(), Type.NODE)) - {throw new XPathException(this, ErrorCodes.XPTY0004, - "fn:idref() argument is not a node");} - - NodeValue node = (NodeValue)nodes.itemAt(0); - if (node.getImplementationType() == NodeValue.IN_MEMORY_NODE) - //TODO : how to enforce this ? - //If $node, or the context item if the second argument is omitted, - //is a node in a tree whose root is not a document node [err:FODC0001] is raised processInMem = true; - {processInMem = true;} - else { - MutableDocumentSet ndocs = new DefaultDocumentSet(); - ndocs.add(((NodeProxy)node).getDocument()); - docs = ndocs; - } - contextSequence = node; - } else if (contextSequence == null) - {throw new XPathException(this, ErrorCodes.XPDY0002, "no context item specified");} - else if(!Type.subTypeOf(contextSequence.getItemType(), Type.NODE)) - {throw new XPathException(this, ErrorCodes.XPTY0004, "context item is not a node");} - else { - if (contextSequence.isPersistentSet()) - {docs = contextSequence.toNodeSet().getDocumentSet();} - else - {processInMem = true;} - } - - if (processInMem) - {result = new ValueSequence();} - else - {result = new ExtArrayNodeSet();} - - for(final SequenceIterator i = idrefval.iterate(); i.hasNext(); ) { - nextId = i.nextItem().getStringValue(); - if (nextId.length() == 0) {continue;} - if(XMLChar.isValidNCName(nextId)) { - if (processInMem) - {getIdRef(result, contextSequence, nextId);} - else - {getIdRef((NodeSet)result, docs, nextId);} - } - } - } - - result.removeDuplicates(); - - if (context.getProfiler().isEnabled()) - {context.getProfiler().end(this, "", result);} - - return result; - - } - - private void getIdRef(NodeSet result, DocumentSet docs, String id) throws XPathException { - final NodeSet attribs = context.getBroker().getValueIndex().find(context.getWatchDog(), Constants.EQ, docs, null, -1, null, new StringValue(id, Type.IDREF)); - - for (final NodeProxy n : attribs) { - n.setNodeType(Node.ATTRIBUTE_NODE); - result.add(n); - } - } - - private void getIdRef(Sequence result, Sequence seq, String id) throws XPathException { - final Set visitedDocs = new TreeSet(); - for (final SequenceIterator i = seq.iterate(); i.hasNext();) { - final org.exist.memtree.NodeImpl v = (org.exist.memtree.NodeImpl) i.nextItem(); - final org.exist.memtree.DocumentImpl doc = v.getDocument(); - if (!visitedDocs.contains(doc)) { - final org.exist.memtree.NodeImpl node = doc.selectByIdref(id); - if (node != null) - {result.add(node);} - visitedDocs.add(doc); - } - } - } +/* + * eXist Open Source Native XML Database + * Copyright (C) 2007-2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id$ + */ +package org.exist.xquery.functions.fn; + +import org.apache.log4j.Logger; + +import org.exist.dom.DefaultDocumentSet; +import org.exist.dom.DocumentSet; +import org.exist.dom.ExtArrayNodeSet; +import org.exist.dom.MutableDocumentSet; +import org.exist.dom.NodeProxy; +import org.exist.dom.NodeSet; +import org.exist.dom.QName; +import org.exist.util.XMLChar; +import org.exist.xquery.Cardinality; +import org.exist.xquery.Constants; +import org.exist.xquery.Dependency; +import org.exist.xquery.ErrorCodes; +import org.exist.xquery.Expression; +import org.exist.xquery.Function; +import org.exist.xquery.FunctionSignature; +import org.exist.xquery.Profiler; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.value.FunctionReturnSequenceType; +import org.exist.xquery.value.FunctionParameterSequenceType; +import org.exist.xquery.value.Item; +import org.exist.xquery.value.NodeValue; +import org.exist.xquery.value.Sequence; +import org.exist.xquery.value.SequenceIterator; +import org.exist.xquery.value.SequenceType; +import org.exist.xquery.value.StringValue; +import org.exist.xquery.value.Type; +import org.exist.xquery.value.ValueSequence; +import org.w3c.dom.Node; + +import java.util.Set; +import java.util.TreeSet; + +/** + * + * @author perig + * @author piotr kaminski + * + */ +public class FunIdRef extends Function { + protected static final Logger logger = Logger.getLogger(FunIdRef.class); + public final static FunctionSignature signature[] = { + new FunctionSignature( + new QName("idref", Function.BUILTIN_FUNCTION_NS), + "Returns the sequence of element or attributes nodes with an IDREF value matching the " + + "value of one or more of the ID values supplied in $ids. " + + "If none is matching or $ids is the empty sequence, returns the empty sequence.", + new SequenceType[] { + new FunctionParameterSequenceType("ids", Type.STRING, Cardinality.ZERO_OR_MORE, "The ID sequence"), + }, + new FunctionReturnSequenceType(Type.NODE, Cardinality.ZERO_OR_MORE, "the elements with matching IDREF values from IDs in $ids")), + + new FunctionSignature( + new QName("idref", Function.BUILTIN_FUNCTION_NS), + "Returns the sequence of element or attributes nodes with an IDREF value matching the " + + "value of one or more of the ID values supplied in $ids. " + + "If none is matching or $ids is the empty sequence, returns the empty sequence.", + new SequenceType[] { + new FunctionParameterSequenceType("ids", Type.STRING, Cardinality.ZERO_OR_MORE, "The ID sequence"), + new FunctionParameterSequenceType("node-in-document", Type.NODE, Cardinality.EXACTLY_ONE, "The node in document") + }, + new FunctionReturnSequenceType(Type.NODE, Cardinality.ZERO_OR_MORE, "the elements with matching IDREF values from IDs in $ids in the same document as $node-in-document")) + }; + + /** + * Constructor for FunId. + */ + public FunIdRef(XQueryContext context, FunctionSignature signature) { + super(context, signature); + } + + /** + * @see org.exist.xquery.Expression#eval(Sequence, Item) + */ + public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathException { + if (context.getProfiler().isEnabled()) { + context.getProfiler().start(this); + context.getProfiler().message(this, Profiler.DEPENDENCIES, "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies())); + if (contextSequence != null) + {context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence);} + if (contextItem != null) + {context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT ITEM", contextItem.toSequence());} + } + + if (getArgumentCount() < 1) + {throw new XPathException(this, ErrorCodes.XPST0017, "function id requires one argument");} + + if(contextItem != null) + {contextSequence = contextItem.toSequence();} + + Sequence result; + boolean processInMem = false; + final Expression arg = getArgument(0); + final Sequence idrefval = arg.eval(contextSequence); + if(idrefval.isEmpty()) + {result = Sequence.EMPTY_SEQUENCE;} + else { + String nextId; + DocumentSet docs = null; + if (getArgumentCount() == 2) { + // second argument should be a node, whose owner document will be + // searched for the id + final Sequence nodes = getArgument(1).eval(contextSequence); + if (nodes.isEmpty()) + {throw new XPathException(this, ErrorCodes.XPDY0002, + "no node or context item for fn:idref");} + + if (!Type.subTypeOf(nodes.itemAt(0).getType(), Type.NODE)) + {throw new XPathException(this, ErrorCodes.XPTY0004, + "fn:idref() argument is not a node");} + + NodeValue node = (NodeValue)nodes.itemAt(0); + if (node.getImplementationType() == NodeValue.IN_MEMORY_NODE) + //TODO : how to enforce this ? + //If $node, or the context item if the second argument is omitted, + //is a node in a tree whose root is not a document node [err:FODC0001] is raised processInMem = true; + {processInMem = true;} + else { + MutableDocumentSet ndocs = new DefaultDocumentSet(); + ndocs.add(((NodeProxy)node).getDocument()); + docs = ndocs; + } + contextSequence = node; + } else if (contextSequence == null) + {throw new XPathException(this, ErrorCodes.XPDY0002, "no context item specified");} + else if(!Type.subTypeOf(contextSequence.getItemType(), Type.NODE)) + {throw new XPathException(this, ErrorCodes.XPTY0004, "context item is not a node");} + else { + if (contextSequence.isPersistentSet()) + {docs = contextSequence.toNodeSet().getDocumentSet();} + else + {processInMem = true;} + } + + if (processInMem) + {result = new ValueSequence();} + else + {result = new ExtArrayNodeSet();} + + for(final SequenceIterator i = idrefval.iterate(); i.hasNext(); ) { + nextId = i.nextItem().getStringValue(); + if (nextId.length() == 0) {continue;} + if(XMLChar.isValidNCName(nextId)) { + if (processInMem) + {getIdRef(result, contextSequence, nextId);} + else + {getIdRef((NodeSet)result, docs, nextId);} + } + } + } + + result.removeDuplicates(); + + if (context.getProfiler().isEnabled()) + {context.getProfiler().end(this, "", result);} + + return result; + + } + + private void getIdRef(NodeSet result, DocumentSet docs, String id) throws XPathException { + final NodeSet attribs = context.getBroker().getValueIndex().find(context.getWatchDog(), Constants.EQ, docs, null, -1, null, new StringValue(id, Type.IDREF)); + + for (final NodeProxy n : attribs) { + n.setNodeType(Node.ATTRIBUTE_NODE); + result.add(n); + } + } + + private void getIdRef(Sequence result, Sequence seq, String id) throws XPathException { + final Set visitedDocs = new TreeSet(); + for (final SequenceIterator i = seq.iterate(); i.hasNext();) { + final org.exist.memtree.NodeImpl v = (org.exist.memtree.NodeImpl) i.nextItem(); + final org.exist.memtree.DocumentImpl doc = v.getDocument(); + if (!visitedDocs.contains(doc)) { + final org.exist.memtree.NodeImpl node = doc.selectByIdref(id); + if (node != null) + {result.add(node);} + visitedDocs.add(doc); + } + } + } } \ No newline at end of file diff --git a/src/org/exist/xquery/functions/fn/FunNilled.java b/src/org/exist/xquery/functions/fn/FunNilled.java index be2e3796489..43cbb7ee3d9 100644 --- a/src/org/exist/xquery/functions/fn/FunNilled.java +++ b/src/org/exist/xquery/functions/fn/FunNilled.java @@ -1,101 +1,101 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2000-2007 The eXist team - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ - -package org.exist.xquery.functions.fn; - -import org.exist.Namespaces; -import org.exist.dom.QName; -import org.exist.xquery.BasicFunction; -import org.exist.xquery.Cardinality; -import org.exist.xquery.Dependency; -import org.exist.xquery.Function; -import org.exist.xquery.FunctionSignature; -import org.exist.xquery.Profiler; -import org.exist.xquery.XPathException; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.value.BooleanValue; -import org.exist.xquery.value.FunctionParameterSequenceType; -import org.exist.xquery.value.FunctionReturnSequenceType; -import org.exist.xquery.value.Item; -import org.exist.xquery.value.NodeValue; -import org.exist.xquery.value.Sequence; -import org.exist.xquery.value.SequenceType; -import org.exist.xquery.value.Type; -import org.w3c.dom.Node; - -/** - * Built-in function fn:last(). - * - * @author wolf - */ -public class FunNilled extends BasicFunction { - - public final static FunctionSignature signature = - new FunctionSignature( - new QName("nilled", Function.BUILTIN_FUNCTION_NS), - "Returns an xs:boolean indicating whether the argument node is \"nilled\". " + - "If the argument is not an element node, returns the empty sequence. " + - "If the argument is the empty sequence, returns the empty sequence.", - new SequenceType[] { new FunctionParameterSequenceType("arg", Type.NODE, Cardinality.ZERO_OR_ONE, "The input node") }, - new FunctionReturnSequenceType(Type.BOOLEAN, Cardinality.ZERO_OR_ONE, "true if the argument node is \"nilled\"")); - - public FunNilled(XQueryContext context) { - super(context, signature); - } - - public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { - if (context.getProfiler().isEnabled()) { - context.getProfiler().start(this); - context.getProfiler().message(this, Profiler.DEPENDENCIES, "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies())); - if (contextSequence != null) - {context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence);} - } - - Sequence result; - if (args[0].isEmpty()) - {result = Sequence.EMPTY_SEQUENCE;} - else { - final Item arg = args[0].itemAt(0); - if (!Type.subTypeOf(arg.getType(), Type.ELEMENT)) - {result = Sequence.EMPTY_SEQUENCE;} - else { - final Node n = ((NodeValue)arg).getNode(); - //TODO : think more... - if (n.hasAttributes()) { - final Node nilled = n.getAttributes().getNamedItemNS(Namespaces.SCHEMA_INSTANCE_NS, "nil"); - if (nilled != null) - {result = new BooleanValue(nilled.getNodeValue() == "false");} - else - {result = BooleanValue.FALSE;} - } else - {result = BooleanValue.FALSE;} - } - } - - - if (context.getProfiler().isEnabled()) - {context.getProfiler().end(this, "", result);} - - return result; - - } - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2000-2007 The eXist team + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id$ + */ + +package org.exist.xquery.functions.fn; + +import org.exist.Namespaces; +import org.exist.dom.QName; +import org.exist.xquery.BasicFunction; +import org.exist.xquery.Cardinality; +import org.exist.xquery.Dependency; +import org.exist.xquery.Function; +import org.exist.xquery.FunctionSignature; +import org.exist.xquery.Profiler; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.value.BooleanValue; +import org.exist.xquery.value.FunctionParameterSequenceType; +import org.exist.xquery.value.FunctionReturnSequenceType; +import org.exist.xquery.value.Item; +import org.exist.xquery.value.NodeValue; +import org.exist.xquery.value.Sequence; +import org.exist.xquery.value.SequenceType; +import org.exist.xquery.value.Type; +import org.w3c.dom.Node; + +/** + * Built-in function fn:last(). + * + * @author wolf + */ +public class FunNilled extends BasicFunction { + + public final static FunctionSignature signature = + new FunctionSignature( + new QName("nilled", Function.BUILTIN_FUNCTION_NS), + "Returns an xs:boolean indicating whether the argument node is \"nilled\". " + + "If the argument is not an element node, returns the empty sequence. " + + "If the argument is the empty sequence, returns the empty sequence.", + new SequenceType[] { new FunctionParameterSequenceType("arg", Type.NODE, Cardinality.ZERO_OR_ONE, "The input node") }, + new FunctionReturnSequenceType(Type.BOOLEAN, Cardinality.ZERO_OR_ONE, "true if the argument node is \"nilled\"")); + + public FunNilled(XQueryContext context) { + super(context, signature); + } + + public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { + if (context.getProfiler().isEnabled()) { + context.getProfiler().start(this); + context.getProfiler().message(this, Profiler.DEPENDENCIES, "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies())); + if (contextSequence != null) + {context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence);} + } + + Sequence result; + if (args[0].isEmpty()) + {result = Sequence.EMPTY_SEQUENCE;} + else { + final Item arg = args[0].itemAt(0); + if (!Type.subTypeOf(arg.getType(), Type.ELEMENT)) + {result = Sequence.EMPTY_SEQUENCE;} + else { + final Node n = ((NodeValue)arg).getNode(); + //TODO : think more... + if (n.hasAttributes()) { + final Node nilled = n.getAttributes().getNamedItemNS(Namespaces.SCHEMA_INSTANCE_NS, "nil"); + if (nilled != null) + {result = new BooleanValue(nilled.getNodeValue() == "false");} + else + {result = BooleanValue.FALSE;} + } else + {result = BooleanValue.FALSE;} + } + } + + + if (context.getProfiler().isEnabled()) + {context.getProfiler().end(this, "", result);} + + return result; + + } + +} diff --git a/src/org/exist/xquery/functions/fn/FunTrace.java b/src/org/exist/xquery/functions/fn/FunTrace.java index 0ff8b83f906..8805c837f78 100644 --- a/src/org/exist/xquery/functions/fn/FunTrace.java +++ b/src/org/exist/xquery/functions/fn/FunTrace.java @@ -1,139 +1,139 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ -package org.exist.xquery.functions.fn; - -import java.io.StringWriter; -import java.io.Writer; -import org.exist.dom.QName; -import org.exist.storage.serializers.Serializer; -import org.exist.xquery.BasicFunction; -import org.exist.xquery.Cardinality; -import org.exist.xquery.Function; -import org.exist.xquery.FunctionSignature; -import org.exist.xquery.XPathException; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.value.FunctionParameterSequenceType; -import org.exist.xquery.value.FunctionReturnSequenceType; -import org.exist.xquery.value.Item; -import org.exist.xquery.value.NodeValue; -import org.exist.xquery.value.Sequence; -import org.exist.xquery.value.SequenceIterator; -import org.exist.xquery.value.SequenceType; -import org.exist.xquery.value.Type; -import org.exist.xquery.value.ValueSequence; -import org.xml.sax.SAXException; - -/** - * @author Dannes Wessels - * @author Wolfgang Meier (wolfgang@exist-db.org) - */ -public class FunTrace extends BasicFunction { - - public final static FunctionSignature signature = - new FunctionSignature( - new QName("trace", Function.BUILTIN_FUNCTION_NS), - "This function is intended to be used in debugging queries by " - +"providing a trace of their execution. The input $value is " - +"returned, unchanged, as the result of the function. " - +"In addition, the inputs $value, converted to an xs:string, " - +"and $label is directed to a trace data set in the eXist log files.", - new SequenceType[] { - new FunctionParameterSequenceType("value", Type.ITEM, Cardinality.ZERO_OR_MORE, "The value"), - new FunctionParameterSequenceType("label", Type.STRING, Cardinality.EXACTLY_ONE, "The label in the log file") - }, - new FunctionReturnSequenceType(Type.ITEM, Cardinality.ZERO_OR_MORE, "the labelled $value in the log") - ); - - public FunTrace(XQueryContext context) { - super(context, signature); - } - -/* - * (non-Javadoc) - * @see org.exist.xquery.BasicFunction#eval(Sequence[], Sequence) - */ - public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { - - // TODO Add TRACE log statements using log4j - // TODO Figure out why XQTS still does not work - // TODO Remove unneeded comments - - String label = args[1].getStringValue(); - if(label==null){ - label=""; - } - - final Serializer serializer= context.getBroker().getSerializer(); - - Sequence result ; - - if(args[0].isEmpty()){ - result = Sequence.EMPTY_SEQUENCE; - - } else { - // Copy all Items from input to output sequence - result = new ValueSequence(); - - int position = 0; - - for (final SequenceIterator i = args[0].iterate(); i.hasNext();) { - - // Get item - final Item next = i.nextItem(); - - // Only write if debug mode - if (true) { - - String value = null; - position++; - - final int type = next.getType(); - - // Serialize an element type - if (Type.ELEMENT == type) { - final Writer sw = new StringWriter(); - try { - serializer.serialize((NodeValue) next, sw); - - } catch (final SAXException ex) { - LOG.error(ex.getMessage()); - } - value = sw.toString(); - - // Get string value for other types - } else { - value = next.getStringValue(); - - } - - // Write to log - LOG.info(label + " [" + position + "]: " + Type.getTypeName(type) + ": " + value); - } - - // Add to result - result.add(next); - } - } - - return result; - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id$ + */ +package org.exist.xquery.functions.fn; + +import java.io.StringWriter; +import java.io.Writer; +import org.exist.dom.QName; +import org.exist.storage.serializers.Serializer; +import org.exist.xquery.BasicFunction; +import org.exist.xquery.Cardinality; +import org.exist.xquery.Function; +import org.exist.xquery.FunctionSignature; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.value.FunctionParameterSequenceType; +import org.exist.xquery.value.FunctionReturnSequenceType; +import org.exist.xquery.value.Item; +import org.exist.xquery.value.NodeValue; +import org.exist.xquery.value.Sequence; +import org.exist.xquery.value.SequenceIterator; +import org.exist.xquery.value.SequenceType; +import org.exist.xquery.value.Type; +import org.exist.xquery.value.ValueSequence; +import org.xml.sax.SAXException; + +/** + * @author Dannes Wessels + * @author Wolfgang Meier (wolfgang@exist-db.org) + */ +public class FunTrace extends BasicFunction { + + public final static FunctionSignature signature = + new FunctionSignature( + new QName("trace", Function.BUILTIN_FUNCTION_NS), + "This function is intended to be used in debugging queries by " + +"providing a trace of their execution. The input $value is " + +"returned, unchanged, as the result of the function. " + +"In addition, the inputs $value, converted to an xs:string, " + +"and $label is directed to a trace data set in the eXist log files.", + new SequenceType[] { + new FunctionParameterSequenceType("value", Type.ITEM, Cardinality.ZERO_OR_MORE, "The value"), + new FunctionParameterSequenceType("label", Type.STRING, Cardinality.EXACTLY_ONE, "The label in the log file") + }, + new FunctionReturnSequenceType(Type.ITEM, Cardinality.ZERO_OR_MORE, "the labelled $value in the log") + ); + + public FunTrace(XQueryContext context) { + super(context, signature); + } + +/* + * (non-Javadoc) + * @see org.exist.xquery.BasicFunction#eval(Sequence[], Sequence) + */ + public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { + + // TODO Add TRACE log statements using log4j + // TODO Figure out why XQTS still does not work + // TODO Remove unneeded comments + + String label = args[1].getStringValue(); + if(label==null){ + label=""; + } + + final Serializer serializer= context.getBroker().getSerializer(); + + Sequence result ; + + if(args[0].isEmpty()){ + result = Sequence.EMPTY_SEQUENCE; + + } else { + // Copy all Items from input to output sequence + result = new ValueSequence(); + + int position = 0; + + for (final SequenceIterator i = args[0].iterate(); i.hasNext();) { + + // Get item + final Item next = i.nextItem(); + + // Only write if debug mode + if (true) { + + String value = null; + position++; + + final int type = next.getType(); + + // Serialize an element type + if (Type.ELEMENT == type) { + final Writer sw = new StringWriter(); + try { + serializer.serialize((NodeValue) next, sw); + + } catch (final SAXException ex) { + LOG.error(ex.getMessage()); + } + value = sw.toString(); + + // Get string value for other types + } else { + value = next.getStringValue(); + + } + + // Write to log + LOG.info(label + " [" + position + "]: " + Type.getTypeName(type) + ": " + value); + } + + // Add to result + result.add(next); + } + } + + return result; + } +} diff --git a/src/org/exist/xquery/functions/math/MathModule.java b/src/org/exist/xquery/functions/math/MathModule.java index 2219180f35f..a9f2cbddc65 100644 --- a/src/org/exist/xquery/functions/math/MathModule.java +++ b/src/org/exist/xquery/functions/math/MathModule.java @@ -1,82 +1,82 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2012 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.xquery.functions.math; - -import java.util.List; -import java.util.Map; -import org.exist.xquery.AbstractInternalModule; -import org.exist.xquery.FunctionDef; - -/** - * eXist module for mathematical operations. - * - * @author Dannes Wessels - * @author ljo - */ -public class MathModule extends AbstractInternalModule { - - public final static String NAMESPACE_URI = "http://www.w3.org/2005/xpath-functions/math"; - - public final static String PREFIX = "math"; - public final static String INCLUSION_DATE = "2012-12-05"; - public final static String RELEASED_IN_VERSION = "eXist-2.0"; - - private final static FunctionDef functions[] = { - - new FunctionDef(OneParamFunctions.FNS_ACOS, OneParamFunctions.class), - new FunctionDef(OneParamFunctions.FNS_ASIN, OneParamFunctions.class), - new FunctionDef(OneParamFunctions.FNS_ATAN, OneParamFunctions.class), - new FunctionDef(OneParamFunctions.FNS_COS, OneParamFunctions.class), - new FunctionDef(OneParamFunctions.FNS_EXP, OneParamFunctions.class), - new FunctionDef(OneParamFunctions.FNS_EXP10, OneParamFunctions.class), - new FunctionDef(OneParamFunctions.FNS_LOG, OneParamFunctions.class), - new FunctionDef(OneParamFunctions.FNS_LOG10, OneParamFunctions.class), - new FunctionDef(OneParamFunctions.FNS_SIN, OneParamFunctions.class), - new FunctionDef(OneParamFunctions.FNS_SQRT, OneParamFunctions.class), - new FunctionDef(OneParamFunctions.FNS_TAN, OneParamFunctions.class), - - new FunctionDef(NoParamFunctions.FNS_PI, NoParamFunctions.class), - - new FunctionDef(TwoParamFunctions.FNS_ATAN2, TwoParamFunctions.class), - new FunctionDef(TwoParamFunctions.FNS_POW, TwoParamFunctions.class) - }; - - public MathModule(Map> parameters) { - super(functions, parameters); - } - - public String getNamespaceURI() { - return NAMESPACE_URI; - } - - public String getDefaultPrefix() { - return PREFIX; - } - - public String getDescription() { - return "A module containing functions for common mathematical operations."; - } - - public String getReleaseVersion() { - return RELEASED_IN_VERSION; - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2012 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.xquery.functions.math; + +import java.util.List; +import java.util.Map; +import org.exist.xquery.AbstractInternalModule; +import org.exist.xquery.FunctionDef; + +/** + * eXist module for mathematical operations. + * + * @author Dannes Wessels + * @author ljo + */ +public class MathModule extends AbstractInternalModule { + + public final static String NAMESPACE_URI = "http://www.w3.org/2005/xpath-functions/math"; + + public final static String PREFIX = "math"; + public final static String INCLUSION_DATE = "2012-12-05"; + public final static String RELEASED_IN_VERSION = "eXist-2.0"; + + private final static FunctionDef functions[] = { + + new FunctionDef(OneParamFunctions.FNS_ACOS, OneParamFunctions.class), + new FunctionDef(OneParamFunctions.FNS_ASIN, OneParamFunctions.class), + new FunctionDef(OneParamFunctions.FNS_ATAN, OneParamFunctions.class), + new FunctionDef(OneParamFunctions.FNS_COS, OneParamFunctions.class), + new FunctionDef(OneParamFunctions.FNS_EXP, OneParamFunctions.class), + new FunctionDef(OneParamFunctions.FNS_EXP10, OneParamFunctions.class), + new FunctionDef(OneParamFunctions.FNS_LOG, OneParamFunctions.class), + new FunctionDef(OneParamFunctions.FNS_LOG10, OneParamFunctions.class), + new FunctionDef(OneParamFunctions.FNS_SIN, OneParamFunctions.class), + new FunctionDef(OneParamFunctions.FNS_SQRT, OneParamFunctions.class), + new FunctionDef(OneParamFunctions.FNS_TAN, OneParamFunctions.class), + + new FunctionDef(NoParamFunctions.FNS_PI, NoParamFunctions.class), + + new FunctionDef(TwoParamFunctions.FNS_ATAN2, TwoParamFunctions.class), + new FunctionDef(TwoParamFunctions.FNS_POW, TwoParamFunctions.class) + }; + + public MathModule(Map> parameters) { + super(functions, parameters); + } + + public String getNamespaceURI() { + return NAMESPACE_URI; + } + + public String getDefaultPrefix() { + return PREFIX; + } + + public String getDescription() { + return "A module containing functions for common mathematical operations."; + } + + public String getReleaseVersion() { + return RELEASED_IN_VERSION; + } +} diff --git a/src/org/exist/xquery/functions/math/NoParamFunctions.java b/src/org/exist/xquery/functions/math/NoParamFunctions.java index 5913f8c73fd..91182f7be0d 100644 --- a/src/org/exist/xquery/functions/math/NoParamFunctions.java +++ b/src/org/exist/xquery/functions/math/NoParamFunctions.java @@ -1,98 +1,98 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2012 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.xquery.functions.math; - -import org.apache.log4j.Logger; -import org.exist.dom.QName; -import org.exist.xquery.BasicFunction; -import org.exist.xquery.Cardinality; -import org.exist.xquery.Dependency; -import org.exist.xquery.FunctionSignature; -import org.exist.xquery.Profiler; -import org.exist.xquery.XPathException; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.value.DoubleValue; -import org.exist.xquery.value.FunctionReturnSequenceType; -import org.exist.xquery.value.Sequence; -import org.exist.xquery.value.Type; - -/** - * Class containing math functions that accept no parameters. - * - * @author Dannes Wessels - */ -public class NoParamFunctions extends BasicFunction { - - //private static final Logger logger = Logger.getLogger(NoParamFunctions.class); - - public static final String PI = "pi"; - - public final static FunctionSignature FNS_PI = new FunctionSignature( - new QName(PI, MathModule.NAMESPACE_URI), - "Returns the value of pi.", - null, - new FunctionReturnSequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE, "the value of pi") - ); - - /** - * @param context - */ - public NoParamFunctions(XQueryContext context, FunctionSignature signature) { - super(context, signature); - } - - public int getDependencies() { - return Dependency.NO_DEPENDENCY; - } - - /* (non-Javadoc) - * @see org.exist.xquery.Expression#eval(org.exist.dom.DocumentSet, org.exist.xquery.value.Sequence, org.exist.xquery.value.Item) - */ - public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { - - if (context.getProfiler().isEnabled()) { - context.getProfiler().start(this); - context.getProfiler().message(this, Profiler.DEPENDENCIES, "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies())); - if (contextSequence != null){ - context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence); - } - } - - - Sequence result; - final String functionName = getSignature().getName().getLocalName(); - if(PI.equals(functionName)) { - result=new DoubleValue(Math.PI); - - } else { - throw new XPathException(this, "Function "+functionName+" not found."); - } - - - if (context.getProfiler().isEnabled()){ - context.getProfiler().end(this, "", result); - } - - return result; - } - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2012 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.xquery.functions.math; + +import org.apache.log4j.Logger; +import org.exist.dom.QName; +import org.exist.xquery.BasicFunction; +import org.exist.xquery.Cardinality; +import org.exist.xquery.Dependency; +import org.exist.xquery.FunctionSignature; +import org.exist.xquery.Profiler; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.value.DoubleValue; +import org.exist.xquery.value.FunctionReturnSequenceType; +import org.exist.xquery.value.Sequence; +import org.exist.xquery.value.Type; + +/** + * Class containing math functions that accept no parameters. + * + * @author Dannes Wessels + */ +public class NoParamFunctions extends BasicFunction { + + //private static final Logger logger = Logger.getLogger(NoParamFunctions.class); + + public static final String PI = "pi"; + + public final static FunctionSignature FNS_PI = new FunctionSignature( + new QName(PI, MathModule.NAMESPACE_URI), + "Returns the value of pi.", + null, + new FunctionReturnSequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE, "the value of pi") + ); + + /** + * @param context + */ + public NoParamFunctions(XQueryContext context, FunctionSignature signature) { + super(context, signature); + } + + public int getDependencies() { + return Dependency.NO_DEPENDENCY; + } + + /* (non-Javadoc) + * @see org.exist.xquery.Expression#eval(org.exist.dom.DocumentSet, org.exist.xquery.value.Sequence, org.exist.xquery.value.Item) + */ + public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { + + if (context.getProfiler().isEnabled()) { + context.getProfiler().start(this); + context.getProfiler().message(this, Profiler.DEPENDENCIES, "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies())); + if (contextSequence != null){ + context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence); + } + } + + + Sequence result; + final String functionName = getSignature().getName().getLocalName(); + if(PI.equals(functionName)) { + result=new DoubleValue(Math.PI); + + } else { + throw new XPathException(this, "Function "+functionName+" not found."); + } + + + if (context.getProfiler().isEnabled()){ + context.getProfiler().end(this, "", result); + } + + return result; + } + +} diff --git a/src/org/exist/xquery/functions/math/OneParamFunctions.java b/src/org/exist/xquery/functions/math/OneParamFunctions.java index f9714a72cac..b9ba9353934 100644 --- a/src/org/exist/xquery/functions/math/OneParamFunctions.java +++ b/src/org/exist/xquery/functions/math/OneParamFunctions.java @@ -1,215 +1,215 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2012 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.xquery.functions.math; - -import org.apache.log4j.Logger; -import org.exist.dom.QName; -import org.exist.xquery.BasicFunction; -import org.exist.xquery.Cardinality; -import org.exist.xquery.Dependency; -import org.exist.xquery.FunctionSignature; -import org.exist.xquery.Profiler; -import org.exist.xquery.XPathException; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.value.DoubleValue; -import org.exist.xquery.value.FunctionParameterSequenceType; -import org.exist.xquery.value.FunctionReturnSequenceType; -import org.exist.xquery.value.NumericValue; -import org.exist.xquery.value.Sequence; -import org.exist.xquery.value.SequenceType; -import org.exist.xquery.value.Type; - -/** - * Class containing math functions that accept one parameter. - * - * @author Dannes Wessels - */ -public class OneParamFunctions extends BasicFunction { - - //private static final Logger logger = Logger.getLogger(OneParamFunctions.class); - - public static final String ACOS = "acos"; - public static final String ASIN = "asin"; - public static final String ATAN = "atan"; - public static final String COS = "cos"; - public static final String EXP = "exp"; - public static final String EXP10 = "exp10"; - public static final String LOG = "log"; - public static final String LOG10 = "log10"; - public static final String SIN = "sin"; - public static final String SQRT = "sqrt"; - public static final String TAN = "tan"; - - public final static FunctionSignature FNS_ACOS = new FunctionSignature( - new QName(ACOS, MathModule.NAMESPACE_URI), - "Returns the arc cosine of the argument, the result being in the range zero to +π radians.", - new SequenceType[] { new FunctionParameterSequenceType("arg", Type.DOUBLE, Cardinality.EXACTLY_ONE, "The input number") }, - new FunctionReturnSequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE, "the result") - ); - - public final static FunctionSignature FNS_ASIN = new FunctionSignature( - new QName(ASIN, MathModule.NAMESPACE_URI), - "Returns the arc sine of the argument, the result being in the range -π/2 to +π/2 radians.", - new SequenceType[] { new FunctionParameterSequenceType("arg", Type.DOUBLE, Cardinality.EXACTLY_ONE, "The input number") }, - new FunctionReturnSequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE, "result") - ); - - public final static FunctionSignature FNS_ATAN = new FunctionSignature( - new QName(ATAN, MathModule.NAMESPACE_URI), - "Returns the arc tangent of the argument, the result being in the range -π/2 to +π/2 radians.", - new SequenceType[] { new FunctionParameterSequenceType("arg", Type.DOUBLE, Cardinality.EXACTLY_ONE, "The input number") }, - new FunctionReturnSequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE, "the result") - ); - - public final static FunctionSignature FNS_COS = new FunctionSignature( - new QName(COS, MathModule.NAMESPACE_URI), - "Returns the cosine of the argument, expressed in radians.", - new SequenceType[] { new FunctionParameterSequenceType("arg", Type.DOUBLE, Cardinality.EXACTLY_ONE, "The input number") }, - new FunctionReturnSequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE, "the cosine") - ); - - public final static FunctionSignature FNS_EXP = new FunctionSignature( - new QName(EXP, MathModule.NAMESPACE_URI), - "Calculates e (the Euler Constant) raised to the power of $arg", - new SequenceType[] { new FunctionParameterSequenceType("arg", Type.DOUBLE, Cardinality.EXACTLY_ONE, "The input number") }, - new FunctionReturnSequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE, "e (the Euler Constant) raised to the power of a value or expression") - ); - - public final static FunctionSignature FNS_EXP10 = new FunctionSignature( // NEW - new QName(EXP10, MathModule.NAMESPACE_URI), - "Calculates 10 raised to the power of $arg", - new SequenceType[] { new FunctionParameterSequenceType("arg", Type.DOUBLE, Cardinality.EXACTLY_ONE, "The input number") }, - new FunctionReturnSequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE, "e (the Euler Constant) raised to the power of a value or expression") - ); - - public final static FunctionSignature FNS_LOG = new FunctionSignature( - new QName(LOG, MathModule.NAMESPACE_URI), - "Returns the natural logarithm of the argument.", - new SequenceType[] { new FunctionParameterSequenceType("arg", Type.DOUBLE, Cardinality.EXACTLY_ONE, "The input number") }, - new FunctionReturnSequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE, "the log") - ); - - public final static FunctionSignature FNS_LOG10 = new FunctionSignature( // NEW - new QName(LOG10, MathModule.NAMESPACE_URI), - "Returns the base-ten logarithm of the argument.", - new SequenceType[] { new FunctionParameterSequenceType("arg", Type.DOUBLE, Cardinality.EXACTLY_ONE, "The input number") }, - new FunctionReturnSequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE, "the log") - ); - - public final static FunctionSignature FNS_SIN = new FunctionSignature( - new QName(SIN, MathModule.NAMESPACE_URI), - "Returns the sine of the argument, expressed in radians.", - new SequenceType[] { new FunctionParameterSequenceType("arg", Type.DOUBLE, Cardinality.EXACTLY_ONE, "The input number") }, - new FunctionReturnSequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE, "the sine") - ); - - public final static FunctionSignature FNS_SQRT = new FunctionSignature( - new QName(SQRT, MathModule.NAMESPACE_URI), - "Returns the non-negative square root of the argument.", - new SequenceType[] { new FunctionParameterSequenceType("arg", Type.DOUBLE, Cardinality.EXACTLY_ONE, "The input number") }, - new FunctionReturnSequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE, "the square root of $x") - ); - - public final static FunctionSignature FNS_TAN = new FunctionSignature( - new QName(TAN, MathModule.NAMESPACE_URI), - "Returns the tangent of the argument, expressed in radians.", - new SequenceType[] { new FunctionParameterSequenceType("arg", Type.DOUBLE, Cardinality.EXACTLY_ONE, "The radians") }, - new FunctionReturnSequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE, "the tangent") - ); - - /** - * @param context - */ - public OneParamFunctions(XQueryContext context, FunctionSignature signature) { - super(context, signature); - } - - /* (non-Javadoc) - * @see org.exist.xquery.Expression#eval(org.exist.dom.DocumentSet, org.exist.xquery.value.Sequence, org.exist.xquery.value.Item) - */ - public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { - - if (context.getProfiler().isEnabled()) { - context.getProfiler().start(this); - context.getProfiler().message(this, Profiler.DEPENDENCIES, "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies())); - if (contextSequence != null) { - context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence); - } - } - - Sequence result; - final Sequence seq = args[0].convertTo(Type.DOUBLE); - final NumericValue value = (NumericValue) seq.itemAt(0).convertTo(Type.DOUBLE); - - if (seq.isEmpty()) { - result = Sequence.EMPTY_SEQUENCE; - - } else { - double calcValue = 0; - final String functionName = getSignature().getName().getLocalName(); - if (ACOS.equals(functionName)) { - calcValue = Math.acos(value.getDouble()); - - } else if (ASIN.equals(functionName)) { - calcValue = Math.asin(value.getDouble()); - - } else if (ATAN.equals(functionName)) { - calcValue = Math.atan(value.getDouble()); - - } else if (COS.equals(functionName)) { - calcValue = Math.cos(value.getDouble()); - - } else if (EXP.equals(functionName)) { - calcValue = Math.exp(value.getDouble()); - - } else if (EXP10.equals(functionName)) { - calcValue = Math.pow(10.0d, value.getDouble()); - - } else if (LOG.equals(functionName)) { - calcValue = Math.log(value.getDouble()); - - } else if (LOG10.equals(functionName)) { - calcValue = Math.log10(value.getDouble()); - - } else if (SIN.equals(functionName)) { - calcValue = Math.sin(value.getDouble()); - - } else if (SQRT.equals(functionName)) { - calcValue = Math.sqrt(value.getDouble()); - - } else if (TAN.equals(functionName)) { - calcValue = Math.tan(value.getDouble()); - - } else { - throw new XPathException(this, "Function " + functionName + " not found."); - } - result = new DoubleValue(calcValue); - } - - if (context.getProfiler().isEnabled()) { - context.getProfiler().end(this, "", result); - } - - return result; - } - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2012 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.xquery.functions.math; + +import org.apache.log4j.Logger; +import org.exist.dom.QName; +import org.exist.xquery.BasicFunction; +import org.exist.xquery.Cardinality; +import org.exist.xquery.Dependency; +import org.exist.xquery.FunctionSignature; +import org.exist.xquery.Profiler; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.value.DoubleValue; +import org.exist.xquery.value.FunctionParameterSequenceType; +import org.exist.xquery.value.FunctionReturnSequenceType; +import org.exist.xquery.value.NumericValue; +import org.exist.xquery.value.Sequence; +import org.exist.xquery.value.SequenceType; +import org.exist.xquery.value.Type; + +/** + * Class containing math functions that accept one parameter. + * + * @author Dannes Wessels + */ +public class OneParamFunctions extends BasicFunction { + + //private static final Logger logger = Logger.getLogger(OneParamFunctions.class); + + public static final String ACOS = "acos"; + public static final String ASIN = "asin"; + public static final String ATAN = "atan"; + public static final String COS = "cos"; + public static final String EXP = "exp"; + public static final String EXP10 = "exp10"; + public static final String LOG = "log"; + public static final String LOG10 = "log10"; + public static final String SIN = "sin"; + public static final String SQRT = "sqrt"; + public static final String TAN = "tan"; + + public final static FunctionSignature FNS_ACOS = new FunctionSignature( + new QName(ACOS, MathModule.NAMESPACE_URI), + "Returns the arc cosine of the argument, the result being in the range zero to +π radians.", + new SequenceType[] { new FunctionParameterSequenceType("arg", Type.DOUBLE, Cardinality.EXACTLY_ONE, "The input number") }, + new FunctionReturnSequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE, "the result") + ); + + public final static FunctionSignature FNS_ASIN = new FunctionSignature( + new QName(ASIN, MathModule.NAMESPACE_URI), + "Returns the arc sine of the argument, the result being in the range -π/2 to +π/2 radians.", + new SequenceType[] { new FunctionParameterSequenceType("arg", Type.DOUBLE, Cardinality.EXACTLY_ONE, "The input number") }, + new FunctionReturnSequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE, "result") + ); + + public final static FunctionSignature FNS_ATAN = new FunctionSignature( + new QName(ATAN, MathModule.NAMESPACE_URI), + "Returns the arc tangent of the argument, the result being in the range -π/2 to +π/2 radians.", + new SequenceType[] { new FunctionParameterSequenceType("arg", Type.DOUBLE, Cardinality.EXACTLY_ONE, "The input number") }, + new FunctionReturnSequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE, "the result") + ); + + public final static FunctionSignature FNS_COS = new FunctionSignature( + new QName(COS, MathModule.NAMESPACE_URI), + "Returns the cosine of the argument, expressed in radians.", + new SequenceType[] { new FunctionParameterSequenceType("arg", Type.DOUBLE, Cardinality.EXACTLY_ONE, "The input number") }, + new FunctionReturnSequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE, "the cosine") + ); + + public final static FunctionSignature FNS_EXP = new FunctionSignature( + new QName(EXP, MathModule.NAMESPACE_URI), + "Calculates e (the Euler Constant) raised to the power of $arg", + new SequenceType[] { new FunctionParameterSequenceType("arg", Type.DOUBLE, Cardinality.EXACTLY_ONE, "The input number") }, + new FunctionReturnSequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE, "e (the Euler Constant) raised to the power of a value or expression") + ); + + public final static FunctionSignature FNS_EXP10 = new FunctionSignature( // NEW + new QName(EXP10, MathModule.NAMESPACE_URI), + "Calculates 10 raised to the power of $arg", + new SequenceType[] { new FunctionParameterSequenceType("arg", Type.DOUBLE, Cardinality.EXACTLY_ONE, "The input number") }, + new FunctionReturnSequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE, "e (the Euler Constant) raised to the power of a value or expression") + ); + + public final static FunctionSignature FNS_LOG = new FunctionSignature( + new QName(LOG, MathModule.NAMESPACE_URI), + "Returns the natural logarithm of the argument.", + new SequenceType[] { new FunctionParameterSequenceType("arg", Type.DOUBLE, Cardinality.EXACTLY_ONE, "The input number") }, + new FunctionReturnSequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE, "the log") + ); + + public final static FunctionSignature FNS_LOG10 = new FunctionSignature( // NEW + new QName(LOG10, MathModule.NAMESPACE_URI), + "Returns the base-ten logarithm of the argument.", + new SequenceType[] { new FunctionParameterSequenceType("arg", Type.DOUBLE, Cardinality.EXACTLY_ONE, "The input number") }, + new FunctionReturnSequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE, "the log") + ); + + public final static FunctionSignature FNS_SIN = new FunctionSignature( + new QName(SIN, MathModule.NAMESPACE_URI), + "Returns the sine of the argument, expressed in radians.", + new SequenceType[] { new FunctionParameterSequenceType("arg", Type.DOUBLE, Cardinality.EXACTLY_ONE, "The input number") }, + new FunctionReturnSequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE, "the sine") + ); + + public final static FunctionSignature FNS_SQRT = new FunctionSignature( + new QName(SQRT, MathModule.NAMESPACE_URI), + "Returns the non-negative square root of the argument.", + new SequenceType[] { new FunctionParameterSequenceType("arg", Type.DOUBLE, Cardinality.EXACTLY_ONE, "The input number") }, + new FunctionReturnSequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE, "the square root of $x") + ); + + public final static FunctionSignature FNS_TAN = new FunctionSignature( + new QName(TAN, MathModule.NAMESPACE_URI), + "Returns the tangent of the argument, expressed in radians.", + new SequenceType[] { new FunctionParameterSequenceType("arg", Type.DOUBLE, Cardinality.EXACTLY_ONE, "The radians") }, + new FunctionReturnSequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE, "the tangent") + ); + + /** + * @param context + */ + public OneParamFunctions(XQueryContext context, FunctionSignature signature) { + super(context, signature); + } + + /* (non-Javadoc) + * @see org.exist.xquery.Expression#eval(org.exist.dom.DocumentSet, org.exist.xquery.value.Sequence, org.exist.xquery.value.Item) + */ + public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { + + if (context.getProfiler().isEnabled()) { + context.getProfiler().start(this); + context.getProfiler().message(this, Profiler.DEPENDENCIES, "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies())); + if (contextSequence != null) { + context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence); + } + } + + Sequence result; + final Sequence seq = args[0].convertTo(Type.DOUBLE); + final NumericValue value = (NumericValue) seq.itemAt(0).convertTo(Type.DOUBLE); + + if (seq.isEmpty()) { + result = Sequence.EMPTY_SEQUENCE; + + } else { + double calcValue = 0; + final String functionName = getSignature().getName().getLocalName(); + if (ACOS.equals(functionName)) { + calcValue = Math.acos(value.getDouble()); + + } else if (ASIN.equals(functionName)) { + calcValue = Math.asin(value.getDouble()); + + } else if (ATAN.equals(functionName)) { + calcValue = Math.atan(value.getDouble()); + + } else if (COS.equals(functionName)) { + calcValue = Math.cos(value.getDouble()); + + } else if (EXP.equals(functionName)) { + calcValue = Math.exp(value.getDouble()); + + } else if (EXP10.equals(functionName)) { + calcValue = Math.pow(10.0d, value.getDouble()); + + } else if (LOG.equals(functionName)) { + calcValue = Math.log(value.getDouble()); + + } else if (LOG10.equals(functionName)) { + calcValue = Math.log10(value.getDouble()); + + } else if (SIN.equals(functionName)) { + calcValue = Math.sin(value.getDouble()); + + } else if (SQRT.equals(functionName)) { + calcValue = Math.sqrt(value.getDouble()); + + } else if (TAN.equals(functionName)) { + calcValue = Math.tan(value.getDouble()); + + } else { + throw new XPathException(this, "Function " + functionName + " not found."); + } + result = new DoubleValue(calcValue); + } + + if (context.getProfiler().isEnabled()) { + context.getProfiler().end(this, "", result); + } + + return result; + } + +} diff --git a/src/org/exist/xquery/functions/math/TwoParamFunctions.java b/src/org/exist/xquery/functions/math/TwoParamFunctions.java index 0421c11b4c2..792f81ceb72 100644 --- a/src/org/exist/xquery/functions/math/TwoParamFunctions.java +++ b/src/org/exist/xquery/functions/math/TwoParamFunctions.java @@ -1,125 +1,125 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2012 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.xquery.functions.math; - -import org.apache.log4j.Logger; -import org.exist.dom.QName; -import org.exist.xquery.BasicFunction; -import org.exist.xquery.Cardinality; -import org.exist.xquery.Dependency; -import org.exist.xquery.FunctionSignature; -import org.exist.xquery.Profiler; -import org.exist.xquery.XPathException; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.value.DoubleValue; -import org.exist.xquery.value.FunctionParameterSequenceType; -import org.exist.xquery.value.FunctionReturnSequenceType; -import org.exist.xquery.value.NumericValue; -import org.exist.xquery.value.Sequence; -import org.exist.xquery.value.SequenceType; -import org.exist.xquery.value.Type; - -/** - * Class containing math functions that accept two parameters. - * - * @author Dannes Wessels - */ -public class TwoParamFunctions extends BasicFunction { - - @SuppressWarnings("unused") - private static final Logger logger = Logger.getLogger(TwoParamFunctions.class); - - public static final String ATAN2 = "atan2"; - public static final String POW = "pow"; - - - public final static FunctionSignature FNS_ATAN2 = new FunctionSignature( - new QName(ATAN2, MathModule.NAMESPACE_URI), - "Returns the angle in radians subtended at the origin by the point on a " - + "plane with coordinates (x, y) and the positive x-axis, the result being in the range -π to +π.", - new SequenceType[] { - new FunctionParameterSequenceType("y", Type.DOUBLE, Cardinality.EXACTLY_ONE, "The y coordinate"), - new FunctionParameterSequenceType("x", Type.DOUBLE, Cardinality.EXACTLY_ONE, "The x coordinate") - }, - new FunctionReturnSequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE, "the theta component of the point (r, theta) in polar coordinates that corresponds to the point (x, y) in Cartesian coordinates.") - ); - - public final static FunctionSignature FNS_POW = new FunctionSignature( - new QName(POW, MathModule.NAMESPACE_URI), - "Returns the result of raising the first argument to the power of the second.", - new SequenceType[] { - new FunctionParameterSequenceType("value", Type.DOUBLE, Cardinality.EXACTLY_ONE, "The value"), - new FunctionParameterSequenceType("power", Type.NUMBER, Cardinality.EXACTLY_ONE, "The power to raise the value to") - }, - new FunctionReturnSequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE, "the result") - ); - - /** - * @param context - */ - public TwoParamFunctions(XQueryContext context, FunctionSignature signature) { - super(context, signature); - } - - /* (non-Javadoc) - * @see org.exist.xquery.Expression#eval(org.exist.dom.DocumentSet, org.exist.xquery.value.Sequence, org.exist.xquery.value.Item) - */ - public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { - if (context.getProfiler().isEnabled()) { - context.getProfiler().start(this); - context.getProfiler().message(this, Profiler.DEPENDENCIES, "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies())); - if (contextSequence != null){ - context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence); - } - } - - - Sequence result; - double calcValue=0; - final String functionName = getSignature().getName().getLocalName(); - - final Sequence seqA = args[0].convertTo(Type.DOUBLE); - final NumericValue valueA = (NumericValue)seqA.itemAt(0).convertTo(Type.DOUBLE); - - final Sequence seqB = args[1].convertTo(Type.DOUBLE); - final NumericValue valueB = (NumericValue)seqB.itemAt(0).convertTo(Type.DOUBLE); - - if(ATAN2.equals(functionName)) { - calcValue = Math.atan2(valueA.getDouble(), valueB.getDouble()); - - } else if(POW.equals(functionName)) { - calcValue=Math.pow(valueA.getDouble(), valueB.getDouble()); - - } else { - throw new XPathException(this, "Function "+functionName+" not found."); - } - result=new DoubleValue(calcValue); - - - if (context.getProfiler().isEnabled()){ - context.getProfiler().end(this, "", result); - } - - return result; - } - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2012 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.xquery.functions.math; + +import org.apache.log4j.Logger; +import org.exist.dom.QName; +import org.exist.xquery.BasicFunction; +import org.exist.xquery.Cardinality; +import org.exist.xquery.Dependency; +import org.exist.xquery.FunctionSignature; +import org.exist.xquery.Profiler; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.value.DoubleValue; +import org.exist.xquery.value.FunctionParameterSequenceType; +import org.exist.xquery.value.FunctionReturnSequenceType; +import org.exist.xquery.value.NumericValue; +import org.exist.xquery.value.Sequence; +import org.exist.xquery.value.SequenceType; +import org.exist.xquery.value.Type; + +/** + * Class containing math functions that accept two parameters. + * + * @author Dannes Wessels + */ +public class TwoParamFunctions extends BasicFunction { + + @SuppressWarnings("unused") + private static final Logger logger = Logger.getLogger(TwoParamFunctions.class); + + public static final String ATAN2 = "atan2"; + public static final String POW = "pow"; + + + public final static FunctionSignature FNS_ATAN2 = new FunctionSignature( + new QName(ATAN2, MathModule.NAMESPACE_URI), + "Returns the angle in radians subtended at the origin by the point on a " + + "plane with coordinates (x, y) and the positive x-axis, the result being in the range -π to +π.", + new SequenceType[] { + new FunctionParameterSequenceType("y", Type.DOUBLE, Cardinality.EXACTLY_ONE, "The y coordinate"), + new FunctionParameterSequenceType("x", Type.DOUBLE, Cardinality.EXACTLY_ONE, "The x coordinate") + }, + new FunctionReturnSequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE, "the theta component of the point (r, theta) in polar coordinates that corresponds to the point (x, y) in Cartesian coordinates.") + ); + + public final static FunctionSignature FNS_POW = new FunctionSignature( + new QName(POW, MathModule.NAMESPACE_URI), + "Returns the result of raising the first argument to the power of the second.", + new SequenceType[] { + new FunctionParameterSequenceType("value", Type.DOUBLE, Cardinality.EXACTLY_ONE, "The value"), + new FunctionParameterSequenceType("power", Type.NUMBER, Cardinality.EXACTLY_ONE, "The power to raise the value to") + }, + new FunctionReturnSequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE, "the result") + ); + + /** + * @param context + */ + public TwoParamFunctions(XQueryContext context, FunctionSignature signature) { + super(context, signature); + } + + /* (non-Javadoc) + * @see org.exist.xquery.Expression#eval(org.exist.dom.DocumentSet, org.exist.xquery.value.Sequence, org.exist.xquery.value.Item) + */ + public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { + if (context.getProfiler().isEnabled()) { + context.getProfiler().start(this); + context.getProfiler().message(this, Profiler.DEPENDENCIES, "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies())); + if (contextSequence != null){ + context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence); + } + } + + + Sequence result; + double calcValue=0; + final String functionName = getSignature().getName().getLocalName(); + + final Sequence seqA = args[0].convertTo(Type.DOUBLE); + final NumericValue valueA = (NumericValue)seqA.itemAt(0).convertTo(Type.DOUBLE); + + final Sequence seqB = args[1].convertTo(Type.DOUBLE); + final NumericValue valueB = (NumericValue)seqB.itemAt(0).convertTo(Type.DOUBLE); + + if(ATAN2.equals(functionName)) { + calcValue = Math.atan2(valueA.getDouble(), valueB.getDouble()); + + } else if(POW.equals(functionName)) { + calcValue=Math.pow(valueA.getDouble(), valueB.getDouble()); + + } else { + throw new XPathException(this, "Function "+functionName+" not found."); + } + result=new DoubleValue(calcValue); + + + if (context.getProfiler().isEnabled()){ + context.getProfiler().end(this, "", result); + } + + return result; + } + +} diff --git a/src/org/exist/xquery/functions/system/GetRevision.java b/src/org/exist/xquery/functions/system/GetRevision.java index 7d8beb551ba..26f759f8d13 100644 --- a/src/org/exist/xquery/functions/system/GetRevision.java +++ b/src/org/exist/xquery/functions/system/GetRevision.java @@ -1,62 +1,62 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-09 Wolfgang M. Meier - * wolfgang@exist-db.org - * http://exist.sourceforge.net - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id$ - */ -package org.exist.xquery.functions.system; - -import org.exist.SystemProperties; -import org.exist.dom.QName; -import org.exist.xquery.BasicFunction; -import org.exist.xquery.Cardinality; -import org.exist.xquery.FunctionSignature; -import org.exist.xquery.XPathException; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.value.FunctionReturnSequenceType; -import org.exist.xquery.value.Sequence; -import org.exist.xquery.value.StringValue; -import org.exist.xquery.value.Type; - -/** - * Return the Subversion revision. - * - * @author Dannes Wessels - */ -public class GetRevision extends BasicFunction { - - public final static FunctionSignature signature = new FunctionSignature( - new QName("get-revision", SystemModule.NAMESPACE_URI, SystemModule.PREFIX), - "Returns the SubVersion (SVN) revision ID of eXist running this query.", - FunctionSignature.NO_ARGS, - new FunctionReturnSequenceType(Type.STRING, Cardinality.EXACTLY_ONE, "the revision ID.") - ); - - public GetRevision(XQueryContext context) { - super(context, signature); - } - - /* (non-Javadoc) - * @see org.exist.xquery.BasicFunction#eval(org.exist.xquery.value.Sequence[], org.exist.xquery.value.Sequence) - */ - @Override - public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { - return new StringValue(SystemProperties.getInstance().getSystemProperty("svn-revision", "unknown revision")); - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-09 Wolfgang M. Meier + * wolfgang@exist-db.org + * http://exist.sourceforge.net + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ +package org.exist.xquery.functions.system; + +import org.exist.SystemProperties; +import org.exist.dom.QName; +import org.exist.xquery.BasicFunction; +import org.exist.xquery.Cardinality; +import org.exist.xquery.FunctionSignature; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.value.FunctionReturnSequenceType; +import org.exist.xquery.value.Sequence; +import org.exist.xquery.value.StringValue; +import org.exist.xquery.value.Type; + +/** + * Return the Subversion revision. + * + * @author Dannes Wessels + */ +public class GetRevision extends BasicFunction { + + public final static FunctionSignature signature = new FunctionSignature( + new QName("get-revision", SystemModule.NAMESPACE_URI, SystemModule.PREFIX), + "Returns the SubVersion (SVN) revision ID of eXist running this query.", + FunctionSignature.NO_ARGS, + new FunctionReturnSequenceType(Type.STRING, Cardinality.EXACTLY_ONE, "the revision ID.") + ); + + public GetRevision(XQueryContext context) { + super(context, signature); + } + + /* (non-Javadoc) + * @see org.exist.xquery.BasicFunction#eval(org.exist.xquery.value.Sequence[], org.exist.xquery.value.Sequence) + */ + @Override + public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { + return new StringValue(SystemProperties.getInstance().getSystemProperty("svn-revision", "unknown revision")); + } +} diff --git a/src/org/exist/xquery/functions/system/TriggerSystemTask.java b/src/org/exist/xquery/functions/system/TriggerSystemTask.java index 92f71091fe3..3c15b58e152 100644 --- a/src/org/exist/xquery/functions/system/TriggerSystemTask.java +++ b/src/org/exist/xquery/functions/system/TriggerSystemTask.java @@ -1,127 +1,127 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-09 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.xquery.functions.system; - -import java.util.Properties; - -import org.apache.log4j.Logger; -import org.exist.EXistException; -import org.exist.dom.QName; -import org.exist.storage.SystemTask; -import org.exist.xquery.BasicFunction; -import org.exist.xquery.Cardinality; -import org.exist.xquery.FunctionSignature; -import org.exist.xquery.XPathException; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.value.FunctionParameterSequenceType; -import org.exist.xquery.value.NodeValue; -import org.exist.xquery.value.Sequence; -import org.exist.xquery.value.SequenceType; -import org.exist.xquery.value.Type; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -/** - * - */ -public class TriggerSystemTask extends BasicFunction { - - protected final static Logger logger = Logger.getLogger(TriggerSystemTask.class); - - public final static FunctionSignature signature = - new FunctionSignature( - new QName("trigger-system-task", SystemModule.NAMESPACE_URI, SystemModule.PREFIX), - "Trigger a system task.", - new SequenceType[]{ - new FunctionParameterSequenceType("java-classname", Type.STRING, Cardinality.EXACTLY_ONE, "The full name of the Java class to execute. It must implement org.exist.storage.SystemTask"), - new FunctionParameterSequenceType("task-parameters", Type.NODE, Cardinality.ZERO_OR_ONE, "The XML fragment with the following structure: ") - }, - new SequenceType(Type.ITEM, Cardinality.EMPTY)); - - - public TriggerSystemTask(XQueryContext context) { - super(context, signature); - } - - public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { - final String className = args[0].getStringValue(); - final Properties properties = new Properties(); - if (args[1].hasOne()) { - parseParameters(((NodeValue) args[1].itemAt(0)).getNode(), properties); - } - - try { - final Class clazz = Class.forName(className); - final Object taskObject = clazz.newInstance(); - - if (!(taskObject instanceof SystemTask)) { - final XPathException xPathException = new XPathException(this, className + " is not an instance of org.exist.storage.SystemTask"); - logger.error("Java classname is not a SystemTask", xPathException); - throw xPathException; - } - - final SystemTask task = (SystemTask) taskObject; - task.configure(context.getBroker().getConfiguration(), properties); - LOG.info("Triggering SystemTask: " + className); - context.getBroker().getBrokerPool().triggerSystemTask(task); - - } catch (final ClassNotFoundException e) { - final String message = "system task class '" + className + "' not found"; - logger.error(message, e); - throw new XPathException(this, message); - - } catch (final InstantiationException e) { - final String message = "system task '" + className + "' can not be instantiated"; - logger.error(message, e); - throw new XPathException(this, message); - - } catch (final IllegalAccessException e) { - final String message = "system task '" + className + "' can not be accessed"; - logger.error(message, e); - throw new XPathException(this, message); - - } catch (final EXistException e) { - final String message = "system task " + className + " reported an error during initialization: "; - logger.error(message, e); - throw new XPathException(this, message + e.getMessage(), e); - } - return Sequence.EMPTY_SEQUENCE; - } - - private void parseParameters(Node options, Properties properties) throws XPathException { - if(options.getNodeType() == Node.ELEMENT_NODE && "parameters".equals(options.getLocalName())) { - Node child = options.getFirstChild(); - while(child != null) { - if(child.getNodeType() == Node.ELEMENT_NODE && "param".equals(child.getLocalName())) { - final Element elem = (Element)child; - final String name = elem.getAttribute("name"); - final String value = elem.getAttribute("value"); - logger.trace("parseParameters: name[" + name + "] value[" + value + "]"); - if(name == null || value == null) - {throw new XPathException(this, "Name or value attribute missing for stylesheet parameter");} - properties.setProperty(name, value); - } - child = child.getNextSibling(); - } - } - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-09 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.xquery.functions.system; + +import java.util.Properties; + +import org.apache.log4j.Logger; +import org.exist.EXistException; +import org.exist.dom.QName; +import org.exist.storage.SystemTask; +import org.exist.xquery.BasicFunction; +import org.exist.xquery.Cardinality; +import org.exist.xquery.FunctionSignature; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.value.FunctionParameterSequenceType; +import org.exist.xquery.value.NodeValue; +import org.exist.xquery.value.Sequence; +import org.exist.xquery.value.SequenceType; +import org.exist.xquery.value.Type; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +/** + * + */ +public class TriggerSystemTask extends BasicFunction { + + protected final static Logger logger = Logger.getLogger(TriggerSystemTask.class); + + public final static FunctionSignature signature = + new FunctionSignature( + new QName("trigger-system-task", SystemModule.NAMESPACE_URI, SystemModule.PREFIX), + "Trigger a system task.", + new SequenceType[]{ + new FunctionParameterSequenceType("java-classname", Type.STRING, Cardinality.EXACTLY_ONE, "The full name of the Java class to execute. It must implement org.exist.storage.SystemTask"), + new FunctionParameterSequenceType("task-parameters", Type.NODE, Cardinality.ZERO_OR_ONE, "The XML fragment with the following structure: ") + }, + new SequenceType(Type.ITEM, Cardinality.EMPTY)); + + + public TriggerSystemTask(XQueryContext context) { + super(context, signature); + } + + public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { + final String className = args[0].getStringValue(); + final Properties properties = new Properties(); + if (args[1].hasOne()) { + parseParameters(((NodeValue) args[1].itemAt(0)).getNode(), properties); + } + + try { + final Class clazz = Class.forName(className); + final Object taskObject = clazz.newInstance(); + + if (!(taskObject instanceof SystemTask)) { + final XPathException xPathException = new XPathException(this, className + " is not an instance of org.exist.storage.SystemTask"); + logger.error("Java classname is not a SystemTask", xPathException); + throw xPathException; + } + + final SystemTask task = (SystemTask) taskObject; + task.configure(context.getBroker().getConfiguration(), properties); + LOG.info("Triggering SystemTask: " + className); + context.getBroker().getBrokerPool().triggerSystemTask(task); + + } catch (final ClassNotFoundException e) { + final String message = "system task class '" + className + "' not found"; + logger.error(message, e); + throw new XPathException(this, message); + + } catch (final InstantiationException e) { + final String message = "system task '" + className + "' can not be instantiated"; + logger.error(message, e); + throw new XPathException(this, message); + + } catch (final IllegalAccessException e) { + final String message = "system task '" + className + "' can not be accessed"; + logger.error(message, e); + throw new XPathException(this, message); + + } catch (final EXistException e) { + final String message = "system task " + className + " reported an error during initialization: "; + logger.error(message, e); + throw new XPathException(this, message + e.getMessage(), e); + } + return Sequence.EMPTY_SEQUENCE; + } + + private void parseParameters(Node options, Properties properties) throws XPathException { + if(options.getNodeType() == Node.ELEMENT_NODE && "parameters".equals(options.getLocalName())) { + Node child = options.getFirstChild(); + while(child != null) { + if(child.getNodeType() == Node.ELEMENT_NODE && "param".equals(child.getLocalName())) { + final Element elem = (Element)child; + final String name = elem.getAttribute("name"); + final String value = elem.getAttribute("value"); + logger.trace("parseParameters: name[" + name + "] value[" + value + "]"); + if(name == null || value == null) + {throw new XPathException(this, "Name or value attribute missing for stylesheet parameter");} + properties.setProperty(name, value); + } + child = child.getNextSibling(); + } + } + } +} diff --git a/src/org/exist/xquery/functions/text/Tokenize.java b/src/org/exist/xquery/functions/text/Tokenize.java index 8e858d00392..a3691575c3a 100644 --- a/src/org/exist/xquery/functions/text/Tokenize.java +++ b/src/org/exist/xquery/functions/text/Tokenize.java @@ -1,78 +1,78 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-09 Wolfgang M. Meier - * wolfgang@exist-db.org - * http://exist.sourceforge.net - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id: FuzzyIndexTerms.java 3063 2006-04-05 20:49:44Z brihaye $ - */ -package org.exist.xquery.functions.text; - - -import org.exist.dom.QName; -import org.exist.storage.analysis.SimpleTokenizer; -import org.exist.storage.analysis.TextToken; -import org.exist.xquery.BasicFunction; -import org.exist.xquery.Cardinality; -import org.exist.xquery.FunctionSignature; -import org.exist.xquery.XPathException; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.value.FunctionParameterSequenceType; -import org.exist.xquery.value.FunctionReturnSequenceType; -import org.exist.xquery.value.Sequence; -import org.exist.xquery.value.SequenceType; -import org.exist.xquery.value.StringValue; -import org.exist.xquery.value.Type; -import org.exist.xquery.value.ValueSequence; - - - -/** - * @author Wolfgang Meier (wolfgang@exist-db.org) - */ -public class Tokenize extends BasicFunction { - - public final static FunctionSignature signature = new FunctionSignature( - new QName("make-token", TextModule.NAMESPACE_URI, TextModule.PREFIX), - "Split a string into tokens", - new SequenceType[]{ - new FunctionParameterSequenceType("text", Type.STRING, Cardinality.ONE, "The string to tokenize")}, - new FunctionReturnSequenceType(Type.STRING, Cardinality.ZERO_OR_MORE, "a sequence of tokens")); - - public Tokenize(XQueryContext context) { - super(context, signature); - } - - /* (non-Javadoc) - * @see org.exist.xquery.BasicFunction#eval(org.exist.xquery.value.Sequence[], org.exist.xquery.value.Sequence) - */ - public Sequence eval(Sequence[] args, Sequence contextSequence) - throws XPathException { - if(args[0].isEmpty()) - {return Sequence.EMPTY_SEQUENCE;} - - final ValueSequence result = new ValueSequence(); - final SimpleTokenizer tokenizer = new SimpleTokenizer(); - tokenizer.setText(args[0].getStringValue()); - TextToken token = tokenizer.nextToken(false); - while(token != null && token.getType() != TextToken.EOF) { - result.add(new StringValue(token.getText())); - token = tokenizer.nextToken(false); - } - return result; - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-09 Wolfgang M. Meier + * wolfgang@exist-db.org + * http://exist.sourceforge.net + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id: FuzzyIndexTerms.java 3063 2006-04-05 20:49:44Z brihaye $ + */ +package org.exist.xquery.functions.text; + + +import org.exist.dom.QName; +import org.exist.storage.analysis.SimpleTokenizer; +import org.exist.storage.analysis.TextToken; +import org.exist.xquery.BasicFunction; +import org.exist.xquery.Cardinality; +import org.exist.xquery.FunctionSignature; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.value.FunctionParameterSequenceType; +import org.exist.xquery.value.FunctionReturnSequenceType; +import org.exist.xquery.value.Sequence; +import org.exist.xquery.value.SequenceType; +import org.exist.xquery.value.StringValue; +import org.exist.xquery.value.Type; +import org.exist.xquery.value.ValueSequence; + + + +/** + * @author Wolfgang Meier (wolfgang@exist-db.org) + */ +public class Tokenize extends BasicFunction { + + public final static FunctionSignature signature = new FunctionSignature( + new QName("make-token", TextModule.NAMESPACE_URI, TextModule.PREFIX), + "Split a string into tokens", + new SequenceType[]{ + new FunctionParameterSequenceType("text", Type.STRING, Cardinality.ONE, "The string to tokenize")}, + new FunctionReturnSequenceType(Type.STRING, Cardinality.ZERO_OR_MORE, "a sequence of tokens")); + + public Tokenize(XQueryContext context) { + super(context, signature); + } + + /* (non-Javadoc) + * @see org.exist.xquery.BasicFunction#eval(org.exist.xquery.value.Sequence[], org.exist.xquery.value.Sequence) + */ + public Sequence eval(Sequence[] args, Sequence contextSequence) + throws XPathException { + if(args[0].isEmpty()) + {return Sequence.EMPTY_SEQUENCE;} + + final ValueSequence result = new ValueSequence(); + final SimpleTokenizer tokenizer = new SimpleTokenizer(); + tokenizer.setText(args[0].getStringValue()); + TextToken token = tokenizer.nextToken(false); + while(token != null && token.getType() != TextToken.EOF) { + result.add(new StringValue(token.getText())); + token = tokenizer.nextToken(false); + } + return result; + } +} diff --git a/src/org/exist/xquery/functions/util/DeepCopyFunction.java b/src/org/exist/xquery/functions/util/DeepCopyFunction.java index 4732805f9f8..8f46840814c 100644 --- a/src/org/exist/xquery/functions/util/DeepCopyFunction.java +++ b/src/org/exist/xquery/functions/util/DeepCopyFunction.java @@ -1,89 +1,89 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-09 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - * - * Original package com.ocom.leaseman.modules.lease (Scott Warren) - */ -package org.exist.xquery.functions.util; - -import java.util.Properties; - -import org.apache.log4j.Logger; -import org.exist.dom.QName; -import org.exist.memtree.DocumentBuilderReceiver; -import org.exist.memtree.MemTreeBuilder; -import org.exist.xquery.BasicFunction; -import org.exist.xquery.Cardinality; -import org.exist.xquery.FunctionSignature; -import org.exist.xquery.XPathException; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.value.FunctionParameterSequenceType; -import org.exist.xquery.value.FunctionReturnSequenceType; -import org.exist.xquery.value.Item; -import org.exist.xquery.value.NodeValue; -import org.exist.xquery.value.Sequence; -import org.exist.xquery.value.SequenceType; -import org.exist.xquery.value.Type; - -import org.xml.sax.SAXException; - -public class DeepCopyFunction extends BasicFunction { - - protected static final Logger logger = Logger.getLogger(DeepCopyFunction.class); - - public final static FunctionSignature signature = - new FunctionSignature( - new QName("deep-copy", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), - "Performs a Deep Clone of the passed in item.", - new SequenceType[] - { - new FunctionParameterSequenceType("item", Type.ITEM, Cardinality.ZERO_OR_ONE, "The item to be cloned"), - }, - new FunctionReturnSequenceType(Type.ITEM, Cardinality.ZERO_OR_ONE, "the item clone")); - - public DeepCopyFunction(XQueryContext context, FunctionSignature signature) { - super(context, signature); - } - - public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { - - if (args[0].isEmpty()) { - return Sequence.EMPTY_SEQUENCE; - } - - final Item a = args[0].itemAt(0); - - final MemTreeBuilder builder = new MemTreeBuilder(context); - builder.startDocument(); - final DocumentBuilderReceiver receiver = new DocumentBuilderReceiver(builder); - - try { - final Properties props = new Properties(); - a.toSAX(context.getBroker(), receiver, props); - - } catch (final SAXException e) { - throw new XPathException(this, "Cannot Deep-copy Item"); - } - - builder.endDocument(); - - return (NodeValue)receiver.getDocument().getDocumentElement(); - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-09 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + * + * Original package com.ocom.leaseman.modules.lease (Scott Warren) + */ +package org.exist.xquery.functions.util; + +import java.util.Properties; + +import org.apache.log4j.Logger; +import org.exist.dom.QName; +import org.exist.memtree.DocumentBuilderReceiver; +import org.exist.memtree.MemTreeBuilder; +import org.exist.xquery.BasicFunction; +import org.exist.xquery.Cardinality; +import org.exist.xquery.FunctionSignature; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.value.FunctionParameterSequenceType; +import org.exist.xquery.value.FunctionReturnSequenceType; +import org.exist.xquery.value.Item; +import org.exist.xquery.value.NodeValue; +import org.exist.xquery.value.Sequence; +import org.exist.xquery.value.SequenceType; +import org.exist.xquery.value.Type; + +import org.xml.sax.SAXException; + +public class DeepCopyFunction extends BasicFunction { + + protected static final Logger logger = Logger.getLogger(DeepCopyFunction.class); + + public final static FunctionSignature signature = + new FunctionSignature( + new QName("deep-copy", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), + "Performs a Deep Clone of the passed in item.", + new SequenceType[] + { + new FunctionParameterSequenceType("item", Type.ITEM, Cardinality.ZERO_OR_ONE, "The item to be cloned"), + }, + new FunctionReturnSequenceType(Type.ITEM, Cardinality.ZERO_OR_ONE, "the item clone")); + + public DeepCopyFunction(XQueryContext context, FunctionSignature signature) { + super(context, signature); + } + + public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { + + if (args[0].isEmpty()) { + return Sequence.EMPTY_SEQUENCE; + } + + final Item a = args[0].itemAt(0); + + final MemTreeBuilder builder = new MemTreeBuilder(context); + builder.startDocument(); + final DocumentBuilderReceiver receiver = new DocumentBuilderReceiver(builder); + + try { + final Properties props = new Properties(); + a.toSAX(context.getBroker(), receiver, props); + + } catch (final SAXException e) { + throw new XPathException(this, "Cannot Deep-copy Item"); + } + + builder.endDocument(); + + return (NodeValue)receiver.getDocument().getDocumentElement(); + } +} diff --git a/src/org/exist/xquery/functions/util/FunDoctype.java b/src/org/exist/xquery/functions/util/FunDoctype.java index fbd84d8f73a..94b62a303af 100644 --- a/src/org/exist/xquery/functions/util/FunDoctype.java +++ b/src/org/exist/xquery/functions/util/FunDoctype.java @@ -1,96 +1,96 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-09 Wolfgang M. Meier - * wolfgang@exist-db.org - * http://exist.sourceforge.net - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id: ExtDoctype.java 4403 2006-09-27 12:27:37Z wolfgang_m $ - */ -package org.exist.xquery.functions.util; - -import org.apache.log4j.Logger; -import org.exist.dom.*; -import org.exist.numbering.NodeId; -import org.exist.xquery.*; -import org.exist.xquery.value.*; - -import java.util.Iterator; -import org.exist.security.PermissionDeniedException; - -/** - * @author wolf - */ -public class FunDoctype extends Function { - - protected static final Logger logger = Logger.getLogger(FunDoctype.class); - - public final static FunctionSignature signature = - new FunctionSignature( - new QName("doctype", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), - "Returns the document nodes of the documents with the given DOCTYPE(s).", - new SequenceType[] { - new FunctionParameterSequenceType("doctype", Type.STRING, Cardinality.ONE_OR_MORE, "The DOCTYPE of the documents to find")}, - new FunctionReturnSequenceType(Type.NODE, Cardinality.ZERO_OR_MORE, "the document nodes"), - true); - - /** - * @param context - */ - public FunDoctype(XQueryContext context) { - super(context, signature); - } - - /* (non-Javadoc) - * @see org.exist.xquery.Expression#eval(org.exist.dom.DocumentSet, org.exist.xquery.value.Sequence, org.exist.xquery.value.Item) - */ - public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathException { - - if (context.getProfiler().isEnabled()) { - context.getProfiler().start(this); - context.getProfiler().message(this, Profiler.DEPENDENCIES, "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies())); - if (contextSequence != null) - {context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence);} - if (contextItem != null) - {context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT ITEM", contextItem.toSequence());} - } - - final MutableDocumentSet docs = new DefaultDocumentSet(); - for (int i = 0; i < getArgumentCount(); i++) { - final Sequence seq = getArgument(i).eval(contextSequence, contextItem); - for (final SequenceIterator j = seq.iterate(); j.hasNext();) { - final String next = j.nextItem().getStringValue(); - try { - context.getBroker().getXMLResourcesByDoctype(next, docs); - } catch(final PermissionDeniedException pde) { - LOG.error(pde.getMessage(), pde); - throw new XPathException(pde); - } - } - } - - final NodeSet result = new ExtArrayNodeSet(1); - for (final Iterator i = docs.getDocumentIterator(); i.hasNext();) { - result.add(new NodeProxy(i.next(), NodeId.DOCUMENT_NODE)); - } - - if (context.getProfiler().isEnabled()) - {context.getProfiler().end(this, "", result);} - - return result; - } - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-09 Wolfgang M. Meier + * wolfgang@exist-db.org + * http://exist.sourceforge.net + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id: ExtDoctype.java 4403 2006-09-27 12:27:37Z wolfgang_m $ + */ +package org.exist.xquery.functions.util; + +import org.apache.log4j.Logger; +import org.exist.dom.*; +import org.exist.numbering.NodeId; +import org.exist.xquery.*; +import org.exist.xquery.value.*; + +import java.util.Iterator; +import org.exist.security.PermissionDeniedException; + +/** + * @author wolf + */ +public class FunDoctype extends Function { + + protected static final Logger logger = Logger.getLogger(FunDoctype.class); + + public final static FunctionSignature signature = + new FunctionSignature( + new QName("doctype", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), + "Returns the document nodes of the documents with the given DOCTYPE(s).", + new SequenceType[] { + new FunctionParameterSequenceType("doctype", Type.STRING, Cardinality.ONE_OR_MORE, "The DOCTYPE of the documents to find")}, + new FunctionReturnSequenceType(Type.NODE, Cardinality.ZERO_OR_MORE, "the document nodes"), + true); + + /** + * @param context + */ + public FunDoctype(XQueryContext context) { + super(context, signature); + } + + /* (non-Javadoc) + * @see org.exist.xquery.Expression#eval(org.exist.dom.DocumentSet, org.exist.xquery.value.Sequence, org.exist.xquery.value.Item) + */ + public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathException { + + if (context.getProfiler().isEnabled()) { + context.getProfiler().start(this); + context.getProfiler().message(this, Profiler.DEPENDENCIES, "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies())); + if (contextSequence != null) + {context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence);} + if (contextItem != null) + {context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT ITEM", contextItem.toSequence());} + } + + final MutableDocumentSet docs = new DefaultDocumentSet(); + for (int i = 0; i < getArgumentCount(); i++) { + final Sequence seq = getArgument(i).eval(contextSequence, contextItem); + for (final SequenceIterator j = seq.iterate(); j.hasNext();) { + final String next = j.nextItem().getStringValue(); + try { + context.getBroker().getXMLResourcesByDoctype(next, docs); + } catch(final PermissionDeniedException pde) { + LOG.error(pde.getMessage(), pde); + throw new XPathException(pde); + } + } + } + + final NodeSet result = new ExtArrayNodeSet(1); + for (final Iterator i = docs.getDocumentIterator(); i.hasNext();) { + result.add(new NodeProxy(i.next(), NodeId.DOCUMENT_NODE)); + } + + if (context.getProfiler().isEnabled()) + {context.getProfiler().end(this, "", result);} + + return result; + } + +} diff --git a/src/org/exist/xquery/functions/util/GetSequenceType.java b/src/org/exist/xquery/functions/util/GetSequenceType.java index 23a727d2b13..d6306ae6141 100644 --- a/src/org/exist/xquery/functions/util/GetSequenceType.java +++ b/src/org/exist/xquery/functions/util/GetSequenceType.java @@ -1,63 +1,63 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2009 The eXist team - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id: Compile.java 5533 2007-03-26 13:55:42Z ellefj $ - */ -package org.exist.xquery.functions.util; - -import org.apache.log4j.Logger; -import org.exist.dom.QName; -import org.exist.xquery.BasicFunction; -import org.exist.xquery.Cardinality; -import org.exist.xquery.FunctionSignature; -import org.exist.xquery.XPathException; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.value.FunctionParameterSequenceType; -import org.exist.xquery.value.FunctionReturnSequenceType; -import org.exist.xquery.value.Sequence; -import org.exist.xquery.value.SequenceType; -import org.exist.xquery.value.StringValue; -import org.exist.xquery.value.Type; - -public class GetSequenceType extends BasicFunction { - - protected static final Logger logger = Logger.getLogger(GetSequenceType.class); - - public final static FunctionSignature signature = - new FunctionSignature( - new QName("get-sequence-type", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), - "Returns the string representation of the type of sequence.", - new SequenceType[] { - new FunctionParameterSequenceType("sequence-type", Type.ANY_TYPE, Cardinality.ZERO_OR_MORE, "The type of sequence") - }, - new FunctionReturnSequenceType(Type.STRING, Cardinality.EXACTLY_ONE, "the string representation of the type of sequence")); - - public GetSequenceType(XQueryContext context) { - super(context, signature); - } - - public Sequence eval(Sequence[] args, Sequence contextSequence) - throws XPathException { - - final Sequence seq = args[0]; - final StringValue stringValue = new StringValue(Type.getTypeName(seq.getItemType())); - return stringValue; - } - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2009 The eXist team + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id: Compile.java 5533 2007-03-26 13:55:42Z ellefj $ + */ +package org.exist.xquery.functions.util; + +import org.apache.log4j.Logger; +import org.exist.dom.QName; +import org.exist.xquery.BasicFunction; +import org.exist.xquery.Cardinality; +import org.exist.xquery.FunctionSignature; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.value.FunctionParameterSequenceType; +import org.exist.xquery.value.FunctionReturnSequenceType; +import org.exist.xquery.value.Sequence; +import org.exist.xquery.value.SequenceType; +import org.exist.xquery.value.StringValue; +import org.exist.xquery.value.Type; + +public class GetSequenceType extends BasicFunction { + + protected static final Logger logger = Logger.getLogger(GetSequenceType.class); + + public final static FunctionSignature signature = + new FunctionSignature( + new QName("get-sequence-type", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), + "Returns the string representation of the type of sequence.", + new SequenceType[] { + new FunctionParameterSequenceType("sequence-type", Type.ANY_TYPE, Cardinality.ZERO_OR_MORE, "The type of sequence") + }, + new FunctionReturnSequenceType(Type.STRING, Cardinality.EXACTLY_ONE, "the string representation of the type of sequence")); + + public GetSequenceType(XQueryContext context) { + super(context, signature); + } + + public Sequence eval(Sequence[] args, Sequence contextSequence) + throws XPathException { + + final Sequence seq = args[0]; + final StringValue stringValue = new StringValue(Type.getTypeName(seq.getItemType())); + return stringValue; + } + +} diff --git a/src/org/exist/xquery/functions/util/IndexKeyDocuments.java b/src/org/exist/xquery/functions/util/IndexKeyDocuments.java index 827a0e23422..9d32addd386 100644 --- a/src/org/exist/xquery/functions/util/IndexKeyDocuments.java +++ b/src/org/exist/xquery/functions/util/IndexKeyDocuments.java @@ -1,125 +1,125 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2006-2009 The eXist Team - * - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id: QNameIndexLookup.java 3063 2006-04-05 20:49:44Z brihaye $ - */ -package org.exist.xquery.functions.util; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.log4j.Logger; -import org.exist.dom.DocumentSet; -import org.exist.dom.NodeSet; -import org.exist.dom.QName; -import org.exist.indexing.IndexWorker; -import org.exist.indexing.OrderedValuesIndex; -import org.exist.storage.Indexable; -import org.exist.util.Occurrences; -import org.exist.util.ValueOccurrences; -import org.exist.xquery.BasicFunction; -import org.exist.xquery.Cardinality; -import org.exist.xquery.Dependency; -import org.exist.xquery.FunctionSignature; -import org.exist.xquery.Profiler; -import org.exist.xquery.XPathException; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.value.FunctionParameterSequenceType; -import org.exist.xquery.value.FunctionReturnSequenceType; -import org.exist.xquery.value.IntegerValue; -import org.exist.xquery.value.Sequence; -import org.exist.xquery.value.SequenceType; -import org.exist.xquery.value.Type; - -/** - * @author Pierrick Brihaye - */ -public class IndexKeyDocuments extends BasicFunction { - - protected static final Logger logger = Logger.getLogger(IndexKeyDocuments.class); - protected static final FunctionParameterSequenceType nodeParam = new FunctionParameterSequenceType("nodes", Type.NODE, Cardinality.ZERO_OR_MORE, "The nodes whose content is indexed"); - protected static final FunctionParameterSequenceType valueParam = new FunctionParameterSequenceType("value", Type.ATOMIC, Cardinality.EXACTLY_ONE, "The indexed value to search for"); - protected static final FunctionParameterSequenceType indexParam = new FunctionParameterSequenceType("index", Type.STRING, Cardinality.EXACTLY_ONE, "The index in which the search is made"); - protected static final FunctionReturnSequenceType result = new FunctionReturnSequenceType(Type.INTEGER, Cardinality.ZERO_OR_ONE, "the number of documents for the indexed value"); - - public final static FunctionSignature[] signatures = { - new FunctionSignature( - new QName("index-key-documents", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), - "Return the number of documents for an indexed value.", - new SequenceType[] { nodeParam, valueParam }, - result), - new FunctionSignature( - new QName("index-key-documents", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), - "Return the number of documents for an indexed value.", - new SequenceType[] { nodeParam, valueParam, indexParam }, - result) - }; - - public IndexKeyDocuments(XQueryContext context, FunctionSignature signature) { - super(context, signature); - } - - public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { - - if (context.getProfiler().isEnabled()) { - context.getProfiler().start(this); - context.getProfiler().message(this, Profiler.DEPENDENCIES, "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies())); - if (contextSequence != null) - {context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence);} - } - - Sequence result; - if (args[0].isEmpty()) - {result = Sequence.EMPTY_SEQUENCE;} - else { - final NodeSet nodes = args[0].toNodeSet(); - final DocumentSet docs = nodes.getDocumentSet(); - if (this.getArgumentCount() == 3) { - final IndexWorker indexWorker = context.getBroker().getIndexController().getWorkerByIndexName(args[2].itemAt(0).getStringValue()); - //Alternate design - //IndexWorker indexWorker = context.getBroker().getBrokerPool().getIndexManager().getIndexByName(args[2].itemAt(0).getStringValue()).getWorker(); - if (indexWorker == null) - {throw new XPathException(this, "Unknown index: " + args[2].itemAt(0).getStringValue());} - final Map hints = new HashMap(); - if (indexWorker instanceof OrderedValuesIndex) - {hints.put(OrderedValuesIndex.START_VALUE, args[1]);} - else - {logger.warn(indexWorker.getClass().getName() + " isn't an instance of org.exist.indexing.OrderedIndexWorker. Start value '" + args[1] + "' ignored." );} - final Occurrences[] occur = indexWorker.scanIndex(context, docs, nodes, hints); - if (occur.length == 0) - {result= Sequence.EMPTY_SEQUENCE;} - else - {result = new IntegerValue(occur[0].getDocuments());} - } else { - final ValueOccurrences occur[] = context.getBroker().getValueIndex() - .scanIndexKeys(docs, nodes, (Indexable) args[1]); - if (occur.length == 0) - {result= Sequence.EMPTY_SEQUENCE;} - else - {result = new IntegerValue(occur[0].getDocuments());} - } - } - - if (context.getProfiler().isEnabled()) - {context.getProfiler().end(this, "", result);} - - return result; - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2006-2009 The eXist Team + * + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id: QNameIndexLookup.java 3063 2006-04-05 20:49:44Z brihaye $ + */ +package org.exist.xquery.functions.util; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.log4j.Logger; +import org.exist.dom.DocumentSet; +import org.exist.dom.NodeSet; +import org.exist.dom.QName; +import org.exist.indexing.IndexWorker; +import org.exist.indexing.OrderedValuesIndex; +import org.exist.storage.Indexable; +import org.exist.util.Occurrences; +import org.exist.util.ValueOccurrences; +import org.exist.xquery.BasicFunction; +import org.exist.xquery.Cardinality; +import org.exist.xquery.Dependency; +import org.exist.xquery.FunctionSignature; +import org.exist.xquery.Profiler; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.value.FunctionParameterSequenceType; +import org.exist.xquery.value.FunctionReturnSequenceType; +import org.exist.xquery.value.IntegerValue; +import org.exist.xquery.value.Sequence; +import org.exist.xquery.value.SequenceType; +import org.exist.xquery.value.Type; + +/** + * @author Pierrick Brihaye + */ +public class IndexKeyDocuments extends BasicFunction { + + protected static final Logger logger = Logger.getLogger(IndexKeyDocuments.class); + protected static final FunctionParameterSequenceType nodeParam = new FunctionParameterSequenceType("nodes", Type.NODE, Cardinality.ZERO_OR_MORE, "The nodes whose content is indexed"); + protected static final FunctionParameterSequenceType valueParam = new FunctionParameterSequenceType("value", Type.ATOMIC, Cardinality.EXACTLY_ONE, "The indexed value to search for"); + protected static final FunctionParameterSequenceType indexParam = new FunctionParameterSequenceType("index", Type.STRING, Cardinality.EXACTLY_ONE, "The index in which the search is made"); + protected static final FunctionReturnSequenceType result = new FunctionReturnSequenceType(Type.INTEGER, Cardinality.ZERO_OR_ONE, "the number of documents for the indexed value"); + + public final static FunctionSignature[] signatures = { + new FunctionSignature( + new QName("index-key-documents", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), + "Return the number of documents for an indexed value.", + new SequenceType[] { nodeParam, valueParam }, + result), + new FunctionSignature( + new QName("index-key-documents", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), + "Return the number of documents for an indexed value.", + new SequenceType[] { nodeParam, valueParam, indexParam }, + result) + }; + + public IndexKeyDocuments(XQueryContext context, FunctionSignature signature) { + super(context, signature); + } + + public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { + + if (context.getProfiler().isEnabled()) { + context.getProfiler().start(this); + context.getProfiler().message(this, Profiler.DEPENDENCIES, "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies())); + if (contextSequence != null) + {context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence);} + } + + Sequence result; + if (args[0].isEmpty()) + {result = Sequence.EMPTY_SEQUENCE;} + else { + final NodeSet nodes = args[0].toNodeSet(); + final DocumentSet docs = nodes.getDocumentSet(); + if (this.getArgumentCount() == 3) { + final IndexWorker indexWorker = context.getBroker().getIndexController().getWorkerByIndexName(args[2].itemAt(0).getStringValue()); + //Alternate design + //IndexWorker indexWorker = context.getBroker().getBrokerPool().getIndexManager().getIndexByName(args[2].itemAt(0).getStringValue()).getWorker(); + if (indexWorker == null) + {throw new XPathException(this, "Unknown index: " + args[2].itemAt(0).getStringValue());} + final Map hints = new HashMap(); + if (indexWorker instanceof OrderedValuesIndex) + {hints.put(OrderedValuesIndex.START_VALUE, args[1]);} + else + {logger.warn(indexWorker.getClass().getName() + " isn't an instance of org.exist.indexing.OrderedIndexWorker. Start value '" + args[1] + "' ignored." );} + final Occurrences[] occur = indexWorker.scanIndex(context, docs, nodes, hints); + if (occur.length == 0) + {result= Sequence.EMPTY_SEQUENCE;} + else + {result = new IntegerValue(occur[0].getDocuments());} + } else { + final ValueOccurrences occur[] = context.getBroker().getValueIndex() + .scanIndexKeys(docs, nodes, (Indexable) args[1]); + if (occur.length == 0) + {result= Sequence.EMPTY_SEQUENCE;} + else + {result = new IntegerValue(occur[0].getDocuments());} + } + } + + if (context.getProfiler().isEnabled()) + {context.getProfiler().end(this, "", result);} + + return result; + } +} diff --git a/src/org/exist/xquery/functions/util/IndexKeyOccurrences.java b/src/org/exist/xquery/functions/util/IndexKeyOccurrences.java index 9843a408c79..0c2f836d016 100644 --- a/src/org/exist/xquery/functions/util/IndexKeyOccurrences.java +++ b/src/org/exist/xquery/functions/util/IndexKeyOccurrences.java @@ -1,127 +1,127 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2006-2009 The eXist Team - * - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id: QNameIndexLookup.java 3063 2006-04-05 20:49:44Z brihaye $ - */ -package org.exist.xquery.functions.util; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.log4j.Logger; -import org.exist.dom.DocumentSet; -import org.exist.dom.NodeSet; -import org.exist.dom.QName; -import org.exist.indexing.IndexWorker; -import org.exist.indexing.OrderedValuesIndex; -import org.exist.storage.Indexable; -import org.exist.util.Occurrences; -import org.exist.util.ValueOccurrences; -import org.exist.xquery.BasicFunction; -import org.exist.xquery.Cardinality; -import org.exist.xquery.Dependency; -import org.exist.xquery.FunctionSignature; -import org.exist.xquery.Profiler; -import org.exist.xquery.XPathException; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.value.FunctionParameterSequenceType; -import org.exist.xquery.value.FunctionReturnSequenceType; -import org.exist.xquery.value.IntegerValue; -import org.exist.xquery.value.Sequence; -import org.exist.xquery.value.SequenceType; -import org.exist.xquery.value.Type; - -/** - * @author Pierrick Brihaye - */ -public class IndexKeyOccurrences extends BasicFunction { - - protected static final Logger logger = Logger.getLogger(IndexKeyOccurrences.class); - protected static final FunctionParameterSequenceType nodeParam = new FunctionParameterSequenceType("nodes", Type.NODE, Cardinality.ZERO_OR_MORE, "The nodes whose content is indexed"); - protected static final FunctionParameterSequenceType valueParam = new FunctionParameterSequenceType("value", Type.ATOMIC, Cardinality.EXACTLY_ONE, "The indexed value to search for"); - protected static final FunctionParameterSequenceType indexParam = new FunctionParameterSequenceType("index", Type.STRING, Cardinality.EXACTLY_ONE, "The index in which the search is made"); - protected static final FunctionReturnSequenceType result = new FunctionReturnSequenceType(Type.INTEGER, Cardinality.ZERO_OR_ONE, "the number of occurrences for the indexed value"); - - public final static FunctionSignature signatures[] = { - new FunctionSignature( - new QName("index-key-occurrences", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), - "Return the number of occurrences for an indexed value.", - new SequenceType[] { nodeParam, valueParam }, - result), - new FunctionSignature( - new QName("index-key-occurrences", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), - "Return the number of occurrences for an indexed value.", - new SequenceType[] { nodeParam, valueParam, indexParam }, - result) - }; - - public IndexKeyOccurrences(XQueryContext context, FunctionSignature signature) { - super(context, signature); - } - - public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { - - if (context.getProfiler().isEnabled()) { - context.getProfiler().start(this); - context.getProfiler().message(this, Profiler.DEPENDENCIES, "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies())); - if (contextSequence != null) - {context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence);} - } - - Sequence result; - if (args[0].isEmpty()) - {result = Sequence.EMPTY_SEQUENCE;} - else { - final NodeSet nodes = args[0].toNodeSet(); - final DocumentSet docs = nodes.getDocumentSet(); - - if (this.getArgumentCount() == 3){ - final IndexWorker indexWorker = context.getBroker().getIndexController().getWorkerByIndexName(args[2].itemAt(0).getStringValue()); - //Alternate design - //IndexWorker indexWorker = context.getBroker().getBrokerPool().getIndexManager().getIndexByName(args[2].itemAt(0).getStringValue()).getWorker(); - if (indexWorker == null) - {throw new XPathException(this, "Unknown index: " + args[2].itemAt(0).getStringValue());} - final Map hints = new HashMap(); - if (indexWorker instanceof OrderedValuesIndex) - {hints.put(OrderedValuesIndex.START_VALUE, args[1]);} - else - {logger.warn(indexWorker.getClass().getName() + " isn't an instance of org.exist.indexing.OrderedIndexWorker. Start value '" + args[1] + "' ignored." );} - final Occurrences[] occur = indexWorker.scanIndex(context, docs, nodes, hints); - if (occur.length == 0) - {result= Sequence.EMPTY_SEQUENCE;} - else - {result = new IntegerValue(occur[0].getOccurrences());} - } else { - ValueOccurrences occur[] = context.getBroker().getValueIndex().scanIndexKeys(docs, nodes, (Indexable) (args[1].itemAt(0))); - if (occur.length == 0) - {occur = context.getBroker().getValueIndex().scanIndexKeys(docs, nodes, null, (Indexable) (args[1].itemAt(0)));} - if (occur.length == 0) - {result = Sequence.EMPTY_SEQUENCE;} - else - {result = new IntegerValue(occur[0].getOccurrences());} - } - } - - if (context.getProfiler().isEnabled()) - {context.getProfiler().end(this, "", result);} - - return result; - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2006-2009 The eXist Team + * + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id: QNameIndexLookup.java 3063 2006-04-05 20:49:44Z brihaye $ + */ +package org.exist.xquery.functions.util; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.log4j.Logger; +import org.exist.dom.DocumentSet; +import org.exist.dom.NodeSet; +import org.exist.dom.QName; +import org.exist.indexing.IndexWorker; +import org.exist.indexing.OrderedValuesIndex; +import org.exist.storage.Indexable; +import org.exist.util.Occurrences; +import org.exist.util.ValueOccurrences; +import org.exist.xquery.BasicFunction; +import org.exist.xquery.Cardinality; +import org.exist.xquery.Dependency; +import org.exist.xquery.FunctionSignature; +import org.exist.xquery.Profiler; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.value.FunctionParameterSequenceType; +import org.exist.xquery.value.FunctionReturnSequenceType; +import org.exist.xquery.value.IntegerValue; +import org.exist.xquery.value.Sequence; +import org.exist.xquery.value.SequenceType; +import org.exist.xquery.value.Type; + +/** + * @author Pierrick Brihaye + */ +public class IndexKeyOccurrences extends BasicFunction { + + protected static final Logger logger = Logger.getLogger(IndexKeyOccurrences.class); + protected static final FunctionParameterSequenceType nodeParam = new FunctionParameterSequenceType("nodes", Type.NODE, Cardinality.ZERO_OR_MORE, "The nodes whose content is indexed"); + protected static final FunctionParameterSequenceType valueParam = new FunctionParameterSequenceType("value", Type.ATOMIC, Cardinality.EXACTLY_ONE, "The indexed value to search for"); + protected static final FunctionParameterSequenceType indexParam = new FunctionParameterSequenceType("index", Type.STRING, Cardinality.EXACTLY_ONE, "The index in which the search is made"); + protected static final FunctionReturnSequenceType result = new FunctionReturnSequenceType(Type.INTEGER, Cardinality.ZERO_OR_ONE, "the number of occurrences for the indexed value"); + + public final static FunctionSignature signatures[] = { + new FunctionSignature( + new QName("index-key-occurrences", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), + "Return the number of occurrences for an indexed value.", + new SequenceType[] { nodeParam, valueParam }, + result), + new FunctionSignature( + new QName("index-key-occurrences", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), + "Return the number of occurrences for an indexed value.", + new SequenceType[] { nodeParam, valueParam, indexParam }, + result) + }; + + public IndexKeyOccurrences(XQueryContext context, FunctionSignature signature) { + super(context, signature); + } + + public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { + + if (context.getProfiler().isEnabled()) { + context.getProfiler().start(this); + context.getProfiler().message(this, Profiler.DEPENDENCIES, "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies())); + if (contextSequence != null) + {context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence);} + } + + Sequence result; + if (args[0].isEmpty()) + {result = Sequence.EMPTY_SEQUENCE;} + else { + final NodeSet nodes = args[0].toNodeSet(); + final DocumentSet docs = nodes.getDocumentSet(); + + if (this.getArgumentCount() == 3){ + final IndexWorker indexWorker = context.getBroker().getIndexController().getWorkerByIndexName(args[2].itemAt(0).getStringValue()); + //Alternate design + //IndexWorker indexWorker = context.getBroker().getBrokerPool().getIndexManager().getIndexByName(args[2].itemAt(0).getStringValue()).getWorker(); + if (indexWorker == null) + {throw new XPathException(this, "Unknown index: " + args[2].itemAt(0).getStringValue());} + final Map hints = new HashMap(); + if (indexWorker instanceof OrderedValuesIndex) + {hints.put(OrderedValuesIndex.START_VALUE, args[1]);} + else + {logger.warn(indexWorker.getClass().getName() + " isn't an instance of org.exist.indexing.OrderedIndexWorker. Start value '" + args[1] + "' ignored." );} + final Occurrences[] occur = indexWorker.scanIndex(context, docs, nodes, hints); + if (occur.length == 0) + {result= Sequence.EMPTY_SEQUENCE;} + else + {result = new IntegerValue(occur[0].getOccurrences());} + } else { + ValueOccurrences occur[] = context.getBroker().getValueIndex().scanIndexKeys(docs, nodes, (Indexable) (args[1].itemAt(0))); + if (occur.length == 0) + {occur = context.getBroker().getValueIndex().scanIndexKeys(docs, nodes, null, (Indexable) (args[1].itemAt(0)));} + if (occur.length == 0) + {result = Sequence.EMPTY_SEQUENCE;} + else + {result = new IntegerValue(occur[0].getOccurrences());} + } + } + + if (context.getProfiler().isEnabled()) + {context.getProfiler().end(this, "", result);} + + return result; + } +} diff --git a/src/org/exist/xquery/functions/util/IndexType.java b/src/org/exist/xquery/functions/util/IndexType.java index 19d65f079a7..ce9b584974e 100644 --- a/src/org/exist/xquery/functions/util/IndexType.java +++ b/src/org/exist/xquery/functions/util/IndexType.java @@ -1,105 +1,105 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-09 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id$ - */ -package org.exist.xquery.functions.util; - -import org.apache.log4j.Logger; -import org.exist.dom.NodeSet; -import org.exist.dom.QName; -import org.exist.xquery.AnalyzeContextInfo; -import org.exist.xquery.BasicFunction; -import org.exist.xquery.Cardinality; -import org.exist.xquery.Dependency; -import org.exist.xquery.FunctionSignature; -import org.exist.xquery.Profiler; -import org.exist.xquery.XPathException; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.value.FunctionParameterSequenceType; -import org.exist.xquery.value.FunctionReturnSequenceType; -import org.exist.xquery.value.Sequence; -import org.exist.xquery.value.SequenceType; -import org.exist.xquery.value.StringValue; -import org.exist.xquery.value.Type; - -/** - * @author wolf - * - */ -public class IndexType extends BasicFunction { - - protected static final Logger logger = Logger.getLogger(IndexType.class); - - public final static FunctionSignature signature = new FunctionSignature( - new QName("index-type", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), - "Returns the range index type for a set of nodes or an empty sequence if no index is defined. ", - new SequenceType[] { - new FunctionParameterSequenceType("set-of-nodes", Type.NODE, Cardinality.ZERO_OR_MORE, "The set of nodes") - }, - new FunctionReturnSequenceType(Type.STRING, Cardinality.ZERO_OR_ONE, "the range index type")); - - /** - * @param context - */ - public IndexType(XQueryContext context) { - super(context, signature); - } - - public void analyze(AnalyzeContextInfo contextInfo) throws XPathException { - contextInfo.addFlag(NEED_INDEX_INFO); - super.analyze(contextInfo); - contextInfo.removeFlag(NEED_INDEX_INFO); - } - - /* - * (non-Javadoc) - * - * @see org.exist.xquery.BasicFunction#eval(org.exist.xquery.value.Sequence[], - * org.exist.xquery.value.Sequence) - */ - public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { - - if (context.getProfiler().isEnabled()) { - context.getProfiler().start(this); - context.getProfiler().message(this, Profiler.DEPENDENCIES, "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies())); - if (contextSequence != null) - {context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence);} - } - - Sequence result; - - if (args[0].isEmpty()) - {result = Sequence.EMPTY_SEQUENCE;} - else { - final NodeSet nodes = args[0].toNodeSet(); - //Remember it is the default value when no index is defined - if (nodes.getIndexType() == Type.ANY_TYPE) - {result = Sequence.EMPTY_SEQUENCE;} - else - {result = new StringValue(Type.getTypeName(nodes.getIndexType()));} - } - //TODO : consider modularized indexes. We should thus return a * sequence... - - if (context.getProfiler().isEnabled()) - {context.getProfiler().end(this, "", result);} - - return result; - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-09 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ +package org.exist.xquery.functions.util; + +import org.apache.log4j.Logger; +import org.exist.dom.NodeSet; +import org.exist.dom.QName; +import org.exist.xquery.AnalyzeContextInfo; +import org.exist.xquery.BasicFunction; +import org.exist.xquery.Cardinality; +import org.exist.xquery.Dependency; +import org.exist.xquery.FunctionSignature; +import org.exist.xquery.Profiler; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.value.FunctionParameterSequenceType; +import org.exist.xquery.value.FunctionReturnSequenceType; +import org.exist.xquery.value.Sequence; +import org.exist.xquery.value.SequenceType; +import org.exist.xquery.value.StringValue; +import org.exist.xquery.value.Type; + +/** + * @author wolf + * + */ +public class IndexType extends BasicFunction { + + protected static final Logger logger = Logger.getLogger(IndexType.class); + + public final static FunctionSignature signature = new FunctionSignature( + new QName("index-type", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), + "Returns the range index type for a set of nodes or an empty sequence if no index is defined. ", + new SequenceType[] { + new FunctionParameterSequenceType("set-of-nodes", Type.NODE, Cardinality.ZERO_OR_MORE, "The set of nodes") + }, + new FunctionReturnSequenceType(Type.STRING, Cardinality.ZERO_OR_ONE, "the range index type")); + + /** + * @param context + */ + public IndexType(XQueryContext context) { + super(context, signature); + } + + public void analyze(AnalyzeContextInfo contextInfo) throws XPathException { + contextInfo.addFlag(NEED_INDEX_INFO); + super.analyze(contextInfo); + contextInfo.removeFlag(NEED_INDEX_INFO); + } + + /* + * (non-Javadoc) + * + * @see org.exist.xquery.BasicFunction#eval(org.exist.xquery.value.Sequence[], + * org.exist.xquery.value.Sequence) + */ + public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { + + if (context.getProfiler().isEnabled()) { + context.getProfiler().start(this); + context.getProfiler().message(this, Profiler.DEPENDENCIES, "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies())); + if (contextSequence != null) + {context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence);} + } + + Sequence result; + + if (args[0].isEmpty()) + {result = Sequence.EMPTY_SEQUENCE;} + else { + final NodeSet nodes = args[0].toNodeSet(); + //Remember it is the default value when no index is defined + if (nodes.getIndexType() == Type.ANY_TYPE) + {result = Sequence.EMPTY_SEQUENCE;} + else + {result = new StringValue(Type.getTypeName(nodes.getIndexType()));} + } + //TODO : consider modularized indexes. We should thus return a * sequence... + + if (context.getProfiler().isEnabled()) + {context.getProfiler().end(this, "", result);} + + return result; + } +} diff --git a/src/org/exist/xquery/functions/util/UUID.java b/src/org/exist/xquery/functions/util/UUID.java index b1abd4c29dc..87cfcdcc4ef 100644 --- a/src/org/exist/xquery/functions/util/UUID.java +++ b/src/org/exist/xquery/functions/util/UUID.java @@ -1,95 +1,95 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2007-09 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.xquery.functions.util; - -import org.apache.log4j.Logger; - -import org.exist.dom.QName; -import org.exist.security.UUIDGenerator; -import org.exist.xquery.BasicFunction; -import org.exist.xquery.Cardinality; -import org.exist.xquery.FunctionSignature; -import org.exist.xquery.XPathException; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.value.FunctionParameterSequenceType; -import org.exist.xquery.value.FunctionReturnSequenceType; -import org.exist.xquery.value.Sequence; -import org.exist.xquery.value.SequenceType; -import org.exist.xquery.value.StringValue; -import org.exist.xquery.value.Type; -import org.exist.xquery.value.ValueSequence; - -/** - * @author wessels - * @author Loren Cahlander - */ -public class UUID extends BasicFunction { - - private static final Logger logger = Logger.getLogger(UUID.class); - - public final static FunctionSignature signatures[] = { - new FunctionSignature( - new QName("uuid", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), - "Generate a version 4 (random) universally unique identifier (UUID) string, e.g. 154ad200-9c79-44f3-8cff-9780d91552a6", - FunctionSignature.NO_ARGS, - new FunctionReturnSequenceType(Type.STRING, Cardinality.EXACTLY_ONE, "a generated UUID string") - ), - - new FunctionSignature ( - new QName("uuid", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), - "Generate a version 3 universally unique identifier (UUID) string, e.g. 2b92ddb6-8e4e-3891-b519-afa1609ced73", - new SequenceType[]{ - new FunctionParameterSequenceType("name", Type.ITEM, Cardinality.EXACTLY_ONE, - "The input value for UUID calculation."), - }, - new FunctionReturnSequenceType(Type.STRING, Cardinality.EXACTLY_ONE, "a generated UUID string") - ) - }; - - public UUID(XQueryContext context, FunctionSignature signature) { - super(context, signature); - } - - - @Override - public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { - - final Sequence result = new ValueSequence(); - - // Check input parameters - if (args.length == 0) { - final String uuid = UUIDGenerator.getUUIDversion4(); - result.add(new StringValue(uuid)); - - } else if (args.length == 1) { - final String parameter = args[0].getStringValue(); - final String uuid = UUIDGenerator.getUUIDversion3(parameter); - result.add(new StringValue(uuid)); - - } else { - logger.error("Not a supported number of parameters"); - throw new XPathException("Not a supported number of parameters"); - } - - return result; - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2007-09 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.xquery.functions.util; + +import org.apache.log4j.Logger; + +import org.exist.dom.QName; +import org.exist.security.UUIDGenerator; +import org.exist.xquery.BasicFunction; +import org.exist.xquery.Cardinality; +import org.exist.xquery.FunctionSignature; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.value.FunctionParameterSequenceType; +import org.exist.xquery.value.FunctionReturnSequenceType; +import org.exist.xquery.value.Sequence; +import org.exist.xquery.value.SequenceType; +import org.exist.xquery.value.StringValue; +import org.exist.xquery.value.Type; +import org.exist.xquery.value.ValueSequence; + +/** + * @author wessels + * @author Loren Cahlander + */ +public class UUID extends BasicFunction { + + private static final Logger logger = Logger.getLogger(UUID.class); + + public final static FunctionSignature signatures[] = { + new FunctionSignature( + new QName("uuid", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), + "Generate a version 4 (random) universally unique identifier (UUID) string, e.g. 154ad200-9c79-44f3-8cff-9780d91552a6", + FunctionSignature.NO_ARGS, + new FunctionReturnSequenceType(Type.STRING, Cardinality.EXACTLY_ONE, "a generated UUID string") + ), + + new FunctionSignature ( + new QName("uuid", UtilModule.NAMESPACE_URI, UtilModule.PREFIX), + "Generate a version 3 universally unique identifier (UUID) string, e.g. 2b92ddb6-8e4e-3891-b519-afa1609ced73", + new SequenceType[]{ + new FunctionParameterSequenceType("name", Type.ITEM, Cardinality.EXACTLY_ONE, + "The input value for UUID calculation."), + }, + new FunctionReturnSequenceType(Type.STRING, Cardinality.EXACTLY_ONE, "a generated UUID string") + ) + }; + + public UUID(XQueryContext context, FunctionSignature signature) { + super(context, signature); + } + + + @Override + public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { + + final Sequence result = new ValueSequence(); + + // Check input parameters + if (args.length == 0) { + final String uuid = UUIDGenerator.getUUIDversion4(); + result.add(new StringValue(uuid)); + + } else if (args.length == 1) { + final String parameter = args[0].getStringValue(); + final String uuid = UUIDGenerator.getUUIDversion3(parameter); + result.add(new StringValue(uuid)); + + } else { + logger.error("Not a supported number of parameters"); + throw new XPathException("Not a supported number of parameters"); + } + + return result; + } +} diff --git a/src/org/exist/xquery/functions/util/Wait.java b/src/org/exist/xquery/functions/util/Wait.java index 978778d5b3b..103b37e6534 100644 --- a/src/org/exist/xquery/functions/util/Wait.java +++ b/src/org/exist/xquery/functions/util/Wait.java @@ -1,74 +1,74 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2007-09 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id: UUID.java 10203 2009-10-08 15:20:09Z ellefj $ - */ -package org.exist.xquery.functions.util; - -import org.exist.dom.QName; -import org.exist.xquery.BasicFunction; -import org.exist.xquery.Cardinality; -import org.exist.xquery.FunctionSignature; -import org.exist.xquery.XPathException; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.value.FunctionParameterSequenceType; -import org.exist.xquery.value.FunctionReturnSequenceType; -import org.exist.xquery.value.IntegerValue; -import org.exist.xquery.value.Sequence; -import org.exist.xquery.value.SequenceType; -import org.exist.xquery.value.Type; - -/** - * @author Andrzej Taramina - */ -public class Wait extends BasicFunction -{ - public final static FunctionSignature signatures[] = { - new FunctionSignature ( - new QName( "wait", UtilModule.NAMESPACE_URI, UtilModule.PREFIX ), - "Wait for the specified number of milliseconds", - new SequenceType[]{ - new FunctionParameterSequenceType( "interval", Type.INTEGER, Cardinality.EXACTLY_ONE, "Number of milliseconds to wait." ), - }, - new FunctionReturnSequenceType( Type.ITEM, Cardinality.EMPTY, "Returns an empty sequence" ) - ) - }; - - public Wait( XQueryContext context, FunctionSignature signature ) - { - super( context, signature ); - } - - - @Override - public Sequence eval( Sequence[] args, Sequence contextSequence ) throws XPathException - { - final long interval = ((IntegerValue)args[0].itemAt(0)).getLong(); - - if( interval > 0 ) { - try { - Thread.sleep( interval ); - } - catch( final InterruptedException e ) { - } - } - - return( Sequence.EMPTY_SEQUENCE ); - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2007-09 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id: UUID.java 10203 2009-10-08 15:20:09Z ellefj $ + */ +package org.exist.xquery.functions.util; + +import org.exist.dom.QName; +import org.exist.xquery.BasicFunction; +import org.exist.xquery.Cardinality; +import org.exist.xquery.FunctionSignature; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.value.FunctionParameterSequenceType; +import org.exist.xquery.value.FunctionReturnSequenceType; +import org.exist.xquery.value.IntegerValue; +import org.exist.xquery.value.Sequence; +import org.exist.xquery.value.SequenceType; +import org.exist.xquery.value.Type; + +/** + * @author Andrzej Taramina + */ +public class Wait extends BasicFunction +{ + public final static FunctionSignature signatures[] = { + new FunctionSignature ( + new QName( "wait", UtilModule.NAMESPACE_URI, UtilModule.PREFIX ), + "Wait for the specified number of milliseconds", + new SequenceType[]{ + new FunctionParameterSequenceType( "interval", Type.INTEGER, Cardinality.EXACTLY_ONE, "Number of milliseconds to wait." ), + }, + new FunctionReturnSequenceType( Type.ITEM, Cardinality.EMPTY, "Returns an empty sequence" ) + ) + }; + + public Wait( XQueryContext context, FunctionSignature signature ) + { + super( context, signature ); + } + + + @Override + public Sequence eval( Sequence[] args, Sequence contextSequence ) throws XPathException + { + final long interval = ((IntegerValue)args[0].itemAt(0)).getLong(); + + if( interval > 0 ) { + try { + Thread.sleep( interval ); + } + catch( final InterruptedException e ) { + } + } + + return( Sequence.EMPTY_SEQUENCE ); + } +} diff --git a/src/org/exist/xquery/functions/xmldb/FunXCollection.java b/src/org/exist/xquery/functions/xmldb/FunXCollection.java index 3c60ceead78..7502a6e541a 100644 --- a/src/org/exist/xquery/functions/xmldb/FunXCollection.java +++ b/src/org/exist/xquery/functions/xmldb/FunXCollection.java @@ -1,60 +1,60 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2007-2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ -package org.exist.xquery.functions.xmldb; - -//import org.apache.log4j.Logger; - -import org.exist.dom.QName; -import org.exist.xquery.Cardinality; -import org.exist.xquery.FunctionSignature; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.functions.fn.ExtCollection; -import org.exist.xquery.value.FunctionReturnSequenceType; -import org.exist.xquery.value.FunctionParameterSequenceType; -import org.exist.xquery.value.SequenceType; -import org.exist.xquery.value.Type; - -/** - * @author wolf - * @author ljo - */ -public class FunXCollection extends ExtCollection { -// private static final Logger logger = Logger.getLogger(FunXCollection.class); - public final static FunctionSignature signature = - new FunctionSignature( - new QName("xcollection", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), - "Returns the document nodes in the collections $collection-uris " + - "non-recursively, i.e. does not include document nodes found in " + - "sub-collections. " + - "C.f. fn:collection(). " + - XMLDBModule.COLLECTION_URI, - new SequenceType[] { - new FunctionParameterSequenceType("collection-uris", Type.STRING, Cardinality.ONE_OR_MORE, "The collection URIs")}, - new FunctionReturnSequenceType(Type.NODE, Cardinality.ZERO_OR_MORE, "the document nodes from the specified collections excluding sub-collections")); - - /** - * @param context - */ - public FunXCollection(XQueryContext context) { - super(context, signature, false); - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2007-2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id$ + */ +package org.exist.xquery.functions.xmldb; + +//import org.apache.log4j.Logger; + +import org.exist.dom.QName; +import org.exist.xquery.Cardinality; +import org.exist.xquery.FunctionSignature; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.functions.fn.ExtCollection; +import org.exist.xquery.value.FunctionReturnSequenceType; +import org.exist.xquery.value.FunctionParameterSequenceType; +import org.exist.xquery.value.SequenceType; +import org.exist.xquery.value.Type; + +/** + * @author wolf + * @author ljo + */ +public class FunXCollection extends ExtCollection { +// private static final Logger logger = Logger.getLogger(FunXCollection.class); + public final static FunctionSignature signature = + new FunctionSignature( + new QName("xcollection", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), + "Returns the document nodes in the collections $collection-uris " + + "non-recursively, i.e. does not include document nodes found in " + + "sub-collections. " + + "C.f. fn:collection(). " + + XMLDBModule.COLLECTION_URI, + new SequenceType[] { + new FunctionParameterSequenceType("collection-uris", Type.STRING, Cardinality.ONE_OR_MORE, "The collection URIs")}, + new FunctionReturnSequenceType(Type.NODE, Cardinality.ZERO_OR_MORE, "the document nodes from the specified collections excluding sub-collections")); + + /** + * @param context + */ + public FunXCollection(XQueryContext context) { + super(context, signature, false); + } +} diff --git a/src/org/exist/xquery/functions/xmldb/XMLDBDocument.java b/src/org/exist/xquery/functions/xmldb/XMLDBDocument.java index adeb1e20bb8..1b224e1fa8d 100644 --- a/src/org/exist/xquery/functions/xmldb/XMLDBDocument.java +++ b/src/org/exist/xquery/functions/xmldb/XMLDBDocument.java @@ -1,266 +1,266 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ -package org.exist.xquery.functions.xmldb; - -import org.apache.log4j.Logger; - -import org.exist.dom.DefaultDocumentSet; -import org.exist.dom.DocumentImpl; -import org.exist.dom.DocumentSet; -import org.exist.dom.ExtArrayNodeSet; -import org.exist.dom.MutableDocumentSet; -import org.exist.dom.NodeProxy; -import org.exist.dom.QName; -import org.exist.dom.StoredNode; -import org.exist.numbering.NodeId; -import org.exist.security.Permission; -import org.exist.security.PermissionDeniedException; -import org.exist.storage.UpdateListener; -import org.exist.util.LockException; -import org.exist.xmldb.XmldbURI; -import org.exist.xquery.Cardinality; -import org.exist.xquery.Dependency; -import org.exist.xquery.ErrorCodes; -import org.exist.xquery.Function; -import org.exist.xquery.FunctionSignature; -import org.exist.xquery.XPathException; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.value.AnyURIValue; -import org.exist.xquery.value.FunctionReturnSequenceType; -import org.exist.xquery.value.FunctionParameterSequenceType; -import org.exist.xquery.value.Item; -import org.exist.xquery.value.Sequence; -import org.exist.xquery.value.SequenceIterator; -import org.exist.xquery.value.SequenceType; -import org.exist.xquery.value.Type; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * Implements eXist's xmldb:document() function. - * - * @author wolf - */ -public class XMLDBDocument extends Function { - private static final Logger logger = Logger.getLogger(XMLDBDocument.class); - - - public final static FunctionSignature signature = - new FunctionSignature( - new QName("document", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), - "Returns the documents $document-uris in the input sequence. " + - XMLDBModule.COLLECTION_URI + - "If the input sequence is empty, " + - "the function will load all documents in the database.", - new SequenceType[] { - new FunctionParameterSequenceType("document-uris", Type.STRING, Cardinality.ONE_OR_MORE, "The document URIs") - }, - new FunctionReturnSequenceType(Type.NODE, Cardinality.ZERO_OR_MORE, "the documents"), - true, "See the standard fn:doc() function"); - - private List cachedArgs = null; - private Sequence cached = null; - private DocumentSet cachedDocs = null; - private UpdateListener listener = null; - - /** - * @param context - */ - public XMLDBDocument(XQueryContext context) { - super(context, signature); - } - - /* (non-Javadoc) - * @see org.exist.xquery.Function#getDependencies() - */ - public int getDependencies() { - return Dependency.CONTEXT_SET; - } - - /* (non-Javadoc) - * @see org.exist.xquery.Expression#eval(org.exist.dom.DocumentSet, org.exist.xquery.value.Sequence, org.exist.xquery.value.Item) - */ - public Sequence eval(Sequence contextSequence, Item contextItem) - throws XPathException { - - DocumentSet docs = null; - Sequence result = null; - // check if the loaded documents should remain locked - final boolean lockOnLoad = context.lockDocumentsOnLoad(); - boolean cacheIsValid = false; - if (getArgumentCount() == 0) { - // TODO: disabled cache for now as it may cause concurrency issues - // better use compile-time inspection and maybe a pragma to mark those - // sections in the query that can be safely cached - // if(cached != null) { - // result = cached; - // docs = cachedDocs; - // } else { - MutableDocumentSet mdocs = new DefaultDocumentSet(); - try { - context.getBroker().getAllXMLResources(mdocs); - } catch(final PermissionDeniedException pde) { - LOG.error(pde.getMessage(), pde); - throw new XPathException(this, pde); - } - docs = mdocs; - // } - } else { - List args = getParameterValues(contextSequence, contextItem); - if(cachedArgs != null) - {cacheIsValid = compareArguments(cachedArgs, args);} - if(cacheIsValid) { - result = cached; - docs = cachedDocs; - } else { - MutableDocumentSet mdocs = new DefaultDocumentSet(); - for(int i = 0; i < args.size(); i++) { - try { - final String next = (String)args.get(i); - XmldbURI nextUri = new AnyURIValue(next).toXmldbURI(); - if(nextUri.getCollectionPath().length() == 0) { - throw new XPathException(this, "Invalid argument to " + XMLDBModule.PREFIX + ":document() function: empty string is not allowed here."); - } - if(nextUri.numSegments()==1) { - nextUri = context.getBaseURI().toXmldbURI().resolveCollectionPath(nextUri); - } - final DocumentImpl doc = context.getBroker().getResource(nextUri, Permission.READ); - if(doc == null) { - if (context.isRaiseErrorOnFailedRetrieval()) { - throw new XPathException(this, ErrorCodes.FODC0002, "can not access '" + nextUri + "'"); - } - }else { - mdocs.add(doc); - } - } catch (final XPathException e) { //From AnyURIValue constructor - e.setLocation(line, column); - logger.error("From AnyURIValue constructor:", e); - - throw e; - } catch (final PermissionDeniedException e) { - logger.error("Permission denied", e); - - throw new XPathException(this, "Permission denied: unable to load document " + (String) args.get(i)); - } - } - docs = mdocs; - cachedArgs = args; - } - } - try { - if(!cacheIsValid) - // wait for pending updates - {docs.lock(context.getBroker(), lockOnLoad, true);} - // wait for pending updates - if(result == null) { - result = new ExtArrayNodeSet(docs.getDocumentCount(), 1); - DocumentImpl doc; - for (final Iterator i = docs.getDocumentIterator(); i.hasNext();) { - doc = i.next(); - result.add(new NodeProxy(doc)); //, -1, Node.DOCUMENT_NODE)); - if(lockOnLoad) { - context.addLockedDocument(doc); - } - } - } - } catch (final LockException e) { - logger.error("Could not acquire lock on document set", e); - - throw new XPathException(this, "Could not acquire lock on document set."); - } finally { - if(!(cacheIsValid || lockOnLoad)) - // release all locks - {docs.unlock(lockOnLoad);} - } - cached = result; - cachedDocs = docs; - registerUpdateListener(); - - return result; - } - - private List getParameterValues(Sequence contextSequence, Item contextItem) throws XPathException { - final List args = new ArrayList(getArgumentCount() + 10); - for(int i = 0; i < getArgumentCount(); i++) { - final Sequence seq = - getArgument(i).eval(contextSequence, contextItem); - for (final SequenceIterator j = seq.iterate(); j.hasNext();) { - final Item next = j.nextItem(); - args.add(next.getStringValue()); - } - } - return args; - } - - private boolean compareArguments(List args1, List args2) { - if(args1.size() != args2.size()) - {return false;} - for(int i = 0; i < args1.size(); i++) { - final String arg1 = args1.get(i); - final String arg2 = args2.get(i); - if(!arg1.equals(arg2)) - {return false;} - } - return true; - } - - protected void registerUpdateListener() { - if (listener == null) { - listener = new UpdateListener() { - public void documentUpdated(DocumentImpl document, int event) { - // clear all - cachedArgs = null; - cached = null; - cachedDocs = null; - } - - public void unsubscribe() { - XMLDBDocument.this.listener = null; - } - - public void nodeMoved(NodeId oldNodeId, StoredNode newNode) { - // not relevant - } - - public void debug() { - logger.debug("UpdateListener: Line: " + getLine() + ": " + XMLDBDocument.this.toString()); - } - }; - context.registerUpdateListener(listener); - } - } - - /* (non-Javadoc) - * @see org.exist.xquery.PathExpr#resetState() - */ - public void resetState(boolean postOptimization) { - super.resetState(postOptimization); - if (!postOptimization) { - cached = null; - cachedArgs = null; - cachedDocs = null; - listener = null; - } - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id$ + */ +package org.exist.xquery.functions.xmldb; + +import org.apache.log4j.Logger; + +import org.exist.dom.DefaultDocumentSet; +import org.exist.dom.DocumentImpl; +import org.exist.dom.DocumentSet; +import org.exist.dom.ExtArrayNodeSet; +import org.exist.dom.MutableDocumentSet; +import org.exist.dom.NodeProxy; +import org.exist.dom.QName; +import org.exist.dom.StoredNode; +import org.exist.numbering.NodeId; +import org.exist.security.Permission; +import org.exist.security.PermissionDeniedException; +import org.exist.storage.UpdateListener; +import org.exist.util.LockException; +import org.exist.xmldb.XmldbURI; +import org.exist.xquery.Cardinality; +import org.exist.xquery.Dependency; +import org.exist.xquery.ErrorCodes; +import org.exist.xquery.Function; +import org.exist.xquery.FunctionSignature; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.value.AnyURIValue; +import org.exist.xquery.value.FunctionReturnSequenceType; +import org.exist.xquery.value.FunctionParameterSequenceType; +import org.exist.xquery.value.Item; +import org.exist.xquery.value.Sequence; +import org.exist.xquery.value.SequenceIterator; +import org.exist.xquery.value.SequenceType; +import org.exist.xquery.value.Type; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * Implements eXist's xmldb:document() function. + * + * @author wolf + */ +public class XMLDBDocument extends Function { + private static final Logger logger = Logger.getLogger(XMLDBDocument.class); + + + public final static FunctionSignature signature = + new FunctionSignature( + new QName("document", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), + "Returns the documents $document-uris in the input sequence. " + + XMLDBModule.COLLECTION_URI + + "If the input sequence is empty, " + + "the function will load all documents in the database.", + new SequenceType[] { + new FunctionParameterSequenceType("document-uris", Type.STRING, Cardinality.ONE_OR_MORE, "The document URIs") + }, + new FunctionReturnSequenceType(Type.NODE, Cardinality.ZERO_OR_MORE, "the documents"), + true, "See the standard fn:doc() function"); + + private List cachedArgs = null; + private Sequence cached = null; + private DocumentSet cachedDocs = null; + private UpdateListener listener = null; + + /** + * @param context + */ + public XMLDBDocument(XQueryContext context) { + super(context, signature); + } + + /* (non-Javadoc) + * @see org.exist.xquery.Function#getDependencies() + */ + public int getDependencies() { + return Dependency.CONTEXT_SET; + } + + /* (non-Javadoc) + * @see org.exist.xquery.Expression#eval(org.exist.dom.DocumentSet, org.exist.xquery.value.Sequence, org.exist.xquery.value.Item) + */ + public Sequence eval(Sequence contextSequence, Item contextItem) + throws XPathException { + + DocumentSet docs = null; + Sequence result = null; + // check if the loaded documents should remain locked + final boolean lockOnLoad = context.lockDocumentsOnLoad(); + boolean cacheIsValid = false; + if (getArgumentCount() == 0) { + // TODO: disabled cache for now as it may cause concurrency issues + // better use compile-time inspection and maybe a pragma to mark those + // sections in the query that can be safely cached + // if(cached != null) { + // result = cached; + // docs = cachedDocs; + // } else { + MutableDocumentSet mdocs = new DefaultDocumentSet(); + try { + context.getBroker().getAllXMLResources(mdocs); + } catch(final PermissionDeniedException pde) { + LOG.error(pde.getMessage(), pde); + throw new XPathException(this, pde); + } + docs = mdocs; + // } + } else { + List args = getParameterValues(contextSequence, contextItem); + if(cachedArgs != null) + {cacheIsValid = compareArguments(cachedArgs, args);} + if(cacheIsValid) { + result = cached; + docs = cachedDocs; + } else { + MutableDocumentSet mdocs = new DefaultDocumentSet(); + for(int i = 0; i < args.size(); i++) { + try { + final String next = (String)args.get(i); + XmldbURI nextUri = new AnyURIValue(next).toXmldbURI(); + if(nextUri.getCollectionPath().length() == 0) { + throw new XPathException(this, "Invalid argument to " + XMLDBModule.PREFIX + ":document() function: empty string is not allowed here."); + } + if(nextUri.numSegments()==1) { + nextUri = context.getBaseURI().toXmldbURI().resolveCollectionPath(nextUri); + } + final DocumentImpl doc = context.getBroker().getResource(nextUri, Permission.READ); + if(doc == null) { + if (context.isRaiseErrorOnFailedRetrieval()) { + throw new XPathException(this, ErrorCodes.FODC0002, "can not access '" + nextUri + "'"); + } + }else { + mdocs.add(doc); + } + } catch (final XPathException e) { //From AnyURIValue constructor + e.setLocation(line, column); + logger.error("From AnyURIValue constructor:", e); + + throw e; + } catch (final PermissionDeniedException e) { + logger.error("Permission denied", e); + + throw new XPathException(this, "Permission denied: unable to load document " + (String) args.get(i)); + } + } + docs = mdocs; + cachedArgs = args; + } + } + try { + if(!cacheIsValid) + // wait for pending updates + {docs.lock(context.getBroker(), lockOnLoad, true);} + // wait for pending updates + if(result == null) { + result = new ExtArrayNodeSet(docs.getDocumentCount(), 1); + DocumentImpl doc; + for (final Iterator i = docs.getDocumentIterator(); i.hasNext();) { + doc = i.next(); + result.add(new NodeProxy(doc)); //, -1, Node.DOCUMENT_NODE)); + if(lockOnLoad) { + context.addLockedDocument(doc); + } + } + } + } catch (final LockException e) { + logger.error("Could not acquire lock on document set", e); + + throw new XPathException(this, "Could not acquire lock on document set."); + } finally { + if(!(cacheIsValid || lockOnLoad)) + // release all locks + {docs.unlock(lockOnLoad);} + } + cached = result; + cachedDocs = docs; + registerUpdateListener(); + + return result; + } + + private List getParameterValues(Sequence contextSequence, Item contextItem) throws XPathException { + final List args = new ArrayList(getArgumentCount() + 10); + for(int i = 0; i < getArgumentCount(); i++) { + final Sequence seq = + getArgument(i).eval(contextSequence, contextItem); + for (final SequenceIterator j = seq.iterate(); j.hasNext();) { + final Item next = j.nextItem(); + args.add(next.getStringValue()); + } + } + return args; + } + + private boolean compareArguments(List args1, List args2) { + if(args1.size() != args2.size()) + {return false;} + for(int i = 0; i < args1.size(); i++) { + final String arg1 = args1.get(i); + final String arg2 = args2.get(i); + if(!arg1.equals(arg2)) + {return false;} + } + return true; + } + + protected void registerUpdateListener() { + if (listener == null) { + listener = new UpdateListener() { + public void documentUpdated(DocumentImpl document, int event) { + // clear all + cachedArgs = null; + cached = null; + cachedDocs = null; + } + + public void unsubscribe() { + XMLDBDocument.this.listener = null; + } + + public void nodeMoved(NodeId oldNodeId, StoredNode newNode) { + // not relevant + } + + public void debug() { + logger.debug("UpdateListener: Line: " + getLine() + ": " + XMLDBDocument.this.toString()); + } + }; + context.registerUpdateListener(listener); + } + } + + /* (non-Javadoc) + * @see org.exist.xquery.PathExpr#resetState() + */ + public void resetState(boolean postOptimization) { + super.resetState(postOptimization); + if (!postOptimization) { + cached = null; + cachedArgs = null; + cachedDocs = null; + listener = null; + } + } +} diff --git a/src/org/exist/xquery/modules/ModuleUtils.java b/src/org/exist/xquery/modules/ModuleUtils.java index ded20a717c8..81057652812 100644 --- a/src/org/exist/xquery/modules/ModuleUtils.java +++ b/src/org/exist/xquery/modules/ModuleUtils.java @@ -1,479 +1,479 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-08 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.xquery.modules; - -import java.io.InputStream; -import java.io.IOException; -import java.io.Reader; -import java.io.StringReader; -import java.math.BigInteger; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Properties; -import java.util.Random; -import java.util.concurrent.locks.ReentrantReadWriteLock; -import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock; -import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock; -import javax.xml.transform.Source; -import javax.xml.transform.sax.SAXSource; - -import org.apache.log4j.Logger; -import org.exist.memtree.DocumentBuilderReceiver; -import org.exist.memtree.DocumentImpl; -import org.exist.memtree.MemTreeBuilder; -import org.exist.memtree.SAXAdapter; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.value.NodeValue; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; - -/** - * Utility Functions for XQuery Extension Modules - * - * @author Adam Retter - * @serial 200805202059 - * @version 1.1 - */ -public class ModuleUtils { - protected final static Logger LOG = Logger.getLogger(ModuleUtils.class); - - /** - * Takes a String of XML and Creates an XML Node from it using SAX in the - * context of the query - * - * @param context - * The Context of the calling XQuery - * @param str - * The String of XML - * - * @return The NodeValue of XML - */ - public static NodeValue stringToXML(XQueryContext context, String str) throws SAXException, IOException { - final Reader reader = new StringReader(str); - try { - return inputSourceToXML(context, new InputSource(reader)); - } finally { - reader.close(); - } - } - - - /** - * Takes an InputStream of XML and Creates an XML Node from it using SAX in the - * context of the query - * - * @param context - * The Context of the calling XQuery - * @param is - * The InputStream of XML - * - * @return The NodeValue of XML - */ - public static NodeValue streamToXML(XQueryContext context, InputStream is) throws SAXException, IOException { - return inputSourceToXML(context, new InputSource(is)); - } - - /** - * Takes a Source of XML and Creates an XML Node from it using SAX in the - * context of the query - * - * @param context - * The Context of the calling XQuery - * @param src - * The Source of XML - * - * @return The NodeValue of XML - */ - public static NodeValue sourceToXML(XQueryContext context, Source src) throws SAXException, IOException { - if(src instanceof SAXSource && ((SAXSource)src).getXMLReader() != null) { - //Handles the case where a SAXSource may already have an - //XMLReader allocated, for example EXPath httpclient - //where it wants to tidy html using TagSoup - return inputSourceToXML(context, (SAXSource)src); - } else { - final InputSource inputSource = SAXSource.sourceToInputSource(src); - if(inputSource == null){ - throw new IOException(src.getClass().getName() + " is unsupported."); - } - - return inputSourceToXML(context, inputSource); - } - } - - - /** - * Takes a InputSource of XML and Creates an XML Node from it using SAX in the - * context of the query - * - * @param context - * The Context of the calling XQuery - * @param inputSource - * The InputSource of XML - * - * @return The NodeValue of XML - */ - public static NodeValue inputSourceToXML(XQueryContext context, InputSource inputSource) throws SAXException, IOException { - context.pushDocumentContext(); - - XMLReader reader = null; - try { - // try and construct xml document from input stream, we use eXist's - // in-memory DOM implementation - reader = context.getBroker().getBrokerPool().getParserPool().borrowXMLReader(); - LOG.debug( "Parsing XML response ..." ); - - // TODO : we should be able to cope with context.getBaseURI() - final MemTreeBuilder builder = context.getDocumentBuilder(); - final DocumentBuilderReceiver receiver = new DocumentBuilderReceiver( builder, true ); - reader.setContentHandler(receiver); - reader.setProperty("http://xml.org/sax/properties/lexical-handler", receiver); - reader.parse(inputSource); - final Document doc = receiver.getDocument(); - // return (NodeValue)doc.getDocumentElement(); - return((NodeValue)doc); - } finally { - context.popDocumentContext(); - - if(reader != null){ - context.getBroker().getBrokerPool().getParserPool().returnXMLReader(reader); - } - } - } - - /** - * Takes a InputSource of XML and Creates an XML Node from it using SAX in the - * context of the query - * - * @param context - * The Context of the calling XQuery - * @param xml - * The InputSource of XML - * - * @return The NodeValue of XML - */ - private static NodeValue inputSourceToXML(XQueryContext context, SAXSource src) throws SAXException, IOException { - if(src.getXMLReader() == null) { - throw new SAXException("No XML Reader specified."); - } - final XMLReader reader = src.getXMLReader(); - - context.pushDocumentContext(); - - try { - // try and construct xml document from input stream, we use eXist's - // in-memory DOM implementation - - // TODO : we should be able to cope with context.getBaseURI() - final MemTreeBuilder builder = context.getDocumentBuilder(); - final DocumentBuilderReceiver receiver = new DocumentBuilderReceiver(builder, true); - reader.setContentHandler(receiver); - reader.parse(src.getInputSource()); - final Document doc = receiver.getDocument(); - return((NodeValue)doc); - } finally { - context.popDocumentContext(); - } - } - - /** - * Takes a HTML InputSource and creates an XML representation of the HTML by - * tidying it (uses NekoHTML) - * - * @param context - * The Context of the calling XQuery - * @param srcHtml - * The Source for the HTML - * @param parserFeatures - * The features to set on the Parser - * @param parserProperties - * The properties to set on the Parser - * - * @return An in-memory Document representing the XML'ised HTML - */ - public static DocumentImpl htmlToXHtml(XQueryContext context, String url, Source srcHtml, Map parserFeatures, MapparserProperties) throws IOException, SAXException { - - final InputSource inputSource = SAXSource.sourceToInputSource(srcHtml); - - if(inputSource == null){ - throw new IOException(srcHtml.getClass().getName() + " is unsupported."); - } - - return htmlToXHtml(context, url, inputSource, parserFeatures, parserProperties); - } - - /** - * Takes a HTML InputSource and creates an XML representation of the HTML by - * tidying it (uses NekoHTML) - * - * @param context - * The Context of the calling XQuery - * @param srcHtml - * The InputSource for the HTML - * @param parserFeatures - * The features to set on the Parser - * @param parserProperties - * The properties to set on the Parser - * - * @return An in-memory Document representing the XML'ised HTML - */ - public static DocumentImpl htmlToXHtml(XQueryContext context, String url, InputSource srcHtml, Map parserFeatures, MapparserProperties) throws IOException, SAXException { - // we use eXist's in-memory DOM implementation - org.exist.memtree.DocumentImpl memtreeDoc = null; - - // use Neko to parse the HTML content to XML - XMLReader reader = null; - try { - LOG.debug("Converting HTML to XML using NekoHTML parser for: " + url); - reader = (XMLReader) Class.forName("org.cyberneko.html.parsers.SAXParser").newInstance(); - - if(parserFeatures != null) { - for(final Entry parserFeature : parserFeatures.entrySet()) { - reader.setFeature(parserFeature.getKey(), parserFeature.getValue()); - } - } - - if(parserProperties == null) { - //default: do not modify the case of elements and attributes - reader.setProperty("http://cyberneko.org/html/properties/names/elems","match"); - reader.setProperty("http://cyberneko.org/html/properties/names/attrs","no-change"); - } else { - for(final Entry parserProperty : parserProperties.entrySet()) { - reader.setProperty(parserProperty.getKey(), parserProperty.getValue()); - } - } - } catch(final Exception e) { - final String errorMsg = "Error while invoking NekoHTML parser. (" - + e.getMessage() - + "). If you want to parse non-wellformed HTML files, put " - + "nekohtml.jar into directory 'lib/user'."; - LOG.error(errorMsg, e); - - throw new IOException(errorMsg, e); - } - - final SAXAdapter adapter = new SAXAdapter(); - reader.setContentHandler(adapter); - reader.parse(srcHtml); - final Document doc = adapter.getDocument(); - memtreeDoc = (DocumentImpl) doc; - memtreeDoc.setContext(context); - - return memtreeDoc; - } - - /** - * Parses a structure like into a set of Properties - * - * @param nParameters - * The parameters Node - * @return a set of name value properties for representing the XML - * parameters - */ - public static Properties parseParameters(Node nParameters){ - return parseProperties(nParameters, "param"); - } - - /** - * Parses a structure like into a set of Properties - * - * @param nProperties - * The properties Node - * @return a set of name value properties for representing the XML - * properties - */ - public static Properties parseProperties(Node nProperties) { - return parseProperties(nProperties, "property"); - } - - /** - * Parses a structure like into a set of Properties - * - * @param container - * The container of the properties - * @param elementName - * The name of the property element - * @return a set of name value properties for representing the XML - * properties - */ - private static Properties parseProperties(Node container, String elementName) { - final Properties properties = new Properties(); - - if(container != null && container.getNodeType() == Node.ELEMENT_NODE) { - final NodeList params = ((Element) container).getElementsByTagName(elementName); - for(int i = 0; i < params.getLength(); i++) { - final Element param = ((Element) params.item(i)); - - final String name = param.getAttribute("name"); - final String value = param.getAttribute("value"); - - if(name != null && value != null) { - properties.setProperty(name, value); - } else { - LOG.warn("Name or value attribute missing for " + elementName); - } - } - } - return properties; - } - - - private static class ContextMapLocks { - private final Map locks = new HashMap(); - - private synchronized ReentrantReadWriteLock getLock(String contextMapName) { - ReentrantReadWriteLock lock = locks.get(contextMapName); - if(lock == null) { - lock = new ReentrantReadWriteLock(); - locks.put(contextMapName, lock); - } - return lock; - } - - public ReadLock getReadLock(String contextMapName) { - return getLock(contextMapName).readLock(); - } - - public WriteLock getWriteLock(String contextMapName) { - return getLock(contextMapName).writeLock(); - } - } - - private final static ContextMapLocks contextMapLocks = new ContextMapLocks(); - - /** - * Retrieves a previously stored Object from the Context of an XQuery. - * - * @param context The Context of the XQuery containing the Object - * @param contextMapName DOCUMENT ME! - * @param objectUID The UID of the Object to retrieve from the Context of the XQuery - * - * @return DOCUMENT ME! - */ - public static T retrieveObjectFromContextMap(XQueryContext context, String contextMapName, long objectUID) { - - contextMapLocks.getReadLock(contextMapName).lock(); - try{ - // get the existing object map from the context - final Map map = (HashMap)context.getXQueryContextVar(contextMapName); - - if(map == null) { - return null; - } - - // get the connection - return map.get(objectUID); - } finally { - contextMapLocks.getReadLock(contextMapName).unlock(); - } - } - - public static void modifyContextMap(XQueryContext context, String contextMapName, ContextMapModifier modifier) { - contextMapLocks.getWriteLock(contextMapName).lock(); - try { - // get the existing map from the context - Map map = (Map)context.getXQueryContextVar(contextMapName); - if(map == null) { - //create a new map if it doesnt exist - map = new HashMap(); - context.setXQueryContextVar(contextMapName, map); - } - - //modify the map - modifier.modify(map); - - } finally { - contextMapLocks.getWriteLock(contextMapName).unlock(); - } - } - - public interface ContextMapModifier { - public void modify(Map map); - } - - public static abstract class ContextMapEntryModifier implements ContextMapModifier { - - @Override - public void modify(Map map) { - for(final Entry entry : map.entrySet()) { - modify(entry); - } - } - - public abstract void modify(Entry entry); - } - - /** - * Stores an Object in the Context of an XQuery. - * - * @param context The Context of the XQuery to store the Object in - * @param contextMapName The name of the context map - * @param o The Object to store - * - * @return A unique ID representing the Object - */ - public static long storeObjectInContextMap(XQueryContext context, String contextMapName, T o) { - - contextMapLocks.getWriteLock(contextMapName).lock(); - try{ - - // get the existing map from the context - Map map = (Map)context.getXQueryContextVar(contextMapName); - - if(map == null) { - // if there is no map, create a new one - map = new HashMap(); - } - - // get an id for the map - long uid = 0; - while(uid == 0 || map.keySet().contains(uid)) { - uid = getUID(); - } - - // place the object in the map - map.put(uid, o); - - // store the map back in the context - context.setXQueryContextVar(contextMapName, map); - - return (uid); - } finally { - contextMapLocks.getWriteLock(contextMapName).unlock(); - } - } - - private final static Random random = new Random(); - - private static long getUID() { - final BigInteger bi = new BigInteger(64, random); - return bi.longValue(); - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-08 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.xquery.modules; + +import java.io.InputStream; +import java.io.IOException; +import java.io.Reader; +import java.io.StringReader; +import java.math.BigInteger; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Properties; +import java.util.Random; +import java.util.concurrent.locks.ReentrantReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock; +import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock; +import javax.xml.transform.Source; +import javax.xml.transform.sax.SAXSource; + +import org.apache.log4j.Logger; +import org.exist.memtree.DocumentBuilderReceiver; +import org.exist.memtree.DocumentImpl; +import org.exist.memtree.MemTreeBuilder; +import org.exist.memtree.SAXAdapter; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.value.NodeValue; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; + +/** + * Utility Functions for XQuery Extension Modules + * + * @author Adam Retter + * @serial 200805202059 + * @version 1.1 + */ +public class ModuleUtils { + protected final static Logger LOG = Logger.getLogger(ModuleUtils.class); + + /** + * Takes a String of XML and Creates an XML Node from it using SAX in the + * context of the query + * + * @param context + * The Context of the calling XQuery + * @param str + * The String of XML + * + * @return The NodeValue of XML + */ + public static NodeValue stringToXML(XQueryContext context, String str) throws SAXException, IOException { + final Reader reader = new StringReader(str); + try { + return inputSourceToXML(context, new InputSource(reader)); + } finally { + reader.close(); + } + } + + + /** + * Takes an InputStream of XML and Creates an XML Node from it using SAX in the + * context of the query + * + * @param context + * The Context of the calling XQuery + * @param is + * The InputStream of XML + * + * @return The NodeValue of XML + */ + public static NodeValue streamToXML(XQueryContext context, InputStream is) throws SAXException, IOException { + return inputSourceToXML(context, new InputSource(is)); + } + + /** + * Takes a Source of XML and Creates an XML Node from it using SAX in the + * context of the query + * + * @param context + * The Context of the calling XQuery + * @param src + * The Source of XML + * + * @return The NodeValue of XML + */ + public static NodeValue sourceToXML(XQueryContext context, Source src) throws SAXException, IOException { + if(src instanceof SAXSource && ((SAXSource)src).getXMLReader() != null) { + //Handles the case where a SAXSource may already have an + //XMLReader allocated, for example EXPath httpclient + //where it wants to tidy html using TagSoup + return inputSourceToXML(context, (SAXSource)src); + } else { + final InputSource inputSource = SAXSource.sourceToInputSource(src); + if(inputSource == null){ + throw new IOException(src.getClass().getName() + " is unsupported."); + } + + return inputSourceToXML(context, inputSource); + } + } + + + /** + * Takes a InputSource of XML and Creates an XML Node from it using SAX in the + * context of the query + * + * @param context + * The Context of the calling XQuery + * @param inputSource + * The InputSource of XML + * + * @return The NodeValue of XML + */ + public static NodeValue inputSourceToXML(XQueryContext context, InputSource inputSource) throws SAXException, IOException { + context.pushDocumentContext(); + + XMLReader reader = null; + try { + // try and construct xml document from input stream, we use eXist's + // in-memory DOM implementation + reader = context.getBroker().getBrokerPool().getParserPool().borrowXMLReader(); + LOG.debug( "Parsing XML response ..." ); + + // TODO : we should be able to cope with context.getBaseURI() + final MemTreeBuilder builder = context.getDocumentBuilder(); + final DocumentBuilderReceiver receiver = new DocumentBuilderReceiver( builder, true ); + reader.setContentHandler(receiver); + reader.setProperty("http://xml.org/sax/properties/lexical-handler", receiver); + reader.parse(inputSource); + final Document doc = receiver.getDocument(); + // return (NodeValue)doc.getDocumentElement(); + return((NodeValue)doc); + } finally { + context.popDocumentContext(); + + if(reader != null){ + context.getBroker().getBrokerPool().getParserPool().returnXMLReader(reader); + } + } + } + + /** + * Takes a InputSource of XML and Creates an XML Node from it using SAX in the + * context of the query + * + * @param context + * The Context of the calling XQuery + * @param xml + * The InputSource of XML + * + * @return The NodeValue of XML + */ + private static NodeValue inputSourceToXML(XQueryContext context, SAXSource src) throws SAXException, IOException { + if(src.getXMLReader() == null) { + throw new SAXException("No XML Reader specified."); + } + final XMLReader reader = src.getXMLReader(); + + context.pushDocumentContext(); + + try { + // try and construct xml document from input stream, we use eXist's + // in-memory DOM implementation + + // TODO : we should be able to cope with context.getBaseURI() + final MemTreeBuilder builder = context.getDocumentBuilder(); + final DocumentBuilderReceiver receiver = new DocumentBuilderReceiver(builder, true); + reader.setContentHandler(receiver); + reader.parse(src.getInputSource()); + final Document doc = receiver.getDocument(); + return((NodeValue)doc); + } finally { + context.popDocumentContext(); + } + } + + /** + * Takes a HTML InputSource and creates an XML representation of the HTML by + * tidying it (uses NekoHTML) + * + * @param context + * The Context of the calling XQuery + * @param srcHtml + * The Source for the HTML + * @param parserFeatures + * The features to set on the Parser + * @param parserProperties + * The properties to set on the Parser + * + * @return An in-memory Document representing the XML'ised HTML + */ + public static DocumentImpl htmlToXHtml(XQueryContext context, String url, Source srcHtml, Map parserFeatures, MapparserProperties) throws IOException, SAXException { + + final InputSource inputSource = SAXSource.sourceToInputSource(srcHtml); + + if(inputSource == null){ + throw new IOException(srcHtml.getClass().getName() + " is unsupported."); + } + + return htmlToXHtml(context, url, inputSource, parserFeatures, parserProperties); + } + + /** + * Takes a HTML InputSource and creates an XML representation of the HTML by + * tidying it (uses NekoHTML) + * + * @param context + * The Context of the calling XQuery + * @param srcHtml + * The InputSource for the HTML + * @param parserFeatures + * The features to set on the Parser + * @param parserProperties + * The properties to set on the Parser + * + * @return An in-memory Document representing the XML'ised HTML + */ + public static DocumentImpl htmlToXHtml(XQueryContext context, String url, InputSource srcHtml, Map parserFeatures, MapparserProperties) throws IOException, SAXException { + // we use eXist's in-memory DOM implementation + org.exist.memtree.DocumentImpl memtreeDoc = null; + + // use Neko to parse the HTML content to XML + XMLReader reader = null; + try { + LOG.debug("Converting HTML to XML using NekoHTML parser for: " + url); + reader = (XMLReader) Class.forName("org.cyberneko.html.parsers.SAXParser").newInstance(); + + if(parserFeatures != null) { + for(final Entry parserFeature : parserFeatures.entrySet()) { + reader.setFeature(parserFeature.getKey(), parserFeature.getValue()); + } + } + + if(parserProperties == null) { + //default: do not modify the case of elements and attributes + reader.setProperty("http://cyberneko.org/html/properties/names/elems","match"); + reader.setProperty("http://cyberneko.org/html/properties/names/attrs","no-change"); + } else { + for(final Entry parserProperty : parserProperties.entrySet()) { + reader.setProperty(parserProperty.getKey(), parserProperty.getValue()); + } + } + } catch(final Exception e) { + final String errorMsg = "Error while invoking NekoHTML parser. (" + + e.getMessage() + + "). If you want to parse non-wellformed HTML files, put " + + "nekohtml.jar into directory 'lib/user'."; + LOG.error(errorMsg, e); + + throw new IOException(errorMsg, e); + } + + final SAXAdapter adapter = new SAXAdapter(); + reader.setContentHandler(adapter); + reader.parse(srcHtml); + final Document doc = adapter.getDocument(); + memtreeDoc = (DocumentImpl) doc; + memtreeDoc.setContext(context); + + return memtreeDoc; + } + + /** + * Parses a structure like into a set of Properties + * + * @param nParameters + * The parameters Node + * @return a set of name value properties for representing the XML + * parameters + */ + public static Properties parseParameters(Node nParameters){ + return parseProperties(nParameters, "param"); + } + + /** + * Parses a structure like into a set of Properties + * + * @param nProperties + * The properties Node + * @return a set of name value properties for representing the XML + * properties + */ + public static Properties parseProperties(Node nProperties) { + return parseProperties(nProperties, "property"); + } + + /** + * Parses a structure like into a set of Properties + * + * @param container + * The container of the properties + * @param elementName + * The name of the property element + * @return a set of name value properties for representing the XML + * properties + */ + private static Properties parseProperties(Node container, String elementName) { + final Properties properties = new Properties(); + + if(container != null && container.getNodeType() == Node.ELEMENT_NODE) { + final NodeList params = ((Element) container).getElementsByTagName(elementName); + for(int i = 0; i < params.getLength(); i++) { + final Element param = ((Element) params.item(i)); + + final String name = param.getAttribute("name"); + final String value = param.getAttribute("value"); + + if(name != null && value != null) { + properties.setProperty(name, value); + } else { + LOG.warn("Name or value attribute missing for " + elementName); + } + } + } + return properties; + } + + + private static class ContextMapLocks { + private final Map locks = new HashMap(); + + private synchronized ReentrantReadWriteLock getLock(String contextMapName) { + ReentrantReadWriteLock lock = locks.get(contextMapName); + if(lock == null) { + lock = new ReentrantReadWriteLock(); + locks.put(contextMapName, lock); + } + return lock; + } + + public ReadLock getReadLock(String contextMapName) { + return getLock(contextMapName).readLock(); + } + + public WriteLock getWriteLock(String contextMapName) { + return getLock(contextMapName).writeLock(); + } + } + + private final static ContextMapLocks contextMapLocks = new ContextMapLocks(); + + /** + * Retrieves a previously stored Object from the Context of an XQuery. + * + * @param context The Context of the XQuery containing the Object + * @param contextMapName DOCUMENT ME! + * @param objectUID The UID of the Object to retrieve from the Context of the XQuery + * + * @return DOCUMENT ME! + */ + public static T retrieveObjectFromContextMap(XQueryContext context, String contextMapName, long objectUID) { + + contextMapLocks.getReadLock(contextMapName).lock(); + try{ + // get the existing object map from the context + final Map map = (HashMap)context.getXQueryContextVar(contextMapName); + + if(map == null) { + return null; + } + + // get the connection + return map.get(objectUID); + } finally { + contextMapLocks.getReadLock(contextMapName).unlock(); + } + } + + public static void modifyContextMap(XQueryContext context, String contextMapName, ContextMapModifier modifier) { + contextMapLocks.getWriteLock(contextMapName).lock(); + try { + // get the existing map from the context + Map map = (Map)context.getXQueryContextVar(contextMapName); + if(map == null) { + //create a new map if it doesnt exist + map = new HashMap(); + context.setXQueryContextVar(contextMapName, map); + } + + //modify the map + modifier.modify(map); + + } finally { + contextMapLocks.getWriteLock(contextMapName).unlock(); + } + } + + public interface ContextMapModifier { + public void modify(Map map); + } + + public static abstract class ContextMapEntryModifier implements ContextMapModifier { + + @Override + public void modify(Map map) { + for(final Entry entry : map.entrySet()) { + modify(entry); + } + } + + public abstract void modify(Entry entry); + } + + /** + * Stores an Object in the Context of an XQuery. + * + * @param context The Context of the XQuery to store the Object in + * @param contextMapName The name of the context map + * @param o The Object to store + * + * @return A unique ID representing the Object + */ + public static long storeObjectInContextMap(XQueryContext context, String contextMapName, T o) { + + contextMapLocks.getWriteLock(contextMapName).lock(); + try{ + + // get the existing map from the context + Map map = (Map)context.getXQueryContextVar(contextMapName); + + if(map == null) { + // if there is no map, create a new one + map = new HashMap(); + } + + // get an id for the map + long uid = 0; + while(uid == 0 || map.keySet().contains(uid)) { + uid = getUID(); + } + + // place the object in the map + map.put(uid, o); + + // store the map back in the context + context.setXQueryContextVar(contextMapName, map); + + return (uid); + } finally { + contextMapLocks.getWriteLock(contextMapName).unlock(); + } + } + + private final static Random random = new Random(); + + private static long getUID() { + final BigInteger bi = new BigInteger(64, random); + return bi.longValue(); + } +} diff --git a/src/org/exist/xquery/pragmas/ForceIndexUse.java b/src/org/exist/xquery/pragmas/ForceIndexUse.java index ec9ccec4b54..f2ac934aa58 100644 --- a/src/org/exist/xquery/pragmas/ForceIndexUse.java +++ b/src/org/exist/xquery/pragmas/ForceIndexUse.java @@ -1,73 +1,73 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-06 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -package org.exist.xquery.pragmas; - -import org.exist.xquery.*; -import org.exist.Namespaces; -import org.exist.dom.QName; - -public class ForceIndexUse extends Pragma { - - Expression expression; - boolean bailout = true; - - public static final QName EXCEPTION_IF_INDEX_NOT_USED_PRAGMA = - new QName("force-index-use", Namespaces.EXIST_NS, "exist"); - - public ForceIndexUse(QName qname, String contents) throws XPathException { - super(qname, contents); - } - - public void before(XQueryContext context, Expression expression) throws XPathException { - } - - public void after(XQueryContext context, Expression expression) throws XPathException { - expression.accept(new DefaultExpressionVisitor() { - public void visitGeneralComparison(GeneralComparison expression) { - bailout = !expression.hasUsedIndex(); - } - public void visitBuiltinFunction(Function expression) { - if (expression instanceof IndexUseReporter) - {bailout = !((IndexUseReporter)expression).hasUsedIndex();} - } - }); - - if (bailout) - {throw new XPathException(expression, "XQDYxxxx: Can not use index on expression '" + expression + "'");} - - /* - if (expression instanceof PathExpr) { - PathExpr pe = (PathExpr)expression; - for (Iterator i = pe.steps.iterator(); i.hasNext();) { - Expression expr = (Expression) i.next(); - if (expr instanceof GeneralComparison) { - if (!((GeneralComparison)expr).hasUsedIndex()) - throw new XPathException(expression, "XQDYxxxx: Can not use index"); - } - if (expr instanceof FunMatches) { - if (!((FunMatches)expr).hasUsedIndex()) - throw new XPathException(expression, "XQDYxxxx: Can not use index"); - } - } - } - */ - } - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-06 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +package org.exist.xquery.pragmas; + +import org.exist.xquery.*; +import org.exist.Namespaces; +import org.exist.dom.QName; + +public class ForceIndexUse extends Pragma { + + Expression expression; + boolean bailout = true; + + public static final QName EXCEPTION_IF_INDEX_NOT_USED_PRAGMA = + new QName("force-index-use", Namespaces.EXIST_NS, "exist"); + + public ForceIndexUse(QName qname, String contents) throws XPathException { + super(qname, contents); + } + + public void before(XQueryContext context, Expression expression) throws XPathException { + } + + public void after(XQueryContext context, Expression expression) throws XPathException { + expression.accept(new DefaultExpressionVisitor() { + public void visitGeneralComparison(GeneralComparison expression) { + bailout = !expression.hasUsedIndex(); + } + public void visitBuiltinFunction(Function expression) { + if (expression instanceof IndexUseReporter) + {bailout = !((IndexUseReporter)expression).hasUsedIndex();} + } + }); + + if (bailout) + {throw new XPathException(expression, "XQDYxxxx: Can not use index on expression '" + expression + "'");} + + /* + if (expression instanceof PathExpr) { + PathExpr pe = (PathExpr)expression; + for (Iterator i = pe.steps.iterator(); i.hasNext();) { + Expression expr = (Expression) i.next(); + if (expr instanceof GeneralComparison) { + if (!((GeneralComparison)expr).hasUsedIndex()) + throw new XPathException(expression, "XQDYxxxx: Can not use index"); + } + if (expr instanceof FunMatches) { + if (!((FunMatches)expr).hasUsedIndex()) + throw new XPathException(expression, "XQDYxxxx: Can not use index"); + } + } + } + */ + } + +} diff --git a/src/org/exist/xquery/pragmas/ProfilePragma.java b/src/org/exist/xquery/pragmas/ProfilePragma.java index b4c4867de18..32bd63b651d 100644 --- a/src/org/exist/xquery/pragmas/ProfilePragma.java +++ b/src/org/exist/xquery/pragmas/ProfilePragma.java @@ -1,46 +1,46 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-04 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id$ - */ -package org.exist.xquery.pragmas; - -import org.exist.xquery.*; -import org.exist.Namespaces; -import org.exist.dom.QName; - -public class ProfilePragma extends Pragma { - - public final static QName PROFILING_PRAGMA = new QName("profiling", Namespaces.EXIST_NS, "exist"); - - public ProfilePragma(QName qname, String contents) throws XPathException { - super(qname, contents); - } - - public void after(XQueryContext context, Expression expression) throws XPathException { - final Profiler profiler = context.getProfiler(); - profiler.setEnabled(false); - } - - public void before(XQueryContext context, Expression expression) throws XPathException { - final Profiler profiler = context.getProfiler(); - final Option pragma = new Option(getQName(), getContents()); - profiler.configure(pragma); - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-04 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ +package org.exist.xquery.pragmas; + +import org.exist.xquery.*; +import org.exist.Namespaces; +import org.exist.dom.QName; + +public class ProfilePragma extends Pragma { + + public final static QName PROFILING_PRAGMA = new QName("profiling", Namespaces.EXIST_NS, "exist"); + + public ProfilePragma(QName qname, String contents) throws XPathException { + super(qname, contents); + } + + public void after(XQueryContext context, Expression expression) throws XPathException { + final Profiler profiler = context.getProfiler(); + profiler.setEnabled(false); + } + + public void before(XQueryContext context, Expression expression) throws XPathException { + final Profiler profiler = context.getProfiler(); + final Option pragma = new Option(getQName(), getContents()); + profiler.configure(pragma); + } +} diff --git a/src/org/exist/xquery/regex/CaseVariants.java b/src/org/exist/xquery/regex/CaseVariants.java index 7014735a26c..4504a2a22e0 100644 --- a/src/org/exist/xquery/regex/CaseVariants.java +++ b/src/org/exist/xquery/regex/CaseVariants.java @@ -1,1888 +1,1888 @@ -package org.exist.xquery.regex; - -import org.exist.util.hashtable.Int2ObjectHashMap; - -/** - * This class holds data about the case-variants of Unicode characters. The data is automatically - * generated from the Unicode database. - * - * Copied from Saxon-HE 9.2 package net.sf.saxon.regex. - */ -public class CaseVariants { - - static int[] EMPTY_INT_ARRAY = new int[0]; - - // Use one hashmap for characters with a single case variant, another for characters with multiple - // case variants, to reduce the number of objects that need to be allocated - - private static Int2ObjectHashMap monoVariants = new Int2ObjectHashMap(2500); - private static Int2ObjectHashMap polyVariants = new Int2ObjectHashMap(100); - - private static void cv(int a, int b) { - monoVariants.put(a, b); - } - - private static void cv(int a, int b, int c) { - final int[] v = {b, c}; - polyVariants.put(a, v); - } - - private static void cv(int a, int b, int c, int d) { - final int[] v = {b, c, d}; - polyVariants.put(a, v); - } - - /** - * Get the case variants of a character - * - * @param code the character whose case variants are required - * @return the case variants of the character, excluding the character itself - */ - - public static int[] getCaseVariants(int code) { - final int mono = (Integer) monoVariants.get(code); - //UNDERSTAND: is it safe? -// if (mono != monoVariants.getDefaultValue()) { -// return new int[]{mono}; -// } else { - final int[] result = polyVariants.get(code); - if (result == null) { - return EMPTY_INT_ARRAY; - } else { - return result; - } -// } - } - - /** - * Get the case variants of roman letters (A-Z, a-z), other than the letters A-Z and a-z themselves - */ - - public static int[] ROMAN_VARIANTS = {0x0130, 0x0131, 0x212A, 0x017F}; - - /** - * The following data was generated from the Unicode database as follows: - * (a) the database was converted to XML - * (b) the following query was run: - * let $chars := doc('UnicodeData.xml')/ * /Char[string(toUpper) or string(toLower)] - * for $c in $chars - * let $variants := ($chars[(code, toUpper) = $c/(code, toUpper)] | - * $chars[(code, toLower) = $c/(code, toLower)]) except $c - * return - * if (count($variants) gt 0) then - * concat("cv(0x", $c/code, ", 0x", string-join($variants/code, ", 0x"), "); ") - * else () - */ - - - static { - cv(0x0041, 0x0061); - cv(0x0042, 0x0062); - cv(0x0043, 0x0063); - cv(0x0044, 0x0064); - cv(0x0045, 0x0065); - cv(0x0046, 0x0066); - cv(0x0047, 0x0067); - cv(0x0048, 0x0068); - cv(0x0049, 0x0069, 0x0130, 0x0131); - cv(0x004A, 0x006A); - cv(0x004B, 0x006B, 0x212A); - cv(0x004C, 0x006C); - cv(0x004D, 0x006D); - cv(0x004E, 0x006E); - cv(0x004F, 0x006F); - cv(0x0050, 0x0070); - cv(0x0051, 0x0071); - cv(0x0052, 0x0072); - cv(0x0053, 0x0073, 0x017F); - cv(0x0054, 0x0074); - cv(0x0055, 0x0075); - cv(0x0056, 0x0076); - cv(0x0057, 0x0077); - cv(0x0058, 0x0078); - cv(0x0059, 0x0079); - cv(0x005A, 0x007A); - cv(0x0061, 0x0041); - cv(0x0062, 0x0042); - cv(0x0063, 0x0043); - cv(0x0064, 0x0044); - cv(0x0065, 0x0045); - cv(0x0066, 0x0046); - cv(0x0067, 0x0047); - cv(0x0068, 0x0048); - cv(0x0069, 0x0049, 0x0130, 0x0131); - cv(0x006A, 0x004A); - cv(0x006B, 0x004B, 0x212A); - cv(0x006C, 0x004C); - cv(0x006D, 0x004D); - cv(0x006E, 0x004E); - cv(0x006F, 0x004F); - cv(0x0070, 0x0050); - cv(0x0071, 0x0051); - cv(0x0072, 0x0052); - cv(0x0073, 0x0053, 0x017F); - cv(0x0074, 0x0054); - cv(0x0075, 0x0055); - cv(0x0076, 0x0056); - cv(0x0077, 0x0057); - cv(0x0078, 0x0058); - cv(0x0079, 0x0059); - cv(0x007A, 0x005A); - cv(0x00B5, 0x039C, 0x03BC); - cv(0x00C0, 0x00E0); - cv(0x00C1, 0x00E1); - cv(0x00C2, 0x00E2); - cv(0x00C3, 0x00E3); - cv(0x00C4, 0x00E4); - cv(0x00C5, 0x00E5, 0x212B); - cv(0x00C6, 0x00E6); - cv(0x00C7, 0x00E7); - cv(0x00C8, 0x00E8); - cv(0x00C9, 0x00E9); - cv(0x00CA, 0x00EA); - cv(0x00CB, 0x00EB); - cv(0x00CC, 0x00EC); - cv(0x00CD, 0x00ED); - cv(0x00CE, 0x00EE); - cv(0x00CF, 0x00EF); - cv(0x00D0, 0x00F0); - cv(0x00D1, 0x00F1); - cv(0x00D2, 0x00F2); - cv(0x00D3, 0x00F3); - cv(0x00D4, 0x00F4); - cv(0x00D5, 0x00F5); - cv(0x00D6, 0x00F6); - cv(0x00D8, 0x00F8); - cv(0x00D9, 0x00F9); - cv(0x00DA, 0x00FA); - cv(0x00DB, 0x00FB); - cv(0x00DC, 0x00FC); - cv(0x00DD, 0x00FD); - cv(0x00DE, 0x00FE); - cv(0x00E0, 0x00C0); - cv(0x00E1, 0x00C1); - cv(0x00E2, 0x00C2); - cv(0x00E3, 0x00C3); - cv(0x00E4, 0x00C4); - cv(0x00E5, 0x00C5, 0x212B); - cv(0x00E6, 0x00C6); - cv(0x00E7, 0x00C7); - cv(0x00E8, 0x00C8); - cv(0x00E9, 0x00C9); - cv(0x00EA, 0x00CA); - cv(0x00EB, 0x00CB); - cv(0x00EC, 0x00CC); - cv(0x00ED, 0x00CD); - cv(0x00EE, 0x00CE); - cv(0x00EF, 0x00CF); - cv(0x00F0, 0x00D0); - cv(0x00F1, 0x00D1); - cv(0x00F2, 0x00D2); - cv(0x00F3, 0x00D3); - cv(0x00F4, 0x00D4); - cv(0x00F5, 0x00D5); - cv(0x00F6, 0x00D6); - cv(0x00F8, 0x00D8); - cv(0x00F9, 0x00D9); - cv(0x00FA, 0x00DA); - cv(0x00FB, 0x00DB); - cv(0x00FC, 0x00DC); - cv(0x00FD, 0x00DD); - cv(0x00FE, 0x00DE); - cv(0x00FF, 0x0178); - cv(0x0100, 0x0101); - cv(0x0101, 0x0100); - cv(0x0102, 0x0103); - cv(0x0103, 0x0102); - cv(0x0104, 0x0105); - cv(0x0105, 0x0104); - cv(0x0106, 0x0107); - cv(0x0107, 0x0106); - cv(0x0108, 0x0109); - cv(0x0109, 0x0108); - cv(0x010A, 0x010B); - cv(0x010B, 0x010A); - cv(0x010C, 0x010D); - cv(0x010D, 0x010C); - cv(0x010E, 0x010F); - cv(0x010F, 0x010E); - cv(0x0110, 0x0111); - cv(0x0111, 0x0110); - cv(0x0112, 0x0113); - cv(0x0113, 0x0112); - cv(0x0114, 0x0115); - cv(0x0115, 0x0114); - cv(0x0116, 0x0117); - cv(0x0117, 0x0116); - cv(0x0118, 0x0119); - cv(0x0119, 0x0118); - cv(0x011A, 0x011B); - cv(0x011B, 0x011A); - cv(0x011C, 0x011D); - cv(0x011D, 0x011C); - cv(0x011E, 0x011F); - cv(0x011F, 0x011E); - cv(0x0120, 0x0121); - cv(0x0121, 0x0120); - cv(0x0122, 0x0123); - cv(0x0123, 0x0122); - cv(0x0124, 0x0125); - cv(0x0125, 0x0124); - cv(0x0126, 0x0127); - cv(0x0127, 0x0126); - cv(0x0128, 0x0129); - cv(0x0129, 0x0128); - cv(0x012A, 0x012B); - cv(0x012B, 0x012A); - cv(0x012C, 0x012D); - cv(0x012D, 0x012C); - cv(0x012E, 0x012F); - cv(0x012F, 0x012E); - cv(0x0130, 0x0049, 0x0069); - cv(0x0131, 0x0049, 0x0069); - cv(0x0132, 0x0133); - cv(0x0133, 0x0132); - cv(0x0134, 0x0135); - cv(0x0135, 0x0134); - cv(0x0136, 0x0137); - cv(0x0137, 0x0136); - cv(0x0139, 0x013A); - cv(0x013A, 0x0139); - cv(0x013B, 0x013C); - cv(0x013C, 0x013B); - cv(0x013D, 0x013E); - cv(0x013E, 0x013D); - cv(0x013F, 0x0140); - cv(0x0140, 0x013F); - cv(0x0141, 0x0142); - cv(0x0142, 0x0141); - cv(0x0143, 0x0144); - cv(0x0144, 0x0143); - cv(0x0145, 0x0146); - cv(0x0146, 0x0145); - cv(0x0147, 0x0148); - cv(0x0148, 0x0147); - cv(0x014A, 0x014B); - cv(0x014B, 0x014A); - cv(0x014C, 0x014D); - cv(0x014D, 0x014C); - cv(0x014E, 0x014F); - cv(0x014F, 0x014E); - cv(0x0150, 0x0151); - cv(0x0151, 0x0150); - cv(0x0152, 0x0153); - cv(0x0153, 0x0152); - cv(0x0154, 0x0155); - cv(0x0155, 0x0154); - cv(0x0156, 0x0157); - cv(0x0157, 0x0156); - cv(0x0158, 0x0159); - cv(0x0159, 0x0158); - cv(0x015A, 0x015B); - cv(0x015B, 0x015A); - cv(0x015C, 0x015D); - cv(0x015D, 0x015C); - cv(0x015E, 0x015F); - cv(0x015F, 0x015E); - cv(0x0160, 0x0161); - cv(0x0161, 0x0160); - cv(0x0162, 0x0163); - cv(0x0163, 0x0162); - cv(0x0164, 0x0165); - cv(0x0165, 0x0164); - cv(0x0166, 0x0167); - cv(0x0167, 0x0166); - cv(0x0168, 0x0169); - cv(0x0169, 0x0168); - cv(0x016A, 0x016B); - cv(0x016B, 0x016A); - cv(0x016C, 0x016D); - cv(0x016D, 0x016C); - cv(0x016E, 0x016F); - cv(0x016F, 0x016E); - cv(0x0170, 0x0171); - cv(0x0171, 0x0170); - cv(0x0172, 0x0173); - cv(0x0173, 0x0172); - cv(0x0174, 0x0175); - cv(0x0175, 0x0174); - cv(0x0176, 0x0177); - cv(0x0177, 0x0176); - cv(0x0178, 0x00FF); - cv(0x0179, 0x017A); - cv(0x017A, 0x0179); - cv(0x017B, 0x017C); - cv(0x017C, 0x017B); - cv(0x017D, 0x017E); - cv(0x017E, 0x017D); - cv(0x017F, 0x0053, 0x0073); - cv(0x0181, 0x0253); - cv(0x0182, 0x0183); - cv(0x0183, 0x0182); - cv(0x0184, 0x0185); - cv(0x0185, 0x0184); - cv(0x0186, 0x0254); - cv(0x0187, 0x0188); - cv(0x0188, 0x0187); - cv(0x0189, 0x0256); - cv(0x018A, 0x0257); - cv(0x018B, 0x018C); - cv(0x018C, 0x018B); - cv(0x018E, 0x01DD); - cv(0x018F, 0x0259); - cv(0x0190, 0x025B); - cv(0x0191, 0x0192); - cv(0x0192, 0x0191); - cv(0x0193, 0x0260); - cv(0x0194, 0x0263); - cv(0x0195, 0x01F6); - cv(0x0196, 0x0269); - cv(0x0197, 0x0268); - cv(0x0198, 0x0199); - cv(0x0199, 0x0198); - cv(0x019A, 0x023D); - cv(0x019C, 0x026F); - cv(0x019D, 0x0272); - cv(0x019E, 0x0220); - cv(0x019F, 0x0275); - cv(0x01A0, 0x01A1); - cv(0x01A1, 0x01A0); - cv(0x01A2, 0x01A3); - cv(0x01A3, 0x01A2); - cv(0x01A4, 0x01A5); - cv(0x01A5, 0x01A4); - cv(0x01A6, 0x0280); - cv(0x01A7, 0x01A8); - cv(0x01A8, 0x01A7); - cv(0x01A9, 0x0283); - cv(0x01AC, 0x01AD); - cv(0x01AD, 0x01AC); - cv(0x01AE, 0x0288); - cv(0x01AF, 0x01B0); - cv(0x01B0, 0x01AF); - cv(0x01B1, 0x028A); - cv(0x01B2, 0x028B); - cv(0x01B3, 0x01B4); - cv(0x01B4, 0x01B3); - cv(0x01B5, 0x01B6); - cv(0x01B6, 0x01B5); - cv(0x01B7, 0x0292); - cv(0x01B8, 0x01B9); - cv(0x01B9, 0x01B8); - cv(0x01BC, 0x01BD); - cv(0x01BD, 0x01BC); - cv(0x01BF, 0x01F7); - cv(0x01C4, 0x01C5, 0x01C6); - cv(0x01C5, 0x01C4, 0x01C6); - cv(0x01C6, 0x01C4, 0x01C5); - cv(0x01C7, 0x01C8, 0x01C9); - cv(0x01C8, 0x01C7, 0x01C9); - cv(0x01C9, 0x01C7, 0x01C8); - cv(0x01CA, 0x01CB, 0x01CC); - cv(0x01CB, 0x01CA, 0x01CC); - cv(0x01CC, 0x01CA, 0x01CB); - cv(0x01CD, 0x01CE); - cv(0x01CE, 0x01CD); - cv(0x01CF, 0x01D0); - cv(0x01D0, 0x01CF); - cv(0x01D1, 0x01D2); - cv(0x01D2, 0x01D1); - cv(0x01D3, 0x01D4); - cv(0x01D4, 0x01D3); - cv(0x01D5, 0x01D6); - cv(0x01D6, 0x01D5); - cv(0x01D7, 0x01D8); - cv(0x01D8, 0x01D7); - cv(0x01D9, 0x01DA); - cv(0x01DA, 0x01D9); - cv(0x01DB, 0x01DC); - cv(0x01DC, 0x01DB); - cv(0x01DD, 0x018E); - cv(0x01DE, 0x01DF); - cv(0x01DF, 0x01DE); - cv(0x01E0, 0x01E1); - cv(0x01E1, 0x01E0); - cv(0x01E2, 0x01E3); - cv(0x01E3, 0x01E2); - cv(0x01E4, 0x01E5); - cv(0x01E5, 0x01E4); - cv(0x01E6, 0x01E7); - cv(0x01E7, 0x01E6); - cv(0x01E8, 0x01E9); - cv(0x01E9, 0x01E8); - cv(0x01EA, 0x01EB); - cv(0x01EB, 0x01EA); - cv(0x01EC, 0x01ED); - cv(0x01ED, 0x01EC); - cv(0x01EE, 0x01EF); - cv(0x01EF, 0x01EE); - cv(0x01F1, 0x01F2, 0x01F3); - cv(0x01F2, 0x01F1, 0x01F3); - cv(0x01F3, 0x01F1, 0x01F2); - cv(0x01F4, 0x01F5); - cv(0x01F5, 0x01F4); - cv(0x01F6, 0x0195); - cv(0x01F7, 0x01BF); - cv(0x01F8, 0x01F9); - cv(0x01F9, 0x01F8); - cv(0x01FA, 0x01FB); - cv(0x01FB, 0x01FA); - cv(0x01FC, 0x01FD); - cv(0x01FD, 0x01FC); - cv(0x01FE, 0x01FF); - cv(0x01FF, 0x01FE); - cv(0x0200, 0x0201); - cv(0x0201, 0x0200); - cv(0x0202, 0x0203); - cv(0x0203, 0x0202); - cv(0x0204, 0x0205); - cv(0x0205, 0x0204); - cv(0x0206, 0x0207); - cv(0x0207, 0x0206); - cv(0x0208, 0x0209); - cv(0x0209, 0x0208); - cv(0x020A, 0x020B); - cv(0x020B, 0x020A); - cv(0x020C, 0x020D); - cv(0x020D, 0x020C); - cv(0x020E, 0x020F); - cv(0x020F, 0x020E); - cv(0x0210, 0x0211); - cv(0x0211, 0x0210); - cv(0x0212, 0x0213); - cv(0x0213, 0x0212); - cv(0x0214, 0x0215); - cv(0x0215, 0x0214); - cv(0x0216, 0x0217); - cv(0x0217, 0x0216); - cv(0x0218, 0x0219); - cv(0x0219, 0x0218); - cv(0x021A, 0x021B); - cv(0x021B, 0x021A); - cv(0x021C, 0x021D); - cv(0x021D, 0x021C); - cv(0x021E, 0x021F); - cv(0x021F, 0x021E); - cv(0x0220, 0x019E); - cv(0x0222, 0x0223); - cv(0x0223, 0x0222); - cv(0x0224, 0x0225); - cv(0x0225, 0x0224); - cv(0x0226, 0x0227); - cv(0x0227, 0x0226); - cv(0x0228, 0x0229); - cv(0x0229, 0x0228); - cv(0x022A, 0x022B); - cv(0x022B, 0x022A); - cv(0x022C, 0x022D); - cv(0x022D, 0x022C); - cv(0x022E, 0x022F); - cv(0x022F, 0x022E); - cv(0x0230, 0x0231); - cv(0x0231, 0x0230); - cv(0x0232, 0x0233); - cv(0x0233, 0x0232); - cv(0x023B, 0x023C); - cv(0x023C, 0x023B); - cv(0x023D, 0x019A); - cv(0x0241, 0x0294); - cv(0x0253, 0x0181); - cv(0x0254, 0x0186); - cv(0x0256, 0x0189); - cv(0x0257, 0x018A); - cv(0x0259, 0x018F); - cv(0x025B, 0x0190); - cv(0x0260, 0x0193); - cv(0x0263, 0x0194); - cv(0x0268, 0x0197); - cv(0x0269, 0x0196); - cv(0x026F, 0x019C); - cv(0x0272, 0x019D); - cv(0x0275, 0x019F); - cv(0x0280, 0x01A6); - cv(0x0283, 0x01A9); - cv(0x0288, 0x01AE); - cv(0x028A, 0x01B1); - cv(0x028B, 0x01B2); - cv(0x0292, 0x01B7); - cv(0x0294, 0x0241); - cv(0x0345, 0x0399, 0x03B9, 0x1FBE); - cv(0x0386, 0x03AC); - cv(0x0388, 0x03AD); - cv(0x0389, 0x03AE); - cv(0x038A, 0x03AF); - cv(0x038C, 0x03CC); - cv(0x038E, 0x03CD); - cv(0x038F, 0x03CE); - cv(0x0391, 0x03B1); - cv(0x0392, 0x03B2, 0x03D0); - cv(0x0393, 0x03B3); - cv(0x0394, 0x03B4); - cv(0x0395, 0x03B5, 0x03F5); - cv(0x0396, 0x03B6); - cv(0x0397, 0x03B7); - cv(0x0398, 0x03B8, 0x03D1, 0x03F4); - cv(0x0399, 0x0345, 0x03B9, 0x1FBE); - cv(0x039A, 0x03BA, 0x03F0); - cv(0x039B, 0x03BB); - cv(0x039C, 0x00B5, 0x03BC); - cv(0x039D, 0x03BD); - cv(0x039E, 0x03BE); - cv(0x039F, 0x03BF); - cv(0x03A0, 0x03C0, 0x03D6); - cv(0x03A1, 0x03C1, 0x03F1); - cv(0x03A3, 0x03C2, 0x03C3); - cv(0x03A4, 0x03C4); - cv(0x03A5, 0x03C5); - cv(0x03A6, 0x03C6, 0x03D5); - cv(0x03A7, 0x03C7); - cv(0x03A8, 0x03C8); - cv(0x03A9, 0x03C9, 0x2126); - cv(0x03AA, 0x03CA); - cv(0x03AB, 0x03CB); - cv(0x03AC, 0x0386); - cv(0x03AD, 0x0388); - cv(0x03AE, 0x0389); - cv(0x03AF, 0x038A); - cv(0x03B1, 0x0391); - cv(0x03B2, 0x0392, 0x03D0); - cv(0x03B3, 0x0393); - cv(0x03B4, 0x0394); - cv(0x03B5, 0x0395, 0x03F5); - cv(0x03B6, 0x0396); - cv(0x03B7, 0x0397); - cv(0x03B8, 0x0398, 0x03D1, 0x03F4); - cv(0x03B9, 0x0345, 0x0399, 0x1FBE); - cv(0x03BA, 0x039A, 0x03F0); - cv(0x03BB, 0x039B); - cv(0x03BC, 0x00B5, 0x039C); - cv(0x03BD, 0x039D); - cv(0x03BE, 0x039E); - cv(0x03BF, 0x039F); - cv(0x03C0, 0x03A0, 0x03D6); - cv(0x03C1, 0x03A1, 0x03F1); - cv(0x03C2, 0x03A3, 0x03C3); - cv(0x03C3, 0x03A3, 0x03C2); - cv(0x03C4, 0x03A4); - cv(0x03C5, 0x03A5); - cv(0x03C6, 0x03A6, 0x03D5); - cv(0x03C7, 0x03A7); - cv(0x03C8, 0x03A8); - cv(0x03C9, 0x03A9, 0x2126); - cv(0x03CA, 0x03AA); - cv(0x03CB, 0x03AB); - cv(0x03CC, 0x038C); - cv(0x03CD, 0x038E); - cv(0x03CE, 0x038F); - cv(0x03D0, 0x0392, 0x03B2); - cv(0x03D1, 0x0398, 0x03B8); - cv(0x03D5, 0x03A6, 0x03C6); - cv(0x03D6, 0x03A0, 0x03C0); - cv(0x03D8, 0x03D9); - cv(0x03D9, 0x03D8); - cv(0x03DA, 0x03DB); - cv(0x03DB, 0x03DA); - cv(0x03DC, 0x03DD); - cv(0x03DD, 0x03DC); - cv(0x03DE, 0x03DF); - cv(0x03DF, 0x03DE); - cv(0x03E0, 0x03E1); - cv(0x03E1, 0x03E0); - cv(0x03E2, 0x03E3); - cv(0x03E3, 0x03E2); - cv(0x03E4, 0x03E5); - cv(0x03E5, 0x03E4); - cv(0x03E6, 0x03E7); - cv(0x03E7, 0x03E6); - cv(0x03E8, 0x03E9); - cv(0x03E9, 0x03E8); - cv(0x03EA, 0x03EB); - cv(0x03EB, 0x03EA); - cv(0x03EC, 0x03ED); - cv(0x03ED, 0x03EC); - cv(0x03EE, 0x03EF); - cv(0x03EF, 0x03EE); - cv(0x03F0, 0x039A, 0x03BA); - cv(0x03F1, 0x03A1, 0x03C1); - cv(0x03F2, 0x03F9); - cv(0x03F4, 0x0398, 0x03B8); - cv(0x03F5, 0x0395, 0x03B5); - cv(0x03F7, 0x03F8); - cv(0x03F8, 0x03F7); - cv(0x03F9, 0x03F2); - cv(0x03FA, 0x03FB); - cv(0x03FB, 0x03FA); - cv(0x0400, 0x0450); - cv(0x0401, 0x0451); - cv(0x0402, 0x0452); - cv(0x0403, 0x0453); - cv(0x0404, 0x0454); - cv(0x0405, 0x0455); - cv(0x0406, 0x0456); - cv(0x0407, 0x0457); - cv(0x0408, 0x0458); - cv(0x0409, 0x0459); - cv(0x040A, 0x045A); - cv(0x040B, 0x045B); - cv(0x040C, 0x045C); - cv(0x040D, 0x045D); - cv(0x040E, 0x045E); - cv(0x040F, 0x045F); - cv(0x0410, 0x0430); - cv(0x0411, 0x0431); - cv(0x0412, 0x0432); - cv(0x0413, 0x0433); - cv(0x0414, 0x0434); - cv(0x0415, 0x0435); - cv(0x0416, 0x0436); - cv(0x0417, 0x0437); - cv(0x0418, 0x0438); - cv(0x0419, 0x0439); - cv(0x041A, 0x043A); - cv(0x041B, 0x043B); - cv(0x041C, 0x043C); - cv(0x041D, 0x043D); - cv(0x041E, 0x043E); - cv(0x041F, 0x043F); - cv(0x0420, 0x0440); - cv(0x0421, 0x0441); - cv(0x0422, 0x0442); - cv(0x0423, 0x0443); - cv(0x0424, 0x0444); - cv(0x0425, 0x0445); - cv(0x0426, 0x0446); - cv(0x0427, 0x0447); - cv(0x0428, 0x0448); - cv(0x0429, 0x0449); - cv(0x042A, 0x044A); - cv(0x042B, 0x044B); - cv(0x042C, 0x044C); - cv(0x042D, 0x044D); - cv(0x042E, 0x044E); - cv(0x042F, 0x044F); - cv(0x0430, 0x0410); - cv(0x0431, 0x0411); - cv(0x0432, 0x0412); - cv(0x0433, 0x0413); - cv(0x0434, 0x0414); - cv(0x0435, 0x0415); - cv(0x0436, 0x0416); - cv(0x0437, 0x0417); - cv(0x0438, 0x0418); - cv(0x0439, 0x0419); - cv(0x043A, 0x041A); - cv(0x043B, 0x041B); - cv(0x043C, 0x041C); - cv(0x043D, 0x041D); - cv(0x043E, 0x041E); - cv(0x043F, 0x041F); - cv(0x0440, 0x0420); - cv(0x0441, 0x0421); - cv(0x0442, 0x0422); - cv(0x0443, 0x0423); - cv(0x0444, 0x0424); - cv(0x0445, 0x0425); - cv(0x0446, 0x0426); - cv(0x0447, 0x0427); - cv(0x0448, 0x0428); - cv(0x0449, 0x0429); - cv(0x044A, 0x042A); - cv(0x044B, 0x042B); - cv(0x044C, 0x042C); - cv(0x044D, 0x042D); - cv(0x044E, 0x042E); - cv(0x044F, 0x042F); - cv(0x0450, 0x0400); - cv(0x0451, 0x0401); - cv(0x0452, 0x0402); - cv(0x0453, 0x0403); - cv(0x0454, 0x0404); - cv(0x0455, 0x0405); - cv(0x0456, 0x0406); - cv(0x0457, 0x0407); - cv(0x0458, 0x0408); - cv(0x0459, 0x0409); - cv(0x045A, 0x040A); - cv(0x045B, 0x040B); - cv(0x045C, 0x040C); - cv(0x045D, 0x040D); - cv(0x045E, 0x040E); - cv(0x045F, 0x040F); - cv(0x0460, 0x0461); - cv(0x0461, 0x0460); - cv(0x0462, 0x0463); - cv(0x0463, 0x0462); - cv(0x0464, 0x0465); - cv(0x0465, 0x0464); - cv(0x0466, 0x0467); - cv(0x0467, 0x0466); - cv(0x0468, 0x0469); - cv(0x0469, 0x0468); - cv(0x046A, 0x046B); - cv(0x046B, 0x046A); - cv(0x046C, 0x046D); - cv(0x046D, 0x046C); - cv(0x046E, 0x046F); - cv(0x046F, 0x046E); - cv(0x0470, 0x0471); - cv(0x0471, 0x0470); - cv(0x0472, 0x0473); - cv(0x0473, 0x0472); - cv(0x0474, 0x0475); - cv(0x0475, 0x0474); - cv(0x0476, 0x0477); - cv(0x0477, 0x0476); - cv(0x0478, 0x0479); - cv(0x0479, 0x0478); - cv(0x047A, 0x047B); - cv(0x047B, 0x047A); - cv(0x047C, 0x047D); - cv(0x047D, 0x047C); - cv(0x047E, 0x047F); - cv(0x047F, 0x047E); - cv(0x0480, 0x0481); - cv(0x0481, 0x0480); - cv(0x048A, 0x048B); - cv(0x048B, 0x048A); - cv(0x048C, 0x048D); - cv(0x048D, 0x048C); - cv(0x048E, 0x048F); - cv(0x048F, 0x048E); - cv(0x0490, 0x0491); - cv(0x0491, 0x0490); - cv(0x0492, 0x0493); - cv(0x0493, 0x0492); - cv(0x0494, 0x0495); - cv(0x0495, 0x0494); - cv(0x0496, 0x0497); - cv(0x0497, 0x0496); - cv(0x0498, 0x0499); - cv(0x0499, 0x0498); - cv(0x049A, 0x049B); - cv(0x049B, 0x049A); - cv(0x049C, 0x049D); - cv(0x049D, 0x049C); - cv(0x049E, 0x049F); - cv(0x049F, 0x049E); - cv(0x04A0, 0x04A1); - cv(0x04A1, 0x04A0); - cv(0x04A2, 0x04A3); - cv(0x04A3, 0x04A2); - cv(0x04A4, 0x04A5); - cv(0x04A5, 0x04A4); - cv(0x04A6, 0x04A7); - cv(0x04A7, 0x04A6); - cv(0x04A8, 0x04A9); - cv(0x04A9, 0x04A8); - cv(0x04AA, 0x04AB); - cv(0x04AB, 0x04AA); - cv(0x04AC, 0x04AD); - cv(0x04AD, 0x04AC); - cv(0x04AE, 0x04AF); - cv(0x04AF, 0x04AE); - cv(0x04B0, 0x04B1); - cv(0x04B1, 0x04B0); - cv(0x04B2, 0x04B3); - cv(0x04B3, 0x04B2); - cv(0x04B4, 0x04B5); - cv(0x04B5, 0x04B4); - cv(0x04B6, 0x04B7); - cv(0x04B7, 0x04B6); - cv(0x04B8, 0x04B9); - cv(0x04B9, 0x04B8); - cv(0x04BA, 0x04BB); - cv(0x04BB, 0x04BA); - cv(0x04BC, 0x04BD); - cv(0x04BD, 0x04BC); - cv(0x04BE, 0x04BF); - cv(0x04BF, 0x04BE); - cv(0x04C1, 0x04C2); - cv(0x04C2, 0x04C1); - cv(0x04C3, 0x04C4); - cv(0x04C4, 0x04C3); - cv(0x04C5, 0x04C6); - cv(0x04C6, 0x04C5); - cv(0x04C7, 0x04C8); - cv(0x04C8, 0x04C7); - cv(0x04C9, 0x04CA); - cv(0x04CA, 0x04C9); - cv(0x04CB, 0x04CC); - cv(0x04CC, 0x04CB); - cv(0x04CD, 0x04CE); - cv(0x04CE, 0x04CD); - cv(0x04D0, 0x04D1); - cv(0x04D1, 0x04D0); - cv(0x04D2, 0x04D3); - cv(0x04D3, 0x04D2); - cv(0x04D4, 0x04D5); - cv(0x04D5, 0x04D4); - cv(0x04D6, 0x04D7); - cv(0x04D7, 0x04D6); - cv(0x04D8, 0x04D9); - cv(0x04D9, 0x04D8); - cv(0x04DA, 0x04DB); - cv(0x04DB, 0x04DA); - cv(0x04DC, 0x04DD); - cv(0x04DD, 0x04DC); - cv(0x04DE, 0x04DF); - cv(0x04DF, 0x04DE); - cv(0x04E0, 0x04E1); - cv(0x04E1, 0x04E0); - cv(0x04E2, 0x04E3); - cv(0x04E3, 0x04E2); - cv(0x04E4, 0x04E5); - cv(0x04E5, 0x04E4); - cv(0x04E6, 0x04E7); - cv(0x04E7, 0x04E6); - cv(0x04E8, 0x04E9); - cv(0x04E9, 0x04E8); - cv(0x04EA, 0x04EB); - cv(0x04EB, 0x04EA); - cv(0x04EC, 0x04ED); - cv(0x04ED, 0x04EC); - cv(0x04EE, 0x04EF); - cv(0x04EF, 0x04EE); - cv(0x04F0, 0x04F1); - cv(0x04F1, 0x04F0); - cv(0x04F2, 0x04F3); - cv(0x04F3, 0x04F2); - cv(0x04F4, 0x04F5); - cv(0x04F5, 0x04F4); - cv(0x04F6, 0x04F7); - cv(0x04F7, 0x04F6); - cv(0x04F8, 0x04F9); - cv(0x04F9, 0x04F8); - cv(0x0500, 0x0501); - cv(0x0501, 0x0500); - cv(0x0502, 0x0503); - cv(0x0503, 0x0502); - cv(0x0504, 0x0505); - cv(0x0505, 0x0504); - cv(0x0506, 0x0507); - cv(0x0507, 0x0506); - cv(0x0508, 0x0509); - cv(0x0509, 0x0508); - cv(0x050A, 0x050B); - cv(0x050B, 0x050A); - cv(0x050C, 0x050D); - cv(0x050D, 0x050C); - cv(0x050E, 0x050F); - cv(0x050F, 0x050E); - cv(0x0531, 0x0561); - cv(0x0532, 0x0562); - cv(0x0533, 0x0563); - cv(0x0534, 0x0564); - cv(0x0535, 0x0565); - cv(0x0536, 0x0566); - cv(0x0537, 0x0567); - cv(0x0538, 0x0568); - cv(0x0539, 0x0569); - cv(0x053A, 0x056A); - cv(0x053B, 0x056B); - cv(0x053C, 0x056C); - cv(0x053D, 0x056D); - cv(0x053E, 0x056E); - cv(0x053F, 0x056F); - cv(0x0540, 0x0570); - cv(0x0541, 0x0571); - cv(0x0542, 0x0572); - cv(0x0543, 0x0573); - cv(0x0544, 0x0574); - cv(0x0545, 0x0575); - cv(0x0546, 0x0576); - cv(0x0547, 0x0577); - cv(0x0548, 0x0578); - cv(0x0549, 0x0579); - cv(0x054A, 0x057A); - cv(0x054B, 0x057B); - cv(0x054C, 0x057C); - cv(0x054D, 0x057D); - cv(0x054E, 0x057E); - cv(0x054F, 0x057F); - cv(0x0550, 0x0580); - cv(0x0551, 0x0581); - cv(0x0552, 0x0582); - cv(0x0553, 0x0583); - cv(0x0554, 0x0584); - cv(0x0555, 0x0585); - cv(0x0556, 0x0586); - cv(0x0561, 0x0531); - cv(0x0562, 0x0532); - cv(0x0563, 0x0533); - cv(0x0564, 0x0534); - cv(0x0565, 0x0535); - cv(0x0566, 0x0536); - cv(0x0567, 0x0537); - cv(0x0568, 0x0538); - cv(0x0569, 0x0539); - cv(0x056A, 0x053A); - cv(0x056B, 0x053B); - cv(0x056C, 0x053C); - cv(0x056D, 0x053D); - cv(0x056E, 0x053E); - cv(0x056F, 0x053F); - cv(0x0570, 0x0540); - cv(0x0571, 0x0541); - cv(0x0572, 0x0542); - cv(0x0573, 0x0543); - cv(0x0574, 0x0544); - cv(0x0575, 0x0545); - cv(0x0576, 0x0546); - cv(0x0577, 0x0547); - cv(0x0578, 0x0548); - cv(0x0579, 0x0549); - cv(0x057A, 0x054A); - cv(0x057B, 0x054B); - cv(0x057C, 0x054C); - cv(0x057D, 0x054D); - cv(0x057E, 0x054E); - cv(0x057F, 0x054F); - cv(0x0580, 0x0550); - cv(0x0581, 0x0551); - cv(0x0582, 0x0552); - cv(0x0583, 0x0553); - cv(0x0584, 0x0554); - cv(0x0585, 0x0555); - cv(0x0586, 0x0556); - cv(0x10A0, 0x2D00); - cv(0x10A1, 0x2D01); - cv(0x10A2, 0x2D02); - cv(0x10A3, 0x2D03); - cv(0x10A4, 0x2D04); - cv(0x10A5, 0x2D05); - cv(0x10A6, 0x2D06); - cv(0x10A7, 0x2D07); - cv(0x10A8, 0x2D08); - cv(0x10A9, 0x2D09); - cv(0x10AA, 0x2D0A); - cv(0x10AB, 0x2D0B); - cv(0x10AC, 0x2D0C); - cv(0x10AD, 0x2D0D); - cv(0x10AE, 0x2D0E); - cv(0x10AF, 0x2D0F); - cv(0x10B0, 0x2D10); - cv(0x10B1, 0x2D11); - cv(0x10B2, 0x2D12); - cv(0x10B3, 0x2D13); - cv(0x10B4, 0x2D14); - cv(0x10B5, 0x2D15); - cv(0x10B6, 0x2D16); - cv(0x10B7, 0x2D17); - cv(0x10B8, 0x2D18); - cv(0x10B9, 0x2D19); - cv(0x10BA, 0x2D1A); - cv(0x10BB, 0x2D1B); - cv(0x10BC, 0x2D1C); - cv(0x10BD, 0x2D1D); - cv(0x10BE, 0x2D1E); - cv(0x10BF, 0x2D1F); - cv(0x10C0, 0x2D20); - cv(0x10C1, 0x2D21); - cv(0x10C2, 0x2D22); - cv(0x10C3, 0x2D23); - cv(0x10C4, 0x2D24); - cv(0x10C5, 0x2D25); - cv(0x1E00, 0x1E01); - cv(0x1E01, 0x1E00); - cv(0x1E02, 0x1E03); - cv(0x1E03, 0x1E02); - cv(0x1E04, 0x1E05); - cv(0x1E05, 0x1E04); - cv(0x1E06, 0x1E07); - cv(0x1E07, 0x1E06); - cv(0x1E08, 0x1E09); - cv(0x1E09, 0x1E08); - cv(0x1E0A, 0x1E0B); - cv(0x1E0B, 0x1E0A); - cv(0x1E0C, 0x1E0D); - cv(0x1E0D, 0x1E0C); - cv(0x1E0E, 0x1E0F); - cv(0x1E0F, 0x1E0E); - cv(0x1E10, 0x1E11); - cv(0x1E11, 0x1E10); - cv(0x1E12, 0x1E13); - cv(0x1E13, 0x1E12); - cv(0x1E14, 0x1E15); - cv(0x1E15, 0x1E14); - cv(0x1E16, 0x1E17); - cv(0x1E17, 0x1E16); - cv(0x1E18, 0x1E19); - cv(0x1E19, 0x1E18); - cv(0x1E1A, 0x1E1B); - cv(0x1E1B, 0x1E1A); - cv(0x1E1C, 0x1E1D); - cv(0x1E1D, 0x1E1C); - cv(0x1E1E, 0x1E1F); - cv(0x1E1F, 0x1E1E); - cv(0x1E20, 0x1E21); - cv(0x1E21, 0x1E20); - cv(0x1E22, 0x1E23); - cv(0x1E23, 0x1E22); - cv(0x1E24, 0x1E25); - cv(0x1E25, 0x1E24); - cv(0x1E26, 0x1E27); - cv(0x1E27, 0x1E26); - cv(0x1E28, 0x1E29); - cv(0x1E29, 0x1E28); - cv(0x1E2A, 0x1E2B); - cv(0x1E2B, 0x1E2A); - cv(0x1E2C, 0x1E2D); - cv(0x1E2D, 0x1E2C); - cv(0x1E2E, 0x1E2F); - cv(0x1E2F, 0x1E2E); - cv(0x1E30, 0x1E31); - cv(0x1E31, 0x1E30); - cv(0x1E32, 0x1E33); - cv(0x1E33, 0x1E32); - cv(0x1E34, 0x1E35); - cv(0x1E35, 0x1E34); - cv(0x1E36, 0x1E37); - cv(0x1E37, 0x1E36); - cv(0x1E38, 0x1E39); - cv(0x1E39, 0x1E38); - cv(0x1E3A, 0x1E3B); - cv(0x1E3B, 0x1E3A); - cv(0x1E3C, 0x1E3D); - cv(0x1E3D, 0x1E3C); - cv(0x1E3E, 0x1E3F); - cv(0x1E3F, 0x1E3E); - cv(0x1E40, 0x1E41); - cv(0x1E41, 0x1E40); - cv(0x1E42, 0x1E43); - cv(0x1E43, 0x1E42); - cv(0x1E44, 0x1E45); - cv(0x1E45, 0x1E44); - cv(0x1E46, 0x1E47); - cv(0x1E47, 0x1E46); - cv(0x1E48, 0x1E49); - cv(0x1E49, 0x1E48); - cv(0x1E4A, 0x1E4B); - cv(0x1E4B, 0x1E4A); - cv(0x1E4C, 0x1E4D); - cv(0x1E4D, 0x1E4C); - cv(0x1E4E, 0x1E4F); - cv(0x1E4F, 0x1E4E); - cv(0x1E50, 0x1E51); - cv(0x1E51, 0x1E50); - cv(0x1E52, 0x1E53); - cv(0x1E53, 0x1E52); - cv(0x1E54, 0x1E55); - cv(0x1E55, 0x1E54); - cv(0x1E56, 0x1E57); - cv(0x1E57, 0x1E56); - cv(0x1E58, 0x1E59); - cv(0x1E59, 0x1E58); - cv(0x1E5A, 0x1E5B); - cv(0x1E5B, 0x1E5A); - cv(0x1E5C, 0x1E5D); - cv(0x1E5D, 0x1E5C); - cv(0x1E5E, 0x1E5F); - cv(0x1E5F, 0x1E5E); - cv(0x1E60, 0x1E61, 0x1E9B); - cv(0x1E61, 0x1E60, 0x1E9B); - cv(0x1E62, 0x1E63); - cv(0x1E63, 0x1E62); - cv(0x1E64, 0x1E65); - cv(0x1E65, 0x1E64); - cv(0x1E66, 0x1E67); - cv(0x1E67, 0x1E66); - cv(0x1E68, 0x1E69); - cv(0x1E69, 0x1E68); - cv(0x1E6A, 0x1E6B); - cv(0x1E6B, 0x1E6A); - cv(0x1E6C, 0x1E6D); - cv(0x1E6D, 0x1E6C); - cv(0x1E6E, 0x1E6F); - cv(0x1E6F, 0x1E6E); - cv(0x1E70, 0x1E71); - cv(0x1E71, 0x1E70); - cv(0x1E72, 0x1E73); - cv(0x1E73, 0x1E72); - cv(0x1E74, 0x1E75); - cv(0x1E75, 0x1E74); - cv(0x1E76, 0x1E77); - cv(0x1E77, 0x1E76); - cv(0x1E78, 0x1E79); - cv(0x1E79, 0x1E78); - cv(0x1E7A, 0x1E7B); - cv(0x1E7B, 0x1E7A); - cv(0x1E7C, 0x1E7D); - cv(0x1E7D, 0x1E7C); - cv(0x1E7E, 0x1E7F); - cv(0x1E7F, 0x1E7E); - cv(0x1E80, 0x1E81); - cv(0x1E81, 0x1E80); - cv(0x1E82, 0x1E83); - cv(0x1E83, 0x1E82); - cv(0x1E84, 0x1E85); - cv(0x1E85, 0x1E84); - cv(0x1E86, 0x1E87); - cv(0x1E87, 0x1E86); - cv(0x1E88, 0x1E89); - cv(0x1E89, 0x1E88); - cv(0x1E8A, 0x1E8B); - cv(0x1E8B, 0x1E8A); - cv(0x1E8C, 0x1E8D); - cv(0x1E8D, 0x1E8C); - cv(0x1E8E, 0x1E8F); - cv(0x1E8F, 0x1E8E); - cv(0x1E90, 0x1E91); - cv(0x1E91, 0x1E90); - cv(0x1E92, 0x1E93); - cv(0x1E93, 0x1E92); - cv(0x1E94, 0x1E95); - cv(0x1E95, 0x1E94); - cv(0x1E9B, 0x1E60, 0x1E61); - cv(0x1EA0, 0x1EA1); - cv(0x1EA1, 0x1EA0); - cv(0x1EA2, 0x1EA3); - cv(0x1EA3, 0x1EA2); - cv(0x1EA4, 0x1EA5); - cv(0x1EA5, 0x1EA4); - cv(0x1EA6, 0x1EA7); - cv(0x1EA7, 0x1EA6); - cv(0x1EA8, 0x1EA9); - cv(0x1EA9, 0x1EA8); - cv(0x1EAA, 0x1EAB); - cv(0x1EAB, 0x1EAA); - cv(0x1EAC, 0x1EAD); - cv(0x1EAD, 0x1EAC); - cv(0x1EAE, 0x1EAF); - cv(0x1EAF, 0x1EAE); - cv(0x1EB0, 0x1EB1); - cv(0x1EB1, 0x1EB0); - cv(0x1EB2, 0x1EB3); - cv(0x1EB3, 0x1EB2); - cv(0x1EB4, 0x1EB5); - cv(0x1EB5, 0x1EB4); - cv(0x1EB6, 0x1EB7); - cv(0x1EB7, 0x1EB6); - cv(0x1EB8, 0x1EB9); - cv(0x1EB9, 0x1EB8); - cv(0x1EBA, 0x1EBB); - cv(0x1EBB, 0x1EBA); - cv(0x1EBC, 0x1EBD); - cv(0x1EBD, 0x1EBC); - cv(0x1EBE, 0x1EBF); - cv(0x1EBF, 0x1EBE); - cv(0x1EC0, 0x1EC1); - cv(0x1EC1, 0x1EC0); - cv(0x1EC2, 0x1EC3); - cv(0x1EC3, 0x1EC2); - cv(0x1EC4, 0x1EC5); - cv(0x1EC5, 0x1EC4); - cv(0x1EC6, 0x1EC7); - cv(0x1EC7, 0x1EC6); - cv(0x1EC8, 0x1EC9); - cv(0x1EC9, 0x1EC8); - cv(0x1ECA, 0x1ECB); - cv(0x1ECB, 0x1ECA); - cv(0x1ECC, 0x1ECD); - cv(0x1ECD, 0x1ECC); - cv(0x1ECE, 0x1ECF); - cv(0x1ECF, 0x1ECE); - cv(0x1ED0, 0x1ED1); - cv(0x1ED1, 0x1ED0); - cv(0x1ED2, 0x1ED3); - cv(0x1ED3, 0x1ED2); - cv(0x1ED4, 0x1ED5); - cv(0x1ED5, 0x1ED4); - cv(0x1ED6, 0x1ED7); - cv(0x1ED7, 0x1ED6); - cv(0x1ED8, 0x1ED9); - cv(0x1ED9, 0x1ED8); - cv(0x1EDA, 0x1EDB); - cv(0x1EDB, 0x1EDA); - cv(0x1EDC, 0x1EDD); - cv(0x1EDD, 0x1EDC); - cv(0x1EDE, 0x1EDF); - cv(0x1EDF, 0x1EDE); - cv(0x1EE0, 0x1EE1); - cv(0x1EE1, 0x1EE0); - cv(0x1EE2, 0x1EE3); - cv(0x1EE3, 0x1EE2); - cv(0x1EE4, 0x1EE5); - cv(0x1EE5, 0x1EE4); - cv(0x1EE6, 0x1EE7); - cv(0x1EE7, 0x1EE6); - cv(0x1EE8, 0x1EE9); - cv(0x1EE9, 0x1EE8); - cv(0x1EEA, 0x1EEB); - cv(0x1EEB, 0x1EEA); - cv(0x1EEC, 0x1EED); - cv(0x1EED, 0x1EEC); - cv(0x1EEE, 0x1EEF); - cv(0x1EEF, 0x1EEE); - cv(0x1EF0, 0x1EF1); - cv(0x1EF1, 0x1EF0); - cv(0x1EF2, 0x1EF3); - cv(0x1EF3, 0x1EF2); - cv(0x1EF4, 0x1EF5); - cv(0x1EF5, 0x1EF4); - cv(0x1EF6, 0x1EF7); - cv(0x1EF7, 0x1EF6); - cv(0x1EF8, 0x1EF9); - cv(0x1EF9, 0x1EF8); - cv(0x1F00, 0x1F08); - cv(0x1F01, 0x1F09); - cv(0x1F02, 0x1F0A); - cv(0x1F03, 0x1F0B); - cv(0x1F04, 0x1F0C); - cv(0x1F05, 0x1F0D); - cv(0x1F06, 0x1F0E); - cv(0x1F07, 0x1F0F); - cv(0x1F08, 0x1F00); - cv(0x1F09, 0x1F01); - cv(0x1F0A, 0x1F02); - cv(0x1F0B, 0x1F03); - cv(0x1F0C, 0x1F04); - cv(0x1F0D, 0x1F05); - cv(0x1F0E, 0x1F06); - cv(0x1F0F, 0x1F07); - cv(0x1F10, 0x1F18); - cv(0x1F11, 0x1F19); - cv(0x1F12, 0x1F1A); - cv(0x1F13, 0x1F1B); - cv(0x1F14, 0x1F1C); - cv(0x1F15, 0x1F1D); - cv(0x1F18, 0x1F10); - cv(0x1F19, 0x1F11); - cv(0x1F1A, 0x1F12); - cv(0x1F1B, 0x1F13); - cv(0x1F1C, 0x1F14); - cv(0x1F1D, 0x1F15); - cv(0x1F20, 0x1F28); - cv(0x1F21, 0x1F29); - cv(0x1F22, 0x1F2A); - cv(0x1F23, 0x1F2B); - cv(0x1F24, 0x1F2C); - cv(0x1F25, 0x1F2D); - cv(0x1F26, 0x1F2E); - cv(0x1F27, 0x1F2F); - cv(0x1F28, 0x1F20); - cv(0x1F29, 0x1F21); - cv(0x1F2A, 0x1F22); - cv(0x1F2B, 0x1F23); - cv(0x1F2C, 0x1F24); - cv(0x1F2D, 0x1F25); - cv(0x1F2E, 0x1F26); - cv(0x1F2F, 0x1F27); - cv(0x1F30, 0x1F38); - cv(0x1F31, 0x1F39); - cv(0x1F32, 0x1F3A); - cv(0x1F33, 0x1F3B); - cv(0x1F34, 0x1F3C); - cv(0x1F35, 0x1F3D); - cv(0x1F36, 0x1F3E); - cv(0x1F37, 0x1F3F); - cv(0x1F38, 0x1F30); - cv(0x1F39, 0x1F31); - cv(0x1F3A, 0x1F32); - cv(0x1F3B, 0x1F33); - cv(0x1F3C, 0x1F34); - cv(0x1F3D, 0x1F35); - cv(0x1F3E, 0x1F36); - cv(0x1F3F, 0x1F37); - cv(0x1F40, 0x1F48); - cv(0x1F41, 0x1F49); - cv(0x1F42, 0x1F4A); - cv(0x1F43, 0x1F4B); - cv(0x1F44, 0x1F4C); - cv(0x1F45, 0x1F4D); - cv(0x1F48, 0x1F40); - cv(0x1F49, 0x1F41); - cv(0x1F4A, 0x1F42); - cv(0x1F4B, 0x1F43); - cv(0x1F4C, 0x1F44); - cv(0x1F4D, 0x1F45); - cv(0x1F51, 0x1F59); - cv(0x1F53, 0x1F5B); - cv(0x1F55, 0x1F5D); - cv(0x1F57, 0x1F5F); - cv(0x1F59, 0x1F51); - cv(0x1F5B, 0x1F53); - cv(0x1F5D, 0x1F55); - cv(0x1F5F, 0x1F57); - cv(0x1F60, 0x1F68); - cv(0x1F61, 0x1F69); - cv(0x1F62, 0x1F6A); - cv(0x1F63, 0x1F6B); - cv(0x1F64, 0x1F6C); - cv(0x1F65, 0x1F6D); - cv(0x1F66, 0x1F6E); - cv(0x1F67, 0x1F6F); - cv(0x1F68, 0x1F60); - cv(0x1F69, 0x1F61); - cv(0x1F6A, 0x1F62); - cv(0x1F6B, 0x1F63); - cv(0x1F6C, 0x1F64); - cv(0x1F6D, 0x1F65); - cv(0x1F6E, 0x1F66); - cv(0x1F6F, 0x1F67); - cv(0x1F70, 0x1FBA); - cv(0x1F71, 0x1FBB); - cv(0x1F72, 0x1FC8); - cv(0x1F73, 0x1FC9); - cv(0x1F74, 0x1FCA); - cv(0x1F75, 0x1FCB); - cv(0x1F76, 0x1FDA); - cv(0x1F77, 0x1FDB); - cv(0x1F78, 0x1FF8); - cv(0x1F79, 0x1FF9); - cv(0x1F7A, 0x1FEA); - cv(0x1F7B, 0x1FEB); - cv(0x1F7C, 0x1FFA); - cv(0x1F7D, 0x1FFB); - cv(0x1F80, 0x1F88); - cv(0x1F81, 0x1F89); - cv(0x1F82, 0x1F8A); - cv(0x1F83, 0x1F8B); - cv(0x1F84, 0x1F8C); - cv(0x1F85, 0x1F8D); - cv(0x1F86, 0x1F8E); - cv(0x1F87, 0x1F8F); - cv(0x1F88, 0x1F80); - cv(0x1F89, 0x1F81); - cv(0x1F8A, 0x1F82); - cv(0x1F8B, 0x1F83); - cv(0x1F8C, 0x1F84); - cv(0x1F8D, 0x1F85); - cv(0x1F8E, 0x1F86); - cv(0x1F8F, 0x1F87); - cv(0x1F90, 0x1F98); - cv(0x1F91, 0x1F99); - cv(0x1F92, 0x1F9A); - cv(0x1F93, 0x1F9B); - cv(0x1F94, 0x1F9C); - cv(0x1F95, 0x1F9D); - cv(0x1F96, 0x1F9E); - cv(0x1F97, 0x1F9F); - cv(0x1F98, 0x1F90); - cv(0x1F99, 0x1F91); - cv(0x1F9A, 0x1F92); - cv(0x1F9B, 0x1F93); - cv(0x1F9C, 0x1F94); - cv(0x1F9D, 0x1F95); - cv(0x1F9E, 0x1F96); - cv(0x1F9F, 0x1F97); - cv(0x1FA0, 0x1FA8); - cv(0x1FA1, 0x1FA9); - cv(0x1FA2, 0x1FAA); - cv(0x1FA3, 0x1FAB); - cv(0x1FA4, 0x1FAC); - cv(0x1FA5, 0x1FAD); - cv(0x1FA6, 0x1FAE); - cv(0x1FA7, 0x1FAF); - cv(0x1FA8, 0x1FA0); - cv(0x1FA9, 0x1FA1); - cv(0x1FAA, 0x1FA2); - cv(0x1FAB, 0x1FA3); - cv(0x1FAC, 0x1FA4); - cv(0x1FAD, 0x1FA5); - cv(0x1FAE, 0x1FA6); - cv(0x1FAF, 0x1FA7); - cv(0x1FB0, 0x1FB8); - cv(0x1FB1, 0x1FB9); - cv(0x1FB3, 0x1FBC); - cv(0x1FB8, 0x1FB0); - cv(0x1FB9, 0x1FB1); - cv(0x1FBA, 0x1F70); - cv(0x1FBB, 0x1F71); - cv(0x1FBC, 0x1FB3); - cv(0x1FBE, 0x0345, 0x0399, 0x03B9); - cv(0x1FC3, 0x1FCC); - cv(0x1FC8, 0x1F72); - cv(0x1FC9, 0x1F73); - cv(0x1FCA, 0x1F74); - cv(0x1FCB, 0x1F75); - cv(0x1FCC, 0x1FC3); - cv(0x1FD0, 0x1FD8); - cv(0x1FD1, 0x1FD9); - cv(0x1FD8, 0x1FD0); - cv(0x1FD9, 0x1FD1); - cv(0x1FDA, 0x1F76); - cv(0x1FDB, 0x1F77); - cv(0x1FE0, 0x1FE8); - cv(0x1FE1, 0x1FE9); - cv(0x1FE5, 0x1FEC); - cv(0x1FE8, 0x1FE0); - cv(0x1FE9, 0x1FE1); - cv(0x1FEA, 0x1F7A); - cv(0x1FEB, 0x1F7B); - cv(0x1FEC, 0x1FE5); - cv(0x1FF3, 0x1FFC); - cv(0x1FF8, 0x1F78); - cv(0x1FF9, 0x1F79); - cv(0x1FFA, 0x1F7C); - cv(0x1FFB, 0x1F7D); - cv(0x1FFC, 0x1FF3); - cv(0x2126, 0x03A9, 0x03C9); - cv(0x212A, 0x004B, 0x006B); - cv(0x212B, 0x00C5, 0x00E5); - cv(0x2160, 0x2170); - cv(0x2161, 0x2171); - cv(0x2162, 0x2172); - cv(0x2163, 0x2173); - cv(0x2164, 0x2174); - cv(0x2165, 0x2175); - cv(0x2166, 0x2176); - cv(0x2167, 0x2177); - cv(0x2168, 0x2178); - cv(0x2169, 0x2179); - cv(0x216A, 0x217A); - cv(0x216B, 0x217B); - cv(0x216C, 0x217C); - cv(0x216D, 0x217D); - cv(0x216E, 0x217E); - cv(0x216F, 0x217F); - cv(0x2170, 0x2160); - cv(0x2171, 0x2161); - cv(0x2172, 0x2162); - cv(0x2173, 0x2163); - cv(0x2174, 0x2164); - cv(0x2175, 0x2165); - cv(0x2176, 0x2166); - cv(0x2177, 0x2167); - cv(0x2178, 0x2168); - cv(0x2179, 0x2169); - cv(0x217A, 0x216A); - cv(0x217B, 0x216B); - cv(0x217C, 0x216C); - cv(0x217D, 0x216D); - cv(0x217E, 0x216E); - cv(0x217F, 0x216F); - cv(0x24B6, 0x24D0); - cv(0x24B7, 0x24D1); - cv(0x24B8, 0x24D2); - cv(0x24B9, 0x24D3); - cv(0x24BA, 0x24D4); - cv(0x24BB, 0x24D5); - cv(0x24BC, 0x24D6); - cv(0x24BD, 0x24D7); - cv(0x24BE, 0x24D8); - cv(0x24BF, 0x24D9); - cv(0x24C0, 0x24DA); - cv(0x24C1, 0x24DB); - cv(0x24C2, 0x24DC); - cv(0x24C3, 0x24DD); - cv(0x24C4, 0x24DE); - cv(0x24C5, 0x24DF); - cv(0x24C6, 0x24E0); - cv(0x24C7, 0x24E1); - cv(0x24C8, 0x24E2); - cv(0x24C9, 0x24E3); - cv(0x24CA, 0x24E4); - cv(0x24CB, 0x24E5); - cv(0x24CC, 0x24E6); - cv(0x24CD, 0x24E7); - cv(0x24CE, 0x24E8); - cv(0x24CF, 0x24E9); - cv(0x24D0, 0x24B6); - cv(0x24D1, 0x24B7); - cv(0x24D2, 0x24B8); - cv(0x24D3, 0x24B9); - cv(0x24D4, 0x24BA); - cv(0x24D5, 0x24BB); - cv(0x24D6, 0x24BC); - cv(0x24D7, 0x24BD); - cv(0x24D8, 0x24BE); - cv(0x24D9, 0x24BF); - cv(0x24DA, 0x24C0); - cv(0x24DB, 0x24C1); - cv(0x24DC, 0x24C2); - cv(0x24DD, 0x24C3); - cv(0x24DE, 0x24C4); - cv(0x24DF, 0x24C5); - cv(0x24E0, 0x24C6); - cv(0x24E1, 0x24C7); - cv(0x24E2, 0x24C8); - cv(0x24E3, 0x24C9); - cv(0x24E4, 0x24CA); - cv(0x24E5, 0x24CB); - cv(0x24E6, 0x24CC); - cv(0x24E7, 0x24CD); - cv(0x24E8, 0x24CE); - cv(0x24E9, 0x24CF); - cv(0x2C00, 0x2C30); - cv(0x2C01, 0x2C31); - cv(0x2C02, 0x2C32); - cv(0x2C03, 0x2C33); - cv(0x2C04, 0x2C34); - cv(0x2C05, 0x2C35); - cv(0x2C06, 0x2C36); - cv(0x2C07, 0x2C37); - cv(0x2C08, 0x2C38); - cv(0x2C09, 0x2C39); - cv(0x2C0A, 0x2C3A); - cv(0x2C0B, 0x2C3B); - cv(0x2C0C, 0x2C3C); - cv(0x2C0D, 0x2C3D); - cv(0x2C0E, 0x2C3E); - cv(0x2C0F, 0x2C3F); - cv(0x2C10, 0x2C40); - cv(0x2C11, 0x2C41); - cv(0x2C12, 0x2C42); - cv(0x2C13, 0x2C43); - cv(0x2C14, 0x2C44); - cv(0x2C15, 0x2C45); - cv(0x2C16, 0x2C46); - cv(0x2C17, 0x2C47); - cv(0x2C18, 0x2C48); - cv(0x2C19, 0x2C49); - cv(0x2C1A, 0x2C4A); - cv(0x2C1B, 0x2C4B); - cv(0x2C1C, 0x2C4C); - cv(0x2C1D, 0x2C4D); - cv(0x2C1E, 0x2C4E); - cv(0x2C1F, 0x2C4F); - cv(0x2C20, 0x2C50); - cv(0x2C21, 0x2C51); - cv(0x2C22, 0x2C52); - cv(0x2C23, 0x2C53); - cv(0x2C24, 0x2C54); - cv(0x2C25, 0x2C55); - cv(0x2C26, 0x2C56); - cv(0x2C27, 0x2C57); - cv(0x2C28, 0x2C58); - cv(0x2C29, 0x2C59); - cv(0x2C2A, 0x2C5A); - cv(0x2C2B, 0x2C5B); - cv(0x2C2C, 0x2C5C); - cv(0x2C2D, 0x2C5D); - cv(0x2C2E, 0x2C5E); - cv(0x2C30, 0x2C00); - cv(0x2C31, 0x2C01); - cv(0x2C32, 0x2C02); - cv(0x2C33, 0x2C03); - cv(0x2C34, 0x2C04); - cv(0x2C35, 0x2C05); - cv(0x2C36, 0x2C06); - cv(0x2C37, 0x2C07); - cv(0x2C38, 0x2C08); - cv(0x2C39, 0x2C09); - cv(0x2C3A, 0x2C0A); - cv(0x2C3B, 0x2C0B); - cv(0x2C3C, 0x2C0C); - cv(0x2C3D, 0x2C0D); - cv(0x2C3E, 0x2C0E); - cv(0x2C3F, 0x2C0F); - cv(0x2C40, 0x2C10); - cv(0x2C41, 0x2C11); - cv(0x2C42, 0x2C12); - cv(0x2C43, 0x2C13); - cv(0x2C44, 0x2C14); - cv(0x2C45, 0x2C15); - cv(0x2C46, 0x2C16); - cv(0x2C47, 0x2C17); - cv(0x2C48, 0x2C18); - cv(0x2C49, 0x2C19); - cv(0x2C4A, 0x2C1A); - cv(0x2C4B, 0x2C1B); - cv(0x2C4C, 0x2C1C); - cv(0x2C4D, 0x2C1D); - cv(0x2C4E, 0x2C1E); - cv(0x2C4F, 0x2C1F); - cv(0x2C50, 0x2C20); - cv(0x2C51, 0x2C21); - cv(0x2C52, 0x2C22); - cv(0x2C53, 0x2C23); - cv(0x2C54, 0x2C24); - cv(0x2C55, 0x2C25); - cv(0x2C56, 0x2C26); - cv(0x2C57, 0x2C27); - cv(0x2C58, 0x2C28); - cv(0x2C59, 0x2C29); - cv(0x2C5A, 0x2C2A); - cv(0x2C5B, 0x2C2B); - cv(0x2C5C, 0x2C2C); - cv(0x2C5D, 0x2C2D); - cv(0x2C5E, 0x2C2E); - cv(0x2C80, 0x2C81); - cv(0x2C81, 0x2C80); - cv(0x2C82, 0x2C83); - cv(0x2C83, 0x2C82); - cv(0x2C84, 0x2C85); - cv(0x2C85, 0x2C84); - cv(0x2C86, 0x2C87); - cv(0x2C87, 0x2C86); - cv(0x2C88, 0x2C89); - cv(0x2C89, 0x2C88); - cv(0x2C8A, 0x2C8B); - cv(0x2C8B, 0x2C8A); - cv(0x2C8C, 0x2C8D); - cv(0x2C8D, 0x2C8C); - cv(0x2C8E, 0x2C8F); - cv(0x2C8F, 0x2C8E); - cv(0x2C90, 0x2C91); - cv(0x2C91, 0x2C90); - cv(0x2C92, 0x2C93); - cv(0x2C93, 0x2C92); - cv(0x2C94, 0x2C95); - cv(0x2C95, 0x2C94); - cv(0x2C96, 0x2C97); - cv(0x2C97, 0x2C96); - cv(0x2C98, 0x2C99); - cv(0x2C99, 0x2C98); - cv(0x2C9A, 0x2C9B); - cv(0x2C9B, 0x2C9A); - cv(0x2C9C, 0x2C9D); - cv(0x2C9D, 0x2C9C); - cv(0x2C9E, 0x2C9F); - cv(0x2C9F, 0x2C9E); - cv(0x2CA0, 0x2CA1); - cv(0x2CA1, 0x2CA0); - cv(0x2CA2, 0x2CA3); - cv(0x2CA3, 0x2CA2); - cv(0x2CA4, 0x2CA5); - cv(0x2CA5, 0x2CA4); - cv(0x2CA6, 0x2CA7); - cv(0x2CA7, 0x2CA6); - cv(0x2CA8, 0x2CA9); - cv(0x2CA9, 0x2CA8); - cv(0x2CAA, 0x2CAB); - cv(0x2CAB, 0x2CAA); - cv(0x2CAC, 0x2CAD); - cv(0x2CAD, 0x2CAC); - cv(0x2CAE, 0x2CAF); - cv(0x2CAF, 0x2CAE); - cv(0x2CB0, 0x2CB1); - cv(0x2CB1, 0x2CB0); - cv(0x2CB2, 0x2CB3); - cv(0x2CB3, 0x2CB2); - cv(0x2CB4, 0x2CB5); - cv(0x2CB5, 0x2CB4); - cv(0x2CB6, 0x2CB7); - cv(0x2CB7, 0x2CB6); - cv(0x2CB8, 0x2CB9); - cv(0x2CB9, 0x2CB8); - cv(0x2CBA, 0x2CBB); - cv(0x2CBB, 0x2CBA); - cv(0x2CBC, 0x2CBD); - cv(0x2CBD, 0x2CBC); - cv(0x2CBE, 0x2CBF); - cv(0x2CBF, 0x2CBE); - cv(0x2CC0, 0x2CC1); - cv(0x2CC1, 0x2CC0); - cv(0x2CC2, 0x2CC3); - cv(0x2CC3, 0x2CC2); - cv(0x2CC4, 0x2CC5); - cv(0x2CC5, 0x2CC4); - cv(0x2CC6, 0x2CC7); - cv(0x2CC7, 0x2CC6); - cv(0x2CC8, 0x2CC9); - cv(0x2CC9, 0x2CC8); - cv(0x2CCA, 0x2CCB); - cv(0x2CCB, 0x2CCA); - cv(0x2CCC, 0x2CCD); - cv(0x2CCD, 0x2CCC); - cv(0x2CCE, 0x2CCF); - cv(0x2CCF, 0x2CCE); - cv(0x2CD0, 0x2CD1); - cv(0x2CD1, 0x2CD0); - cv(0x2CD2, 0x2CD3); - cv(0x2CD3, 0x2CD2); - cv(0x2CD4, 0x2CD5); - cv(0x2CD5, 0x2CD4); - cv(0x2CD6, 0x2CD7); - cv(0x2CD7, 0x2CD6); - cv(0x2CD8, 0x2CD9); - cv(0x2CD9, 0x2CD8); - cv(0x2CDA, 0x2CDB); - cv(0x2CDB, 0x2CDA); - cv(0x2CDC, 0x2CDD); - cv(0x2CDD, 0x2CDC); - cv(0x2CDE, 0x2CDF); - cv(0x2CDF, 0x2CDE); - cv(0x2CE0, 0x2CE1); - cv(0x2CE1, 0x2CE0); - cv(0x2CE2, 0x2CE3); - cv(0x2CE3, 0x2CE2); - cv(0x2D00, 0x10A0); - cv(0x2D01, 0x10A1); - cv(0x2D02, 0x10A2); - cv(0x2D03, 0x10A3); - cv(0x2D04, 0x10A4); - cv(0x2D05, 0x10A5); - cv(0x2D06, 0x10A6); - cv(0x2D07, 0x10A7); - cv(0x2D08, 0x10A8); - cv(0x2D09, 0x10A9); - cv(0x2D0A, 0x10AA); - cv(0x2D0B, 0x10AB); - cv(0x2D0C, 0x10AC); - cv(0x2D0D, 0x10AD); - cv(0x2D0E, 0x10AE); - cv(0x2D0F, 0x10AF); - cv(0x2D10, 0x10B0); - cv(0x2D11, 0x10B1); - cv(0x2D12, 0x10B2); - cv(0x2D13, 0x10B3); - cv(0x2D14, 0x10B4); - cv(0x2D15, 0x10B5); - cv(0x2D16, 0x10B6); - cv(0x2D17, 0x10B7); - cv(0x2D18, 0x10B8); - cv(0x2D19, 0x10B9); - cv(0x2D1A, 0x10BA); - cv(0x2D1B, 0x10BB); - cv(0x2D1C, 0x10BC); - cv(0x2D1D, 0x10BD); - cv(0x2D1E, 0x10BE); - cv(0x2D1F, 0x10BF); - cv(0x2D20, 0x10C0); - cv(0x2D21, 0x10C1); - cv(0x2D22, 0x10C2); - cv(0x2D23, 0x10C3); - cv(0x2D24, 0x10C4); - cv(0x2D25, 0x10C5); - cv(0xFF21, 0xFF41); - cv(0xFF22, 0xFF42); - cv(0xFF23, 0xFF43); - cv(0xFF24, 0xFF44); - cv(0xFF25, 0xFF45); - cv(0xFF26, 0xFF46); - cv(0xFF27, 0xFF47); - cv(0xFF28, 0xFF48); - cv(0xFF29, 0xFF49); - cv(0xFF2A, 0xFF4A); - cv(0xFF2B, 0xFF4B); - cv(0xFF2C, 0xFF4C); - cv(0xFF2D, 0xFF4D); - cv(0xFF2E, 0xFF4E); - cv(0xFF2F, 0xFF4F); - cv(0xFF30, 0xFF50); - cv(0xFF31, 0xFF51); - cv(0xFF32, 0xFF52); - cv(0xFF33, 0xFF53); - cv(0xFF34, 0xFF54); - cv(0xFF35, 0xFF55); - cv(0xFF36, 0xFF56); - cv(0xFF37, 0xFF57); - cv(0xFF38, 0xFF58); - cv(0xFF39, 0xFF59); - cv(0xFF3A, 0xFF5A); - cv(0xFF41, 0xFF21); - cv(0xFF42, 0xFF22); - cv(0xFF43, 0xFF23); - cv(0xFF44, 0xFF24); - cv(0xFF45, 0xFF25); - cv(0xFF46, 0xFF26); - cv(0xFF47, 0xFF27); - cv(0xFF48, 0xFF28); - cv(0xFF49, 0xFF29); - cv(0xFF4A, 0xFF2A); - cv(0xFF4B, 0xFF2B); - cv(0xFF4C, 0xFF2C); - cv(0xFF4D, 0xFF2D); - cv(0xFF4E, 0xFF2E); - cv(0xFF4F, 0xFF2F); - cv(0xFF50, 0xFF30); - cv(0xFF51, 0xFF31); - cv(0xFF52, 0xFF32); - cv(0xFF53, 0xFF33); - cv(0xFF54, 0xFF34); - cv(0xFF55, 0xFF35); - cv(0xFF56, 0xFF36); - cv(0xFF57, 0xFF37); - cv(0xFF58, 0xFF38); - cv(0xFF59, 0xFF39); - cv(0xFF5A, 0xFF3A); - cv(0x10400, 0x10428); - cv(0x10401, 0x10429); - cv(0x10402, 0x1042A); - cv(0x10403, 0x1042B); - cv(0x10404, 0x1042C); - cv(0x10405, 0x1042D); - cv(0x10406, 0x1042E); - cv(0x10407, 0x1042F); - cv(0x10408, 0x10430); - cv(0x10409, 0x10431); - cv(0x1040A, 0x10432); - cv(0x1040B, 0x10433); - cv(0x1040C, 0x10434); - cv(0x1040D, 0x10435); - cv(0x1040E, 0x10436); - cv(0x1040F, 0x10437); - cv(0x10410, 0x10438); - cv(0x10411, 0x10439); - cv(0x10412, 0x1043A); - cv(0x10413, 0x1043B); - cv(0x10414, 0x1043C); - cv(0x10415, 0x1043D); - cv(0x10416, 0x1043E); - cv(0x10417, 0x1043F); - cv(0x10418, 0x10440); - cv(0x10419, 0x10441); - cv(0x1041A, 0x10442); - cv(0x1041B, 0x10443); - cv(0x1041C, 0x10444); - cv(0x1041D, 0x10445); - cv(0x1041E, 0x10446); - cv(0x1041F, 0x10447); - cv(0x10420, 0x10448); - cv(0x10421, 0x10449); - cv(0x10422, 0x1044A); - cv(0x10423, 0x1044B); - cv(0x10424, 0x1044C); - cv(0x10425, 0x1044D); - cv(0x10426, 0x1044E); - cv(0x10427, 0x1044F); - cv(0x10428, 0x10400); - cv(0x10429, 0x10401); - cv(0x1042A, 0x10402); - cv(0x1042B, 0x10403); - cv(0x1042C, 0x10404); - cv(0x1042D, 0x10405); - cv(0x1042E, 0x10406); - cv(0x1042F, 0x10407); - cv(0x10430, 0x10408); - cv(0x10431, 0x10409); - cv(0x10432, 0x1040A); - cv(0x10433, 0x1040B); - cv(0x10434, 0x1040C); - cv(0x10435, 0x1040D); - cv(0x10436, 0x1040E); - cv(0x10437, 0x1040F); - cv(0x10438, 0x10410); - cv(0x10439, 0x10411); - cv(0x1043A, 0x10412); - cv(0x1043B, 0x10413); - cv(0x1043C, 0x10414); - cv(0x1043D, 0x10415); - cv(0x1043E, 0x10416); - cv(0x1043F, 0x10417); - cv(0x10440, 0x10418); - cv(0x10441, 0x10419); - cv(0x10442, 0x1041A); - cv(0x10443, 0x1041B); - cv(0x10444, 0x1041C); - cv(0x10445, 0x1041D); - cv(0x10446, 0x1041E); - cv(0x10447, 0x1041F); - cv(0x10448, 0x10420); - cv(0x10449, 0x10421); - cv(0x1044A, 0x10422); - cv(0x1044B, 0x10423); - cv(0x1044C, 0x10424); - cv(0x1044D, 0x10425); - cv(0x1044E, 0x10426); - cv(0x1044F, 0x10427); - } -} - -// -// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License"); -// you may not use this file except in compliance with the License. You may obtain a copy of the -// License at http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" basis, -// WITHOUT WARRANTY OF ANY KIND, either express or implied. -// See the License for the specific language governing rights and limitations under the License. -// -// The Original Code is: all this file -// -// The Initial Developer of the Original Code is Michael H. Kay. -// -// Contributor(s): -// - +package org.exist.xquery.regex; + +import org.exist.util.hashtable.Int2ObjectHashMap; + +/** + * This class holds data about the case-variants of Unicode characters. The data is automatically + * generated from the Unicode database. + * + * Copied from Saxon-HE 9.2 package net.sf.saxon.regex. + */ +public class CaseVariants { + + static int[] EMPTY_INT_ARRAY = new int[0]; + + // Use one hashmap for characters with a single case variant, another for characters with multiple + // case variants, to reduce the number of objects that need to be allocated + + private static Int2ObjectHashMap monoVariants = new Int2ObjectHashMap(2500); + private static Int2ObjectHashMap polyVariants = new Int2ObjectHashMap(100); + + private static void cv(int a, int b) { + monoVariants.put(a, b); + } + + private static void cv(int a, int b, int c) { + final int[] v = {b, c}; + polyVariants.put(a, v); + } + + private static void cv(int a, int b, int c, int d) { + final int[] v = {b, c, d}; + polyVariants.put(a, v); + } + + /** + * Get the case variants of a character + * + * @param code the character whose case variants are required + * @return the case variants of the character, excluding the character itself + */ + + public static int[] getCaseVariants(int code) { + final int mono = (Integer) monoVariants.get(code); + //UNDERSTAND: is it safe? +// if (mono != monoVariants.getDefaultValue()) { +// return new int[]{mono}; +// } else { + final int[] result = polyVariants.get(code); + if (result == null) { + return EMPTY_INT_ARRAY; + } else { + return result; + } +// } + } + + /** + * Get the case variants of roman letters (A-Z, a-z), other than the letters A-Z and a-z themselves + */ + + public static int[] ROMAN_VARIANTS = {0x0130, 0x0131, 0x212A, 0x017F}; + + /** + * The following data was generated from the Unicode database as follows: + * (a) the database was converted to XML + * (b) the following query was run: + * let $chars := doc('UnicodeData.xml')/ * /Char[string(toUpper) or string(toLower)] + * for $c in $chars + * let $variants := ($chars[(code, toUpper) = $c/(code, toUpper)] | + * $chars[(code, toLower) = $c/(code, toLower)]) except $c + * return + * if (count($variants) gt 0) then + * concat("cv(0x", $c/code, ", 0x", string-join($variants/code, ", 0x"), "); ") + * else () + */ + + + static { + cv(0x0041, 0x0061); + cv(0x0042, 0x0062); + cv(0x0043, 0x0063); + cv(0x0044, 0x0064); + cv(0x0045, 0x0065); + cv(0x0046, 0x0066); + cv(0x0047, 0x0067); + cv(0x0048, 0x0068); + cv(0x0049, 0x0069, 0x0130, 0x0131); + cv(0x004A, 0x006A); + cv(0x004B, 0x006B, 0x212A); + cv(0x004C, 0x006C); + cv(0x004D, 0x006D); + cv(0x004E, 0x006E); + cv(0x004F, 0x006F); + cv(0x0050, 0x0070); + cv(0x0051, 0x0071); + cv(0x0052, 0x0072); + cv(0x0053, 0x0073, 0x017F); + cv(0x0054, 0x0074); + cv(0x0055, 0x0075); + cv(0x0056, 0x0076); + cv(0x0057, 0x0077); + cv(0x0058, 0x0078); + cv(0x0059, 0x0079); + cv(0x005A, 0x007A); + cv(0x0061, 0x0041); + cv(0x0062, 0x0042); + cv(0x0063, 0x0043); + cv(0x0064, 0x0044); + cv(0x0065, 0x0045); + cv(0x0066, 0x0046); + cv(0x0067, 0x0047); + cv(0x0068, 0x0048); + cv(0x0069, 0x0049, 0x0130, 0x0131); + cv(0x006A, 0x004A); + cv(0x006B, 0x004B, 0x212A); + cv(0x006C, 0x004C); + cv(0x006D, 0x004D); + cv(0x006E, 0x004E); + cv(0x006F, 0x004F); + cv(0x0070, 0x0050); + cv(0x0071, 0x0051); + cv(0x0072, 0x0052); + cv(0x0073, 0x0053, 0x017F); + cv(0x0074, 0x0054); + cv(0x0075, 0x0055); + cv(0x0076, 0x0056); + cv(0x0077, 0x0057); + cv(0x0078, 0x0058); + cv(0x0079, 0x0059); + cv(0x007A, 0x005A); + cv(0x00B5, 0x039C, 0x03BC); + cv(0x00C0, 0x00E0); + cv(0x00C1, 0x00E1); + cv(0x00C2, 0x00E2); + cv(0x00C3, 0x00E3); + cv(0x00C4, 0x00E4); + cv(0x00C5, 0x00E5, 0x212B); + cv(0x00C6, 0x00E6); + cv(0x00C7, 0x00E7); + cv(0x00C8, 0x00E8); + cv(0x00C9, 0x00E9); + cv(0x00CA, 0x00EA); + cv(0x00CB, 0x00EB); + cv(0x00CC, 0x00EC); + cv(0x00CD, 0x00ED); + cv(0x00CE, 0x00EE); + cv(0x00CF, 0x00EF); + cv(0x00D0, 0x00F0); + cv(0x00D1, 0x00F1); + cv(0x00D2, 0x00F2); + cv(0x00D3, 0x00F3); + cv(0x00D4, 0x00F4); + cv(0x00D5, 0x00F5); + cv(0x00D6, 0x00F6); + cv(0x00D8, 0x00F8); + cv(0x00D9, 0x00F9); + cv(0x00DA, 0x00FA); + cv(0x00DB, 0x00FB); + cv(0x00DC, 0x00FC); + cv(0x00DD, 0x00FD); + cv(0x00DE, 0x00FE); + cv(0x00E0, 0x00C0); + cv(0x00E1, 0x00C1); + cv(0x00E2, 0x00C2); + cv(0x00E3, 0x00C3); + cv(0x00E4, 0x00C4); + cv(0x00E5, 0x00C5, 0x212B); + cv(0x00E6, 0x00C6); + cv(0x00E7, 0x00C7); + cv(0x00E8, 0x00C8); + cv(0x00E9, 0x00C9); + cv(0x00EA, 0x00CA); + cv(0x00EB, 0x00CB); + cv(0x00EC, 0x00CC); + cv(0x00ED, 0x00CD); + cv(0x00EE, 0x00CE); + cv(0x00EF, 0x00CF); + cv(0x00F0, 0x00D0); + cv(0x00F1, 0x00D1); + cv(0x00F2, 0x00D2); + cv(0x00F3, 0x00D3); + cv(0x00F4, 0x00D4); + cv(0x00F5, 0x00D5); + cv(0x00F6, 0x00D6); + cv(0x00F8, 0x00D8); + cv(0x00F9, 0x00D9); + cv(0x00FA, 0x00DA); + cv(0x00FB, 0x00DB); + cv(0x00FC, 0x00DC); + cv(0x00FD, 0x00DD); + cv(0x00FE, 0x00DE); + cv(0x00FF, 0x0178); + cv(0x0100, 0x0101); + cv(0x0101, 0x0100); + cv(0x0102, 0x0103); + cv(0x0103, 0x0102); + cv(0x0104, 0x0105); + cv(0x0105, 0x0104); + cv(0x0106, 0x0107); + cv(0x0107, 0x0106); + cv(0x0108, 0x0109); + cv(0x0109, 0x0108); + cv(0x010A, 0x010B); + cv(0x010B, 0x010A); + cv(0x010C, 0x010D); + cv(0x010D, 0x010C); + cv(0x010E, 0x010F); + cv(0x010F, 0x010E); + cv(0x0110, 0x0111); + cv(0x0111, 0x0110); + cv(0x0112, 0x0113); + cv(0x0113, 0x0112); + cv(0x0114, 0x0115); + cv(0x0115, 0x0114); + cv(0x0116, 0x0117); + cv(0x0117, 0x0116); + cv(0x0118, 0x0119); + cv(0x0119, 0x0118); + cv(0x011A, 0x011B); + cv(0x011B, 0x011A); + cv(0x011C, 0x011D); + cv(0x011D, 0x011C); + cv(0x011E, 0x011F); + cv(0x011F, 0x011E); + cv(0x0120, 0x0121); + cv(0x0121, 0x0120); + cv(0x0122, 0x0123); + cv(0x0123, 0x0122); + cv(0x0124, 0x0125); + cv(0x0125, 0x0124); + cv(0x0126, 0x0127); + cv(0x0127, 0x0126); + cv(0x0128, 0x0129); + cv(0x0129, 0x0128); + cv(0x012A, 0x012B); + cv(0x012B, 0x012A); + cv(0x012C, 0x012D); + cv(0x012D, 0x012C); + cv(0x012E, 0x012F); + cv(0x012F, 0x012E); + cv(0x0130, 0x0049, 0x0069); + cv(0x0131, 0x0049, 0x0069); + cv(0x0132, 0x0133); + cv(0x0133, 0x0132); + cv(0x0134, 0x0135); + cv(0x0135, 0x0134); + cv(0x0136, 0x0137); + cv(0x0137, 0x0136); + cv(0x0139, 0x013A); + cv(0x013A, 0x0139); + cv(0x013B, 0x013C); + cv(0x013C, 0x013B); + cv(0x013D, 0x013E); + cv(0x013E, 0x013D); + cv(0x013F, 0x0140); + cv(0x0140, 0x013F); + cv(0x0141, 0x0142); + cv(0x0142, 0x0141); + cv(0x0143, 0x0144); + cv(0x0144, 0x0143); + cv(0x0145, 0x0146); + cv(0x0146, 0x0145); + cv(0x0147, 0x0148); + cv(0x0148, 0x0147); + cv(0x014A, 0x014B); + cv(0x014B, 0x014A); + cv(0x014C, 0x014D); + cv(0x014D, 0x014C); + cv(0x014E, 0x014F); + cv(0x014F, 0x014E); + cv(0x0150, 0x0151); + cv(0x0151, 0x0150); + cv(0x0152, 0x0153); + cv(0x0153, 0x0152); + cv(0x0154, 0x0155); + cv(0x0155, 0x0154); + cv(0x0156, 0x0157); + cv(0x0157, 0x0156); + cv(0x0158, 0x0159); + cv(0x0159, 0x0158); + cv(0x015A, 0x015B); + cv(0x015B, 0x015A); + cv(0x015C, 0x015D); + cv(0x015D, 0x015C); + cv(0x015E, 0x015F); + cv(0x015F, 0x015E); + cv(0x0160, 0x0161); + cv(0x0161, 0x0160); + cv(0x0162, 0x0163); + cv(0x0163, 0x0162); + cv(0x0164, 0x0165); + cv(0x0165, 0x0164); + cv(0x0166, 0x0167); + cv(0x0167, 0x0166); + cv(0x0168, 0x0169); + cv(0x0169, 0x0168); + cv(0x016A, 0x016B); + cv(0x016B, 0x016A); + cv(0x016C, 0x016D); + cv(0x016D, 0x016C); + cv(0x016E, 0x016F); + cv(0x016F, 0x016E); + cv(0x0170, 0x0171); + cv(0x0171, 0x0170); + cv(0x0172, 0x0173); + cv(0x0173, 0x0172); + cv(0x0174, 0x0175); + cv(0x0175, 0x0174); + cv(0x0176, 0x0177); + cv(0x0177, 0x0176); + cv(0x0178, 0x00FF); + cv(0x0179, 0x017A); + cv(0x017A, 0x0179); + cv(0x017B, 0x017C); + cv(0x017C, 0x017B); + cv(0x017D, 0x017E); + cv(0x017E, 0x017D); + cv(0x017F, 0x0053, 0x0073); + cv(0x0181, 0x0253); + cv(0x0182, 0x0183); + cv(0x0183, 0x0182); + cv(0x0184, 0x0185); + cv(0x0185, 0x0184); + cv(0x0186, 0x0254); + cv(0x0187, 0x0188); + cv(0x0188, 0x0187); + cv(0x0189, 0x0256); + cv(0x018A, 0x0257); + cv(0x018B, 0x018C); + cv(0x018C, 0x018B); + cv(0x018E, 0x01DD); + cv(0x018F, 0x0259); + cv(0x0190, 0x025B); + cv(0x0191, 0x0192); + cv(0x0192, 0x0191); + cv(0x0193, 0x0260); + cv(0x0194, 0x0263); + cv(0x0195, 0x01F6); + cv(0x0196, 0x0269); + cv(0x0197, 0x0268); + cv(0x0198, 0x0199); + cv(0x0199, 0x0198); + cv(0x019A, 0x023D); + cv(0x019C, 0x026F); + cv(0x019D, 0x0272); + cv(0x019E, 0x0220); + cv(0x019F, 0x0275); + cv(0x01A0, 0x01A1); + cv(0x01A1, 0x01A0); + cv(0x01A2, 0x01A3); + cv(0x01A3, 0x01A2); + cv(0x01A4, 0x01A5); + cv(0x01A5, 0x01A4); + cv(0x01A6, 0x0280); + cv(0x01A7, 0x01A8); + cv(0x01A8, 0x01A7); + cv(0x01A9, 0x0283); + cv(0x01AC, 0x01AD); + cv(0x01AD, 0x01AC); + cv(0x01AE, 0x0288); + cv(0x01AF, 0x01B0); + cv(0x01B0, 0x01AF); + cv(0x01B1, 0x028A); + cv(0x01B2, 0x028B); + cv(0x01B3, 0x01B4); + cv(0x01B4, 0x01B3); + cv(0x01B5, 0x01B6); + cv(0x01B6, 0x01B5); + cv(0x01B7, 0x0292); + cv(0x01B8, 0x01B9); + cv(0x01B9, 0x01B8); + cv(0x01BC, 0x01BD); + cv(0x01BD, 0x01BC); + cv(0x01BF, 0x01F7); + cv(0x01C4, 0x01C5, 0x01C6); + cv(0x01C5, 0x01C4, 0x01C6); + cv(0x01C6, 0x01C4, 0x01C5); + cv(0x01C7, 0x01C8, 0x01C9); + cv(0x01C8, 0x01C7, 0x01C9); + cv(0x01C9, 0x01C7, 0x01C8); + cv(0x01CA, 0x01CB, 0x01CC); + cv(0x01CB, 0x01CA, 0x01CC); + cv(0x01CC, 0x01CA, 0x01CB); + cv(0x01CD, 0x01CE); + cv(0x01CE, 0x01CD); + cv(0x01CF, 0x01D0); + cv(0x01D0, 0x01CF); + cv(0x01D1, 0x01D2); + cv(0x01D2, 0x01D1); + cv(0x01D3, 0x01D4); + cv(0x01D4, 0x01D3); + cv(0x01D5, 0x01D6); + cv(0x01D6, 0x01D5); + cv(0x01D7, 0x01D8); + cv(0x01D8, 0x01D7); + cv(0x01D9, 0x01DA); + cv(0x01DA, 0x01D9); + cv(0x01DB, 0x01DC); + cv(0x01DC, 0x01DB); + cv(0x01DD, 0x018E); + cv(0x01DE, 0x01DF); + cv(0x01DF, 0x01DE); + cv(0x01E0, 0x01E1); + cv(0x01E1, 0x01E0); + cv(0x01E2, 0x01E3); + cv(0x01E3, 0x01E2); + cv(0x01E4, 0x01E5); + cv(0x01E5, 0x01E4); + cv(0x01E6, 0x01E7); + cv(0x01E7, 0x01E6); + cv(0x01E8, 0x01E9); + cv(0x01E9, 0x01E8); + cv(0x01EA, 0x01EB); + cv(0x01EB, 0x01EA); + cv(0x01EC, 0x01ED); + cv(0x01ED, 0x01EC); + cv(0x01EE, 0x01EF); + cv(0x01EF, 0x01EE); + cv(0x01F1, 0x01F2, 0x01F3); + cv(0x01F2, 0x01F1, 0x01F3); + cv(0x01F3, 0x01F1, 0x01F2); + cv(0x01F4, 0x01F5); + cv(0x01F5, 0x01F4); + cv(0x01F6, 0x0195); + cv(0x01F7, 0x01BF); + cv(0x01F8, 0x01F9); + cv(0x01F9, 0x01F8); + cv(0x01FA, 0x01FB); + cv(0x01FB, 0x01FA); + cv(0x01FC, 0x01FD); + cv(0x01FD, 0x01FC); + cv(0x01FE, 0x01FF); + cv(0x01FF, 0x01FE); + cv(0x0200, 0x0201); + cv(0x0201, 0x0200); + cv(0x0202, 0x0203); + cv(0x0203, 0x0202); + cv(0x0204, 0x0205); + cv(0x0205, 0x0204); + cv(0x0206, 0x0207); + cv(0x0207, 0x0206); + cv(0x0208, 0x0209); + cv(0x0209, 0x0208); + cv(0x020A, 0x020B); + cv(0x020B, 0x020A); + cv(0x020C, 0x020D); + cv(0x020D, 0x020C); + cv(0x020E, 0x020F); + cv(0x020F, 0x020E); + cv(0x0210, 0x0211); + cv(0x0211, 0x0210); + cv(0x0212, 0x0213); + cv(0x0213, 0x0212); + cv(0x0214, 0x0215); + cv(0x0215, 0x0214); + cv(0x0216, 0x0217); + cv(0x0217, 0x0216); + cv(0x0218, 0x0219); + cv(0x0219, 0x0218); + cv(0x021A, 0x021B); + cv(0x021B, 0x021A); + cv(0x021C, 0x021D); + cv(0x021D, 0x021C); + cv(0x021E, 0x021F); + cv(0x021F, 0x021E); + cv(0x0220, 0x019E); + cv(0x0222, 0x0223); + cv(0x0223, 0x0222); + cv(0x0224, 0x0225); + cv(0x0225, 0x0224); + cv(0x0226, 0x0227); + cv(0x0227, 0x0226); + cv(0x0228, 0x0229); + cv(0x0229, 0x0228); + cv(0x022A, 0x022B); + cv(0x022B, 0x022A); + cv(0x022C, 0x022D); + cv(0x022D, 0x022C); + cv(0x022E, 0x022F); + cv(0x022F, 0x022E); + cv(0x0230, 0x0231); + cv(0x0231, 0x0230); + cv(0x0232, 0x0233); + cv(0x0233, 0x0232); + cv(0x023B, 0x023C); + cv(0x023C, 0x023B); + cv(0x023D, 0x019A); + cv(0x0241, 0x0294); + cv(0x0253, 0x0181); + cv(0x0254, 0x0186); + cv(0x0256, 0x0189); + cv(0x0257, 0x018A); + cv(0x0259, 0x018F); + cv(0x025B, 0x0190); + cv(0x0260, 0x0193); + cv(0x0263, 0x0194); + cv(0x0268, 0x0197); + cv(0x0269, 0x0196); + cv(0x026F, 0x019C); + cv(0x0272, 0x019D); + cv(0x0275, 0x019F); + cv(0x0280, 0x01A6); + cv(0x0283, 0x01A9); + cv(0x0288, 0x01AE); + cv(0x028A, 0x01B1); + cv(0x028B, 0x01B2); + cv(0x0292, 0x01B7); + cv(0x0294, 0x0241); + cv(0x0345, 0x0399, 0x03B9, 0x1FBE); + cv(0x0386, 0x03AC); + cv(0x0388, 0x03AD); + cv(0x0389, 0x03AE); + cv(0x038A, 0x03AF); + cv(0x038C, 0x03CC); + cv(0x038E, 0x03CD); + cv(0x038F, 0x03CE); + cv(0x0391, 0x03B1); + cv(0x0392, 0x03B2, 0x03D0); + cv(0x0393, 0x03B3); + cv(0x0394, 0x03B4); + cv(0x0395, 0x03B5, 0x03F5); + cv(0x0396, 0x03B6); + cv(0x0397, 0x03B7); + cv(0x0398, 0x03B8, 0x03D1, 0x03F4); + cv(0x0399, 0x0345, 0x03B9, 0x1FBE); + cv(0x039A, 0x03BA, 0x03F0); + cv(0x039B, 0x03BB); + cv(0x039C, 0x00B5, 0x03BC); + cv(0x039D, 0x03BD); + cv(0x039E, 0x03BE); + cv(0x039F, 0x03BF); + cv(0x03A0, 0x03C0, 0x03D6); + cv(0x03A1, 0x03C1, 0x03F1); + cv(0x03A3, 0x03C2, 0x03C3); + cv(0x03A4, 0x03C4); + cv(0x03A5, 0x03C5); + cv(0x03A6, 0x03C6, 0x03D5); + cv(0x03A7, 0x03C7); + cv(0x03A8, 0x03C8); + cv(0x03A9, 0x03C9, 0x2126); + cv(0x03AA, 0x03CA); + cv(0x03AB, 0x03CB); + cv(0x03AC, 0x0386); + cv(0x03AD, 0x0388); + cv(0x03AE, 0x0389); + cv(0x03AF, 0x038A); + cv(0x03B1, 0x0391); + cv(0x03B2, 0x0392, 0x03D0); + cv(0x03B3, 0x0393); + cv(0x03B4, 0x0394); + cv(0x03B5, 0x0395, 0x03F5); + cv(0x03B6, 0x0396); + cv(0x03B7, 0x0397); + cv(0x03B8, 0x0398, 0x03D1, 0x03F4); + cv(0x03B9, 0x0345, 0x0399, 0x1FBE); + cv(0x03BA, 0x039A, 0x03F0); + cv(0x03BB, 0x039B); + cv(0x03BC, 0x00B5, 0x039C); + cv(0x03BD, 0x039D); + cv(0x03BE, 0x039E); + cv(0x03BF, 0x039F); + cv(0x03C0, 0x03A0, 0x03D6); + cv(0x03C1, 0x03A1, 0x03F1); + cv(0x03C2, 0x03A3, 0x03C3); + cv(0x03C3, 0x03A3, 0x03C2); + cv(0x03C4, 0x03A4); + cv(0x03C5, 0x03A5); + cv(0x03C6, 0x03A6, 0x03D5); + cv(0x03C7, 0x03A7); + cv(0x03C8, 0x03A8); + cv(0x03C9, 0x03A9, 0x2126); + cv(0x03CA, 0x03AA); + cv(0x03CB, 0x03AB); + cv(0x03CC, 0x038C); + cv(0x03CD, 0x038E); + cv(0x03CE, 0x038F); + cv(0x03D0, 0x0392, 0x03B2); + cv(0x03D1, 0x0398, 0x03B8); + cv(0x03D5, 0x03A6, 0x03C6); + cv(0x03D6, 0x03A0, 0x03C0); + cv(0x03D8, 0x03D9); + cv(0x03D9, 0x03D8); + cv(0x03DA, 0x03DB); + cv(0x03DB, 0x03DA); + cv(0x03DC, 0x03DD); + cv(0x03DD, 0x03DC); + cv(0x03DE, 0x03DF); + cv(0x03DF, 0x03DE); + cv(0x03E0, 0x03E1); + cv(0x03E1, 0x03E0); + cv(0x03E2, 0x03E3); + cv(0x03E3, 0x03E2); + cv(0x03E4, 0x03E5); + cv(0x03E5, 0x03E4); + cv(0x03E6, 0x03E7); + cv(0x03E7, 0x03E6); + cv(0x03E8, 0x03E9); + cv(0x03E9, 0x03E8); + cv(0x03EA, 0x03EB); + cv(0x03EB, 0x03EA); + cv(0x03EC, 0x03ED); + cv(0x03ED, 0x03EC); + cv(0x03EE, 0x03EF); + cv(0x03EF, 0x03EE); + cv(0x03F0, 0x039A, 0x03BA); + cv(0x03F1, 0x03A1, 0x03C1); + cv(0x03F2, 0x03F9); + cv(0x03F4, 0x0398, 0x03B8); + cv(0x03F5, 0x0395, 0x03B5); + cv(0x03F7, 0x03F8); + cv(0x03F8, 0x03F7); + cv(0x03F9, 0x03F2); + cv(0x03FA, 0x03FB); + cv(0x03FB, 0x03FA); + cv(0x0400, 0x0450); + cv(0x0401, 0x0451); + cv(0x0402, 0x0452); + cv(0x0403, 0x0453); + cv(0x0404, 0x0454); + cv(0x0405, 0x0455); + cv(0x0406, 0x0456); + cv(0x0407, 0x0457); + cv(0x0408, 0x0458); + cv(0x0409, 0x0459); + cv(0x040A, 0x045A); + cv(0x040B, 0x045B); + cv(0x040C, 0x045C); + cv(0x040D, 0x045D); + cv(0x040E, 0x045E); + cv(0x040F, 0x045F); + cv(0x0410, 0x0430); + cv(0x0411, 0x0431); + cv(0x0412, 0x0432); + cv(0x0413, 0x0433); + cv(0x0414, 0x0434); + cv(0x0415, 0x0435); + cv(0x0416, 0x0436); + cv(0x0417, 0x0437); + cv(0x0418, 0x0438); + cv(0x0419, 0x0439); + cv(0x041A, 0x043A); + cv(0x041B, 0x043B); + cv(0x041C, 0x043C); + cv(0x041D, 0x043D); + cv(0x041E, 0x043E); + cv(0x041F, 0x043F); + cv(0x0420, 0x0440); + cv(0x0421, 0x0441); + cv(0x0422, 0x0442); + cv(0x0423, 0x0443); + cv(0x0424, 0x0444); + cv(0x0425, 0x0445); + cv(0x0426, 0x0446); + cv(0x0427, 0x0447); + cv(0x0428, 0x0448); + cv(0x0429, 0x0449); + cv(0x042A, 0x044A); + cv(0x042B, 0x044B); + cv(0x042C, 0x044C); + cv(0x042D, 0x044D); + cv(0x042E, 0x044E); + cv(0x042F, 0x044F); + cv(0x0430, 0x0410); + cv(0x0431, 0x0411); + cv(0x0432, 0x0412); + cv(0x0433, 0x0413); + cv(0x0434, 0x0414); + cv(0x0435, 0x0415); + cv(0x0436, 0x0416); + cv(0x0437, 0x0417); + cv(0x0438, 0x0418); + cv(0x0439, 0x0419); + cv(0x043A, 0x041A); + cv(0x043B, 0x041B); + cv(0x043C, 0x041C); + cv(0x043D, 0x041D); + cv(0x043E, 0x041E); + cv(0x043F, 0x041F); + cv(0x0440, 0x0420); + cv(0x0441, 0x0421); + cv(0x0442, 0x0422); + cv(0x0443, 0x0423); + cv(0x0444, 0x0424); + cv(0x0445, 0x0425); + cv(0x0446, 0x0426); + cv(0x0447, 0x0427); + cv(0x0448, 0x0428); + cv(0x0449, 0x0429); + cv(0x044A, 0x042A); + cv(0x044B, 0x042B); + cv(0x044C, 0x042C); + cv(0x044D, 0x042D); + cv(0x044E, 0x042E); + cv(0x044F, 0x042F); + cv(0x0450, 0x0400); + cv(0x0451, 0x0401); + cv(0x0452, 0x0402); + cv(0x0453, 0x0403); + cv(0x0454, 0x0404); + cv(0x0455, 0x0405); + cv(0x0456, 0x0406); + cv(0x0457, 0x0407); + cv(0x0458, 0x0408); + cv(0x0459, 0x0409); + cv(0x045A, 0x040A); + cv(0x045B, 0x040B); + cv(0x045C, 0x040C); + cv(0x045D, 0x040D); + cv(0x045E, 0x040E); + cv(0x045F, 0x040F); + cv(0x0460, 0x0461); + cv(0x0461, 0x0460); + cv(0x0462, 0x0463); + cv(0x0463, 0x0462); + cv(0x0464, 0x0465); + cv(0x0465, 0x0464); + cv(0x0466, 0x0467); + cv(0x0467, 0x0466); + cv(0x0468, 0x0469); + cv(0x0469, 0x0468); + cv(0x046A, 0x046B); + cv(0x046B, 0x046A); + cv(0x046C, 0x046D); + cv(0x046D, 0x046C); + cv(0x046E, 0x046F); + cv(0x046F, 0x046E); + cv(0x0470, 0x0471); + cv(0x0471, 0x0470); + cv(0x0472, 0x0473); + cv(0x0473, 0x0472); + cv(0x0474, 0x0475); + cv(0x0475, 0x0474); + cv(0x0476, 0x0477); + cv(0x0477, 0x0476); + cv(0x0478, 0x0479); + cv(0x0479, 0x0478); + cv(0x047A, 0x047B); + cv(0x047B, 0x047A); + cv(0x047C, 0x047D); + cv(0x047D, 0x047C); + cv(0x047E, 0x047F); + cv(0x047F, 0x047E); + cv(0x0480, 0x0481); + cv(0x0481, 0x0480); + cv(0x048A, 0x048B); + cv(0x048B, 0x048A); + cv(0x048C, 0x048D); + cv(0x048D, 0x048C); + cv(0x048E, 0x048F); + cv(0x048F, 0x048E); + cv(0x0490, 0x0491); + cv(0x0491, 0x0490); + cv(0x0492, 0x0493); + cv(0x0493, 0x0492); + cv(0x0494, 0x0495); + cv(0x0495, 0x0494); + cv(0x0496, 0x0497); + cv(0x0497, 0x0496); + cv(0x0498, 0x0499); + cv(0x0499, 0x0498); + cv(0x049A, 0x049B); + cv(0x049B, 0x049A); + cv(0x049C, 0x049D); + cv(0x049D, 0x049C); + cv(0x049E, 0x049F); + cv(0x049F, 0x049E); + cv(0x04A0, 0x04A1); + cv(0x04A1, 0x04A0); + cv(0x04A2, 0x04A3); + cv(0x04A3, 0x04A2); + cv(0x04A4, 0x04A5); + cv(0x04A5, 0x04A4); + cv(0x04A6, 0x04A7); + cv(0x04A7, 0x04A6); + cv(0x04A8, 0x04A9); + cv(0x04A9, 0x04A8); + cv(0x04AA, 0x04AB); + cv(0x04AB, 0x04AA); + cv(0x04AC, 0x04AD); + cv(0x04AD, 0x04AC); + cv(0x04AE, 0x04AF); + cv(0x04AF, 0x04AE); + cv(0x04B0, 0x04B1); + cv(0x04B1, 0x04B0); + cv(0x04B2, 0x04B3); + cv(0x04B3, 0x04B2); + cv(0x04B4, 0x04B5); + cv(0x04B5, 0x04B4); + cv(0x04B6, 0x04B7); + cv(0x04B7, 0x04B6); + cv(0x04B8, 0x04B9); + cv(0x04B9, 0x04B8); + cv(0x04BA, 0x04BB); + cv(0x04BB, 0x04BA); + cv(0x04BC, 0x04BD); + cv(0x04BD, 0x04BC); + cv(0x04BE, 0x04BF); + cv(0x04BF, 0x04BE); + cv(0x04C1, 0x04C2); + cv(0x04C2, 0x04C1); + cv(0x04C3, 0x04C4); + cv(0x04C4, 0x04C3); + cv(0x04C5, 0x04C6); + cv(0x04C6, 0x04C5); + cv(0x04C7, 0x04C8); + cv(0x04C8, 0x04C7); + cv(0x04C9, 0x04CA); + cv(0x04CA, 0x04C9); + cv(0x04CB, 0x04CC); + cv(0x04CC, 0x04CB); + cv(0x04CD, 0x04CE); + cv(0x04CE, 0x04CD); + cv(0x04D0, 0x04D1); + cv(0x04D1, 0x04D0); + cv(0x04D2, 0x04D3); + cv(0x04D3, 0x04D2); + cv(0x04D4, 0x04D5); + cv(0x04D5, 0x04D4); + cv(0x04D6, 0x04D7); + cv(0x04D7, 0x04D6); + cv(0x04D8, 0x04D9); + cv(0x04D9, 0x04D8); + cv(0x04DA, 0x04DB); + cv(0x04DB, 0x04DA); + cv(0x04DC, 0x04DD); + cv(0x04DD, 0x04DC); + cv(0x04DE, 0x04DF); + cv(0x04DF, 0x04DE); + cv(0x04E0, 0x04E1); + cv(0x04E1, 0x04E0); + cv(0x04E2, 0x04E3); + cv(0x04E3, 0x04E2); + cv(0x04E4, 0x04E5); + cv(0x04E5, 0x04E4); + cv(0x04E6, 0x04E7); + cv(0x04E7, 0x04E6); + cv(0x04E8, 0x04E9); + cv(0x04E9, 0x04E8); + cv(0x04EA, 0x04EB); + cv(0x04EB, 0x04EA); + cv(0x04EC, 0x04ED); + cv(0x04ED, 0x04EC); + cv(0x04EE, 0x04EF); + cv(0x04EF, 0x04EE); + cv(0x04F0, 0x04F1); + cv(0x04F1, 0x04F0); + cv(0x04F2, 0x04F3); + cv(0x04F3, 0x04F2); + cv(0x04F4, 0x04F5); + cv(0x04F5, 0x04F4); + cv(0x04F6, 0x04F7); + cv(0x04F7, 0x04F6); + cv(0x04F8, 0x04F9); + cv(0x04F9, 0x04F8); + cv(0x0500, 0x0501); + cv(0x0501, 0x0500); + cv(0x0502, 0x0503); + cv(0x0503, 0x0502); + cv(0x0504, 0x0505); + cv(0x0505, 0x0504); + cv(0x0506, 0x0507); + cv(0x0507, 0x0506); + cv(0x0508, 0x0509); + cv(0x0509, 0x0508); + cv(0x050A, 0x050B); + cv(0x050B, 0x050A); + cv(0x050C, 0x050D); + cv(0x050D, 0x050C); + cv(0x050E, 0x050F); + cv(0x050F, 0x050E); + cv(0x0531, 0x0561); + cv(0x0532, 0x0562); + cv(0x0533, 0x0563); + cv(0x0534, 0x0564); + cv(0x0535, 0x0565); + cv(0x0536, 0x0566); + cv(0x0537, 0x0567); + cv(0x0538, 0x0568); + cv(0x0539, 0x0569); + cv(0x053A, 0x056A); + cv(0x053B, 0x056B); + cv(0x053C, 0x056C); + cv(0x053D, 0x056D); + cv(0x053E, 0x056E); + cv(0x053F, 0x056F); + cv(0x0540, 0x0570); + cv(0x0541, 0x0571); + cv(0x0542, 0x0572); + cv(0x0543, 0x0573); + cv(0x0544, 0x0574); + cv(0x0545, 0x0575); + cv(0x0546, 0x0576); + cv(0x0547, 0x0577); + cv(0x0548, 0x0578); + cv(0x0549, 0x0579); + cv(0x054A, 0x057A); + cv(0x054B, 0x057B); + cv(0x054C, 0x057C); + cv(0x054D, 0x057D); + cv(0x054E, 0x057E); + cv(0x054F, 0x057F); + cv(0x0550, 0x0580); + cv(0x0551, 0x0581); + cv(0x0552, 0x0582); + cv(0x0553, 0x0583); + cv(0x0554, 0x0584); + cv(0x0555, 0x0585); + cv(0x0556, 0x0586); + cv(0x0561, 0x0531); + cv(0x0562, 0x0532); + cv(0x0563, 0x0533); + cv(0x0564, 0x0534); + cv(0x0565, 0x0535); + cv(0x0566, 0x0536); + cv(0x0567, 0x0537); + cv(0x0568, 0x0538); + cv(0x0569, 0x0539); + cv(0x056A, 0x053A); + cv(0x056B, 0x053B); + cv(0x056C, 0x053C); + cv(0x056D, 0x053D); + cv(0x056E, 0x053E); + cv(0x056F, 0x053F); + cv(0x0570, 0x0540); + cv(0x0571, 0x0541); + cv(0x0572, 0x0542); + cv(0x0573, 0x0543); + cv(0x0574, 0x0544); + cv(0x0575, 0x0545); + cv(0x0576, 0x0546); + cv(0x0577, 0x0547); + cv(0x0578, 0x0548); + cv(0x0579, 0x0549); + cv(0x057A, 0x054A); + cv(0x057B, 0x054B); + cv(0x057C, 0x054C); + cv(0x057D, 0x054D); + cv(0x057E, 0x054E); + cv(0x057F, 0x054F); + cv(0x0580, 0x0550); + cv(0x0581, 0x0551); + cv(0x0582, 0x0552); + cv(0x0583, 0x0553); + cv(0x0584, 0x0554); + cv(0x0585, 0x0555); + cv(0x0586, 0x0556); + cv(0x10A0, 0x2D00); + cv(0x10A1, 0x2D01); + cv(0x10A2, 0x2D02); + cv(0x10A3, 0x2D03); + cv(0x10A4, 0x2D04); + cv(0x10A5, 0x2D05); + cv(0x10A6, 0x2D06); + cv(0x10A7, 0x2D07); + cv(0x10A8, 0x2D08); + cv(0x10A9, 0x2D09); + cv(0x10AA, 0x2D0A); + cv(0x10AB, 0x2D0B); + cv(0x10AC, 0x2D0C); + cv(0x10AD, 0x2D0D); + cv(0x10AE, 0x2D0E); + cv(0x10AF, 0x2D0F); + cv(0x10B0, 0x2D10); + cv(0x10B1, 0x2D11); + cv(0x10B2, 0x2D12); + cv(0x10B3, 0x2D13); + cv(0x10B4, 0x2D14); + cv(0x10B5, 0x2D15); + cv(0x10B6, 0x2D16); + cv(0x10B7, 0x2D17); + cv(0x10B8, 0x2D18); + cv(0x10B9, 0x2D19); + cv(0x10BA, 0x2D1A); + cv(0x10BB, 0x2D1B); + cv(0x10BC, 0x2D1C); + cv(0x10BD, 0x2D1D); + cv(0x10BE, 0x2D1E); + cv(0x10BF, 0x2D1F); + cv(0x10C0, 0x2D20); + cv(0x10C1, 0x2D21); + cv(0x10C2, 0x2D22); + cv(0x10C3, 0x2D23); + cv(0x10C4, 0x2D24); + cv(0x10C5, 0x2D25); + cv(0x1E00, 0x1E01); + cv(0x1E01, 0x1E00); + cv(0x1E02, 0x1E03); + cv(0x1E03, 0x1E02); + cv(0x1E04, 0x1E05); + cv(0x1E05, 0x1E04); + cv(0x1E06, 0x1E07); + cv(0x1E07, 0x1E06); + cv(0x1E08, 0x1E09); + cv(0x1E09, 0x1E08); + cv(0x1E0A, 0x1E0B); + cv(0x1E0B, 0x1E0A); + cv(0x1E0C, 0x1E0D); + cv(0x1E0D, 0x1E0C); + cv(0x1E0E, 0x1E0F); + cv(0x1E0F, 0x1E0E); + cv(0x1E10, 0x1E11); + cv(0x1E11, 0x1E10); + cv(0x1E12, 0x1E13); + cv(0x1E13, 0x1E12); + cv(0x1E14, 0x1E15); + cv(0x1E15, 0x1E14); + cv(0x1E16, 0x1E17); + cv(0x1E17, 0x1E16); + cv(0x1E18, 0x1E19); + cv(0x1E19, 0x1E18); + cv(0x1E1A, 0x1E1B); + cv(0x1E1B, 0x1E1A); + cv(0x1E1C, 0x1E1D); + cv(0x1E1D, 0x1E1C); + cv(0x1E1E, 0x1E1F); + cv(0x1E1F, 0x1E1E); + cv(0x1E20, 0x1E21); + cv(0x1E21, 0x1E20); + cv(0x1E22, 0x1E23); + cv(0x1E23, 0x1E22); + cv(0x1E24, 0x1E25); + cv(0x1E25, 0x1E24); + cv(0x1E26, 0x1E27); + cv(0x1E27, 0x1E26); + cv(0x1E28, 0x1E29); + cv(0x1E29, 0x1E28); + cv(0x1E2A, 0x1E2B); + cv(0x1E2B, 0x1E2A); + cv(0x1E2C, 0x1E2D); + cv(0x1E2D, 0x1E2C); + cv(0x1E2E, 0x1E2F); + cv(0x1E2F, 0x1E2E); + cv(0x1E30, 0x1E31); + cv(0x1E31, 0x1E30); + cv(0x1E32, 0x1E33); + cv(0x1E33, 0x1E32); + cv(0x1E34, 0x1E35); + cv(0x1E35, 0x1E34); + cv(0x1E36, 0x1E37); + cv(0x1E37, 0x1E36); + cv(0x1E38, 0x1E39); + cv(0x1E39, 0x1E38); + cv(0x1E3A, 0x1E3B); + cv(0x1E3B, 0x1E3A); + cv(0x1E3C, 0x1E3D); + cv(0x1E3D, 0x1E3C); + cv(0x1E3E, 0x1E3F); + cv(0x1E3F, 0x1E3E); + cv(0x1E40, 0x1E41); + cv(0x1E41, 0x1E40); + cv(0x1E42, 0x1E43); + cv(0x1E43, 0x1E42); + cv(0x1E44, 0x1E45); + cv(0x1E45, 0x1E44); + cv(0x1E46, 0x1E47); + cv(0x1E47, 0x1E46); + cv(0x1E48, 0x1E49); + cv(0x1E49, 0x1E48); + cv(0x1E4A, 0x1E4B); + cv(0x1E4B, 0x1E4A); + cv(0x1E4C, 0x1E4D); + cv(0x1E4D, 0x1E4C); + cv(0x1E4E, 0x1E4F); + cv(0x1E4F, 0x1E4E); + cv(0x1E50, 0x1E51); + cv(0x1E51, 0x1E50); + cv(0x1E52, 0x1E53); + cv(0x1E53, 0x1E52); + cv(0x1E54, 0x1E55); + cv(0x1E55, 0x1E54); + cv(0x1E56, 0x1E57); + cv(0x1E57, 0x1E56); + cv(0x1E58, 0x1E59); + cv(0x1E59, 0x1E58); + cv(0x1E5A, 0x1E5B); + cv(0x1E5B, 0x1E5A); + cv(0x1E5C, 0x1E5D); + cv(0x1E5D, 0x1E5C); + cv(0x1E5E, 0x1E5F); + cv(0x1E5F, 0x1E5E); + cv(0x1E60, 0x1E61, 0x1E9B); + cv(0x1E61, 0x1E60, 0x1E9B); + cv(0x1E62, 0x1E63); + cv(0x1E63, 0x1E62); + cv(0x1E64, 0x1E65); + cv(0x1E65, 0x1E64); + cv(0x1E66, 0x1E67); + cv(0x1E67, 0x1E66); + cv(0x1E68, 0x1E69); + cv(0x1E69, 0x1E68); + cv(0x1E6A, 0x1E6B); + cv(0x1E6B, 0x1E6A); + cv(0x1E6C, 0x1E6D); + cv(0x1E6D, 0x1E6C); + cv(0x1E6E, 0x1E6F); + cv(0x1E6F, 0x1E6E); + cv(0x1E70, 0x1E71); + cv(0x1E71, 0x1E70); + cv(0x1E72, 0x1E73); + cv(0x1E73, 0x1E72); + cv(0x1E74, 0x1E75); + cv(0x1E75, 0x1E74); + cv(0x1E76, 0x1E77); + cv(0x1E77, 0x1E76); + cv(0x1E78, 0x1E79); + cv(0x1E79, 0x1E78); + cv(0x1E7A, 0x1E7B); + cv(0x1E7B, 0x1E7A); + cv(0x1E7C, 0x1E7D); + cv(0x1E7D, 0x1E7C); + cv(0x1E7E, 0x1E7F); + cv(0x1E7F, 0x1E7E); + cv(0x1E80, 0x1E81); + cv(0x1E81, 0x1E80); + cv(0x1E82, 0x1E83); + cv(0x1E83, 0x1E82); + cv(0x1E84, 0x1E85); + cv(0x1E85, 0x1E84); + cv(0x1E86, 0x1E87); + cv(0x1E87, 0x1E86); + cv(0x1E88, 0x1E89); + cv(0x1E89, 0x1E88); + cv(0x1E8A, 0x1E8B); + cv(0x1E8B, 0x1E8A); + cv(0x1E8C, 0x1E8D); + cv(0x1E8D, 0x1E8C); + cv(0x1E8E, 0x1E8F); + cv(0x1E8F, 0x1E8E); + cv(0x1E90, 0x1E91); + cv(0x1E91, 0x1E90); + cv(0x1E92, 0x1E93); + cv(0x1E93, 0x1E92); + cv(0x1E94, 0x1E95); + cv(0x1E95, 0x1E94); + cv(0x1E9B, 0x1E60, 0x1E61); + cv(0x1EA0, 0x1EA1); + cv(0x1EA1, 0x1EA0); + cv(0x1EA2, 0x1EA3); + cv(0x1EA3, 0x1EA2); + cv(0x1EA4, 0x1EA5); + cv(0x1EA5, 0x1EA4); + cv(0x1EA6, 0x1EA7); + cv(0x1EA7, 0x1EA6); + cv(0x1EA8, 0x1EA9); + cv(0x1EA9, 0x1EA8); + cv(0x1EAA, 0x1EAB); + cv(0x1EAB, 0x1EAA); + cv(0x1EAC, 0x1EAD); + cv(0x1EAD, 0x1EAC); + cv(0x1EAE, 0x1EAF); + cv(0x1EAF, 0x1EAE); + cv(0x1EB0, 0x1EB1); + cv(0x1EB1, 0x1EB0); + cv(0x1EB2, 0x1EB3); + cv(0x1EB3, 0x1EB2); + cv(0x1EB4, 0x1EB5); + cv(0x1EB5, 0x1EB4); + cv(0x1EB6, 0x1EB7); + cv(0x1EB7, 0x1EB6); + cv(0x1EB8, 0x1EB9); + cv(0x1EB9, 0x1EB8); + cv(0x1EBA, 0x1EBB); + cv(0x1EBB, 0x1EBA); + cv(0x1EBC, 0x1EBD); + cv(0x1EBD, 0x1EBC); + cv(0x1EBE, 0x1EBF); + cv(0x1EBF, 0x1EBE); + cv(0x1EC0, 0x1EC1); + cv(0x1EC1, 0x1EC0); + cv(0x1EC2, 0x1EC3); + cv(0x1EC3, 0x1EC2); + cv(0x1EC4, 0x1EC5); + cv(0x1EC5, 0x1EC4); + cv(0x1EC6, 0x1EC7); + cv(0x1EC7, 0x1EC6); + cv(0x1EC8, 0x1EC9); + cv(0x1EC9, 0x1EC8); + cv(0x1ECA, 0x1ECB); + cv(0x1ECB, 0x1ECA); + cv(0x1ECC, 0x1ECD); + cv(0x1ECD, 0x1ECC); + cv(0x1ECE, 0x1ECF); + cv(0x1ECF, 0x1ECE); + cv(0x1ED0, 0x1ED1); + cv(0x1ED1, 0x1ED0); + cv(0x1ED2, 0x1ED3); + cv(0x1ED3, 0x1ED2); + cv(0x1ED4, 0x1ED5); + cv(0x1ED5, 0x1ED4); + cv(0x1ED6, 0x1ED7); + cv(0x1ED7, 0x1ED6); + cv(0x1ED8, 0x1ED9); + cv(0x1ED9, 0x1ED8); + cv(0x1EDA, 0x1EDB); + cv(0x1EDB, 0x1EDA); + cv(0x1EDC, 0x1EDD); + cv(0x1EDD, 0x1EDC); + cv(0x1EDE, 0x1EDF); + cv(0x1EDF, 0x1EDE); + cv(0x1EE0, 0x1EE1); + cv(0x1EE1, 0x1EE0); + cv(0x1EE2, 0x1EE3); + cv(0x1EE3, 0x1EE2); + cv(0x1EE4, 0x1EE5); + cv(0x1EE5, 0x1EE4); + cv(0x1EE6, 0x1EE7); + cv(0x1EE7, 0x1EE6); + cv(0x1EE8, 0x1EE9); + cv(0x1EE9, 0x1EE8); + cv(0x1EEA, 0x1EEB); + cv(0x1EEB, 0x1EEA); + cv(0x1EEC, 0x1EED); + cv(0x1EED, 0x1EEC); + cv(0x1EEE, 0x1EEF); + cv(0x1EEF, 0x1EEE); + cv(0x1EF0, 0x1EF1); + cv(0x1EF1, 0x1EF0); + cv(0x1EF2, 0x1EF3); + cv(0x1EF3, 0x1EF2); + cv(0x1EF4, 0x1EF5); + cv(0x1EF5, 0x1EF4); + cv(0x1EF6, 0x1EF7); + cv(0x1EF7, 0x1EF6); + cv(0x1EF8, 0x1EF9); + cv(0x1EF9, 0x1EF8); + cv(0x1F00, 0x1F08); + cv(0x1F01, 0x1F09); + cv(0x1F02, 0x1F0A); + cv(0x1F03, 0x1F0B); + cv(0x1F04, 0x1F0C); + cv(0x1F05, 0x1F0D); + cv(0x1F06, 0x1F0E); + cv(0x1F07, 0x1F0F); + cv(0x1F08, 0x1F00); + cv(0x1F09, 0x1F01); + cv(0x1F0A, 0x1F02); + cv(0x1F0B, 0x1F03); + cv(0x1F0C, 0x1F04); + cv(0x1F0D, 0x1F05); + cv(0x1F0E, 0x1F06); + cv(0x1F0F, 0x1F07); + cv(0x1F10, 0x1F18); + cv(0x1F11, 0x1F19); + cv(0x1F12, 0x1F1A); + cv(0x1F13, 0x1F1B); + cv(0x1F14, 0x1F1C); + cv(0x1F15, 0x1F1D); + cv(0x1F18, 0x1F10); + cv(0x1F19, 0x1F11); + cv(0x1F1A, 0x1F12); + cv(0x1F1B, 0x1F13); + cv(0x1F1C, 0x1F14); + cv(0x1F1D, 0x1F15); + cv(0x1F20, 0x1F28); + cv(0x1F21, 0x1F29); + cv(0x1F22, 0x1F2A); + cv(0x1F23, 0x1F2B); + cv(0x1F24, 0x1F2C); + cv(0x1F25, 0x1F2D); + cv(0x1F26, 0x1F2E); + cv(0x1F27, 0x1F2F); + cv(0x1F28, 0x1F20); + cv(0x1F29, 0x1F21); + cv(0x1F2A, 0x1F22); + cv(0x1F2B, 0x1F23); + cv(0x1F2C, 0x1F24); + cv(0x1F2D, 0x1F25); + cv(0x1F2E, 0x1F26); + cv(0x1F2F, 0x1F27); + cv(0x1F30, 0x1F38); + cv(0x1F31, 0x1F39); + cv(0x1F32, 0x1F3A); + cv(0x1F33, 0x1F3B); + cv(0x1F34, 0x1F3C); + cv(0x1F35, 0x1F3D); + cv(0x1F36, 0x1F3E); + cv(0x1F37, 0x1F3F); + cv(0x1F38, 0x1F30); + cv(0x1F39, 0x1F31); + cv(0x1F3A, 0x1F32); + cv(0x1F3B, 0x1F33); + cv(0x1F3C, 0x1F34); + cv(0x1F3D, 0x1F35); + cv(0x1F3E, 0x1F36); + cv(0x1F3F, 0x1F37); + cv(0x1F40, 0x1F48); + cv(0x1F41, 0x1F49); + cv(0x1F42, 0x1F4A); + cv(0x1F43, 0x1F4B); + cv(0x1F44, 0x1F4C); + cv(0x1F45, 0x1F4D); + cv(0x1F48, 0x1F40); + cv(0x1F49, 0x1F41); + cv(0x1F4A, 0x1F42); + cv(0x1F4B, 0x1F43); + cv(0x1F4C, 0x1F44); + cv(0x1F4D, 0x1F45); + cv(0x1F51, 0x1F59); + cv(0x1F53, 0x1F5B); + cv(0x1F55, 0x1F5D); + cv(0x1F57, 0x1F5F); + cv(0x1F59, 0x1F51); + cv(0x1F5B, 0x1F53); + cv(0x1F5D, 0x1F55); + cv(0x1F5F, 0x1F57); + cv(0x1F60, 0x1F68); + cv(0x1F61, 0x1F69); + cv(0x1F62, 0x1F6A); + cv(0x1F63, 0x1F6B); + cv(0x1F64, 0x1F6C); + cv(0x1F65, 0x1F6D); + cv(0x1F66, 0x1F6E); + cv(0x1F67, 0x1F6F); + cv(0x1F68, 0x1F60); + cv(0x1F69, 0x1F61); + cv(0x1F6A, 0x1F62); + cv(0x1F6B, 0x1F63); + cv(0x1F6C, 0x1F64); + cv(0x1F6D, 0x1F65); + cv(0x1F6E, 0x1F66); + cv(0x1F6F, 0x1F67); + cv(0x1F70, 0x1FBA); + cv(0x1F71, 0x1FBB); + cv(0x1F72, 0x1FC8); + cv(0x1F73, 0x1FC9); + cv(0x1F74, 0x1FCA); + cv(0x1F75, 0x1FCB); + cv(0x1F76, 0x1FDA); + cv(0x1F77, 0x1FDB); + cv(0x1F78, 0x1FF8); + cv(0x1F79, 0x1FF9); + cv(0x1F7A, 0x1FEA); + cv(0x1F7B, 0x1FEB); + cv(0x1F7C, 0x1FFA); + cv(0x1F7D, 0x1FFB); + cv(0x1F80, 0x1F88); + cv(0x1F81, 0x1F89); + cv(0x1F82, 0x1F8A); + cv(0x1F83, 0x1F8B); + cv(0x1F84, 0x1F8C); + cv(0x1F85, 0x1F8D); + cv(0x1F86, 0x1F8E); + cv(0x1F87, 0x1F8F); + cv(0x1F88, 0x1F80); + cv(0x1F89, 0x1F81); + cv(0x1F8A, 0x1F82); + cv(0x1F8B, 0x1F83); + cv(0x1F8C, 0x1F84); + cv(0x1F8D, 0x1F85); + cv(0x1F8E, 0x1F86); + cv(0x1F8F, 0x1F87); + cv(0x1F90, 0x1F98); + cv(0x1F91, 0x1F99); + cv(0x1F92, 0x1F9A); + cv(0x1F93, 0x1F9B); + cv(0x1F94, 0x1F9C); + cv(0x1F95, 0x1F9D); + cv(0x1F96, 0x1F9E); + cv(0x1F97, 0x1F9F); + cv(0x1F98, 0x1F90); + cv(0x1F99, 0x1F91); + cv(0x1F9A, 0x1F92); + cv(0x1F9B, 0x1F93); + cv(0x1F9C, 0x1F94); + cv(0x1F9D, 0x1F95); + cv(0x1F9E, 0x1F96); + cv(0x1F9F, 0x1F97); + cv(0x1FA0, 0x1FA8); + cv(0x1FA1, 0x1FA9); + cv(0x1FA2, 0x1FAA); + cv(0x1FA3, 0x1FAB); + cv(0x1FA4, 0x1FAC); + cv(0x1FA5, 0x1FAD); + cv(0x1FA6, 0x1FAE); + cv(0x1FA7, 0x1FAF); + cv(0x1FA8, 0x1FA0); + cv(0x1FA9, 0x1FA1); + cv(0x1FAA, 0x1FA2); + cv(0x1FAB, 0x1FA3); + cv(0x1FAC, 0x1FA4); + cv(0x1FAD, 0x1FA5); + cv(0x1FAE, 0x1FA6); + cv(0x1FAF, 0x1FA7); + cv(0x1FB0, 0x1FB8); + cv(0x1FB1, 0x1FB9); + cv(0x1FB3, 0x1FBC); + cv(0x1FB8, 0x1FB0); + cv(0x1FB9, 0x1FB1); + cv(0x1FBA, 0x1F70); + cv(0x1FBB, 0x1F71); + cv(0x1FBC, 0x1FB3); + cv(0x1FBE, 0x0345, 0x0399, 0x03B9); + cv(0x1FC3, 0x1FCC); + cv(0x1FC8, 0x1F72); + cv(0x1FC9, 0x1F73); + cv(0x1FCA, 0x1F74); + cv(0x1FCB, 0x1F75); + cv(0x1FCC, 0x1FC3); + cv(0x1FD0, 0x1FD8); + cv(0x1FD1, 0x1FD9); + cv(0x1FD8, 0x1FD0); + cv(0x1FD9, 0x1FD1); + cv(0x1FDA, 0x1F76); + cv(0x1FDB, 0x1F77); + cv(0x1FE0, 0x1FE8); + cv(0x1FE1, 0x1FE9); + cv(0x1FE5, 0x1FEC); + cv(0x1FE8, 0x1FE0); + cv(0x1FE9, 0x1FE1); + cv(0x1FEA, 0x1F7A); + cv(0x1FEB, 0x1F7B); + cv(0x1FEC, 0x1FE5); + cv(0x1FF3, 0x1FFC); + cv(0x1FF8, 0x1F78); + cv(0x1FF9, 0x1F79); + cv(0x1FFA, 0x1F7C); + cv(0x1FFB, 0x1F7D); + cv(0x1FFC, 0x1FF3); + cv(0x2126, 0x03A9, 0x03C9); + cv(0x212A, 0x004B, 0x006B); + cv(0x212B, 0x00C5, 0x00E5); + cv(0x2160, 0x2170); + cv(0x2161, 0x2171); + cv(0x2162, 0x2172); + cv(0x2163, 0x2173); + cv(0x2164, 0x2174); + cv(0x2165, 0x2175); + cv(0x2166, 0x2176); + cv(0x2167, 0x2177); + cv(0x2168, 0x2178); + cv(0x2169, 0x2179); + cv(0x216A, 0x217A); + cv(0x216B, 0x217B); + cv(0x216C, 0x217C); + cv(0x216D, 0x217D); + cv(0x216E, 0x217E); + cv(0x216F, 0x217F); + cv(0x2170, 0x2160); + cv(0x2171, 0x2161); + cv(0x2172, 0x2162); + cv(0x2173, 0x2163); + cv(0x2174, 0x2164); + cv(0x2175, 0x2165); + cv(0x2176, 0x2166); + cv(0x2177, 0x2167); + cv(0x2178, 0x2168); + cv(0x2179, 0x2169); + cv(0x217A, 0x216A); + cv(0x217B, 0x216B); + cv(0x217C, 0x216C); + cv(0x217D, 0x216D); + cv(0x217E, 0x216E); + cv(0x217F, 0x216F); + cv(0x24B6, 0x24D0); + cv(0x24B7, 0x24D1); + cv(0x24B8, 0x24D2); + cv(0x24B9, 0x24D3); + cv(0x24BA, 0x24D4); + cv(0x24BB, 0x24D5); + cv(0x24BC, 0x24D6); + cv(0x24BD, 0x24D7); + cv(0x24BE, 0x24D8); + cv(0x24BF, 0x24D9); + cv(0x24C0, 0x24DA); + cv(0x24C1, 0x24DB); + cv(0x24C2, 0x24DC); + cv(0x24C3, 0x24DD); + cv(0x24C4, 0x24DE); + cv(0x24C5, 0x24DF); + cv(0x24C6, 0x24E0); + cv(0x24C7, 0x24E1); + cv(0x24C8, 0x24E2); + cv(0x24C9, 0x24E3); + cv(0x24CA, 0x24E4); + cv(0x24CB, 0x24E5); + cv(0x24CC, 0x24E6); + cv(0x24CD, 0x24E7); + cv(0x24CE, 0x24E8); + cv(0x24CF, 0x24E9); + cv(0x24D0, 0x24B6); + cv(0x24D1, 0x24B7); + cv(0x24D2, 0x24B8); + cv(0x24D3, 0x24B9); + cv(0x24D4, 0x24BA); + cv(0x24D5, 0x24BB); + cv(0x24D6, 0x24BC); + cv(0x24D7, 0x24BD); + cv(0x24D8, 0x24BE); + cv(0x24D9, 0x24BF); + cv(0x24DA, 0x24C0); + cv(0x24DB, 0x24C1); + cv(0x24DC, 0x24C2); + cv(0x24DD, 0x24C3); + cv(0x24DE, 0x24C4); + cv(0x24DF, 0x24C5); + cv(0x24E0, 0x24C6); + cv(0x24E1, 0x24C7); + cv(0x24E2, 0x24C8); + cv(0x24E3, 0x24C9); + cv(0x24E4, 0x24CA); + cv(0x24E5, 0x24CB); + cv(0x24E6, 0x24CC); + cv(0x24E7, 0x24CD); + cv(0x24E8, 0x24CE); + cv(0x24E9, 0x24CF); + cv(0x2C00, 0x2C30); + cv(0x2C01, 0x2C31); + cv(0x2C02, 0x2C32); + cv(0x2C03, 0x2C33); + cv(0x2C04, 0x2C34); + cv(0x2C05, 0x2C35); + cv(0x2C06, 0x2C36); + cv(0x2C07, 0x2C37); + cv(0x2C08, 0x2C38); + cv(0x2C09, 0x2C39); + cv(0x2C0A, 0x2C3A); + cv(0x2C0B, 0x2C3B); + cv(0x2C0C, 0x2C3C); + cv(0x2C0D, 0x2C3D); + cv(0x2C0E, 0x2C3E); + cv(0x2C0F, 0x2C3F); + cv(0x2C10, 0x2C40); + cv(0x2C11, 0x2C41); + cv(0x2C12, 0x2C42); + cv(0x2C13, 0x2C43); + cv(0x2C14, 0x2C44); + cv(0x2C15, 0x2C45); + cv(0x2C16, 0x2C46); + cv(0x2C17, 0x2C47); + cv(0x2C18, 0x2C48); + cv(0x2C19, 0x2C49); + cv(0x2C1A, 0x2C4A); + cv(0x2C1B, 0x2C4B); + cv(0x2C1C, 0x2C4C); + cv(0x2C1D, 0x2C4D); + cv(0x2C1E, 0x2C4E); + cv(0x2C1F, 0x2C4F); + cv(0x2C20, 0x2C50); + cv(0x2C21, 0x2C51); + cv(0x2C22, 0x2C52); + cv(0x2C23, 0x2C53); + cv(0x2C24, 0x2C54); + cv(0x2C25, 0x2C55); + cv(0x2C26, 0x2C56); + cv(0x2C27, 0x2C57); + cv(0x2C28, 0x2C58); + cv(0x2C29, 0x2C59); + cv(0x2C2A, 0x2C5A); + cv(0x2C2B, 0x2C5B); + cv(0x2C2C, 0x2C5C); + cv(0x2C2D, 0x2C5D); + cv(0x2C2E, 0x2C5E); + cv(0x2C30, 0x2C00); + cv(0x2C31, 0x2C01); + cv(0x2C32, 0x2C02); + cv(0x2C33, 0x2C03); + cv(0x2C34, 0x2C04); + cv(0x2C35, 0x2C05); + cv(0x2C36, 0x2C06); + cv(0x2C37, 0x2C07); + cv(0x2C38, 0x2C08); + cv(0x2C39, 0x2C09); + cv(0x2C3A, 0x2C0A); + cv(0x2C3B, 0x2C0B); + cv(0x2C3C, 0x2C0C); + cv(0x2C3D, 0x2C0D); + cv(0x2C3E, 0x2C0E); + cv(0x2C3F, 0x2C0F); + cv(0x2C40, 0x2C10); + cv(0x2C41, 0x2C11); + cv(0x2C42, 0x2C12); + cv(0x2C43, 0x2C13); + cv(0x2C44, 0x2C14); + cv(0x2C45, 0x2C15); + cv(0x2C46, 0x2C16); + cv(0x2C47, 0x2C17); + cv(0x2C48, 0x2C18); + cv(0x2C49, 0x2C19); + cv(0x2C4A, 0x2C1A); + cv(0x2C4B, 0x2C1B); + cv(0x2C4C, 0x2C1C); + cv(0x2C4D, 0x2C1D); + cv(0x2C4E, 0x2C1E); + cv(0x2C4F, 0x2C1F); + cv(0x2C50, 0x2C20); + cv(0x2C51, 0x2C21); + cv(0x2C52, 0x2C22); + cv(0x2C53, 0x2C23); + cv(0x2C54, 0x2C24); + cv(0x2C55, 0x2C25); + cv(0x2C56, 0x2C26); + cv(0x2C57, 0x2C27); + cv(0x2C58, 0x2C28); + cv(0x2C59, 0x2C29); + cv(0x2C5A, 0x2C2A); + cv(0x2C5B, 0x2C2B); + cv(0x2C5C, 0x2C2C); + cv(0x2C5D, 0x2C2D); + cv(0x2C5E, 0x2C2E); + cv(0x2C80, 0x2C81); + cv(0x2C81, 0x2C80); + cv(0x2C82, 0x2C83); + cv(0x2C83, 0x2C82); + cv(0x2C84, 0x2C85); + cv(0x2C85, 0x2C84); + cv(0x2C86, 0x2C87); + cv(0x2C87, 0x2C86); + cv(0x2C88, 0x2C89); + cv(0x2C89, 0x2C88); + cv(0x2C8A, 0x2C8B); + cv(0x2C8B, 0x2C8A); + cv(0x2C8C, 0x2C8D); + cv(0x2C8D, 0x2C8C); + cv(0x2C8E, 0x2C8F); + cv(0x2C8F, 0x2C8E); + cv(0x2C90, 0x2C91); + cv(0x2C91, 0x2C90); + cv(0x2C92, 0x2C93); + cv(0x2C93, 0x2C92); + cv(0x2C94, 0x2C95); + cv(0x2C95, 0x2C94); + cv(0x2C96, 0x2C97); + cv(0x2C97, 0x2C96); + cv(0x2C98, 0x2C99); + cv(0x2C99, 0x2C98); + cv(0x2C9A, 0x2C9B); + cv(0x2C9B, 0x2C9A); + cv(0x2C9C, 0x2C9D); + cv(0x2C9D, 0x2C9C); + cv(0x2C9E, 0x2C9F); + cv(0x2C9F, 0x2C9E); + cv(0x2CA0, 0x2CA1); + cv(0x2CA1, 0x2CA0); + cv(0x2CA2, 0x2CA3); + cv(0x2CA3, 0x2CA2); + cv(0x2CA4, 0x2CA5); + cv(0x2CA5, 0x2CA4); + cv(0x2CA6, 0x2CA7); + cv(0x2CA7, 0x2CA6); + cv(0x2CA8, 0x2CA9); + cv(0x2CA9, 0x2CA8); + cv(0x2CAA, 0x2CAB); + cv(0x2CAB, 0x2CAA); + cv(0x2CAC, 0x2CAD); + cv(0x2CAD, 0x2CAC); + cv(0x2CAE, 0x2CAF); + cv(0x2CAF, 0x2CAE); + cv(0x2CB0, 0x2CB1); + cv(0x2CB1, 0x2CB0); + cv(0x2CB2, 0x2CB3); + cv(0x2CB3, 0x2CB2); + cv(0x2CB4, 0x2CB5); + cv(0x2CB5, 0x2CB4); + cv(0x2CB6, 0x2CB7); + cv(0x2CB7, 0x2CB6); + cv(0x2CB8, 0x2CB9); + cv(0x2CB9, 0x2CB8); + cv(0x2CBA, 0x2CBB); + cv(0x2CBB, 0x2CBA); + cv(0x2CBC, 0x2CBD); + cv(0x2CBD, 0x2CBC); + cv(0x2CBE, 0x2CBF); + cv(0x2CBF, 0x2CBE); + cv(0x2CC0, 0x2CC1); + cv(0x2CC1, 0x2CC0); + cv(0x2CC2, 0x2CC3); + cv(0x2CC3, 0x2CC2); + cv(0x2CC4, 0x2CC5); + cv(0x2CC5, 0x2CC4); + cv(0x2CC6, 0x2CC7); + cv(0x2CC7, 0x2CC6); + cv(0x2CC8, 0x2CC9); + cv(0x2CC9, 0x2CC8); + cv(0x2CCA, 0x2CCB); + cv(0x2CCB, 0x2CCA); + cv(0x2CCC, 0x2CCD); + cv(0x2CCD, 0x2CCC); + cv(0x2CCE, 0x2CCF); + cv(0x2CCF, 0x2CCE); + cv(0x2CD0, 0x2CD1); + cv(0x2CD1, 0x2CD0); + cv(0x2CD2, 0x2CD3); + cv(0x2CD3, 0x2CD2); + cv(0x2CD4, 0x2CD5); + cv(0x2CD5, 0x2CD4); + cv(0x2CD6, 0x2CD7); + cv(0x2CD7, 0x2CD6); + cv(0x2CD8, 0x2CD9); + cv(0x2CD9, 0x2CD8); + cv(0x2CDA, 0x2CDB); + cv(0x2CDB, 0x2CDA); + cv(0x2CDC, 0x2CDD); + cv(0x2CDD, 0x2CDC); + cv(0x2CDE, 0x2CDF); + cv(0x2CDF, 0x2CDE); + cv(0x2CE0, 0x2CE1); + cv(0x2CE1, 0x2CE0); + cv(0x2CE2, 0x2CE3); + cv(0x2CE3, 0x2CE2); + cv(0x2D00, 0x10A0); + cv(0x2D01, 0x10A1); + cv(0x2D02, 0x10A2); + cv(0x2D03, 0x10A3); + cv(0x2D04, 0x10A4); + cv(0x2D05, 0x10A5); + cv(0x2D06, 0x10A6); + cv(0x2D07, 0x10A7); + cv(0x2D08, 0x10A8); + cv(0x2D09, 0x10A9); + cv(0x2D0A, 0x10AA); + cv(0x2D0B, 0x10AB); + cv(0x2D0C, 0x10AC); + cv(0x2D0D, 0x10AD); + cv(0x2D0E, 0x10AE); + cv(0x2D0F, 0x10AF); + cv(0x2D10, 0x10B0); + cv(0x2D11, 0x10B1); + cv(0x2D12, 0x10B2); + cv(0x2D13, 0x10B3); + cv(0x2D14, 0x10B4); + cv(0x2D15, 0x10B5); + cv(0x2D16, 0x10B6); + cv(0x2D17, 0x10B7); + cv(0x2D18, 0x10B8); + cv(0x2D19, 0x10B9); + cv(0x2D1A, 0x10BA); + cv(0x2D1B, 0x10BB); + cv(0x2D1C, 0x10BC); + cv(0x2D1D, 0x10BD); + cv(0x2D1E, 0x10BE); + cv(0x2D1F, 0x10BF); + cv(0x2D20, 0x10C0); + cv(0x2D21, 0x10C1); + cv(0x2D22, 0x10C2); + cv(0x2D23, 0x10C3); + cv(0x2D24, 0x10C4); + cv(0x2D25, 0x10C5); + cv(0xFF21, 0xFF41); + cv(0xFF22, 0xFF42); + cv(0xFF23, 0xFF43); + cv(0xFF24, 0xFF44); + cv(0xFF25, 0xFF45); + cv(0xFF26, 0xFF46); + cv(0xFF27, 0xFF47); + cv(0xFF28, 0xFF48); + cv(0xFF29, 0xFF49); + cv(0xFF2A, 0xFF4A); + cv(0xFF2B, 0xFF4B); + cv(0xFF2C, 0xFF4C); + cv(0xFF2D, 0xFF4D); + cv(0xFF2E, 0xFF4E); + cv(0xFF2F, 0xFF4F); + cv(0xFF30, 0xFF50); + cv(0xFF31, 0xFF51); + cv(0xFF32, 0xFF52); + cv(0xFF33, 0xFF53); + cv(0xFF34, 0xFF54); + cv(0xFF35, 0xFF55); + cv(0xFF36, 0xFF56); + cv(0xFF37, 0xFF57); + cv(0xFF38, 0xFF58); + cv(0xFF39, 0xFF59); + cv(0xFF3A, 0xFF5A); + cv(0xFF41, 0xFF21); + cv(0xFF42, 0xFF22); + cv(0xFF43, 0xFF23); + cv(0xFF44, 0xFF24); + cv(0xFF45, 0xFF25); + cv(0xFF46, 0xFF26); + cv(0xFF47, 0xFF27); + cv(0xFF48, 0xFF28); + cv(0xFF49, 0xFF29); + cv(0xFF4A, 0xFF2A); + cv(0xFF4B, 0xFF2B); + cv(0xFF4C, 0xFF2C); + cv(0xFF4D, 0xFF2D); + cv(0xFF4E, 0xFF2E); + cv(0xFF4F, 0xFF2F); + cv(0xFF50, 0xFF30); + cv(0xFF51, 0xFF31); + cv(0xFF52, 0xFF32); + cv(0xFF53, 0xFF33); + cv(0xFF54, 0xFF34); + cv(0xFF55, 0xFF35); + cv(0xFF56, 0xFF36); + cv(0xFF57, 0xFF37); + cv(0xFF58, 0xFF38); + cv(0xFF59, 0xFF39); + cv(0xFF5A, 0xFF3A); + cv(0x10400, 0x10428); + cv(0x10401, 0x10429); + cv(0x10402, 0x1042A); + cv(0x10403, 0x1042B); + cv(0x10404, 0x1042C); + cv(0x10405, 0x1042D); + cv(0x10406, 0x1042E); + cv(0x10407, 0x1042F); + cv(0x10408, 0x10430); + cv(0x10409, 0x10431); + cv(0x1040A, 0x10432); + cv(0x1040B, 0x10433); + cv(0x1040C, 0x10434); + cv(0x1040D, 0x10435); + cv(0x1040E, 0x10436); + cv(0x1040F, 0x10437); + cv(0x10410, 0x10438); + cv(0x10411, 0x10439); + cv(0x10412, 0x1043A); + cv(0x10413, 0x1043B); + cv(0x10414, 0x1043C); + cv(0x10415, 0x1043D); + cv(0x10416, 0x1043E); + cv(0x10417, 0x1043F); + cv(0x10418, 0x10440); + cv(0x10419, 0x10441); + cv(0x1041A, 0x10442); + cv(0x1041B, 0x10443); + cv(0x1041C, 0x10444); + cv(0x1041D, 0x10445); + cv(0x1041E, 0x10446); + cv(0x1041F, 0x10447); + cv(0x10420, 0x10448); + cv(0x10421, 0x10449); + cv(0x10422, 0x1044A); + cv(0x10423, 0x1044B); + cv(0x10424, 0x1044C); + cv(0x10425, 0x1044D); + cv(0x10426, 0x1044E); + cv(0x10427, 0x1044F); + cv(0x10428, 0x10400); + cv(0x10429, 0x10401); + cv(0x1042A, 0x10402); + cv(0x1042B, 0x10403); + cv(0x1042C, 0x10404); + cv(0x1042D, 0x10405); + cv(0x1042E, 0x10406); + cv(0x1042F, 0x10407); + cv(0x10430, 0x10408); + cv(0x10431, 0x10409); + cv(0x10432, 0x1040A); + cv(0x10433, 0x1040B); + cv(0x10434, 0x1040C); + cv(0x10435, 0x1040D); + cv(0x10436, 0x1040E); + cv(0x10437, 0x1040F); + cv(0x10438, 0x10410); + cv(0x10439, 0x10411); + cv(0x1043A, 0x10412); + cv(0x1043B, 0x10413); + cv(0x1043C, 0x10414); + cv(0x1043D, 0x10415); + cv(0x1043E, 0x10416); + cv(0x1043F, 0x10417); + cv(0x10440, 0x10418); + cv(0x10441, 0x10419); + cv(0x10442, 0x1041A); + cv(0x10443, 0x1041B); + cv(0x10444, 0x1041C); + cv(0x10445, 0x1041D); + cv(0x10446, 0x1041E); + cv(0x10447, 0x1041F); + cv(0x10448, 0x10420); + cv(0x10449, 0x10421); + cv(0x1044A, 0x10422); + cv(0x1044B, 0x10423); + cv(0x1044C, 0x10424); + cv(0x1044D, 0x10425); + cv(0x1044E, 0x10426); + cv(0x1044F, 0x10427); + } +} + +// +// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License"); +// you may not use this file except in compliance with the License. You may obtain a copy of the +// License at http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" basis, +// WITHOUT WARRANTY OF ANY KIND, either express or implied. +// See the License for the specific language governing rights and limitations under the License. +// +// The Original Code is: all this file +// +// The Initial Developer of the Original Code is Michael H. Kay. +// +// Contributor(s): +// + diff --git a/src/org/exist/xquery/regex/IntRangeSet.java b/src/org/exist/xquery/regex/IntRangeSet.java index 6805f94c3fe..ffa72718d89 100644 --- a/src/org/exist/xquery/regex/IntRangeSet.java +++ b/src/org/exist/xquery/regex/IntRangeSet.java @@ -1,402 +1,402 @@ -package org.exist.xquery.regex; - -import java.io.Serializable; -import java.util.Arrays; - -import org.exist.util.FastStringBuffer; - -/** - * Set of int values. This implementation of IntSet uses a sorted array - * of integer ranges. - * - * Copied from Saxon-HE 9.2 package net.sf.saxon.regex. - * - * @author Michael Kay - */ -public class IntRangeSet implements Serializable { - - // The array of start points, which will always be sorted - private int[] startPoints; - - // The array of end points, which will always be sorted - private int[] endPoints; - - // The number of elements of the above two arrays that are actually in use - private int used = 0; - - // Hashcode, evaluated lazily - private int hashCode = -1; - - // The number of items in the set - private int size = 0; - - /** - * Create an empty set - */ - public IntRangeSet() { - startPoints = new int[4]; - endPoints = new int[4]; - used = 0; - size = 0; - hashCode = -1; - } - - /** - * Create one IntRangeSet as a copy of another - * @param input the IntRangeSet to be copied - */ - - public IntRangeSet(IntRangeSet input) { - startPoints = new int[input.used]; - endPoints = new int[input.used]; - used = input.used; - System.arraycopy(input.startPoints, 0, startPoints, 0, used); - System.arraycopy(input.endPoints, 0, endPoints, 0, used); - hashCode = input.hashCode; - } - - /** - * Create an IntRangeSet given the start points and end points of the integer ranges. - * The two arrays must be the same length; each must be in ascending order; and the n'th end point - * must be greater than the n'th start point, and less than the n+1'th start point, for all n. - * @param startPoints the start points of the integer ranges - * @param endPoints the end points of the integer ranges - * @throws IllegalArgumentException if the two arrays are different lengths. Other error conditions - * in the input are not currently detected. - */ - - public IntRangeSet(int[] startPoints, int[] endPoints) { - if (startPoints.length != endPoints.length) { - throw new IllegalArgumentException("Array lengths differ"); - } - this.startPoints = startPoints; - this.endPoints = endPoints; - used = startPoints.length; - for (int i=0; i endPoints[used-1]) { - return false; - } - if (value < startPoints[0]) { - return false; - } - int i = 0; - int j = used; - do { - final int mid = i + (j-i)/2; - if (endPoints[mid] < value) { - i = Math.max(mid, i+1); - } else if (startPoints[mid] > value) { - j = Math.min(mid, j-1); - } else { - return true; - } - } while (i != j); - return false; - } - - public boolean remove(int value) { - throw new UnsupportedOperationException("remove"); - } - - /** - * Add an integer to the set - * @param value the integer to be added - * @return true if the integer was added, false if it was already present - */ - - public boolean add(int value) { - hashCode = -1; - if (used == 0) { - ensureCapacity(1); - startPoints[used-1] = value; - endPoints[used-1] = value; - size++; - return true; - } - if (value > endPoints[used-1]) { - if (value == endPoints[used-1] + 1) { - endPoints[used-1]++; - } else { - ensureCapacity(used+1); - startPoints[used-1] = value; - endPoints[used-1] = value; - } - size++; - return true; - } - if (value < startPoints[0]) { - if (value == startPoints[0] - 1) { - startPoints[0]--; - } else { - ensureCapacity(used+1); - System.arraycopy(startPoints, 0, startPoints, 1, used-1); - System.arraycopy(endPoints, 0, endPoints, 1, used-1); - startPoints[0] = value; - endPoints[0] = value; - } - size++; - return true; - } - int i = 0; - int j = used; - do { - final int mid = i + (j-i)/2; - if (endPoints[mid] < value) { - i = Math.max(mid, i+1); - } else if (startPoints[mid] > value) { - j = Math.min(mid, j-1); - } else { - return false; // value is already present - } - } while (i != j); - if (i > 0 && endPoints[i-1]+1 == value) { - i--; - } else if (i < used-1 && startPoints[i+1]-1 == value) { - i++; - } - if (endPoints[i]+1 == value) { - if (value == startPoints[i+1]-1) { - // merge the two ranges - endPoints[i] = endPoints[i+1]; - System.arraycopy(startPoints, i+2, startPoints, i+1, used-i-2); - System.arraycopy(endPoints, i+2, endPoints, i+1, used-i-2); - used--; - } else { - endPoints[i]++; - } - size++; - return true; - } else if (startPoints[i]-1 == value) { - if (value == endPoints[i-1]+1) { - // merge the two ranges - endPoints[i-1] = endPoints[i]; - System.arraycopy(startPoints, i+1, startPoints, i, used-i-1); - System.arraycopy(endPoints, i+1, endPoints, i, used-i-1); - used--; - } else { - startPoints[i]--; - } - size++; - return true; - } else { - if (value > endPoints[i]) { - i++; - } - ensureCapacity(used+1); - try { - System.arraycopy(startPoints, i, startPoints, i+1, used-i-1); - System.arraycopy(endPoints, i, endPoints, i+1, used-i-1); - } catch (final Exception err) { - err.printStackTrace(); - } - startPoints[i] = value; - endPoints[i] = value; - size++; - return true; - } - } - - private void ensureCapacity(int n) { - if (startPoints.length < n) { - int[] s = new int[startPoints.length * 2]; - int[] e = new int[startPoints.length * 2]; - System.arraycopy(startPoints, 0, s, 0, used); - System.arraycopy(endPoints, 0, e, 0, used); - startPoints = s; - endPoints = e; - } - used = n; - } - - - /** - * Get an iterator over the values - */ - - public IntRangeSetIterator iterator() { - return new IntRangeSetIterator(); - } - - public String toString() { - final FastStringBuffer sb = new FastStringBuffer(used*8); - for (int i=0; iNOT comparable with other implementations of IntSet - */ - - public boolean equals(Object other) { - if (other == null) {return false;} - if (other instanceof IntRangeSet) { - return used == ((IntRangeSet)other).used && - Arrays.equals(startPoints, ((IntRangeSet)other).startPoints) && - Arrays.equals(endPoints, ((IntRangeSet)other).endPoints) ; - } - return containsAll((IntRangeSet)other); - } - - /** - * Construct a hash key that supports the equals() test - */ - - public int hashCode() { - // Note, hashcodes are NOT the same as those used by IntHashSet and IntArraySet - if (hashCode == -1) { - int h = 0x836a89f1; - for (int i=0; i endPoints[used-1]) { - if (low == endPoints[used-1] + 1) { - endPoints[used-1] = high; - } else { - ensureCapacity(used+1); - startPoints[used-1] = low; - endPoints[used-1] = high; - } - size += (high - low + 1); - } else { - for (int i=low; i<=high; i++) { - add(i); - } - } - } - - /** - * Get the start points of the ranges - */ - - public int[] getStartPoints() { - return startPoints; - } - - /** - * Get the end points of the ranges - */ - - public int[] getEndPoints() { - return endPoints; - } - - /** - * Get the number of ranges actually in use - */ - - public int getNumberOfRanges() { - return used; - } - - /** - * Iterator class - */ - - private class IntRangeSetIterator implements Serializable { - - private int i = 0; - private int current = 0; - - public IntRangeSetIterator() { - i = -1; - current = Integer.MIN_VALUE; - } - - public boolean hasNext() { - if (i<0) { - return size > 0; - } else { - return current < endPoints[used-1]; - } - } - - public int next() { - if (i < 0) { - i = 0; - current = startPoints[0]; - return current; - } - if (current == endPoints[i]) { - current = startPoints[++i]; - return current; - } else { - return ++current; - } - } - } - -} - -// -// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License"); -// you may not use this file except in compliance with the License. You may obtain a copy of the -// License at http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" basis, -// WITHOUT WARRANTY OF ANY KIND, either express or implied. -// See the License for the specific language governing rights and limitations under the License. -// -// The Original Code is: all this file. -// -// The Initial Developer of the Original Code is Michael Kay. -// -// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved. -// -// Contributor(s): none. +package org.exist.xquery.regex; + +import java.io.Serializable; +import java.util.Arrays; + +import org.exist.util.FastStringBuffer; + +/** + * Set of int values. This implementation of IntSet uses a sorted array + * of integer ranges. + * + * Copied from Saxon-HE 9.2 package net.sf.saxon.regex. + * + * @author Michael Kay + */ +public class IntRangeSet implements Serializable { + + // The array of start points, which will always be sorted + private int[] startPoints; + + // The array of end points, which will always be sorted + private int[] endPoints; + + // The number of elements of the above two arrays that are actually in use + private int used = 0; + + // Hashcode, evaluated lazily + private int hashCode = -1; + + // The number of items in the set + private int size = 0; + + /** + * Create an empty set + */ + public IntRangeSet() { + startPoints = new int[4]; + endPoints = new int[4]; + used = 0; + size = 0; + hashCode = -1; + } + + /** + * Create one IntRangeSet as a copy of another + * @param input the IntRangeSet to be copied + */ + + public IntRangeSet(IntRangeSet input) { + startPoints = new int[input.used]; + endPoints = new int[input.used]; + used = input.used; + System.arraycopy(input.startPoints, 0, startPoints, 0, used); + System.arraycopy(input.endPoints, 0, endPoints, 0, used); + hashCode = input.hashCode; + } + + /** + * Create an IntRangeSet given the start points and end points of the integer ranges. + * The two arrays must be the same length; each must be in ascending order; and the n'th end point + * must be greater than the n'th start point, and less than the n+1'th start point, for all n. + * @param startPoints the start points of the integer ranges + * @param endPoints the end points of the integer ranges + * @throws IllegalArgumentException if the two arrays are different lengths. Other error conditions + * in the input are not currently detected. + */ + + public IntRangeSet(int[] startPoints, int[] endPoints) { + if (startPoints.length != endPoints.length) { + throw new IllegalArgumentException("Array lengths differ"); + } + this.startPoints = startPoints; + this.endPoints = endPoints; + used = startPoints.length; + for (int i=0; i endPoints[used-1]) { + return false; + } + if (value < startPoints[0]) { + return false; + } + int i = 0; + int j = used; + do { + final int mid = i + (j-i)/2; + if (endPoints[mid] < value) { + i = Math.max(mid, i+1); + } else if (startPoints[mid] > value) { + j = Math.min(mid, j-1); + } else { + return true; + } + } while (i != j); + return false; + } + + public boolean remove(int value) { + throw new UnsupportedOperationException("remove"); + } + + /** + * Add an integer to the set + * @param value the integer to be added + * @return true if the integer was added, false if it was already present + */ + + public boolean add(int value) { + hashCode = -1; + if (used == 0) { + ensureCapacity(1); + startPoints[used-1] = value; + endPoints[used-1] = value; + size++; + return true; + } + if (value > endPoints[used-1]) { + if (value == endPoints[used-1] + 1) { + endPoints[used-1]++; + } else { + ensureCapacity(used+1); + startPoints[used-1] = value; + endPoints[used-1] = value; + } + size++; + return true; + } + if (value < startPoints[0]) { + if (value == startPoints[0] - 1) { + startPoints[0]--; + } else { + ensureCapacity(used+1); + System.arraycopy(startPoints, 0, startPoints, 1, used-1); + System.arraycopy(endPoints, 0, endPoints, 1, used-1); + startPoints[0] = value; + endPoints[0] = value; + } + size++; + return true; + } + int i = 0; + int j = used; + do { + final int mid = i + (j-i)/2; + if (endPoints[mid] < value) { + i = Math.max(mid, i+1); + } else if (startPoints[mid] > value) { + j = Math.min(mid, j-1); + } else { + return false; // value is already present + } + } while (i != j); + if (i > 0 && endPoints[i-1]+1 == value) { + i--; + } else if (i < used-1 && startPoints[i+1]-1 == value) { + i++; + } + if (endPoints[i]+1 == value) { + if (value == startPoints[i+1]-1) { + // merge the two ranges + endPoints[i] = endPoints[i+1]; + System.arraycopy(startPoints, i+2, startPoints, i+1, used-i-2); + System.arraycopy(endPoints, i+2, endPoints, i+1, used-i-2); + used--; + } else { + endPoints[i]++; + } + size++; + return true; + } else if (startPoints[i]-1 == value) { + if (value == endPoints[i-1]+1) { + // merge the two ranges + endPoints[i-1] = endPoints[i]; + System.arraycopy(startPoints, i+1, startPoints, i, used-i-1); + System.arraycopy(endPoints, i+1, endPoints, i, used-i-1); + used--; + } else { + startPoints[i]--; + } + size++; + return true; + } else { + if (value > endPoints[i]) { + i++; + } + ensureCapacity(used+1); + try { + System.arraycopy(startPoints, i, startPoints, i+1, used-i-1); + System.arraycopy(endPoints, i, endPoints, i+1, used-i-1); + } catch (final Exception err) { + err.printStackTrace(); + } + startPoints[i] = value; + endPoints[i] = value; + size++; + return true; + } + } + + private void ensureCapacity(int n) { + if (startPoints.length < n) { + int[] s = new int[startPoints.length * 2]; + int[] e = new int[startPoints.length * 2]; + System.arraycopy(startPoints, 0, s, 0, used); + System.arraycopy(endPoints, 0, e, 0, used); + startPoints = s; + endPoints = e; + } + used = n; + } + + + /** + * Get an iterator over the values + */ + + public IntRangeSetIterator iterator() { + return new IntRangeSetIterator(); + } + + public String toString() { + final FastStringBuffer sb = new FastStringBuffer(used*8); + for (int i=0; iNOT comparable with other implementations of IntSet + */ + + public boolean equals(Object other) { + if (other == null) {return false;} + if (other instanceof IntRangeSet) { + return used == ((IntRangeSet)other).used && + Arrays.equals(startPoints, ((IntRangeSet)other).startPoints) && + Arrays.equals(endPoints, ((IntRangeSet)other).endPoints) ; + } + return containsAll((IntRangeSet)other); + } + + /** + * Construct a hash key that supports the equals() test + */ + + public int hashCode() { + // Note, hashcodes are NOT the same as those used by IntHashSet and IntArraySet + if (hashCode == -1) { + int h = 0x836a89f1; + for (int i=0; i endPoints[used-1]) { + if (low == endPoints[used-1] + 1) { + endPoints[used-1] = high; + } else { + ensureCapacity(used+1); + startPoints[used-1] = low; + endPoints[used-1] = high; + } + size += (high - low + 1); + } else { + for (int i=low; i<=high; i++) { + add(i); + } + } + } + + /** + * Get the start points of the ranges + */ + + public int[] getStartPoints() { + return startPoints; + } + + /** + * Get the end points of the ranges + */ + + public int[] getEndPoints() { + return endPoints; + } + + /** + * Get the number of ranges actually in use + */ + + public int getNumberOfRanges() { + return used; + } + + /** + * Iterator class + */ + + private class IntRangeSetIterator implements Serializable { + + private int i = 0; + private int current = 0; + + public IntRangeSetIterator() { + i = -1; + current = Integer.MIN_VALUE; + } + + public boolean hasNext() { + if (i<0) { + return size > 0; + } else { + return current < endPoints[used-1]; + } + } + + public int next() { + if (i < 0) { + i = 0; + current = startPoints[0]; + return current; + } + if (current == endPoints[i]) { + current = startPoints[++i]; + return current; + } else { + return ++current; + } + } + } + +} + +// +// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License"); +// you may not use this file except in compliance with the License. You may obtain a copy of the +// License at http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" basis, +// WITHOUT WARRANTY OF ANY KIND, either express or implied. +// See the License for the specific language governing rights and limitations under the License. +// +// The Original Code is: all this file. +// +// The Initial Developer of the Original Code is Michael Kay. +// +// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved. +// +// Contributor(s): none. diff --git a/src/org/exist/xquery/regex/JDK15RegexTranslator.java b/src/org/exist/xquery/regex/JDK15RegexTranslator.java index 069ab883f3a..31741ccc7fb 100644 --- a/src/org/exist/xquery/regex/JDK15RegexTranslator.java +++ b/src/org/exist/xquery/regex/JDK15RegexTranslator.java @@ -1,1016 +1,1016 @@ -package org.exist.xquery.regex; - -import java.util.ArrayList; -import java.util.List; - -import org.exist.util.FastStringBuffer; -import org.exist.util.UTF16CharacterSet; -import org.exist.xquery.value.StringValue; - -/** - * This class translates XML Schema regex syntax into JDK 1.5 regex syntax. This differs from the JDK 1.4 - * translator because JDK 1.5 handles non-BMP characters (wide characters) in places where JDK 1.4 does not, - * for example in a range such as [X-Y]. This enables much of the code from the 1.4 translator to be - * removed. - * Author: James Clark, Thai Open Source Software Center Ltd. See statement at end of file. - * Modified by Michael Kay (a) to integrate the code into Saxon, and (b) to support XPath additions - * to the XML Schema regex syntax. This version also removes most of the complexities of handling non-BMP - * characters, since JDK 1.5 handles these natively. - * - * Copied from Saxon-HE 9.2 package net.sf.saxon.regex. - */ -public class JDK15RegexTranslator extends RegexTranslator { - - int XML10 = 10; - - /** - * Translates XML Schema and XPath regexes into java.util.regex regexes. - * - * @see java.util.regex.Pattern - * @see XML Schema Part 2 - */ - - public static final CharClass[] categoryCharClasses = new CharClass[RegexData.categories.length()]; - public static final CharClass[] subCategoryCharClasses = new CharClass[RegexData.subCategories.length() / 2]; - - /** - * CharClass for each block name in specialBlockNames. - */ - public static final CharClass[] specialBlockCharClasses = { - new CharRange(0x10300, 0x1032F), - new CharRange(0x10330, 0x1034F), - new CharRange(0x10400, 0x1044F), - new CharRange(0x1D000, 0x1D0FF), - new CharRange(0x1D100, 0x1D1FF), - new CharRange(0x1D400, 0x1D7FF), - new CharRange(0x20000, 0x2A6D6), - new CharRange(0x2F800, 0x2FA1F), - new CharRange(0xE0000, 0xE007F), - new Union(new CharClass[]{ - new CharRange(0xE000, 0xF8FF), - new CharRange(0xF0000, 0xFFFFD), - new CharRange(0x100000, 0x10FFFD) - }), - Empty.getInstance(), - Empty.getInstance(), - Empty.getInstance() - }; - - private static final CharClass DOT_SCHEMA = - new Complement(new Union(new CharClass[]{new SingleChar('\n'), new SingleChar('\r')})); - - private static final CharClass ESC_d = new Property("Nd"); - - private static final CharClass ESC_D = new Complement(ESC_d); - - private static final CharClass ESC_W = new Union(new CharClass[]{computeCategoryCharClass('P'), - computeCategoryCharClass('Z'), - computeCategoryCharClass('C')}); - //was: new Property("P"), new Property("Z"), new Property("C") } - - private static final CharClass ESC_w = new Complement(ESC_W); - - private static final CharClass ESC_s = new Union(new CharClass[]{ - new SingleChar(' '), - new SingleChar('\n'), - new SingleChar('\r'), - new SingleChar('\t') - }); - - private static final CharClass ESC_S = new Complement(ESC_s); - -// private static final CharClass ESC_i = makeCharClass(RegexData.NMSTRT_CATEGORIES, -// RegexData.NMSTRT_INCLUDES, -// RegexData.NMSTRT_EXCLUDE_RANGES); - - private static final CharClass ESC_i_10 = makeNameCharClass(XMLCharacterData.NAME_START_10_MASK); - - private static final CharClass ESC_i_11 = makeNameCharClass(XMLCharacterData.NAME_START_11_MASK); - - private static final CharClass ESC_I_10 = new Complement(ESC_i_10); - - private static final CharClass ESC_I_11 = new Complement(ESC_i_11); - - private static final CharClass ESC_c_10 = makeNameCharClass(XMLCharacterData.NAME_10_MASK); - - private static final CharClass ESC_c_11 = makeNameCharClass(XMLCharacterData.NAME_11_MASK); - - private static final CharClass ESC_C_10 = new Complement(ESC_c_10); - - private static final CharClass ESC_C_11 = new Complement(ESC_c_11); - -// private static final CharClass ESC_I = new Complement(ESC_i); - -// private static final CharClass ESC_c = makeCharClass(RegexData.NMCHAR_CATEGORIES, -// RegexData.NMCHAR_INCLUDES, -// RegexData.NMCHAR_EXCLUDE_RANGES); -// -// private static final CharClass ESC_C = new Complement(ESC_c); - - private JDK15RegexTranslator() { - - } - - /** - * Translates a regular expression in the syntax of XML Schemas Part 2 into a regular - * expression in the syntax of java.util.regex.Pattern. The translation - * assumes that the string to be matched against the regex uses surrogate pairs correctly. - * If the string comes from XML content, a conforming XML parser will automatically - * check this; if the string comes from elsewhere, it may be necessary to check - * surrogate usage before matching. - * @param xmlVersion set to {@link net.sf.saxon.Configuration#XML10} for XML 1.0 - * or {@link net.sf.saxon.Configuration#XML11} for XML 1.1 - * @param regExp a String containing a regular expression in the syntax of XML Schemas Part 2 - * @param xpath a boolean indicating whether the XPath 2.0 F+O extensions to the schema - * regex syntax are permitted - * @param ignoreWhitespace true if whitespace is to be ignored ('x' flag) - * @param caseBlind true if case is to be ignored ('i' flag) - * @return a JDK 1.5 regular expression - * @throws RegexSyntaxException if regexp is not a regular expression in the - * syntax of XML Schemas Part 2, or XPath 2.0, as appropriate - * @see java.util.regex.Pattern - * @see XML Schema Part 2 - */ - public static String translate(CharSequence regExp, - int xmlVersion, boolean xpath, boolean ignoreWhitespace, boolean caseBlind) - throws RegexSyntaxException { - - //System.err.println("Input regex: " + regexp); - final JDK15RegexTranslator tr = new JDK15RegexTranslator(); - tr.regExp = regExp; - tr.length = regExp.length(); - tr.xmlVersion = xmlVersion; - tr.isXPath = xpath; - tr.ignoreWhitespace = ignoreWhitespace; - tr.caseBlind = caseBlind; - tr.advance(); - tr.translateTop(); - //System.err.println("Output regex: " + tr.result.toString()); - return tr.result.toString(); - } - - - - static abstract class CharClass { - - protected CharClass() { - } - - abstract void output(FastStringBuffer buf); - - abstract void outputComplement(FastStringBuffer buf); - - - int getSingleChar() { - return -1; - } - - } - - static abstract class SimpleCharClass extends CharClass { - SimpleCharClass() { - - } - - void output(FastStringBuffer buf) { - buf.append('['); - inClassOutput(buf); - buf.append(']'); - } - - void outputComplement(FastStringBuffer buf) { - buf.append("[^"); - inClassOutput(buf); - buf.append(']'); - } - - abstract void inClassOutput(FastStringBuffer buf); - } - - static class SingleChar extends SimpleCharClass { - private final int c; - private boolean isEscaped = false; - - SingleChar(int c) { - this.c = c; - } - - SingleChar(int c, boolean isEscaped) { - this.c = c; - this.isEscaped = isEscaped; - } - - int getSingleChar() { - return c; - } - - void output(FastStringBuffer buf) { - inClassOutput(buf); - } - - void inClassOutput(FastStringBuffer buf) { - if (isJavaMetaChar(c)) { - buf.append('\\'); - buf.append((char) c); - } else { - switch (c) { - case '\r': - buf.append("\\r"); - break; - case '\n': - buf.append("\\n"); - break; - case '\t': - buf.append("\\t"); - break; - case ' ': - buf.append("\\x20"); - break; - default: - buf.appendWideChar(c); - } - } - } - } - - - static class Empty extends SimpleCharClass { - private static final Empty instance = new Empty(); - - private Empty() { - - } - - static Empty getInstance() { - return instance; - } - - void output(FastStringBuffer buf) { - buf.append("\\x00"); // no character matches - } - - void outputComplement(FastStringBuffer buf) { - buf.append("[^\\x00]"); // every character matches - } - - void inClassOutput(FastStringBuffer buf) { - throw new RuntimeException("BMP output botch"); - } - - } - - static class CharRange extends SimpleCharClass { - private final int lower; - private final int upper; - - CharRange(int lower, int upper) { - this.lower = lower; - this.upper = upper; - } - - void inClassOutput(FastStringBuffer buf) { - if (isJavaMetaChar(lower)) { - buf.append('\\'); - } - buf.appendWideChar(lower); - buf.append('-'); - if (isJavaMetaChar(upper)) { - buf.append('\\'); - } - buf.appendWideChar(upper); - } - - } - - static class Property extends SimpleCharClass { - private final String name; - - Property(String name) { - this.name = name; - } - - void inClassOutput(FastStringBuffer buf) { - buf.append("\\p{"); - buf.append(name); - buf.append('}'); - } - - void outputComplement(FastStringBuffer buf) { - buf.append("\\P{"); - buf.append(name); - buf.append('}'); - } - } - - static class Subtraction extends CharClass { - private final CharClass cc1; - private final CharClass cc2; - - Subtraction(CharClass cc1, CharClass cc2) { - // min corresponds to intersection - // complement corresponds to negation - this.cc1 = cc1; - this.cc2 = cc2; - } - - void output(FastStringBuffer buf) { - buf.append('['); - cc1.output(buf); - buf.append("&&"); - cc2.outputComplement(buf); - buf.append(']'); - } - - void outputComplement(FastStringBuffer buf) { - buf.append('['); - cc1.outputComplement(buf); - cc2.output(buf); - buf.append(']'); - } - } - - static class Union extends CharClass { - private final List members; - - Union(CharClass[] v) { - this(toList(v)); - } - - private static List toList(CharClass[] v) { - final List members = new ArrayList(5); - for (int i = 0; i < v.length; i++) - members.add(v[i]); - return members; - } - - Union(List members) { - this.members = members; - } - - void output(FastStringBuffer buf) { - buf.append('['); - for (int i = 0, len = members.size(); i < len; i++) { - final CharClass cc = (CharClass) members.get(i); - cc.output(buf); - } - buf.append(']'); - } - - void outputComplement(FastStringBuffer buf) { - boolean first = true; - final int len = members.size(); - for (int i = 0; i < len; i++) { - final CharClass cc = (CharClass) members.get(i); - if (cc instanceof SimpleCharClass) { - if (first) { - buf.append("[^"); - first = false; - } - ((SimpleCharClass) cc).inClassOutput(buf); - } - } - for (int i = 0; i < len; i++) { - final CharClass cc = (CharClass) members.get(i); - if (!(cc instanceof SimpleCharClass)) { - if (first) { - buf.append('['); - first = false; - } else { - buf.append("&&"); - } - cc.outputComplement(buf); - } - } - if (first) { - // empty union, so the complement is everything - buf.append("[\u0001-"); - buf.appendWideChar(UTF16CharacterSet.NONBMP_MAX); - buf.append("]"); - } else { - buf.append(']'); - } - } - } - - static class BackReference extends CharClass { - private final int i; - - BackReference(int i) { - this.i = i; - } - - void output(FastStringBuffer buf) { - inClassOutput(buf); - } - - void outputComplement(FastStringBuffer buf) { - inClassOutput(buf); - } - - void inClassOutput(FastStringBuffer buf) { - if (i != -1) { - buf.append("(?:\\" + i + ")"); // terminate the back-reference with a syntactic separator - } else { - buf.append("(?:)"); // matches a zero-length string, while allowing a quantifier - } - } - } - - - static class Complement extends CharClass { - private final CharClass cc; - - Complement(CharClass cc) { - this.cc = cc; - } - - void output(FastStringBuffer buf) { - cc.outputComplement(buf); - } - - void outputComplement(FastStringBuffer buf) { - cc.output(buf); - } - } - - protected boolean translateAtom() throws RegexSyntaxException { - switch (curChar) { - case RegexData.EOS: - if (!eos) - {break;} - // else fall through - case '?': - case '*': - case '+': - case ')': - case '{': - case '}': - case '|': - case ']': - return false; - case '(': - copyCurChar(); - final int thisCapture = ++currentCapture; - translateRegExp(); - expect(')'); - captures.add(thisCapture); - copyCurChar(); - return true; - case '\\': - advance(); - parseEsc().output(result); - return true; - case '[': - inCharClassExpr = true; - advance(); - parseCharClassExpr().output(result); - return true; - case '.': - if (isXPath) { - // under XPath, "." has the same meaning as in JDK 1.5 - break; - } else { - // under XMLSchema, "." means anything except \n or \r, which is different from the XPath/JDK rule - DOT_SCHEMA.output(result); - advance(); - return true; - } - case '$': - case '^': - if (isXPath) { - copyCurChar(); - return true; - } - result.append('\\'); - break; - default: - if (caseBlind) { - final int thisChar = absorbSurrogatePair(); - final int[] variants = CaseVariants.getCaseVariants(thisChar); - if (variants.length > 0) { - final CharClass[] chars = new CharClass[variants.length+1]; - chars[0] = new SingleChar(thisChar); - for (int i=0; i currentCapture) { - break; - } else { - backRef = backRef2; - } - } - - } - if (!captures.contains(backRef)) { - final String explanation = (backRef > currentCapture ? "(no such group)" : "(group not yet closed)"); - throw makeException("invalid backreference \\" + backRef + " " + explanation); - } - return new BackReference(backRef); - } else { - throw makeException("digit not allowed after \\"); - } - case '$': - if (isXPath) { - break; - } - // otherwise fall through - default: - throw makeException("invalid escape sequence"); - } - final CharClass tem = new SingleChar(curChar, true); - advance(); - return tem; - } - - private CharClass parseProp() throws RegexSyntaxException { - expect('{'); - final int start = pos; - for (; ;) { - advance(); - if (curChar == '}') - {break;} - if (!isAsciiAlnum(curChar) && curChar != '-') - {expect('}');} - } - CharSequence propertyNameCS = regExp.subSequence(start, pos - 1); - if (ignoreWhitespace && !inCharClassExpr) { - propertyNameCS = StringValue.collapseWhitespace(propertyNameCS); - } - final String propertyName = propertyNameCS.toString(); - advance(); - switch (propertyName.length()) { - case 0: - throw makeException("empty property name"); - case 2: - final int sci = RegexData.subCategories.indexOf(propertyName); - if (sci < 0 || sci % 2 == 1) - {throw makeException("unknown category");} - return getSubCategoryCharClass(sci / 2); - case 1: - final int ci = RegexData.categories.indexOf(propertyName.charAt(0)); - if (ci < 0) - {throw makeException("unknown category", propertyName);} - return getCategoryCharClass(ci); - default: - if (!propertyName.startsWith("Is")) - {break;} - final String blockName = propertyName.substring(2); - for (int i = 0; i < RegexData.specialBlockNames.length; i++) - if (blockName.equals(RegexData.specialBlockNames[i])) - {return specialBlockCharClasses[i];} - if (!isBlock(blockName)) - {throw makeException("invalid block name", blockName);} - return new Property("In" + blockName); - } - throw makeException("invalid property name", propertyName); - } - - private CharClass parseCharClassExpr() throws RegexSyntaxException { - boolean compl; - if (curChar == '^') { - advance(); - compl = true; - } else { - compl = false; - } - final List members = new ArrayList(10); - //boolean firstOrLast = true; - do { - final CharClass lower = parseCharClassEscOrXmlChar(); - members.add(lower); - if (curChar == ']' || eos) { - addCaseVariant(lower, members); - break; - } - //firstOrLast = isLastInGroup(); - if (curChar == '-') { - final char next = regExp.charAt(pos); - if (next == '[') { - // hyphen denotes subtraction - addCaseVariant(lower, members); - advance(); - break; - } else if (next == ']') { - // hyphen denotes a regular character - no need to do anything - addCaseVariant(lower, members); - } else { - // hyphen denotes a character range - advance(); - final CharClass upper = parseCharClassEscOrXmlChar(); - if (lower.getSingleChar() < 0 || upper.getSingleChar() < 0) { - throw makeException("the ends of a range must be single characters"); - } - if (lower.getSingleChar() > upper.getSingleChar()) { - throw makeException("invalid range (start > end)"); - } - if (lower instanceof SingleChar && lower.getSingleChar() == '-' && !((SingleChar)lower).isEscaped) { - throw makeException("range cannot start with unescaped hyphen"); - } - if (upper instanceof SingleChar && upper.getSingleChar() == '-' && !((SingleChar)upper).isEscaped) { - throw makeException("range cannot end with unescaped hyphen"); - } - members.set(members.size() - 1, - new CharRange(lower.getSingleChar(), upper.getSingleChar())); - if (caseBlind) { - // Special-case A-Z and a-z - if (lower.getSingleChar() == 'a' && upper.getSingleChar() == 'z') { - members.add(new CharRange('A', 'Z')); - for (int v=0; v= 0; ci = RegexData.CATEGORY_NAMES.indexOf(code, ci + 1)) { - final int[] addRanges = RegexData.CATEGORY_RANGES[ci / 2]; - for (int i = 0; i < addRanges.length; i += 2) - classes.add(new CharRange(addRanges[i], addRanges[i + 1])); - } - if (code == 'P') - {classes.add(makeCharClass(RegexData.CATEGORY_Pi + RegexData.CATEGORY_Pf));} - if (code == 'L') { - classes.add(new SingleChar(RegexData.UNICODE_3_1_ADD_Ll)); - classes.add(new SingleChar(RegexData.UNICODE_3_1_ADD_Lu)); - } - if (code == 'C') { - // JDK 1.4 leaves Cn out of C? - classes.add(new Subtraction(new Property("Cn"), - new Union(new CharClass[]{new SingleChar(RegexData.UNICODE_3_1_ADD_Lu), - new SingleChar(RegexData.UNICODE_3_1_ADD_Ll)}))); - final List assignedRanges = new ArrayList(5); - for (int i = 0; i < RegexData.CATEGORY_RANGES.length; i++) - for (int j = 0; j < RegexData.CATEGORY_RANGES[i].length; j += 2) - assignedRanges.add(new CharRange(RegexData.CATEGORY_RANGES[i][j], - RegexData.CATEGORY_RANGES[i][j + 1])); - classes.add(new Subtraction(new CharRange(UTF16CharacterSet.NONBMP_MIN, UTF16CharacterSet.NONBMP_MAX), - new Union(assignedRanges))); - } - if (classes.size() == 1) - {return (CharClass) classes.get(0);} - return new Union(classes); - } - - private static CharClass computeSubCategoryCharClass(String name) { - final CharClass base = new Property(name); - final int sci = RegexData.CATEGORY_NAMES.indexOf(name); - if (sci < 0) { - if ("Cn".equals(name)) { - // Unassigned - final List assignedRanges = new ArrayList(5); - assignedRanges.add(new SingleChar(RegexData.UNICODE_3_1_ADD_Lu)); - assignedRanges.add(new SingleChar(RegexData.UNICODE_3_1_ADD_Ll)); - for (int i = 0; i < RegexData.CATEGORY_RANGES.length; i++) - for (int j = 0; j < RegexData.CATEGORY_RANGES[i].length; j += 2) - assignedRanges.add(new CharRange(RegexData.CATEGORY_RANGES[i][j], - RegexData.CATEGORY_RANGES[i][j + 1])); - return new Subtraction(new Union( - new CharClass[]{base, new CharRange(UTF16CharacterSet.NONBMP_MIN, UTF16CharacterSet.NONBMP_MAX)}), - new Union(assignedRanges)); - } - if ("Pi".equals(name)) - {return makeCharClass(RegexData.CATEGORY_Pi);} - if ("Pf".equals(name)) - {return makeCharClass(RegexData.CATEGORY_Pf);} - return base; - } - final List classes = new ArrayList(5); - classes.add(base); - final int[] addRanges = RegexData.CATEGORY_RANGES[sci / 2]; - for (int i = 0; i < addRanges.length; i += 2) - classes.add(new CharRange(addRanges[i], addRanges[i + 1])); - if ("Lu".equals(name)) - {classes.add(new SingleChar(RegexData.UNICODE_3_1_ADD_Lu));} - else if ("Ll".equals(name)) - {classes.add(new SingleChar(RegexData.UNICODE_3_1_ADD_Ll));} - else if ("Nl".equals(name)) - {classes.add(new CharRange(RegexData.UNICODE_3_1_CHANGE_No_to_Nl_MIN, RegexData.UNICODE_3_1_CHANGE_No_to_Nl_MAX));} - else if ("No".equals(name)) - {return new Subtraction(new Union(classes), - new CharRange(RegexData.UNICODE_3_1_CHANGE_No_to_Nl_MIN, - RegexData.UNICODE_3_1_CHANGE_No_to_Nl_MAX));} - return new Union(classes); - } - - private static CharClass makeCharClass(String members) { - final List list = new ArrayList(5); - for (int i = 0, len = members.length(); i < len; i++) - list.add(new SingleChar(members.charAt(i))); - return new Union(list); - } - - /** - * Main method for testing. Outputs to System.err the Java translation of a supplied - * regular expression - * @param args command line arguments - * arg[0] a regular expression - * arg[1] = xpath to invoke the XPath rules - * @throws RegexSyntaxException - */ - -// public static void main(String[] args) throws RegexSyntaxException { -// String s = translate(args[0], 11, args[1].equals("xpath"), false, true); -// System.err.println(StringValue.diagnosticDisplay(s)); -// try { -// Pattern.compile(s); -// } catch (Exception err) { -// System.err.println("Error: " + err.getMessage()); -// } -// System.err.println(); -// } - - -//} - - -} - -/* -Copyright (c) 2001-2003 Thai Open Source Software Center Ltd -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - Neither the name of the Thai Open Source Software Center Ltd nor - the names of its contributors may be used to endorse or promote - products derived from this software without specific prior written - permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -// -// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License"); -// you may not use this file except in compliance with the License. You may obtain a copy of the -// License at http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" basis, -// WITHOUT WARRANTY OF ANY KIND, either express or implied. -// See the License for the specific language governing rights and limitations under the License. -// -// The Original Code is: all this file except changes marked. -// -// The Initial Developer of the Original Code is James Clark -// -// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved. -// -// Contributor(s): Michael Kay -// - +package org.exist.xquery.regex; + +import java.util.ArrayList; +import java.util.List; + +import org.exist.util.FastStringBuffer; +import org.exist.util.UTF16CharacterSet; +import org.exist.xquery.value.StringValue; + +/** + * This class translates XML Schema regex syntax into JDK 1.5 regex syntax. This differs from the JDK 1.4 + * translator because JDK 1.5 handles non-BMP characters (wide characters) in places where JDK 1.4 does not, + * for example in a range such as [X-Y]. This enables much of the code from the 1.4 translator to be + * removed. + * Author: James Clark, Thai Open Source Software Center Ltd. See statement at end of file. + * Modified by Michael Kay (a) to integrate the code into Saxon, and (b) to support XPath additions + * to the XML Schema regex syntax. This version also removes most of the complexities of handling non-BMP + * characters, since JDK 1.5 handles these natively. + * + * Copied from Saxon-HE 9.2 package net.sf.saxon.regex. + */ +public class JDK15RegexTranslator extends RegexTranslator { + + int XML10 = 10; + + /** + * Translates XML Schema and XPath regexes into java.util.regex regexes. + * + * @see java.util.regex.Pattern + * @see XML Schema Part 2 + */ + + public static final CharClass[] categoryCharClasses = new CharClass[RegexData.categories.length()]; + public static final CharClass[] subCategoryCharClasses = new CharClass[RegexData.subCategories.length() / 2]; + + /** + * CharClass for each block name in specialBlockNames. + */ + public static final CharClass[] specialBlockCharClasses = { + new CharRange(0x10300, 0x1032F), + new CharRange(0x10330, 0x1034F), + new CharRange(0x10400, 0x1044F), + new CharRange(0x1D000, 0x1D0FF), + new CharRange(0x1D100, 0x1D1FF), + new CharRange(0x1D400, 0x1D7FF), + new CharRange(0x20000, 0x2A6D6), + new CharRange(0x2F800, 0x2FA1F), + new CharRange(0xE0000, 0xE007F), + new Union(new CharClass[]{ + new CharRange(0xE000, 0xF8FF), + new CharRange(0xF0000, 0xFFFFD), + new CharRange(0x100000, 0x10FFFD) + }), + Empty.getInstance(), + Empty.getInstance(), + Empty.getInstance() + }; + + private static final CharClass DOT_SCHEMA = + new Complement(new Union(new CharClass[]{new SingleChar('\n'), new SingleChar('\r')})); + + private static final CharClass ESC_d = new Property("Nd"); + + private static final CharClass ESC_D = new Complement(ESC_d); + + private static final CharClass ESC_W = new Union(new CharClass[]{computeCategoryCharClass('P'), + computeCategoryCharClass('Z'), + computeCategoryCharClass('C')}); + //was: new Property("P"), new Property("Z"), new Property("C") } + + private static final CharClass ESC_w = new Complement(ESC_W); + + private static final CharClass ESC_s = new Union(new CharClass[]{ + new SingleChar(' '), + new SingleChar('\n'), + new SingleChar('\r'), + new SingleChar('\t') + }); + + private static final CharClass ESC_S = new Complement(ESC_s); + +// private static final CharClass ESC_i = makeCharClass(RegexData.NMSTRT_CATEGORIES, +// RegexData.NMSTRT_INCLUDES, +// RegexData.NMSTRT_EXCLUDE_RANGES); + + private static final CharClass ESC_i_10 = makeNameCharClass(XMLCharacterData.NAME_START_10_MASK); + + private static final CharClass ESC_i_11 = makeNameCharClass(XMLCharacterData.NAME_START_11_MASK); + + private static final CharClass ESC_I_10 = new Complement(ESC_i_10); + + private static final CharClass ESC_I_11 = new Complement(ESC_i_11); + + private static final CharClass ESC_c_10 = makeNameCharClass(XMLCharacterData.NAME_10_MASK); + + private static final CharClass ESC_c_11 = makeNameCharClass(XMLCharacterData.NAME_11_MASK); + + private static final CharClass ESC_C_10 = new Complement(ESC_c_10); + + private static final CharClass ESC_C_11 = new Complement(ESC_c_11); + +// private static final CharClass ESC_I = new Complement(ESC_i); + +// private static final CharClass ESC_c = makeCharClass(RegexData.NMCHAR_CATEGORIES, +// RegexData.NMCHAR_INCLUDES, +// RegexData.NMCHAR_EXCLUDE_RANGES); +// +// private static final CharClass ESC_C = new Complement(ESC_c); + + private JDK15RegexTranslator() { + + } + + /** + * Translates a regular expression in the syntax of XML Schemas Part 2 into a regular + * expression in the syntax of java.util.regex.Pattern. The translation + * assumes that the string to be matched against the regex uses surrogate pairs correctly. + * If the string comes from XML content, a conforming XML parser will automatically + * check this; if the string comes from elsewhere, it may be necessary to check + * surrogate usage before matching. + * @param xmlVersion set to {@link net.sf.saxon.Configuration#XML10} for XML 1.0 + * or {@link net.sf.saxon.Configuration#XML11} for XML 1.1 + * @param regExp a String containing a regular expression in the syntax of XML Schemas Part 2 + * @param xpath a boolean indicating whether the XPath 2.0 F+O extensions to the schema + * regex syntax are permitted + * @param ignoreWhitespace true if whitespace is to be ignored ('x' flag) + * @param caseBlind true if case is to be ignored ('i' flag) + * @return a JDK 1.5 regular expression + * @throws RegexSyntaxException if regexp is not a regular expression in the + * syntax of XML Schemas Part 2, or XPath 2.0, as appropriate + * @see java.util.regex.Pattern + * @see XML Schema Part 2 + */ + public static String translate(CharSequence regExp, + int xmlVersion, boolean xpath, boolean ignoreWhitespace, boolean caseBlind) + throws RegexSyntaxException { + + //System.err.println("Input regex: " + regexp); + final JDK15RegexTranslator tr = new JDK15RegexTranslator(); + tr.regExp = regExp; + tr.length = regExp.length(); + tr.xmlVersion = xmlVersion; + tr.isXPath = xpath; + tr.ignoreWhitespace = ignoreWhitespace; + tr.caseBlind = caseBlind; + tr.advance(); + tr.translateTop(); + //System.err.println("Output regex: " + tr.result.toString()); + return tr.result.toString(); + } + + + + static abstract class CharClass { + + protected CharClass() { + } + + abstract void output(FastStringBuffer buf); + + abstract void outputComplement(FastStringBuffer buf); + + + int getSingleChar() { + return -1; + } + + } + + static abstract class SimpleCharClass extends CharClass { + SimpleCharClass() { + + } + + void output(FastStringBuffer buf) { + buf.append('['); + inClassOutput(buf); + buf.append(']'); + } + + void outputComplement(FastStringBuffer buf) { + buf.append("[^"); + inClassOutput(buf); + buf.append(']'); + } + + abstract void inClassOutput(FastStringBuffer buf); + } + + static class SingleChar extends SimpleCharClass { + private final int c; + private boolean isEscaped = false; + + SingleChar(int c) { + this.c = c; + } + + SingleChar(int c, boolean isEscaped) { + this.c = c; + this.isEscaped = isEscaped; + } + + int getSingleChar() { + return c; + } + + void output(FastStringBuffer buf) { + inClassOutput(buf); + } + + void inClassOutput(FastStringBuffer buf) { + if (isJavaMetaChar(c)) { + buf.append('\\'); + buf.append((char) c); + } else { + switch (c) { + case '\r': + buf.append("\\r"); + break; + case '\n': + buf.append("\\n"); + break; + case '\t': + buf.append("\\t"); + break; + case ' ': + buf.append("\\x20"); + break; + default: + buf.appendWideChar(c); + } + } + } + } + + + static class Empty extends SimpleCharClass { + private static final Empty instance = new Empty(); + + private Empty() { + + } + + static Empty getInstance() { + return instance; + } + + void output(FastStringBuffer buf) { + buf.append("\\x00"); // no character matches + } + + void outputComplement(FastStringBuffer buf) { + buf.append("[^\\x00]"); // every character matches + } + + void inClassOutput(FastStringBuffer buf) { + throw new RuntimeException("BMP output botch"); + } + + } + + static class CharRange extends SimpleCharClass { + private final int lower; + private final int upper; + + CharRange(int lower, int upper) { + this.lower = lower; + this.upper = upper; + } + + void inClassOutput(FastStringBuffer buf) { + if (isJavaMetaChar(lower)) { + buf.append('\\'); + } + buf.appendWideChar(lower); + buf.append('-'); + if (isJavaMetaChar(upper)) { + buf.append('\\'); + } + buf.appendWideChar(upper); + } + + } + + static class Property extends SimpleCharClass { + private final String name; + + Property(String name) { + this.name = name; + } + + void inClassOutput(FastStringBuffer buf) { + buf.append("\\p{"); + buf.append(name); + buf.append('}'); + } + + void outputComplement(FastStringBuffer buf) { + buf.append("\\P{"); + buf.append(name); + buf.append('}'); + } + } + + static class Subtraction extends CharClass { + private final CharClass cc1; + private final CharClass cc2; + + Subtraction(CharClass cc1, CharClass cc2) { + // min corresponds to intersection + // complement corresponds to negation + this.cc1 = cc1; + this.cc2 = cc2; + } + + void output(FastStringBuffer buf) { + buf.append('['); + cc1.output(buf); + buf.append("&&"); + cc2.outputComplement(buf); + buf.append(']'); + } + + void outputComplement(FastStringBuffer buf) { + buf.append('['); + cc1.outputComplement(buf); + cc2.output(buf); + buf.append(']'); + } + } + + static class Union extends CharClass { + private final List members; + + Union(CharClass[] v) { + this(toList(v)); + } + + private static List toList(CharClass[] v) { + final List members = new ArrayList(5); + for (int i = 0; i < v.length; i++) + members.add(v[i]); + return members; + } + + Union(List members) { + this.members = members; + } + + void output(FastStringBuffer buf) { + buf.append('['); + for (int i = 0, len = members.size(); i < len; i++) { + final CharClass cc = (CharClass) members.get(i); + cc.output(buf); + } + buf.append(']'); + } + + void outputComplement(FastStringBuffer buf) { + boolean first = true; + final int len = members.size(); + for (int i = 0; i < len; i++) { + final CharClass cc = (CharClass) members.get(i); + if (cc instanceof SimpleCharClass) { + if (first) { + buf.append("[^"); + first = false; + } + ((SimpleCharClass) cc).inClassOutput(buf); + } + } + for (int i = 0; i < len; i++) { + final CharClass cc = (CharClass) members.get(i); + if (!(cc instanceof SimpleCharClass)) { + if (first) { + buf.append('['); + first = false; + } else { + buf.append("&&"); + } + cc.outputComplement(buf); + } + } + if (first) { + // empty union, so the complement is everything + buf.append("[\u0001-"); + buf.appendWideChar(UTF16CharacterSet.NONBMP_MAX); + buf.append("]"); + } else { + buf.append(']'); + } + } + } + + static class BackReference extends CharClass { + private final int i; + + BackReference(int i) { + this.i = i; + } + + void output(FastStringBuffer buf) { + inClassOutput(buf); + } + + void outputComplement(FastStringBuffer buf) { + inClassOutput(buf); + } + + void inClassOutput(FastStringBuffer buf) { + if (i != -1) { + buf.append("(?:\\" + i + ")"); // terminate the back-reference with a syntactic separator + } else { + buf.append("(?:)"); // matches a zero-length string, while allowing a quantifier + } + } + } + + + static class Complement extends CharClass { + private final CharClass cc; + + Complement(CharClass cc) { + this.cc = cc; + } + + void output(FastStringBuffer buf) { + cc.outputComplement(buf); + } + + void outputComplement(FastStringBuffer buf) { + cc.output(buf); + } + } + + protected boolean translateAtom() throws RegexSyntaxException { + switch (curChar) { + case RegexData.EOS: + if (!eos) + {break;} + // else fall through + case '?': + case '*': + case '+': + case ')': + case '{': + case '}': + case '|': + case ']': + return false; + case '(': + copyCurChar(); + final int thisCapture = ++currentCapture; + translateRegExp(); + expect(')'); + captures.add(thisCapture); + copyCurChar(); + return true; + case '\\': + advance(); + parseEsc().output(result); + return true; + case '[': + inCharClassExpr = true; + advance(); + parseCharClassExpr().output(result); + return true; + case '.': + if (isXPath) { + // under XPath, "." has the same meaning as in JDK 1.5 + break; + } else { + // under XMLSchema, "." means anything except \n or \r, which is different from the XPath/JDK rule + DOT_SCHEMA.output(result); + advance(); + return true; + } + case '$': + case '^': + if (isXPath) { + copyCurChar(); + return true; + } + result.append('\\'); + break; + default: + if (caseBlind) { + final int thisChar = absorbSurrogatePair(); + final int[] variants = CaseVariants.getCaseVariants(thisChar); + if (variants.length > 0) { + final CharClass[] chars = new CharClass[variants.length+1]; + chars[0] = new SingleChar(thisChar); + for (int i=0; i currentCapture) { + break; + } else { + backRef = backRef2; + } + } + + } + if (!captures.contains(backRef)) { + final String explanation = (backRef > currentCapture ? "(no such group)" : "(group not yet closed)"); + throw makeException("invalid backreference \\" + backRef + " " + explanation); + } + return new BackReference(backRef); + } else { + throw makeException("digit not allowed after \\"); + } + case '$': + if (isXPath) { + break; + } + // otherwise fall through + default: + throw makeException("invalid escape sequence"); + } + final CharClass tem = new SingleChar(curChar, true); + advance(); + return tem; + } + + private CharClass parseProp() throws RegexSyntaxException { + expect('{'); + final int start = pos; + for (; ;) { + advance(); + if (curChar == '}') + {break;} + if (!isAsciiAlnum(curChar) && curChar != '-') + {expect('}');} + } + CharSequence propertyNameCS = regExp.subSequence(start, pos - 1); + if (ignoreWhitespace && !inCharClassExpr) { + propertyNameCS = StringValue.collapseWhitespace(propertyNameCS); + } + final String propertyName = propertyNameCS.toString(); + advance(); + switch (propertyName.length()) { + case 0: + throw makeException("empty property name"); + case 2: + final int sci = RegexData.subCategories.indexOf(propertyName); + if (sci < 0 || sci % 2 == 1) + {throw makeException("unknown category");} + return getSubCategoryCharClass(sci / 2); + case 1: + final int ci = RegexData.categories.indexOf(propertyName.charAt(0)); + if (ci < 0) + {throw makeException("unknown category", propertyName);} + return getCategoryCharClass(ci); + default: + if (!propertyName.startsWith("Is")) + {break;} + final String blockName = propertyName.substring(2); + for (int i = 0; i < RegexData.specialBlockNames.length; i++) + if (blockName.equals(RegexData.specialBlockNames[i])) + {return specialBlockCharClasses[i];} + if (!isBlock(blockName)) + {throw makeException("invalid block name", blockName);} + return new Property("In" + blockName); + } + throw makeException("invalid property name", propertyName); + } + + private CharClass parseCharClassExpr() throws RegexSyntaxException { + boolean compl; + if (curChar == '^') { + advance(); + compl = true; + } else { + compl = false; + } + final List members = new ArrayList(10); + //boolean firstOrLast = true; + do { + final CharClass lower = parseCharClassEscOrXmlChar(); + members.add(lower); + if (curChar == ']' || eos) { + addCaseVariant(lower, members); + break; + } + //firstOrLast = isLastInGroup(); + if (curChar == '-') { + final char next = regExp.charAt(pos); + if (next == '[') { + // hyphen denotes subtraction + addCaseVariant(lower, members); + advance(); + break; + } else if (next == ']') { + // hyphen denotes a regular character - no need to do anything + addCaseVariant(lower, members); + } else { + // hyphen denotes a character range + advance(); + final CharClass upper = parseCharClassEscOrXmlChar(); + if (lower.getSingleChar() < 0 || upper.getSingleChar() < 0) { + throw makeException("the ends of a range must be single characters"); + } + if (lower.getSingleChar() > upper.getSingleChar()) { + throw makeException("invalid range (start > end)"); + } + if (lower instanceof SingleChar && lower.getSingleChar() == '-' && !((SingleChar)lower).isEscaped) { + throw makeException("range cannot start with unescaped hyphen"); + } + if (upper instanceof SingleChar && upper.getSingleChar() == '-' && !((SingleChar)upper).isEscaped) { + throw makeException("range cannot end with unescaped hyphen"); + } + members.set(members.size() - 1, + new CharRange(lower.getSingleChar(), upper.getSingleChar())); + if (caseBlind) { + // Special-case A-Z and a-z + if (lower.getSingleChar() == 'a' && upper.getSingleChar() == 'z') { + members.add(new CharRange('A', 'Z')); + for (int v=0; v= 0; ci = RegexData.CATEGORY_NAMES.indexOf(code, ci + 1)) { + final int[] addRanges = RegexData.CATEGORY_RANGES[ci / 2]; + for (int i = 0; i < addRanges.length; i += 2) + classes.add(new CharRange(addRanges[i], addRanges[i + 1])); + } + if (code == 'P') + {classes.add(makeCharClass(RegexData.CATEGORY_Pi + RegexData.CATEGORY_Pf));} + if (code == 'L') { + classes.add(new SingleChar(RegexData.UNICODE_3_1_ADD_Ll)); + classes.add(new SingleChar(RegexData.UNICODE_3_1_ADD_Lu)); + } + if (code == 'C') { + // JDK 1.4 leaves Cn out of C? + classes.add(new Subtraction(new Property("Cn"), + new Union(new CharClass[]{new SingleChar(RegexData.UNICODE_3_1_ADD_Lu), + new SingleChar(RegexData.UNICODE_3_1_ADD_Ll)}))); + final List assignedRanges = new ArrayList(5); + for (int i = 0; i < RegexData.CATEGORY_RANGES.length; i++) + for (int j = 0; j < RegexData.CATEGORY_RANGES[i].length; j += 2) + assignedRanges.add(new CharRange(RegexData.CATEGORY_RANGES[i][j], + RegexData.CATEGORY_RANGES[i][j + 1])); + classes.add(new Subtraction(new CharRange(UTF16CharacterSet.NONBMP_MIN, UTF16CharacterSet.NONBMP_MAX), + new Union(assignedRanges))); + } + if (classes.size() == 1) + {return (CharClass) classes.get(0);} + return new Union(classes); + } + + private static CharClass computeSubCategoryCharClass(String name) { + final CharClass base = new Property(name); + final int sci = RegexData.CATEGORY_NAMES.indexOf(name); + if (sci < 0) { + if ("Cn".equals(name)) { + // Unassigned + final List assignedRanges = new ArrayList(5); + assignedRanges.add(new SingleChar(RegexData.UNICODE_3_1_ADD_Lu)); + assignedRanges.add(new SingleChar(RegexData.UNICODE_3_1_ADD_Ll)); + for (int i = 0; i < RegexData.CATEGORY_RANGES.length; i++) + for (int j = 0; j < RegexData.CATEGORY_RANGES[i].length; j += 2) + assignedRanges.add(new CharRange(RegexData.CATEGORY_RANGES[i][j], + RegexData.CATEGORY_RANGES[i][j + 1])); + return new Subtraction(new Union( + new CharClass[]{base, new CharRange(UTF16CharacterSet.NONBMP_MIN, UTF16CharacterSet.NONBMP_MAX)}), + new Union(assignedRanges)); + } + if ("Pi".equals(name)) + {return makeCharClass(RegexData.CATEGORY_Pi);} + if ("Pf".equals(name)) + {return makeCharClass(RegexData.CATEGORY_Pf);} + return base; + } + final List classes = new ArrayList(5); + classes.add(base); + final int[] addRanges = RegexData.CATEGORY_RANGES[sci / 2]; + for (int i = 0; i < addRanges.length; i += 2) + classes.add(new CharRange(addRanges[i], addRanges[i + 1])); + if ("Lu".equals(name)) + {classes.add(new SingleChar(RegexData.UNICODE_3_1_ADD_Lu));} + else if ("Ll".equals(name)) + {classes.add(new SingleChar(RegexData.UNICODE_3_1_ADD_Ll));} + else if ("Nl".equals(name)) + {classes.add(new CharRange(RegexData.UNICODE_3_1_CHANGE_No_to_Nl_MIN, RegexData.UNICODE_3_1_CHANGE_No_to_Nl_MAX));} + else if ("No".equals(name)) + {return new Subtraction(new Union(classes), + new CharRange(RegexData.UNICODE_3_1_CHANGE_No_to_Nl_MIN, + RegexData.UNICODE_3_1_CHANGE_No_to_Nl_MAX));} + return new Union(classes); + } + + private static CharClass makeCharClass(String members) { + final List list = new ArrayList(5); + for (int i = 0, len = members.length(); i < len; i++) + list.add(new SingleChar(members.charAt(i))); + return new Union(list); + } + + /** + * Main method for testing. Outputs to System.err the Java translation of a supplied + * regular expression + * @param args command line arguments + * arg[0] a regular expression + * arg[1] = xpath to invoke the XPath rules + * @throws RegexSyntaxException + */ + +// public static void main(String[] args) throws RegexSyntaxException { +// String s = translate(args[0], 11, args[1].equals("xpath"), false, true); +// System.err.println(StringValue.diagnosticDisplay(s)); +// try { +// Pattern.compile(s); +// } catch (Exception err) { +// System.err.println("Error: " + err.getMessage()); +// } +// System.err.println(); +// } + + +//} + + +} + +/* +Copyright (c) 2001-2003 Thai Open Source Software Center Ltd +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + Neither the name of the Thai Open Source Software Center Ltd nor + the names of its contributors may be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// +// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License"); +// you may not use this file except in compliance with the License. You may obtain a copy of the +// License at http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" basis, +// WITHOUT WARRANTY OF ANY KIND, either express or implied. +// See the License for the specific language governing rights and limitations under the License. +// +// The Original Code is: all this file except changes marked. +// +// The Initial Developer of the Original Code is James Clark +// +// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved. +// +// Contributor(s): Michael Kay +// + diff --git a/src/org/exist/xquery/regex/RegexData.java b/src/org/exist/xquery/regex/RegexData.java index 80e3ed75561..70cbe4ef783 100644 --- a/src/org/exist/xquery/regex/RegexData.java +++ b/src/org/exist/xquery/regex/RegexData.java @@ -1,361 +1,361 @@ -package org.exist.xquery.regex; - -/** - * Non-instantiable class containing constant data definitions used by the various Regular Expression translators - * - * Copied from Saxon-HE 9.2 package net.sf.saxon.regex without change. - */ -public class RegexData { - - public static final String categories = "LMNPZSC"; - public static final String subCategories = "LuLlLtLmLoMnMcMeNdNlNoPcPdPsPePiPfPoZsZlZpSmScSkSoCcCfCoCn"; - - public static final char EOS = '\0'; - - - public static final String[] blockNames = { - "BasicLatin", - "Latin-1Supplement", - "LatinExtended-A", - "LatinExtended-B", - "IPAExtensions", - "SpacingModifierLetters", - "CombiningDiacriticalMarks", - "Greek", - "Cyrillic", - "Armenian", - "Hebrew", - "Arabic", - "Syriac", - "Thaana", - "Devanagari", - "Bengali", - "Gurmukhi", - "Gujarati", - "Oriya", - "Tamil", - "Telugu", - "Kannada", - "Malayalam", - "Sinhala", - "Thai", - "Lao", - "Tibetan", - "Myanmar", - "Georgian", - "HangulJamo", - "Ethiopic", - "Cherokee", - "UnifiedCanadianAboriginalSyllabics", - "Ogham", - "Runic", - "Khmer", - "Mongolian", - "LatinExtendedAdditional", - "GreekExtended", - "GeneralPunctuation", - "SuperscriptsandSubscripts", - "CurrencySymbols", - "CombiningMarksforSymbols", - "LetterlikeSymbols", - "NumberForms", - "Arrows", - "MathematicalOperators", - "MiscellaneousTechnical", - "ControlPictures", - "OpticalCharacterRecognition", - "EnclosedAlphanumerics", - "BoxDrawing", - "BlockElements", - "GeometricShapes", - "MiscellaneousSymbols", - "Dingbats", - "BraillePatterns", - "CJKRadicalsSupplement", - "KangxiRadicals", - "IdeographicDescriptionCharacters", - "CJKSymbolsandPunctuation", - "Hiragana", - "Katakana", - "Bopomofo", - "HangulCompatibilityJamo", - "Kanbun", - "BopomofoExtended", - "EnclosedCJKLettersandMonths", - "CJKCompatibility", - "CJKUnifiedIdeographsExtensionA", - "CJKUnifiedIdeographs", - "YiSyllables", - "YiRadicals", - "HangulSyllables", - // surrogates excluded because there are never any *characters* with codes in surrogate range - // "PrivateUse", excluded because 3.1 adds non-BMP ranges - "CJKCompatibilityIdeographs", - "AlphabeticPresentationForms", - "ArabicPresentationForms-A", - "CombiningHalfMarks", - "CJKCompatibilityForms", - "SmallFormVariants", - "ArabicPresentationForms-B", - "Specials", - "HalfwidthandFullwidthForms", - "Specials" - }; - - - /** - * Names of blocks including ranges outside the BMP. - */ - public static final String[] specialBlockNames = { - "OldItalic", // TODO: these have disappeared from Schema 1.0 2nd edition, but are largely back in 1.1 - "Gothic", - "Deseret", - "ByzantineMusicalSymbols", - "MusicalSymbols", - "MathematicalAlphanumericSymbols", - "CJKUnifiedIdeographsExtensionB", - "CJKCompatibilityIdeographsSupplement", - "Tags", - "PrivateUse", - "HighSurrogates", - "HighPrivateUseSurrogates", - "LowSurrogates", - }; - -// This file was automatically generated by CategoriesGen - - public static final String CATEGORY_NAMES = "NoLoMnCfLlNlPoLuMcNdSoSmCo"; - - public static final int[][] CATEGORY_RANGES = { - { - // No - 0x10107, 0x10133, - 0x10320, 0x10323 - }, - { - // Lo - 0x10000, 0x1000b, - 0x1000d, 0x10026, - 0x10028, 0x1003a, - 0x1003c, 0x1003d, - 0x1003f, 0x1004d, - 0x10050, 0x1005d, - 0x10080, 0x100fa, - 0x10300, 0x1031e, - 0x10330, 0x10349, - 0x10380, 0x1039d, - 0x10450, 0x1049d, - 0x10800, 0x10805, - 0x10808, 0x10808, - 0x1080a, 0x10835, - 0x10837, 0x10838, - 0x1083c, 0x1083c, - 0x1083f, 0x1083f, - 0x20000, 0x2a6d6, - 0x2f800, 0x2fa1d - }, - { - // Mn - 0x1d167, 0x1d169, - 0x1d17b, 0x1d182, - 0x1d185, 0x1d18b, - 0x1d1aa, 0x1d1ad, - 0xe0100, 0xe01ef - }, - { - // Cf - 0x1d173, 0x1d17a, - 0xe0001, 0xe0001, - 0xe0020, 0xe007f - }, - { - // Ll - 0x10428, 0x1044f, - 0x1d41a, 0x1d433, - 0x1d44e, 0x1d454, - 0x1d456, 0x1d467, - 0x1d482, 0x1d49b, - 0x1d4b6, 0x1d4b9, - 0x1d4bb, 0x1d4bb, - 0x1d4bd, 0x1d4c3, - 0x1d4c5, 0x1d4cf, - 0x1d4ea, 0x1d503, - 0x1d51e, 0x1d537, - 0x1d552, 0x1d56b, - 0x1d586, 0x1d59f, - 0x1d5ba, 0x1d5d3, - 0x1d5ee, 0x1d607, - 0x1d622, 0x1d63b, - 0x1d656, 0x1d66f, - 0x1d68a, 0x1d6a3, - 0x1d6c2, 0x1d6da, - 0x1d6dc, 0x1d6e1, - 0x1d6fc, 0x1d714, - 0x1d716, 0x1d71b, - 0x1d736, 0x1d74e, - 0x1d750, 0x1d755, - 0x1d770, 0x1d788, - 0x1d78a, 0x1d78f, - 0x1d7aa, 0x1d7c2, - 0x1d7c4, 0x1d7c9 - }, - { - // Nl - 0x1034a, 0x1034a - }, - { - // Po - 0x10100, 0x10101, - 0x1039f, 0x1039f - }, - { - // Lu - 0x10400, 0x10427, - 0x1d400, 0x1d419, - 0x1d434, 0x1d44d, - 0x1d468, 0x1d481, - 0x1d49c, 0x1d49c, - 0x1d49e, 0x1d49f, - 0x1d4a2, 0x1d4a2, - 0x1d4a5, 0x1d4a6, - 0x1d4a9, 0x1d4ac, - 0x1d4ae, 0x1d4b5, - 0x1d4d0, 0x1d4e9, - 0x1d504, 0x1d505, - 0x1d507, 0x1d50a, - 0x1d50d, 0x1d514, - 0x1d516, 0x1d51c, - 0x1d538, 0x1d539, - 0x1d53b, 0x1d53e, - 0x1d540, 0x1d544, - 0x1d546, 0x1d546, - 0x1d54a, 0x1d550, - 0x1d56c, 0x1d585, - 0x1d5a0, 0x1d5b9, - 0x1d5d4, 0x1d5ed, - 0x1d608, 0x1d621, - 0x1d63c, 0x1d655, - 0x1d670, 0x1d689, - 0x1d6a8, 0x1d6c0, - 0x1d6e2, 0x1d6fa, - 0x1d71c, 0x1d734, - 0x1d756, 0x1d76e, - 0x1d790, 0x1d7a8 - }, - { - // Mc - 0x1d165, 0x1d166, - 0x1d16d, 0x1d172 - }, - { - // Nd - 0x104a0, 0x104a9, - 0x1d7ce, 0x1d7ff - }, - { - // So - 0x10102, 0x10102, - 0x10137, 0x1013f, - 0x1d000, 0x1d0f5, - 0x1d100, 0x1d126, - 0x1d12a, 0x1d164, - 0x1d16a, 0x1d16c, - 0x1d183, 0x1d184, - 0x1d18c, 0x1d1a9, - 0x1d1ae, 0x1d1dd, - 0x1d300, 0x1d356 - }, - { - // Sm - 0x1d6c1, 0x1d6c1, - 0x1d6db, 0x1d6db, - 0x1d6fb, 0x1d6fb, - 0x1d715, 0x1d715, - 0x1d735, 0x1d735, - 0x1d74f, 0x1d74f, - 0x1d76f, 0x1d76f, - 0x1d789, 0x1d789, - 0x1d7a9, 0x1d7a9, - 0x1d7c3, 0x1d7c3 - }, - { - // Co - 0xf0000, 0xffffd, - 0x100000, 0x10fffd - } - }; - - // end of generated code - -// This file was automatically generated by NamingExceptionsGen -// class NamingExceptions { - -// public static final String NMSTRT_INCLUDES = -// "\u003A\u005F\u02BB\u02BC\u02BD\u02BE\u02BF\u02C0\u02C1\u0559" + -// "\u06E5\u06E6\u212E"; -// public static final String NMSTRT_EXCLUDE_RANGES = -// "\u00AA\u00BA\u0132\u0133\u013F\u0140\u0149\u0149\u017F\u017F" + -// "\u01C4\u01CC\u01F1\u01F3\u01F6\u01F9\u0218\u0233\u02A9\u02AD" + -// "\u03D7\u03D7\u03DB\u03DB\u03DD\u03DD\u03DF\u03DF\u03E1\u03E1" + -// "\u0400\u0400\u040D\u040D\u0450\u0450\u045D\u045D\u048C\u048F" + -// "\u04EC\u04ED\u0587\u0587\u06B8\u06B9\u06BF\u06BF\u06CF\u06CF" + -// "\u06FA\u07A5\u0950\u0950\u0AD0\u0AD0\u0D85\u0DC6\u0E2F\u0E2F" + -// "\u0EAF\u0EAF\u0EDC\u0F00\u0F6A\u1055\u1101\u1101\u1104\u1104" + -// "\u1108\u1108\u110A\u110A\u110D\u110D\u1113\u113B\u113D\u113D" + -// "\u113F\u113F\u1141\u114B\u114D\u114D\u114F\u114F\u1151\u1153" + -// "\u1156\u1158\u1162\u1162\u1164\u1164\u1166\u1166\u1168\u1168" + -// "\u116A\u116C\u116F\u1171\u1174\u1174\u1176\u119D\u119F\u11A2" + -// "\u11A9\u11AA\u11AC\u11AD\u11B0\u11B6\u11B9\u11B9\u11BB\u11BB" + -// "\u11C3\u11EA\u11EC\u11EF\u11F1\u11F8\u1200\u18A8\u207F\u2124" + -// "\u2128\u2128\u212C\u212D\u212F\u217F\u2183\u3006\u3038\u303A" + -// "\u3131\u4DB5\uA000\uA48C\uF900\uFFDC"; -// public static final String NMSTRT_CATEGORIES = "LlLuLoLtNl"; -// public static final String NMCHAR_INCLUDES = -// "\u002D\u002E\u003A\u005F\u00B7\u0387\u06dd\u212E"; // MHK: added 06dd -// public static final String NMCHAR_EXCLUDE_RANGES = -// "\u00AA\u00B5\u00BA\u00BA\u0132\u0133\u013F\u0140\u0149\u0149" + -// "\u017F\u017F\u01C4\u01CC\u01F1\u01F3\u01F6\u01F9\u0218\u0233" + -// "\u02A9\u02B8\u02E0\u02EE\u0346\u034E\u0362\u037A\u03D7\u03D7" + -// "\u03DB\u03DB\u03DD\u03DD\u03DF\u03DF\u03E1\u03E1\u0400\u0400" + -// "\u040D\u040D\u0450\u0450\u045D\u045D\u0488\u048F\u04EC\u04ED" + -// "\u0587\u0587\u0653\u0655\u06B8\u06B9\u06BF\u06BF\u06CF\u06CF" + -// "\u06FA\u07B0\u0950\u0950\u0AD0\u0AD0\u0D82\u0DF3\u0E2F\u0E2F" + -// "\u0EAF\u0EAF\u0EDC\u0F00\u0F6A\u0F6A\u0F96\u0F96\u0FAE\u0FB0" + -// "\u0FB8\u0FB8\u0FBA\u1059\u1101\u1101\u1104\u1104\u1108\u1108" + -// "\u110A\u110A\u110D\u110D\u1113\u113B\u113D\u113D\u113F\u113F" + -// "\u1141\u114B\u114D\u114D\u114F\u114F\u1151\u1153\u1156\u1158" + -// "\u1162\u1162\u1164\u1164\u1166\u1166\u1168\u1168\u116A\u116C" + -// "\u116F\u1171\u1174\u1174\u1176\u119D\u119F\u11A2\u11A9\u11AA" + -// "\u11AC\u11AD\u11B0\u11B6\u11B9\u11B9\u11BB\u11BB\u11C3\u11EA" + -// "\u11EC\u11EF\u11F1\u11F8\u1200\u18A9\u207F\u207F\u20DD\u20E0" + -// "\u20E2\u2124\u2128\u2128\u212C\u212D\u212F\u217F\u2183\u2183" + -// "\u3006\u3006\u3038\u303A\u3131\u4DB5\uA000\uA48C\uF900\uFFDC"; -// public static final String NMCHAR_CATEGORIES = "LlLuLoLtNlMcMeMnLmNd"; -// end of generated code - - public static final char UNICODE_3_1_ADD_Lu = '\u03F4'; // added in 3.1 - public static final char UNICODE_3_1_ADD_Ll = '\u03F5'; // added in 3.1 - // 3 characters changed from No to Nl between 3.0 and 3.1 - public static final char UNICODE_3_1_CHANGE_No_to_Nl_MIN = '\u16EE'; - public static final char UNICODE_3_1_CHANGE_No_to_Nl_MAX = '\u16F0'; - public static final String CATEGORY_Pi = "\u00AB\u2018\u201B\u201C\u201F\u2039"; // Java doesn't know about category Pi - public static final String CATEGORY_Pf = "\u00BB\u2019\u201D\u203A"; // Java doesn't know about category Pf - -} - -// -// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License"); -// you may not use this file except in compliance with the License. You may obtain a copy of the -// License at http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" basis, -// WITHOUT WARRANTY OF ANY KIND, either express or implied. -// See the License for the specific language governing rights and limitations under the License. -// -// The Original Code is: all this file -// -// The Initial Developer of the Original Code is Michael H. Kay. -// -// Contributor(s): -// - +package org.exist.xquery.regex; + +/** + * Non-instantiable class containing constant data definitions used by the various Regular Expression translators + * + * Copied from Saxon-HE 9.2 package net.sf.saxon.regex without change. + */ +public class RegexData { + + public static final String categories = "LMNPZSC"; + public static final String subCategories = "LuLlLtLmLoMnMcMeNdNlNoPcPdPsPePiPfPoZsZlZpSmScSkSoCcCfCoCn"; + + public static final char EOS = '\0'; + + + public static final String[] blockNames = { + "BasicLatin", + "Latin-1Supplement", + "LatinExtended-A", + "LatinExtended-B", + "IPAExtensions", + "SpacingModifierLetters", + "CombiningDiacriticalMarks", + "Greek", + "Cyrillic", + "Armenian", + "Hebrew", + "Arabic", + "Syriac", + "Thaana", + "Devanagari", + "Bengali", + "Gurmukhi", + "Gujarati", + "Oriya", + "Tamil", + "Telugu", + "Kannada", + "Malayalam", + "Sinhala", + "Thai", + "Lao", + "Tibetan", + "Myanmar", + "Georgian", + "HangulJamo", + "Ethiopic", + "Cherokee", + "UnifiedCanadianAboriginalSyllabics", + "Ogham", + "Runic", + "Khmer", + "Mongolian", + "LatinExtendedAdditional", + "GreekExtended", + "GeneralPunctuation", + "SuperscriptsandSubscripts", + "CurrencySymbols", + "CombiningMarksforSymbols", + "LetterlikeSymbols", + "NumberForms", + "Arrows", + "MathematicalOperators", + "MiscellaneousTechnical", + "ControlPictures", + "OpticalCharacterRecognition", + "EnclosedAlphanumerics", + "BoxDrawing", + "BlockElements", + "GeometricShapes", + "MiscellaneousSymbols", + "Dingbats", + "BraillePatterns", + "CJKRadicalsSupplement", + "KangxiRadicals", + "IdeographicDescriptionCharacters", + "CJKSymbolsandPunctuation", + "Hiragana", + "Katakana", + "Bopomofo", + "HangulCompatibilityJamo", + "Kanbun", + "BopomofoExtended", + "EnclosedCJKLettersandMonths", + "CJKCompatibility", + "CJKUnifiedIdeographsExtensionA", + "CJKUnifiedIdeographs", + "YiSyllables", + "YiRadicals", + "HangulSyllables", + // surrogates excluded because there are never any *characters* with codes in surrogate range + // "PrivateUse", excluded because 3.1 adds non-BMP ranges + "CJKCompatibilityIdeographs", + "AlphabeticPresentationForms", + "ArabicPresentationForms-A", + "CombiningHalfMarks", + "CJKCompatibilityForms", + "SmallFormVariants", + "ArabicPresentationForms-B", + "Specials", + "HalfwidthandFullwidthForms", + "Specials" + }; + + + /** + * Names of blocks including ranges outside the BMP. + */ + public static final String[] specialBlockNames = { + "OldItalic", // TODO: these have disappeared from Schema 1.0 2nd edition, but are largely back in 1.1 + "Gothic", + "Deseret", + "ByzantineMusicalSymbols", + "MusicalSymbols", + "MathematicalAlphanumericSymbols", + "CJKUnifiedIdeographsExtensionB", + "CJKCompatibilityIdeographsSupplement", + "Tags", + "PrivateUse", + "HighSurrogates", + "HighPrivateUseSurrogates", + "LowSurrogates", + }; + +// This file was automatically generated by CategoriesGen + + public static final String CATEGORY_NAMES = "NoLoMnCfLlNlPoLuMcNdSoSmCo"; + + public static final int[][] CATEGORY_RANGES = { + { + // No + 0x10107, 0x10133, + 0x10320, 0x10323 + }, + { + // Lo + 0x10000, 0x1000b, + 0x1000d, 0x10026, + 0x10028, 0x1003a, + 0x1003c, 0x1003d, + 0x1003f, 0x1004d, + 0x10050, 0x1005d, + 0x10080, 0x100fa, + 0x10300, 0x1031e, + 0x10330, 0x10349, + 0x10380, 0x1039d, + 0x10450, 0x1049d, + 0x10800, 0x10805, + 0x10808, 0x10808, + 0x1080a, 0x10835, + 0x10837, 0x10838, + 0x1083c, 0x1083c, + 0x1083f, 0x1083f, + 0x20000, 0x2a6d6, + 0x2f800, 0x2fa1d + }, + { + // Mn + 0x1d167, 0x1d169, + 0x1d17b, 0x1d182, + 0x1d185, 0x1d18b, + 0x1d1aa, 0x1d1ad, + 0xe0100, 0xe01ef + }, + { + // Cf + 0x1d173, 0x1d17a, + 0xe0001, 0xe0001, + 0xe0020, 0xe007f + }, + { + // Ll + 0x10428, 0x1044f, + 0x1d41a, 0x1d433, + 0x1d44e, 0x1d454, + 0x1d456, 0x1d467, + 0x1d482, 0x1d49b, + 0x1d4b6, 0x1d4b9, + 0x1d4bb, 0x1d4bb, + 0x1d4bd, 0x1d4c3, + 0x1d4c5, 0x1d4cf, + 0x1d4ea, 0x1d503, + 0x1d51e, 0x1d537, + 0x1d552, 0x1d56b, + 0x1d586, 0x1d59f, + 0x1d5ba, 0x1d5d3, + 0x1d5ee, 0x1d607, + 0x1d622, 0x1d63b, + 0x1d656, 0x1d66f, + 0x1d68a, 0x1d6a3, + 0x1d6c2, 0x1d6da, + 0x1d6dc, 0x1d6e1, + 0x1d6fc, 0x1d714, + 0x1d716, 0x1d71b, + 0x1d736, 0x1d74e, + 0x1d750, 0x1d755, + 0x1d770, 0x1d788, + 0x1d78a, 0x1d78f, + 0x1d7aa, 0x1d7c2, + 0x1d7c4, 0x1d7c9 + }, + { + // Nl + 0x1034a, 0x1034a + }, + { + // Po + 0x10100, 0x10101, + 0x1039f, 0x1039f + }, + { + // Lu + 0x10400, 0x10427, + 0x1d400, 0x1d419, + 0x1d434, 0x1d44d, + 0x1d468, 0x1d481, + 0x1d49c, 0x1d49c, + 0x1d49e, 0x1d49f, + 0x1d4a2, 0x1d4a2, + 0x1d4a5, 0x1d4a6, + 0x1d4a9, 0x1d4ac, + 0x1d4ae, 0x1d4b5, + 0x1d4d0, 0x1d4e9, + 0x1d504, 0x1d505, + 0x1d507, 0x1d50a, + 0x1d50d, 0x1d514, + 0x1d516, 0x1d51c, + 0x1d538, 0x1d539, + 0x1d53b, 0x1d53e, + 0x1d540, 0x1d544, + 0x1d546, 0x1d546, + 0x1d54a, 0x1d550, + 0x1d56c, 0x1d585, + 0x1d5a0, 0x1d5b9, + 0x1d5d4, 0x1d5ed, + 0x1d608, 0x1d621, + 0x1d63c, 0x1d655, + 0x1d670, 0x1d689, + 0x1d6a8, 0x1d6c0, + 0x1d6e2, 0x1d6fa, + 0x1d71c, 0x1d734, + 0x1d756, 0x1d76e, + 0x1d790, 0x1d7a8 + }, + { + // Mc + 0x1d165, 0x1d166, + 0x1d16d, 0x1d172 + }, + { + // Nd + 0x104a0, 0x104a9, + 0x1d7ce, 0x1d7ff + }, + { + // So + 0x10102, 0x10102, + 0x10137, 0x1013f, + 0x1d000, 0x1d0f5, + 0x1d100, 0x1d126, + 0x1d12a, 0x1d164, + 0x1d16a, 0x1d16c, + 0x1d183, 0x1d184, + 0x1d18c, 0x1d1a9, + 0x1d1ae, 0x1d1dd, + 0x1d300, 0x1d356 + }, + { + // Sm + 0x1d6c1, 0x1d6c1, + 0x1d6db, 0x1d6db, + 0x1d6fb, 0x1d6fb, + 0x1d715, 0x1d715, + 0x1d735, 0x1d735, + 0x1d74f, 0x1d74f, + 0x1d76f, 0x1d76f, + 0x1d789, 0x1d789, + 0x1d7a9, 0x1d7a9, + 0x1d7c3, 0x1d7c3 + }, + { + // Co + 0xf0000, 0xffffd, + 0x100000, 0x10fffd + } + }; + + // end of generated code + +// This file was automatically generated by NamingExceptionsGen +// class NamingExceptions { + +// public static final String NMSTRT_INCLUDES = +// "\u003A\u005F\u02BB\u02BC\u02BD\u02BE\u02BF\u02C0\u02C1\u0559" + +// "\u06E5\u06E6\u212E"; +// public static final String NMSTRT_EXCLUDE_RANGES = +// "\u00AA\u00BA\u0132\u0133\u013F\u0140\u0149\u0149\u017F\u017F" + +// "\u01C4\u01CC\u01F1\u01F3\u01F6\u01F9\u0218\u0233\u02A9\u02AD" + +// "\u03D7\u03D7\u03DB\u03DB\u03DD\u03DD\u03DF\u03DF\u03E1\u03E1" + +// "\u0400\u0400\u040D\u040D\u0450\u0450\u045D\u045D\u048C\u048F" + +// "\u04EC\u04ED\u0587\u0587\u06B8\u06B9\u06BF\u06BF\u06CF\u06CF" + +// "\u06FA\u07A5\u0950\u0950\u0AD0\u0AD0\u0D85\u0DC6\u0E2F\u0E2F" + +// "\u0EAF\u0EAF\u0EDC\u0F00\u0F6A\u1055\u1101\u1101\u1104\u1104" + +// "\u1108\u1108\u110A\u110A\u110D\u110D\u1113\u113B\u113D\u113D" + +// "\u113F\u113F\u1141\u114B\u114D\u114D\u114F\u114F\u1151\u1153" + +// "\u1156\u1158\u1162\u1162\u1164\u1164\u1166\u1166\u1168\u1168" + +// "\u116A\u116C\u116F\u1171\u1174\u1174\u1176\u119D\u119F\u11A2" + +// "\u11A9\u11AA\u11AC\u11AD\u11B0\u11B6\u11B9\u11B9\u11BB\u11BB" + +// "\u11C3\u11EA\u11EC\u11EF\u11F1\u11F8\u1200\u18A8\u207F\u2124" + +// "\u2128\u2128\u212C\u212D\u212F\u217F\u2183\u3006\u3038\u303A" + +// "\u3131\u4DB5\uA000\uA48C\uF900\uFFDC"; +// public static final String NMSTRT_CATEGORIES = "LlLuLoLtNl"; +// public static final String NMCHAR_INCLUDES = +// "\u002D\u002E\u003A\u005F\u00B7\u0387\u06dd\u212E"; // MHK: added 06dd +// public static final String NMCHAR_EXCLUDE_RANGES = +// "\u00AA\u00B5\u00BA\u00BA\u0132\u0133\u013F\u0140\u0149\u0149" + +// "\u017F\u017F\u01C4\u01CC\u01F1\u01F3\u01F6\u01F9\u0218\u0233" + +// "\u02A9\u02B8\u02E0\u02EE\u0346\u034E\u0362\u037A\u03D7\u03D7" + +// "\u03DB\u03DB\u03DD\u03DD\u03DF\u03DF\u03E1\u03E1\u0400\u0400" + +// "\u040D\u040D\u0450\u0450\u045D\u045D\u0488\u048F\u04EC\u04ED" + +// "\u0587\u0587\u0653\u0655\u06B8\u06B9\u06BF\u06BF\u06CF\u06CF" + +// "\u06FA\u07B0\u0950\u0950\u0AD0\u0AD0\u0D82\u0DF3\u0E2F\u0E2F" + +// "\u0EAF\u0EAF\u0EDC\u0F00\u0F6A\u0F6A\u0F96\u0F96\u0FAE\u0FB0" + +// "\u0FB8\u0FB8\u0FBA\u1059\u1101\u1101\u1104\u1104\u1108\u1108" + +// "\u110A\u110A\u110D\u110D\u1113\u113B\u113D\u113D\u113F\u113F" + +// "\u1141\u114B\u114D\u114D\u114F\u114F\u1151\u1153\u1156\u1158" + +// "\u1162\u1162\u1164\u1164\u1166\u1166\u1168\u1168\u116A\u116C" + +// "\u116F\u1171\u1174\u1174\u1176\u119D\u119F\u11A2\u11A9\u11AA" + +// "\u11AC\u11AD\u11B0\u11B6\u11B9\u11B9\u11BB\u11BB\u11C3\u11EA" + +// "\u11EC\u11EF\u11F1\u11F8\u1200\u18A9\u207F\u207F\u20DD\u20E0" + +// "\u20E2\u2124\u2128\u2128\u212C\u212D\u212F\u217F\u2183\u2183" + +// "\u3006\u3006\u3038\u303A\u3131\u4DB5\uA000\uA48C\uF900\uFFDC"; +// public static final String NMCHAR_CATEGORIES = "LlLuLoLtNlMcMeMnLmNd"; +// end of generated code + + public static final char UNICODE_3_1_ADD_Lu = '\u03F4'; // added in 3.1 + public static final char UNICODE_3_1_ADD_Ll = '\u03F5'; // added in 3.1 + // 3 characters changed from No to Nl between 3.0 and 3.1 + public static final char UNICODE_3_1_CHANGE_No_to_Nl_MIN = '\u16EE'; + public static final char UNICODE_3_1_CHANGE_No_to_Nl_MAX = '\u16F0'; + public static final String CATEGORY_Pi = "\u00AB\u2018\u201B\u201C\u201F\u2039"; // Java doesn't know about category Pi + public static final String CATEGORY_Pf = "\u00BB\u2019\u201D\u203A"; // Java doesn't know about category Pf + +} + +// +// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License"); +// you may not use this file except in compliance with the License. You may obtain a copy of the +// License at http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" basis, +// WITHOUT WARRANTY OF ANY KIND, either express or implied. +// See the License for the specific language governing rights and limitations under the License. +// +// The Original Code is: all this file +// +// The Initial Developer of the Original Code is Michael H. Kay. +// +// Contributor(s): +// + diff --git a/src/org/exist/xquery/regex/RegexSyntaxException.java b/src/org/exist/xquery/regex/RegexSyntaxException.java index d9234d094df..b943ee4f636 100644 --- a/src/org/exist/xquery/regex/RegexSyntaxException.java +++ b/src/org/exist/xquery/regex/RegexSyntaxException.java @@ -1,53 +1,53 @@ -package org.exist.xquery.regex; - -/** - * Thrown when an syntactically incorrect regular expression is detected. - * - * Copied from Saxon-HE 9.2 package net.sf.saxon.regex without change. - */ -public class RegexSyntaxException extends Exception { - private final int position; - - /** - * Represents an unknown position within a string containing a regular expression. - */ - public static final int UNKNOWN_POSITION = -1; - - public RegexSyntaxException(String detail) { - this(detail, UNKNOWN_POSITION); - } - - public RegexSyntaxException(String detail, int position) { - super(detail); - this.position = position; - } - - /** - * Returns the index into the regular expression where the error was detected - * or UNKNOWN_POSITION if this is unknown. - * - * @return the index into the regular expression where the error was detected, - * or UNKNOWNN_POSITION if this is unknown - */ - public int getPosition() { - return position; - } -} - -// -// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License"); -// you may not use this file except in compliance with the License. You may obtain a copy of the -// License at http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" basis, -// WITHOUT WARRANTY OF ANY KIND, either express or implied. -// See the License for the specific language governing rights and limitations under the License. -// -// The Original Code is: all this file. -// -// The Initial Developer of the Original Code is Michael H. Kay -// -// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved. -// -// Contributor(s): none. -// +package org.exist.xquery.regex; + +/** + * Thrown when an syntactically incorrect regular expression is detected. + * + * Copied from Saxon-HE 9.2 package net.sf.saxon.regex without change. + */ +public class RegexSyntaxException extends Exception { + private final int position; + + /** + * Represents an unknown position within a string containing a regular expression. + */ + public static final int UNKNOWN_POSITION = -1; + + public RegexSyntaxException(String detail) { + this(detail, UNKNOWN_POSITION); + } + + public RegexSyntaxException(String detail, int position) { + super(detail); + this.position = position; + } + + /** + * Returns the index into the regular expression where the error was detected + * or UNKNOWN_POSITION if this is unknown. + * + * @return the index into the regular expression where the error was detected, + * or UNKNOWNN_POSITION if this is unknown + */ + public int getPosition() { + return position; + } +} + +// +// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License"); +// you may not use this file except in compliance with the License. You may obtain a copy of the +// License at http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" basis, +// WITHOUT WARRANTY OF ANY KIND, either express or implied. +// See the License for the specific language governing rights and limitations under the License. +// +// The Original Code is: all this file. +// +// The Initial Developer of the Original Code is Michael H. Kay +// +// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved. +// +// Contributor(s): none. +// diff --git a/src/org/exist/xquery/regex/XMLCharacterData.java b/src/org/exist/xquery/regex/XMLCharacterData.java index 1f7d55d4983..4419a54918d 100644 --- a/src/org/exist/xquery/regex/XMLCharacterData.java +++ b/src/org/exist/xquery/regex/XMLCharacterData.java @@ -1,785 +1,785 @@ -package org.exist.xquery.regex; - -import java.util.Arrays; - -import org.exist.util.UTF16CharacterSet; - -/** - * This module contains data regarding the classification of characters in XML 1.0 and XML 1.1, and a number - * of interrogative methods to support queries on this data. - * - * For characters in the BMP, the information is tabulated by means of an array of one-byte entries, - * one for each character, with bit-significant property settings. For characters outside the BMP, the - * rules are built in to the interrogative methods. - * - * Copied from Saxon-HE 9.2 package net.sf.saxon.regex. - */ -public class XMLCharacterData { - - private final static byte[] data = new byte[65536]; - - /** - * Bit setting to indicate that a character is valid in XML 1.0 - */ - public final static byte VALID_10_MASK = 1; - /** - * Bit setting to indicate that a character is valid in an XML 1.0 name - */ - public final static byte NAME_10_MASK = 2; - /** - * Bit setting to indicate that a character is valid at the start of an XML 1.0 name - */ - public final static byte NAME_START_10_MASK = 4; - /** - * Bit setting to indicate that a character is valid in XML 1.1 - */ - public final static byte VALID_11_MASK = 8; - /** - * Bit setting to indicate that a character is valid in an XML 1.1 name - */ - public final static byte NAME_11_MASK = 16; - /** - * Bit setting to indicate that a character is valid at the start of an XML 1.1 name - */ - public final static byte NAME_START_11_MASK = 32; - /** - * Maximum code point for a character permitted in an XML 1.1 name - */ - public final static int MAX_XML11_NAME_CHAR = 0xEFFFF; - - /** - * Determine whether a character is valid in XML 1.0 - * @param i the character - * @return true if the character is valid in XML 1.0 - */ - - public static boolean isValid10(int i) { - return i < 65536 ? (data[i]&VALID_10_MASK) != 0 : (UTF16CharacterSet.NONBMP_MIN <= i && i <= UTF16CharacterSet.NONBMP_MAX); - } - - /** - * Determine whether a character is valid in an NCName in XML 1.0 - * @param i the character - * @return true if the character is valid in an NCName in XML 1.0 - */ - - public static boolean isNCName10(int i) { - return i < 65536 && (data[i]&NAME_10_MASK) != 0; - } - - /** - * Determine whether a character is valid at the start of an NCName in XML 1.0 - * @param i the character - * @return true if the character is valid at the start of an NCName in XML 1.0 - */ - - public static boolean isNCNameStart10(int i) { - return i < 65536 && (data[i]&NAME_START_10_MASK) != 0; - } - - /** - * Determine whether a character is valid in XML 1.1 - * @param i the character - * @return true if the character is valid in XML 1.1 - */ - - public static boolean isValid11(int i) { - return i < 65536 ? (data[i]&VALID_11_MASK) != 0 : (UTF16CharacterSet.NONBMP_MIN <= i && i <= UTF16CharacterSet.NONBMP_MAX); - } - - /** - * Determine whether a character is valid in an NCName in XML 1.1 - * @param i the character - * @return true if the character is valid in an NCName in XML 1.1 - */ - - public static boolean isNCName11(int i) { - return i < 65536 ? (data[i]&NAME_11_MASK) != 0 : (UTF16CharacterSet.NONBMP_MIN <= i && i <= MAX_XML11_NAME_CHAR); - } - - /** - * Determine whether a character is valid at the start of an NCName in XML 1.1 - * @param i the character - * @return true if the character is valid at the start of an NCName in XML 1.1 - */ - - public static boolean isNCNameStart11(int i) { - return i < 65536 ? (data[i]&NAME_START_11_MASK) != 0 : (UTF16CharacterSet.NONBMP_MIN <= i && i <= MAX_XML11_NAME_CHAR); - } - - /** - * Static code to initialize the data table - */ - - static { - data[0] = (byte)0; - Arrays.fill(data, 1, 9, (byte)8); - Arrays.fill(data, 9, 11, (byte)9); - Arrays.fill(data, 11, 13, (byte)8); - data[13] = (byte)9; - Arrays.fill(data, 14, 32, (byte)8); - Arrays.fill(data, 32, 45, (byte)9); - Arrays.fill(data, 45, 47, (byte)27); - data[47] = (byte)9; - Arrays.fill(data, 48, 58, (byte)27); - data[58] = (byte)9; // colon - Arrays.fill(data, 59, 65, (byte)9); - Arrays.fill(data, 65, 91, (byte)63); - Arrays.fill(data, 91, 95, (byte)9); - data[95] = (byte)63; - data[96] = (byte)9; - Arrays.fill(data, 97, 123, (byte)63); - Arrays.fill(data, 123, 183, (byte)9); - data[183] = (byte)27; - Arrays.fill(data, 184, 192, (byte)9); - Arrays.fill(data, 192, 215, (byte)63); - data[215] = (byte)9; - Arrays.fill(data, 216, 247, (byte)63); - data[247] = (byte)9; - Arrays.fill(data, 248, 306, (byte)63); - Arrays.fill(data, 306, 308, (byte)57); - Arrays.fill(data, 308, 319, (byte)63); - Arrays.fill(data, 319, 321, (byte)57); - Arrays.fill(data, 321, 329, (byte)63); - data[329] = (byte)57; - Arrays.fill(data, 330, 383, (byte)63); - data[383] = (byte)57; - Arrays.fill(data, 384, 452, (byte)63); - Arrays.fill(data, 452, 461, (byte)57); - Arrays.fill(data, 461, 497, (byte)63); - Arrays.fill(data, 497, 500, (byte)57); - Arrays.fill(data, 500, 502, (byte)63); - Arrays.fill(data, 502, 506, (byte)57); - Arrays.fill(data, 506, 536, (byte)63); - Arrays.fill(data, 536, 592, (byte)57); - Arrays.fill(data, 592, 681, (byte)63); - Arrays.fill(data, 681, 699, (byte)57); - Arrays.fill(data, 699, 706, (byte)63); - Arrays.fill(data, 706, 720, (byte)57); - Arrays.fill(data, 720, 722, (byte)59); - Arrays.fill(data, 722, 768, (byte)57); - Arrays.fill(data, 768, 838, (byte)27); - Arrays.fill(data, 838, 864, (byte)25); - Arrays.fill(data, 864, 866, (byte)27); - Arrays.fill(data, 866, 880, (byte)25); - Arrays.fill(data, 880, 894, (byte)57); - data[894] = (byte)9; - Arrays.fill(data, 895, 902, (byte)57); - data[902] = (byte)63; - data[903] = (byte)59; - Arrays.fill(data, 904, 907, (byte)63); - data[907] = (byte)57; - data[908] = (byte)63; - data[909] = (byte)57; - Arrays.fill(data, 910, 930, (byte)63); - data[930] = (byte)57; - Arrays.fill(data, 931, 975, (byte)63); - data[975] = (byte)57; - Arrays.fill(data, 976, 983, (byte)63); - Arrays.fill(data, 983, 986, (byte)57); - data[986] = (byte)63; - data[987] = (byte)57; - data[988] = (byte)63; - data[989] = (byte)57; - data[990] = (byte)63; - data[991] = (byte)57; - data[992] = (byte)63; - data[993] = (byte)57; - Arrays.fill(data, 994, 1012, (byte)63); - Arrays.fill(data, 1012, 1025, (byte)57); - Arrays.fill(data, 1025, 1037, (byte)63); - data[1037] = (byte)57; - Arrays.fill(data, 1038, 1104, (byte)63); - data[1104] = (byte)57; - Arrays.fill(data, 1105, 1117, (byte)63); - data[1117] = (byte)57; - Arrays.fill(data, 1118, 1154, (byte)63); - data[1154] = (byte)57; - Arrays.fill(data, 1155, 1159, (byte)59); - Arrays.fill(data, 1159, 1168, (byte)57); - Arrays.fill(data, 1168, 1221, (byte)63); - Arrays.fill(data, 1221, 1223, (byte)57); - Arrays.fill(data, 1223, 1225, (byte)63); - Arrays.fill(data, 1225, 1227, (byte)57); - Arrays.fill(data, 1227, 1229, (byte)63); - Arrays.fill(data, 1229, 1232, (byte)57); - Arrays.fill(data, 1232, 1260, (byte)63); - Arrays.fill(data, 1260, 1262, (byte)57); - Arrays.fill(data, 1262, 1270, (byte)63); - Arrays.fill(data, 1270, 1272, (byte)57); - Arrays.fill(data, 1272, 1274, (byte)63); - Arrays.fill(data, 1274, 1329, (byte)57); - Arrays.fill(data, 1329, 1367, (byte)63); - Arrays.fill(data, 1367, 1369, (byte)57); - data[1369] = (byte)63; - Arrays.fill(data, 1370, 1377, (byte)57); - Arrays.fill(data, 1377, 1415, (byte)63); - Arrays.fill(data, 1415, 1425, (byte)57); - Arrays.fill(data, 1425, 1442, (byte)59); - data[1442] = (byte)57; - Arrays.fill(data, 1443, 1466, (byte)59); - data[1466] = (byte)57; - Arrays.fill(data, 1467, 1470, (byte)59); - data[1470] = (byte)57; - data[1471] = (byte)59; - data[1472] = (byte)57; - Arrays.fill(data, 1473, 1475, (byte)59); - data[1475] = (byte)57; - data[1476] = (byte)59; - Arrays.fill(data, 1477, 1488, (byte)57); - Arrays.fill(data, 1488, 1515, (byte)63); - Arrays.fill(data, 1515, 1520, (byte)57); - Arrays.fill(data, 1520, 1523, (byte)63); - Arrays.fill(data, 1523, 1569, (byte)57); - Arrays.fill(data, 1569, 1595, (byte)63); - Arrays.fill(data, 1595, 1600, (byte)57); - data[1600] = (byte)59; - Arrays.fill(data, 1601, 1611, (byte)63); - Arrays.fill(data, 1611, 1619, (byte)59); - Arrays.fill(data, 1619, 1632, (byte)57); - Arrays.fill(data, 1632, 1642, (byte)59); - Arrays.fill(data, 1642, 1648, (byte)57); - data[1648] = (byte)59; - Arrays.fill(data, 1649, 1720, (byte)63); - Arrays.fill(data, 1720, 1722, (byte)57); - Arrays.fill(data, 1722, 1727, (byte)63); - data[1727] = (byte)57; - Arrays.fill(data, 1728, 1743, (byte)63); - data[1743] = (byte)57; - Arrays.fill(data, 1744, 1748, (byte)63); - data[1748] = (byte)57; - data[1749] = (byte)63; - Arrays.fill(data, 1750, 1765, (byte)59); - Arrays.fill(data, 1765, 1767, (byte)63); - Arrays.fill(data, 1767, 1769, (byte)59); - data[1769] = (byte)57; - Arrays.fill(data, 1770, 1774, (byte)59); - Arrays.fill(data, 1774, 1776, (byte)57); - Arrays.fill(data, 1776, 1786, (byte)59); - Arrays.fill(data, 1786, 2305, (byte)57); - Arrays.fill(data, 2305, 2308, (byte)59); - data[2308] = (byte)57; - Arrays.fill(data, 2309, 2362, (byte)63); - Arrays.fill(data, 2362, 2364, (byte)57); - data[2364] = (byte)59; - data[2365] = (byte)63; - Arrays.fill(data, 2366, 2382, (byte)59); - Arrays.fill(data, 2382, 2385, (byte)57); - Arrays.fill(data, 2385, 2389, (byte)59); - Arrays.fill(data, 2389, 2392, (byte)57); - Arrays.fill(data, 2392, 2402, (byte)63); - Arrays.fill(data, 2402, 2404, (byte)59); - Arrays.fill(data, 2404, 2406, (byte)57); - Arrays.fill(data, 2406, 2416, (byte)59); - Arrays.fill(data, 2416, 2433, (byte)57); - Arrays.fill(data, 2433, 2436, (byte)59); - data[2436] = (byte)57; - Arrays.fill(data, 2437, 2445, (byte)63); - Arrays.fill(data, 2445, 2447, (byte)57); - Arrays.fill(data, 2447, 2449, (byte)63); - Arrays.fill(data, 2449, 2451, (byte)57); - Arrays.fill(data, 2451, 2473, (byte)63); - data[2473] = (byte)57; - Arrays.fill(data, 2474, 2481, (byte)63); - data[2481] = (byte)57; - data[2482] = (byte)63; - Arrays.fill(data, 2483, 2486, (byte)57); - Arrays.fill(data, 2486, 2490, (byte)63); - Arrays.fill(data, 2490, 2492, (byte)57); - data[2492] = (byte)59; - data[2493] = (byte)57; - Arrays.fill(data, 2494, 2501, (byte)59); - Arrays.fill(data, 2501, 2503, (byte)57); - Arrays.fill(data, 2503, 2505, (byte)59); - Arrays.fill(data, 2505, 2507, (byte)57); - Arrays.fill(data, 2507, 2510, (byte)59); - Arrays.fill(data, 2510, 2519, (byte)57); - data[2519] = (byte)59; - Arrays.fill(data, 2520, 2524, (byte)57); - Arrays.fill(data, 2524, 2526, (byte)63); - data[2526] = (byte)57; - Arrays.fill(data, 2527, 2530, (byte)63); - Arrays.fill(data, 2530, 2532, (byte)59); - Arrays.fill(data, 2532, 2534, (byte)57); - Arrays.fill(data, 2534, 2544, (byte)59); - Arrays.fill(data, 2544, 2546, (byte)63); - Arrays.fill(data, 2546, 2562, (byte)57); - data[2562] = (byte)59; - Arrays.fill(data, 2563, 2565, (byte)57); - Arrays.fill(data, 2565, 2571, (byte)63); - Arrays.fill(data, 2571, 2575, (byte)57); - Arrays.fill(data, 2575, 2577, (byte)63); - Arrays.fill(data, 2577, 2579, (byte)57); - Arrays.fill(data, 2579, 2601, (byte)63); - data[2601] = (byte)57; - Arrays.fill(data, 2602, 2609, (byte)63); - data[2609] = (byte)57; - Arrays.fill(data, 2610, 2612, (byte)63); - data[2612] = (byte)57; - Arrays.fill(data, 2613, 2615, (byte)63); - data[2615] = (byte)57; - Arrays.fill(data, 2616, 2618, (byte)63); - Arrays.fill(data, 2618, 2620, (byte)57); - data[2620] = (byte)59; - data[2621] = (byte)57; - Arrays.fill(data, 2622, 2627, (byte)59); - Arrays.fill(data, 2627, 2631, (byte)57); - Arrays.fill(data, 2631, 2633, (byte)59); - Arrays.fill(data, 2633, 2635, (byte)57); - Arrays.fill(data, 2635, 2638, (byte)59); - Arrays.fill(data, 2638, 2649, (byte)57); - Arrays.fill(data, 2649, 2653, (byte)63); - data[2653] = (byte)57; - data[2654] = (byte)63; - Arrays.fill(data, 2655, 2662, (byte)57); - Arrays.fill(data, 2662, 2674, (byte)59); - Arrays.fill(data, 2674, 2677, (byte)63); - Arrays.fill(data, 2677, 2689, (byte)57); - Arrays.fill(data, 2689, 2692, (byte)59); - data[2692] = (byte)57; - Arrays.fill(data, 2693, 2700, (byte)63); - data[2700] = (byte)57; - data[2701] = (byte)63; - data[2702] = (byte)57; - Arrays.fill(data, 2703, 2706, (byte)63); - data[2706] = (byte)57; - Arrays.fill(data, 2707, 2729, (byte)63); - data[2729] = (byte)57; - Arrays.fill(data, 2730, 2737, (byte)63); - data[2737] = (byte)57; - Arrays.fill(data, 2738, 2740, (byte)63); - data[2740] = (byte)57; - Arrays.fill(data, 2741, 2746, (byte)63); - Arrays.fill(data, 2746, 2748, (byte)57); - data[2748] = (byte)59; - data[2749] = (byte)63; - Arrays.fill(data, 2750, 2758, (byte)59); - data[2758] = (byte)57; - Arrays.fill(data, 2759, 2762, (byte)59); - data[2762] = (byte)57; - Arrays.fill(data, 2763, 2766, (byte)59); - Arrays.fill(data, 2766, 2784, (byte)57); - data[2784] = (byte)63; - Arrays.fill(data, 2785, 2790, (byte)57); - Arrays.fill(data, 2790, 2800, (byte)59); - Arrays.fill(data, 2800, 2817, (byte)57); - Arrays.fill(data, 2817, 2820, (byte)59); - data[2820] = (byte)57; - Arrays.fill(data, 2821, 2829, (byte)63); - Arrays.fill(data, 2829, 2831, (byte)57); - Arrays.fill(data, 2831, 2833, (byte)63); - Arrays.fill(data, 2833, 2835, (byte)57); - Arrays.fill(data, 2835, 2857, (byte)63); - data[2857] = (byte)57; - Arrays.fill(data, 2858, 2865, (byte)63); - data[2865] = (byte)57; - Arrays.fill(data, 2866, 2868, (byte)63); - Arrays.fill(data, 2868, 2870, (byte)57); - Arrays.fill(data, 2870, 2874, (byte)63); - Arrays.fill(data, 2874, 2876, (byte)57); - data[2876] = (byte)59; - data[2877] = (byte)63; - Arrays.fill(data, 2878, 2884, (byte)59); - Arrays.fill(data, 2884, 2887, (byte)57); - Arrays.fill(data, 2887, 2889, (byte)59); - Arrays.fill(data, 2889, 2891, (byte)57); - Arrays.fill(data, 2891, 2894, (byte)59); - Arrays.fill(data, 2894, 2902, (byte)57); - Arrays.fill(data, 2902, 2904, (byte)59); - Arrays.fill(data, 2904, 2908, (byte)57); - Arrays.fill(data, 2908, 2910, (byte)63); - data[2910] = (byte)57; - Arrays.fill(data, 2911, 2914, (byte)63); - Arrays.fill(data, 2914, 2918, (byte)57); - Arrays.fill(data, 2918, 2928, (byte)59); - Arrays.fill(data, 2928, 2946, (byte)57); - Arrays.fill(data, 2946, 2948, (byte)59); - data[2948] = (byte)57; - Arrays.fill(data, 2949, 2955, (byte)63); - Arrays.fill(data, 2955, 2958, (byte)57); - Arrays.fill(data, 2958, 2961, (byte)63); - data[2961] = (byte)57; - Arrays.fill(data, 2962, 2966, (byte)63); - Arrays.fill(data, 2966, 2969, (byte)57); - Arrays.fill(data, 2969, 2971, (byte)63); - data[2971] = (byte)57; - data[2972] = (byte)63; - data[2973] = (byte)57; - Arrays.fill(data, 2974, 2976, (byte)63); - Arrays.fill(data, 2976, 2979, (byte)57); - Arrays.fill(data, 2979, 2981, (byte)63); - Arrays.fill(data, 2981, 2984, (byte)57); - Arrays.fill(data, 2984, 2987, (byte)63); - Arrays.fill(data, 2987, 2990, (byte)57); - Arrays.fill(data, 2990, 2998, (byte)63); - data[2998] = (byte)57; - Arrays.fill(data, 2999, 3002, (byte)63); - Arrays.fill(data, 3002, 3006, (byte)57); - Arrays.fill(data, 3006, 3011, (byte)59); - Arrays.fill(data, 3011, 3014, (byte)57); - Arrays.fill(data, 3014, 3017, (byte)59); - data[3017] = (byte)57; - Arrays.fill(data, 3018, 3022, (byte)59); - Arrays.fill(data, 3022, 3031, (byte)57); - data[3031] = (byte)59; - Arrays.fill(data, 3032, 3047, (byte)57); - Arrays.fill(data, 3047, 3056, (byte)59); - Arrays.fill(data, 3056, 3073, (byte)57); - Arrays.fill(data, 3073, 3076, (byte)59); - data[3076] = (byte)57; - Arrays.fill(data, 3077, 3085, (byte)63); - data[3085] = (byte)57; - Arrays.fill(data, 3086, 3089, (byte)63); - data[3089] = (byte)57; - Arrays.fill(data, 3090, 3113, (byte)63); - data[3113] = (byte)57; - Arrays.fill(data, 3114, 3124, (byte)63); - data[3124] = (byte)57; - Arrays.fill(data, 3125, 3130, (byte)63); - Arrays.fill(data, 3130, 3134, (byte)57); - Arrays.fill(data, 3134, 3141, (byte)59); - data[3141] = (byte)57; - Arrays.fill(data, 3142, 3145, (byte)59); - data[3145] = (byte)57; - Arrays.fill(data, 3146, 3150, (byte)59); - Arrays.fill(data, 3150, 3157, (byte)57); - Arrays.fill(data, 3157, 3159, (byte)59); - Arrays.fill(data, 3159, 3168, (byte)57); - Arrays.fill(data, 3168, 3170, (byte)63); - Arrays.fill(data, 3170, 3174, (byte)57); - Arrays.fill(data, 3174, 3184, (byte)59); - Arrays.fill(data, 3184, 3202, (byte)57); - Arrays.fill(data, 3202, 3204, (byte)59); - data[3204] = (byte)57; - Arrays.fill(data, 3205, 3213, (byte)63); - data[3213] = (byte)57; - Arrays.fill(data, 3214, 3217, (byte)63); - data[3217] = (byte)57; - Arrays.fill(data, 3218, 3241, (byte)63); - data[3241] = (byte)57; - Arrays.fill(data, 3242, 3252, (byte)63); - data[3252] = (byte)57; - Arrays.fill(data, 3253, 3258, (byte)63); - Arrays.fill(data, 3258, 3262, (byte)57); - Arrays.fill(data, 3262, 3269, (byte)59); - data[3269] = (byte)57; - Arrays.fill(data, 3270, 3273, (byte)59); - data[3273] = (byte)57; - Arrays.fill(data, 3274, 3278, (byte)59); - Arrays.fill(data, 3278, 3285, (byte)57); - Arrays.fill(data, 3285, 3287, (byte)59); - Arrays.fill(data, 3287, 3294, (byte)57); - data[3294] = (byte)63; - data[3295] = (byte)57; - Arrays.fill(data, 3296, 3298, (byte)63); - Arrays.fill(data, 3298, 3302, (byte)57); - Arrays.fill(data, 3302, 3312, (byte)59); - Arrays.fill(data, 3312, 3330, (byte)57); - Arrays.fill(data, 3330, 3332, (byte)59); - data[3332] = (byte)57; - Arrays.fill(data, 3333, 3341, (byte)63); - data[3341] = (byte)57; - Arrays.fill(data, 3342, 3345, (byte)63); - data[3345] = (byte)57; - Arrays.fill(data, 3346, 3369, (byte)63); - data[3369] = (byte)57; - Arrays.fill(data, 3370, 3386, (byte)63); - Arrays.fill(data, 3386, 3390, (byte)57); - Arrays.fill(data, 3390, 3396, (byte)59); - Arrays.fill(data, 3396, 3398, (byte)57); - Arrays.fill(data, 3398, 3401, (byte)59); - data[3401] = (byte)57; - Arrays.fill(data, 3402, 3406, (byte)59); - Arrays.fill(data, 3406, 3415, (byte)57); - data[3415] = (byte)59; - Arrays.fill(data, 3416, 3424, (byte)57); - Arrays.fill(data, 3424, 3426, (byte)63); - Arrays.fill(data, 3426, 3430, (byte)57); - Arrays.fill(data, 3430, 3440, (byte)59); - Arrays.fill(data, 3440, 3585, (byte)57); - Arrays.fill(data, 3585, 3631, (byte)63); - data[3631] = (byte)57; - data[3632] = (byte)63; - data[3633] = (byte)59; - Arrays.fill(data, 3634, 3636, (byte)63); - Arrays.fill(data, 3636, 3643, (byte)59); - Arrays.fill(data, 3643, 3648, (byte)57); - Arrays.fill(data, 3648, 3654, (byte)63); - Arrays.fill(data, 3654, 3663, (byte)59); - data[3663] = (byte)57; - Arrays.fill(data, 3664, 3674, (byte)59); - Arrays.fill(data, 3674, 3713, (byte)57); - Arrays.fill(data, 3713, 3715, (byte)63); - data[3715] = (byte)57; - data[3716] = (byte)63; - Arrays.fill(data, 3717, 3719, (byte)57); - Arrays.fill(data, 3719, 3721, (byte)63); - data[3721] = (byte)57; - data[3722] = (byte)63; - Arrays.fill(data, 3723, 3725, (byte)57); - data[3725] = (byte)63; - Arrays.fill(data, 3726, 3732, (byte)57); - Arrays.fill(data, 3732, 3736, (byte)63); - data[3736] = (byte)57; - Arrays.fill(data, 3737, 3744, (byte)63); - data[3744] = (byte)57; - Arrays.fill(data, 3745, 3748, (byte)63); - data[3748] = (byte)57; - data[3749] = (byte)63; - data[3750] = (byte)57; - data[3751] = (byte)63; - Arrays.fill(data, 3752, 3754, (byte)57); - Arrays.fill(data, 3754, 3756, (byte)63); - data[3756] = (byte)57; - Arrays.fill(data, 3757, 3759, (byte)63); - data[3759] = (byte)57; - data[3760] = (byte)63; - data[3761] = (byte)59; - Arrays.fill(data, 3762, 3764, (byte)63); - Arrays.fill(data, 3764, 3770, (byte)59); - data[3770] = (byte)57; - Arrays.fill(data, 3771, 3773, (byte)59); - data[3773] = (byte)63; - Arrays.fill(data, 3774, 3776, (byte)57); - Arrays.fill(data, 3776, 3781, (byte)63); - data[3781] = (byte)57; - data[3782] = (byte)59; - data[3783] = (byte)57; - Arrays.fill(data, 3784, 3790, (byte)59); - Arrays.fill(data, 3790, 3792, (byte)57); - Arrays.fill(data, 3792, 3802, (byte)59); - Arrays.fill(data, 3802, 3864, (byte)57); - Arrays.fill(data, 3864, 3866, (byte)59); - Arrays.fill(data, 3866, 3872, (byte)57); - Arrays.fill(data, 3872, 3882, (byte)59); - Arrays.fill(data, 3882, 3893, (byte)57); - data[3893] = (byte)59; - data[3894] = (byte)57; - data[3895] = (byte)59; - data[3896] = (byte)57; - data[3897] = (byte)59; - Arrays.fill(data, 3898, 3902, (byte)57); - Arrays.fill(data, 3902, 3904, (byte)59); - Arrays.fill(data, 3904, 3912, (byte)63); - data[3912] = (byte)57; - Arrays.fill(data, 3913, 3946, (byte)63); - Arrays.fill(data, 3946, 3953, (byte)57); - Arrays.fill(data, 3953, 3973, (byte)59); - data[3973] = (byte)57; - Arrays.fill(data, 3974, 3980, (byte)59); - Arrays.fill(data, 3980, 3984, (byte)57); - Arrays.fill(data, 3984, 3990, (byte)59); - data[3990] = (byte)57; - data[3991] = (byte)59; - data[3992] = (byte)57; - Arrays.fill(data, 3993, 4014, (byte)59); - Arrays.fill(data, 4014, 4017, (byte)57); - Arrays.fill(data, 4017, 4024, (byte)59); - data[4024] = (byte)57; - data[4025] = (byte)59; - Arrays.fill(data, 4026, 4256, (byte)57); - Arrays.fill(data, 4256, 4294, (byte)63); - Arrays.fill(data, 4294, 4304, (byte)57); - Arrays.fill(data, 4304, 4343, (byte)63); - Arrays.fill(data, 4343, 4352, (byte)57); - data[4352] = (byte)63; - data[4353] = (byte)57; - Arrays.fill(data, 4354, 4356, (byte)63); - data[4356] = (byte)57; - Arrays.fill(data, 4357, 4360, (byte)63); - data[4360] = (byte)57; - data[4361] = (byte)63; - data[4362] = (byte)57; - Arrays.fill(data, 4363, 4365, (byte)63); - data[4365] = (byte)57; - Arrays.fill(data, 4366, 4371, (byte)63); - Arrays.fill(data, 4371, 4412, (byte)57); - data[4412] = (byte)63; - data[4413] = (byte)57; - data[4414] = (byte)63; - data[4415] = (byte)57; - data[4416] = (byte)63; - Arrays.fill(data, 4417, 4428, (byte)57); - data[4428] = (byte)63; - data[4429] = (byte)57; - data[4430] = (byte)63; - data[4431] = (byte)57; - data[4432] = (byte)63; - Arrays.fill(data, 4433, 4436, (byte)57); - Arrays.fill(data, 4436, 4438, (byte)63); - Arrays.fill(data, 4438, 4441, (byte)57); - data[4441] = (byte)63; - Arrays.fill(data, 4442, 4447, (byte)57); - Arrays.fill(data, 4447, 4450, (byte)63); - data[4450] = (byte)57; - data[4451] = (byte)63; - data[4452] = (byte)57; - data[4453] = (byte)63; - data[4454] = (byte)57; - data[4455] = (byte)63; - data[4456] = (byte)57; - data[4457] = (byte)63; - Arrays.fill(data, 4458, 4461, (byte)57); - Arrays.fill(data, 4461, 4463, (byte)63); - Arrays.fill(data, 4463, 4466, (byte)57); - Arrays.fill(data, 4466, 4468, (byte)63); - data[4468] = (byte)57; - data[4469] = (byte)63; - Arrays.fill(data, 4470, 4510, (byte)57); - data[4510] = (byte)63; - Arrays.fill(data, 4511, 4520, (byte)57); - data[4520] = (byte)63; - Arrays.fill(data, 4521, 4523, (byte)57); - data[4523] = (byte)63; - Arrays.fill(data, 4524, 4526, (byte)57); - Arrays.fill(data, 4526, 4528, (byte)63); - Arrays.fill(data, 4528, 4535, (byte)57); - Arrays.fill(data, 4535, 4537, (byte)63); - data[4537] = (byte)57; - data[4538] = (byte)63; - data[4539] = (byte)57; - Arrays.fill(data, 4540, 4547, (byte)63); - Arrays.fill(data, 4547, 4587, (byte)57); - data[4587] = (byte)63; - Arrays.fill(data, 4588, 4592, (byte)57); - data[4592] = (byte)63; - Arrays.fill(data, 4593, 4601, (byte)57); - data[4601] = (byte)63; - Arrays.fill(data, 4602, 7680, (byte)57); - Arrays.fill(data, 7680, 7836, (byte)63); - Arrays.fill(data, 7836, 7840, (byte)57); - Arrays.fill(data, 7840, 7930, (byte)63); - Arrays.fill(data, 7930, 7936, (byte)57); - Arrays.fill(data, 7936, 7958, (byte)63); - Arrays.fill(data, 7958, 7960, (byte)57); - Arrays.fill(data, 7960, 7966, (byte)63); - Arrays.fill(data, 7966, 7968, (byte)57); - Arrays.fill(data, 7968, 8006, (byte)63); - Arrays.fill(data, 8006, 8008, (byte)57); - Arrays.fill(data, 8008, 8014, (byte)63); - Arrays.fill(data, 8014, 8016, (byte)57); - Arrays.fill(data, 8016, 8024, (byte)63); - data[8024] = (byte)57; - data[8025] = (byte)63; - data[8026] = (byte)57; - data[8027] = (byte)63; - data[8028] = (byte)57; - data[8029] = (byte)63; - data[8030] = (byte)57; - Arrays.fill(data, 8031, 8062, (byte)63); - Arrays.fill(data, 8062, 8064, (byte)57); - Arrays.fill(data, 8064, 8117, (byte)63); - data[8117] = (byte)57; - Arrays.fill(data, 8118, 8125, (byte)63); - data[8125] = (byte)57; - data[8126] = (byte)63; - Arrays.fill(data, 8127, 8130, (byte)57); - Arrays.fill(data, 8130, 8133, (byte)63); - data[8133] = (byte)57; - Arrays.fill(data, 8134, 8141, (byte)63); - Arrays.fill(data, 8141, 8144, (byte)57); - Arrays.fill(data, 8144, 8148, (byte)63); - Arrays.fill(data, 8148, 8150, (byte)57); - Arrays.fill(data, 8150, 8156, (byte)63); - Arrays.fill(data, 8156, 8160, (byte)57); - Arrays.fill(data, 8160, 8173, (byte)63); - Arrays.fill(data, 8173, 8178, (byte)57); - Arrays.fill(data, 8178, 8181, (byte)63); - data[8181] = (byte)57; - Arrays.fill(data, 8182, 8189, (byte)63); - Arrays.fill(data, 8189, 8192, (byte)57); - Arrays.fill(data, 8192, 8204, (byte)9); - Arrays.fill(data, 8204, 8206, (byte)57); - Arrays.fill(data, 8206, 8255, (byte)9); - Arrays.fill(data, 8255, 8257, (byte)25); - Arrays.fill(data, 8257, 8304, (byte)9); - Arrays.fill(data, 8304, 8400, (byte)57); - Arrays.fill(data, 8400, 8413, (byte)59); - Arrays.fill(data, 8413, 8417, (byte)57); - data[8417] = (byte)59; - Arrays.fill(data, 8418, 8486, (byte)57); - data[8486] = (byte)63; - Arrays.fill(data, 8487, 8490, (byte)57); - Arrays.fill(data, 8490, 8492, (byte)63); - Arrays.fill(data, 8492, 8494, (byte)57); - data[8494] = (byte)63; - Arrays.fill(data, 8495, 8576, (byte)57); - Arrays.fill(data, 8576, 8579, (byte)63); - Arrays.fill(data, 8579, 8592, (byte)57); - Arrays.fill(data, 8592, 11264, (byte)9); - Arrays.fill(data, 11264, 12272, (byte)57); - Arrays.fill(data, 12272, 12289, (byte)9); - Arrays.fill(data, 12289, 12293, (byte)57); - data[12293] = (byte)59; - data[12294] = (byte)57; - data[12295] = (byte)63; - Arrays.fill(data, 12296, 12321, (byte)57); - Arrays.fill(data, 12321, 12330, (byte)63); - Arrays.fill(data, 12330, 12336, (byte)59); - data[12336] = (byte)57; - Arrays.fill(data, 12337, 12342, (byte)59); - Arrays.fill(data, 12342, 12353, (byte)57); - Arrays.fill(data, 12353, 12437, (byte)63); - Arrays.fill(data, 12437, 12441, (byte)57); - Arrays.fill(data, 12441, 12443, (byte)59); - Arrays.fill(data, 12443, 12445, (byte)57); - Arrays.fill(data, 12445, 12447, (byte)59); - Arrays.fill(data, 12447, 12449, (byte)57); - Arrays.fill(data, 12449, 12539, (byte)63); - data[12539] = (byte)57; - Arrays.fill(data, 12540, 12543, (byte)59); - Arrays.fill(data, 12543, 12549, (byte)57); - Arrays.fill(data, 12549, 12589, (byte)63); - Arrays.fill(data, 12589, 19968, (byte)57); - Arrays.fill(data, 19968, 40870, (byte)63); - Arrays.fill(data, 40870, 44032, (byte)57); - Arrays.fill(data, 44032, 55204, (byte)63); - Arrays.fill(data, 55204, 55296, (byte)57); - Arrays.fill(data, 55296, 57344, (byte)0); - Arrays.fill(data, 57344, 63744, (byte)9); - Arrays.fill(data, 63744, 64976, (byte)57); - Arrays.fill(data, 64976, 65008, (byte)9); - Arrays.fill(data, 65008, 65534, (byte)57); - Arrays.fill(data, 65534, 65536, (byte)0); - } - - /** - * Get all the characters in a given category, as an integer set. This must be one of the four - * name classes: Name characters or Name Start characters in XML 1.0 or XML 1.1. (This method - * is used to populate the data tables used by the regular expression translators) - * @param mask identifies the properties of the required category - * @return the set of characters in the given category. - */ - - public static IntRangeSet getCategory(byte mask) { - final IntRangeSet irs = new IntRangeSet(); - for (int i=0; i<65536; i++) { - if ((data[i]&mask) != 0) { - irs.add(i); - } - } - if ((mask & (NAME_START_11_MASK | NAME_11_MASK)) != 0) { - irs.addRange(UTF16CharacterSet.NONBMP_MIN, MAX_XML11_NAME_CHAR); - } - return irs; - } - -} - -// Copyright (c) 2009 Saxonica Limited. All rights reserved. - -// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at http://www.mozilla.org/MPL/ -// -// Software distributed under the License is distributed on an "AS IS" basis, -// WITHOUT WARRANTY OF ANY KIND, either express or implied. -// See the License for the specific language governing rights and limitations under the License. -// -// The Original Code is: all this file. -// -// The Initial Developer of the Original Code is Saxonica Limited. -// -// Portions created by __ are Copyright (C) __. All Rights Reserved. -// -// Contributor(s): None +package org.exist.xquery.regex; + +import java.util.Arrays; + +import org.exist.util.UTF16CharacterSet; + +/** + * This module contains data regarding the classification of characters in XML 1.0 and XML 1.1, and a number + * of interrogative methods to support queries on this data. + * + * For characters in the BMP, the information is tabulated by means of an array of one-byte entries, + * one for each character, with bit-significant property settings. For characters outside the BMP, the + * rules are built in to the interrogative methods. + * + * Copied from Saxon-HE 9.2 package net.sf.saxon.regex. + */ +public class XMLCharacterData { + + private final static byte[] data = new byte[65536]; + + /** + * Bit setting to indicate that a character is valid in XML 1.0 + */ + public final static byte VALID_10_MASK = 1; + /** + * Bit setting to indicate that a character is valid in an XML 1.0 name + */ + public final static byte NAME_10_MASK = 2; + /** + * Bit setting to indicate that a character is valid at the start of an XML 1.0 name + */ + public final static byte NAME_START_10_MASK = 4; + /** + * Bit setting to indicate that a character is valid in XML 1.1 + */ + public final static byte VALID_11_MASK = 8; + /** + * Bit setting to indicate that a character is valid in an XML 1.1 name + */ + public final static byte NAME_11_MASK = 16; + /** + * Bit setting to indicate that a character is valid at the start of an XML 1.1 name + */ + public final static byte NAME_START_11_MASK = 32; + /** + * Maximum code point for a character permitted in an XML 1.1 name + */ + public final static int MAX_XML11_NAME_CHAR = 0xEFFFF; + + /** + * Determine whether a character is valid in XML 1.0 + * @param i the character + * @return true if the character is valid in XML 1.0 + */ + + public static boolean isValid10(int i) { + return i < 65536 ? (data[i]&VALID_10_MASK) != 0 : (UTF16CharacterSet.NONBMP_MIN <= i && i <= UTF16CharacterSet.NONBMP_MAX); + } + + /** + * Determine whether a character is valid in an NCName in XML 1.0 + * @param i the character + * @return true if the character is valid in an NCName in XML 1.0 + */ + + public static boolean isNCName10(int i) { + return i < 65536 && (data[i]&NAME_10_MASK) != 0; + } + + /** + * Determine whether a character is valid at the start of an NCName in XML 1.0 + * @param i the character + * @return true if the character is valid at the start of an NCName in XML 1.0 + */ + + public static boolean isNCNameStart10(int i) { + return i < 65536 && (data[i]&NAME_START_10_MASK) != 0; + } + + /** + * Determine whether a character is valid in XML 1.1 + * @param i the character + * @return true if the character is valid in XML 1.1 + */ + + public static boolean isValid11(int i) { + return i < 65536 ? (data[i]&VALID_11_MASK) != 0 : (UTF16CharacterSet.NONBMP_MIN <= i && i <= UTF16CharacterSet.NONBMP_MAX); + } + + /** + * Determine whether a character is valid in an NCName in XML 1.1 + * @param i the character + * @return true if the character is valid in an NCName in XML 1.1 + */ + + public static boolean isNCName11(int i) { + return i < 65536 ? (data[i]&NAME_11_MASK) != 0 : (UTF16CharacterSet.NONBMP_MIN <= i && i <= MAX_XML11_NAME_CHAR); + } + + /** + * Determine whether a character is valid at the start of an NCName in XML 1.1 + * @param i the character + * @return true if the character is valid at the start of an NCName in XML 1.1 + */ + + public static boolean isNCNameStart11(int i) { + return i < 65536 ? (data[i]&NAME_START_11_MASK) != 0 : (UTF16CharacterSet.NONBMP_MIN <= i && i <= MAX_XML11_NAME_CHAR); + } + + /** + * Static code to initialize the data table + */ + + static { + data[0] = (byte)0; + Arrays.fill(data, 1, 9, (byte)8); + Arrays.fill(data, 9, 11, (byte)9); + Arrays.fill(data, 11, 13, (byte)8); + data[13] = (byte)9; + Arrays.fill(data, 14, 32, (byte)8); + Arrays.fill(data, 32, 45, (byte)9); + Arrays.fill(data, 45, 47, (byte)27); + data[47] = (byte)9; + Arrays.fill(data, 48, 58, (byte)27); + data[58] = (byte)9; // colon + Arrays.fill(data, 59, 65, (byte)9); + Arrays.fill(data, 65, 91, (byte)63); + Arrays.fill(data, 91, 95, (byte)9); + data[95] = (byte)63; + data[96] = (byte)9; + Arrays.fill(data, 97, 123, (byte)63); + Arrays.fill(data, 123, 183, (byte)9); + data[183] = (byte)27; + Arrays.fill(data, 184, 192, (byte)9); + Arrays.fill(data, 192, 215, (byte)63); + data[215] = (byte)9; + Arrays.fill(data, 216, 247, (byte)63); + data[247] = (byte)9; + Arrays.fill(data, 248, 306, (byte)63); + Arrays.fill(data, 306, 308, (byte)57); + Arrays.fill(data, 308, 319, (byte)63); + Arrays.fill(data, 319, 321, (byte)57); + Arrays.fill(data, 321, 329, (byte)63); + data[329] = (byte)57; + Arrays.fill(data, 330, 383, (byte)63); + data[383] = (byte)57; + Arrays.fill(data, 384, 452, (byte)63); + Arrays.fill(data, 452, 461, (byte)57); + Arrays.fill(data, 461, 497, (byte)63); + Arrays.fill(data, 497, 500, (byte)57); + Arrays.fill(data, 500, 502, (byte)63); + Arrays.fill(data, 502, 506, (byte)57); + Arrays.fill(data, 506, 536, (byte)63); + Arrays.fill(data, 536, 592, (byte)57); + Arrays.fill(data, 592, 681, (byte)63); + Arrays.fill(data, 681, 699, (byte)57); + Arrays.fill(data, 699, 706, (byte)63); + Arrays.fill(data, 706, 720, (byte)57); + Arrays.fill(data, 720, 722, (byte)59); + Arrays.fill(data, 722, 768, (byte)57); + Arrays.fill(data, 768, 838, (byte)27); + Arrays.fill(data, 838, 864, (byte)25); + Arrays.fill(data, 864, 866, (byte)27); + Arrays.fill(data, 866, 880, (byte)25); + Arrays.fill(data, 880, 894, (byte)57); + data[894] = (byte)9; + Arrays.fill(data, 895, 902, (byte)57); + data[902] = (byte)63; + data[903] = (byte)59; + Arrays.fill(data, 904, 907, (byte)63); + data[907] = (byte)57; + data[908] = (byte)63; + data[909] = (byte)57; + Arrays.fill(data, 910, 930, (byte)63); + data[930] = (byte)57; + Arrays.fill(data, 931, 975, (byte)63); + data[975] = (byte)57; + Arrays.fill(data, 976, 983, (byte)63); + Arrays.fill(data, 983, 986, (byte)57); + data[986] = (byte)63; + data[987] = (byte)57; + data[988] = (byte)63; + data[989] = (byte)57; + data[990] = (byte)63; + data[991] = (byte)57; + data[992] = (byte)63; + data[993] = (byte)57; + Arrays.fill(data, 994, 1012, (byte)63); + Arrays.fill(data, 1012, 1025, (byte)57); + Arrays.fill(data, 1025, 1037, (byte)63); + data[1037] = (byte)57; + Arrays.fill(data, 1038, 1104, (byte)63); + data[1104] = (byte)57; + Arrays.fill(data, 1105, 1117, (byte)63); + data[1117] = (byte)57; + Arrays.fill(data, 1118, 1154, (byte)63); + data[1154] = (byte)57; + Arrays.fill(data, 1155, 1159, (byte)59); + Arrays.fill(data, 1159, 1168, (byte)57); + Arrays.fill(data, 1168, 1221, (byte)63); + Arrays.fill(data, 1221, 1223, (byte)57); + Arrays.fill(data, 1223, 1225, (byte)63); + Arrays.fill(data, 1225, 1227, (byte)57); + Arrays.fill(data, 1227, 1229, (byte)63); + Arrays.fill(data, 1229, 1232, (byte)57); + Arrays.fill(data, 1232, 1260, (byte)63); + Arrays.fill(data, 1260, 1262, (byte)57); + Arrays.fill(data, 1262, 1270, (byte)63); + Arrays.fill(data, 1270, 1272, (byte)57); + Arrays.fill(data, 1272, 1274, (byte)63); + Arrays.fill(data, 1274, 1329, (byte)57); + Arrays.fill(data, 1329, 1367, (byte)63); + Arrays.fill(data, 1367, 1369, (byte)57); + data[1369] = (byte)63; + Arrays.fill(data, 1370, 1377, (byte)57); + Arrays.fill(data, 1377, 1415, (byte)63); + Arrays.fill(data, 1415, 1425, (byte)57); + Arrays.fill(data, 1425, 1442, (byte)59); + data[1442] = (byte)57; + Arrays.fill(data, 1443, 1466, (byte)59); + data[1466] = (byte)57; + Arrays.fill(data, 1467, 1470, (byte)59); + data[1470] = (byte)57; + data[1471] = (byte)59; + data[1472] = (byte)57; + Arrays.fill(data, 1473, 1475, (byte)59); + data[1475] = (byte)57; + data[1476] = (byte)59; + Arrays.fill(data, 1477, 1488, (byte)57); + Arrays.fill(data, 1488, 1515, (byte)63); + Arrays.fill(data, 1515, 1520, (byte)57); + Arrays.fill(data, 1520, 1523, (byte)63); + Arrays.fill(data, 1523, 1569, (byte)57); + Arrays.fill(data, 1569, 1595, (byte)63); + Arrays.fill(data, 1595, 1600, (byte)57); + data[1600] = (byte)59; + Arrays.fill(data, 1601, 1611, (byte)63); + Arrays.fill(data, 1611, 1619, (byte)59); + Arrays.fill(data, 1619, 1632, (byte)57); + Arrays.fill(data, 1632, 1642, (byte)59); + Arrays.fill(data, 1642, 1648, (byte)57); + data[1648] = (byte)59; + Arrays.fill(data, 1649, 1720, (byte)63); + Arrays.fill(data, 1720, 1722, (byte)57); + Arrays.fill(data, 1722, 1727, (byte)63); + data[1727] = (byte)57; + Arrays.fill(data, 1728, 1743, (byte)63); + data[1743] = (byte)57; + Arrays.fill(data, 1744, 1748, (byte)63); + data[1748] = (byte)57; + data[1749] = (byte)63; + Arrays.fill(data, 1750, 1765, (byte)59); + Arrays.fill(data, 1765, 1767, (byte)63); + Arrays.fill(data, 1767, 1769, (byte)59); + data[1769] = (byte)57; + Arrays.fill(data, 1770, 1774, (byte)59); + Arrays.fill(data, 1774, 1776, (byte)57); + Arrays.fill(data, 1776, 1786, (byte)59); + Arrays.fill(data, 1786, 2305, (byte)57); + Arrays.fill(data, 2305, 2308, (byte)59); + data[2308] = (byte)57; + Arrays.fill(data, 2309, 2362, (byte)63); + Arrays.fill(data, 2362, 2364, (byte)57); + data[2364] = (byte)59; + data[2365] = (byte)63; + Arrays.fill(data, 2366, 2382, (byte)59); + Arrays.fill(data, 2382, 2385, (byte)57); + Arrays.fill(data, 2385, 2389, (byte)59); + Arrays.fill(data, 2389, 2392, (byte)57); + Arrays.fill(data, 2392, 2402, (byte)63); + Arrays.fill(data, 2402, 2404, (byte)59); + Arrays.fill(data, 2404, 2406, (byte)57); + Arrays.fill(data, 2406, 2416, (byte)59); + Arrays.fill(data, 2416, 2433, (byte)57); + Arrays.fill(data, 2433, 2436, (byte)59); + data[2436] = (byte)57; + Arrays.fill(data, 2437, 2445, (byte)63); + Arrays.fill(data, 2445, 2447, (byte)57); + Arrays.fill(data, 2447, 2449, (byte)63); + Arrays.fill(data, 2449, 2451, (byte)57); + Arrays.fill(data, 2451, 2473, (byte)63); + data[2473] = (byte)57; + Arrays.fill(data, 2474, 2481, (byte)63); + data[2481] = (byte)57; + data[2482] = (byte)63; + Arrays.fill(data, 2483, 2486, (byte)57); + Arrays.fill(data, 2486, 2490, (byte)63); + Arrays.fill(data, 2490, 2492, (byte)57); + data[2492] = (byte)59; + data[2493] = (byte)57; + Arrays.fill(data, 2494, 2501, (byte)59); + Arrays.fill(data, 2501, 2503, (byte)57); + Arrays.fill(data, 2503, 2505, (byte)59); + Arrays.fill(data, 2505, 2507, (byte)57); + Arrays.fill(data, 2507, 2510, (byte)59); + Arrays.fill(data, 2510, 2519, (byte)57); + data[2519] = (byte)59; + Arrays.fill(data, 2520, 2524, (byte)57); + Arrays.fill(data, 2524, 2526, (byte)63); + data[2526] = (byte)57; + Arrays.fill(data, 2527, 2530, (byte)63); + Arrays.fill(data, 2530, 2532, (byte)59); + Arrays.fill(data, 2532, 2534, (byte)57); + Arrays.fill(data, 2534, 2544, (byte)59); + Arrays.fill(data, 2544, 2546, (byte)63); + Arrays.fill(data, 2546, 2562, (byte)57); + data[2562] = (byte)59; + Arrays.fill(data, 2563, 2565, (byte)57); + Arrays.fill(data, 2565, 2571, (byte)63); + Arrays.fill(data, 2571, 2575, (byte)57); + Arrays.fill(data, 2575, 2577, (byte)63); + Arrays.fill(data, 2577, 2579, (byte)57); + Arrays.fill(data, 2579, 2601, (byte)63); + data[2601] = (byte)57; + Arrays.fill(data, 2602, 2609, (byte)63); + data[2609] = (byte)57; + Arrays.fill(data, 2610, 2612, (byte)63); + data[2612] = (byte)57; + Arrays.fill(data, 2613, 2615, (byte)63); + data[2615] = (byte)57; + Arrays.fill(data, 2616, 2618, (byte)63); + Arrays.fill(data, 2618, 2620, (byte)57); + data[2620] = (byte)59; + data[2621] = (byte)57; + Arrays.fill(data, 2622, 2627, (byte)59); + Arrays.fill(data, 2627, 2631, (byte)57); + Arrays.fill(data, 2631, 2633, (byte)59); + Arrays.fill(data, 2633, 2635, (byte)57); + Arrays.fill(data, 2635, 2638, (byte)59); + Arrays.fill(data, 2638, 2649, (byte)57); + Arrays.fill(data, 2649, 2653, (byte)63); + data[2653] = (byte)57; + data[2654] = (byte)63; + Arrays.fill(data, 2655, 2662, (byte)57); + Arrays.fill(data, 2662, 2674, (byte)59); + Arrays.fill(data, 2674, 2677, (byte)63); + Arrays.fill(data, 2677, 2689, (byte)57); + Arrays.fill(data, 2689, 2692, (byte)59); + data[2692] = (byte)57; + Arrays.fill(data, 2693, 2700, (byte)63); + data[2700] = (byte)57; + data[2701] = (byte)63; + data[2702] = (byte)57; + Arrays.fill(data, 2703, 2706, (byte)63); + data[2706] = (byte)57; + Arrays.fill(data, 2707, 2729, (byte)63); + data[2729] = (byte)57; + Arrays.fill(data, 2730, 2737, (byte)63); + data[2737] = (byte)57; + Arrays.fill(data, 2738, 2740, (byte)63); + data[2740] = (byte)57; + Arrays.fill(data, 2741, 2746, (byte)63); + Arrays.fill(data, 2746, 2748, (byte)57); + data[2748] = (byte)59; + data[2749] = (byte)63; + Arrays.fill(data, 2750, 2758, (byte)59); + data[2758] = (byte)57; + Arrays.fill(data, 2759, 2762, (byte)59); + data[2762] = (byte)57; + Arrays.fill(data, 2763, 2766, (byte)59); + Arrays.fill(data, 2766, 2784, (byte)57); + data[2784] = (byte)63; + Arrays.fill(data, 2785, 2790, (byte)57); + Arrays.fill(data, 2790, 2800, (byte)59); + Arrays.fill(data, 2800, 2817, (byte)57); + Arrays.fill(data, 2817, 2820, (byte)59); + data[2820] = (byte)57; + Arrays.fill(data, 2821, 2829, (byte)63); + Arrays.fill(data, 2829, 2831, (byte)57); + Arrays.fill(data, 2831, 2833, (byte)63); + Arrays.fill(data, 2833, 2835, (byte)57); + Arrays.fill(data, 2835, 2857, (byte)63); + data[2857] = (byte)57; + Arrays.fill(data, 2858, 2865, (byte)63); + data[2865] = (byte)57; + Arrays.fill(data, 2866, 2868, (byte)63); + Arrays.fill(data, 2868, 2870, (byte)57); + Arrays.fill(data, 2870, 2874, (byte)63); + Arrays.fill(data, 2874, 2876, (byte)57); + data[2876] = (byte)59; + data[2877] = (byte)63; + Arrays.fill(data, 2878, 2884, (byte)59); + Arrays.fill(data, 2884, 2887, (byte)57); + Arrays.fill(data, 2887, 2889, (byte)59); + Arrays.fill(data, 2889, 2891, (byte)57); + Arrays.fill(data, 2891, 2894, (byte)59); + Arrays.fill(data, 2894, 2902, (byte)57); + Arrays.fill(data, 2902, 2904, (byte)59); + Arrays.fill(data, 2904, 2908, (byte)57); + Arrays.fill(data, 2908, 2910, (byte)63); + data[2910] = (byte)57; + Arrays.fill(data, 2911, 2914, (byte)63); + Arrays.fill(data, 2914, 2918, (byte)57); + Arrays.fill(data, 2918, 2928, (byte)59); + Arrays.fill(data, 2928, 2946, (byte)57); + Arrays.fill(data, 2946, 2948, (byte)59); + data[2948] = (byte)57; + Arrays.fill(data, 2949, 2955, (byte)63); + Arrays.fill(data, 2955, 2958, (byte)57); + Arrays.fill(data, 2958, 2961, (byte)63); + data[2961] = (byte)57; + Arrays.fill(data, 2962, 2966, (byte)63); + Arrays.fill(data, 2966, 2969, (byte)57); + Arrays.fill(data, 2969, 2971, (byte)63); + data[2971] = (byte)57; + data[2972] = (byte)63; + data[2973] = (byte)57; + Arrays.fill(data, 2974, 2976, (byte)63); + Arrays.fill(data, 2976, 2979, (byte)57); + Arrays.fill(data, 2979, 2981, (byte)63); + Arrays.fill(data, 2981, 2984, (byte)57); + Arrays.fill(data, 2984, 2987, (byte)63); + Arrays.fill(data, 2987, 2990, (byte)57); + Arrays.fill(data, 2990, 2998, (byte)63); + data[2998] = (byte)57; + Arrays.fill(data, 2999, 3002, (byte)63); + Arrays.fill(data, 3002, 3006, (byte)57); + Arrays.fill(data, 3006, 3011, (byte)59); + Arrays.fill(data, 3011, 3014, (byte)57); + Arrays.fill(data, 3014, 3017, (byte)59); + data[3017] = (byte)57; + Arrays.fill(data, 3018, 3022, (byte)59); + Arrays.fill(data, 3022, 3031, (byte)57); + data[3031] = (byte)59; + Arrays.fill(data, 3032, 3047, (byte)57); + Arrays.fill(data, 3047, 3056, (byte)59); + Arrays.fill(data, 3056, 3073, (byte)57); + Arrays.fill(data, 3073, 3076, (byte)59); + data[3076] = (byte)57; + Arrays.fill(data, 3077, 3085, (byte)63); + data[3085] = (byte)57; + Arrays.fill(data, 3086, 3089, (byte)63); + data[3089] = (byte)57; + Arrays.fill(data, 3090, 3113, (byte)63); + data[3113] = (byte)57; + Arrays.fill(data, 3114, 3124, (byte)63); + data[3124] = (byte)57; + Arrays.fill(data, 3125, 3130, (byte)63); + Arrays.fill(data, 3130, 3134, (byte)57); + Arrays.fill(data, 3134, 3141, (byte)59); + data[3141] = (byte)57; + Arrays.fill(data, 3142, 3145, (byte)59); + data[3145] = (byte)57; + Arrays.fill(data, 3146, 3150, (byte)59); + Arrays.fill(data, 3150, 3157, (byte)57); + Arrays.fill(data, 3157, 3159, (byte)59); + Arrays.fill(data, 3159, 3168, (byte)57); + Arrays.fill(data, 3168, 3170, (byte)63); + Arrays.fill(data, 3170, 3174, (byte)57); + Arrays.fill(data, 3174, 3184, (byte)59); + Arrays.fill(data, 3184, 3202, (byte)57); + Arrays.fill(data, 3202, 3204, (byte)59); + data[3204] = (byte)57; + Arrays.fill(data, 3205, 3213, (byte)63); + data[3213] = (byte)57; + Arrays.fill(data, 3214, 3217, (byte)63); + data[3217] = (byte)57; + Arrays.fill(data, 3218, 3241, (byte)63); + data[3241] = (byte)57; + Arrays.fill(data, 3242, 3252, (byte)63); + data[3252] = (byte)57; + Arrays.fill(data, 3253, 3258, (byte)63); + Arrays.fill(data, 3258, 3262, (byte)57); + Arrays.fill(data, 3262, 3269, (byte)59); + data[3269] = (byte)57; + Arrays.fill(data, 3270, 3273, (byte)59); + data[3273] = (byte)57; + Arrays.fill(data, 3274, 3278, (byte)59); + Arrays.fill(data, 3278, 3285, (byte)57); + Arrays.fill(data, 3285, 3287, (byte)59); + Arrays.fill(data, 3287, 3294, (byte)57); + data[3294] = (byte)63; + data[3295] = (byte)57; + Arrays.fill(data, 3296, 3298, (byte)63); + Arrays.fill(data, 3298, 3302, (byte)57); + Arrays.fill(data, 3302, 3312, (byte)59); + Arrays.fill(data, 3312, 3330, (byte)57); + Arrays.fill(data, 3330, 3332, (byte)59); + data[3332] = (byte)57; + Arrays.fill(data, 3333, 3341, (byte)63); + data[3341] = (byte)57; + Arrays.fill(data, 3342, 3345, (byte)63); + data[3345] = (byte)57; + Arrays.fill(data, 3346, 3369, (byte)63); + data[3369] = (byte)57; + Arrays.fill(data, 3370, 3386, (byte)63); + Arrays.fill(data, 3386, 3390, (byte)57); + Arrays.fill(data, 3390, 3396, (byte)59); + Arrays.fill(data, 3396, 3398, (byte)57); + Arrays.fill(data, 3398, 3401, (byte)59); + data[3401] = (byte)57; + Arrays.fill(data, 3402, 3406, (byte)59); + Arrays.fill(data, 3406, 3415, (byte)57); + data[3415] = (byte)59; + Arrays.fill(data, 3416, 3424, (byte)57); + Arrays.fill(data, 3424, 3426, (byte)63); + Arrays.fill(data, 3426, 3430, (byte)57); + Arrays.fill(data, 3430, 3440, (byte)59); + Arrays.fill(data, 3440, 3585, (byte)57); + Arrays.fill(data, 3585, 3631, (byte)63); + data[3631] = (byte)57; + data[3632] = (byte)63; + data[3633] = (byte)59; + Arrays.fill(data, 3634, 3636, (byte)63); + Arrays.fill(data, 3636, 3643, (byte)59); + Arrays.fill(data, 3643, 3648, (byte)57); + Arrays.fill(data, 3648, 3654, (byte)63); + Arrays.fill(data, 3654, 3663, (byte)59); + data[3663] = (byte)57; + Arrays.fill(data, 3664, 3674, (byte)59); + Arrays.fill(data, 3674, 3713, (byte)57); + Arrays.fill(data, 3713, 3715, (byte)63); + data[3715] = (byte)57; + data[3716] = (byte)63; + Arrays.fill(data, 3717, 3719, (byte)57); + Arrays.fill(data, 3719, 3721, (byte)63); + data[3721] = (byte)57; + data[3722] = (byte)63; + Arrays.fill(data, 3723, 3725, (byte)57); + data[3725] = (byte)63; + Arrays.fill(data, 3726, 3732, (byte)57); + Arrays.fill(data, 3732, 3736, (byte)63); + data[3736] = (byte)57; + Arrays.fill(data, 3737, 3744, (byte)63); + data[3744] = (byte)57; + Arrays.fill(data, 3745, 3748, (byte)63); + data[3748] = (byte)57; + data[3749] = (byte)63; + data[3750] = (byte)57; + data[3751] = (byte)63; + Arrays.fill(data, 3752, 3754, (byte)57); + Arrays.fill(data, 3754, 3756, (byte)63); + data[3756] = (byte)57; + Arrays.fill(data, 3757, 3759, (byte)63); + data[3759] = (byte)57; + data[3760] = (byte)63; + data[3761] = (byte)59; + Arrays.fill(data, 3762, 3764, (byte)63); + Arrays.fill(data, 3764, 3770, (byte)59); + data[3770] = (byte)57; + Arrays.fill(data, 3771, 3773, (byte)59); + data[3773] = (byte)63; + Arrays.fill(data, 3774, 3776, (byte)57); + Arrays.fill(data, 3776, 3781, (byte)63); + data[3781] = (byte)57; + data[3782] = (byte)59; + data[3783] = (byte)57; + Arrays.fill(data, 3784, 3790, (byte)59); + Arrays.fill(data, 3790, 3792, (byte)57); + Arrays.fill(data, 3792, 3802, (byte)59); + Arrays.fill(data, 3802, 3864, (byte)57); + Arrays.fill(data, 3864, 3866, (byte)59); + Arrays.fill(data, 3866, 3872, (byte)57); + Arrays.fill(data, 3872, 3882, (byte)59); + Arrays.fill(data, 3882, 3893, (byte)57); + data[3893] = (byte)59; + data[3894] = (byte)57; + data[3895] = (byte)59; + data[3896] = (byte)57; + data[3897] = (byte)59; + Arrays.fill(data, 3898, 3902, (byte)57); + Arrays.fill(data, 3902, 3904, (byte)59); + Arrays.fill(data, 3904, 3912, (byte)63); + data[3912] = (byte)57; + Arrays.fill(data, 3913, 3946, (byte)63); + Arrays.fill(data, 3946, 3953, (byte)57); + Arrays.fill(data, 3953, 3973, (byte)59); + data[3973] = (byte)57; + Arrays.fill(data, 3974, 3980, (byte)59); + Arrays.fill(data, 3980, 3984, (byte)57); + Arrays.fill(data, 3984, 3990, (byte)59); + data[3990] = (byte)57; + data[3991] = (byte)59; + data[3992] = (byte)57; + Arrays.fill(data, 3993, 4014, (byte)59); + Arrays.fill(data, 4014, 4017, (byte)57); + Arrays.fill(data, 4017, 4024, (byte)59); + data[4024] = (byte)57; + data[4025] = (byte)59; + Arrays.fill(data, 4026, 4256, (byte)57); + Arrays.fill(data, 4256, 4294, (byte)63); + Arrays.fill(data, 4294, 4304, (byte)57); + Arrays.fill(data, 4304, 4343, (byte)63); + Arrays.fill(data, 4343, 4352, (byte)57); + data[4352] = (byte)63; + data[4353] = (byte)57; + Arrays.fill(data, 4354, 4356, (byte)63); + data[4356] = (byte)57; + Arrays.fill(data, 4357, 4360, (byte)63); + data[4360] = (byte)57; + data[4361] = (byte)63; + data[4362] = (byte)57; + Arrays.fill(data, 4363, 4365, (byte)63); + data[4365] = (byte)57; + Arrays.fill(data, 4366, 4371, (byte)63); + Arrays.fill(data, 4371, 4412, (byte)57); + data[4412] = (byte)63; + data[4413] = (byte)57; + data[4414] = (byte)63; + data[4415] = (byte)57; + data[4416] = (byte)63; + Arrays.fill(data, 4417, 4428, (byte)57); + data[4428] = (byte)63; + data[4429] = (byte)57; + data[4430] = (byte)63; + data[4431] = (byte)57; + data[4432] = (byte)63; + Arrays.fill(data, 4433, 4436, (byte)57); + Arrays.fill(data, 4436, 4438, (byte)63); + Arrays.fill(data, 4438, 4441, (byte)57); + data[4441] = (byte)63; + Arrays.fill(data, 4442, 4447, (byte)57); + Arrays.fill(data, 4447, 4450, (byte)63); + data[4450] = (byte)57; + data[4451] = (byte)63; + data[4452] = (byte)57; + data[4453] = (byte)63; + data[4454] = (byte)57; + data[4455] = (byte)63; + data[4456] = (byte)57; + data[4457] = (byte)63; + Arrays.fill(data, 4458, 4461, (byte)57); + Arrays.fill(data, 4461, 4463, (byte)63); + Arrays.fill(data, 4463, 4466, (byte)57); + Arrays.fill(data, 4466, 4468, (byte)63); + data[4468] = (byte)57; + data[4469] = (byte)63; + Arrays.fill(data, 4470, 4510, (byte)57); + data[4510] = (byte)63; + Arrays.fill(data, 4511, 4520, (byte)57); + data[4520] = (byte)63; + Arrays.fill(data, 4521, 4523, (byte)57); + data[4523] = (byte)63; + Arrays.fill(data, 4524, 4526, (byte)57); + Arrays.fill(data, 4526, 4528, (byte)63); + Arrays.fill(data, 4528, 4535, (byte)57); + Arrays.fill(data, 4535, 4537, (byte)63); + data[4537] = (byte)57; + data[4538] = (byte)63; + data[4539] = (byte)57; + Arrays.fill(data, 4540, 4547, (byte)63); + Arrays.fill(data, 4547, 4587, (byte)57); + data[4587] = (byte)63; + Arrays.fill(data, 4588, 4592, (byte)57); + data[4592] = (byte)63; + Arrays.fill(data, 4593, 4601, (byte)57); + data[4601] = (byte)63; + Arrays.fill(data, 4602, 7680, (byte)57); + Arrays.fill(data, 7680, 7836, (byte)63); + Arrays.fill(data, 7836, 7840, (byte)57); + Arrays.fill(data, 7840, 7930, (byte)63); + Arrays.fill(data, 7930, 7936, (byte)57); + Arrays.fill(data, 7936, 7958, (byte)63); + Arrays.fill(data, 7958, 7960, (byte)57); + Arrays.fill(data, 7960, 7966, (byte)63); + Arrays.fill(data, 7966, 7968, (byte)57); + Arrays.fill(data, 7968, 8006, (byte)63); + Arrays.fill(data, 8006, 8008, (byte)57); + Arrays.fill(data, 8008, 8014, (byte)63); + Arrays.fill(data, 8014, 8016, (byte)57); + Arrays.fill(data, 8016, 8024, (byte)63); + data[8024] = (byte)57; + data[8025] = (byte)63; + data[8026] = (byte)57; + data[8027] = (byte)63; + data[8028] = (byte)57; + data[8029] = (byte)63; + data[8030] = (byte)57; + Arrays.fill(data, 8031, 8062, (byte)63); + Arrays.fill(data, 8062, 8064, (byte)57); + Arrays.fill(data, 8064, 8117, (byte)63); + data[8117] = (byte)57; + Arrays.fill(data, 8118, 8125, (byte)63); + data[8125] = (byte)57; + data[8126] = (byte)63; + Arrays.fill(data, 8127, 8130, (byte)57); + Arrays.fill(data, 8130, 8133, (byte)63); + data[8133] = (byte)57; + Arrays.fill(data, 8134, 8141, (byte)63); + Arrays.fill(data, 8141, 8144, (byte)57); + Arrays.fill(data, 8144, 8148, (byte)63); + Arrays.fill(data, 8148, 8150, (byte)57); + Arrays.fill(data, 8150, 8156, (byte)63); + Arrays.fill(data, 8156, 8160, (byte)57); + Arrays.fill(data, 8160, 8173, (byte)63); + Arrays.fill(data, 8173, 8178, (byte)57); + Arrays.fill(data, 8178, 8181, (byte)63); + data[8181] = (byte)57; + Arrays.fill(data, 8182, 8189, (byte)63); + Arrays.fill(data, 8189, 8192, (byte)57); + Arrays.fill(data, 8192, 8204, (byte)9); + Arrays.fill(data, 8204, 8206, (byte)57); + Arrays.fill(data, 8206, 8255, (byte)9); + Arrays.fill(data, 8255, 8257, (byte)25); + Arrays.fill(data, 8257, 8304, (byte)9); + Arrays.fill(data, 8304, 8400, (byte)57); + Arrays.fill(data, 8400, 8413, (byte)59); + Arrays.fill(data, 8413, 8417, (byte)57); + data[8417] = (byte)59; + Arrays.fill(data, 8418, 8486, (byte)57); + data[8486] = (byte)63; + Arrays.fill(data, 8487, 8490, (byte)57); + Arrays.fill(data, 8490, 8492, (byte)63); + Arrays.fill(data, 8492, 8494, (byte)57); + data[8494] = (byte)63; + Arrays.fill(data, 8495, 8576, (byte)57); + Arrays.fill(data, 8576, 8579, (byte)63); + Arrays.fill(data, 8579, 8592, (byte)57); + Arrays.fill(data, 8592, 11264, (byte)9); + Arrays.fill(data, 11264, 12272, (byte)57); + Arrays.fill(data, 12272, 12289, (byte)9); + Arrays.fill(data, 12289, 12293, (byte)57); + data[12293] = (byte)59; + data[12294] = (byte)57; + data[12295] = (byte)63; + Arrays.fill(data, 12296, 12321, (byte)57); + Arrays.fill(data, 12321, 12330, (byte)63); + Arrays.fill(data, 12330, 12336, (byte)59); + data[12336] = (byte)57; + Arrays.fill(data, 12337, 12342, (byte)59); + Arrays.fill(data, 12342, 12353, (byte)57); + Arrays.fill(data, 12353, 12437, (byte)63); + Arrays.fill(data, 12437, 12441, (byte)57); + Arrays.fill(data, 12441, 12443, (byte)59); + Arrays.fill(data, 12443, 12445, (byte)57); + Arrays.fill(data, 12445, 12447, (byte)59); + Arrays.fill(data, 12447, 12449, (byte)57); + Arrays.fill(data, 12449, 12539, (byte)63); + data[12539] = (byte)57; + Arrays.fill(data, 12540, 12543, (byte)59); + Arrays.fill(data, 12543, 12549, (byte)57); + Arrays.fill(data, 12549, 12589, (byte)63); + Arrays.fill(data, 12589, 19968, (byte)57); + Arrays.fill(data, 19968, 40870, (byte)63); + Arrays.fill(data, 40870, 44032, (byte)57); + Arrays.fill(data, 44032, 55204, (byte)63); + Arrays.fill(data, 55204, 55296, (byte)57); + Arrays.fill(data, 55296, 57344, (byte)0); + Arrays.fill(data, 57344, 63744, (byte)9); + Arrays.fill(data, 63744, 64976, (byte)57); + Arrays.fill(data, 64976, 65008, (byte)9); + Arrays.fill(data, 65008, 65534, (byte)57); + Arrays.fill(data, 65534, 65536, (byte)0); + } + + /** + * Get all the characters in a given category, as an integer set. This must be one of the four + * name classes: Name characters or Name Start characters in XML 1.0 or XML 1.1. (This method + * is used to populate the data tables used by the regular expression translators) + * @param mask identifies the properties of the required category + * @return the set of characters in the given category. + */ + + public static IntRangeSet getCategory(byte mask) { + final IntRangeSet irs = new IntRangeSet(); + for (int i=0; i<65536; i++) { + if ((data[i]&mask) != 0) { + irs.add(i); + } + } + if ((mask & (NAME_START_11_MASK | NAME_11_MASK)) != 0) { + irs.addRange(UTF16CharacterSet.NONBMP_MIN, MAX_XML11_NAME_CHAR); + } + return irs; + } + +} + +// Copyright (c) 2009 Saxonica Limited. All rights reserved. + +// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" basis, +// WITHOUT WARRANTY OF ANY KIND, either express or implied. +// See the License for the specific language governing rights and limitations under the License. +// +// The Original Code is: all this file. +// +// The Initial Developer of the Original Code is Saxonica Limited. +// +// Portions created by __ are Copyright (C) __. All Rights Reserved. +// +// Contributor(s): None diff --git a/src/org/exist/xquery/value/GroupedValueSequence.java b/src/org/exist/xquery/value/GroupedValueSequence.java index a4023394aaa..4ed4ce26556 100644 --- a/src/org/exist/xquery/value/GroupedValueSequence.java +++ b/src/org/exist/xquery/value/GroupedValueSequence.java @@ -1,265 +1,265 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-06 The eXist Project - * http://exist-db.org - * http://exist.sourceforge.net - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id$ - */ -package org.exist.xquery.value; - -import org.exist.dom.ExtArrayNodeSet; -import org.exist.dom.NodeProxy; -import org.exist.dom.NodeSet; -import org.exist.xquery.GroupSpec; -import org.exist.xquery.XPathException; -import org.exist.xquery.XQueryContext; -import org.exist.xquery.util.ExpressionDumper; - - -/** - * A sequence that containts items of one group specified by the group specs of - * an "group by" clause. Used by - * {@link org.exist.xquery.value.GroupedValueSequenceTable}. - * - * This class is based on {@link org.exist.xquery.value.OrderedValueSequence}. - * - * WARNING : don't use except for group by clause - * - * @author Boris Verhaegen - */ - -public class GroupedValueSequence extends AbstractSequence { - - private Entry[] items = null; - private int count = 0; - //grouping keys values of this group - private GroupSpec groupSpecs[]; - private Sequence groupKey; -// private XQueryContext context; - @SuppressWarnings("unused") - private int groupKeyLength; - - // used to keep track of the type of added items. - private int itemType = Type.ANY_TYPE; - - public GroupedValueSequence(GroupSpec groupSpecs[], int size, Sequence keySequence, XQueryContext aContext) { - this.groupSpecs = groupSpecs; - this.items = new Entry[size]; - this.groupKey = keySequence; -// this.context = aContext; //UNDERSTAND: do we need context here??? -shabanovd - this.groupKeyLength = groupKey.getItemCount(); - } - - /* (non-Javadoc) - * @see org.exist.xquery.value.Sequence#iterate() - */ - public SequenceIterator iterate() throws XPathException { - return new GroupedValueSequenceIterator(); - } - - /* (non-Javadoc) - * @see org.exist.xquery.value.AbstractSequence#unorderedIterator() - */ - public SequenceIterator unorderedIterator() throws XPathException { - return new GroupedValueSequenceIterator(); - } - - /* (non-Javadoc) - * @see org.exist.xquery.value.Sequence#getLength() - */ - public int getItemCount() { - return (items == null) ? 0 : count; - } - - public Sequence getGroupKey() { - return this.groupKey; - } - - public boolean isEmpty() { - return isEmpty; - } - - public boolean hasOne() { - return hasOne; - } - - /* (non-Javadoc) - * @see org.exist.xquery.value.Sequence#add(org.exist.xquery.value.Item) - */ - public void add(Item item) throws XPathException { - if (hasOne) - {hasOne = false;} - if (isEmpty) - {hasOne = true;} - isEmpty = false; - if(count == items.length) { - Entry newItems[] = new Entry[count * 2]; - System.arraycopy(items, 0, newItems, 0, count); - items = newItems; - } - items[count++] = new Entry(item); - checkItemType(item.getType()); - } - - /* (non-Javadoc) - * @see org.exist.xquery.value.AbstractSequence#addAll(org.exist.xquery.value.Sequence) - */ - public void addAll(Sequence other) throws XPathException { - if(other.hasOne()) - {add(other.itemAt(0));} - else if(!other.isEmpty()) { - for(final SequenceIterator i = other.iterate(); i.hasNext(); ) { - final Item next = i.nextItem(); - if(next != null) - {add(next);} - } - } - } - - public Item itemAt(int pos) { - if(items != null && pos > -1 && pos < count) - {return items[pos].item;} - else - {return null;} - } - - private void checkItemType(int type) { - if(itemType == Type.NODE || itemType == type) - {return;} - if(itemType == Type.ANY_TYPE) - {itemType = type;} - else - {itemType = Type.NODE;} - } - - /* (non-Javadoc) - * @see org.exist.xquery.value.Sequence#getItemType() - */ - public int getItemType() { - return itemType; - } - - /* (non-Javadoc) - * @see org.exist.xquery.value.Sequence#toNodeSet() - */ - public NodeSet toNodeSet() throws XPathException { - // for this method to work, all items have to be nodes - if(itemType != Type.ANY_TYPE && Type.subTypeOf(itemType, Type.NODE)) { - final NodeSet set = new ExtArrayNodeSet(); - //We can't make it from an ExtArrayNodeSet (probably because it is sorted ?) - //NodeSet set = new ArraySet(100); - for (int i = 0; i < this.count; i++) { - NodeValue v = null; - final Entry temp = items[i]; - v = (NodeValue)temp.item; - if(v.getImplementationType() != NodeValue.PERSISTENT_NODE) { - set.add((NodeProxy)v); - } else { - set.add((NodeProxy)v); - } - } - return set; - } else - {throw new XPathException("Type error: the sequence cannot be converted into" + - " a node set. Item type is " + Type.getTypeName(itemType));} - - } - - public MemoryNodeSet toMemNodeSet() throws XPathException { - if(count == 0) - {return MemoryNodeSet.EMPTY;} - if(itemType == Type.ANY_TYPE || !Type.subTypeOf(itemType, Type.NODE)) { - throw new XPathException("Type error: the sequence cannot be converted into" + - " a node set. Item type is " + Type.getTypeName(itemType)); - } - NodeValue v; - for (int i = 0; i <= count; i++) { - v = (NodeValue)items[i]; - if(v.getImplementationType() == NodeValue.PERSISTENT_NODE) - {return null;} - } - return new ValueSequence(this); - } - - /* (non-Javadoc) - * @see org.exist.xquery.value.Sequence#removeDuplicates() - */ - public void removeDuplicates() { - // TODO: is this ever relevant? - } - - private class Entry implements Comparable { - Item item; - AtomicValue values[]; - public Entry(Item item) throws XPathException { - this.item = item; - values = new AtomicValue[groupSpecs.length]; - for(int i = 0; i < groupSpecs.length; i++) { - final Sequence seq = groupSpecs[i].getGroupExpression().eval(null); - values[i] = AtomicValue.EMPTY_VALUE; - //TODO : get rid of getLength() - if(seq.hasOne()) { - values[i] = seq.itemAt(0).atomize(); - } else if(seq.hasMany()) - {throw new XPathException("expected a single value for group by expression " + - ExpressionDumper.dump(groupSpecs[i].getGroupExpression()) + - " ; found: " + seq.getItemCount());} - } - } - - /* (non-Javadoc) - * @see java.lang.Comparable#compareTo(java.lang.Object) - */ - public int compareTo(Entry other){ - int cmp = 0; - AtomicValue a, b; - for(int i = 0; i < values.length; i++) { - a = values[i]; - b = other.values[i]; - if(a == AtomicValue.EMPTY_VALUE && b != AtomicValue.EMPTY_VALUE) { - cmp = 1; - } - else{ - cmp = a.compareTo(b); - } - } - return cmp; - } - } - - private class GroupedValueSequenceIterator implements SequenceIterator { - int pos = 0; - /* (non-Javadoc) - * @see org.exist.xquery.value.SequenceIterator#hasNext() - */ - public boolean hasNext() { - return pos < count; - } - - /* (non-Javadoc) - * @see org.exist.xquery.value.SequenceIterator#nextItem() - */ - public Item nextItem() { - if(pos < count) { - return items[pos++].item; - } - return null; - } - } -} - +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-06 The eXist Project + * http://exist-db.org + * http://exist.sourceforge.net + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ +package org.exist.xquery.value; + +import org.exist.dom.ExtArrayNodeSet; +import org.exist.dom.NodeProxy; +import org.exist.dom.NodeSet; +import org.exist.xquery.GroupSpec; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.util.ExpressionDumper; + + +/** + * A sequence that containts items of one group specified by the group specs of + * an "group by" clause. Used by + * {@link org.exist.xquery.value.GroupedValueSequenceTable}. + * + * This class is based on {@link org.exist.xquery.value.OrderedValueSequence}. + * + * WARNING : don't use except for group by clause + * + * @author Boris Verhaegen + */ + +public class GroupedValueSequence extends AbstractSequence { + + private Entry[] items = null; + private int count = 0; + //grouping keys values of this group + private GroupSpec groupSpecs[]; + private Sequence groupKey; +// private XQueryContext context; + @SuppressWarnings("unused") + private int groupKeyLength; + + // used to keep track of the type of added items. + private int itemType = Type.ANY_TYPE; + + public GroupedValueSequence(GroupSpec groupSpecs[], int size, Sequence keySequence, XQueryContext aContext) { + this.groupSpecs = groupSpecs; + this.items = new Entry[size]; + this.groupKey = keySequence; +// this.context = aContext; //UNDERSTAND: do we need context here??? -shabanovd + this.groupKeyLength = groupKey.getItemCount(); + } + + /* (non-Javadoc) + * @see org.exist.xquery.value.Sequence#iterate() + */ + public SequenceIterator iterate() throws XPathException { + return new GroupedValueSequenceIterator(); + } + + /* (non-Javadoc) + * @see org.exist.xquery.value.AbstractSequence#unorderedIterator() + */ + public SequenceIterator unorderedIterator() throws XPathException { + return new GroupedValueSequenceIterator(); + } + + /* (non-Javadoc) + * @see org.exist.xquery.value.Sequence#getLength() + */ + public int getItemCount() { + return (items == null) ? 0 : count; + } + + public Sequence getGroupKey() { + return this.groupKey; + } + + public boolean isEmpty() { + return isEmpty; + } + + public boolean hasOne() { + return hasOne; + } + + /* (non-Javadoc) + * @see org.exist.xquery.value.Sequence#add(org.exist.xquery.value.Item) + */ + public void add(Item item) throws XPathException { + if (hasOne) + {hasOne = false;} + if (isEmpty) + {hasOne = true;} + isEmpty = false; + if(count == items.length) { + Entry newItems[] = new Entry[count * 2]; + System.arraycopy(items, 0, newItems, 0, count); + items = newItems; + } + items[count++] = new Entry(item); + checkItemType(item.getType()); + } + + /* (non-Javadoc) + * @see org.exist.xquery.value.AbstractSequence#addAll(org.exist.xquery.value.Sequence) + */ + public void addAll(Sequence other) throws XPathException { + if(other.hasOne()) + {add(other.itemAt(0));} + else if(!other.isEmpty()) { + for(final SequenceIterator i = other.iterate(); i.hasNext(); ) { + final Item next = i.nextItem(); + if(next != null) + {add(next);} + } + } + } + + public Item itemAt(int pos) { + if(items != null && pos > -1 && pos < count) + {return items[pos].item;} + else + {return null;} + } + + private void checkItemType(int type) { + if(itemType == Type.NODE || itemType == type) + {return;} + if(itemType == Type.ANY_TYPE) + {itemType = type;} + else + {itemType = Type.NODE;} + } + + /* (non-Javadoc) + * @see org.exist.xquery.value.Sequence#getItemType() + */ + public int getItemType() { + return itemType; + } + + /* (non-Javadoc) + * @see org.exist.xquery.value.Sequence#toNodeSet() + */ + public NodeSet toNodeSet() throws XPathException { + // for this method to work, all items have to be nodes + if(itemType != Type.ANY_TYPE && Type.subTypeOf(itemType, Type.NODE)) { + final NodeSet set = new ExtArrayNodeSet(); + //We can't make it from an ExtArrayNodeSet (probably because it is sorted ?) + //NodeSet set = new ArraySet(100); + for (int i = 0; i < this.count; i++) { + NodeValue v = null; + final Entry temp = items[i]; + v = (NodeValue)temp.item; + if(v.getImplementationType() != NodeValue.PERSISTENT_NODE) { + set.add((NodeProxy)v); + } else { + set.add((NodeProxy)v); + } + } + return set; + } else + {throw new XPathException("Type error: the sequence cannot be converted into" + + " a node set. Item type is " + Type.getTypeName(itemType));} + + } + + public MemoryNodeSet toMemNodeSet() throws XPathException { + if(count == 0) + {return MemoryNodeSet.EMPTY;} + if(itemType == Type.ANY_TYPE || !Type.subTypeOf(itemType, Type.NODE)) { + throw new XPathException("Type error: the sequence cannot be converted into" + + " a node set. Item type is " + Type.getTypeName(itemType)); + } + NodeValue v; + for (int i = 0; i <= count; i++) { + v = (NodeValue)items[i]; + if(v.getImplementationType() == NodeValue.PERSISTENT_NODE) + {return null;} + } + return new ValueSequence(this); + } + + /* (non-Javadoc) + * @see org.exist.xquery.value.Sequence#removeDuplicates() + */ + public void removeDuplicates() { + // TODO: is this ever relevant? + } + + private class Entry implements Comparable { + Item item; + AtomicValue values[]; + public Entry(Item item) throws XPathException { + this.item = item; + values = new AtomicValue[groupSpecs.length]; + for(int i = 0; i < groupSpecs.length; i++) { + final Sequence seq = groupSpecs[i].getGroupExpression().eval(null); + values[i] = AtomicValue.EMPTY_VALUE; + //TODO : get rid of getLength() + if(seq.hasOne()) { + values[i] = seq.itemAt(0).atomize(); + } else if(seq.hasMany()) + {throw new XPathException("expected a single value for group by expression " + + ExpressionDumper.dump(groupSpecs[i].getGroupExpression()) + + " ; found: " + seq.getItemCount());} + } + } + + /* (non-Javadoc) + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ + public int compareTo(Entry other){ + int cmp = 0; + AtomicValue a, b; + for(int i = 0; i < values.length; i++) { + a = values[i]; + b = other.values[i]; + if(a == AtomicValue.EMPTY_VALUE && b != AtomicValue.EMPTY_VALUE) { + cmp = 1; + } + else{ + cmp = a.compareTo(b); + } + } + return cmp; + } + } + + private class GroupedValueSequenceIterator implements SequenceIterator { + int pos = 0; + /* (non-Javadoc) + * @see org.exist.xquery.value.SequenceIterator#hasNext() + */ + public boolean hasNext() { + return pos < count; + } + + /* (non-Javadoc) + * @see org.exist.xquery.value.SequenceIterator#nextItem() + */ + public Item nextItem() { + if(pos < count) { + return items[pos++].item; + } + return null; + } + } +} + diff --git a/src/org/exist/xquery/value/GroupedValueSequenceTable.java b/src/org/exist/xquery/value/GroupedValueSequenceTable.java index f194cd854c7..20cac34da5c 100644 --- a/src/org/exist/xquery/value/GroupedValueSequenceTable.java +++ b/src/org/exist/xquery/value/GroupedValueSequenceTable.java @@ -1,119 +1,119 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-06 The eXist Project - * http://exist-db.org - * http://exist.sourceforge.net - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id$ - */ -package org.exist.xquery.value; - -import java.util.Hashtable; -import java.util.Iterator; - -import org.exist.xquery.ErrorCodes; -import org.exist.xquery.GroupSpec; -import org.exist.xquery.XPathException; -import org.exist.xquery.XQueryContext; - -/** - * An Hashtable that containts a GroupedValueSequence for each group. Groups are - * specified by the group specs of a "group by" clause. Used by - * {@link org.exist.xquery.ForExpr} et al. - * - * WARNING : don't use except for experimental "group by" clause - * - * @author Boris Verhaegen (boris.verhaegen@gmail.com) - */ - -public class GroupedValueSequenceTable extends - Hashtable { - - private static final long serialVersionUID = 1324942298919800292L; - - private GroupSpec groupSpecs[]; - private String toGroupVarName; - private XQueryContext context; - - public GroupedValueSequenceTable(GroupSpec groupSpecs[], String varName, XQueryContext aContext) { - super(11, (float) 0.75); // Hashtable parameters - this.groupSpecs = groupSpecs; - this.toGroupVarName = varName; - this.context = aContext; //UNDERSTAND: do we need context here??? -shabanovd - } - - public void setToGroupVarName(String varName) { - toGroupVarName = varName; - } - - public String getToGroupVarName() { - return toGroupVarName; - } - - public Iterator iterate() { - return this.keySet().iterator(); - } - - /** - * Add item in the correct GroupedValueSequence. - * Create correct GroupedValueSequence if needed. Insertion based on the - * group specs of a "group by" clause. - * - * @throws XPathException - */ - public void add(Item item) throws XPathException { - final Sequence specEvaluation[] = new Sequence[groupSpecs.length]; - final ValueSequence keySequence = new ValueSequence(); - - for (int i = 0; i < groupSpecs.length; i++) { - // evaluates the values of the grouping keys - specEvaluation[i] = groupSpecs[i].getGroupExpression().eval(item.toSequence()); // TODO : too early evaluation ! - - if (specEvaluation[i].isEmpty()) - {keySequence.add(AtomicValue.EMPTY_VALUE);} - else if (specEvaluation[i].hasOne()) - {keySequence.add(specEvaluation[i].itemAt(0));} - else - {throw new XPathException(groupSpecs[i].getGroupExpression(), ErrorCodes.XPTY0004, "More that one key values", specEvaluation[i]);} - } - - final String hashKey = keySequence.getHashKey(); - - if (this.containsKey(hashKey)) { - final GroupedValueSequence currentGroup = super.get(hashKey); - currentGroup.add(item); - } else { - // this group doesn't exists, then creates this group - final GroupedValueSequence newGroup = new GroupedValueSequence( - groupSpecs, 1, keySequence, context); - newGroup.add(item); - super.put(hashKey, newGroup); - } - } - - /** - * Add all items of a sequence - * - * @param sequence - * @throws XPathException - */ - public void addAll(Sequence sequence) throws XPathException { - for (final SequenceIterator i = sequence.iterate(); i.hasNext();) { - this.add(i.nextItem()); - } - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-06 The eXist Project + * http://exist-db.org + * http://exist.sourceforge.net + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ +package org.exist.xquery.value; + +import java.util.Hashtable; +import java.util.Iterator; + +import org.exist.xquery.ErrorCodes; +import org.exist.xquery.GroupSpec; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQueryContext; + +/** + * An Hashtable that containts a GroupedValueSequence for each group. Groups are + * specified by the group specs of a "group by" clause. Used by + * {@link org.exist.xquery.ForExpr} et al. + * + * WARNING : don't use except for experimental "group by" clause + * + * @author Boris Verhaegen (boris.verhaegen@gmail.com) + */ + +public class GroupedValueSequenceTable extends + Hashtable { + + private static final long serialVersionUID = 1324942298919800292L; + + private GroupSpec groupSpecs[]; + private String toGroupVarName; + private XQueryContext context; + + public GroupedValueSequenceTable(GroupSpec groupSpecs[], String varName, XQueryContext aContext) { + super(11, (float) 0.75); // Hashtable parameters + this.groupSpecs = groupSpecs; + this.toGroupVarName = varName; + this.context = aContext; //UNDERSTAND: do we need context here??? -shabanovd + } + + public void setToGroupVarName(String varName) { + toGroupVarName = varName; + } + + public String getToGroupVarName() { + return toGroupVarName; + } + + public Iterator iterate() { + return this.keySet().iterator(); + } + + /** + * Add item in the correct GroupedValueSequence. + * Create correct GroupedValueSequence if needed. Insertion based on the + * group specs of a "group by" clause. + * + * @throws XPathException + */ + public void add(Item item) throws XPathException { + final Sequence specEvaluation[] = new Sequence[groupSpecs.length]; + final ValueSequence keySequence = new ValueSequence(); + + for (int i = 0; i < groupSpecs.length; i++) { + // evaluates the values of the grouping keys + specEvaluation[i] = groupSpecs[i].getGroupExpression().eval(item.toSequence()); // TODO : too early evaluation ! + + if (specEvaluation[i].isEmpty()) + {keySequence.add(AtomicValue.EMPTY_VALUE);} + else if (specEvaluation[i].hasOne()) + {keySequence.add(specEvaluation[i].itemAt(0));} + else + {throw new XPathException(groupSpecs[i].getGroupExpression(), ErrorCodes.XPTY0004, "More that one key values", specEvaluation[i]);} + } + + final String hashKey = keySequence.getHashKey(); + + if (this.containsKey(hashKey)) { + final GroupedValueSequence currentGroup = super.get(hashKey); + currentGroup.add(item); + } else { + // this group doesn't exists, then creates this group + final GroupedValueSequence newGroup = new GroupedValueSequence( + groupSpecs, 1, keySequence, context); + newGroup.add(item); + super.put(hashKey, newGroup); + } + } + + /** + * Add all items of a sequence + * + * @param sequence + * @throws XPathException + */ + public void addAll(Sequence sequence) throws XPathException { + for (final SequenceIterator i = sequence.iterate(); i.hasNext();) { + this.add(i.nextItem()); + } + } +} diff --git a/test/src/org/exist/backup/SystemExportImportTest.java b/test/src/org/exist/backup/SystemExportImportTest.java index c5222607e96..f6dfa3f8969 100644 --- a/test/src/org/exist/backup/SystemExportImportTest.java +++ b/test/src/org/exist/backup/SystemExportImportTest.java @@ -1,282 +1,282 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2012 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.backup; - -import static org.junit.Assert.*; - -import java.io.File; -import java.util.Properties; - -import javax.xml.transform.OutputKeys; - -import org.exist.backup.SystemExport; -import org.exist.backup.SystemImport; -import org.exist.backup.restore.listener.DefaultRestoreListener; -import org.exist.backup.restore.listener.RestoreListener; -import org.exist.collections.Collection; -import org.exist.collections.CollectionConfigurationManager; -import org.exist.collections.IndexInfo; -import org.exist.dom.DocumentImpl; -import org.exist.security.PermissionDeniedException; -import org.exist.storage.BrokerPool; -import org.exist.storage.DBBroker; -import org.exist.storage.serializers.EXistOutputKeys; -import org.exist.storage.serializers.Serializer; -import org.exist.storage.txn.TransactionManager; -import org.exist.storage.txn.Txn; -import org.exist.test.TestConstants; -import org.exist.util.Configuration; -import org.exist.util.ConfigurationHelper; -import org.exist.xmldb.XmldbURI; -import org.junit.Test; -import org.xml.sax.SAXException; -import org.xmldb.api.DatabaseManager; -import org.xmldb.api.base.Database; - -/** - * @author Dmitriy Shabanov - * - */ -public class SystemExportImportTest { - - private static String COLLECTION_CONFIG = - "" + - " " + - " " + - ""; - - private static XmldbURI col1uri = TestConstants.TEST_COLLECTION_URI; - - private static XmldbURI doc01uri = col1uri.append("test1.xml"); - private static XmldbURI doc02uri = col1uri.append("test2.xml"); - private static XmldbURI doc03uri = col1uri.append("test3.xml"); - private static XmldbURI doc11uri = col1uri.append("test.binary"); - - private static String XML1 = ""; - private static String XML2 = - "\n" + - ""; - private static String XML2_PROPER = - "\n" + - ""; - - - private static String XML3 = ""; - private static String XML3_PROPER = "\n"; - - private static String BINARY = "test"; - - private static BrokerPool pool; - - @Test - public void test_01() throws Exception { - System.out.println("test_01"); - - startDB(); - - File file; - - DBBroker broker = null; - try { - broker = pool.get(pool.getSecurityManager().getSystemSubject()); - assertNotNull(broker); - - Collection root = broker.getCollection(col1uri); - assertNotNull(root); - - SystemExport sysexport = new SystemExport( broker, null, null, true ); - file = sysexport.export( "backup", false, false, null ); - } finally { - pool.release(broker); - } - - clean(); - - //check that it clean - broker = null; - try { - broker = pool.get(pool.getSecurityManager().getSystemSubject()); - - Collection col = broker.getCollection(col1uri); - assertNull(col); - } finally { - pool.release(broker); - } - - SystemImport restore = new SystemImport(pool); - RestoreListener listener = new DefaultRestoreListener(); - restore.restore(listener, "admin", "", "", file, "xmldb:exist://"); - - broker = null; - try { - broker = pool.get(pool.getSecurityManager().getSystemSubject()); - assertNotNull(broker); - - Collection col = broker.getCollection(col1uri); - assertNotNull(col); - - DocumentImpl doc = getDoc(broker, col, doc01uri.lastSegment()); - assertEquals(XML1, serializer(broker, doc)); - - doc = getDoc(broker, col, doc02uri.lastSegment()); - assertEquals(XML2_PROPER, serializer(broker, doc)); - - doc = getDoc(broker, col, doc03uri.lastSegment()); - assertEquals(XML3_PROPER, serializer(broker, doc)); - - } finally { - pool.release(broker); - } - - BrokerPool.stopAll(false); - } - - private DocumentImpl getDoc(DBBroker broker, Collection col, XmldbURI uri) throws PermissionDeniedException { - DocumentImpl doc = col.getDocument(broker, uri); - assertNotNull(doc); - - return doc; - } - - public Properties contentsOutputProps = new Properties(); - { - contentsOutputProps.setProperty( OutputKeys.INDENT, "yes" ); - contentsOutputProps.setProperty( EXistOutputKeys.OUTPUT_DOCTYPE, "yes" ); - } - - private String serializer(DBBroker broker, DocumentImpl document) throws SAXException { - Serializer serializer = broker.getSerializer(); - serializer.setUser(broker.getSubject()); - serializer.setProperties(contentsOutputProps); - return serializer.serialize(document); - } - - //@BeforeClass - public static void startDB() { - DBBroker broker = null; - TransactionManager transact = null; - Txn transaction = null; - try { - File confFile = ConfigurationHelper.lookup("conf.xml"); - Configuration config = new Configuration(confFile.getAbsolutePath()); - BrokerPool.configure(1, 5, config); - pool = BrokerPool.getInstance(); - assertNotNull(pool); - pool.getPluginsManager().addPlugin("org.exist.storage.md.Plugin"); - - broker = pool.get(pool.getSecurityManager().getSystemSubject()); - assertNotNull(broker); - transact = pool.getTransactionManager(); - assertNotNull(transact); - transaction = transact.beginTransaction(); - assertNotNull(transaction); - System.out.println("Transaction started ..."); - - Collection root = broker.getOrCreateCollection(transaction, col1uri); - assertNotNull(root); - broker.saveCollection(transaction, root); - - CollectionConfigurationManager mgr = pool.getConfigurationManager(); - mgr.addConfiguration(transaction, broker, root, COLLECTION_CONFIG); - - System.out.println("store "+doc01uri); - IndexInfo info = root.validateXMLResource(transaction, broker, doc01uri.lastSegment(), XML1); - assertNotNull(info); - root.store(transaction, broker, info, XML1, false); - - System.out.println("store "+doc02uri); - info = root.validateXMLResource(transaction, broker, doc02uri.lastSegment(), XML2); - assertNotNull(info); - root.store(transaction, broker, info, XML2, false); - - System.out.println("store "+doc03uri); - info = root.validateXMLResource(transaction, broker, doc03uri.lastSegment(), XML3); - assertNotNull(info); - root.store(transaction, broker, info, XML3, false); - - System.out.println("store "+doc11uri); - root.addBinaryResource(transaction, broker, doc11uri.lastSegment(), BINARY.getBytes(), null); - - transact.commit(transaction); - } catch (Exception e) { - e.printStackTrace(); - transact.abort(transaction); - fail(e.getMessage()); - } finally { - if (pool != null) - pool.release(broker); - } - - rundb(); - } - - - private static void rundb() { - try { - Class cl = Class.forName("org.exist.xmldb.DatabaseImpl"); - Database database = (Database) cl.newInstance(); - database.setProperty("create-database", "true"); - DatabaseManager.registerDatabase(database); - } catch (Exception e) { - e.printStackTrace(); - } - } - - //@AfterClass - public static void cleanup() { - clean(); - BrokerPool.stopAll(false); - pool = null; - System.out.println("stoped"); - } - - private static void clean() { - System.out.println("CLEANING..."); - DBBroker broker = null; - TransactionManager transact = null; - Txn transaction = null; - try { - broker = pool.get(pool.getSecurityManager().getSystemSubject()); - assertNotNull(broker); - transact = pool.getTransactionManager(); - assertNotNull(transact); - transaction = transact.beginTransaction(); - assertNotNull(transaction); - System.out.println("Transaction started ..."); - - Collection root = broker.getOrCreateCollection(transaction, col1uri); - assertNotNull(root); - broker.removeCollection(transaction, root); - - transact.commit(transaction); - } catch (Exception e) { - transact.abort(transaction); - e.printStackTrace(); - fail(e.getMessage()); - } finally { - if (pool != null) pool.release(broker); - } - System.out.println("CLEANED."); - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2012 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.backup; + +import static org.junit.Assert.*; + +import java.io.File; +import java.util.Properties; + +import javax.xml.transform.OutputKeys; + +import org.exist.backup.SystemExport; +import org.exist.backup.SystemImport; +import org.exist.backup.restore.listener.DefaultRestoreListener; +import org.exist.backup.restore.listener.RestoreListener; +import org.exist.collections.Collection; +import org.exist.collections.CollectionConfigurationManager; +import org.exist.collections.IndexInfo; +import org.exist.dom.DocumentImpl; +import org.exist.security.PermissionDeniedException; +import org.exist.storage.BrokerPool; +import org.exist.storage.DBBroker; +import org.exist.storage.serializers.EXistOutputKeys; +import org.exist.storage.serializers.Serializer; +import org.exist.storage.txn.TransactionManager; +import org.exist.storage.txn.Txn; +import org.exist.test.TestConstants; +import org.exist.util.Configuration; +import org.exist.util.ConfigurationHelper; +import org.exist.xmldb.XmldbURI; +import org.junit.Test; +import org.xml.sax.SAXException; +import org.xmldb.api.DatabaseManager; +import org.xmldb.api.base.Database; + +/** + * @author Dmitriy Shabanov + * + */ +public class SystemExportImportTest { + + private static String COLLECTION_CONFIG = + "" + + " " + + " " + + ""; + + private static XmldbURI col1uri = TestConstants.TEST_COLLECTION_URI; + + private static XmldbURI doc01uri = col1uri.append("test1.xml"); + private static XmldbURI doc02uri = col1uri.append("test2.xml"); + private static XmldbURI doc03uri = col1uri.append("test3.xml"); + private static XmldbURI doc11uri = col1uri.append("test.binary"); + + private static String XML1 = ""; + private static String XML2 = + "\n" + + ""; + private static String XML2_PROPER = + "\n" + + ""; + + + private static String XML3 = ""; + private static String XML3_PROPER = "\n"; + + private static String BINARY = "test"; + + private static BrokerPool pool; + + @Test + public void test_01() throws Exception { + System.out.println("test_01"); + + startDB(); + + File file; + + DBBroker broker = null; + try { + broker = pool.get(pool.getSecurityManager().getSystemSubject()); + assertNotNull(broker); + + Collection root = broker.getCollection(col1uri); + assertNotNull(root); + + SystemExport sysexport = new SystemExport( broker, null, null, true ); + file = sysexport.export( "backup", false, false, null ); + } finally { + pool.release(broker); + } + + clean(); + + //check that it clean + broker = null; + try { + broker = pool.get(pool.getSecurityManager().getSystemSubject()); + + Collection col = broker.getCollection(col1uri); + assertNull(col); + } finally { + pool.release(broker); + } + + SystemImport restore = new SystemImport(pool); + RestoreListener listener = new DefaultRestoreListener(); + restore.restore(listener, "admin", "", "", file, "xmldb:exist://"); + + broker = null; + try { + broker = pool.get(pool.getSecurityManager().getSystemSubject()); + assertNotNull(broker); + + Collection col = broker.getCollection(col1uri); + assertNotNull(col); + + DocumentImpl doc = getDoc(broker, col, doc01uri.lastSegment()); + assertEquals(XML1, serializer(broker, doc)); + + doc = getDoc(broker, col, doc02uri.lastSegment()); + assertEquals(XML2_PROPER, serializer(broker, doc)); + + doc = getDoc(broker, col, doc03uri.lastSegment()); + assertEquals(XML3_PROPER, serializer(broker, doc)); + + } finally { + pool.release(broker); + } + + BrokerPool.stopAll(false); + } + + private DocumentImpl getDoc(DBBroker broker, Collection col, XmldbURI uri) throws PermissionDeniedException { + DocumentImpl doc = col.getDocument(broker, uri); + assertNotNull(doc); + + return doc; + } + + public Properties contentsOutputProps = new Properties(); + { + contentsOutputProps.setProperty( OutputKeys.INDENT, "yes" ); + contentsOutputProps.setProperty( EXistOutputKeys.OUTPUT_DOCTYPE, "yes" ); + } + + private String serializer(DBBroker broker, DocumentImpl document) throws SAXException { + Serializer serializer = broker.getSerializer(); + serializer.setUser(broker.getSubject()); + serializer.setProperties(contentsOutputProps); + return serializer.serialize(document); + } + + //@BeforeClass + public static void startDB() { + DBBroker broker = null; + TransactionManager transact = null; + Txn transaction = null; + try { + File confFile = ConfigurationHelper.lookup("conf.xml"); + Configuration config = new Configuration(confFile.getAbsolutePath()); + BrokerPool.configure(1, 5, config); + pool = BrokerPool.getInstance(); + assertNotNull(pool); + pool.getPluginsManager().addPlugin("org.exist.storage.md.Plugin"); + + broker = pool.get(pool.getSecurityManager().getSystemSubject()); + assertNotNull(broker); + transact = pool.getTransactionManager(); + assertNotNull(transact); + transaction = transact.beginTransaction(); + assertNotNull(transaction); + System.out.println("Transaction started ..."); + + Collection root = broker.getOrCreateCollection(transaction, col1uri); + assertNotNull(root); + broker.saveCollection(transaction, root); + + CollectionConfigurationManager mgr = pool.getConfigurationManager(); + mgr.addConfiguration(transaction, broker, root, COLLECTION_CONFIG); + + System.out.println("store "+doc01uri); + IndexInfo info = root.validateXMLResource(transaction, broker, doc01uri.lastSegment(), XML1); + assertNotNull(info); + root.store(transaction, broker, info, XML1, false); + + System.out.println("store "+doc02uri); + info = root.validateXMLResource(transaction, broker, doc02uri.lastSegment(), XML2); + assertNotNull(info); + root.store(transaction, broker, info, XML2, false); + + System.out.println("store "+doc03uri); + info = root.validateXMLResource(transaction, broker, doc03uri.lastSegment(), XML3); + assertNotNull(info); + root.store(transaction, broker, info, XML3, false); + + System.out.println("store "+doc11uri); + root.addBinaryResource(transaction, broker, doc11uri.lastSegment(), BINARY.getBytes(), null); + + transact.commit(transaction); + } catch (Exception e) { + e.printStackTrace(); + transact.abort(transaction); + fail(e.getMessage()); + } finally { + if (pool != null) + pool.release(broker); + } + + rundb(); + } + + + private static void rundb() { + try { + Class cl = Class.forName("org.exist.xmldb.DatabaseImpl"); + Database database = (Database) cl.newInstance(); + database.setProperty("create-database", "true"); + DatabaseManager.registerDatabase(database); + } catch (Exception e) { + e.printStackTrace(); + } + } + + //@AfterClass + public static void cleanup() { + clean(); + BrokerPool.stopAll(false); + pool = null; + System.out.println("stoped"); + } + + private static void clean() { + System.out.println("CLEANING..."); + DBBroker broker = null; + TransactionManager transact = null; + Txn transaction = null; + try { + broker = pool.get(pool.getSecurityManager().getSystemSubject()); + assertNotNull(broker); + transact = pool.getTransactionManager(); + assertNotNull(transact); + transaction = transact.beginTransaction(); + assertNotNull(transaction); + System.out.println("Transaction started ..."); + + Collection root = broker.getOrCreateCollection(transaction, col1uri); + assertNotNull(root); + broker.removeCollection(transaction, root); + + transact.commit(transaction); + } catch (Exception e) { + transact.abort(transaction); + e.printStackTrace(); + fail(e.getMessage()); + } finally { + if (pool != null) pool.release(broker); + } + System.out.println("CLEANED."); + } +} diff --git a/test/src/org/exist/config/mapping/MappedClass.java b/test/src/org/exist/config/mapping/MappedClass.java index c5692d4377c..d7ec1aeab9c 100644 --- a/test/src/org/exist/config/mapping/MappedClass.java +++ b/test/src/org/exist/config/mapping/MappedClass.java @@ -1,49 +1,49 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2011 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id: ConfigurableObject.java 13769 2011-02-12 17:47:00Z shabanovd $ - */ -package org.exist.config.mapping; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Dmitriy Shabanov - * - */ -public class MappedClass { - - protected String name = null; - protected String version = null; - - protected List subconfs = new ArrayList(); - - public void setName(String name) { - this.name = name; - } - - public void setVersion(String version) { - this.version = version; - } - - public void setSubclass(SubConfig subconf) { - subconfs.add(subconf); - } +/* + * eXist Open Source Native XML Database + * Copyright (C) 2011 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id: ConfigurableObject.java 13769 2011-02-12 17:47:00Z shabanovd $ + */ +package org.exist.config.mapping; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Dmitriy Shabanov + * + */ +public class MappedClass { + + protected String name = null; + protected String version = null; + + protected List subconfs = new ArrayList(); + + public void setName(String name) { + this.name = name; + } + + public void setVersion(String version) { + this.version = version; + } + + public void setSubclass(SubConfig subconf) { + subconfs.add(subconf); + } } \ No newline at end of file diff --git a/test/src/org/exist/config/mapping/Mapping.xml b/test/src/org/exist/config/mapping/Mapping.xml index c2ded827baa..d31c99fd282 100644 --- a/test/src/org/exist/config/mapping/Mapping.xml +++ b/test/src/org/exist/config/mapping/Mapping.xml @@ -1,13 +1,13 @@ - - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/test/src/org/exist/config/mapping/SubConfig.java b/test/src/org/exist/config/mapping/SubConfig.java index 34743a8e33b..af3bf39410b 100644 --- a/test/src/org/exist/config/mapping/SubConfig.java +++ b/test/src/org/exist/config/mapping/SubConfig.java @@ -1,48 +1,48 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2011 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * $Id: ConfigurableObject.java 13769 2011-02-12 17:47:00Z shabanovd $ - */ -package org.exist.config.mapping; - -/** - * @author Dmitriy Shabanov - * - */ -public class SubConfig { - - private String key = null; - private String secret = null; - - public void setKey(String key) { - this.key = key; - } - - public String getKey() { - return key; - } - - public void setSecret(String secret) { - this.secret = secret; - } - - public String getSecret() { - return secret; - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2011 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id: ConfigurableObject.java 13769 2011-02-12 17:47:00Z shabanovd $ + */ +package org.exist.config.mapping; + +/** + * @author Dmitriy Shabanov + * + */ +public class SubConfig { + + private String key = null; + private String secret = null; + + public void setKey(String key) { + this.key = key; + } + + public String getKey() { + return key; + } + + public void setSecret(String secret) { + this.secret = secret; + } + + public String getSecret() { + return secret; + } +} diff --git a/test/src/org/exist/deadlocks/GetReleaseBrokerDeadlocks.java b/test/src/org/exist/deadlocks/GetReleaseBrokerDeadlocks.java index 7af0314785a..3d39cc1f5e1 100644 --- a/test/src/org/exist/deadlocks/GetReleaseBrokerDeadlocks.java +++ b/test/src/org/exist/deadlocks/GetReleaseBrokerDeadlocks.java @@ -1,206 +1,206 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2012 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.deadlocks; - -import static org.junit.Assert.*; - -import java.util.Map; -import java.util.Random; - -import org.exist.Database; -import org.exist.security.Subject; -import org.exist.storage.BrokerPool; -import org.exist.storage.DBBroker; -import org.exist.util.Configuration; -import org.exist.xquery.FunctionFactory; -import org.junit.Ignore; -import org.junit.Test; - -/** - * @author Dmitriy Shabanov - * - */ -public class GetReleaseBrokerDeadlocks { - - private static Random rd = new Random(); - - @Test - @Ignore - public void exterServiceMode() { - try { - Configuration config = new Configuration(); - config.setProperty(FunctionFactory.PROPERTY_DISABLE_DEPRECATED_FUNCTIONS, new Boolean(false)); - BrokerPool.configure(1, 5, config); - - Database db = BrokerPool.getInstance(); - - Thread thread = new Thread(new EnterServiceMode()); - - DBBroker broker = null; - try { - broker = db.get(null); - - thread.start(); - Thread.sleep(1000); - - } finally { - System.out.println("release broker"+Thread.currentThread()); - db.release(broker); - } - - Thread.sleep(1000); - - assertFalse(thread.isAlive()); - - } catch (Exception e) { - fail(e.getMessage()); - } - } - - class EnterServiceMode implements Runnable { - - @Override - public void run() { - try { - BrokerPool db = BrokerPool.getInstance(); - - Subject subject = db.getSecurityManager().getSystemSubject(); - try { - db.enterServiceMode(subject); - System.out.println("enter servise mode "+Thread.currentThread()); - - //do something - Thread.sleep(100); - } finally { - db.exitServiceMode(subject); - } - - } catch (Exception e) { - fail(e.getMessage()); - } - } - } - - @Test - @Ignore - public void testingGetReleaseCycle() { - boolean debug = false; - try { - Configuration config = new Configuration(); - config.setProperty(FunctionFactory.PROPERTY_DISABLE_DEPRECATED_FUNCTIONS, new Boolean(false)); - BrokerPool.configure(1, 5, config); - - Database db = BrokerPool.getInstance(); - - Thread thread; - for (int i = 0; i < 1000; i++) { - thread = new Thread(new GetRelease()); - thread.start(); - Thread.sleep(rd.nextInt(250)); - - System.out.println(""+i+", "+db.countActiveBrokers()); - - if (ex != null) { - ex.printStackTrace(); - fail(ex.getMessage()); - } - - if (debug && db.countActiveBrokers() == 20) { - Map stackTraces = Thread.getAllStackTraces(); - - StringBuilder sb = new StringBuilder(); - - sb.append("************************************************\n"); - sb.append("************************************************\n"); - - for (Map.Entry entry : stackTraces.entrySet()) { - - StackTraceElement[] stacks = entry.getValue(); - - sb.append("THREAD: "); - sb.append(entry.getKey().getName()); - sb.append("\n"); - for (int n = 0; n < stacks.length; n++) { - sb.append(" "); - sb.append(stacks[n]); - sb.append("\n"); - } - } - - if (stackTraces.isEmpty()) - sb.append("No threads."); - - System.out.println(sb.toString()); - } - } - - while (db.countActiveBrokers() > 0) { - System.out.println(db.countActiveBrokers()); - Thread.sleep(100); - } - - - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - private static Throwable ex = null; - - class GetRelease implements Runnable { - - @Override - public void run() { - try { - BrokerPool db = BrokerPool.getInstance(); - - Subject subject = db.getSecurityManager().getSystemSubject(); - - DBBroker broker = null; - try { - broker = db.get(subject); - System.out.println("get broker "+Thread.currentThread()); - - //do something - Thread.sleep(rd.nextInt(5000)); - - try { - assertEquals(broker, db.get(null)); - - //do something - Thread.sleep(rd.nextInt(5000)); - } finally { - db.release(broker); - } - - } finally { - System.out.println("releasing broker "+Thread.currentThread()); - db.release(broker); - } - - } catch (Throwable e) { - ex = e; - } - } - } +/* + * eXist Open Source Native XML Database + * Copyright (C) 2012 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.deadlocks; + +import static org.junit.Assert.*; + +import java.util.Map; +import java.util.Random; + +import org.exist.Database; +import org.exist.security.Subject; +import org.exist.storage.BrokerPool; +import org.exist.storage.DBBroker; +import org.exist.util.Configuration; +import org.exist.xquery.FunctionFactory; +import org.junit.Ignore; +import org.junit.Test; + +/** + * @author Dmitriy Shabanov + * + */ +public class GetReleaseBrokerDeadlocks { + + private static Random rd = new Random(); + + @Test + @Ignore + public void exterServiceMode() { + try { + Configuration config = new Configuration(); + config.setProperty(FunctionFactory.PROPERTY_DISABLE_DEPRECATED_FUNCTIONS, new Boolean(false)); + BrokerPool.configure(1, 5, config); + + Database db = BrokerPool.getInstance(); + + Thread thread = new Thread(new EnterServiceMode()); + + DBBroker broker = null; + try { + broker = db.get(null); + + thread.start(); + Thread.sleep(1000); + + } finally { + System.out.println("release broker"+Thread.currentThread()); + db.release(broker); + } + + Thread.sleep(1000); + + assertFalse(thread.isAlive()); + + } catch (Exception e) { + fail(e.getMessage()); + } + } + + class EnterServiceMode implements Runnable { + + @Override + public void run() { + try { + BrokerPool db = BrokerPool.getInstance(); + + Subject subject = db.getSecurityManager().getSystemSubject(); + try { + db.enterServiceMode(subject); + System.out.println("enter servise mode "+Thread.currentThread()); + + //do something + Thread.sleep(100); + } finally { + db.exitServiceMode(subject); + } + + } catch (Exception e) { + fail(e.getMessage()); + } + } + } + + @Test + @Ignore + public void testingGetReleaseCycle() { + boolean debug = false; + try { + Configuration config = new Configuration(); + config.setProperty(FunctionFactory.PROPERTY_DISABLE_DEPRECATED_FUNCTIONS, new Boolean(false)); + BrokerPool.configure(1, 5, config); + + Database db = BrokerPool.getInstance(); + + Thread thread; + for (int i = 0; i < 1000; i++) { + thread = new Thread(new GetRelease()); + thread.start(); + Thread.sleep(rd.nextInt(250)); + + System.out.println(""+i+", "+db.countActiveBrokers()); + + if (ex != null) { + ex.printStackTrace(); + fail(ex.getMessage()); + } + + if (debug && db.countActiveBrokers() == 20) { + Map stackTraces = Thread.getAllStackTraces(); + + StringBuilder sb = new StringBuilder(); + + sb.append("************************************************\n"); + sb.append("************************************************\n"); + + for (Map.Entry entry : stackTraces.entrySet()) { + + StackTraceElement[] stacks = entry.getValue(); + + sb.append("THREAD: "); + sb.append(entry.getKey().getName()); + sb.append("\n"); + for (int n = 0; n < stacks.length; n++) { + sb.append(" "); + sb.append(stacks[n]); + sb.append("\n"); + } + } + + if (stackTraces.isEmpty()) + sb.append("No threads."); + + System.out.println(sb.toString()); + } + } + + while (db.countActiveBrokers() > 0) { + System.out.println(db.countActiveBrokers()); + Thread.sleep(100); + } + + + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } + + private static Throwable ex = null; + + class GetRelease implements Runnable { + + @Override + public void run() { + try { + BrokerPool db = BrokerPool.getInstance(); + + Subject subject = db.getSecurityManager().getSystemSubject(); + + DBBroker broker = null; + try { + broker = db.get(subject); + System.out.println("get broker "+Thread.currentThread()); + + //do something + Thread.sleep(rd.nextInt(5000)); + + try { + assertEquals(broker, db.get(null)); + + //do something + Thread.sleep(rd.nextInt(5000)); + } finally { + db.release(broker); + } + + } finally { + System.out.println("releasing broker "+Thread.currentThread()); + db.release(broker); + } + + } catch (Throwable e) { + ex = e; + } + } + } } \ No newline at end of file diff --git a/test/src/org/exist/dom/BasicNodeSetTest.java b/test/src/org/exist/dom/BasicNodeSetTest.java index bdf058813f2..19e8211ec42 100644 --- a/test/src/org/exist/dom/BasicNodeSetTest.java +++ b/test/src/org/exist/dom/BasicNodeSetTest.java @@ -1,507 +1,507 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2011 The eXist-db Project - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ - */ -package org.exist.dom; - -import org.exist.security.PermissionDeniedException; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.exist.EXistException; -import org.exist.collections.Collection; -import org.exist.collections.IndexInfo; -import org.exist.security.xacml.AccessContext; -import org.exist.storage.BrokerPool; -import org.exist.storage.DBBroker; -import org.exist.storage.ElementValue; -import org.exist.storage.serializers.Serializer; -import org.exist.storage.txn.TransactionManager; -import org.exist.storage.txn.Txn; -import org.exist.util.Configuration; -import org.exist.util.DatabaseConfigurationException; -import org.exist.util.XMLFilenameFilter; -import org.exist.xmldb.XmldbURI; -import org.exist.xquery.AncestorSelector; -import org.exist.xquery.ChildSelector; -import org.exist.xquery.Constants; -import org.exist.xquery.DescendantOrSelfSelector; -import org.exist.xquery.DescendantSelector; -import org.exist.xquery.NameTest; -import org.exist.xquery.NodeSelector; -import org.exist.xquery.XPathException; -import org.exist.xquery.XQuery; -import org.exist.xquery.value.Item; -import org.exist.xquery.value.NodeValue; -import org.exist.xquery.value.Sequence; -import org.exist.xquery.value.Type; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -import java.io.File; -import org.junit.Test; -import static org.junit.Assert.assertEquals; - -/** - * Test basic {@link org.exist.dom.NodeSet} operations to ensure that - * the used algorithms are correct. - * - * @author wolf - * @author Adam Retter - */ -public class BasicNodeSetTest { - - private final static String NESTED_XML = - "
" + - "
" + - "
" + - "" + - "" + - "" + - "
" + - "
" + - "" + - "
" + - "
" + - "
" + - "" + - "
" + - "
"; - - - private static BrokerPool pool = null; - private static Collection root = null; - private static DBBroker broker = null; - private static Sequence seqSpeech = null; - private static DocumentSet docs = null; - - @Test - public void childSelector() throws XPathException { - NodeSelector selector = new ChildSelector(seqSpeech.toNodeSet(), -1); - NameTest test = new NameTest(Type.ELEMENT, new QName("LINE", "")); - NodeSet set = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, seqSpeech.getDocumentSet(), test.getName(), selector); - - assertEquals(9492, set.getLength()); - } - - @Test - public void descendantOrSelfSelector() throws XPathException { - NodeSelector selector = new DescendantOrSelfSelector(seqSpeech.toNodeSet(), -1); - NameTest test = new NameTest(Type.ELEMENT, new QName("SPEECH", "")); - NodeSet set = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, seqSpeech.getDocumentSet(), test.getName(), selector); - - assertEquals(2628, set.getLength()); - } - - @Test - public void ancestorSelector() throws XPathException { - NodeSelector selector = new AncestorSelector(seqSpeech.toNodeSet(), -1, false, true); - NameTest test = new NameTest(Type.ELEMENT, new QName("ACT", "")); - NodeSet set = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, seqSpeech.getDocumentSet(), test.getName(), selector); - - assertEquals(15, set.getLength()); - } - - @Test - public void ancestorSelector_self() throws XPathException { - NodeSet ns = seqSpeech.toNodeSet(); - NodeSelector selector = new AncestorSelector(ns, -1, true, true); - NameTest test = new NameTest(Type.ELEMENT, new QName("SPEECH", "")); - NodeSet set = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, seqSpeech.getDocumentSet(), test.getName(), selector); - - assertEquals(2628, set.getLength()); - } - - @Test - public void descendantSelector() throws XPathException, SAXException, PermissionDeniedException { - Sequence seq = executeQuery(broker, "//SCENE", 72, null); - NameTest test = new NameTest(Type.ELEMENT, new QName("SPEAKER", "")); - NodeSelector selector = new DescendantSelector(seq.toNodeSet(), -1); - NodeSet set = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, seq.getDocumentSet(), test.getName(), selector); - - assertEquals(2639, set.getLength()); - } - - @Test - public void selectParentChild() throws XPathException, SAXException, PermissionDeniedException { - - NameTest test = new NameTest(Type.ELEMENT, new QName("SPEAKER", "")); - NodeSet speakers = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null); - Sequence smallSet = executeQuery(broker, "//SPEECH/LINE[fn:contains(., 'perturbed spirit')]/ancestor::SPEECH", 1, null); - - NodeSet result = NodeSetHelper.selectParentChild(speakers, smallSet.toNodeSet(), NodeSet.DESCENDANT, -1); - assertEquals(1, result.getLength()); - String value = serialize(broker, result.itemAt(0)); - assertEquals(value, "HAMLET"); - } - - @Test - public void selectParentChild_2() throws XPathException, SAXException, PermissionDeniedException { - NameTest test = new NameTest(Type.ELEMENT, new QName("SPEAKER", "")); - NodeSet speakers = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null); - Sequence largeSet = executeQuery(broker, "//SPEECH/LINE[fn:contains(., 'love')]/ancestor::SPEECH", 187, null); - - NodeSet result = NodeSetHelper.selectParentChild(speakers, largeSet.toNodeSet(), NodeSet.DESCENDANT, -1); - assertEquals(187, result.getLength()); - } - - @Test - public void selectAncestorDescendant() throws XPathException, SAXException, PermissionDeniedException{ - NameTest test = new NameTest(Type.ELEMENT, new QName("SPEAKER", "")); - NodeSet speakers = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null); - Sequence outerSet = executeQuery(broker, "//SCENE/TITLE[fn:contains(., 'closet')]/ancestor::SCENE", 1, null); - - NodeSet result = speakers.selectAncestorDescendant(outerSet.toNodeSet(), NodeSet.DESCENDANT, false, -1, true); - assertEquals(56, result.getLength()); - } - - @Test - public void selectAncestorDescendant_2() throws XPathException, SAXException, PermissionDeniedException{ - Sequence outerSet = executeQuery(broker, "//SCENE/TITLE[fn:contains(., 'closet')]/ancestor::SCENE", 1, null); - - NodeSet result = ((AbstractNodeSet)outerSet).selectAncestorDescendant(outerSet.toNodeSet(), NodeSet.DESCENDANT, true, -1, true); - assertEquals(1, result.getLength()); - } - - - @Test - public void getParents() throws XPathException, SAXException, PermissionDeniedException{ - Sequence largeSet = executeQuery(broker, "//SPEECH/LINE[fn:contains(., 'love')]/ancestor::SPEECH", 187, null); - - NodeSet result = ((AbstractNodeSet)largeSet).getParents(-1); - assertEquals(51, result.getLength()); - } - - @Test - public void selectAncestors() throws XPathException, SAXException, PermissionDeniedException { - NameTest test = new NameTest(Type.ELEMENT, new QName("SCENE", "")); - NodeSet scenes = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null); - Sequence largeSet = executeQuery(broker, "//SPEECH/LINE[fn:contains(., 'love')]/ancestor::SPEECH", 187, null); - - NodeSet result = ((AbstractNodeSet)scenes).selectAncestors(largeSet.toNodeSet(), false, -1); - assertEquals(49, result.getLength()); - } - - @Test - public void nodeProxy_getParents() throws XPathException, SAXException, PermissionDeniedException { - Sequence smallSet = executeQuery(broker, "//SPEECH/LINE[fn:contains(., 'perturbed spirit')]/ancestor::SPEECH", 1, null); - - NodeProxy proxy = (NodeProxy) smallSet.itemAt(0); - - NodeSet result = proxy.getParents(-1); - assertEquals(1, result.getLength()); - - NameTest test = new NameTest(Type.ELEMENT, new QName("SPEAKER", "")); - NodeSet speakers = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null); - - result = speakers.selectParentChild(proxy, NodeSet.DESCENDANT, -1); - assertEquals(1, result.getLength()); - } - - @Test - public void selectFollowingSiblings() throws XPathException, SAXException, PermissionDeniedException { - Sequence largeSet = executeQuery(broker, "//SPEECH/LINE[fn:contains(., 'love')]/ancestor::SPEECH/SPEAKER", 187, null); - NameTest test = new NameTest(Type.ELEMENT, new QName("LINE", "")); - NodeSet lines = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null); - - NodeSet result = ((AbstractNodeSet) lines).selectFollowingSiblings(largeSet.toNodeSet(), -1); - assertEquals(1689, result.getLength()); - } - - @Test - public void selectPrecedingSiblings() throws XPathException, SAXException, PermissionDeniedException { - NameTest test = new NameTest(Type.ELEMENT, new QName("SPEAKER", "")); - NodeSet speakers = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null); - Sequence largeSet = executeQuery(broker, "//SPEECH/LINE[fn:contains(., 'love')]/ancestor::SPEECH/LINE[1]", 187, null); - - NodeSet result = ((AbstractNodeSet) speakers).selectPrecedingSiblings(largeSet.toNodeSet(), -1); - assertEquals(187, result.getLength()); - } - - @Test - public void extArrayNodeSet_selectParentChild_1() throws XPathException, SAXException, PermissionDeniedException { - Sequence nestedSet = executeQuery(broker, "//section[@n = ('1.1', '1.1.1')]", 2, null); - NameTest test = new NameTest(Type.ELEMENT, new QName("para", "")); - NodeSet children = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null); - - NodeSet result = children.selectParentChild(nestedSet.toNodeSet(), NodeSet.DESCENDANT); - assertEquals(3, result.getLength()); - } - - @Test - public void extArrayNodeSet_selectParentChild_2() throws XPathException, SAXException, PermissionDeniedException { - Sequence nestedSet = executeQuery(broker, "//section[@n = ('1.1', '1.1.2', '1.2')]", 3, null); - NameTest test = new NameTest(Type.ELEMENT, new QName("para", "")); - NodeSet children = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null); - - NodeSet result = children.selectParentChild(nestedSet.toNodeSet(), NodeSet.DESCENDANT); - assertEquals(2, result.getLength()); - } - - @Test - public void extArrayNodeSet_selectParentChild_3() throws XPathException, SAXException, PermissionDeniedException { - Sequence nestedSet = executeQuery(broker, "//section[@n = ('1.1', '1.1.1', '1.2')]", 3, null); - NameTest test = new NameTest(Type.ELEMENT, new QName("para", "")); - NodeSet children = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null); - - NodeSet result = children.selectParentChild(nestedSet.toNodeSet(), NodeSet.DESCENDANT); - assertEquals(4, result.getLength()); - } - - @Test - public void extArrayNodeSet_selectParentChild_4() throws XPathException, SAXException, PermissionDeniedException { - Sequence nestedSet = executeQuery(broker, "//para[@n = ('1.1.2.1')]", 1, null); - NameTest test = new NameTest(Type.ELEMENT, new QName("section", "")); - NodeSet sections = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null); - - NodeSet result = ((NodeSet) nestedSet).selectParentChild(sections.toNodeSet(), NodeSet.DESCENDANT); - assertEquals(1, result.getLength()); - } - - @Test - public void testOptimizations() throws XPathException, SAXException, PermissionDeniedException { - - Serializer serializer = broker.getSerializer(); - serializer.reset(); - DocumentSet docs = root.allDocs(broker, new DefaultDocumentSet(), true); - - System.out.println("------------ Testing NativeElementIndex.findChildNodesByTagName ---------"); - // parent set: 1.1.1; child set: 1.1.1.1, 1.1.1.2, 1.1.1.3, 1.1.2.1, 1.2.1 - ExtNodeSet nestedSet = (ExtNodeSet) executeQuery(broker, "//section[@n = '1.1.1']", 1, null); - NodeSet children = - broker.getStructuralIndex().findDescendantsByTagName(ElementValue.ELEMENT, - new QName("para", ""), Constants.CHILD_AXIS, docs, nestedSet, -1); - assertEquals(3, children.getLength()); - - // parent set: 1.1; child set: 1.1.1, 1.1.2 - nestedSet = (ExtNodeSet) executeQuery(broker, "//section[@n = '1.1']", 1, null); - children = - broker.getStructuralIndex().findDescendantsByTagName(ElementValue.ELEMENT, - new QName("section", ""), Constants.CHILD_AXIS, docs, nestedSet, -1); - assertEquals(2, children.getLength()); - - // parent set: 1, 1.1, 1.1.1, 1.1.2 ; child set: 1.1.1.1, 1.1.1.2, 1.1.1.3, 1.1.2.1, 1.2.1 - // problem: ancestor set contains nested nodes - nestedSet = (ExtNodeSet) executeQuery(broker, "//section[@n = ('1.1', '1.1.1', '1.1.2')]", 3, null); - children = - broker.getStructuralIndex().findDescendantsByTagName(ElementValue.ELEMENT, - new QName("para", ""), Constants.CHILD_AXIS, docs, nestedSet, -1); - assertEquals(4, children.getLength()); - - // parent set: 1.1, 1.1.2, 1.2 ; child set: 1.1.1.1, 1.1.1.2, 1.1.1.3, 1.1.2.1, 1.2.1 - // problem: ancestor set contains nested nodes - nestedSet = (ExtNodeSet) executeQuery(broker, "//section[@n = ('1.1', '1.1.2', '1.2')]", 3, null); - children = - broker.getStructuralIndex().findDescendantsByTagName(ElementValue.ELEMENT, new QName("para", ""), - Constants.CHILD_AXIS, docs, nestedSet, -1); - assertEquals(2, children.getLength()); - - nestedSet = (ExtNodeSet) executeQuery(broker, "//section[@n = '1.1']", 1, null); - children = - broker.getStructuralIndex().findDescendantsByTagName(ElementValue.ELEMENT, new QName("para", ""), - Constants.DESCENDANT_AXIS, docs, nestedSet, -1); - assertEquals(4, children.getLength()); - - nestedSet = (ExtNodeSet) executeQuery(broker, "//section[@n = '1']", 1, null); - children = - broker.getStructuralIndex().findDescendantsByTagName(ElementValue.ELEMENT, new QName("para", ""), - Constants.DESCENDANT_AXIS, docs, nestedSet, -1); - assertEquals(5, children.getLength()); - - nestedSet = (ExtNodeSet) executeQuery(broker, "//section[@n = '1.1.2']", 1, null); - children = - broker.getStructuralIndex().findDescendantsByTagName(ElementValue.ELEMENT, new QName("section", ""), - Constants.DESCENDANT_SELF_AXIS, docs, nestedSet, -1); - assertEquals(1, children.getLength()); - - nestedSet = (ExtNodeSet) executeQuery(broker, "//section[@n = '1.1.2']", 1, null); - children = - broker.getStructuralIndex().findDescendantsByTagName(ElementValue.ATTRIBUTE, new QName("n", ""), - Constants.ATTRIBUTE_AXIS, docs, nestedSet, -1); - assertEquals(1, children.getLength()); - - nestedSet = (ExtNodeSet) executeQuery(broker, "//section[@n = '1.1']", 1, null); - children = - broker.getStructuralIndex().findDescendantsByTagName(ElementValue.ATTRIBUTE, new QName("n", ""), - Constants.DESCENDANT_ATTRIBUTE_AXIS, docs, nestedSet, -1); - assertEquals(7, children.getLength()); - - System.out.println("------------ PASSED: NativeElementIndex.findChildNodesByTagName ---------"); - } - - @Test - public void virtualNodeSet_1() throws XPathException, SAXException, PermissionDeniedException { - executeQuery(broker, "//*/LINE", 9492, null); - } - - @Test - public void virtualNodeSet_2() throws XPathException, SAXException, PermissionDeniedException { - executeQuery(broker, "//*/LINE/*", 61, null); - } - - @Test - public void virtualNodeSet_3() throws XPathException, SAXException, PermissionDeniedException { - executeQuery(broker, "//*/LINE/text()", 9485, null); - } - - @Test - public void virtualNodeSet_4() throws XPathException, SAXException, PermissionDeniedException { - executeQuery(broker, "//SCENE/*/LINE", 9464, null); - } - - @Test - public void virtualNodeSet_5() throws XPathException, SAXException, PermissionDeniedException { - executeQuery(broker, "//SCENE/*[fn:contains(LINE, 'spirit')]", 30, null); - } - - @Test - public void virtualNodeSet_6() throws XPathException, SAXException, PermissionDeniedException { - executeQuery(broker, "//SCENE/*[fn:contains(LINE, 'the')]", 1313, null); - } - - @Test - public void virtualNodeSet_7() throws XPathException, SAXException, PermissionDeniedException { - executeQuery(broker, "//SCENE/*/LINE[fn:contains(., 'the')]", 3198, null); - } - - @Test - public void virtualNodeSet_8() throws XPathException, SAXException, PermissionDeniedException { - executeQuery(broker, "//SCENE[fn:contains(., 'spirit')]/ancestor::*", 16, null); - } - - @Test - public void virtualNodeSet_9() throws XPathException, SAXException, PermissionDeniedException { - executeQuery(broker, "for $s in //SCENE/*[fn:contains(LINE, 'the')] return fn:node-name($s)", 1313, null); - } - - @Test - public void virtualNodeSet_10() throws XPathException, SAXException, PermissionDeniedException { - executeQuery(broker, "//SPEECH[fn:contains(LINE, 'perturbed spirit')]/preceding-sibling::*", 65, null); - } - - @Test - public void virtualNodeSet_11() throws XPathException, SAXException, PermissionDeniedException { - executeQuery(broker, "//SPEECH[fn:contains(LINE, 'perturbed spirit')]/following-sibling::*", 1, null); - } - - private static Sequence executeQuery(DBBroker broker, String query, int expected, String expectedResult) throws XPathException, SAXException, PermissionDeniedException { - XQuery xquery = broker.getXQueryService(); - Sequence seq = xquery.execute(query, null, AccessContext.TEST); - assertEquals(expected, seq.getItemCount()); - - if (expectedResult != null) { - Item item = seq.itemAt(0); - String value = serialize(broker, item); - assertEquals(expectedResult, value); - } - return seq; - } - - private static String serialize(DBBroker broker, Item item) throws SAXException, XPathException { - Serializer serializer = broker.getSerializer(); - - serializer.reset(); - String value; - if(Type.subTypeOf(item.getType(), Type.NODE)) { - value = serializer.serialize((NodeValue) item); - } else { - value = item.getStringValue(); - } - return value; - } - - @BeforeClass - public static void setUp() throws Exception { - TransactionManager transact = null; - Txn transaction = null; - try { - pool = startDB(); - broker = pool.get(pool.getSecurityManager().getSystemSubject()); - transact = pool.getTransactionManager(); - transaction = transact.beginTransaction(); - - root = broker.getOrCreateCollection(transaction, XmldbURI.create(XmldbURI.ROOT_COLLECTION + "/test")); - broker.saveCollection(transaction, root); - - String existHome = System.getProperty("exist.home"); - File existDir = existHome==null ? new File(".") : new File(existHome); - String directory = "samples/shakespeare"; - File dir = new File(existDir, directory); - - // store some documents. - for(File f : dir.listFiles(new XMLFilenameFilter())) { - IndexInfo info = root.validateXMLResource(transaction, broker, XmldbURI.create(f.getName()), new InputSource(f.toURI().toASCIIString())); - root.store(transaction, broker, info, new InputSource(f.toURI().toASCIIString()), false); - } - - IndexInfo info = root.validateXMLResource(transaction, broker, XmldbURI.create("nested.xml"), NESTED_XML); - root.store(transaction, broker, info, NESTED_XML, false); - transact.commit(transaction); - - - //for the tests - docs = root.allDocs(broker, new DefaultDocumentSet(), true); - seqSpeech = executeQuery(broker, "//SPEECH", 2628, null); - - } catch(Exception e) { - if (pool != null) { - pool.release(broker); - BrokerPool.stopAll(false); - pool = null; - root = null; - } - throw e; - } - } - - private static BrokerPool startDB() throws DatabaseConfigurationException, EXistException { - String home, file = "conf.xml"; - home = System.getProperty("exist.home"); - if (home == null) { - home = System.getProperty("user.dir"); - } - - Configuration config = new Configuration(file, home); - BrokerPool.configure(1, 5, config); - return BrokerPool.getInstance(); - } - - @AfterClass - public static void tearDown() { - - TransactionManager transact = null; - Txn transaction = null; - try { - transact = pool.getTransactionManager(); - transaction = transact.beginTransaction(); - root = broker.getOrCreateCollection(transaction, XmldbURI.create(XmldbURI.ROOT_COLLECTION + "/test")); -// broker.removeCollection(transaction, root); - - transact.commit(transaction); - } catch(Exception e) { - if(transaction != null) { - transact.abort(transaction); - } - } finally { - if (pool != null) pool.release(broker); - } - BrokerPool.stopAll(false); - pool = null; - root = null; - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2011 The eXist-db Project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + */ +package org.exist.dom; + +import org.exist.security.PermissionDeniedException; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.exist.EXistException; +import org.exist.collections.Collection; +import org.exist.collections.IndexInfo; +import org.exist.security.xacml.AccessContext; +import org.exist.storage.BrokerPool; +import org.exist.storage.DBBroker; +import org.exist.storage.ElementValue; +import org.exist.storage.serializers.Serializer; +import org.exist.storage.txn.TransactionManager; +import org.exist.storage.txn.Txn; +import org.exist.util.Configuration; +import org.exist.util.DatabaseConfigurationException; +import org.exist.util.XMLFilenameFilter; +import org.exist.xmldb.XmldbURI; +import org.exist.xquery.AncestorSelector; +import org.exist.xquery.ChildSelector; +import org.exist.xquery.Constants; +import org.exist.xquery.DescendantOrSelfSelector; +import org.exist.xquery.DescendantSelector; +import org.exist.xquery.NameTest; +import org.exist.xquery.NodeSelector; +import org.exist.xquery.XPathException; +import org.exist.xquery.XQuery; +import org.exist.xquery.value.Item; +import org.exist.xquery.value.NodeValue; +import org.exist.xquery.value.Sequence; +import org.exist.xquery.value.Type; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +import java.io.File; +import org.junit.Test; +import static org.junit.Assert.assertEquals; + +/** + * Test basic {@link org.exist.dom.NodeSet} operations to ensure that + * the used algorithms are correct. + * + * @author wolf + * @author Adam Retter + */ +public class BasicNodeSetTest { + + private final static String NESTED_XML = + "
" + + "
" + + "
" + + "" + + "" + + "" + + "
" + + "
" + + "" + + "
" + + "
" + + "
" + + "" + + "
" + + "
"; + + + private static BrokerPool pool = null; + private static Collection root = null; + private static DBBroker broker = null; + private static Sequence seqSpeech = null; + private static DocumentSet docs = null; + + @Test + public void childSelector() throws XPathException { + NodeSelector selector = new ChildSelector(seqSpeech.toNodeSet(), -1); + NameTest test = new NameTest(Type.ELEMENT, new QName("LINE", "")); + NodeSet set = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, seqSpeech.getDocumentSet(), test.getName(), selector); + + assertEquals(9492, set.getLength()); + } + + @Test + public void descendantOrSelfSelector() throws XPathException { + NodeSelector selector = new DescendantOrSelfSelector(seqSpeech.toNodeSet(), -1); + NameTest test = new NameTest(Type.ELEMENT, new QName("SPEECH", "")); + NodeSet set = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, seqSpeech.getDocumentSet(), test.getName(), selector); + + assertEquals(2628, set.getLength()); + } + + @Test + public void ancestorSelector() throws XPathException { + NodeSelector selector = new AncestorSelector(seqSpeech.toNodeSet(), -1, false, true); + NameTest test = new NameTest(Type.ELEMENT, new QName("ACT", "")); + NodeSet set = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, seqSpeech.getDocumentSet(), test.getName(), selector); + + assertEquals(15, set.getLength()); + } + + @Test + public void ancestorSelector_self() throws XPathException { + NodeSet ns = seqSpeech.toNodeSet(); + NodeSelector selector = new AncestorSelector(ns, -1, true, true); + NameTest test = new NameTest(Type.ELEMENT, new QName("SPEECH", "")); + NodeSet set = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, seqSpeech.getDocumentSet(), test.getName(), selector); + + assertEquals(2628, set.getLength()); + } + + @Test + public void descendantSelector() throws XPathException, SAXException, PermissionDeniedException { + Sequence seq = executeQuery(broker, "//SCENE", 72, null); + NameTest test = new NameTest(Type.ELEMENT, new QName("SPEAKER", "")); + NodeSelector selector = new DescendantSelector(seq.toNodeSet(), -1); + NodeSet set = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, seq.getDocumentSet(), test.getName(), selector); + + assertEquals(2639, set.getLength()); + } + + @Test + public void selectParentChild() throws XPathException, SAXException, PermissionDeniedException { + + NameTest test = new NameTest(Type.ELEMENT, new QName("SPEAKER", "")); + NodeSet speakers = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null); + Sequence smallSet = executeQuery(broker, "//SPEECH/LINE[fn:contains(., 'perturbed spirit')]/ancestor::SPEECH", 1, null); + + NodeSet result = NodeSetHelper.selectParentChild(speakers, smallSet.toNodeSet(), NodeSet.DESCENDANT, -1); + assertEquals(1, result.getLength()); + String value = serialize(broker, result.itemAt(0)); + assertEquals(value, "HAMLET"); + } + + @Test + public void selectParentChild_2() throws XPathException, SAXException, PermissionDeniedException { + NameTest test = new NameTest(Type.ELEMENT, new QName("SPEAKER", "")); + NodeSet speakers = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null); + Sequence largeSet = executeQuery(broker, "//SPEECH/LINE[fn:contains(., 'love')]/ancestor::SPEECH", 187, null); + + NodeSet result = NodeSetHelper.selectParentChild(speakers, largeSet.toNodeSet(), NodeSet.DESCENDANT, -1); + assertEquals(187, result.getLength()); + } + + @Test + public void selectAncestorDescendant() throws XPathException, SAXException, PermissionDeniedException{ + NameTest test = new NameTest(Type.ELEMENT, new QName("SPEAKER", "")); + NodeSet speakers = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null); + Sequence outerSet = executeQuery(broker, "//SCENE/TITLE[fn:contains(., 'closet')]/ancestor::SCENE", 1, null); + + NodeSet result = speakers.selectAncestorDescendant(outerSet.toNodeSet(), NodeSet.DESCENDANT, false, -1, true); + assertEquals(56, result.getLength()); + } + + @Test + public void selectAncestorDescendant_2() throws XPathException, SAXException, PermissionDeniedException{ + Sequence outerSet = executeQuery(broker, "//SCENE/TITLE[fn:contains(., 'closet')]/ancestor::SCENE", 1, null); + + NodeSet result = ((AbstractNodeSet)outerSet).selectAncestorDescendant(outerSet.toNodeSet(), NodeSet.DESCENDANT, true, -1, true); + assertEquals(1, result.getLength()); + } + + + @Test + public void getParents() throws XPathException, SAXException, PermissionDeniedException{ + Sequence largeSet = executeQuery(broker, "//SPEECH/LINE[fn:contains(., 'love')]/ancestor::SPEECH", 187, null); + + NodeSet result = ((AbstractNodeSet)largeSet).getParents(-1); + assertEquals(51, result.getLength()); + } + + @Test + public void selectAncestors() throws XPathException, SAXException, PermissionDeniedException { + NameTest test = new NameTest(Type.ELEMENT, new QName("SCENE", "")); + NodeSet scenes = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null); + Sequence largeSet = executeQuery(broker, "//SPEECH/LINE[fn:contains(., 'love')]/ancestor::SPEECH", 187, null); + + NodeSet result = ((AbstractNodeSet)scenes).selectAncestors(largeSet.toNodeSet(), false, -1); + assertEquals(49, result.getLength()); + } + + @Test + public void nodeProxy_getParents() throws XPathException, SAXException, PermissionDeniedException { + Sequence smallSet = executeQuery(broker, "//SPEECH/LINE[fn:contains(., 'perturbed spirit')]/ancestor::SPEECH", 1, null); + + NodeProxy proxy = (NodeProxy) smallSet.itemAt(0); + + NodeSet result = proxy.getParents(-1); + assertEquals(1, result.getLength()); + + NameTest test = new NameTest(Type.ELEMENT, new QName("SPEAKER", "")); + NodeSet speakers = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null); + + result = speakers.selectParentChild(proxy, NodeSet.DESCENDANT, -1); + assertEquals(1, result.getLength()); + } + + @Test + public void selectFollowingSiblings() throws XPathException, SAXException, PermissionDeniedException { + Sequence largeSet = executeQuery(broker, "//SPEECH/LINE[fn:contains(., 'love')]/ancestor::SPEECH/SPEAKER", 187, null); + NameTest test = new NameTest(Type.ELEMENT, new QName("LINE", "")); + NodeSet lines = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null); + + NodeSet result = ((AbstractNodeSet) lines).selectFollowingSiblings(largeSet.toNodeSet(), -1); + assertEquals(1689, result.getLength()); + } + + @Test + public void selectPrecedingSiblings() throws XPathException, SAXException, PermissionDeniedException { + NameTest test = new NameTest(Type.ELEMENT, new QName("SPEAKER", "")); + NodeSet speakers = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null); + Sequence largeSet = executeQuery(broker, "//SPEECH/LINE[fn:contains(., 'love')]/ancestor::SPEECH/LINE[1]", 187, null); + + NodeSet result = ((AbstractNodeSet) speakers).selectPrecedingSiblings(largeSet.toNodeSet(), -1); + assertEquals(187, result.getLength()); + } + + @Test + public void extArrayNodeSet_selectParentChild_1() throws XPathException, SAXException, PermissionDeniedException { + Sequence nestedSet = executeQuery(broker, "//section[@n = ('1.1', '1.1.1')]", 2, null); + NameTest test = new NameTest(Type.ELEMENT, new QName("para", "")); + NodeSet children = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null); + + NodeSet result = children.selectParentChild(nestedSet.toNodeSet(), NodeSet.DESCENDANT); + assertEquals(3, result.getLength()); + } + + @Test + public void extArrayNodeSet_selectParentChild_2() throws XPathException, SAXException, PermissionDeniedException { + Sequence nestedSet = executeQuery(broker, "//section[@n = ('1.1', '1.1.2', '1.2')]", 3, null); + NameTest test = new NameTest(Type.ELEMENT, new QName("para", "")); + NodeSet children = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null); + + NodeSet result = children.selectParentChild(nestedSet.toNodeSet(), NodeSet.DESCENDANT); + assertEquals(2, result.getLength()); + } + + @Test + public void extArrayNodeSet_selectParentChild_3() throws XPathException, SAXException, PermissionDeniedException { + Sequence nestedSet = executeQuery(broker, "//section[@n = ('1.1', '1.1.1', '1.2')]", 3, null); + NameTest test = new NameTest(Type.ELEMENT, new QName("para", "")); + NodeSet children = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null); + + NodeSet result = children.selectParentChild(nestedSet.toNodeSet(), NodeSet.DESCENDANT); + assertEquals(4, result.getLength()); + } + + @Test + public void extArrayNodeSet_selectParentChild_4() throws XPathException, SAXException, PermissionDeniedException { + Sequence nestedSet = executeQuery(broker, "//para[@n = ('1.1.2.1')]", 1, null); + NameTest test = new NameTest(Type.ELEMENT, new QName("section", "")); + NodeSet sections = broker.getStructuralIndex().findElementsByTagName(ElementValue.ELEMENT, docs, test.getName(), null); + + NodeSet result = ((NodeSet) nestedSet).selectParentChild(sections.toNodeSet(), NodeSet.DESCENDANT); + assertEquals(1, result.getLength()); + } + + @Test + public void testOptimizations() throws XPathException, SAXException, PermissionDeniedException { + + Serializer serializer = broker.getSerializer(); + serializer.reset(); + DocumentSet docs = root.allDocs(broker, new DefaultDocumentSet(), true); + + System.out.println("------------ Testing NativeElementIndex.findChildNodesByTagName ---------"); + // parent set: 1.1.1; child set: 1.1.1.1, 1.1.1.2, 1.1.1.3, 1.1.2.1, 1.2.1 + ExtNodeSet nestedSet = (ExtNodeSet) executeQuery(broker, "//section[@n = '1.1.1']", 1, null); + NodeSet children = + broker.getStructuralIndex().findDescendantsByTagName(ElementValue.ELEMENT, + new QName("para", ""), Constants.CHILD_AXIS, docs, nestedSet, -1); + assertEquals(3, children.getLength()); + + // parent set: 1.1; child set: 1.1.1, 1.1.2 + nestedSet = (ExtNodeSet) executeQuery(broker, "//section[@n = '1.1']", 1, null); + children = + broker.getStructuralIndex().findDescendantsByTagName(ElementValue.ELEMENT, + new QName("section", ""), Constants.CHILD_AXIS, docs, nestedSet, -1); + assertEquals(2, children.getLength()); + + // parent set: 1, 1.1, 1.1.1, 1.1.2 ; child set: 1.1.1.1, 1.1.1.2, 1.1.1.3, 1.1.2.1, 1.2.1 + // problem: ancestor set contains nested nodes + nestedSet = (ExtNodeSet) executeQuery(broker, "//section[@n = ('1.1', '1.1.1', '1.1.2')]", 3, null); + children = + broker.getStructuralIndex().findDescendantsByTagName(ElementValue.ELEMENT, + new QName("para", ""), Constants.CHILD_AXIS, docs, nestedSet, -1); + assertEquals(4, children.getLength()); + + // parent set: 1.1, 1.1.2, 1.2 ; child set: 1.1.1.1, 1.1.1.2, 1.1.1.3, 1.1.2.1, 1.2.1 + // problem: ancestor set contains nested nodes + nestedSet = (ExtNodeSet) executeQuery(broker, "//section[@n = ('1.1', '1.1.2', '1.2')]", 3, null); + children = + broker.getStructuralIndex().findDescendantsByTagName(ElementValue.ELEMENT, new QName("para", ""), + Constants.CHILD_AXIS, docs, nestedSet, -1); + assertEquals(2, children.getLength()); + + nestedSet = (ExtNodeSet) executeQuery(broker, "//section[@n = '1.1']", 1, null); + children = + broker.getStructuralIndex().findDescendantsByTagName(ElementValue.ELEMENT, new QName("para", ""), + Constants.DESCENDANT_AXIS, docs, nestedSet, -1); + assertEquals(4, children.getLength()); + + nestedSet = (ExtNodeSet) executeQuery(broker, "//section[@n = '1']", 1, null); + children = + broker.getStructuralIndex().findDescendantsByTagName(ElementValue.ELEMENT, new QName("para", ""), + Constants.DESCENDANT_AXIS, docs, nestedSet, -1); + assertEquals(5, children.getLength()); + + nestedSet = (ExtNodeSet) executeQuery(broker, "//section[@n = '1.1.2']", 1, null); + children = + broker.getStructuralIndex().findDescendantsByTagName(ElementValue.ELEMENT, new QName("section", ""), + Constants.DESCENDANT_SELF_AXIS, docs, nestedSet, -1); + assertEquals(1, children.getLength()); + + nestedSet = (ExtNodeSet) executeQuery(broker, "//section[@n = '1.1.2']", 1, null); + children = + broker.getStructuralIndex().findDescendantsByTagName(ElementValue.ATTRIBUTE, new QName("n", ""), + Constants.ATTRIBUTE_AXIS, docs, nestedSet, -1); + assertEquals(1, children.getLength()); + + nestedSet = (ExtNodeSet) executeQuery(broker, "//section[@n = '1.1']", 1, null); + children = + broker.getStructuralIndex().findDescendantsByTagName(ElementValue.ATTRIBUTE, new QName("n", ""), + Constants.DESCENDANT_ATTRIBUTE_AXIS, docs, nestedSet, -1); + assertEquals(7, children.getLength()); + + System.out.println("------------ PASSED: NativeElementIndex.findChildNodesByTagName ---------"); + } + + @Test + public void virtualNodeSet_1() throws XPathException, SAXException, PermissionDeniedException { + executeQuery(broker, "//*/LINE", 9492, null); + } + + @Test + public void virtualNodeSet_2() throws XPathException, SAXException, PermissionDeniedException { + executeQuery(broker, "//*/LINE/*", 61, null); + } + + @Test + public void virtualNodeSet_3() throws XPathException, SAXException, PermissionDeniedException { + executeQuery(broker, "//*/LINE/text()", 9485, null); + } + + @Test + public void virtualNodeSet_4() throws XPathException, SAXException, PermissionDeniedException { + executeQuery(broker, "//SCENE/*/LINE", 9464, null); + } + + @Test + public void virtualNodeSet_5() throws XPathException, SAXException, PermissionDeniedException { + executeQuery(broker, "//SCENE/*[fn:contains(LINE, 'spirit')]", 30, null); + } + + @Test + public void virtualNodeSet_6() throws XPathException, SAXException, PermissionDeniedException { + executeQuery(broker, "//SCENE/*[fn:contains(LINE, 'the')]", 1313, null); + } + + @Test + public void virtualNodeSet_7() throws XPathException, SAXException, PermissionDeniedException { + executeQuery(broker, "//SCENE/*/LINE[fn:contains(., 'the')]", 3198, null); + } + + @Test + public void virtualNodeSet_8() throws XPathException, SAXException, PermissionDeniedException { + executeQuery(broker, "//SCENE[fn:contains(., 'spirit')]/ancestor::*", 16, null); + } + + @Test + public void virtualNodeSet_9() throws XPathException, SAXException, PermissionDeniedException { + executeQuery(broker, "for $s in //SCENE/*[fn:contains(LINE, 'the')] return fn:node-name($s)", 1313, null); + } + + @Test + public void virtualNodeSet_10() throws XPathException, SAXException, PermissionDeniedException { + executeQuery(broker, "//SPEECH[fn:contains(LINE, 'perturbed spirit')]/preceding-sibling::*", 65, null); + } + + @Test + public void virtualNodeSet_11() throws XPathException, SAXException, PermissionDeniedException { + executeQuery(broker, "//SPEECH[fn:contains(LINE, 'perturbed spirit')]/following-sibling::*", 1, null); + } + + private static Sequence executeQuery(DBBroker broker, String query, int expected, String expectedResult) throws XPathException, SAXException, PermissionDeniedException { + XQuery xquery = broker.getXQueryService(); + Sequence seq = xquery.execute(query, null, AccessContext.TEST); + assertEquals(expected, seq.getItemCount()); + + if (expectedResult != null) { + Item item = seq.itemAt(0); + String value = serialize(broker, item); + assertEquals(expectedResult, value); + } + return seq; + } + + private static String serialize(DBBroker broker, Item item) throws SAXException, XPathException { + Serializer serializer = broker.getSerializer(); + + serializer.reset(); + String value; + if(Type.subTypeOf(item.getType(), Type.NODE)) { + value = serializer.serialize((NodeValue) item); + } else { + value = item.getStringValue(); + } + return value; + } + + @BeforeClass + public static void setUp() throws Exception { + TransactionManager transact = null; + Txn transaction = null; + try { + pool = startDB(); + broker = pool.get(pool.getSecurityManager().getSystemSubject()); + transact = pool.getTransactionManager(); + transaction = transact.beginTransaction(); + + root = broker.getOrCreateCollection(transaction, XmldbURI.create(XmldbURI.ROOT_COLLECTION + "/test")); + broker.saveCollection(transaction, root); + + String existHome = System.getProperty("exist.home"); + File existDir = existHome==null ? new File(".") : new File(existHome); + String directory = "samples/shakespeare"; + File dir = new File(existDir, directory); + + // store some documents. + for(File f : dir.listFiles(new XMLFilenameFilter())) { + IndexInfo info = root.validateXMLResource(transaction, broker, XmldbURI.create(f.getName()), new InputSource(f.toURI().toASCIIString())); + root.store(transaction, broker, info, new InputSource(f.toURI().toASCIIString()), false); + } + + IndexInfo info = root.validateXMLResource(transaction, broker, XmldbURI.create("nested.xml"), NESTED_XML); + root.store(transaction, broker, info, NESTED_XML, false); + transact.commit(transaction); + + + //for the tests + docs = root.allDocs(broker, new DefaultDocumentSet(), true); + seqSpeech = executeQuery(broker, "//SPEECH", 2628, null); + + } catch(Exception e) { + if (pool != null) { + pool.release(broker); + BrokerPool.stopAll(false); + pool = null; + root = null; + } + throw e; + } + } + + private static BrokerPool startDB() throws DatabaseConfigurationException, EXistException { + String home, file = "conf.xml"; + home = System.getProperty("exist.home"); + if (home == null) { + home = System.getProperty("user.dir"); + } + + Configuration config = new Configuration(file, home); + BrokerPool.configure(1, 5, config); + return BrokerPool.getInstance(); + } + + @AfterClass + public static void tearDown() { + + TransactionManager transact = null; + Txn transaction = null; + try { + transact = pool.getTransactionManager(); + transaction = transact.beginTransaction(); + root = broker.getOrCreateCollection(transaction, XmldbURI.create(XmldbURI.ROOT_COLLECTION + "/test")); +// broker.removeCollection(transaction, root); + + transact.commit(transaction); + } catch(Exception e) { + if(transaction != null) { + transact.abort(transaction); + } + } finally { + if (pool != null) pool.release(broker); + } + BrokerPool.stopAll(false); + pool = null; + root = null; + } +} diff --git a/test/src/org/exist/dom/utf8.xml b/test/src/org/exist/dom/utf8.xml index e9ccaff6717..b820d5e24ed 100755 --- a/test/src/org/exist/dom/utf8.xml +++ b/test/src/org/exist/dom/utf8.xml @@ -1,7 +1,7 @@ - - - - - - + + + + + + \ No newline at end of file diff --git a/test/src/org/exist/http/RESTTest.java b/test/src/org/exist/http/RESTTest.java index 0601319aba4..df728156f1f 100644 --- a/test/src/org/exist/http/RESTTest.java +++ b/test/src/org/exist/http/RESTTest.java @@ -1,36 +1,36 @@ -package org.exist.http; - -import org.apache.commons.httpclient.HttpClient; -import org.exist.jetty.JettyStart; -import org.exist.xmldb.XmldbURI; -import org.junit.AfterClass; -import org.junit.BeforeClass; - -import static org.junit.Assert.fail; - -public abstract class RESTTest { - - // jetty.port.standalone - protected final static String REST_URL = "http://localhost:" + System.getProperty("jetty.port"); - protected final static String COLLECTION_ROOT_URL = REST_URL + XmldbURI.ROOT_COLLECTION; - protected static JettyStart server = null; - protected static HttpClient client = new HttpClient(); - - @BeforeClass - public static void startupServer() { - try { - if(server == null) { - server = new JettyStart(); - System.out.println("Starting standalone server..."); - server.run(); - } - } catch(Exception e) { - fail(e.getMessage()); - } - } - - @AfterClass - public static void shutdownServer() { - server.shutdown(); - } -} +package org.exist.http; + +import org.apache.commons.httpclient.HttpClient; +import org.exist.jetty.JettyStart; +import org.exist.xmldb.XmldbURI; +import org.junit.AfterClass; +import org.junit.BeforeClass; + +import static org.junit.Assert.fail; + +public abstract class RESTTest { + + // jetty.port.standalone + protected final static String REST_URL = "http://localhost:" + System.getProperty("jetty.port"); + protected final static String COLLECTION_ROOT_URL = REST_URL + XmldbURI.ROOT_COLLECTION; + protected static JettyStart server = null; + protected static HttpClient client = new HttpClient(); + + @BeforeClass + public static void startupServer() { + try { + if(server == null) { + server = new JettyStart(); + System.out.println("Starting standalone server..."); + server.run(); + } + } catch(Exception e) { + fail(e.getMessage()); + } + } + + @AfterClass + public static void shutdownServer() { + server.shutdown(); + } +} diff --git a/test/src/org/exist/performance/actions/XUpdateAction.java b/test/src/org/exist/performance/actions/XUpdateAction.java index 0f4f242a833..dd152dbb9ae 100644 --- a/test/src/org/exist/performance/actions/XUpdateAction.java +++ b/test/src/org/exist/performance/actions/XUpdateAction.java @@ -1,53 +1,53 @@ -package org.exist.performance.actions; - -import org.exist.performance.AbstractAction; -import org.exist.performance.Runner; -import org.exist.performance.Connection; -import org.exist.EXistException; -import org.w3c.dom.Element; -import org.xmldb.api.base.XMLDBException; -import org.xmldb.api.base.Collection; -import org.xmldb.api.modules.XUpdateQueryService; - -/** - * Created by IntelliJ IDEA. - * User: wolf - * Date: 05.02.2007 - * Time: 12:21:01 - * To change this template use File | Settings | File Templates. - */ -public class XUpdateAction extends AbstractAction { - - private String collectionPath; - private String resource = null; - private String xupdate; - private int modifications = 0; - - public void configure(Runner runner, Action parent, Element config) throws EXistException { - super.configure(runner, parent, config); - if (!config.hasAttribute("collection")) - throw new EXistException(StoreFromFile.class.getName() + " requires an attribute 'collection'"); - collectionPath = config.getAttribute("collection"); - if (config.hasAttribute("resource")) - resource = config.getAttribute("resource"); - - xupdate = getContent(config); - } - - public void execute(Connection connection) throws XMLDBException, EXistException { - Collection collection = connection.getCollection(collectionPath); - if (collection == null) - throw new EXistException("collection " + collectionPath + " not found"); - XUpdateQueryService service = (XUpdateQueryService) collection.getService("XUpdateQueryService", "1.0"); - - if (resource == null) { - modifications = (int) service.update(xupdate); - } else { - modifications = (int) service.updateResource(resource, xupdate); - } - } - - public String getLastResult() { - return Integer.toString(modifications); - } -} +package org.exist.performance.actions; + +import org.exist.performance.AbstractAction; +import org.exist.performance.Runner; +import org.exist.performance.Connection; +import org.exist.EXistException; +import org.w3c.dom.Element; +import org.xmldb.api.base.XMLDBException; +import org.xmldb.api.base.Collection; +import org.xmldb.api.modules.XUpdateQueryService; + +/** + * Created by IntelliJ IDEA. + * User: wolf + * Date: 05.02.2007 + * Time: 12:21:01 + * To change this template use File | Settings | File Templates. + */ +public class XUpdateAction extends AbstractAction { + + private String collectionPath; + private String resource = null; + private String xupdate; + private int modifications = 0; + + public void configure(Runner runner, Action parent, Element config) throws EXistException { + super.configure(runner, parent, config); + if (!config.hasAttribute("collection")) + throw new EXistException(StoreFromFile.class.getName() + " requires an attribute 'collection'"); + collectionPath = config.getAttribute("collection"); + if (config.hasAttribute("resource")) + resource = config.getAttribute("resource"); + + xupdate = getContent(config); + } + + public void execute(Connection connection) throws XMLDBException, EXistException { + Collection collection = connection.getCollection(collectionPath); + if (collection == null) + throw new EXistException("collection " + collectionPath + " not found"); + XUpdateQueryService service = (XUpdateQueryService) collection.getService("XUpdateQueryService", "1.0"); + + if (resource == null) { + modifications = (int) service.update(xupdate); + } else { + modifications = (int) service.updateResource(resource, xupdate); + } + } + + public String getLastResult() { + return Integer.toString(modifications); + } +} diff --git a/test/src/org/exist/performance/test.xml b/test/src/org/exist/performance/test.xml index ef11e9c7f94..91d43a94a61 100644 --- a/test/src/org/exist/performance/test.xml +++ b/test/src/org/exist/performance/test.xml @@ -1,519 +1,519 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { $mods/mods:* } - - ]]> - - - { $mods/mods:titleInfo/mods:* } - - ]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Description {$current} - {$current + 1.0} - {$current * 10} - - into /products - ]]> - - - Description {$current} - {$current + 1.0} - {$current * 10} - - preceding //product[1] - ]]> - - Description {$current} - {$current + 1.0} - {$current * 10} - - following //product[1] - ]]> - - - - 10,1) - ]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - declare namespace imdi="http://www.mpi.nl/IMDI/Schema/IMDI"; - for $i in //imdi:Session[contains(imdi:Name, 'drum')] - order by $i/imdi:Name - return $i/imdi:Name - - - - - declare namespace imdi="http://www.mpi.nl/IMDI/Schema/IMDI"; - for $i in //imdi:Session[contains(imdi:Name, 'lake')] - order by $i/imdi:Name - return $i/imdi:Name - - - - - declare namespace imdi="http://www.mpi.nl/IMDI/Schema/IMDI"; - for $i in //imdi:Session[matches(imdi:Country, 'namibia')] - order by $i/imdi:Name - return $i/imdi:Name - - - - - declare namespace imdi="http://www.mpi.nl/IMDI/Schema/IMDI"; - for $i in //imdi:Session[contains(imdi:Name, 'shamanicsong01')] - order by $i/imdi:Name - return $i/imdi:Name - - - - - declare namespace imdi="http://www.mpi.nl/IMDI/Schema/IMDI"; - for $i in //imdi:Session[matches(imdi:Country, 'brazil')] - order by $i/imdi:Name - return $i/imdi:Name - - - - - declare namespace imdi="http://www.mpi.nl/IMDI/Schema/IMDI"; - for $i in //imdi:Session[contains(imdi:Title, 'kleve')] - order by $i/imdi:Name - return $i/imdi:Name - - - - - declare namespace imdi="http://www.mpi.nl/IMDI/Schema/IMDI"; - let $lang := //imdi:ContentLanguage - return - for $i in //imdi:Session[matches(imdi:Country, 'mexico')][matches(imdi:Genre, 'ritual/religious texts')] - order by $i/imdi:Name - return $i/imdi:Name - - - - - declare namespace imdi="http://www.mpi.nl/IMDI/Schema/IMDI"; - let $lang := //imdi:ContentLanguage - return - for $i in //imdi:Session[matches(imdi:Genre, 'ritual/religious texts')] - order by $i/imdi:Name - return $i/imdi:Name - - - - - declare namespace imdi="http://www.mpi.nl/IMDI/Schema/IMDI"; - for $i in //imdi:Session[contains(imdi:Name, 'berries')] - order by $i/imdi:Name - return $i/imdi:Name - - - - - declare namespace imdi="http://www.mpi.nl/IMDI/Schema/IMDI"; - for $i in //imdi:Session[matches(imdi:Name, 'berries')] - order by $i/imdi:Name - return $i/imdi:Name - - - - - declare namespace imdi="http://www.mpi.nl/IMDI/Schema/IMDI"; - for $i in //imdi:Session[matches(imdi:Continent, 'middle-america')] -(: MediaFile/type = video :) - order by $i/imdi:Name - return $i/imdi:Name - - - - - - for $doc in xmldb:get-child-resources("/db/test") - return xmldb:remove("/db/test", $doc) - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { $mods/mods:* } + + ]]> + + + { $mods/mods:titleInfo/mods:* } + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Description {$current} + {$current + 1.0} + {$current * 10} + + into /products + ]]> + + + Description {$current} + {$current + 1.0} + {$current * 10} + + preceding //product[1] + ]]> + + Description {$current} + {$current + 1.0} + {$current * 10} + + following //product[1] + ]]> + + + + 10,1) + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + declare namespace imdi="http://www.mpi.nl/IMDI/Schema/IMDI"; + for $i in //imdi:Session[contains(imdi:Name, 'drum')] + order by $i/imdi:Name + return $i/imdi:Name + + + + + declare namespace imdi="http://www.mpi.nl/IMDI/Schema/IMDI"; + for $i in //imdi:Session[contains(imdi:Name, 'lake')] + order by $i/imdi:Name + return $i/imdi:Name + + + + + declare namespace imdi="http://www.mpi.nl/IMDI/Schema/IMDI"; + for $i in //imdi:Session[matches(imdi:Country, 'namibia')] + order by $i/imdi:Name + return $i/imdi:Name + + + + + declare namespace imdi="http://www.mpi.nl/IMDI/Schema/IMDI"; + for $i in //imdi:Session[contains(imdi:Name, 'shamanicsong01')] + order by $i/imdi:Name + return $i/imdi:Name + + + + + declare namespace imdi="http://www.mpi.nl/IMDI/Schema/IMDI"; + for $i in //imdi:Session[matches(imdi:Country, 'brazil')] + order by $i/imdi:Name + return $i/imdi:Name + + + + + declare namespace imdi="http://www.mpi.nl/IMDI/Schema/IMDI"; + for $i in //imdi:Session[contains(imdi:Title, 'kleve')] + order by $i/imdi:Name + return $i/imdi:Name + + + + + declare namespace imdi="http://www.mpi.nl/IMDI/Schema/IMDI"; + let $lang := //imdi:ContentLanguage + return + for $i in //imdi:Session[matches(imdi:Country, 'mexico')][matches(imdi:Genre, 'ritual/religious texts')] + order by $i/imdi:Name + return $i/imdi:Name + + + + + declare namespace imdi="http://www.mpi.nl/IMDI/Schema/IMDI"; + let $lang := //imdi:ContentLanguage + return + for $i in //imdi:Session[matches(imdi:Genre, 'ritual/religious texts')] + order by $i/imdi:Name + return $i/imdi:Name + + + + + declare namespace imdi="http://www.mpi.nl/IMDI/Schema/IMDI"; + for $i in //imdi:Session[contains(imdi:Name, 'berries')] + order by $i/imdi:Name + return $i/imdi:Name + + + + + declare namespace imdi="http://www.mpi.nl/IMDI/Schema/IMDI"; + for $i in //imdi:Session[matches(imdi:Name, 'berries')] + order by $i/imdi:Name + return $i/imdi:Name + + + + + declare namespace imdi="http://www.mpi.nl/IMDI/Schema/IMDI"; + for $i in //imdi:Session[matches(imdi:Continent, 'middle-america')] +(: MediaFile/type = video :) + order by $i/imdi:Name + return $i/imdi:Name + + + + + + for $doc in xmldb:get-child-resources("/db/test") + return xmldb:remove("/db/test", $doc) + + + + + diff --git a/test/src/org/exist/storage/RemoveRootCollectionTest.java b/test/src/org/exist/storage/RemoveRootCollectionTest.java index 6eb9cd96b7b..c8484e5bad4 100644 --- a/test/src/org/exist/storage/RemoveRootCollectionTest.java +++ b/test/src/org/exist/storage/RemoveRootCollectionTest.java @@ -1,79 +1,79 @@ -package org.exist.storage; - -import static org.junit.Assert.*; - -import java.io.File; - -import org.exist.collections.*; -import org.exist.storage.txn.*; -import org.exist.util.Configuration; -import org.exist.xmldb.XmldbURI; -import org.junit.*; -import org.xml.sax.InputSource; - - -public class RemoveRootCollectionTest { - - private BrokerPool pool; - private DBBroker broker; - private TransactionManager transact; - Collection root; - - @Test public void removeEmptyRootCollection() throws Exception { - Txn transaction = transact.beginTransaction(); - broker.removeCollection(transaction, root); - transact.commit(transaction); - assertEquals(0, root.getChildCollectionCount(broker)); - assertEquals(0, root.getDocumentCount(broker)); - } - - @Test public void removeRootCollectionWithChildCollection() throws Exception { - addChildToRoot(); - Txn transaction = transact.beginTransaction(); - broker.removeCollection(transaction, root); - transact.commit(transaction); - assertEquals(0, root.getChildCollectionCount(broker)); - assertEquals(0, root.getDocumentCount(broker)); - } - - @Ignore @Test public void removeRootCollectionWithDocument() throws Exception { - addDocumentToRoot(); - Txn transaction = transact.beginTransaction(); - broker.removeCollection(transaction, root); - transact.commit(transaction); - assertEquals(0, root.getChildCollectionCount(broker)); - assertEquals(0, root.getDocumentCount(broker)); - } - - - @Before public void startDB() throws Exception { - Configuration config = new Configuration(); - BrokerPool.configure(1, 1, config); - pool = BrokerPool.getInstance(); assertNotNull(pool); - broker = pool.get(pool.getSecurityManager().getSystemSubject()); assertNotNull(broker); - transact = pool.getTransactionManager(); assertNotNull(transact); - root = broker.getCollection(XmldbURI.ROOT_COLLECTION_URI); assertNotNull(root); - } - - @After public void stopDB() { - pool.release(broker); - BrokerPool.stopAll(false); - } - - private void addDocumentToRoot() throws Exception { - Txn transaction = transact.beginTransaction(); - InputSource is = new InputSource(new File("samples/shakespeare/hamlet.xml").toURI().toASCIIString()); - assertNotNull(is); - IndexInfo info = root.validateXMLResource(transaction, broker, XmldbURI.create("hamlet.xml"), is); - assertNotNull(info); - root.store(transaction, broker, info, is, false); - transact.commit(transaction); - } - - private void addChildToRoot() throws Exception { - Txn transaction = transact.beginTransaction(); - Collection child = broker.getOrCreateCollection(transaction, XmldbURI.ROOT_COLLECTION_URI.append("child")); - broker.saveCollection(transaction, child); - transact.commit(transaction); - } -} +package org.exist.storage; + +import static org.junit.Assert.*; + +import java.io.File; + +import org.exist.collections.*; +import org.exist.storage.txn.*; +import org.exist.util.Configuration; +import org.exist.xmldb.XmldbURI; +import org.junit.*; +import org.xml.sax.InputSource; + + +public class RemoveRootCollectionTest { + + private BrokerPool pool; + private DBBroker broker; + private TransactionManager transact; + Collection root; + + @Test public void removeEmptyRootCollection() throws Exception { + Txn transaction = transact.beginTransaction(); + broker.removeCollection(transaction, root); + transact.commit(transaction); + assertEquals(0, root.getChildCollectionCount(broker)); + assertEquals(0, root.getDocumentCount(broker)); + } + + @Test public void removeRootCollectionWithChildCollection() throws Exception { + addChildToRoot(); + Txn transaction = transact.beginTransaction(); + broker.removeCollection(transaction, root); + transact.commit(transaction); + assertEquals(0, root.getChildCollectionCount(broker)); + assertEquals(0, root.getDocumentCount(broker)); + } + + @Ignore @Test public void removeRootCollectionWithDocument() throws Exception { + addDocumentToRoot(); + Txn transaction = transact.beginTransaction(); + broker.removeCollection(transaction, root); + transact.commit(transaction); + assertEquals(0, root.getChildCollectionCount(broker)); + assertEquals(0, root.getDocumentCount(broker)); + } + + + @Before public void startDB() throws Exception { + Configuration config = new Configuration(); + BrokerPool.configure(1, 1, config); + pool = BrokerPool.getInstance(); assertNotNull(pool); + broker = pool.get(pool.getSecurityManager().getSystemSubject()); assertNotNull(broker); + transact = pool.getTransactionManager(); assertNotNull(transact); + root = broker.getCollection(XmldbURI.ROOT_COLLECTION_URI); assertNotNull(root); + } + + @After public void stopDB() { + pool.release(broker); + BrokerPool.stopAll(false); + } + + private void addDocumentToRoot() throws Exception { + Txn transaction = transact.beginTransaction(); + InputSource is = new InputSource(new File("samples/shakespeare/hamlet.xml").toURI().toASCIIString()); + assertNotNull(is); + IndexInfo info = root.validateXMLResource(transaction, broker, XmldbURI.create("hamlet.xml"), is); + assertNotNull(info); + root.store(transaction, broker, info, is, false); + transact.commit(transaction); + } + + private void addChildToRoot() throws Exception { + Txn transaction = transact.beginTransaction(); + Collection child = broker.getOrCreateCollection(transaction, XmldbURI.ROOT_COLLECTION_URI.append("child")); + broker.saveCollection(transaction, child); + transact.commit(transaction); + } +} diff --git a/test/src/org/exist/storage/btree/BTreeTest.java b/test/src/org/exist/storage/btree/BTreeTest.java index 89d3cf0d862..ca2d2e15741 100644 --- a/test/src/org/exist/storage/btree/BTreeTest.java +++ b/test/src/org/exist/storage/btree/BTreeTest.java @@ -1,547 +1,547 @@ -package org.exist.storage.btree; - -import org.exist.EXistException; -import org.exist.storage.BrokerPool; -import org.exist.util.ByteConversion; -import org.exist.util.Configuration; -import org.exist.util.UTF8; -import org.exist.util.XMLString; -import org.exist.xquery.TerminatedException; -import org.exist.xquery.value.AtomicValue; -import org.exist.xquery.value.DoubleValue; -import org.junit.After; -import static org.junit.Assert.*; -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.junit.Test; - -import java.io.File; -import java.io.IOException; -import java.io.StringWriter; -import java.util.Map; -import java.util.Random; -import java.util.TreeMap; - -/** - * Low-level tests on the B+tree. - */ -public class BTreeTest { - - private BrokerPool pool; - private File file = null; - - private int count = 0; - private static final int COUNT = 5000; - - @Test - public void simpleUpdates() { - System.out.println("------------------ testStrings: START -------------------------"); - BTree btree = null; - try { - btree = new BTree(pool, (byte) 0, false, pool.getCacheManager(), file, 0.1); - btree.create((short) -1); - - String prefixStr = "K"; - for (int i = 1; i <= COUNT; i++) { - Value value = new Value(prefixStr + Integer.toString(i)); - btree.addValue(value, i); - } - - System.out.println("Testing IndexQuery.TRUNC_RIGHT"); - IndexQuery query = new IndexQuery(IndexQuery.TRUNC_RIGHT, new Value(prefixStr)); - btree.query(query, new StringIndexCallback()); - assertEquals(COUNT, count); - btree.flush(); - - System.out.println("Removing index entries ..."); - btree.remove(query, new StringIndexCallback()); - assertEquals(COUNT, count); - btree.flush(); - - System.out.println("Readding data ..."); - for (int i = 1; i <= COUNT; i++) { - Value value = new Value(prefixStr + Integer.toString(i)); - btree.addValue(value, i); - } - - System.out.println("Testing IndexQuery.TRUNC_RIGHT"); - btree.query(query, new StringIndexCallback()); - assertEquals(COUNT, count); - btree.flush(); - } catch (DBException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } finally { - if (btree != null) - try { - btree.close(); - } catch (DBException e) { - } - } - System.out.println("------------------ testStrings: END -------------------------"); - } - - @Test - public void strings() { - System.out.println("------------------ testStrings: START -------------------------"); - BTree btree = null; - try { - btree = new BTree(pool, (byte) 0, false, pool.getCacheManager(), file, 0.1); - btree.create((short) -1); - - String prefixStr = "C"; - for (int i = 1; i <= COUNT; i++) { - Value value = new Value(prefixStr + Integer.toString(i)); - btree.addValue(value, i); - } - - btree.flush(); - System.out.println("BTree size: " + file.length()); - - StringWriter writer = new StringWriter(); - btree.dump(writer); - System.out.println(writer.toString()); - - for (int i = 1; i <= COUNT; i++) { - long p = btree.findValue(new Value(prefixStr + Integer.toString(i))); - assertEquals(p, i); - } - - System.out.println("Testing IndexQuery.TRUNC_RIGHT"); - IndexQuery query = new IndexQuery(IndexQuery.TRUNC_RIGHT, new Value(prefixStr)); - btree.query(query, new StringIndexCallback()); - assertEquals(COUNT, count); - - System.out.println("Testing IndexQuery.TRUNC_RIGHT"); - query = new IndexQuery(IndexQuery.TRUNC_RIGHT, new Value(prefixStr + "1")); - btree.query(query, new StringIndexCallback()); - assertEquals(1111, count); - - System.out.println("Testing IndexQuery.NEQ"); - query = new IndexQuery(IndexQuery.NEQ, new Value(prefixStr + "10")); - btree.query(query, new StringIndexCallback()); - assertEquals(COUNT - 1, count); - - System.out.println("Testing IndexQuery.GT"); - query = new IndexQuery(IndexQuery.GT, new Value(prefixStr)); - btree.query(query, new StringIndexCallback()); - assertEquals(COUNT, count); - - System.out.println("Testing IndexQuery.GT"); - query = new IndexQuery(IndexQuery.GT, new Value(prefixStr + "1")); - btree.query(query, new StringIndexCallback()); - assertEquals(COUNT - 1, count); - - System.out.println("Testing IndexQuery.LT"); - query = new IndexQuery(IndexQuery.LT, new Value(prefixStr)); - btree.query(query, new StringIndexCallback()); - assertEquals(count, 0); - } catch (DBException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (TerminatedException e) { - e.printStackTrace(); - fail(e.getMessage()); - } finally { - if (btree != null) - try { - btree.close(); - } catch (DBException e) { - } - } - System.out.println("------------------ testStrings: END -------------------------"); - } - - @Test - public void longStrings() { - // Test storage of long keys up to half of the page size (4k) - System.out.println("------------------ testLongStrings: START -------------------------"); - Random rand = new Random(System.currentTimeMillis()); - - BTree btree = null; - try { - btree = new BTree(pool, (byte) 0, false, pool.getCacheManager(), file, 0.1); - btree.setSplitFactor(0.7); - btree.create((short) -1); - - Map keys = new TreeMap(); - String prefixStr = "C"; - for (int i = 1; i <= COUNT; i++) { - StringBuilder buf = new StringBuilder(); - buf.append(prefixStr).append(Integer.toString(i)); - int nextLen = rand.nextInt(2000); - while (nextLen < 512) { - nextLen = rand.nextInt(2000); - } - for (int j = 0; j < nextLen; j++) { - buf.append('x'); - } - final String key = buf.toString(); - - Value value = new Value(key); - btree.addValue(value, i); - keys.put(key, i); - } - - btree.flush(); - System.out.println("BTree size: " + (file.length() / 1024)); - - for (Map.Entry entry: keys.entrySet()) { - long p = btree.findValue(new Value(entry.getKey().toString())); - //System.out.println("Checking key " + entry.getKey()); - assertEquals(p, entry.getValue().intValue()); - } - } catch (DBException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } finally { - if (btree != null) - try { - btree.close(); - } catch (DBException e) { - } - } - System.out.println("------------------ testLongStrings: END -------------------------"); - } - - @Test - public void stringsTruncated() { - System.out.println("------------------ testStringsTruncated: START -------------------------"); - BTree btree = null; - try { - btree = new BTree(pool, (byte) 0, false, pool.getCacheManager(), file, 0.1); - btree.create((short) -1); - - char prefix = 'A'; - for (int i = 0; i < 24; i++) { - for (int j = 1; j <= COUNT; j++) { - Value value = new Value(prefix + Integer.toString(j)); - btree.addValue(value, j); - } - prefix++; - } - - btree.flush(); - - System.out.println("Testing IndexQuery.TRUNC_RIGHT"); - prefix = 'A'; - for (int i = 0; i < 24; i++) { - IndexQuery query = new IndexQuery(IndexQuery.TRUNC_RIGHT, new Value(Character.toString(prefix))); - btree.query(query, new StringIndexCallback()); - assertEquals(COUNT, count); - prefix++; - } - } catch (DBException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (TerminatedException e) { - e.printStackTrace(); - fail(e.getMessage()); - } finally { - if (btree != null) - try { - btree.close(); - } catch (DBException e) { - } - } - System.out.println("------------------ testStringsTruncated: END -------------------------"); - } - - @Test - public void removeStrings() { - System.out.println("------------------ testRemoveStrings: START -------------------------"); - BTree btree = null; - try { - btree = new BTree(pool, (byte) 0, false, pool.getCacheManager(), file, 0.1); - btree.create((short) -1); - - char prefix = 'A'; - for (int i = 0; i < 24; i++) { - for (int j = 1; j <= COUNT; j++) { - Value value = new Value(prefix + Integer.toString(j)); - btree.addValue(value, j); - } - prefix++; - } - btree.flush(); - - prefix = 'A'; - for (int i = 0; i < 24; i++) { - IndexQuery query = new IndexQuery(IndexQuery.TRUNC_RIGHT, new Value(Character.toString(prefix))); - btree.remove(query, new StringIndexCallback()); - assertEquals(COUNT, count); - - assertEquals(-1, btree.findValue(new Value(prefix + Integer.toString(100)))); - - query = new IndexQuery(IndexQuery.TRUNC_RIGHT, new Value(prefix + Integer.toString(100))); - btree.query(query, new StringIndexCallback()); - assertEquals(0, count); - prefix++; - } - - System.out.println("Testing IndexQuery.TRUNC_RIGHT"); - IndexQuery query = new IndexQuery(IndexQuery.TRUNC_RIGHT, new Value(Character.toString('D'))); - btree.query(query, new StringIndexCallback()); - assertEquals(0, count); - } catch (DBException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (TerminatedException e) { - e.printStackTrace(); - fail(e.getMessage()); - } finally { - if (btree != null) - try { - btree.close(); - } catch (DBException e) { - } - } - System.out.println("------------------ testRemoveStrings: END -------------------------"); - } - - @Test - public void numbers() throws TerminatedException { - System.out.println("------------------ testNumbers: START -------------------------"); - try { - BTree btree = new BTree(pool, (byte) 0, false, pool.getCacheManager(), file, 0.1); - btree.create((short) -1); - - for (int i = 1; i <= COUNT; i++) { - Value value = new SimpleValue(new DoubleValue(i)); - btree.addValue(value, i); - } - btree.flush(); - - for (int i = 1; i <= COUNT; i++) { - long p = btree.findValue(new SimpleValue(new DoubleValue(i))); - assertEquals(p, i); - } - - System.out.println("Testing IndexQuery.GT"); - IndexQuery query; - for (int i = 0; i < COUNT; i += 10) { - query = new IndexQuery(IndexQuery.GT, new SimpleValue(new DoubleValue(i))); - btree.query(query, new SimpleCallback()); - assertEquals(COUNT - i, count); - } - - System.out.println("Testing IndexQuery.GEQ"); - query = new IndexQuery(IndexQuery.GEQ, new SimpleValue(new DoubleValue(COUNT / 2))); - btree.query(query, new SimpleCallback()); - assertEquals(COUNT / 2 + 1, count); - - System.out.println("Testing IndexQuery.NEQ"); - for (int i = 1; i <= COUNT / 8; i++) { - query = new IndexQuery(IndexQuery.NEQ, new SimpleValue(new DoubleValue(i))); - btree.query(query, new SimpleCallback()); - assertEquals(COUNT - 1, count); - } - - btree.close(); - } catch (DBException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (EXistException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - System.out.println("------------------ testNumbers: END -------------------------"); - } - - @Test - public void numbersWithPrefix() { - System.out.println("------------------ testNumbersWithPrefix: START -------------------------"); - try { - BTree btree = new BTree(pool, (byte) 0, false, pool.getCacheManager(), file, 0.1); - btree.create((short) -1); - - for (int i = 1; i <= COUNT; i++) { - Value value = new PrefixValue(99, new DoubleValue(i)); - btree.addValue(value, i); - } - - for (int i = 1; i <= COUNT; i++) { - Value value = new PrefixValue(100, new DoubleValue(i)); - btree.addValue(value, i); - } - - btree.flush(); - System.out.println("BTree size: " + file.length()); - - for (int i = 1; i <= COUNT; i++) { - long p = btree.findValue(new PrefixValue(99, new DoubleValue(i))); - assertEquals(p, i); - } - Value prefix = new PrefixValue(99); - - System.out.println("Testing IndexQuery.TRUNC_RIGHT"); - IndexQuery query = new IndexQuery(IndexQuery.TRUNC_RIGHT, new PrefixValue(99)); - btree.query(query, new PrefixIndexCallback()); - assertEquals(COUNT, count); - - System.out.println("Testing IndexQuery.GT"); - for (int i = 0; i < COUNT; i += 10) { - query = new IndexQuery(IndexQuery.GT, new PrefixValue(99, new DoubleValue(i))); - btree.query(query, prefix, new PrefixIndexCallback()); - assertEquals(COUNT - i, count); - } - - System.out.println("Testing IndexQuery.GEQ"); - query = new IndexQuery(IndexQuery.GEQ, new PrefixValue(99, new DoubleValue(COUNT / 2))); - btree.query(query, prefix, new PrefixIndexCallback()); - assertEquals(COUNT / 2 + 1, count); - - System.out.println("Testing IndexQuery.LT"); - query = new IndexQuery(IndexQuery.LT, new PrefixValue(99, new DoubleValue(COUNT / 2))); - btree.query(query, prefix, new PrefixIndexCallback()); - assertEquals(COUNT / 2 - 1, count); - - System.out.println("Testing IndexQuery.LEQ"); - query = new IndexQuery(IndexQuery.LEQ, new PrefixValue(99, new DoubleValue(COUNT / 2))); - btree.query(query, prefix, new PrefixIndexCallback()); - assertEquals(COUNT / 2, count); - - System.out.println("Testing IndexQuery.NEQ"); - for (int i = 1; i <= COUNT / 8; i++) { - count = 0; - query = new IndexQuery(IndexQuery.NEQ, new PrefixValue(99, new DoubleValue(i))); - btree.query(query, prefix, new PrefixIndexCallback()); - assertEquals(COUNT - 1, count); - } - - btree.close(); - } catch (DBException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (TerminatedException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (EXistException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - System.out.println("------------------ testNumbersWithPrefix: END -------------------------"); - } - - @Before - public void initialize() { - try { - Configuration config = new Configuration(); - BrokerPool.configure(1, 5, config); - pool = BrokerPool.getInstance(); - - file = new File(System.getProperty("exist.home", ".") + "/test/junit/test.dbx"); - assertFalse(file.exists()); - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @After - public void cleanUp() { - try { - BrokerPool.stopAll(false); - - file.delete(); - } catch (Exception e) { - fail(e.getMessage()); - } - pool = null; - file = null; - } - - private final class SimpleCallback implements BTreeCallback { - - public SimpleCallback() { - count = 0; - } - - public boolean indexInfo(Value value, long pointer) throws TerminatedException { - count++; - return false; - } - } - - private final class PrefixIndexCallback implements BTreeCallback { - - public PrefixIndexCallback() { - count = 0; - } - - public boolean indexInfo(Value value, long pointer) throws TerminatedException { - int prefix = ByteConversion.byteToInt(value.data(), value.start()); - assertEquals(99, prefix); -// XMLString key = UTF8.decode(value.data(), value.start() + 4, value.getLength() - 4); -// System.out.println(prefix + " : " + key); - count++; - return false; - } - } - - private final class StringIndexCallback implements BTreeCallback { - - public StringIndexCallback() { - count = 0; - } - - public boolean indexInfo(Value value, long pointer) throws TerminatedException { - @SuppressWarnings("unused") - XMLString key = UTF8.decode(value.data(), value.start(), value.getLength()); -// System.out.println("\"" + key + "\": " + count); - count++; - return false; - } - } - - private class SimpleValue extends Value { - - public SimpleValue(AtomicValue value) throws EXistException { - data = value.serializeValue(0); - len = data.length; - pos = 0; - } - } - - private class PrefixValue extends Value { - - public PrefixValue(int prefix) { - len = 4; - data = new byte[len]; - ByteConversion.intToByte(prefix, data, 0); - pos = 0; - } - - public PrefixValue(int prefix, AtomicValue value) throws EXistException { - data = value.serializeValue(4); - len = data.length; - ByteConversion.intToByte(prefix, data, 0); - pos = 0; - } - } -} +package org.exist.storage.btree; + +import org.exist.EXistException; +import org.exist.storage.BrokerPool; +import org.exist.util.ByteConversion; +import org.exist.util.Configuration; +import org.exist.util.UTF8; +import org.exist.util.XMLString; +import org.exist.xquery.TerminatedException; +import org.exist.xquery.value.AtomicValue; +import org.exist.xquery.value.DoubleValue; +import org.junit.After; +import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +import java.io.File; +import java.io.IOException; +import java.io.StringWriter; +import java.util.Map; +import java.util.Random; +import java.util.TreeMap; + +/** + * Low-level tests on the B+tree. + */ +public class BTreeTest { + + private BrokerPool pool; + private File file = null; + + private int count = 0; + private static final int COUNT = 5000; + + @Test + public void simpleUpdates() { + System.out.println("------------------ testStrings: START -------------------------"); + BTree btree = null; + try { + btree = new BTree(pool, (byte) 0, false, pool.getCacheManager(), file, 0.1); + btree.create((short) -1); + + String prefixStr = "K"; + for (int i = 1; i <= COUNT; i++) { + Value value = new Value(prefixStr + Integer.toString(i)); + btree.addValue(value, i); + } + + System.out.println("Testing IndexQuery.TRUNC_RIGHT"); + IndexQuery query = new IndexQuery(IndexQuery.TRUNC_RIGHT, new Value(prefixStr)); + btree.query(query, new StringIndexCallback()); + assertEquals(COUNT, count); + btree.flush(); + + System.out.println("Removing index entries ..."); + btree.remove(query, new StringIndexCallback()); + assertEquals(COUNT, count); + btree.flush(); + + System.out.println("Readding data ..."); + for (int i = 1; i <= COUNT; i++) { + Value value = new Value(prefixStr + Integer.toString(i)); + btree.addValue(value, i); + } + + System.out.println("Testing IndexQuery.TRUNC_RIGHT"); + btree.query(query, new StringIndexCallback()); + assertEquals(COUNT, count); + btree.flush(); + } catch (DBException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (IOException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } finally { + if (btree != null) + try { + btree.close(); + } catch (DBException e) { + } + } + System.out.println("------------------ testStrings: END -------------------------"); + } + + @Test + public void strings() { + System.out.println("------------------ testStrings: START -------------------------"); + BTree btree = null; + try { + btree = new BTree(pool, (byte) 0, false, pool.getCacheManager(), file, 0.1); + btree.create((short) -1); + + String prefixStr = "C"; + for (int i = 1; i <= COUNT; i++) { + Value value = new Value(prefixStr + Integer.toString(i)); + btree.addValue(value, i); + } + + btree.flush(); + System.out.println("BTree size: " + file.length()); + + StringWriter writer = new StringWriter(); + btree.dump(writer); + System.out.println(writer.toString()); + + for (int i = 1; i <= COUNT; i++) { + long p = btree.findValue(new Value(prefixStr + Integer.toString(i))); + assertEquals(p, i); + } + + System.out.println("Testing IndexQuery.TRUNC_RIGHT"); + IndexQuery query = new IndexQuery(IndexQuery.TRUNC_RIGHT, new Value(prefixStr)); + btree.query(query, new StringIndexCallback()); + assertEquals(COUNT, count); + + System.out.println("Testing IndexQuery.TRUNC_RIGHT"); + query = new IndexQuery(IndexQuery.TRUNC_RIGHT, new Value(prefixStr + "1")); + btree.query(query, new StringIndexCallback()); + assertEquals(1111, count); + + System.out.println("Testing IndexQuery.NEQ"); + query = new IndexQuery(IndexQuery.NEQ, new Value(prefixStr + "10")); + btree.query(query, new StringIndexCallback()); + assertEquals(COUNT - 1, count); + + System.out.println("Testing IndexQuery.GT"); + query = new IndexQuery(IndexQuery.GT, new Value(prefixStr)); + btree.query(query, new StringIndexCallback()); + assertEquals(COUNT, count); + + System.out.println("Testing IndexQuery.GT"); + query = new IndexQuery(IndexQuery.GT, new Value(prefixStr + "1")); + btree.query(query, new StringIndexCallback()); + assertEquals(COUNT - 1, count); + + System.out.println("Testing IndexQuery.LT"); + query = new IndexQuery(IndexQuery.LT, new Value(prefixStr)); + btree.query(query, new StringIndexCallback()); + assertEquals(count, 0); + } catch (DBException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (IOException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (TerminatedException e) { + e.printStackTrace(); + fail(e.getMessage()); + } finally { + if (btree != null) + try { + btree.close(); + } catch (DBException e) { + } + } + System.out.println("------------------ testStrings: END -------------------------"); + } + + @Test + public void longStrings() { + // Test storage of long keys up to half of the page size (4k) + System.out.println("------------------ testLongStrings: START -------------------------"); + Random rand = new Random(System.currentTimeMillis()); + + BTree btree = null; + try { + btree = new BTree(pool, (byte) 0, false, pool.getCacheManager(), file, 0.1); + btree.setSplitFactor(0.7); + btree.create((short) -1); + + Map keys = new TreeMap(); + String prefixStr = "C"; + for (int i = 1; i <= COUNT; i++) { + StringBuilder buf = new StringBuilder(); + buf.append(prefixStr).append(Integer.toString(i)); + int nextLen = rand.nextInt(2000); + while (nextLen < 512) { + nextLen = rand.nextInt(2000); + } + for (int j = 0; j < nextLen; j++) { + buf.append('x'); + } + final String key = buf.toString(); + + Value value = new Value(key); + btree.addValue(value, i); + keys.put(key, i); + } + + btree.flush(); + System.out.println("BTree size: " + (file.length() / 1024)); + + for (Map.Entry entry: keys.entrySet()) { + long p = btree.findValue(new Value(entry.getKey().toString())); + //System.out.println("Checking key " + entry.getKey()); + assertEquals(p, entry.getValue().intValue()); + } + } catch (DBException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (IOException e) { + e.printStackTrace(); + fail(e.getMessage()); + } finally { + if (btree != null) + try { + btree.close(); + } catch (DBException e) { + } + } + System.out.println("------------------ testLongStrings: END -------------------------"); + } + + @Test + public void stringsTruncated() { + System.out.println("------------------ testStringsTruncated: START -------------------------"); + BTree btree = null; + try { + btree = new BTree(pool, (byte) 0, false, pool.getCacheManager(), file, 0.1); + btree.create((short) -1); + + char prefix = 'A'; + for (int i = 0; i < 24; i++) { + for (int j = 1; j <= COUNT; j++) { + Value value = new Value(prefix + Integer.toString(j)); + btree.addValue(value, j); + } + prefix++; + } + + btree.flush(); + + System.out.println("Testing IndexQuery.TRUNC_RIGHT"); + prefix = 'A'; + for (int i = 0; i < 24; i++) { + IndexQuery query = new IndexQuery(IndexQuery.TRUNC_RIGHT, new Value(Character.toString(prefix))); + btree.query(query, new StringIndexCallback()); + assertEquals(COUNT, count); + prefix++; + } + } catch (DBException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (IOException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (TerminatedException e) { + e.printStackTrace(); + fail(e.getMessage()); + } finally { + if (btree != null) + try { + btree.close(); + } catch (DBException e) { + } + } + System.out.println("------------------ testStringsTruncated: END -------------------------"); + } + + @Test + public void removeStrings() { + System.out.println("------------------ testRemoveStrings: START -------------------------"); + BTree btree = null; + try { + btree = new BTree(pool, (byte) 0, false, pool.getCacheManager(), file, 0.1); + btree.create((short) -1); + + char prefix = 'A'; + for (int i = 0; i < 24; i++) { + for (int j = 1; j <= COUNT; j++) { + Value value = new Value(prefix + Integer.toString(j)); + btree.addValue(value, j); + } + prefix++; + } + btree.flush(); + + prefix = 'A'; + for (int i = 0; i < 24; i++) { + IndexQuery query = new IndexQuery(IndexQuery.TRUNC_RIGHT, new Value(Character.toString(prefix))); + btree.remove(query, new StringIndexCallback()); + assertEquals(COUNT, count); + + assertEquals(-1, btree.findValue(new Value(prefix + Integer.toString(100)))); + + query = new IndexQuery(IndexQuery.TRUNC_RIGHT, new Value(prefix + Integer.toString(100))); + btree.query(query, new StringIndexCallback()); + assertEquals(0, count); + prefix++; + } + + System.out.println("Testing IndexQuery.TRUNC_RIGHT"); + IndexQuery query = new IndexQuery(IndexQuery.TRUNC_RIGHT, new Value(Character.toString('D'))); + btree.query(query, new StringIndexCallback()); + assertEquals(0, count); + } catch (DBException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (IOException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (TerminatedException e) { + e.printStackTrace(); + fail(e.getMessage()); + } finally { + if (btree != null) + try { + btree.close(); + } catch (DBException e) { + } + } + System.out.println("------------------ testRemoveStrings: END -------------------------"); + } + + @Test + public void numbers() throws TerminatedException { + System.out.println("------------------ testNumbers: START -------------------------"); + try { + BTree btree = new BTree(pool, (byte) 0, false, pool.getCacheManager(), file, 0.1); + btree.create((short) -1); + + for (int i = 1; i <= COUNT; i++) { + Value value = new SimpleValue(new DoubleValue(i)); + btree.addValue(value, i); + } + btree.flush(); + + for (int i = 1; i <= COUNT; i++) { + long p = btree.findValue(new SimpleValue(new DoubleValue(i))); + assertEquals(p, i); + } + + System.out.println("Testing IndexQuery.GT"); + IndexQuery query; + for (int i = 0; i < COUNT; i += 10) { + query = new IndexQuery(IndexQuery.GT, new SimpleValue(new DoubleValue(i))); + btree.query(query, new SimpleCallback()); + assertEquals(COUNT - i, count); + } + + System.out.println("Testing IndexQuery.GEQ"); + query = new IndexQuery(IndexQuery.GEQ, new SimpleValue(new DoubleValue(COUNT / 2))); + btree.query(query, new SimpleCallback()); + assertEquals(COUNT / 2 + 1, count); + + System.out.println("Testing IndexQuery.NEQ"); + for (int i = 1; i <= COUNT / 8; i++) { + query = new IndexQuery(IndexQuery.NEQ, new SimpleValue(new DoubleValue(i))); + btree.query(query, new SimpleCallback()); + assertEquals(COUNT - 1, count); + } + + btree.close(); + } catch (DBException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (IOException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (EXistException e) { + e.printStackTrace(); + fail(e.getMessage()); + } + System.out.println("------------------ testNumbers: END -------------------------"); + } + + @Test + public void numbersWithPrefix() { + System.out.println("------------------ testNumbersWithPrefix: START -------------------------"); + try { + BTree btree = new BTree(pool, (byte) 0, false, pool.getCacheManager(), file, 0.1); + btree.create((short) -1); + + for (int i = 1; i <= COUNT; i++) { + Value value = new PrefixValue(99, new DoubleValue(i)); + btree.addValue(value, i); + } + + for (int i = 1; i <= COUNT; i++) { + Value value = new PrefixValue(100, new DoubleValue(i)); + btree.addValue(value, i); + } + + btree.flush(); + System.out.println("BTree size: " + file.length()); + + for (int i = 1; i <= COUNT; i++) { + long p = btree.findValue(new PrefixValue(99, new DoubleValue(i))); + assertEquals(p, i); + } + Value prefix = new PrefixValue(99); + + System.out.println("Testing IndexQuery.TRUNC_RIGHT"); + IndexQuery query = new IndexQuery(IndexQuery.TRUNC_RIGHT, new PrefixValue(99)); + btree.query(query, new PrefixIndexCallback()); + assertEquals(COUNT, count); + + System.out.println("Testing IndexQuery.GT"); + for (int i = 0; i < COUNT; i += 10) { + query = new IndexQuery(IndexQuery.GT, new PrefixValue(99, new DoubleValue(i))); + btree.query(query, prefix, new PrefixIndexCallback()); + assertEquals(COUNT - i, count); + } + + System.out.println("Testing IndexQuery.GEQ"); + query = new IndexQuery(IndexQuery.GEQ, new PrefixValue(99, new DoubleValue(COUNT / 2))); + btree.query(query, prefix, new PrefixIndexCallback()); + assertEquals(COUNT / 2 + 1, count); + + System.out.println("Testing IndexQuery.LT"); + query = new IndexQuery(IndexQuery.LT, new PrefixValue(99, new DoubleValue(COUNT / 2))); + btree.query(query, prefix, new PrefixIndexCallback()); + assertEquals(COUNT / 2 - 1, count); + + System.out.println("Testing IndexQuery.LEQ"); + query = new IndexQuery(IndexQuery.LEQ, new PrefixValue(99, new DoubleValue(COUNT / 2))); + btree.query(query, prefix, new PrefixIndexCallback()); + assertEquals(COUNT / 2, count); + + System.out.println("Testing IndexQuery.NEQ"); + for (int i = 1; i <= COUNT / 8; i++) { + count = 0; + query = new IndexQuery(IndexQuery.NEQ, new PrefixValue(99, new DoubleValue(i))); + btree.query(query, prefix, new PrefixIndexCallback()); + assertEquals(COUNT - 1, count); + } + + btree.close(); + } catch (DBException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (IOException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (TerminatedException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (EXistException e) { + e.printStackTrace(); + fail(e.getMessage()); + } + System.out.println("------------------ testNumbersWithPrefix: END -------------------------"); + } + + @Before + public void initialize() { + try { + Configuration config = new Configuration(); + BrokerPool.configure(1, 5, config); + pool = BrokerPool.getInstance(); + + file = new File(System.getProperty("exist.home", ".") + "/test/junit/test.dbx"); + assertFalse(file.exists()); + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } + + @After + public void cleanUp() { + try { + BrokerPool.stopAll(false); + + file.delete(); + } catch (Exception e) { + fail(e.getMessage()); + } + pool = null; + file = null; + } + + private final class SimpleCallback implements BTreeCallback { + + public SimpleCallback() { + count = 0; + } + + public boolean indexInfo(Value value, long pointer) throws TerminatedException { + count++; + return false; + } + } + + private final class PrefixIndexCallback implements BTreeCallback { + + public PrefixIndexCallback() { + count = 0; + } + + public boolean indexInfo(Value value, long pointer) throws TerminatedException { + int prefix = ByteConversion.byteToInt(value.data(), value.start()); + assertEquals(99, prefix); +// XMLString key = UTF8.decode(value.data(), value.start() + 4, value.getLength() - 4); +// System.out.println(prefix + " : " + key); + count++; + return false; + } + } + + private final class StringIndexCallback implements BTreeCallback { + + public StringIndexCallback() { + count = 0; + } + + public boolean indexInfo(Value value, long pointer) throws TerminatedException { + @SuppressWarnings("unused") + XMLString key = UTF8.decode(value.data(), value.start(), value.getLength()); +// System.out.println("\"" + key + "\": " + count); + count++; + return false; + } + } + + private class SimpleValue extends Value { + + public SimpleValue(AtomicValue value) throws EXistException { + data = value.serializeValue(0); + len = data.length; + pos = 0; + } + } + + private class PrefixValue extends Value { + + public PrefixValue(int prefix) { + len = 4; + data = new byte[len]; + ByteConversion.intToByte(prefix, data, 0); + pos = 0; + } + + public PrefixValue(int prefix, AtomicValue value) throws EXistException { + data = value.serializeValue(4); + len = data.length; + ByteConversion.intToByte(prefix, data, 0); + pos = 0; + } + } +} diff --git a/test/src/org/exist/test/TestConstants.java b/test/src/org/exist/test/TestConstants.java index 55252cd0bc2..dfd30d70747 100644 --- a/test/src/org/exist/test/TestConstants.java +++ b/test/src/org/exist/test/TestConstants.java @@ -1,103 +1,103 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2006-2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id$ - */ -package org.exist.test; - -import org.exist.xmldb.XmldbURI; -import org.exist.xquery.util.URIUtils; - -public class TestConstants { - - /** - * String representing the decoded path: t[e s]tá열 - */ - public static final String DECODED_SPECIAL_NAME = "t[e s]t\u00E0\uC5F4"; - - /** - * String representing the encoded path: t%5Be%20s%5Dt%C3%A0%EC%97%B4 - */ - public static final String SPECIAL_NAME = URIUtils.urlEncodeUtf8(DECODED_SPECIAL_NAME); - - /** - * XmldbURI representing the decoded path: t[e s]tá열 - */ - public static final XmldbURI SPECIAL_URI = XmldbURI.create(SPECIAL_NAME); - - /** - * XmldbURI representing the decoded path: /db/test - */ - public static final XmldbURI TEST_COLLECTION_URI = XmldbURI.ROOT_COLLECTION_URI.append("test"); - /** - * XmldbURI representing the decoded path: /db/test/test2 - */ - public static final XmldbURI TEST_COLLECTION_URI2 = TEST_COLLECTION_URI.append("test2"); - /** - * XmldbURI representing the decoded path: /db/test/test2/test3 - */ - public static final XmldbURI TEST_COLLECTION_URI3 = TEST_COLLECTION_URI2.append("test3"); - - /** - * XmldbURI representing the decoded path: /db/t[e s]tá열 - */ - public static final XmldbURI SPECIAL_COLLECTION_URI = XmldbURI.ROOT_COLLECTION_URI.append(SPECIAL_NAME); - - /** - * XmldbURI representing the decoded path: /db/destination - */ - public static final XmldbURI DESTINATION_COLLECTION_URI = XmldbURI.ROOT_COLLECTION_URI.append("destination"); - /** - * XmldbURI representing the decoded path: /db/destination2 - */ - public static final XmldbURI DESTINATION_COLLECTION_URI2 = XmldbURI.ROOT_COLLECTION_URI.append("destination2"); - /** - * XmldbURI representing the decoded path: /db/destination3 - */ - public static final XmldbURI DESTINATION_COLLECTION_URI3 = XmldbURI.ROOT_COLLECTION_URI.append("destination3"); - - /** - * XmldbURI representing the decoded path: test.xml - */ - public static final XmldbURI TEST_XML_URI = XmldbURI.create("test.xml"); - /** - * XmldbURI representing the decoded path: test2.xml - */ - public static final XmldbURI TEST_XML_URI2 = XmldbURI.create("test2.xml"); - /** - * XmldbURI representing the decoded path: test3.xml - */ - public static final XmldbURI TEST_XML_URI3 = XmldbURI.create("test3.xml"); - - /** - * XmldbURI representing the decoded path: t[e s]tá열.xml - */ - public static final XmldbURI SPECIAL_XML_URI = XmldbURI.create(URIUtils.urlEncodeUtf8("t[es]t\u00E0\uC5F4.xml")); - - /** - * XmldbURI representing the decoded path: binary.txt - */ - public static final XmldbURI TEST_BINARY_URI = XmldbURI.create("binary.txt"); - - /** - * XmldbURI representing the decoded path: testmodule.xqm - */ - public static final XmldbURI TEST_MODULE_URI = XmldbURI.create("testmodule.xqm"); - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2006-2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id$ + */ +package org.exist.test; + +import org.exist.xmldb.XmldbURI; +import org.exist.xquery.util.URIUtils; + +public class TestConstants { + + /** + * String representing the decoded path: t[e s]tá열 + */ + public static final String DECODED_SPECIAL_NAME = "t[e s]t\u00E0\uC5F4"; + + /** + * String representing the encoded path: t%5Be%20s%5Dt%C3%A0%EC%97%B4 + */ + public static final String SPECIAL_NAME = URIUtils.urlEncodeUtf8(DECODED_SPECIAL_NAME); + + /** + * XmldbURI representing the decoded path: t[e s]tá열 + */ + public static final XmldbURI SPECIAL_URI = XmldbURI.create(SPECIAL_NAME); + + /** + * XmldbURI representing the decoded path: /db/test + */ + public static final XmldbURI TEST_COLLECTION_URI = XmldbURI.ROOT_COLLECTION_URI.append("test"); + /** + * XmldbURI representing the decoded path: /db/test/test2 + */ + public static final XmldbURI TEST_COLLECTION_URI2 = TEST_COLLECTION_URI.append("test2"); + /** + * XmldbURI representing the decoded path: /db/test/test2/test3 + */ + public static final XmldbURI TEST_COLLECTION_URI3 = TEST_COLLECTION_URI2.append("test3"); + + /** + * XmldbURI representing the decoded path: /db/t[e s]tá열 + */ + public static final XmldbURI SPECIAL_COLLECTION_URI = XmldbURI.ROOT_COLLECTION_URI.append(SPECIAL_NAME); + + /** + * XmldbURI representing the decoded path: /db/destination + */ + public static final XmldbURI DESTINATION_COLLECTION_URI = XmldbURI.ROOT_COLLECTION_URI.append("destination"); + /** + * XmldbURI representing the decoded path: /db/destination2 + */ + public static final XmldbURI DESTINATION_COLLECTION_URI2 = XmldbURI.ROOT_COLLECTION_URI.append("destination2"); + /** + * XmldbURI representing the decoded path: /db/destination3 + */ + public static final XmldbURI DESTINATION_COLLECTION_URI3 = XmldbURI.ROOT_COLLECTION_URI.append("destination3"); + + /** + * XmldbURI representing the decoded path: test.xml + */ + public static final XmldbURI TEST_XML_URI = XmldbURI.create("test.xml"); + /** + * XmldbURI representing the decoded path: test2.xml + */ + public static final XmldbURI TEST_XML_URI2 = XmldbURI.create("test2.xml"); + /** + * XmldbURI representing the decoded path: test3.xml + */ + public static final XmldbURI TEST_XML_URI3 = XmldbURI.create("test3.xml"); + + /** + * XmldbURI representing the decoded path: t[e s]tá열.xml + */ + public static final XmldbURI SPECIAL_XML_URI = XmldbURI.create(URIUtils.urlEncodeUtf8("t[es]t\u00E0\uC5F4.xml")); + + /** + * XmldbURI representing the decoded path: binary.txt + */ + public static final XmldbURI TEST_BINARY_URI = XmldbURI.create("binary.txt"); + + /** + * XmldbURI representing the decoded path: testmodule.xqm + */ + public static final XmldbURI TEST_MODULE_URI = XmldbURI.create("testmodule.xqm"); + +} diff --git a/test/src/org/exist/util/MimeTableTest.java b/test/src/org/exist/util/MimeTableTest.java index 2afed09871d..256b0cd56f4 100644 --- a/test/src/org/exist/util/MimeTableTest.java +++ b/test/src/org/exist/util/MimeTableTest.java @@ -1,151 +1,151 @@ -package org.exist.util; - -import java.io.File; -import java.lang.reflect.Field; - -import static org.junit.Assert.*; -import org.junit.*; - -/** - * Test case for mime-type mapping. - * Tests the distribution edition of mime-types.xml - * as well as variants that exploit the default mime type feature - * - * @author Peter Ciuffetti - */ -public class MimeTableTest { - - @After - public void tearDown() throws Exception { - // MimeTable is a singleton - // We use reflection here to null-out the 'instance' field - // so subsequent tests that call getInstance() will re-load - // the specified mime type config file - Field field = MimeTable.class.getDeclaredField("instance"); - field.setAccessible(true); - field.set(MimeTable.getInstance(), null); - } - - /** - * This test checks the behavior of MimeTable.java - * with respect to the distribution version of mime-types.xml. - * The distribution version of mime-types.xml does not use the - * default mime type capability. - */ - @Test - public void testDistributionVersionOfMimeTypesXml() { - File existDir; - String existHome = System.getProperty("exist.home"); - existDir = existHome == null ? new File(".") : new File(existHome); - - File file = new File(existDir, "mime-types.xml"); - - MimeTable mimeTable = MimeTable.getInstance(file); - assertNotNull("Mime table not found", mimeTable); - - MimeType mt; - - mt = mimeTable.getContentTypeFor("test.xml"); - assertNotNull("Mime type not found for test.xml", mt); - assertEquals("Incorrect mime type", "application/xml", mt.getName()); - assertEquals("Incorrect resource type", MimeType.XML, mt.getType()); - - mt = mimeTable.getContentTypeFor("test.html"); - assertNotNull("Mime type not found for test.html", mt); - assertEquals("Incorrect mime type", "text/html", mt.getName()); - assertEquals("Incorrect resource type", MimeType.XML, mt.getType()); - - mt = mimeTable.getContentTypeFor("test.jpg"); - assertNotNull("Mime type not found for test.jpg", mt); - assertEquals("Incorrect mime type", "image/jpeg", mt.getName()); - assertEquals("Incorrect resource type", MimeType.BINARY, mt.getType()); - - mt = mimeTable.getContentTypeFor("foo"); - assertNull("Should return null mime type for file without extension", mt); - - mt = mimeTable.getContentTypeFor("foo.bar"); - assertNull("Should return null mime type for file with extension not configured in mime-types.xml", mt); - } - - /** - * This test checks the behavior of the mime-types@default-resource-type attribute - * The test config assigns all resources to application/xml - */ - @Test - public void testWithDefaultResourceTypeFeature() { - File existDir; - String existHome = System.getProperty("exist.home"); - existDir = existHome == null ? new File("./test/src/org/exist/util") : new File(existHome+"/test/src/org/exist/util"); - - MimeTable mimeTable = MimeTable.getInstance(new File(existDir, "mime-types-xml-default.xml")); - assertNotNull("Mime table not found", mimeTable); - - MimeType mt; - - mt = mimeTable.getContentTypeFor("test.xml"); - assertNotNull("Mime type not found for test.xml", mt); - assertEquals("Incorrect mime type", "application/xml", mt.getName()); - assertEquals("Incorrect resource type", MimeType.XML, mt.getType()); - - mt = mimeTable.getContentTypeFor("test.html"); - assertNotNull("Mime type not found for test.html", mt); - assertEquals("Incorrect mime type", "application/xml", mt.getName()); - assertEquals("Incorrect resource type", MimeType.XML, mt.getType()); - - mt = mimeTable.getContentTypeFor("test.jpg"); - assertNotNull("Mime type not found for test.jpg", mt); - assertEquals("Incorrect mime type", "application/xml", mt.getName()); - assertEquals("Incorrect resource type", MimeType.XML, mt.getType()); - - mt = mimeTable.getContentTypeFor("foo"); - assertNotNull("Mime type not found for foo", mt); - assertEquals("Incorrect mime type", "application/xml", mt.getName()); - assertEquals("Incorrect resource type", MimeType.XML, mt.getType()); - - mt = mimeTable.getContentTypeFor("foo.bar"); - assertNotNull("Mime type not found for test.jpg", mt); - assertEquals("Incorrect mime type", "application/xml", mt.getName()); - assertEquals("Incorrect resource type", MimeType.XML, mt.getType()); - } - - /** - * This test checks the behavior of the mime-types@default-mime-type attribute - * The test config assigns all resources to foo/bar (BINARY) - */ - @Test - public void testWithDefaultMimeTypeFeature() { - File existDir; - String existHome = System.getProperty("exist.home"); - existDir = existHome == null ? new File("./test/src/org/exist/util") : new File(existHome+"/test/src/org/exist/util"); - - MimeTable mimeTable = MimeTable.getInstance(new File(existDir, "mime-types-foo-default.xml")); - assertNotNull("Mime table not found", mimeTable); - - MimeType mt; - - mt = mimeTable.getContentTypeFor("test.xml"); - assertNotNull("Mime type not found for test.xml", mt); - assertEquals("Incorrect mime type", "foo/bar", mt.getName()); - assertEquals("Incorrect resource type", MimeType.BINARY, mt.getType()); - - mt = mimeTable.getContentTypeFor("test.html"); - assertNotNull("Mime type not found for test.html", mt); - assertEquals("Incorrect mime type", "foo/bar", mt.getName()); - assertEquals("Incorrect resource type", MimeType.BINARY, mt.getType()); - - mt = mimeTable.getContentTypeFor("test.jpg"); - assertNotNull("Mime type not found for test.jpg", mt); - assertEquals("Incorrect mime type", "foo/bar", mt.getName()); - assertEquals("Incorrect resource type", MimeType.BINARY, mt.getType()); - - mt = mimeTable.getContentTypeFor("foo"); - assertNotNull("Mime type not found for foo", mt); - assertEquals("Incorrect mime type", "foo/bar", mt.getName()); - assertEquals("Incorrect resource type", MimeType.BINARY, mt.getType()); - - mt = mimeTable.getContentTypeFor("foo.bar"); - assertNotNull("Mime type not found for test.jpg", mt); - assertEquals("Incorrect mime type", "foo/bar", mt.getName()); - assertEquals("Incorrect resource type", MimeType.BINARY, mt.getType()); - } -} +package org.exist.util; + +import java.io.File; +import java.lang.reflect.Field; + +import static org.junit.Assert.*; +import org.junit.*; + +/** + * Test case for mime-type mapping. + * Tests the distribution edition of mime-types.xml + * as well as variants that exploit the default mime type feature + * + * @author Peter Ciuffetti + */ +public class MimeTableTest { + + @After + public void tearDown() throws Exception { + // MimeTable is a singleton + // We use reflection here to null-out the 'instance' field + // so subsequent tests that call getInstance() will re-load + // the specified mime type config file + Field field = MimeTable.class.getDeclaredField("instance"); + field.setAccessible(true); + field.set(MimeTable.getInstance(), null); + } + + /** + * This test checks the behavior of MimeTable.java + * with respect to the distribution version of mime-types.xml. + * The distribution version of mime-types.xml does not use the + * default mime type capability. + */ + @Test + public void testDistributionVersionOfMimeTypesXml() { + File existDir; + String existHome = System.getProperty("exist.home"); + existDir = existHome == null ? new File(".") : new File(existHome); + + File file = new File(existDir, "mime-types.xml"); + + MimeTable mimeTable = MimeTable.getInstance(file); + assertNotNull("Mime table not found", mimeTable); + + MimeType mt; + + mt = mimeTable.getContentTypeFor("test.xml"); + assertNotNull("Mime type not found for test.xml", mt); + assertEquals("Incorrect mime type", "application/xml", mt.getName()); + assertEquals("Incorrect resource type", MimeType.XML, mt.getType()); + + mt = mimeTable.getContentTypeFor("test.html"); + assertNotNull("Mime type not found for test.html", mt); + assertEquals("Incorrect mime type", "text/html", mt.getName()); + assertEquals("Incorrect resource type", MimeType.XML, mt.getType()); + + mt = mimeTable.getContentTypeFor("test.jpg"); + assertNotNull("Mime type not found for test.jpg", mt); + assertEquals("Incorrect mime type", "image/jpeg", mt.getName()); + assertEquals("Incorrect resource type", MimeType.BINARY, mt.getType()); + + mt = mimeTable.getContentTypeFor("foo"); + assertNull("Should return null mime type for file without extension", mt); + + mt = mimeTable.getContentTypeFor("foo.bar"); + assertNull("Should return null mime type for file with extension not configured in mime-types.xml", mt); + } + + /** + * This test checks the behavior of the mime-types@default-resource-type attribute + * The test config assigns all resources to application/xml + */ + @Test + public void testWithDefaultResourceTypeFeature() { + File existDir; + String existHome = System.getProperty("exist.home"); + existDir = existHome == null ? new File("./test/src/org/exist/util") : new File(existHome+"/test/src/org/exist/util"); + + MimeTable mimeTable = MimeTable.getInstance(new File(existDir, "mime-types-xml-default.xml")); + assertNotNull("Mime table not found", mimeTable); + + MimeType mt; + + mt = mimeTable.getContentTypeFor("test.xml"); + assertNotNull("Mime type not found for test.xml", mt); + assertEquals("Incorrect mime type", "application/xml", mt.getName()); + assertEquals("Incorrect resource type", MimeType.XML, mt.getType()); + + mt = mimeTable.getContentTypeFor("test.html"); + assertNotNull("Mime type not found for test.html", mt); + assertEquals("Incorrect mime type", "application/xml", mt.getName()); + assertEquals("Incorrect resource type", MimeType.XML, mt.getType()); + + mt = mimeTable.getContentTypeFor("test.jpg"); + assertNotNull("Mime type not found for test.jpg", mt); + assertEquals("Incorrect mime type", "application/xml", mt.getName()); + assertEquals("Incorrect resource type", MimeType.XML, mt.getType()); + + mt = mimeTable.getContentTypeFor("foo"); + assertNotNull("Mime type not found for foo", mt); + assertEquals("Incorrect mime type", "application/xml", mt.getName()); + assertEquals("Incorrect resource type", MimeType.XML, mt.getType()); + + mt = mimeTable.getContentTypeFor("foo.bar"); + assertNotNull("Mime type not found for test.jpg", mt); + assertEquals("Incorrect mime type", "application/xml", mt.getName()); + assertEquals("Incorrect resource type", MimeType.XML, mt.getType()); + } + + /** + * This test checks the behavior of the mime-types@default-mime-type attribute + * The test config assigns all resources to foo/bar (BINARY) + */ + @Test + public void testWithDefaultMimeTypeFeature() { + File existDir; + String existHome = System.getProperty("exist.home"); + existDir = existHome == null ? new File("./test/src/org/exist/util") : new File(existHome+"/test/src/org/exist/util"); + + MimeTable mimeTable = MimeTable.getInstance(new File(existDir, "mime-types-foo-default.xml")); + assertNotNull("Mime table not found", mimeTable); + + MimeType mt; + + mt = mimeTable.getContentTypeFor("test.xml"); + assertNotNull("Mime type not found for test.xml", mt); + assertEquals("Incorrect mime type", "foo/bar", mt.getName()); + assertEquals("Incorrect resource type", MimeType.BINARY, mt.getType()); + + mt = mimeTable.getContentTypeFor("test.html"); + assertNotNull("Mime type not found for test.html", mt); + assertEquals("Incorrect mime type", "foo/bar", mt.getName()); + assertEquals("Incorrect resource type", MimeType.BINARY, mt.getType()); + + mt = mimeTable.getContentTypeFor("test.jpg"); + assertNotNull("Mime type not found for test.jpg", mt); + assertEquals("Incorrect mime type", "foo/bar", mt.getName()); + assertEquals("Incorrect resource type", MimeType.BINARY, mt.getType()); + + mt = mimeTable.getContentTypeFor("foo"); + assertNotNull("Mime type not found for foo", mt); + assertEquals("Incorrect mime type", "foo/bar", mt.getName()); + assertEquals("Incorrect resource type", MimeType.BINARY, mt.getType()); + + mt = mimeTable.getContentTypeFor("foo.bar"); + assertNotNull("Mime type not found for test.jpg", mt); + assertEquals("Incorrect mime type", "foo/bar", mt.getName()); + assertEquals("Incorrect resource type", MimeType.BINARY, mt.getType()); + } +} diff --git a/test/src/org/exist/util/SortTests.java b/test/src/org/exist/util/SortTests.java index abe5685f11c..6d9707c08ae 100644 --- a/test/src/org/exist/util/SortTests.java +++ b/test/src/org/exist/util/SortTests.java @@ -1,73 +1,73 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2009 The eXist Project - * http://exist.sourceforge.net - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -package org.exist.util; - -import junit.framework.Test; -import junit.framework.TestSuite; - -import org.exist.util.sorters.SortMethodChecker; -import org.exist.util.sorters.SortingAlgorithmTester; - -/** - * Perform comprehensive testing of the eXist sort algorithms. - *

- * This work was undertaken as part of the development of the taxonomic - * repository at http://biodiversity.org.au . See Greg Whitbread for further details. - * - * @author pmurray@bigpond.com - * @author pmurray@anbg.gov.au - * @author https://sourceforge.net/users/paulmurray - * @author http://www.users.bigpond.com/pmurray - * - */ - -public class SortTests extends TestSuite { - - public static Test suite() { - return new SortTests("Test suite for org.exist.util sorting algorithms"); - } - - public static Test suite(String name) { - return new SortTests(name); - } - - private void init() { - for (SortingAlgorithmTester s : SortingAlgorithmTester.allSorters()) { - for (SortMethodChecker c : SortMethodChecker.allCheckers(s)) { - addTest(c.suite()); - } - } - } - - public SortTests() { - init(); - } - - public SortTests(String name) { - super(name); - init(); - } - - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2009 The eXist Project + * http://exist.sourceforge.net + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +package org.exist.util; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.exist.util.sorters.SortMethodChecker; +import org.exist.util.sorters.SortingAlgorithmTester; + +/** + * Perform comprehensive testing of the eXist sort algorithms. + *

+ * This work was undertaken as part of the development of the taxonomic + * repository at http://biodiversity.org.au . See Greg Whitbread for further details. + * + * @author pmurray@bigpond.com + * @author pmurray@anbg.gov.au + * @author https://sourceforge.net/users/paulmurray + * @author http://www.users.bigpond.com/pmurray + * + */ + +public class SortTests extends TestSuite { + + public static Test suite() { + return new SortTests("Test suite for org.exist.util sorting algorithms"); + } + + public static Test suite(String name) { + return new SortTests(name); + } + + private void init() { + for (SortingAlgorithmTester s : SortingAlgorithmTester.allSorters()) { + for (SortMethodChecker c : SortMethodChecker.allCheckers(s)) { + addTest(c.suite()); + } + } + } + + public SortTests() { + init(); + } + + public SortTests(String name) { + super(name); + init(); + } + + public static void main(String[] args) { + junit.textui.TestRunner.run(suite()); + } +} diff --git a/test/src/org/exist/util/mime-types-foo-default.xml b/test/src/org/exist/util/mime-types-foo-default.xml index 5101b5d5411..6b2d3f88f5b 100644 --- a/test/src/org/exist/util/mime-types-foo-default.xml +++ b/test/src/org/exist/util/mime-types-foo-default.xml @@ -1,9 +1,9 @@ - - - - - + + + + + diff --git a/test/src/org/exist/util/mime-types-xml-default.xml b/test/src/org/exist/util/mime-types-xml-default.xml index d3ae14cc08d..296b4f31d45 100644 --- a/test/src/org/exist/util/mime-types-xml-default.xml +++ b/test/src/org/exist/util/mime-types-xml-default.xml @@ -1,9 +1,9 @@ - - - - - + + + + + diff --git a/test/src/org/exist/util/sorters/ComparatorChecker.java b/test/src/org/exist/util/sorters/ComparatorChecker.java index 69066ad878e..7f8e4df4f3c 100644 --- a/test/src/org/exist/util/sorters/ComparatorChecker.java +++ b/test/src/org/exist/util/sorters/ComparatorChecker.java @@ -1,83 +1,83 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ - -package org.exist.util.sorters; - -import java.lang.reflect.Method; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Test case to check methods that use comparators. - *

- * This work was undertaken as part of the development of the taxonomic - * repository at http://biodiversity.org.au . See Greg Whitbread for further details. - * - * @author pmurray@bigpond.com - * @author pmurray@anbg.gov.au - * @author https://sourceforge.net/users/paulmurray - * @author http://www.users.bigpond.com/pmurray - * - */ - -public abstract class ComparatorChecker extends SortMethodChecker { - - enum SortOrder { - ASCENDING, DESCENDING, UNSTABLE, RANDOM - }; - - ComparatorChecker(SortingAlgorithmTester sorter) { - super(sorter); - } - - abstract void check(SortOrder sortOrder, int lo, int hi) throws Exception; - - abstract void sort(SortOrder sortOrder, int lo, int hi) throws Exception; - - void sort(SortOrder sortOrder) throws Exception { - sort(sortOrder, 0, getLength() - 1); - } - - void check(SortOrder sortOrder) throws Exception { - check(sortOrder, 0, getLength() - 1); - } - - public Test suite() { - TestSuite s = new TestSuite(); - s.setName(sorter.getClass().getSimpleName() + " " - + getClass().getSimpleName()); - String testSuiteName=s.getName(); - for (Method m : SortTestComparator.class.getMethods()) { - if (m.getName().startsWith("test")) { - s.addTest(new SortTestComparator( - this, - m.getName(), - testSuiteName - )); - } - } - - return s; - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ + +package org.exist.util.sorters; + +import java.lang.reflect.Method; + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * Test case to check methods that use comparators. + *

+ * This work was undertaken as part of the development of the taxonomic + * repository at http://biodiversity.org.au . See Greg Whitbread for further details. + * + * @author pmurray@bigpond.com + * @author pmurray@anbg.gov.au + * @author https://sourceforge.net/users/paulmurray + * @author http://www.users.bigpond.com/pmurray + * + */ + +public abstract class ComparatorChecker extends SortMethodChecker { + + enum SortOrder { + ASCENDING, DESCENDING, UNSTABLE, RANDOM + }; + + ComparatorChecker(SortingAlgorithmTester sorter) { + super(sorter); + } + + abstract void check(SortOrder sortOrder, int lo, int hi) throws Exception; + + abstract void sort(SortOrder sortOrder, int lo, int hi) throws Exception; + + void sort(SortOrder sortOrder) throws Exception { + sort(sortOrder, 0, getLength() - 1); + } + + void check(SortOrder sortOrder) throws Exception { + check(sortOrder, 0, getLength() - 1); + } + + public Test suite() { + TestSuite s = new TestSuite(); + s.setName(sorter.getClass().getSimpleName() + " " + + getClass().getSimpleName()); + String testSuiteName=s.getName(); + for (Method m : SortTestComparator.class.getMethods()) { + if (m.getName().startsWith("test")) { + s.addTest(new SortTestComparator( + this, + m.getName(), + testSuiteName + )); + } + } + + return s; + } +} diff --git a/test/src/org/exist/util/sorters/FastQSortTester.java b/test/src/org/exist/util/sorters/FastQSortTester.java index 3ae35272367..436fb4ae150 100644 --- a/test/src/org/exist/util/sorters/FastQSortTester.java +++ b/test/src/org/exist/util/sorters/FastQSortTester.java @@ -1,102 +1,102 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ - -package org.exist.util.sorters; - -import java.util.Comparator; -import java.util.List; - -import org.exist.dom.NodeProxy; -import org.exist.util.FastQSort; - -/** - * Interface to the quicksort methods. - *

- * This work was undertaken as part of the development of the taxonomic - * repository at http://biodiversity.org.au . See Greg Whitbread for further details. - * - * @author pmurray@bigpond.com - * @author pmurray@anbg.gov.au - * @author https://sourceforge.net/users/paulmurray - * @author http://www.users.bigpond.com/pmurray - * @see FastQSort - * - */ - -class FastQSortTester extends SortingAlgorithmTester { - public void invokeSort(C a[], Comparator c, int lo, int hi) - throws Exception - { - FastQSort.sort(a, c, lo, hi); - } - - public > void invokeSort(C[] a, int lo, int hi) - throws Exception - { - FastQSort.sort(a, lo, hi); - } - - public > void sort(C[] a, int lo, int hi) - throws Exception - { - FastQSort.sort(a, lo, hi); - } - - public > void sort(C[] a, int lo, int hi, int[] b) - throws Exception - { - FastQSort.sort(a, lo, hi, b); - } - - public void sort(C[] a, Comparator c, int lo, - int hi) - throws Exception - { - FastQSort.sort(a, c, lo, hi); - - } - - public > void sort(List a, int lo, int hi) - throws Exception - { - FastQSort.sort(a, lo, hi); - } - - public void sort(int lo, int hi,NodeProxy[] a) - throws Exception - { - sort(a, lo, hi); - } - - public void sort(long[] a, int lo, int hi, Object[] b) - throws Exception - { - FastQSort.sort(a, lo, hi, b); - } - - public void sortByNodeId(NodeProxy[] a, int lo, int hi) - throws Exception - { - FastQSort.sortByNodeId(a, lo, hi); - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ + +package org.exist.util.sorters; + +import java.util.Comparator; +import java.util.List; + +import org.exist.dom.NodeProxy; +import org.exist.util.FastQSort; + +/** + * Interface to the quicksort methods. + *

+ * This work was undertaken as part of the development of the taxonomic + * repository at http://biodiversity.org.au . See Greg Whitbread for further details. + * + * @author pmurray@bigpond.com + * @author pmurray@anbg.gov.au + * @author https://sourceforge.net/users/paulmurray + * @author http://www.users.bigpond.com/pmurray + * @see FastQSort + * + */ + +class FastQSortTester extends SortingAlgorithmTester { + public void invokeSort(C a[], Comparator c, int lo, int hi) + throws Exception + { + FastQSort.sort(a, c, lo, hi); + } + + public > void invokeSort(C[] a, int lo, int hi) + throws Exception + { + FastQSort.sort(a, lo, hi); + } + + public > void sort(C[] a, int lo, int hi) + throws Exception + { + FastQSort.sort(a, lo, hi); + } + + public > void sort(C[] a, int lo, int hi, int[] b) + throws Exception + { + FastQSort.sort(a, lo, hi, b); + } + + public void sort(C[] a, Comparator c, int lo, + int hi) + throws Exception + { + FastQSort.sort(a, c, lo, hi); + + } + + public > void sort(List a, int lo, int hi) + throws Exception + { + FastQSort.sort(a, lo, hi); + } + + public void sort(int lo, int hi,NodeProxy[] a) + throws Exception + { + sort(a, lo, hi); + } + + public void sort(long[] a, int lo, int hi, Object[] b) + throws Exception + { + FastQSort.sort(a, lo, hi, b); + } + + public void sortByNodeId(NodeProxy[] a, int lo, int hi) + throws Exception + { + FastQSort.sortByNodeId(a, lo, hi); + } +} diff --git a/test/src/org/exist/util/sorters/HSortTester.java b/test/src/org/exist/util/sorters/HSortTester.java index 4449459b960..1869de65029 100644 --- a/test/src/org/exist/util/sorters/HSortTester.java +++ b/test/src/org/exist/util/sorters/HSortTester.java @@ -1,94 +1,94 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ - -package org.exist.util.sorters; - -import java.util.Comparator; -import java.util.List; - -import org.exist.dom.NodeProxy; -import org.exist.util.HSort; - -/** - * Interface to the improved heapsort methods. - * - * @author José María Fernández (jmfg@users.sourceforge.net) - * @see HSort - * - */ - -class HSortTester extends SortingAlgorithmTester { - public > void invokeSort(C[] a, int lo, int hi) - throws Exception - { - HSort.sort(a, lo, hi); - } - - public void invokeSort(C a[], Comparator c, int lo, int hi) - throws Exception - { - HSort.sort(a, c, lo, hi); - } - - public > void sort(C[] a, int lo, int hi) - throws Exception - { - HSort.sort(a, lo, hi); - } - - public > void sort(C[] a, int lo, int hi, int[] b) - throws Exception - { - HSort.sort(a, lo, hi, b); - } - - public void sort(C[] a, Comparator c, int lo, - int hi) - throws Exception - { - HSort.sort(a, c, lo, hi); - } - - public > void sort(List a, int lo, int hi) - throws Exception - { - HSort.sort(a, lo, hi); - } - - public void sort(int lo, int hi,NodeProxy[] a) - throws Exception - { - sort(a, lo, hi); - } - - public void sort(long[] a, int lo, int hi, Object[] b) - throws Exception - { - HSort.sort(a, lo, hi, b); - } - - public void sortByNodeId(NodeProxy[] a, int lo, int hi) - throws Exception - { - HSort.sortByNodeId(a, lo, hi); - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ + +package org.exist.util.sorters; + +import java.util.Comparator; +import java.util.List; + +import org.exist.dom.NodeProxy; +import org.exist.util.HSort; + +/** + * Interface to the improved heapsort methods. + * + * @author José María Fernández (jmfg@users.sourceforge.net) + * @see HSort + * + */ + +class HSortTester extends SortingAlgorithmTester { + public > void invokeSort(C[] a, int lo, int hi) + throws Exception + { + HSort.sort(a, lo, hi); + } + + public void invokeSort(C a[], Comparator c, int lo, int hi) + throws Exception + { + HSort.sort(a, c, lo, hi); + } + + public > void sort(C[] a, int lo, int hi) + throws Exception + { + HSort.sort(a, lo, hi); + } + + public > void sort(C[] a, int lo, int hi, int[] b) + throws Exception + { + HSort.sort(a, lo, hi, b); + } + + public void sort(C[] a, Comparator c, int lo, + int hi) + throws Exception + { + HSort.sort(a, c, lo, hi); + } + + public > void sort(List a, int lo, int hi) + throws Exception + { + HSort.sort(a, lo, hi); + } + + public void sort(int lo, int hi,NodeProxy[] a) + throws Exception + { + sort(a, lo, hi); + } + + public void sort(long[] a, int lo, int hi, Object[] b) + throws Exception + { + HSort.sort(a, lo, hi, b); + } + + public void sortByNodeId(NodeProxy[] a, int lo, int hi) + throws Exception + { + HSort.sortByNodeId(a, lo, hi); + } +} diff --git a/test/src/org/exist/util/sorters/HeapSortTester.java b/test/src/org/exist/util/sorters/HeapSortTester.java index 2f8cd507c82..6a632ea0b52 100644 --- a/test/src/org/exist/util/sorters/HeapSortTester.java +++ b/test/src/org/exist/util/sorters/HeapSortTester.java @@ -1,102 +1,102 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ - -package org.exist.util.sorters; - -import java.util.Comparator; -import java.util.List; - -import org.exist.dom.NodeProxy; -import org.exist.util.HeapSort; - -/** - * Interface to the heapsort methods. - *

- * This work was undertaken as part of the development of the taxonomic - * repository at http://biodiversity.org.au . See Greg Whitbread for further details. - * - * @author pmurray@bigpond.com - * @author pmurray@anbg.gov.au - * @author https://sourceforge.net/users/paulmurray - * @author http://www.users.bigpond.com/pmurray - * @see HeapSort - * - */ - -class HeapSortTester extends SortingAlgorithmTester { - public > void invokeSort(C[] a, int lo, int hi) - throws Exception - { - HeapSort.sort(a, lo, hi); - } - - public void invokeSort(C a[], Comparator c, int lo, int hi) - throws Exception - { - HeapSort.sort(a, c, lo, hi); - } - - public > void sort(C[] a, int lo, int hi) - throws Exception - { - HeapSort.sort(a, lo, hi); - } - - public > void sort(C[] a, int lo, int hi, int[] b) - throws Exception - { - HeapSort.sort(a, lo, hi, b); - } - - public void sort(C[] a, Comparator c, int lo, - int hi) - throws Exception - { - HeapSort.sort(a, c, lo, hi); - - } - - public > void sort(List a, int lo, int hi) - throws Exception - { - HeapSort.sort(a, lo, hi); - } - - public void sort(int lo, int hi,NodeProxy[] a) - throws Exception - { - sort(a, lo, hi); - } - - public void sort(long[] a, int lo, int hi, Object[] b) - throws Exception - { - HeapSort.sort(a, lo, hi, b); - } - - public void sortByNodeId(NodeProxy[] a, int lo, int hi) - throws Exception - { - HeapSort.sortByNodeId(a, lo, hi); - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ + +package org.exist.util.sorters; + +import java.util.Comparator; +import java.util.List; + +import org.exist.dom.NodeProxy; +import org.exist.util.HeapSort; + +/** + * Interface to the heapsort methods. + *

+ * This work was undertaken as part of the development of the taxonomic + * repository at http://biodiversity.org.au . See Greg Whitbread for further details. + * + * @author pmurray@bigpond.com + * @author pmurray@anbg.gov.au + * @author https://sourceforge.net/users/paulmurray + * @author http://www.users.bigpond.com/pmurray + * @see HeapSort + * + */ + +class HeapSortTester extends SortingAlgorithmTester { + public > void invokeSort(C[] a, int lo, int hi) + throws Exception + { + HeapSort.sort(a, lo, hi); + } + + public void invokeSort(C a[], Comparator c, int lo, int hi) + throws Exception + { + HeapSort.sort(a, c, lo, hi); + } + + public > void sort(C[] a, int lo, int hi) + throws Exception + { + HeapSort.sort(a, lo, hi); + } + + public > void sort(C[] a, int lo, int hi, int[] b) + throws Exception + { + HeapSort.sort(a, lo, hi, b); + } + + public void sort(C[] a, Comparator c, int lo, + int hi) + throws Exception + { + HeapSort.sort(a, c, lo, hi); + + } + + public > void sort(List a, int lo, int hi) + throws Exception + { + HeapSort.sort(a, lo, hi); + } + + public void sort(int lo, int hi,NodeProxy[] a) + throws Exception + { + sort(a, lo, hi); + } + + public void sort(long[] a, int lo, int hi, Object[] b) + throws Exception + { + HeapSort.sort(a, lo, hi, b); + } + + public void sortByNodeId(NodeProxy[] a, int lo, int hi) + throws Exception + { + HeapSort.sortByNodeId(a, lo, hi); + } +} diff --git a/test/src/org/exist/util/sorters/InsertionSortTester.java b/test/src/org/exist/util/sorters/InsertionSortTester.java index 066657d85e0..4acb7c6d84c 100644 --- a/test/src/org/exist/util/sorters/InsertionSortTester.java +++ b/test/src/org/exist/util/sorters/InsertionSortTester.java @@ -1,100 +1,100 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ - -package org.exist.util.sorters; - -import java.util.Comparator; -import java.util.List; - -import org.exist.dom.NodeProxy; -import org.exist.util.InsertionSort; - -/** - * Interface to the insertion sort methods. - *

- * This work was undertaken as part of the development of the taxonomic - * repository at http://biodiversity.org.au . See Greg Whitbread for further details. - * - * @author pmurray@bigpond.com - * @author pmurray@anbg.gov.au - * @author https://sourceforge.net/users/paulmurray - * @author http://www.users.bigpond.com/pmurray - * @see InsertionSort - */ - -class InsertionSortTester extends SortingAlgorithmTester { - public > void invokeSort(C[] a, int lo, int hi) - throws Exception - { - InsertionSort.sort(a, lo, hi); - } - - public void invokeSort(C a[], Comparator c, int lo, int hi) - throws Exception - { - InsertionSort.sort(a, c, lo, hi); - } - - public > void sort(C[] a, int lo, int hi) - throws Exception - { - InsertionSort.sort(a, lo, hi); - } - - public > void sort(C[] a, int lo, int hi, int[] b) - throws Exception - { - InsertionSort.sort(a, lo, hi, b); - } - - public void sort(C[] a, Comparator c, int lo, - int hi) - throws Exception - { - InsertionSort.sort(a, c, lo, hi); - } - - public > void sort(List a, int lo, int hi) - throws Exception - { - InsertionSort.sort(a, lo, hi); - } - - public void sort(int lo, int hi, NodeProxy[] a) - throws Exception - { - sort(a, lo, hi); - } - - public void sort(long[] a, int lo, int hi, Object[] b) - throws Exception - { - InsertionSort.sort(a, lo, hi, b); - } - - public void sortByNodeId(NodeProxy[] a, int lo, int hi) - throws Exception - { - InsertionSort.sortByNodeId(a, lo, hi); - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ + +package org.exist.util.sorters; + +import java.util.Comparator; +import java.util.List; + +import org.exist.dom.NodeProxy; +import org.exist.util.InsertionSort; + +/** + * Interface to the insertion sort methods. + *

+ * This work was undertaken as part of the development of the taxonomic + * repository at http://biodiversity.org.au . See Greg Whitbread for further details. + * + * @author pmurray@bigpond.com + * @author pmurray@anbg.gov.au + * @author https://sourceforge.net/users/paulmurray + * @author http://www.users.bigpond.com/pmurray + * @see InsertionSort + */ + +class InsertionSortTester extends SortingAlgorithmTester { + public > void invokeSort(C[] a, int lo, int hi) + throws Exception + { + InsertionSort.sort(a, lo, hi); + } + + public void invokeSort(C a[], Comparator c, int lo, int hi) + throws Exception + { + InsertionSort.sort(a, c, lo, hi); + } + + public > void sort(C[] a, int lo, int hi) + throws Exception + { + InsertionSort.sort(a, lo, hi); + } + + public > void sort(C[] a, int lo, int hi, int[] b) + throws Exception + { + InsertionSort.sort(a, lo, hi, b); + } + + public void sort(C[] a, Comparator c, int lo, + int hi) + throws Exception + { + InsertionSort.sort(a, c, lo, hi); + } + + public > void sort(List a, int lo, int hi) + throws Exception + { + InsertionSort.sort(a, lo, hi); + } + + public void sort(int lo, int hi, NodeProxy[] a) + throws Exception + { + sort(a, lo, hi); + } + + public void sort(long[] a, int lo, int hi, Object[] b) + throws Exception + { + InsertionSort.sort(a, lo, hi, b); + } + + public void sortByNodeId(NodeProxy[] a, int lo, int hi) + throws Exception + { + InsertionSort.sortByNodeId(a, lo, hi); + } +} diff --git a/test/src/org/exist/util/sorters/ListChecker.java b/test/src/org/exist/util/sorters/ListChecker.java index 09004ecbedd..c7b59750528 100644 --- a/test/src/org/exist/util/sorters/ListChecker.java +++ b/test/src/org/exist/util/sorters/ListChecker.java @@ -1,91 +1,91 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ - -package org.exist.util.sorters; - -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.List; - -/** - * Check sort(List). - *

- * This work was undertaken as part of the development of the taxonomic - * repository at http://biodiversity.org.au . See Greg Whitbread for further details. - * - * @author pmurray@bigpond.com - * @author pmurray@anbg.gov.au - * @author https://sourceforge.net/users/paulmurray - * @author http://www.users.bigpond.com/pmurray - * - */ - -class ListChecker extends SortMethodChecker { - ListChecker(SortingAlgorithmTester sorter) { - super(sorter); - } - - List a; - - /** - * It asserts the ascending ordering of an Integer List - */ - void check(int lo, int hi) { - for (int i = lo; i < hi; i++) { - assertTrue(a.get(i).intValue() <= a.get(i + 1).intValue()); - } - } - - /** - * It returns the length of the list to be used on assertion - */ - int getLength() { - return a.size(); - } - - /** - * It loads an input int array into the internal Integer list - */ - void init(int[] values) throws Exception { - a = new ArrayList(values.length); - for (int i = 0; i < values.length; i++) { - a.add(Integer.valueOf(values[i])); - } - } - - /** - * This method invokes sort routine on selected sorter - */ - void sort(int lo, int hi) throws Exception { - sorter.sort(a, lo, hi); - } - - /** - * This method asserts single values - */ - void checkValue(int idx, int v) { - assertEquals("@" + idx, v, a.get(idx).intValue()); - } +/* + * eXist Open Source Native XML Database + * Copyright (C) 2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ + +package org.exist.util.sorters; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; + +/** + * Check sort(List). + *

+ * This work was undertaken as part of the development of the taxonomic + * repository at http://biodiversity.org.au . See Greg Whitbread for further details. + * + * @author pmurray@bigpond.com + * @author pmurray@anbg.gov.au + * @author https://sourceforge.net/users/paulmurray + * @author http://www.users.bigpond.com/pmurray + * + */ + +class ListChecker extends SortMethodChecker { + ListChecker(SortingAlgorithmTester sorter) { + super(sorter); + } + + List a; + + /** + * It asserts the ascending ordering of an Integer List + */ + void check(int lo, int hi) { + for (int i = lo; i < hi; i++) { + assertTrue(a.get(i).intValue() <= a.get(i + 1).intValue()); + } + } + + /** + * It returns the length of the list to be used on assertion + */ + int getLength() { + return a.size(); + } + + /** + * It loads an input int array into the internal Integer list + */ + void init(int[] values) throws Exception { + a = new ArrayList(values.length); + for (int i = 0; i < values.length; i++) { + a.add(Integer.valueOf(values[i])); + } + } + + /** + * This method invokes sort routine on selected sorter + */ + void sort(int lo, int hi) throws Exception { + sorter.sort(a, lo, hi); + } + + /** + * This method asserts single values + */ + void checkValue(int idx, int v) { + assertEquals("@" + idx, v, a.get(idx).intValue()); + } } \ No newline at end of file diff --git a/test/src/org/exist/util/sorters/LongArrayAndObjectChecker.java b/test/src/org/exist/util/sorters/LongArrayAndObjectChecker.java index a292caa27b4..44107c1ae80 100644 --- a/test/src/org/exist/util/sorters/LongArrayAndObjectChecker.java +++ b/test/src/org/exist/util/sorters/LongArrayAndObjectChecker.java @@ -1,94 +1,94 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ - -package org.exist.util.sorters; - -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertTrue; - -/** - * check sort(long[], Object[]) - *

- * This work was undertaken as part of the development of the taxonomic - * repository at http://biodiversity.org.au . See Greg Whitbread for further details. - * - * @author pmurray@bigpond.com - * @author pmurray@anbg.gov.au - * @author https://sourceforge.net/users/paulmurray - * @author http://www.users.bigpond.com/pmurray - * - */ -class LongArrayAndObjectChecker extends SortMethodChecker { - LongArrayAndObjectChecker(SortingAlgorithmTester sorter) { - super(sorter); - } - - long[] a; - Integer[] b; - - /** - * It returns the length of the array to be used on assertion - */ - int getLength() { - return a.length; - } - - /** - * It asserts the ascending ordering of the couple of - * Integer and long arrays given an specific comparator - */ - void check(int lo, int hi) { - for (int i = lo; i < hi; i++) { - assertTrue(a[i] <= a[i + 1]); - assertEquals(a[i], b[i].intValue()); - } - assertEquals(a[hi], b[hi].intValue()); - } - - /** - * It loads an input int array into the internal Integer one - */ - void init(int[] values) throws Exception { - a = new long[values.length]; - b = new Integer[values.length]; - for (int i = 0; i < values.length; i++) { - a[i] = values[i]; - b[i] = Integer.valueOf(values[i]); - } - } - - /** - * This method invokes sort routine on selected sorter - */ - void sort(int lo, int hi) throws Exception { - sorter.sort(a, lo, hi, b); - } - - /** - * This method asserts single values - */ - void checkValue(int idx, int v) { - assertEquals("@" + idx, v, a[idx]); - assertEquals("@" + idx, v, b[idx].intValue()); - } +/* + * eXist Open Source Native XML Database + * Copyright (C) 2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ + +package org.exist.util.sorters; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertTrue; + +/** + * check sort(long[], Object[]) + *

+ * This work was undertaken as part of the development of the taxonomic + * repository at http://biodiversity.org.au . See Greg Whitbread for further details. + * + * @author pmurray@bigpond.com + * @author pmurray@anbg.gov.au + * @author https://sourceforge.net/users/paulmurray + * @author http://www.users.bigpond.com/pmurray + * + */ +class LongArrayAndObjectChecker extends SortMethodChecker { + LongArrayAndObjectChecker(SortingAlgorithmTester sorter) { + super(sorter); + } + + long[] a; + Integer[] b; + + /** + * It returns the length of the array to be used on assertion + */ + int getLength() { + return a.length; + } + + /** + * It asserts the ascending ordering of the couple of + * Integer and long arrays given an specific comparator + */ + void check(int lo, int hi) { + for (int i = lo; i < hi; i++) { + assertTrue(a[i] <= a[i + 1]); + assertEquals(a[i], b[i].intValue()); + } + assertEquals(a[hi], b[hi].intValue()); + } + + /** + * It loads an input int array into the internal Integer one + */ + void init(int[] values) throws Exception { + a = new long[values.length]; + b = new Integer[values.length]; + for (int i = 0; i < values.length; i++) { + a[i] = values[i]; + b[i] = Integer.valueOf(values[i]); + } + } + + /** + * This method invokes sort routine on selected sorter + */ + void sort(int lo, int hi) throws Exception { + sorter.sort(a, lo, hi, b); + } + + /** + * This method asserts single values + */ + void checkValue(int idx, int v) { + assertEquals("@" + idx, v, a[idx]); + assertEquals("@" + idx, v, b[idx].intValue()); + } } \ No newline at end of file diff --git a/test/src/org/exist/util/sorters/NodeProxyByIdChecker.java b/test/src/org/exist/util/sorters/NodeProxyByIdChecker.java index 8f0ce0cb27b..d125fd59ca2 100644 --- a/test/src/org/exist/util/sorters/NodeProxyByIdChecker.java +++ b/test/src/org/exist/util/sorters/NodeProxyByIdChecker.java @@ -1,85 +1,85 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ - -package org.exist.util.sorters; - -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertTrue; - -import org.exist.dom.NodeProxy; - -/** - * check sortByNodeId(NodeProxy[]) - *

- * This work was undertaken as part of the development of the taxonomic - * repository at http://biodiversity.org.au . See Greg Whitbread for further details. - * - * @author pmurray@bigpond.com - * @author pmurray@anbg.gov.au - * @author https://sourceforge.net/users/paulmurray - * @author http://www.users.bigpond.com/pmurray - * - */ - -class NodeProxyByIdChecker extends NodeProxyChecker { - NodeProxyByIdChecker(SortingAlgorithmTester sorter) { - super(sorter); - } - - /** - * It asserts the ascending ordering of an NodeProxy array - * based on NodeId - */ - void check(int lo, int hi) { - for (int i = lo; i < hi; i++) { - assertTrue(((SortTestNodeProxy) a[i]).getNodeId().i <= ((SortTestNodeProxy) a[i + 1]) - .getNodeId().i); - } - } - - /** - * It asserts the ascending ordering of a NodeProxy array - * based on the NodeIds - */ - void init(int[] values) throws Exception { - a = new NodeProxy[values.length]; - for (int i = 0; i < values.length; i++) { - a[i] = new SortTestNodeProxy(values[i], -rnd.nextInt(1000)); - } - } - - /** - * This method invokes sort routine on selected sorter - * based on NodeId from NodeProxy elements - */ - void sort(int lo, int hi) throws Exception { - sorter.sortByNodeId(a, lo, hi); - } - - /** - * This method asserts single values - */ - void checkValue(int idx, int v) { - assertEquals("@" + idx, v, ((SortTestNodeProxy) a[idx]).getNodeId().i); - } +/* + * eXist Open Source Native XML Database + * Copyright (C) 2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ + +package org.exist.util.sorters; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertTrue; + +import org.exist.dom.NodeProxy; + +/** + * check sortByNodeId(NodeProxy[]) + *

+ * This work was undertaken as part of the development of the taxonomic + * repository at http://biodiversity.org.au . See Greg Whitbread for further details. + * + * @author pmurray@bigpond.com + * @author pmurray@anbg.gov.au + * @author https://sourceforge.net/users/paulmurray + * @author http://www.users.bigpond.com/pmurray + * + */ + +class NodeProxyByIdChecker extends NodeProxyChecker { + NodeProxyByIdChecker(SortingAlgorithmTester sorter) { + super(sorter); + } + + /** + * It asserts the ascending ordering of an NodeProxy array + * based on NodeId + */ + void check(int lo, int hi) { + for (int i = lo; i < hi; i++) { + assertTrue(((SortTestNodeProxy) a[i]).getNodeId().i <= ((SortTestNodeProxy) a[i + 1]) + .getNodeId().i); + } + } + + /** + * It asserts the ascending ordering of a NodeProxy array + * based on the NodeIds + */ + void init(int[] values) throws Exception { + a = new NodeProxy[values.length]; + for (int i = 0; i < values.length; i++) { + a[i] = new SortTestNodeProxy(values[i], -rnd.nextInt(1000)); + } + } + + /** + * This method invokes sort routine on selected sorter + * based on NodeId from NodeProxy elements + */ + void sort(int lo, int hi) throws Exception { + sorter.sortByNodeId(a, lo, hi); + } + + /** + * This method asserts single values + */ + void checkValue(int idx, int v) { + assertEquals("@" + idx, v, ((SortTestNodeProxy) a[idx]).getNodeId().i); + } } \ No newline at end of file diff --git a/test/src/org/exist/util/sorters/NodeProxyChecker.java b/test/src/org/exist/util/sorters/NodeProxyChecker.java index 910080030d0..a4c9a98b77a 100644 --- a/test/src/org/exist/util/sorters/NodeProxyChecker.java +++ b/test/src/org/exist/util/sorters/NodeProxyChecker.java @@ -1,87 +1,87 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ - -package org.exist.util.sorters; - -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertTrue; - -import org.exist.dom.NodeProxy; - -/** - * check sort(NodeProxy) - *

- * This work was undertaken as part of the development of the taxonomic - * repository at http://biodiversity.org.au . See Greg Whitbread for further details. - * - * @author pmurray@bigpond.com - * @author pmurray@anbg.gov.au - * @author https://sourceforge.net/users/paulmurray - * @author http://www.users.bigpond.com/pmurray - * - */ - -class NodeProxyChecker extends SortMethodChecker { - NodeProxyChecker(SortingAlgorithmTester sorter) { - super(sorter); - } - - NodeProxy[] a; - - int getLength() { - return a.length; - } - - /** - * It asserts the ascending ordering of a NodeProxy array - */ - void check(int lo, int hi) { - for (int i = lo; i < hi; i++) { - assertTrue(((SortTestNodeProxy) a[i]).val <= ((SortTestNodeProxy) a[i + 1]).val); - } - } - - /** - * It loads an input int array into the internal NodeProxy one - */ - void init(int[] values) throws Exception { - a = new NodeProxy[values.length]; - for (int i = 0; i < values.length; i++) { - a[i] = new SortTestNodeProxy(-rnd.nextInt(1000), values[i]); - } - } - - /** - * This method invokes sort routine on selected sorter - */ - void sort(int lo, int hi) throws Exception { - sorter.sort(a, lo, hi); - } - - /** - * This method asserts single values - */ - void checkValue(int idx, int v) { - assertEquals("@" + idx, v, ((SortTestNodeProxy) a[idx]).val); - } +/* + * eXist Open Source Native XML Database + * Copyright (C) 2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ + +package org.exist.util.sorters; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertTrue; + +import org.exist.dom.NodeProxy; + +/** + * check sort(NodeProxy) + *

+ * This work was undertaken as part of the development of the taxonomic + * repository at http://biodiversity.org.au . See Greg Whitbread for further details. + * + * @author pmurray@bigpond.com + * @author pmurray@anbg.gov.au + * @author https://sourceforge.net/users/paulmurray + * @author http://www.users.bigpond.com/pmurray + * + */ + +class NodeProxyChecker extends SortMethodChecker { + NodeProxyChecker(SortingAlgorithmTester sorter) { + super(sorter); + } + + NodeProxy[] a; + + int getLength() { + return a.length; + } + + /** + * It asserts the ascending ordering of a NodeProxy array + */ + void check(int lo, int hi) { + for (int i = lo; i < hi; i++) { + assertTrue(((SortTestNodeProxy) a[i]).val <= ((SortTestNodeProxy) a[i + 1]).val); + } + } + + /** + * It loads an input int array into the internal NodeProxy one + */ + void init(int[] values) throws Exception { + a = new NodeProxy[values.length]; + for (int i = 0; i < values.length; i++) { + a[i] = new SortTestNodeProxy(-rnd.nextInt(1000), values[i]); + } + } + + /** + * This method invokes sort routine on selected sorter + */ + void sort(int lo, int hi) throws Exception { + sorter.sort(a, lo, hi); + } + + /** + * This method asserts single values + */ + void checkValue(int idx, int v) { + assertEquals("@" + idx, v, ((SortTestNodeProxy) a[idx]).val); + } } \ No newline at end of file diff --git a/test/src/org/exist/util/sorters/ObjectAndIntArrayChecker.java b/test/src/org/exist/util/sorters/ObjectAndIntArrayChecker.java index 269dbb71556..dd40a49fdf4 100644 --- a/test/src/org/exist/util/sorters/ObjectAndIntArrayChecker.java +++ b/test/src/org/exist/util/sorters/ObjectAndIntArrayChecker.java @@ -1,96 +1,96 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ - -package org.exist.util.sorters; - -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertTrue; - -/** - * check sort(Object[], int[]) - *

- * This work was undertaken as part of the development of the taxonomic - * repository at http://biodiversity.org.au . See Greg Whitbread for further details. - * - * @author pmurray@bigpond.com - * @author pmurray@anbg.gov.au - * @author https://sourceforge.net/users/paulmurray - * @author http://www.users.bigpond.com/pmurray - * - */ - -class ObjectAndIntArrayChecker extends SortMethodChecker { - ObjectAndIntArrayChecker(SortingAlgorithmTester sorter) { - super(sorter); - } - - Integer[] a; - int[] b; - - /** - * It asserts the ascending ordering of an Integer array - * given an specific comparator - */ - void check(int lo, int hi) { - for (int i = lo; i < hi; i++) { - assertTrue(a[i].intValue() <= a[i + 1].intValue()); - assertEquals(a[i].intValue(), b[i]); - } - assertEquals(a[hi].intValue(), b[hi]); - } - - /** - * It returns the length of the array to be used on assertion - */ - int getLength() { - return a.length; - } - - /** - * It loads an input int array into the internal - * Integer and int ones - */ - void init(int[] values) throws Exception { - a = new Integer[values.length]; - b = new int[values.length]; - for (int i = 0; i < values.length; i++) { - a[i] = Integer.valueOf(values[i]); - b[i] = values[i]; - } - } - - /** - * This method invokes sort routine on selected sorter - */ - void sort(int lo, int hi) throws Exception { - sorter.sort(a, lo, hi, b); - } - - /** - * This method asserts single values - */ - void checkValue(int idx, int v) { - assertEquals("@" + idx, v, a[idx].intValue()); - assertEquals("@" + idx, v, b[idx]); - } +/* + * eXist Open Source Native XML Database + * Copyright (C) 2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ + +package org.exist.util.sorters; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertTrue; + +/** + * check sort(Object[], int[]) + *

+ * This work was undertaken as part of the development of the taxonomic + * repository at http://biodiversity.org.au . See Greg Whitbread for further details. + * + * @author pmurray@bigpond.com + * @author pmurray@anbg.gov.au + * @author https://sourceforge.net/users/paulmurray + * @author http://www.users.bigpond.com/pmurray + * + */ + +class ObjectAndIntArrayChecker extends SortMethodChecker { + ObjectAndIntArrayChecker(SortingAlgorithmTester sorter) { + super(sorter); + } + + Integer[] a; + int[] b; + + /** + * It asserts the ascending ordering of an Integer array + * given an specific comparator + */ + void check(int lo, int hi) { + for (int i = lo; i < hi; i++) { + assertTrue(a[i].intValue() <= a[i + 1].intValue()); + assertEquals(a[i].intValue(), b[i]); + } + assertEquals(a[hi].intValue(), b[hi]); + } + + /** + * It returns the length of the array to be used on assertion + */ + int getLength() { + return a.length; + } + + /** + * It loads an input int array into the internal + * Integer and int ones + */ + void init(int[] values) throws Exception { + a = new Integer[values.length]; + b = new int[values.length]; + for (int i = 0; i < values.length; i++) { + a[i] = Integer.valueOf(values[i]); + b[i] = values[i]; + } + } + + /** + * This method invokes sort routine on selected sorter + */ + void sort(int lo, int hi) throws Exception { + sorter.sort(a, lo, hi, b); + } + + /** + * This method asserts single values + */ + void checkValue(int idx, int v) { + assertEquals("@" + idx, v, a[idx].intValue()); + assertEquals("@" + idx, v, b[idx]); + } } \ No newline at end of file diff --git a/test/src/org/exist/util/sorters/PlainArrayChecker.java b/test/src/org/exist/util/sorters/PlainArrayChecker.java index 9cf5a579d90..2c2a60c375c 100644 --- a/test/src/org/exist/util/sorters/PlainArrayChecker.java +++ b/test/src/org/exist/util/sorters/PlainArrayChecker.java @@ -1,157 +1,157 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ - -package org.exist.util.sorters; - -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertTrue; - -import java.util.Comparator; - -/** - * check sort(Comparable[]) - *

- * This work was undertaken as part of the development of the taxonomic - * repository at http://biodiversity.org.au . See Greg Whitbread for further details. - * - * @author pmurray@bigpond.com - * @author pmurray@anbg.gov.au - * @author https://sourceforge.net/users/paulmurray - * @author http://www.users.bigpond.com/pmurray - * - */ -class PlainArrayChecker extends ComparatorChecker { - PlainArrayChecker(SortingAlgorithmTester sorter) { - super(sorter); - } - - Integer[] a; - - /** - * It asserts the ascending ordering of an Integer array - */ - void check(int lo, int hi) { - for (int i = lo; i < hi; i++) { - assertTrue(a[i].intValue() <= a[i + 1].intValue()); - } - } - - /** - * It loads an input int array into the internal Integer one - */ - void init(int[] values) - throws Exception - { - a = new Integer[values.length]; - for (int i = 0; i < values.length; i++) { - a[i] = Integer.valueOf(values[i]); - } - - } - - /** - * It returns the length of the array to be used on assertion - */ - int getLength() { - return a.length; - } - - /** - * This method invokes sort routine on selected sorter - */ - void sort(int lo, int hi) - throws Exception - { - sorter.sort(a, lo, hi); - } - - /** - * This method invokes sort routine with a given - * comparator on selected sorter - */ - void sort(SortOrder sortOrder, int lo, int hi) - throws Exception - { - sorter.sort(a, getComparator(sortOrder), lo, hi); - } - - /** - * This method asserts single values - */ - void checkValue(int idx, int v) { - assertEquals("@" + idx, v, a[idx].intValue()); - } - - /** - * It asserts the ascending ordering of an Integer array - * given an specific comparator - */ - void check(SortOrder sortOrder, int lo, int hi) - throws Exception - { - Comparator c = getComparator(sortOrder); - for (int i = lo; i < hi; i++) { - assertTrue(c.compare(a[i], a[i + 1]) <= 0); - } - } - - /** - * This method returns an Integer comparator based - * on input sort order - * @param sortOrder - * @return - */ - Comparator getComparator(SortOrder sortOrder) { - switch (sortOrder) { - case ASCENDING: - return new Comparator() { - public int compare(Integer o1, Integer o2) { - return o1.intValue() - o2.intValue(); - } - }; - case DESCENDING: - return new Comparator() { - public int compare(Integer o1, Integer o2) { - return o2.intValue() - o1.intValue(); - } - }; - case RANDOM: - return new Comparator() { - public int compare(Integer o1, Integer o2) { - return rnd.nextBoolean() ? -1 : 1; - } - }; - case UNSTABLE: - return new Comparator() { - public int compare(Integer o1, Integer o2) { - if (o1.intValue() <= o2.intValue()) - return (o2.intValue() - o1.intValue()) % 3 - 1; - else - return 1 - (o1.intValue() - o2.intValue()) % 3; - } - }; - } - return null; // should never happen - } - +/* + * eXist Open Source Native XML Database + * Copyright (C) 2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ + +package org.exist.util.sorters; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertTrue; + +import java.util.Comparator; + +/** + * check sort(Comparable[]) + *

+ * This work was undertaken as part of the development of the taxonomic + * repository at http://biodiversity.org.au . See Greg Whitbread for further details. + * + * @author pmurray@bigpond.com + * @author pmurray@anbg.gov.au + * @author https://sourceforge.net/users/paulmurray + * @author http://www.users.bigpond.com/pmurray + * + */ +class PlainArrayChecker extends ComparatorChecker { + PlainArrayChecker(SortingAlgorithmTester sorter) { + super(sorter); + } + + Integer[] a; + + /** + * It asserts the ascending ordering of an Integer array + */ + void check(int lo, int hi) { + for (int i = lo; i < hi; i++) { + assertTrue(a[i].intValue() <= a[i + 1].intValue()); + } + } + + /** + * It loads an input int array into the internal Integer one + */ + void init(int[] values) + throws Exception + { + a = new Integer[values.length]; + for (int i = 0; i < values.length; i++) { + a[i] = Integer.valueOf(values[i]); + } + + } + + /** + * It returns the length of the array to be used on assertion + */ + int getLength() { + return a.length; + } + + /** + * This method invokes sort routine on selected sorter + */ + void sort(int lo, int hi) + throws Exception + { + sorter.sort(a, lo, hi); + } + + /** + * This method invokes sort routine with a given + * comparator on selected sorter + */ + void sort(SortOrder sortOrder, int lo, int hi) + throws Exception + { + sorter.sort(a, getComparator(sortOrder), lo, hi); + } + + /** + * This method asserts single values + */ + void checkValue(int idx, int v) { + assertEquals("@" + idx, v, a[idx].intValue()); + } + + /** + * It asserts the ascending ordering of an Integer array + * given an specific comparator + */ + void check(SortOrder sortOrder, int lo, int hi) + throws Exception + { + Comparator c = getComparator(sortOrder); + for (int i = lo; i < hi; i++) { + assertTrue(c.compare(a[i], a[i + 1]) <= 0); + } + } + + /** + * This method returns an Integer comparator based + * on input sort order + * @param sortOrder + * @return + */ + Comparator getComparator(SortOrder sortOrder) { + switch (sortOrder) { + case ASCENDING: + return new Comparator() { + public int compare(Integer o1, Integer o2) { + return o1.intValue() - o2.intValue(); + } + }; + case DESCENDING: + return new Comparator() { + public int compare(Integer o1, Integer o2) { + return o2.intValue() - o1.intValue(); + } + }; + case RANDOM: + return new Comparator() { + public int compare(Integer o1, Integer o2) { + return rnd.nextBoolean() ? -1 : 1; + } + }; + case UNSTABLE: + return new Comparator() { + public int compare(Integer o1, Integer o2) { + if (o1.intValue() <= o2.intValue()) + return (o2.intValue() - o1.intValue()) % 3 - 1; + else + return 1 - (o1.intValue() - o2.intValue()) % 3; + } + }; + } + return null; // should never happen + } + } \ No newline at end of file diff --git a/test/src/org/exist/util/sorters/SortMethodChecker.java b/test/src/org/exist/util/sorters/SortMethodChecker.java index 9c1b5017cfe..f0c78b1f9ca 100644 --- a/test/src/org/exist/util/sorters/SortMethodChecker.java +++ b/test/src/org/exist/util/sorters/SortMethodChecker.java @@ -1,103 +1,103 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ - -package org.exist.util.sorters; - -import java.lang.reflect.Method; -import java.util.Random; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Check one of the sort() methods, given an algorithm to use. - *

- * This work was undertaken as part of the development of the taxonomic - * repository at http://biodiversity.org.au . See Greg Whitbread for further details. - * - * @author pmurray@bigpond.com - * @author pmurray@anbg.gov.au - * @author https://sourceforge.net/users/paulmurray - * @author http://www.users.bigpond.com/pmurray - * - */ -public abstract class SortMethodChecker { - final SortingAlgorithmTester sorter; - protected final Random rnd = new Random(); - - SortMethodChecker(SortingAlgorithmTester sorter) { - this.sorter = sorter; - } - - abstract void checkValue(int idx, int v) throws Exception; - - public String toString() { - return getClass().getSimpleName() + " " - + sorter.getClass().getSimpleName(); - } - - abstract void init(int[] values) throws Exception; - - abstract int getLength() throws Exception; - - abstract void sort(int lo, int hi) throws Exception; - - abstract void check(int lo, int hi) throws Exception; - - void sort() throws Exception { - sort(0, getLength() - 1); - } - - void check() throws Exception { - check(0, getLength() - 1); - } - - public Test suite() { - TestSuite s = new TestSuite(); - s.setName(sorter.getClass().getSimpleName() + " " - + getClass().getSimpleName()); - String testSuiteName = s.getName(); - for (Method m : SortTestCase.class.getMethods()) { - if (m.getName().startsWith("test")) { - s.addTest(new SortTestCase( - this, - m.getName(), - testSuiteName - )); - } - } - return s; - } - - public static SortMethodChecker[] allCheckers(SortingAlgorithmTester s) { - return new SortMethodChecker[] { - new PlainArrayChecker(s), - new ListChecker(s), - new ObjectAndIntArrayChecker(s), - new LongArrayAndObjectChecker(s), - new NodeProxyChecker(s), - new NodeProxyByIdChecker(s) - }; - } - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ + +package org.exist.util.sorters; + +import java.lang.reflect.Method; +import java.util.Random; + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * Check one of the sort() methods, given an algorithm to use. + *

+ * This work was undertaken as part of the development of the taxonomic + * repository at http://biodiversity.org.au . See Greg Whitbread for further details. + * + * @author pmurray@bigpond.com + * @author pmurray@anbg.gov.au + * @author https://sourceforge.net/users/paulmurray + * @author http://www.users.bigpond.com/pmurray + * + */ +public abstract class SortMethodChecker { + final SortingAlgorithmTester sorter; + protected final Random rnd = new Random(); + + SortMethodChecker(SortingAlgorithmTester sorter) { + this.sorter = sorter; + } + + abstract void checkValue(int idx, int v) throws Exception; + + public String toString() { + return getClass().getSimpleName() + " " + + sorter.getClass().getSimpleName(); + } + + abstract void init(int[] values) throws Exception; + + abstract int getLength() throws Exception; + + abstract void sort(int lo, int hi) throws Exception; + + abstract void check(int lo, int hi) throws Exception; + + void sort() throws Exception { + sort(0, getLength() - 1); + } + + void check() throws Exception { + check(0, getLength() - 1); + } + + public Test suite() { + TestSuite s = new TestSuite(); + s.setName(sorter.getClass().getSimpleName() + " " + + getClass().getSimpleName()); + String testSuiteName = s.getName(); + for (Method m : SortTestCase.class.getMethods()) { + if (m.getName().startsWith("test")) { + s.addTest(new SortTestCase( + this, + m.getName(), + testSuiteName + )); + } + } + return s; + } + + public static SortMethodChecker[] allCheckers(SortingAlgorithmTester s) { + return new SortMethodChecker[] { + new PlainArrayChecker(s), + new ListChecker(s), + new ObjectAndIntArrayChecker(s), + new LongArrayAndObjectChecker(s), + new NodeProxyChecker(s), + new NodeProxyByIdChecker(s) + }; + } + +} diff --git a/test/src/org/exist/util/sorters/SortTestCase.java b/test/src/org/exist/util/sorters/SortTestCase.java index 751a4821745..5eaf04e2985 100644 --- a/test/src/org/exist/util/sorters/SortTestCase.java +++ b/test/src/org/exist/util/sorters/SortTestCase.java @@ -1,191 +1,191 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ - -package org.exist.util.sorters; - - -import java.util.Random; - -import junit.framework.TestCase; - -/** - * TestCase - given a sort() method and an algorithm via a checker, do a variety - * of tests. - *

- * This work was undertaken as part of the development of the taxonomic - * repository at http://biodiversity.org.au . See Greg Whitbread for further details. - * - * @author pmurray@bigpond.com - * @author pmurray@anbg.gov.au - * @author https://sourceforge.net/users/paulmurray - * @author http://www.users.bigpond.com/pmurray - * - */ -public class SortTestCase extends TestCase { - - protected final Random rnd = new Random(); - protected final CH checker; - protected final String testSuite; - - SortTestCase(CH checker, String method, String testSuite) { - super(method); - this.checker = checker; - this.testSuite = testSuite; - } - - protected int[] getRandomIntArray(int sz) { - int[] a = new int[sz]; - for (int i = 0; i < sz; i++) { - a[i] = rnd.nextInt(1000); - } - return a; - } - - protected int[] getConstantIntArray(int sz) { - int[] a = new int[sz]; - for (int i = 0; i < sz; i++) { - a[i] = 0; - } - return a; - } - - protected int[] getAscendingIntArray(int sz) { - int[] a = new int[sz]; - for (int i = 0; i < sz; i++) { - a[i] = i; - } - return a; - } - - protected int[] getDescendingIntArray(int sz) { - int[] a = new int[sz]; - for (int i = 0; i < sz; i++) { - a[i] = sz - i - 1; - } - return a; - } - - public void testSingleElement() throws Exception { - checker.init(getConstantIntArray(1)); - checker.sort(); - } - - public void testRandom() throws Exception { - for (int i = 0; i < 10; i++) { - checker.init(getRandomIntArray(100)); - checker.sort(); - checker.check(); - } - } - - public void testConstant() throws Exception { - checker.init(getConstantIntArray(100)); - checker.sort(); - checker.check(); - } - - public void testAscending() throws Exception { - checker.init(getAscendingIntArray(100)); - checker.sort(); - checker.check(); - } - - public void testDecending() throws Exception { - checker.init(getDescendingIntArray(100)); - checker.sort(); - checker.check(); - } - - public void testSortSubsection1() throws Exception { - - for (int i = 0; i < 1000; i += 100) { - int[] a = new int[1000]; - - for (int ii = 0; ii < 1000; ii++) { - a[ii] = (ii >= i && ii < i + 100) ? rnd.nextInt(1000) - : 999 - ii; - } - - checker.init(a); - checker.sort(i, i + 99); - checker.check(i, i + 99); - - // check that the other values have not been disturbed - for (int ii = 0; ii < i; ii++) { - checker.checkValue(ii, 999 - ii); - } - for (int ii = i + 100; ii < 1000; ii++) { - checker.checkValue(ii, 999 - ii); - } - - } - } - - public void testSortSubsection2() throws Exception { - for (int i = 0; i < 1000; i += 100) { - int[] a = new int[1000]; - - for (int ii = 0; ii < 1000; ii++) { - a[ii] = (ii >= i && ii < i + 100) ? rnd.nextInt(1000) : ii; - } - - checker.init(a); - checker.sort(i, i + 99); - checker.check(i, i + 99); - - // check that the other values have not been disturbed - for (int ii = 0; ii < i; ii++) { - checker.checkValue(ii, ii); - } - for (int ii = i + 100; ii < 1000; ii++) { - checker.checkValue(ii, ii); - } - - } - } - - public void testSortSubsection3() throws Exception { - - for (int i = 0; i < 1000; i += 100) { - int[] a = new int[1000]; - - for (int ii = 0; ii < 1000; ii++) { - a[ii] = (ii >= i && ii < i + 100) ? rnd.nextInt(1000) - : (ii % 7); - } - - checker.init(a); - checker.sort(i, i + 99); - checker.check(i, i + 99); - - // check that the other values have not been disturbed - for (int ii = 0; ii < i; ii++) { - checker.checkValue(ii, ii % 7); - } - for (int ii = i + 100; ii < 1000; ii++) { - checker.checkValue(ii, ii % 7); - } - - } - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ + +package org.exist.util.sorters; + + +import java.util.Random; + +import junit.framework.TestCase; + +/** + * TestCase - given a sort() method and an algorithm via a checker, do a variety + * of tests. + *

+ * This work was undertaken as part of the development of the taxonomic + * repository at http://biodiversity.org.au . See Greg Whitbread for further details. + * + * @author pmurray@bigpond.com + * @author pmurray@anbg.gov.au + * @author https://sourceforge.net/users/paulmurray + * @author http://www.users.bigpond.com/pmurray + * + */ +public class SortTestCase extends TestCase { + + protected final Random rnd = new Random(); + protected final CH checker; + protected final String testSuite; + + SortTestCase(CH checker, String method, String testSuite) { + super(method); + this.checker = checker; + this.testSuite = testSuite; + } + + protected int[] getRandomIntArray(int sz) { + int[] a = new int[sz]; + for (int i = 0; i < sz; i++) { + a[i] = rnd.nextInt(1000); + } + return a; + } + + protected int[] getConstantIntArray(int sz) { + int[] a = new int[sz]; + for (int i = 0; i < sz; i++) { + a[i] = 0; + } + return a; + } + + protected int[] getAscendingIntArray(int sz) { + int[] a = new int[sz]; + for (int i = 0; i < sz; i++) { + a[i] = i; + } + return a; + } + + protected int[] getDescendingIntArray(int sz) { + int[] a = new int[sz]; + for (int i = 0; i < sz; i++) { + a[i] = sz - i - 1; + } + return a; + } + + public void testSingleElement() throws Exception { + checker.init(getConstantIntArray(1)); + checker.sort(); + } + + public void testRandom() throws Exception { + for (int i = 0; i < 10; i++) { + checker.init(getRandomIntArray(100)); + checker.sort(); + checker.check(); + } + } + + public void testConstant() throws Exception { + checker.init(getConstantIntArray(100)); + checker.sort(); + checker.check(); + } + + public void testAscending() throws Exception { + checker.init(getAscendingIntArray(100)); + checker.sort(); + checker.check(); + } + + public void testDecending() throws Exception { + checker.init(getDescendingIntArray(100)); + checker.sort(); + checker.check(); + } + + public void testSortSubsection1() throws Exception { + + for (int i = 0; i < 1000; i += 100) { + int[] a = new int[1000]; + + for (int ii = 0; ii < 1000; ii++) { + a[ii] = (ii >= i && ii < i + 100) ? rnd.nextInt(1000) + : 999 - ii; + } + + checker.init(a); + checker.sort(i, i + 99); + checker.check(i, i + 99); + + // check that the other values have not been disturbed + for (int ii = 0; ii < i; ii++) { + checker.checkValue(ii, 999 - ii); + } + for (int ii = i + 100; ii < 1000; ii++) { + checker.checkValue(ii, 999 - ii); + } + + } + } + + public void testSortSubsection2() throws Exception { + for (int i = 0; i < 1000; i += 100) { + int[] a = new int[1000]; + + for (int ii = 0; ii < 1000; ii++) { + a[ii] = (ii >= i && ii < i + 100) ? rnd.nextInt(1000) : ii; + } + + checker.init(a); + checker.sort(i, i + 99); + checker.check(i, i + 99); + + // check that the other values have not been disturbed + for (int ii = 0; ii < i; ii++) { + checker.checkValue(ii, ii); + } + for (int ii = i + 100; ii < 1000; ii++) { + checker.checkValue(ii, ii); + } + + } + } + + public void testSortSubsection3() throws Exception { + + for (int i = 0; i < 1000; i += 100) { + int[] a = new int[1000]; + + for (int ii = 0; ii < 1000; ii++) { + a[ii] = (ii >= i && ii < i + 100) ? rnd.nextInt(1000) + : (ii % 7); + } + + checker.init(a); + checker.sort(i, i + 99); + checker.check(i, i + 99); + + // check that the other values have not been disturbed + for (int ii = 0; ii < i; ii++) { + checker.checkValue(ii, ii % 7); + } + for (int ii = i + 100; ii < 1000; ii++) { + checker.checkValue(ii, ii % 7); + } + + } + } +} diff --git a/test/src/org/exist/util/sorters/SortTestComparator.java b/test/src/org/exist/util/sorters/SortTestComparator.java index a4542d47401..a20418682a7 100644 --- a/test/src/org/exist/util/sorters/SortTestComparator.java +++ b/test/src/org/exist/util/sorters/SortTestComparator.java @@ -1,177 +1,177 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ - -package org.exist.util.sorters; - -import org.exist.util.sorters.ComparatorChecker.SortOrder; - -/** - * TestCase - given a sort() method and an algorithm via a checker, do a variety - * of tests that rely on the comparator methods. - *

- * This work was undertaken as part of the development of the taxonomic - * repository at http://biodiversity.org.au . See Greg Whitbread for further details. - * - * @author pmurray@bigpond.com - * @author pmurray@anbg.gov.au - * @author https://sourceforge.net/users/paulmurray - * @author http://www.users.bigpond.com/pmurray - * - */ -public class SortTestComparator - extends SortTestCase -{ - SortTestComparator(CH checker, String method, String testSuite) { - super(checker, method, testSuite); - } - - public void testComparatorAscending() throws Exception { - System.out.print("\n"+testSuite+" "+getName()+" "); - for (int i = 0; i < 10; i++) { - checker.init(getRandomIntArray(100)); - checker.sort(SortOrder.ASCENDING); - checker.check(SortOrder.ASCENDING); - } - } - - public void testComparatorDescending() throws Exception { - System.out.print("\n"+testSuite+" "+getName()+" "); - for (int i = 0; i < 10; i++) { - checker.init(getRandomIntArray(100)); - checker.sort(SortOrder.DESCENDING); - checker.check(SortOrder.DESCENDING); - } - } - - public void testBadComparatorUnstable() throws Exception { - System.out.print("\n"+testSuite+" "+getName()+" "); - for (int i = 0; i < 10; i++) { - checker.init(getRandomIntArray(100)); - checker.sort(SortOrder.UNSTABLE); - } - } - - public void testBadComparatorRandom() throws Exception { - System.out.print("\n"+testSuite+" "+getName()+" "); - checker.init(getRandomIntArray(100)); - checker.sort(SortOrder.RANDOM); - } - - public void testSortSubsection1asc() throws Exception { - System.out.print("\n"+testSuite+" "+getName()+" "); - for (int i = 0; i < 1000; i += 100) { - int[] a = new int[1000]; - - for (int ii = 0; ii < 1000; ii++) { - a[ii] = (ii >= i && ii < i + 100) ? rnd.nextInt(1000) - : 999 - ii; - } - - checker.init(a); - checker.sort(SortOrder.ASCENDING, i, i + 99); - checker.check(SortOrder.ASCENDING, i, i + 99); - - // check that the other values have not been disturbed - for (int ii = 0; ii < i; ii++) { - checker.checkValue(ii, 999 - ii); - } - for (int ii = i + 100; ii < 1000; ii++) { - checker.checkValue(ii, 999 - ii); - } - } - } - - public void testSortSubsection2asc() throws Exception { - System.out.print("\n"+testSuite+" "+getName()+" "); - for (int i = 0; i < 1000; i += 100) { - int[] a = new int[1000]; - - for (int ii = 0; ii < 1000; ii++) { - a[ii] = (ii >= i && ii < i + 100) ? rnd.nextInt(1000) : ii; - } - - checker.init(a); - checker.sort(SortOrder.ASCENDING, i, i + 99); - checker.check(SortOrder.ASCENDING, i, i + 99); - - // check that the other values have not been disturbed - for (int ii = 0; ii < i; ii++) { - checker.checkValue(ii, ii); - } - for (int ii = i + 100; ii < 1000; ii++) { - checker.checkValue(ii, ii); - } - } - } - - public void testSortSubsection1desc() throws Exception { - System.out.print("\n"+testSuite+" "+getName()+" "); - - for (int i = 0; i < 1000; i += 100) { - int[] a = new int[1000]; - - for (int ii = 0; ii < 1000; ii++) { - a[ii] = (ii >= i && ii < i + 100) ? rnd.nextInt(1000) - : 999 - ii; - } - - checker.init(a); - checker.sort(SortOrder.DESCENDING, i, i + 99); - checker.check(SortOrder.DESCENDING, i, i + 99); - - // check that the other values have not been disturbed - for (int ii = 0; ii < i; ii++) { - checker.checkValue(ii, 999 - ii); - } - for (int ii = i + 100; ii < 1000; ii++) { - checker.checkValue(ii, 999 - ii); - } - - } - } - - public void testSortSubsection2desc() throws Exception { - System.out.print("\n"+testSuite+" "+getName()+" "); - for (int i = 0; i < 1000; i += 100) { - int[] a = new int[1000]; - - for (int ii = 0; ii < 1000; ii++) { - a[ii] = (ii >= i && ii < i + 100) ? rnd.nextInt(1000) : ii; - } - - checker.init(a); - checker.sort(SortOrder.DESCENDING, i, i + 99); - checker.check(SortOrder.DESCENDING, i, i + 99); - - // check that the other values have not been disturbed - for (int ii = 0; ii < i; ii++) { - checker.checkValue(ii, ii); - } - for (int ii = i + 100; ii < 1000; ii++) { - checker.checkValue(ii, ii); - } - - } - } - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ + +package org.exist.util.sorters; + +import org.exist.util.sorters.ComparatorChecker.SortOrder; + +/** + * TestCase - given a sort() method and an algorithm via a checker, do a variety + * of tests that rely on the comparator methods. + *

+ * This work was undertaken as part of the development of the taxonomic + * repository at http://biodiversity.org.au . See Greg Whitbread for further details. + * + * @author pmurray@bigpond.com + * @author pmurray@anbg.gov.au + * @author https://sourceforge.net/users/paulmurray + * @author http://www.users.bigpond.com/pmurray + * + */ +public class SortTestComparator + extends SortTestCase +{ + SortTestComparator(CH checker, String method, String testSuite) { + super(checker, method, testSuite); + } + + public void testComparatorAscending() throws Exception { + System.out.print("\n"+testSuite+" "+getName()+" "); + for (int i = 0; i < 10; i++) { + checker.init(getRandomIntArray(100)); + checker.sort(SortOrder.ASCENDING); + checker.check(SortOrder.ASCENDING); + } + } + + public void testComparatorDescending() throws Exception { + System.out.print("\n"+testSuite+" "+getName()+" "); + for (int i = 0; i < 10; i++) { + checker.init(getRandomIntArray(100)); + checker.sort(SortOrder.DESCENDING); + checker.check(SortOrder.DESCENDING); + } + } + + public void testBadComparatorUnstable() throws Exception { + System.out.print("\n"+testSuite+" "+getName()+" "); + for (int i = 0; i < 10; i++) { + checker.init(getRandomIntArray(100)); + checker.sort(SortOrder.UNSTABLE); + } + } + + public void testBadComparatorRandom() throws Exception { + System.out.print("\n"+testSuite+" "+getName()+" "); + checker.init(getRandomIntArray(100)); + checker.sort(SortOrder.RANDOM); + } + + public void testSortSubsection1asc() throws Exception { + System.out.print("\n"+testSuite+" "+getName()+" "); + for (int i = 0; i < 1000; i += 100) { + int[] a = new int[1000]; + + for (int ii = 0; ii < 1000; ii++) { + a[ii] = (ii >= i && ii < i + 100) ? rnd.nextInt(1000) + : 999 - ii; + } + + checker.init(a); + checker.sort(SortOrder.ASCENDING, i, i + 99); + checker.check(SortOrder.ASCENDING, i, i + 99); + + // check that the other values have not been disturbed + for (int ii = 0; ii < i; ii++) { + checker.checkValue(ii, 999 - ii); + } + for (int ii = i + 100; ii < 1000; ii++) { + checker.checkValue(ii, 999 - ii); + } + } + } + + public void testSortSubsection2asc() throws Exception { + System.out.print("\n"+testSuite+" "+getName()+" "); + for (int i = 0; i < 1000; i += 100) { + int[] a = new int[1000]; + + for (int ii = 0; ii < 1000; ii++) { + a[ii] = (ii >= i && ii < i + 100) ? rnd.nextInt(1000) : ii; + } + + checker.init(a); + checker.sort(SortOrder.ASCENDING, i, i + 99); + checker.check(SortOrder.ASCENDING, i, i + 99); + + // check that the other values have not been disturbed + for (int ii = 0; ii < i; ii++) { + checker.checkValue(ii, ii); + } + for (int ii = i + 100; ii < 1000; ii++) { + checker.checkValue(ii, ii); + } + } + } + + public void testSortSubsection1desc() throws Exception { + System.out.print("\n"+testSuite+" "+getName()+" "); + + for (int i = 0; i < 1000; i += 100) { + int[] a = new int[1000]; + + for (int ii = 0; ii < 1000; ii++) { + a[ii] = (ii >= i && ii < i + 100) ? rnd.nextInt(1000) + : 999 - ii; + } + + checker.init(a); + checker.sort(SortOrder.DESCENDING, i, i + 99); + checker.check(SortOrder.DESCENDING, i, i + 99); + + // check that the other values have not been disturbed + for (int ii = 0; ii < i; ii++) { + checker.checkValue(ii, 999 - ii); + } + for (int ii = i + 100; ii < 1000; ii++) { + checker.checkValue(ii, 999 - ii); + } + + } + } + + public void testSortSubsection2desc() throws Exception { + System.out.print("\n"+testSuite+" "+getName()+" "); + for (int i = 0; i < 1000; i += 100) { + int[] a = new int[1000]; + + for (int ii = 0; ii < 1000; ii++) { + a[ii] = (ii >= i && ii < i + 100) ? rnd.nextInt(1000) : ii; + } + + checker.init(a); + checker.sort(SortOrder.DESCENDING, i, i + 99); + checker.check(SortOrder.DESCENDING, i, i + 99); + + // check that the other values have not been disturbed + for (int ii = 0; ii < i; ii++) { + checker.checkValue(ii, ii); + } + for (int ii = i + 100; ii < 1000; ii++) { + checker.checkValue(ii, ii); + } + + } + } + +} diff --git a/test/src/org/exist/util/sorters/SortTestNodeId.java b/test/src/org/exist/util/sorters/SortTestNodeId.java index 963517d758d..af503b80722 100644 --- a/test/src/org/exist/util/sorters/SortTestNodeId.java +++ b/test/src/org/exist/util/sorters/SortTestNodeId.java @@ -1,150 +1,150 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ - -package org.exist.util.sorters; - -import java.io.IOException; - -import org.exist.numbering.NodeId; -import org.exist.storage.io.VariableByteOutputStream; - -/** - * Mock NodeId. - *

- * This work was undertaken as part of the development of the taxonomic - * repository at http://biodiversity.org.au . See Greg Whitbread for further details. - * - * @author pmurray@bigpond.com - * @author pmurray@anbg.gov.au - * @author https://sourceforge.net/users/paulmurray - * @author http://www.users.bigpond.com/pmurray - * @see NodeId - * - */ -class SortTestNodeId implements NodeId { - final int i; - - SortTestNodeId(int i) { - this.i = i; - } - - public boolean after(NodeId arg0, boolean arg1) { - throw new UnsupportedOperationException(); - } - - public boolean before(NodeId arg0, boolean arg1) { - throw new UnsupportedOperationException(); - } - - public int compareTo(SortTestNodeId arg0) { - if (i < 0) - throw new IllegalStateException( - "Sort ought not be looking at the nodeid"); - return i - arg0.i; - } - - public int compareTo(NodeId arg0) { - return compareTo((SortTestNodeId) arg0); - } - - public int computeRelation(NodeId arg0) { - throw new UnsupportedOperationException(); - } - - public boolean equals(NodeId arg0) { - return i == ((SortTestNodeId) arg0).i; - } - - public NodeId getChild(int arg0) { - throw new UnsupportedOperationException(); - } - - public NodeId getParentId() { - throw new UnsupportedOperationException(); - } - - public int getTreeLevel() { - throw new UnsupportedOperationException(); - } - - public NodeId insertBefore() { - throw new UnsupportedOperationException(); - } - - public NodeId insertNode(NodeId arg0) { - throw new UnsupportedOperationException(); - } - - public boolean isChildOf(NodeId arg0) { - throw new UnsupportedOperationException(); - } - - public boolean isDescendantOf(NodeId arg0) { - throw new UnsupportedOperationException(); - } - - public boolean isDescendantOrSelfOf(NodeId arg0) { - throw new UnsupportedOperationException(); - } - - public boolean isSiblingOf(NodeId arg0) { - throw new UnsupportedOperationException(); - } - - public NodeId newChild() { - throw new UnsupportedOperationException(); - } - - public NodeId nextSibling() { - throw new UnsupportedOperationException(); - } - - public NodeId precedingSibling() { - throw new UnsupportedOperationException(); - } - - public void serialize(byte[] arg0, int arg1) { - throw new UnsupportedOperationException(); - } - - public int size() { - throw new UnsupportedOperationException(); - } - - public int units() { - throw new UnsupportedOperationException(); - } - - public void write(VariableByteOutputStream arg0) { - throw new UnsupportedOperationException(); - } - - public NodeId write(NodeId arg0, VariableByteOutputStream arg1) - throws IOException { - throw new UnsupportedOperationException(); - } - - public NodeId append(NodeId other) { - throw new UnsupportedOperationException(); - } +/* + * eXist Open Source Native XML Database + * Copyright (C) 2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ + +package org.exist.util.sorters; + +import java.io.IOException; + +import org.exist.numbering.NodeId; +import org.exist.storage.io.VariableByteOutputStream; + +/** + * Mock NodeId. + *

+ * This work was undertaken as part of the development of the taxonomic + * repository at http://biodiversity.org.au . See Greg Whitbread for further details. + * + * @author pmurray@bigpond.com + * @author pmurray@anbg.gov.au + * @author https://sourceforge.net/users/paulmurray + * @author http://www.users.bigpond.com/pmurray + * @see NodeId + * + */ +class SortTestNodeId implements NodeId { + final int i; + + SortTestNodeId(int i) { + this.i = i; + } + + public boolean after(NodeId arg0, boolean arg1) { + throw new UnsupportedOperationException(); + } + + public boolean before(NodeId arg0, boolean arg1) { + throw new UnsupportedOperationException(); + } + + public int compareTo(SortTestNodeId arg0) { + if (i < 0) + throw new IllegalStateException( + "Sort ought not be looking at the nodeid"); + return i - arg0.i; + } + + public int compareTo(NodeId arg0) { + return compareTo((SortTestNodeId) arg0); + } + + public int computeRelation(NodeId arg0) { + throw new UnsupportedOperationException(); + } + + public boolean equals(NodeId arg0) { + return i == ((SortTestNodeId) arg0).i; + } + + public NodeId getChild(int arg0) { + throw new UnsupportedOperationException(); + } + + public NodeId getParentId() { + throw new UnsupportedOperationException(); + } + + public int getTreeLevel() { + throw new UnsupportedOperationException(); + } + + public NodeId insertBefore() { + throw new UnsupportedOperationException(); + } + + public NodeId insertNode(NodeId arg0) { + throw new UnsupportedOperationException(); + } + + public boolean isChildOf(NodeId arg0) { + throw new UnsupportedOperationException(); + } + + public boolean isDescendantOf(NodeId arg0) { + throw new UnsupportedOperationException(); + } + + public boolean isDescendantOrSelfOf(NodeId arg0) { + throw new UnsupportedOperationException(); + } + + public boolean isSiblingOf(NodeId arg0) { + throw new UnsupportedOperationException(); + } + + public NodeId newChild() { + throw new UnsupportedOperationException(); + } + + public NodeId nextSibling() { + throw new UnsupportedOperationException(); + } + + public NodeId precedingSibling() { + throw new UnsupportedOperationException(); + } + + public void serialize(byte[] arg0, int arg1) { + throw new UnsupportedOperationException(); + } + + public int size() { + throw new UnsupportedOperationException(); + } + + public int units() { + throw new UnsupportedOperationException(); + } + + public void write(VariableByteOutputStream arg0) { + throw new UnsupportedOperationException(); + } + + public NodeId write(NodeId arg0, VariableByteOutputStream arg1) + throws IOException { + throw new UnsupportedOperationException(); + } + + public NodeId append(NodeId other) { + throw new UnsupportedOperationException(); + } } \ No newline at end of file diff --git a/test/src/org/exist/util/sorters/SortTestNodeProxy.java b/test/src/org/exist/util/sorters/SortTestNodeProxy.java index ff4c31f3a59..de851055933 100644 --- a/test/src/org/exist/util/sorters/SortTestNodeProxy.java +++ b/test/src/org/exist/util/sorters/SortTestNodeProxy.java @@ -1,63 +1,63 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ - -package org.exist.util.sorters; - -import org.exist.dom.NodeProxy; - -/** - * Mock NodeProxy. - *

- * This work was undertaken as part of the development of the taxonomic - * repository at http://biodiversity.org.au . See Greg Whitbread for further details. - * - * @author pmurray@bigpond.com - * @author pmurray@anbg.gov.au - * @author https://sourceforge.net/users/paulmurray - * @author http://www.users.bigpond.com/pmurray - * @see NodeProxy - * - */ -class SortTestNodeProxy extends NodeProxy { - final int val; - - public SortTestNodeProxy(int id, int val) { - super(null, new SortTestNodeId(id)); - this.val = val; - } - - public int compareTo(Object o) { - if (val < 0) - throw new IllegalStateException( - "Sort ought not be looking at the value"); - if(!(o instanceof SortTestNodeProxy)) - throw new IllegalStateException("Test implementation limitation hit"); - - return val - ((SortTestNodeProxy)o).val; - } - - public SortTestNodeId getNodeId() { - return (SortTestNodeId) super.getNodeId(); - } - +/* + * eXist Open Source Native XML Database + * Copyright (C) 2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ + +package org.exist.util.sorters; + +import org.exist.dom.NodeProxy; + +/** + * Mock NodeProxy. + *

+ * This work was undertaken as part of the development of the taxonomic + * repository at http://biodiversity.org.au . See Greg Whitbread for further details. + * + * @author pmurray@bigpond.com + * @author pmurray@anbg.gov.au + * @author https://sourceforge.net/users/paulmurray + * @author http://www.users.bigpond.com/pmurray + * @see NodeProxy + * + */ +class SortTestNodeProxy extends NodeProxy { + final int val; + + public SortTestNodeProxy(int id, int val) { + super(null, new SortTestNodeId(id)); + this.val = val; + } + + public int compareTo(Object o) { + if (val < 0) + throw new IllegalStateException( + "Sort ought not be looking at the value"); + if(!(o instanceof SortTestNodeProxy)) + throw new IllegalStateException("Test implementation limitation hit"); + + return val - ((SortTestNodeProxy)o).val; + } + + public SortTestNodeId getNodeId() { + return (SortTestNodeId) super.getNodeId(); + } + } \ No newline at end of file diff --git a/test/src/org/exist/util/sorters/SortingAlgorithmTester.java b/test/src/org/exist/util/sorters/SortingAlgorithmTester.java index 7c81243c674..175527b63a3 100644 --- a/test/src/org/exist/util/sorters/SortingAlgorithmTester.java +++ b/test/src/org/exist/util/sorters/SortingAlgorithmTester.java @@ -1,78 +1,78 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ - -package org.exist.util.sorters; - -import java.util.Comparator; -import java.util.List; - -import org.exist.dom.NodeProxy; - -/** - * Interface to some sorting algorithm. - *

- * This work was undertaken as part of the development of the taxonomic - * repository at http://biodiversity.org.au . See Greg Whitbread for further details. - * - * @author pmurray@bigpond.com - * @author pmurray@anbg.gov.au - * @author https://sourceforge.net/users/paulmurray - * @author http://www.users.bigpond.com/pmurray - * - */ -public abstract class SortingAlgorithmTester { - abstract > void invokeSort(C[] a, int lo, int hi) - throws Exception; - - abstract void invokeSort(C a[], Comparator c, int lo, int hi) - throws Exception; - - abstract > void sort(C[] a, int lo, int hi) - throws Exception; - - abstract > void sort(C[] a, int lo, int hi, int[] b) - throws Exception; - - abstract void sort(C[] a, Comparator c, - int lo, int hi) throws Exception; - - abstract > void sort(List a, int lo, int hi) - throws Exception; - - // This one must change its parameters so some Java compilers do not - // get fooled - abstract void sort(int lo, int hi,NodeProxy[] a) throws Exception; - - abstract void sortByNodeId(NodeProxy[] a, int lo, int hi) throws Exception; - - abstract void sort(long[] a, int lo, int hi, Object b[]) throws Exception; - - public static SortingAlgorithmTester[] allSorters() { - return new SortingAlgorithmTester[] { - new InsertionSortTester(), - new HeapSortTester(), - new FastQSortTester(), -// new HSortTester(), - }; - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ + +package org.exist.util.sorters; + +import java.util.Comparator; +import java.util.List; + +import org.exist.dom.NodeProxy; + +/** + * Interface to some sorting algorithm. + *

+ * This work was undertaken as part of the development of the taxonomic + * repository at http://biodiversity.org.au . See Greg Whitbread for further details. + * + * @author pmurray@bigpond.com + * @author pmurray@anbg.gov.au + * @author https://sourceforge.net/users/paulmurray + * @author http://www.users.bigpond.com/pmurray + * + */ +public abstract class SortingAlgorithmTester { + abstract > void invokeSort(C[] a, int lo, int hi) + throws Exception; + + abstract void invokeSort(C a[], Comparator c, int lo, int hi) + throws Exception; + + abstract > void sort(C[] a, int lo, int hi) + throws Exception; + + abstract > void sort(C[] a, int lo, int hi, int[] b) + throws Exception; + + abstract void sort(C[] a, Comparator c, + int lo, int hi) throws Exception; + + abstract > void sort(List a, int lo, int hi) + throws Exception; + + // This one must change its parameters so some Java compilers do not + // get fooled + abstract void sort(int lo, int hi,NodeProxy[] a) throws Exception; + + abstract void sortByNodeId(NodeProxy[] a, int lo, int hi) throws Exception; + + abstract void sort(long[] a, int lo, int hi, Object b[]) throws Exception; + + public static SortingAlgorithmTester[] allSorters() { + return new SortingAlgorithmTester[] { + new InsertionSortTester(), + new HeapSortTester(), + new FastQSortTester(), +// new HSortTester(), + }; + } +} diff --git a/test/src/org/exist/validation/DatabaseCollectionTest.java b/test/src/org/exist/validation/DatabaseCollectionTest.java index 764b1712a6b..51def6980d9 100644 --- a/test/src/org/exist/validation/DatabaseCollectionTest.java +++ b/test/src/org/exist/validation/DatabaseCollectionTest.java @@ -1,109 +1,109 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2011 The eXist-db Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.validation; - -import org.exist.security.Account; -import org.exist.security.Permission; -import org.junit.*; -import static org.junit.Assert.*; - -import org.exist.xmldb.DatabaseInstanceManager; -import org.exist.xmldb.UserManagementService; -import org.exist.xmldb.XmldbURI; - -import org.xmldb.api.DatabaseManager; -import org.xmldb.api.base.Collection; -import org.xmldb.api.base.Database; -import org.xmldb.api.base.XMLDBException; -import org.xmldb.api.modules.CollectionManagementService; - -/** - * Created collections needed for validation tests. - * - * @author Dannes Wessels (dizzzz@exist-db.org) - */ -public class DatabaseCollectionTest { - - private final static String ROOT_URI = XmldbURI.LOCAL_DB; - private final static String DRIVER = "org.exist.xmldb.DatabaseImpl"; - - private final static String TEST_COLLECTION = "testValidationDatabaseCollection"; - - public final static String ADMIN_UID = "admin"; - public final static String ADMIN_PWD = ""; - - public final static String GUEST_UID = "guest"; - - @Before - public void setUp() { - try { - System.out.println(">>> setUp"); - Class cl = Class.forName(DRIVER); - Database database = (Database) cl.newInstance(); - database.setProperty("create-database", "true"); - DatabaseManager.registerDatabase(database); - Collection root = DatabaseManager.getCollection(ROOT_URI, ADMIN_UID, ADMIN_PWD); - CollectionManagementService cms = (CollectionManagementService)root.getService("CollectionManagementService", "1.0"); - Collection test = cms.createCollection(TEST_COLLECTION); - UserManagementService ums = (UserManagementService) test.getService("UserManagementService", "1.0"); - // change ownership to guest - Account guest = ums.getAccount(GUEST_UID); - ums.chown(guest, guest.getPrimaryGroup()); - ums.chmod(Permission.DEFAULT_COLLECTION_PERM); - - assertNotNull("Could not connect to database."); - System.out.println("<<<\n"); - } catch (Exception e) { - fail(e.getMessage()); - } - } - - @After - public void tearDown() throws Exception { - - //delete the test collection - Collection root = DatabaseManager.getCollection(ROOT_URI, ADMIN_UID, ADMIN_PWD); - CollectionManagementService cms = (CollectionManagementService)root.getService("CollectionManagementService", "1.0"); - cms.removeCollection(TEST_COLLECTION); - - DatabaseInstanceManager dim = (DatabaseInstanceManager) root.getService("DatabaseInstanceManager", "1.0"); - dim.shutdown(); - } - - @Test - public void createCollections() throws XMLDBException { - - Collection testCollection = DatabaseManager.getCollection(ROOT_URI + "/" + TEST_COLLECTION); - CollectionManagementService service = (CollectionManagementService) testCollection.getService("CollectionManagementService", "1.0"); - Collection validationCollection = service.createCollection(TestTools.VALIDATION_HOME_COLLECTION); - assertNotNull(validationCollection); - - validationCollection = service.createCollection(TestTools.VALIDATION_HOME_COLLECTION + "/" + TestTools.VALIDATION_TMP_COLLECTION); - assertNotNull(validationCollection); - - validationCollection = service.createCollection(TestTools.VALIDATION_HOME_COLLECTION + "/" + TestTools.VALIDATION_XSD_COLLECTION); - assertNotNull(validationCollection); - - validationCollection = service.createCollection(TestTools.VALIDATION_HOME_COLLECTION + "/" + TestTools.VALIDATION_DTD_COLLECTION); - assertNotNull(validationCollection); - } +/* + * eXist Open Source Native XML Database + * Copyright (C) 2011 The eXist-db Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.validation; + +import org.exist.security.Account; +import org.exist.security.Permission; +import org.junit.*; +import static org.junit.Assert.*; + +import org.exist.xmldb.DatabaseInstanceManager; +import org.exist.xmldb.UserManagementService; +import org.exist.xmldb.XmldbURI; + +import org.xmldb.api.DatabaseManager; +import org.xmldb.api.base.Collection; +import org.xmldb.api.base.Database; +import org.xmldb.api.base.XMLDBException; +import org.xmldb.api.modules.CollectionManagementService; + +/** + * Created collections needed for validation tests. + * + * @author Dannes Wessels (dizzzz@exist-db.org) + */ +public class DatabaseCollectionTest { + + private final static String ROOT_URI = XmldbURI.LOCAL_DB; + private final static String DRIVER = "org.exist.xmldb.DatabaseImpl"; + + private final static String TEST_COLLECTION = "testValidationDatabaseCollection"; + + public final static String ADMIN_UID = "admin"; + public final static String ADMIN_PWD = ""; + + public final static String GUEST_UID = "guest"; + + @Before + public void setUp() { + try { + System.out.println(">>> setUp"); + Class cl = Class.forName(DRIVER); + Database database = (Database) cl.newInstance(); + database.setProperty("create-database", "true"); + DatabaseManager.registerDatabase(database); + Collection root = DatabaseManager.getCollection(ROOT_URI, ADMIN_UID, ADMIN_PWD); + CollectionManagementService cms = (CollectionManagementService)root.getService("CollectionManagementService", "1.0"); + Collection test = cms.createCollection(TEST_COLLECTION); + UserManagementService ums = (UserManagementService) test.getService("UserManagementService", "1.0"); + // change ownership to guest + Account guest = ums.getAccount(GUEST_UID); + ums.chown(guest, guest.getPrimaryGroup()); + ums.chmod(Permission.DEFAULT_COLLECTION_PERM); + + assertNotNull("Could not connect to database."); + System.out.println("<<<\n"); + } catch (Exception e) { + fail(e.getMessage()); + } + } + + @After + public void tearDown() throws Exception { + + //delete the test collection + Collection root = DatabaseManager.getCollection(ROOT_URI, ADMIN_UID, ADMIN_PWD); + CollectionManagementService cms = (CollectionManagementService)root.getService("CollectionManagementService", "1.0"); + cms.removeCollection(TEST_COLLECTION); + + DatabaseInstanceManager dim = (DatabaseInstanceManager) root.getService("DatabaseInstanceManager", "1.0"); + dim.shutdown(); + } + + @Test + public void createCollections() throws XMLDBException { + + Collection testCollection = DatabaseManager.getCollection(ROOT_URI + "/" + TEST_COLLECTION); + CollectionManagementService service = (CollectionManagementService) testCollection.getService("CollectionManagementService", "1.0"); + Collection validationCollection = service.createCollection(TestTools.VALIDATION_HOME_COLLECTION); + assertNotNull(validationCollection); + + validationCollection = service.createCollection(TestTools.VALIDATION_HOME_COLLECTION + "/" + TestTools.VALIDATION_TMP_COLLECTION); + assertNotNull(validationCollection); + + validationCollection = service.createCollection(TestTools.VALIDATION_HOME_COLLECTION + "/" + TestTools.VALIDATION_XSD_COLLECTION); + assertNotNull(validationCollection); + + validationCollection = service.createCollection(TestTools.VALIDATION_HOME_COLLECTION + "/" + TestTools.VALIDATION_DTD_COLLECTION); + assertNotNull(validationCollection); + } } \ No newline at end of file diff --git a/test/src/org/exist/validation/TestTools.java b/test/src/org/exist/validation/TestTools.java index 55dc24254e8..64535aed631 100644 --- a/test/src/org/exist/validation/TestTools.java +++ b/test/src/org/exist/validation/TestTools.java @@ -1,170 +1,170 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ - -package org.exist.validation; - -import java.io.ByteArrayInputStream; -import org.apache.commons.io.output.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URL; -import java.net.URLConnection; - -import org.exist.util.ConfigurationHelper; - -/** - * A set of helper methods for the validation tests. - * - * @author Dannes Wessels (dizzzz@exist-db.org) - */ -public class TestTools { - - public final static String VALIDATION_HOME_COLLECTION = "validation"; - public final static String VALIDATION_DTD_COLLECTION = "dtd"; - public final static String VALIDATION_XSD_COLLECTION = "xsd"; - public final static String VALIDATION_TMP_COLLECTION = "tmp"; - - - /* - public static void insertResources(){ - - try { - String eXistHome = ConfigurationHelper.getExistHome().getAbsolutePath(); - - Class cl = Class.forName("org.exist.xmldb.DatabaseImpl"); - Database database = (Database) cl.newInstance(); - database.setProperty("create-database", "true"); - DatabaseManager.registerDatabase(database); - Collection root = DatabaseManager.getCollection("xmldb:exist://" + DBBroker.ROOT_COLLECTION, "admin", null); - XPathQueryService service = (XPathQueryService) root.getService("XQueryService", "1.0"); - - CollectionManagementService cmservice = (CollectionManagementService) root.getService("CollectionManagementService", "1.0"); - Collection col1 = cmservice.createCollection(TestTools.VALIDATION_HOME); - Collection col2 = cmservice.createCollection(TestTools.VALIDATION_XSD); - - Permission permission = PermissionAiderFactory.getPermission("guest", "guest", 999); - - UserManagementService umservice = (UserManagementService) root.getService("UserManagementService", "1.0"); - umservice.setPermissions(col1, permission); - umservice.setPermissions(col2, permission); - - String addressbook = eXistHome + "/samples/validation/addressbook"; - - TestTools.insertDocumentToURL(addressbook + "/addressbook.xsd", - "xmldb:exist://" + TestTools.VALIDATION_XSD + "/addressbook.xsd"); - TestTools.insertDocumentToURL(addressbook + "/catalog.xml", - "xmldb:exist://" + TestTools.VALIDATION_XSD + "/catalog.xml"); - - TestTools.insertDocumentToURL(addressbook + "/addressbook_valid.xml", - "xmldb:exist://" + TestTools.VALIDATION_HOME + "/addressbook_valid.xml"); - TestTools.insertDocumentToURL(addressbook + "/addressbook_invalid.xml", - "xmldb:exist://" + TestTools.VALIDATION_HOME + "/addressbook_invalid.xml"); - - } catch (Throwable ex) { - ex.printStackTrace(); - } - }*/ - - // Transfer bytes from in to out - public static void copyStream(InputStream is, OutputStream os) throws IOException { - byte[] buf = new byte[1024]; - int len; - while ((len = is.read(buf)) > 0) { - os.write(buf, 0, len); - } - } - - /** - * - * @param file File to be uploaded - * @param target Target URL (e.g. xmldb:exist:///db/collection/document.xml) - * @throws java.lang.Exception Oops..... - */ - public static void insertDocumentToURL(String file, String target) throws IOException { - InputStream is = null; - OutputStream os = null; - try { - is = new FileInputStream(file); - final URL url = new URL(target); - final URLConnection connection = url.openConnection(); - os = connection.getOutputStream(); - TestTools.copyStream(is, os); - } finally { - if(is != null){ - is.close(); - } - if(os != null) { - os.close(); - } - } - } - - public static String getEXistHome() { - return ConfigurationHelper.getExistHome().getAbsolutePath(); - } - - public static byte[] getHamlet() throws IOException { - return loadSample("shakespeare/hamlet.xml"); - } - - public static byte[] loadSample(String sampleRelativePath) throws IOException { - File file = new File(getEXistHome(), "samples/" + sampleRelativePath); - InputStream fis = null; - ByteArrayOutputStream baos = null; - try { - fis = new FileInputStream(file); - baos = new ByteArrayOutputStream(); - TestTools.copyStream(fis, baos); - } finally { - if(fis != null){ - fis.close(); - } - if(baos != null) { - baos.close(); - } - } - return baos.toByteArray(); - } - - public static void insertDocumentToURL(byte[] data, String target) throws IOException { - final URL url = new URL(target); - final URLConnection connection = url.openConnection(); - InputStream is = null; - OutputStream os = null; - try { - is = new ByteArrayInputStream(data); - os = connection.getOutputStream(); - TestTools.copyStream(is, os); - os.flush(); - } finally { - if(is != null){ - is.close(); - } - if(os != null) { - os.close(); - } - } - } +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ + +package org.exist.validation; + +import java.io.ByteArrayInputStream; +import org.apache.commons.io.output.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URL; +import java.net.URLConnection; + +import org.exist.util.ConfigurationHelper; + +/** + * A set of helper methods for the validation tests. + * + * @author Dannes Wessels (dizzzz@exist-db.org) + */ +public class TestTools { + + public final static String VALIDATION_HOME_COLLECTION = "validation"; + public final static String VALIDATION_DTD_COLLECTION = "dtd"; + public final static String VALIDATION_XSD_COLLECTION = "xsd"; + public final static String VALIDATION_TMP_COLLECTION = "tmp"; + + + /* + public static void insertResources(){ + + try { + String eXistHome = ConfigurationHelper.getExistHome().getAbsolutePath(); + + Class cl = Class.forName("org.exist.xmldb.DatabaseImpl"); + Database database = (Database) cl.newInstance(); + database.setProperty("create-database", "true"); + DatabaseManager.registerDatabase(database); + Collection root = DatabaseManager.getCollection("xmldb:exist://" + DBBroker.ROOT_COLLECTION, "admin", null); + XPathQueryService service = (XPathQueryService) root.getService("XQueryService", "1.0"); + + CollectionManagementService cmservice = (CollectionManagementService) root.getService("CollectionManagementService", "1.0"); + Collection col1 = cmservice.createCollection(TestTools.VALIDATION_HOME); + Collection col2 = cmservice.createCollection(TestTools.VALIDATION_XSD); + + Permission permission = PermissionAiderFactory.getPermission("guest", "guest", 999); + + UserManagementService umservice = (UserManagementService) root.getService("UserManagementService", "1.0"); + umservice.setPermissions(col1, permission); + umservice.setPermissions(col2, permission); + + String addressbook = eXistHome + "/samples/validation/addressbook"; + + TestTools.insertDocumentToURL(addressbook + "/addressbook.xsd", + "xmldb:exist://" + TestTools.VALIDATION_XSD + "/addressbook.xsd"); + TestTools.insertDocumentToURL(addressbook + "/catalog.xml", + "xmldb:exist://" + TestTools.VALIDATION_XSD + "/catalog.xml"); + + TestTools.insertDocumentToURL(addressbook + "/addressbook_valid.xml", + "xmldb:exist://" + TestTools.VALIDATION_HOME + "/addressbook_valid.xml"); + TestTools.insertDocumentToURL(addressbook + "/addressbook_invalid.xml", + "xmldb:exist://" + TestTools.VALIDATION_HOME + "/addressbook_invalid.xml"); + + } catch (Throwable ex) { + ex.printStackTrace(); + } + }*/ + + // Transfer bytes from in to out + public static void copyStream(InputStream is, OutputStream os) throws IOException { + byte[] buf = new byte[1024]; + int len; + while ((len = is.read(buf)) > 0) { + os.write(buf, 0, len); + } + } + + /** + * + * @param file File to be uploaded + * @param target Target URL (e.g. xmldb:exist:///db/collection/document.xml) + * @throws java.lang.Exception Oops..... + */ + public static void insertDocumentToURL(String file, String target) throws IOException { + InputStream is = null; + OutputStream os = null; + try { + is = new FileInputStream(file); + final URL url = new URL(target); + final URLConnection connection = url.openConnection(); + os = connection.getOutputStream(); + TestTools.copyStream(is, os); + } finally { + if(is != null){ + is.close(); + } + if(os != null) { + os.close(); + } + } + } + + public static String getEXistHome() { + return ConfigurationHelper.getExistHome().getAbsolutePath(); + } + + public static byte[] getHamlet() throws IOException { + return loadSample("shakespeare/hamlet.xml"); + } + + public static byte[] loadSample(String sampleRelativePath) throws IOException { + File file = new File(getEXistHome(), "samples/" + sampleRelativePath); + InputStream fis = null; + ByteArrayOutputStream baos = null; + try { + fis = new FileInputStream(file); + baos = new ByteArrayOutputStream(); + TestTools.copyStream(fis, baos); + } finally { + if(fis != null){ + fis.close(); + } + if(baos != null) { + baos.close(); + } + } + return baos.toByteArray(); + } + + public static void insertDocumentToURL(byte[] data, String target) throws IOException { + final URL url = new URL(target); + final URLConnection connection = url.openConnection(); + InputStream is = null; + OutputStream os = null; + try { + is = new ByteArrayInputStream(data); + os = connection.getOutputStream(); + TestTools.copyStream(is, os); + os.flush(); + } finally { + if(is != null){ + is.close(); + } + if(os != null) { + os.close(); + } + } + } } \ No newline at end of file diff --git a/test/src/org/exist/validation/ValidationFunctions_Node_Test.java b/test/src/org/exist/validation/ValidationFunctions_Node_Test.java index e37b78bfe9c..7d49c4a34c4 100644 --- a/test/src/org/exist/validation/ValidationFunctions_Node_Test.java +++ b/test/src/org/exist/validation/ValidationFunctions_Node_Test.java @@ -1,258 +1,258 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id: ValidationFunctions_XSD_Test.java 5941 2007-05-29 20:27:59Z dizzzz $ - */ -package org.exist.validation; - -import org.junit.*; -//import static org.junit.Assert.*; -// -//import org.apache.log4j.Appender; -//import org.apache.log4j.BasicConfigurator; -//import org.apache.log4j.ConsoleAppender; -//import org.apache.log4j.Layout; -//import org.apache.log4j.Logger; -//import org.apache.log4j.PatternLayout; -//import org.exist.security.Permission; -//import org.exist.security.UnixStylePermission; -// -//import org.exist.storage.DBBroker; -//import org.exist.util.ConfigurationHelper; -//import org.exist.xmldb.DatabaseInstanceManager; -//import org.exist.xmldb.UserManagementService; -// -//import org.xmldb.api.DatabaseManager; -//import org.xmldb.api.base.Collection; -//import org.xmldb.api.base.Database; -//import org.xmldb.api.base.ResourceSet; -//import org.xmldb.api.modules.CollectionManagementService; -//import org.xmldb.api.modules.XPathQueryService; - -/** - * Set of Tests for validation:validate($a) and validation:validate($a, $b) - * regaring validatin using XSD's. - * - * @author Dannes Wessels (dizzzz@exist-db.org) - */ -public class ValidationFunctions_Node_Test { - - @Test - public void noTest() { - - } - -// private final static Logger logger = Logger.getLogger(ValidationFunctions_Node_Test.class); -// -// private static String eXistHome = ConfigurationHelper.getExistHome().getAbsolutePath(); -// -// private static CollectionManagementService cmservice = null; -// private static UserManagementService umservice = null; -// private static XPathQueryService service; -// private static Collection root = null; -// private static Database database = null; -// -// -// -// -// public static void initLog4J() { -// Layout layout = new PatternLayout("%d [%t] %-5p (%F [%M]:%L) - %m %n"); -// Appender appender = new ConsoleAppender(layout); -// BasicConfigurator.configure(appender); -// } -// -// @BeforeClass -// public static void start() throws Exception { -// -// // initialize driver -// initLog4J(); -// logger.info("start"); -// -// Class cl = Class.forName("org.exist.xmldb.DatabaseImpl"); -// database = (Database) cl.newInstance(); -// database.setProperty("create-database", "true"); -// DatabaseManager.registerDatabase(database); -// root = DatabaseManager.getCollection("xmldb:exist://" + DBBroker.ROOT_COLLECTION, "guest", "guest"); -// service = (XPathQueryService) root.getService("XQueryService", "1.0"); -// -// -// cmservice = (CollectionManagementService) root.getService("CollectionManagementService", "1.0"); -// Collection col1 = cmservice.createCollection(TestTools.VALIDATION_HOME); -// Collection col2 = cmservice.createCollection(TestTools.VALIDATION_XSD); -// -// Permission permission = new UnixStylePermission("guest", "guest", 666); -// -// umservice = (UserManagementService) root.getService("UserManagementService", "1.0"); -// umservice.setPermissions(col1, permission); -// umservice.setPermissions(col2, permission); -// -// String addressbook = eXistHome + "/samples/validation/addressbook"; -// -// TestTools.insertDocumentToURL(addressbook + "/addressbook.xsd", -// "xmldb:exist://" + TestTools.VALIDATION_XSD + "/addressbook.xsd"); -// TestTools.insertDocumentToURL(addressbook + "/catalog.xml", -// "xmldb:exist://" + TestTools.VALIDATION_XSD + "/catalog.xml"); -// -// TestTools.insertDocumentToURL(addressbook + "/addressbook_valid.xml", -// "xmldb:exist://" + TestTools.VALIDATION_HOME + "/addressbook_valid.xml"); -// TestTools.insertDocumentToURL(addressbook + "/addressbook_invalid.xml", -// "xmldb:exist://" + TestTools.VALIDATION_HOME + "/addressbook_invalid.xml"); -// } -// -// // =========================================================== -// private void clearGrammarCache() { -// logger.info("Clearing grammar cache"); -// @SuppressWarnings("unused") -// ResourceSet result = null; -// try { -// result = service.query("validation:clear-grammar-cache()"); -// -// } catch (Exception e) { -// logger.error(e); -// e.printStackTrace(); -// fail(e.getMessage()); -// } -// -// } -// -// @Test -// public void storedNode() { -// -// logger.info("storedNode"); -// -// clearGrammarCache(); -// -// String query = null; -// ResourceSet result = null; -// String r = null; -// -// try { -// logger.info("Test1"); -// query = "let $doc := doc('/db/validation/addressbook_valid.xml') " + -// "let $result := validation:validate( $doc, " + -// " xs:anyURI('/db/validation/xsd/addressbook.xsd') ) " + -// "return $result"; -// result = service.query(query); -// r = (String) result.getResource(0).getContent(); -// assertEquals("valid document as node", "true", r); -// -// clearGrammarCache(); -// -// } catch (Exception e) { -// logger.error(e); -// e.printStackTrace(); -// fail(e.getMessage()); -// } -// -// try { -// logger.info("Test2"); -// -// query = "let $doc := doc('/db/validation/addressbook_invalid.xml') " + -// "let $result := validation:validate( $doc, " + -// " xs:anyURI('/db/validation/xsd/addressbook.xsd') ) " + -// "return $result"; -// result = service.query(query); -// r = (String) result.getResource(0).getContent(); -// assertEquals("invalid document as node", "false", r); -// -// clearGrammarCache(); -// -// } catch (Exception e) { -// logger.error(e); -// e.printStackTrace(); -// fail(e.getMessage()); -// } -// } -// -// @Test -// public void constructedNode() { -// -// logger.info("constructedNode"); -// -// clearGrammarCache(); -// -// String query = null; -// ResourceSet result = null; -// String r = null; -// -// try { -// logger.info("Test1"); -// -// query = "let $doc := " + -// "" + -// " John Punin puninj@cs.rpi.edu " + -// " Harrison Ford hford@famous.org " + -// " Julia Roberts jr@pw.com " + -// " " + -// "let $result := validation:validate( $doc, " + -// " xs:anyURI('/db/validation/xsd/addressbook.xsd') ) " + -// "return $result"; -// result = service.query(query); -// r = (String) result.getResource(0).getContent(); -// assertEquals("valid document as node", "true", r); -// -// clearGrammarCache(); -// -// } catch (Exception e) { -// logger.error(e); -// e.printStackTrace(); -// fail(e.getMessage()); -// } -// -// try { -// logger.info("Test2"); -// -// query = "let $doc := " + -// "" + -// " John Punin puninj@cs.rpi.edu " + -// " Harrison Ford hford@famous.org " + -// " Julia Roberts jr@pw.com " + -// " " + -// "let $result := validation:validate( $doc, " + -// " xs:anyURI('/db/validation/xsd/addressbook.xsd') ) " + -// "return $result"; -// result = service.query(query); -// r = (String) result.getResource(0).getContent(); -// assertEquals("invalid document as node", "false", r); -// -// clearGrammarCache(); -// -// } catch (Exception e) { -// logger.error(e); -// e.printStackTrace(); -// fail(e.getMessage()); -// } -// } -// -// @AfterClass -// public static void shutdownDB() throws Exception { -// -// logger.info("shutdownDB"); -// -// -// root = DatabaseManager.getCollection("xmldb:exist://" + DBBroker.ROOT_COLLECTION, "admin", null); -// -// -// DatabaseManager.deregisterDatabase(database); -// DatabaseInstanceManager dim = -// (DatabaseInstanceManager) root.getService("DatabaseInstanceManager", "1.0"); -// dim.shutdownDB(); -// -// } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id: ValidationFunctions_XSD_Test.java 5941 2007-05-29 20:27:59Z dizzzz $ + */ +package org.exist.validation; + +import org.junit.*; +//import static org.junit.Assert.*; +// +//import org.apache.log4j.Appender; +//import org.apache.log4j.BasicConfigurator; +//import org.apache.log4j.ConsoleAppender; +//import org.apache.log4j.Layout; +//import org.apache.log4j.Logger; +//import org.apache.log4j.PatternLayout; +//import org.exist.security.Permission; +//import org.exist.security.UnixStylePermission; +// +//import org.exist.storage.DBBroker; +//import org.exist.util.ConfigurationHelper; +//import org.exist.xmldb.DatabaseInstanceManager; +//import org.exist.xmldb.UserManagementService; +// +//import org.xmldb.api.DatabaseManager; +//import org.xmldb.api.base.Collection; +//import org.xmldb.api.base.Database; +//import org.xmldb.api.base.ResourceSet; +//import org.xmldb.api.modules.CollectionManagementService; +//import org.xmldb.api.modules.XPathQueryService; + +/** + * Set of Tests for validation:validate($a) and validation:validate($a, $b) + * regaring validatin using XSD's. + * + * @author Dannes Wessels (dizzzz@exist-db.org) + */ +public class ValidationFunctions_Node_Test { + + @Test + public void noTest() { + + } + +// private final static Logger logger = Logger.getLogger(ValidationFunctions_Node_Test.class); +// +// private static String eXistHome = ConfigurationHelper.getExistHome().getAbsolutePath(); +// +// private static CollectionManagementService cmservice = null; +// private static UserManagementService umservice = null; +// private static XPathQueryService service; +// private static Collection root = null; +// private static Database database = null; +// +// +// +// +// public static void initLog4J() { +// Layout layout = new PatternLayout("%d [%t] %-5p (%F [%M]:%L) - %m %n"); +// Appender appender = new ConsoleAppender(layout); +// BasicConfigurator.configure(appender); +// } +// +// @BeforeClass +// public static void start() throws Exception { +// +// // initialize driver +// initLog4J(); +// logger.info("start"); +// +// Class cl = Class.forName("org.exist.xmldb.DatabaseImpl"); +// database = (Database) cl.newInstance(); +// database.setProperty("create-database", "true"); +// DatabaseManager.registerDatabase(database); +// root = DatabaseManager.getCollection("xmldb:exist://" + DBBroker.ROOT_COLLECTION, "guest", "guest"); +// service = (XPathQueryService) root.getService("XQueryService", "1.0"); +// +// +// cmservice = (CollectionManagementService) root.getService("CollectionManagementService", "1.0"); +// Collection col1 = cmservice.createCollection(TestTools.VALIDATION_HOME); +// Collection col2 = cmservice.createCollection(TestTools.VALIDATION_XSD); +// +// Permission permission = new UnixStylePermission("guest", "guest", 666); +// +// umservice = (UserManagementService) root.getService("UserManagementService", "1.0"); +// umservice.setPermissions(col1, permission); +// umservice.setPermissions(col2, permission); +// +// String addressbook = eXistHome + "/samples/validation/addressbook"; +// +// TestTools.insertDocumentToURL(addressbook + "/addressbook.xsd", +// "xmldb:exist://" + TestTools.VALIDATION_XSD + "/addressbook.xsd"); +// TestTools.insertDocumentToURL(addressbook + "/catalog.xml", +// "xmldb:exist://" + TestTools.VALIDATION_XSD + "/catalog.xml"); +// +// TestTools.insertDocumentToURL(addressbook + "/addressbook_valid.xml", +// "xmldb:exist://" + TestTools.VALIDATION_HOME + "/addressbook_valid.xml"); +// TestTools.insertDocumentToURL(addressbook + "/addressbook_invalid.xml", +// "xmldb:exist://" + TestTools.VALIDATION_HOME + "/addressbook_invalid.xml"); +// } +// +// // =========================================================== +// private void clearGrammarCache() { +// logger.info("Clearing grammar cache"); +// @SuppressWarnings("unused") +// ResourceSet result = null; +// try { +// result = service.query("validation:clear-grammar-cache()"); +// +// } catch (Exception e) { +// logger.error(e); +// e.printStackTrace(); +// fail(e.getMessage()); +// } +// +// } +// +// @Test +// public void storedNode() { +// +// logger.info("storedNode"); +// +// clearGrammarCache(); +// +// String query = null; +// ResourceSet result = null; +// String r = null; +// +// try { +// logger.info("Test1"); +// query = "let $doc := doc('/db/validation/addressbook_valid.xml') " + +// "let $result := validation:validate( $doc, " + +// " xs:anyURI('/db/validation/xsd/addressbook.xsd') ) " + +// "return $result"; +// result = service.query(query); +// r = (String) result.getResource(0).getContent(); +// assertEquals("valid document as node", "true", r); +// +// clearGrammarCache(); +// +// } catch (Exception e) { +// logger.error(e); +// e.printStackTrace(); +// fail(e.getMessage()); +// } +// +// try { +// logger.info("Test2"); +// +// query = "let $doc := doc('/db/validation/addressbook_invalid.xml') " + +// "let $result := validation:validate( $doc, " + +// " xs:anyURI('/db/validation/xsd/addressbook.xsd') ) " + +// "return $result"; +// result = service.query(query); +// r = (String) result.getResource(0).getContent(); +// assertEquals("invalid document as node", "false", r); +// +// clearGrammarCache(); +// +// } catch (Exception e) { +// logger.error(e); +// e.printStackTrace(); +// fail(e.getMessage()); +// } +// } +// +// @Test +// public void constructedNode() { +// +// logger.info("constructedNode"); +// +// clearGrammarCache(); +// +// String query = null; +// ResourceSet result = null; +// String r = null; +// +// try { +// logger.info("Test1"); +// +// query = "let $doc := " + +// "" + +// " John Punin puninj@cs.rpi.edu " + +// " Harrison Ford hford@famous.org " + +// " Julia Roberts jr@pw.com " + +// " " + +// "let $result := validation:validate( $doc, " + +// " xs:anyURI('/db/validation/xsd/addressbook.xsd') ) " + +// "return $result"; +// result = service.query(query); +// r = (String) result.getResource(0).getContent(); +// assertEquals("valid document as node", "true", r); +// +// clearGrammarCache(); +// +// } catch (Exception e) { +// logger.error(e); +// e.printStackTrace(); +// fail(e.getMessage()); +// } +// +// try { +// logger.info("Test2"); +// +// query = "let $doc := " + +// "" + +// " John Punin puninj@cs.rpi.edu " + +// " Harrison Ford hford@famous.org " + +// " Julia Roberts jr@pw.com " + +// " " + +// "let $result := validation:validate( $doc, " + +// " xs:anyURI('/db/validation/xsd/addressbook.xsd') ) " + +// "return $result"; +// result = service.query(query); +// r = (String) result.getResource(0).getContent(); +// assertEquals("invalid document as node", "false", r); +// +// clearGrammarCache(); +// +// } catch (Exception e) { +// logger.error(e); +// e.printStackTrace(); +// fail(e.getMessage()); +// } +// } +// +// @AfterClass +// public static void shutdownDB() throws Exception { +// +// logger.info("shutdownDB"); +// +// +// root = DatabaseManager.getCollection("xmldb:exist://" + DBBroker.ROOT_COLLECTION, "admin", null); +// +// +// DatabaseManager.deregisterDatabase(database); +// DatabaseInstanceManager dim = +// (DatabaseInstanceManager) root.getService("DatabaseInstanceManager", "1.0"); +// dim.shutdownDB(); +// +// } +} diff --git a/test/src/org/exist/validation/ValidationFunctions_XSD_Test.java b/test/src/org/exist/validation/ValidationFunctions_XSD_Test.java index 08ee75abd3e..3d0bab819af 100644 --- a/test/src/org/exist/validation/ValidationFunctions_XSD_Test.java +++ b/test/src/org/exist/validation/ValidationFunctions_XSD_Test.java @@ -1,317 +1,317 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.validation; - -import org.junit.*; -//import static org.junit.Assert.*; -// -//import org.apache.log4j.Appender; -//import org.apache.log4j.BasicConfigurator; -//import org.apache.log4j.ConsoleAppender; -//import org.apache.log4j.Layout; -//import org.apache.log4j.Logger; -//import org.apache.log4j.PatternLayout; -//import org.exist.security.Permission; -//import org.exist.security.UnixStylePermission; -// -//import org.exist.storage.DBBroker; -//import org.exist.util.ConfigurationHelper; -//import org.exist.xmldb.DatabaseInstanceManager; -//import org.exist.xmldb.UserManagementService; -// -//import org.xmldb.api.DatabaseManager; -//import org.xmldb.api.base.Collection; -//import org.xmldb.api.base.Database; -//import org.xmldb.api.base.ResourceSet; -//import org.xmldb.api.modules.CollectionManagementService; -//import org.xmldb.api.modules.XPathQueryService; - -/** - * Set of Tests for validation:validate($a) and validation:validate($a, $b) - * regaring validatin using XSD's. - * - * @author Dannes Wessels (dizzzz@exist-db.org) - */ -public class ValidationFunctions_XSD_Test { - - -// private final static Logger logger = Logger.getLogger(ValidationFunctions_XSD_Test.class); -// -// private static String eXistHome = ConfigurationHelper.getExistHome().getAbsolutePath(); -// -// private static CollectionManagementService cmservice = null; -// private static UserManagementService umservice = null; -// private static XPathQueryService service; -// private static Collection root = null; -// private static Database database = null; -// - @Test - public void noTest() { - - } - -// public static void initLog4J(){ -// Layout layout = new PatternLayout("%d [%t] %-5p (%F [%M]:%L) - %m %n"); -// Appender appender=new ConsoleAppender(layout); -// BasicConfigurator.configure(appender); -// } -// -// @BeforeClass -// public static void setUp() throws Exception { -// -// // initialize driver -// initLog4J(); -// -// logger.info("setUp"); -// -// Class cl = Class.forName("org.exist.xmldb.DatabaseImpl"); -// database = (Database) cl.newInstance(); -// database.setProperty("create-database", "true"); -// DatabaseManager.registerDatabase(database); -// root = DatabaseManager.getCollection("xmldb:exist://" + DBBroker.ROOT_COLLECTION, "guest", "guest"); -// service = (XPathQueryService) root.getService( "XQueryService", "1.0" ); -// -// cmservice = (CollectionManagementService) root.getService("CollectionManagementService", "1.0"); -// Collection col1 = cmservice.createCollection(TestTools.VALIDATION_HOME); -// Collection col2 = cmservice.createCollection(TestTools.VALIDATION_XSD); -// -// Permission permission = new UnixStylePermission("guest", "guest", 666); -// -// umservice = (UserManagementService) root.getService("UserManagementService", "1.0"); -// umservice.setPermissions(col1, permission); -// umservice.setPermissions(col2, permission); -// -// String addressbook = eXistHome + "/samples/validation/addressbook"; -// -// TestTools.insertDocumentToURL(addressbook + "/addressbook.xsd", -// "xmldb:exist://" + TestTools.VALIDATION_XSD + "/addressbook.xsd"); -// TestTools.insertDocumentToURL(addressbook + "/catalog.xml", -// "xmldb:exist://" + TestTools.VALIDATION_XSD + "/catalog.xml"); -// -// TestTools.insertDocumentToURL(addressbook + "/addressbook_valid.xml", -// "xmldb:exist://" + TestTools.VALIDATION_HOME + "/addressbook_valid.xml"); -// TestTools.insertDocumentToURL(addressbook + "/addressbook_invalid.xml", -// "xmldb:exist://" + TestTools.VALIDATION_HOME + "/addressbook_invalid.xml"); -// } -// -// // =========================================================== -// -// private void clearGrammarCache() { -// logger.info("Clearing grammar cache"); -// @SuppressWarnings("unused") -// ResourceSet result = null; -// try { -// result = service.query("validation:clear-grammar-cache()"); -// -// } catch (Exception e) { -// logger.error(e); -// e.printStackTrace(); -// fail(e.getMessage()); -// } -// -// } -// -// @Test -// public void testXSD_NotInSystemCatalog() { -// -// logger.info("start"); -// -// clearGrammarCache(); -// -// ResourceSet result = null; -// String r = null; -// try { -// // XSD for addressbook_valid.xml is *not* registered in system catalog. -// // result should be "document is invalid" -// result = service.query( -// "validation:validate( xs:anyURI('/db/validation/addressbook_valid.xml') )"); -// r = (String) result.getResource(0).getContent(); -// assertEquals( "addressbook_valid.xml not in systemcatalog", "false", r ); -// -// clearGrammarCache(); -// -// } catch (Exception e) { -// logger.error(e); -// e.printStackTrace(); -// fail(e.getMessage()); -// } -// } -// -// @Test -// public void testXSD_SpecifiedCatalog() { -// -// logger.info("start"); -// -// clearGrammarCache(); -// -// ResourceSet result = null; -// String r = null; -// try { -// logger.info("Test1"); -// result = service.query( -// "validation:validate( xs:anyURI('/db/validation/addressbook_valid.xml'), " -// +" xs:anyURI('/db/validation/xsd/catalog.xml') )"); -// r = (String) result.getResource(0).getContent(); -// assertEquals("valid document", "true", r ); -// -// clearGrammarCache(); -// -// logger.info("Test2"); -// result = service.query( -// "validation:validate( xs:anyURI('/db/validation/addressbook_invalid.xml'), " -// +" xs:anyURI('/db/validation/xsd/catalog.xml') )"); -// r = (String) result.getResource(0).getContent(); -// assertEquals( "invalid document", "false", r ); -// -// clearGrammarCache(); -// -// logger.info("Test3"); -// result = service.query( -// "validation:validate( xs:anyURI('/db/validation/addressbook_valid.xml'), " -// +" xs:anyURI('/db/validation/dtd/catalog.xml') )"); -// r = (String) result.getResource(0).getContent(); -// assertEquals("wrong catalog", "false", r ); -// -// clearGrammarCache(); -// -// logger.info("Test4"); -// result = service.query( -// "validation:validate( xs:anyURI('/db/validation/addressbook_invalid.xml')," -// +" xs:anyURI('/db/validation/dtd/catalog.xml') )"); -// r = (String) result.getResource(0).getContent(); -// assertEquals("wrong catalog, invalid document", "false", r ); -// -// } catch (Exception e) { -// logger.error(e); -// e.printStackTrace(); -// fail(e.getMessage()); -// } -// } -// -// @Test -// public void testXSD_SpecifiedGrammar() { -// -// logger.info("start"); -// -// clearGrammarCache(); -// -// ResourceSet result = null; -// String r = null; -// try { -// logger.info("Test1"); -// result = service.query( -// "validation:validate( xs:anyURI('/db/validation/addressbook_valid.xml'), " -// +" xs:anyURI('/db/validation/xsd/addressbook.xsd') )"); -// r = (String) result.getResource(0).getContent(); -// assertEquals("valid document", "true", r ); -// -// clearGrammarCache(); -// -// logger.info("Test2"); -// result = service.query( -// "validation:validate( xs:anyURI('/db/validation/addressbook_invalid.xml'), " -// +" xs:anyURI('/db/validation/xsd/addressbook.xsd') )"); -// r = (String) result.getResource(0).getContent(); -// assertEquals( "invalid document", "false", r ); -// -// clearGrammarCache(); -// -// -// } catch (Exception e) { -// logger.error(e); -// e.printStackTrace(); -// fail(e.getMessage()); -// } -// } -// -// @Test -// public void testXSD_SearchedGrammar() { -// -// logger.info("start"); -// -// clearGrammarCache(); -// -// ResourceSet result = null; -// String r = null; -// try { -// -// logger.info("Test1"); -// result = service.query( -// "validation:validate( xs:anyURI('/db/validation/addressbook_valid.xml'), " -// +" xs:anyURI('/db/validation/xsd/') )"); -// r = (String) result.getResource(0).getContent(); -// assertEquals("valid document", "true", r ); -// -// clearGrammarCache(); -// -// logger.info("Test2"); -// result = service.query( -// "validation:validate( xs:anyURI('/db/validation/addressbook_valid.xml'), " -// +" xs:anyURI('/db/validation/dtd/') )"); -// r = (String) result.getResource(0).getContent(); -// assertEquals( "valid document, not found", "false", r ); -// -// clearGrammarCache(); -// -// logger.info("Test3"); -// result = service.query( -// "validation:validate( xs:anyURI('/db/validation/addressbook_valid.xml'), " -// +" xs:anyURI('/db/validation/') )"); -// r = (String) result.getResource(0).getContent(); -// assertEquals("valid document", "true", r ); -// -// clearGrammarCache(); -// -// logger.info("Test4"); -// result = service.query( -// "validation:validate( xs:anyURI('/db/validation/addressbook_invalid.xml') ," -// +" xs:anyURI('/db/validation/') )"); -// r = (String) result.getResource(0).getContent(); -// assertEquals( "invalid document", "false", r ); -// -// clearGrammarCache(); -// -// -// } catch (Exception e) { -// logger.error(e); -// e.printStackTrace(); -// fail(e.getMessage()); -// } -// } -// -// // DTDs -// -// @AfterClass -// public static void stop() throws Exception { -// -// logger.info("stop"); -// -// root = DatabaseManager.getCollection("xmldb:exist://" + DBBroker.ROOT_COLLECTION, "admin", null); -// -// DatabaseManager.deregisterDatabase(database); -// DatabaseInstanceManager dim = -// (DatabaseInstanceManager) root.getService("DatabaseInstanceManager", "1.0"); -// dim.shutdownDB(); -// -// } - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.validation; + +import org.junit.*; +//import static org.junit.Assert.*; +// +//import org.apache.log4j.Appender; +//import org.apache.log4j.BasicConfigurator; +//import org.apache.log4j.ConsoleAppender; +//import org.apache.log4j.Layout; +//import org.apache.log4j.Logger; +//import org.apache.log4j.PatternLayout; +//import org.exist.security.Permission; +//import org.exist.security.UnixStylePermission; +// +//import org.exist.storage.DBBroker; +//import org.exist.util.ConfigurationHelper; +//import org.exist.xmldb.DatabaseInstanceManager; +//import org.exist.xmldb.UserManagementService; +// +//import org.xmldb.api.DatabaseManager; +//import org.xmldb.api.base.Collection; +//import org.xmldb.api.base.Database; +//import org.xmldb.api.base.ResourceSet; +//import org.xmldb.api.modules.CollectionManagementService; +//import org.xmldb.api.modules.XPathQueryService; + +/** + * Set of Tests for validation:validate($a) and validation:validate($a, $b) + * regaring validatin using XSD's. + * + * @author Dannes Wessels (dizzzz@exist-db.org) + */ +public class ValidationFunctions_XSD_Test { + + +// private final static Logger logger = Logger.getLogger(ValidationFunctions_XSD_Test.class); +// +// private static String eXistHome = ConfigurationHelper.getExistHome().getAbsolutePath(); +// +// private static CollectionManagementService cmservice = null; +// private static UserManagementService umservice = null; +// private static XPathQueryService service; +// private static Collection root = null; +// private static Database database = null; +// + @Test + public void noTest() { + + } + +// public static void initLog4J(){ +// Layout layout = new PatternLayout("%d [%t] %-5p (%F [%M]:%L) - %m %n"); +// Appender appender=new ConsoleAppender(layout); +// BasicConfigurator.configure(appender); +// } +// +// @BeforeClass +// public static void setUp() throws Exception { +// +// // initialize driver +// initLog4J(); +// +// logger.info("setUp"); +// +// Class cl = Class.forName("org.exist.xmldb.DatabaseImpl"); +// database = (Database) cl.newInstance(); +// database.setProperty("create-database", "true"); +// DatabaseManager.registerDatabase(database); +// root = DatabaseManager.getCollection("xmldb:exist://" + DBBroker.ROOT_COLLECTION, "guest", "guest"); +// service = (XPathQueryService) root.getService( "XQueryService", "1.0" ); +// +// cmservice = (CollectionManagementService) root.getService("CollectionManagementService", "1.0"); +// Collection col1 = cmservice.createCollection(TestTools.VALIDATION_HOME); +// Collection col2 = cmservice.createCollection(TestTools.VALIDATION_XSD); +// +// Permission permission = new UnixStylePermission("guest", "guest", 666); +// +// umservice = (UserManagementService) root.getService("UserManagementService", "1.0"); +// umservice.setPermissions(col1, permission); +// umservice.setPermissions(col2, permission); +// +// String addressbook = eXistHome + "/samples/validation/addressbook"; +// +// TestTools.insertDocumentToURL(addressbook + "/addressbook.xsd", +// "xmldb:exist://" + TestTools.VALIDATION_XSD + "/addressbook.xsd"); +// TestTools.insertDocumentToURL(addressbook + "/catalog.xml", +// "xmldb:exist://" + TestTools.VALIDATION_XSD + "/catalog.xml"); +// +// TestTools.insertDocumentToURL(addressbook + "/addressbook_valid.xml", +// "xmldb:exist://" + TestTools.VALIDATION_HOME + "/addressbook_valid.xml"); +// TestTools.insertDocumentToURL(addressbook + "/addressbook_invalid.xml", +// "xmldb:exist://" + TestTools.VALIDATION_HOME + "/addressbook_invalid.xml"); +// } +// +// // =========================================================== +// +// private void clearGrammarCache() { +// logger.info("Clearing grammar cache"); +// @SuppressWarnings("unused") +// ResourceSet result = null; +// try { +// result = service.query("validation:clear-grammar-cache()"); +// +// } catch (Exception e) { +// logger.error(e); +// e.printStackTrace(); +// fail(e.getMessage()); +// } +// +// } +// +// @Test +// public void testXSD_NotInSystemCatalog() { +// +// logger.info("start"); +// +// clearGrammarCache(); +// +// ResourceSet result = null; +// String r = null; +// try { +// // XSD for addressbook_valid.xml is *not* registered in system catalog. +// // result should be "document is invalid" +// result = service.query( +// "validation:validate( xs:anyURI('/db/validation/addressbook_valid.xml') )"); +// r = (String) result.getResource(0).getContent(); +// assertEquals( "addressbook_valid.xml not in systemcatalog", "false", r ); +// +// clearGrammarCache(); +// +// } catch (Exception e) { +// logger.error(e); +// e.printStackTrace(); +// fail(e.getMessage()); +// } +// } +// +// @Test +// public void testXSD_SpecifiedCatalog() { +// +// logger.info("start"); +// +// clearGrammarCache(); +// +// ResourceSet result = null; +// String r = null; +// try { +// logger.info("Test1"); +// result = service.query( +// "validation:validate( xs:anyURI('/db/validation/addressbook_valid.xml'), " +// +" xs:anyURI('/db/validation/xsd/catalog.xml') )"); +// r = (String) result.getResource(0).getContent(); +// assertEquals("valid document", "true", r ); +// +// clearGrammarCache(); +// +// logger.info("Test2"); +// result = service.query( +// "validation:validate( xs:anyURI('/db/validation/addressbook_invalid.xml'), " +// +" xs:anyURI('/db/validation/xsd/catalog.xml') )"); +// r = (String) result.getResource(0).getContent(); +// assertEquals( "invalid document", "false", r ); +// +// clearGrammarCache(); +// +// logger.info("Test3"); +// result = service.query( +// "validation:validate( xs:anyURI('/db/validation/addressbook_valid.xml'), " +// +" xs:anyURI('/db/validation/dtd/catalog.xml') )"); +// r = (String) result.getResource(0).getContent(); +// assertEquals("wrong catalog", "false", r ); +// +// clearGrammarCache(); +// +// logger.info("Test4"); +// result = service.query( +// "validation:validate( xs:anyURI('/db/validation/addressbook_invalid.xml')," +// +" xs:anyURI('/db/validation/dtd/catalog.xml') )"); +// r = (String) result.getResource(0).getContent(); +// assertEquals("wrong catalog, invalid document", "false", r ); +// +// } catch (Exception e) { +// logger.error(e); +// e.printStackTrace(); +// fail(e.getMessage()); +// } +// } +// +// @Test +// public void testXSD_SpecifiedGrammar() { +// +// logger.info("start"); +// +// clearGrammarCache(); +// +// ResourceSet result = null; +// String r = null; +// try { +// logger.info("Test1"); +// result = service.query( +// "validation:validate( xs:anyURI('/db/validation/addressbook_valid.xml'), " +// +" xs:anyURI('/db/validation/xsd/addressbook.xsd') )"); +// r = (String) result.getResource(0).getContent(); +// assertEquals("valid document", "true", r ); +// +// clearGrammarCache(); +// +// logger.info("Test2"); +// result = service.query( +// "validation:validate( xs:anyURI('/db/validation/addressbook_invalid.xml'), " +// +" xs:anyURI('/db/validation/xsd/addressbook.xsd') )"); +// r = (String) result.getResource(0).getContent(); +// assertEquals( "invalid document", "false", r ); +// +// clearGrammarCache(); +// +// +// } catch (Exception e) { +// logger.error(e); +// e.printStackTrace(); +// fail(e.getMessage()); +// } +// } +// +// @Test +// public void testXSD_SearchedGrammar() { +// +// logger.info("start"); +// +// clearGrammarCache(); +// +// ResourceSet result = null; +// String r = null; +// try { +// +// logger.info("Test1"); +// result = service.query( +// "validation:validate( xs:anyURI('/db/validation/addressbook_valid.xml'), " +// +" xs:anyURI('/db/validation/xsd/') )"); +// r = (String) result.getResource(0).getContent(); +// assertEquals("valid document", "true", r ); +// +// clearGrammarCache(); +// +// logger.info("Test2"); +// result = service.query( +// "validation:validate( xs:anyURI('/db/validation/addressbook_valid.xml'), " +// +" xs:anyURI('/db/validation/dtd/') )"); +// r = (String) result.getResource(0).getContent(); +// assertEquals( "valid document, not found", "false", r ); +// +// clearGrammarCache(); +// +// logger.info("Test3"); +// result = service.query( +// "validation:validate( xs:anyURI('/db/validation/addressbook_valid.xml'), " +// +" xs:anyURI('/db/validation/') )"); +// r = (String) result.getResource(0).getContent(); +// assertEquals("valid document", "true", r ); +// +// clearGrammarCache(); +// +// logger.info("Test4"); +// result = service.query( +// "validation:validate( xs:anyURI('/db/validation/addressbook_invalid.xml') ," +// +" xs:anyURI('/db/validation/') )"); +// r = (String) result.getResource(0).getContent(); +// assertEquals( "invalid document", "false", r ); +// +// clearGrammarCache(); +// +// +// } catch (Exception e) { +// logger.error(e); +// e.printStackTrace(); +// fail(e.getMessage()); +// } +// } +// +// // DTDs +// +// @AfterClass +// public static void stop() throws Exception { +// +// logger.info("stop"); +// +// root = DatabaseManager.getCollection("xmldb:exist://" + DBBroker.ROOT_COLLECTION, "admin", null); +// +// DatabaseManager.deregisterDatabase(database); +// DatabaseInstanceManager dim = +// (DatabaseInstanceManager) root.getService("DatabaseInstanceManager", "1.0"); +// dim.shutdownDB(); +// +// } + +} diff --git a/test/src/org/exist/xmldb/CollectionTest.java b/test/src/org/exist/xmldb/CollectionTest.java index 3ef6dd6cbbb..01d13072b96 100644 --- a/test/src/org/exist/xmldb/CollectionTest.java +++ b/test/src/org/exist/xmldb/CollectionTest.java @@ -1,72 +1,72 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-2011 The eXist-db Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id: BinaryResourceUpdateTest.java 11148 2010-02-07 14:37:35Z dizzzz $ - */ -package org.exist.xmldb; - -import org.exist.test.TestConstants; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertNotNull; -import org.xmldb.api.DatabaseManager; -import org.xmldb.api.base.Collection; -import org.xmldb.api.base.Database; -import org.xmldb.api.base.XMLDBException; -import org.xmldb.api.modules.CollectionManagementService; -import static org.exist.xmldb.XmldbLocalTests.*; - -public class CollectionTest { - - @Test - public void create() throws XMLDBException { - Collection root = DatabaseManager.getCollection(ROOT_URI, ADMIN_UID, ADMIN_PWD); - CollectionManagementService service = (CollectionManagementService)root.getService("CollectionManagementService", "1.0"); - Collection testCollection = service.createCollection(TestConstants.SPECIAL_NAME); - assertNotNull(testCollection); - } - - @Test - public void testRead() throws XMLDBException { - Collection test = DatabaseManager.getCollection(ROOT_URI, ADMIN_UID, ADMIN_PWD); - assertNotNull(test); - Collection root = DatabaseManager.getCollection(ROOT_URI, ADMIN_UID, ADMIN_PWD); - test = root.getChildCollection(TestConstants.SPECIAL_NAME); - assertNotNull(test); - CollectionManagementService service = (CollectionManagementService)root.getService("CollectionManagementService", "1.0"); - service.removeCollection(TestConstants.SPECIAL_NAME); - } - - @Before - public void setUp() throws Exception { - // initialize driver - Class cl = Class.forName(DRIVER); - Database database = (Database) cl.newInstance(); - database.setProperty("create-database", "true"); - DatabaseManager.registerDatabase(database); - } - - @After - public void tearDown() throws XMLDBException { - Collection root = DatabaseManager.getCollection(ROOT_URI, ADMIN_UID, ADMIN_PWD); - DatabaseInstanceManager mgr = (DatabaseInstanceManager) root.getService("DatabaseInstanceManager", "1.0"); - mgr.shutdown(); - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-2011 The eXist-db Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id: BinaryResourceUpdateTest.java 11148 2010-02-07 14:37:35Z dizzzz $ + */ +package org.exist.xmldb; + +import org.exist.test.TestConstants; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import static org.junit.Assert.assertNotNull; +import org.xmldb.api.DatabaseManager; +import org.xmldb.api.base.Collection; +import org.xmldb.api.base.Database; +import org.xmldb.api.base.XMLDBException; +import org.xmldb.api.modules.CollectionManagementService; +import static org.exist.xmldb.XmldbLocalTests.*; + +public class CollectionTest { + + @Test + public void create() throws XMLDBException { + Collection root = DatabaseManager.getCollection(ROOT_URI, ADMIN_UID, ADMIN_PWD); + CollectionManagementService service = (CollectionManagementService)root.getService("CollectionManagementService", "1.0"); + Collection testCollection = service.createCollection(TestConstants.SPECIAL_NAME); + assertNotNull(testCollection); + } + + @Test + public void testRead() throws XMLDBException { + Collection test = DatabaseManager.getCollection(ROOT_URI, ADMIN_UID, ADMIN_PWD); + assertNotNull(test); + Collection root = DatabaseManager.getCollection(ROOT_URI, ADMIN_UID, ADMIN_PWD); + test = root.getChildCollection(TestConstants.SPECIAL_NAME); + assertNotNull(test); + CollectionManagementService service = (CollectionManagementService)root.getService("CollectionManagementService", "1.0"); + service.removeCollection(TestConstants.SPECIAL_NAME); + } + + @Before + public void setUp() throws Exception { + // initialize driver + Class cl = Class.forName(DRIVER); + Database database = (Database) cl.newInstance(); + database.setProperty("create-database", "true"); + DatabaseManager.registerDatabase(database); + } + + @After + public void tearDown() throws XMLDBException { + Collection root = DatabaseManager.getCollection(ROOT_URI, ADMIN_UID, ADMIN_PWD); + DatabaseInstanceManager mgr = (DatabaseInstanceManager) root.getService("DatabaseInstanceManager", "1.0"); + mgr.shutdown(); + } +} diff --git a/test/src/org/exist/xmldb/SerializationTest.java b/test/src/org/exist/xmldb/SerializationTest.java index 408951be500..c2f66112c66 100644 --- a/test/src/org/exist/xmldb/SerializationTest.java +++ b/test/src/org/exist/xmldb/SerializationTest.java @@ -1,134 +1,134 @@ -package org.exist.xmldb; - -import org.custommonkey.xmlunit.XMLTestCase; -import org.exist.Namespaces; -import org.xmldb.api.DatabaseManager; -import org.xmldb.api.base.Collection; -import org.xmldb.api.base.Database; -import org.xmldb.api.base.Resource; -import org.xmldb.api.base.ResourceSet; -import org.xmldb.api.base.XMLDBException; -import org.xmldb.api.modules.CollectionManagementService; -import org.xmldb.api.modules.XMLResource; -import org.xmldb.api.modules.XQueryService; - -public class SerializationTest extends XMLTestCase { - - private static final String TEST_COLLECTION_NAME = "test"; - - private static final String XML = - "" + - " 1" + - " 2" + - ""; - - private static final String XML_EXPECTED1 = - "\n" + - " 1\n" + - " 2\n" + - ""; - - private static final String XML_EXPECTED2 = - "\n" + - " \n"+ - //BUG : we should have - //123 - " 123\n" + - //BUG : we should have - //123 - " 123\n" + - " \n" + - ""; - - - public static void main(String[] args) { - junit.textui.TestRunner.run(SerializationTest.class); - } - - private Database database; - private Collection testCollection; - - public void testQueryResults() { - try { - XQueryService service = (XQueryService) testCollection.getService("XQueryService", "1.0"); - ResourceSet result = service.query("declare namespace foo=\"http://foo.com\"; //foo:entry"); - Resource resource = result.getMembersAsResource(); - String str = resource.getContent().toString(); - System.out.println(str); - assertXMLEqual(XML_EXPECTED1, str); - - //TODO : THIS IS BUGGY ! - result = service.query("declare namespace config='urn:config'; " + - "declare namespace c='urn:content'; " + - "declare variable $config {123}; " + - "declare variable $serverConfig {123}; " + - " " + - "{($config,$serverConfig)} " + - ""); - resource = result.getMembersAsResource(); - str = resource.getContent().toString(); - System.out.println(str); - assertXMLEqual(XML_EXPECTED2, str); - - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - protected void setUp() { - try { - // initialize driver - Class cl = Class.forName("org.exist.xmldb.DatabaseImpl"); - database = (Database) cl.newInstance(); - database.setProperty("create-database", "true"); - DatabaseManager.registerDatabase(database); - - Collection root = - DatabaseManager.getCollection(XmldbURI.LOCAL_DB, "admin", ""); - CollectionManagementService service = - (CollectionManagementService) root.getService( - "CollectionManagementService", - "1.0"); - testCollection = service.createCollection(TEST_COLLECTION_NAME); - assertNotNull(testCollection); - - XMLResource res = (XMLResource) - testCollection.createResource("defaultns.xml", "XMLResource"); - res.setContent(XML); - testCollection.storeResource(res); - } catch (ClassNotFoundException e) { - } catch (InstantiationException e) { - } catch (IllegalAccessException e) { - } catch (XMLDBException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - /* - * @see TestCase#tearDown() - */ - protected void tearDown() { - try { - Collection root = - DatabaseManager.getCollection(XmldbURI.LOCAL_DB, "admin", ""); - CollectionManagementService service = - (CollectionManagementService) root.getService( - "CollectionManagementService", - "1.0"); - service.removeCollection(TEST_COLLECTION_NAME); - - DatabaseManager.deregisterDatabase(database); - DatabaseInstanceManager dim = - (DatabaseInstanceManager) testCollection.getService( - "DatabaseInstanceManager", "1.0"); - dim.shutdown(); - database = null; - testCollection = null; - System.out.println("tearDown PASSED"); - } catch (XMLDBException e) { - fail(e.getMessage()); - } - } +package org.exist.xmldb; + +import org.custommonkey.xmlunit.XMLTestCase; +import org.exist.Namespaces; +import org.xmldb.api.DatabaseManager; +import org.xmldb.api.base.Collection; +import org.xmldb.api.base.Database; +import org.xmldb.api.base.Resource; +import org.xmldb.api.base.ResourceSet; +import org.xmldb.api.base.XMLDBException; +import org.xmldb.api.modules.CollectionManagementService; +import org.xmldb.api.modules.XMLResource; +import org.xmldb.api.modules.XQueryService; + +public class SerializationTest extends XMLTestCase { + + private static final String TEST_COLLECTION_NAME = "test"; + + private static final String XML = + "" + + " 1" + + " 2" + + ""; + + private static final String XML_EXPECTED1 = + "\n" + + " 1\n" + + " 2\n" + + ""; + + private static final String XML_EXPECTED2 = + "\n" + + " \n"+ + //BUG : we should have + //123 + " 123\n" + + //BUG : we should have + //123 + " 123\n" + + " \n" + + ""; + + + public static void main(String[] args) { + junit.textui.TestRunner.run(SerializationTest.class); + } + + private Database database; + private Collection testCollection; + + public void testQueryResults() { + try { + XQueryService service = (XQueryService) testCollection.getService("XQueryService", "1.0"); + ResourceSet result = service.query("declare namespace foo=\"http://foo.com\"; //foo:entry"); + Resource resource = result.getMembersAsResource(); + String str = resource.getContent().toString(); + System.out.println(str); + assertXMLEqual(XML_EXPECTED1, str); + + //TODO : THIS IS BUGGY ! + result = service.query("declare namespace config='urn:config'; " + + "declare namespace c='urn:content'; " + + "declare variable $config {123}; " + + "declare variable $serverConfig {123}; " + + " " + + "{($config,$serverConfig)} " + + ""); + resource = result.getMembersAsResource(); + str = resource.getContent().toString(); + System.out.println(str); + assertXMLEqual(XML_EXPECTED2, str); + + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } + + protected void setUp() { + try { + // initialize driver + Class cl = Class.forName("org.exist.xmldb.DatabaseImpl"); + database = (Database) cl.newInstance(); + database.setProperty("create-database", "true"); + DatabaseManager.registerDatabase(database); + + Collection root = + DatabaseManager.getCollection(XmldbURI.LOCAL_DB, "admin", ""); + CollectionManagementService service = + (CollectionManagementService) root.getService( + "CollectionManagementService", + "1.0"); + testCollection = service.createCollection(TEST_COLLECTION_NAME); + assertNotNull(testCollection); + + XMLResource res = (XMLResource) + testCollection.createResource("defaultns.xml", "XMLResource"); + res.setContent(XML); + testCollection.storeResource(res); + } catch (ClassNotFoundException e) { + } catch (InstantiationException e) { + } catch (IllegalAccessException e) { + } catch (XMLDBException e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } + + /* + * @see TestCase#tearDown() + */ + protected void tearDown() { + try { + Collection root = + DatabaseManager.getCollection(XmldbURI.LOCAL_DB, "admin", ""); + CollectionManagementService service = + (CollectionManagementService) root.getService( + "CollectionManagementService", + "1.0"); + service.removeCollection(TEST_COLLECTION_NAME); + + DatabaseManager.deregisterDatabase(database); + DatabaseInstanceManager dim = + (DatabaseInstanceManager) testCollection.getService( + "DatabaseInstanceManager", "1.0"); + dim.shutdown(); + database = null; + testCollection = null; + System.out.println("tearDown PASSED"); + } catch (XMLDBException e) { + fail(e.getMessage()); + } + } } \ No newline at end of file diff --git a/test/src/org/exist/xmlrpc/MoveResourceTest.java b/test/src/org/exist/xmlrpc/MoveResourceTest.java index 19f7ac0878c..5bf88e5b278 100644 --- a/test/src/org/exist/xmlrpc/MoveResourceTest.java +++ b/test/src/org/exist/xmlrpc/MoveResourceTest.java @@ -1,233 +1,233 @@ -package org.exist.xmlrpc; - -import junit.framework.TestCase; -import junit.textui.TestRunner; -import org.apache.log4j.BasicConfigurator; -import org.apache.xmlrpc.XmlRpcException; -import org.apache.xmlrpc.client.XmlRpcClient; -import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; -import org.exist.jetty.JettyStart; -import org.exist.xmldb.XmldbURI; - -import java.io.*; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLEncoder; -import java.util.Hashtable; -import java.util.Vector; - -/** - * Test for deadlocks when moving resources from one collection to another. - * Uses two threads: one stores a document, then moves it to another collection. - * Based on XML-RPC. The second thread tries to execute a query via REST. - * - * Due to the complex move task, threads will deadlock almost immediately if - * something's wrong with collection locking. - */ -public class MoveResourceTest extends TestCase { - - public static void main(String[] args) { - BasicConfigurator.configure(); - TestRunner.run(MoveResourceTest.class); - } - - private JettyStart server; - - // jetty.port.standalone - private final static String URI = "http://localhost:" + System.getProperty("jetty.port") + "/xmlrpc"; - - private final static String REST_URI = "http://localhost:" + System.getProperty("jetty.port"); - - public MoveResourceTest(String string) { - super(string); - } - - public void testMove() { - Thread thread1 = new MoveThread(); - Thread thread2 = new CheckThread(); - Thread thread3 = new CheckThread(); - - thread1.start(); - thread2.start(); - thread3.start(); - try { - thread1.join(); - thread2.join(); - thread3.join(); - } catch (InterruptedException e) { - } - - System.out.println("DONE."); - } - - private void createCollection(XmlRpcClient client, XmldbURI collection) throws IOException, XmlRpcException { - Vector params = new Vector(); - params.addElement(collection.toString()); - Boolean result = (Boolean)client.execute("createCollection", params); - assertTrue(result.booleanValue()); - } - - private String readData() throws IOException { - String existHome = System.getProperty("exist.home"); - File existDir = existHome==null ? new File(".") : new File(existHome); - File f = new File(existDir,"samples/shakespeare/r_and_j.xml"); - assertNotNull(f); - - Reader reader = new BufferedReader(new InputStreamReader(new FileInputStream(f), "UTF-8")); - StringBuffer buf = new StringBuffer(); - char[] ch = new char[1024]; - int len; - while ((len = reader.read(ch)) > 0) { - buf.append(ch, 0, len); - } - return buf.toString(); - } - - private class MoveThread extends Thread { - - public void run() { - for (int i = 0; i < 100; i++) { - try { - XmldbURI sourceColl = XmldbURI.ROOT_COLLECTION_URI.append("source" + i); - XmldbURI targetColl1 = XmldbURI.ROOT_COLLECTION_URI.append("target"); - XmldbURI targetColl2 = targetColl1.append("test" + i); - XmldbURI sourceResource = sourceColl.append("source.xml"); - XmldbURI targetResource = targetColl2.append("copied.xml"); - - System.out.println("Creating collections ..."); - XmlRpcClient xmlrpc = getClient(); - - createCollection(xmlrpc, sourceColl); - createCollection(xmlrpc, targetColl1); - createCollection(xmlrpc, targetColl2); - - System.out.println("Storing document ..."); - Vector params = new Vector(); - params.addElement(readData()); - params.addElement(sourceResource.toString()); - params.addElement(new Integer(1)); - - Boolean result = (Boolean)xmlrpc.execute("parse", params); - assertTrue(result.booleanValue()); - - System.out.println("Document stored."); - - System.out.println("Moving resource ..."); - params.clear(); - params.addElement(sourceResource.toString()); - params.addElement(targetColl2.toString()); - params.addElement("copied.xml"); - - xmlrpc.execute( "moveResource", params ); - - System.out.println("Retrieving document " + targetResource); - Hashtable options = new Hashtable(); - options.put("indent", "yes"); - options.put("encoding", "UTF-8"); - options.put("expand-xincludes", "yes"); - options.put("process-xsl-pi", "no"); - - params.clear(); - params.addElement( targetResource.toString() ); - params.addElement( options ); - - byte[] data = (byte[]) xmlrpc.execute( "getDocument", params ); - assertTrue(data != null && data.length > 0); -// System.out.println( new String(data, "UTF-8") ); - - synchronized (this) { - wait(250); - } - - System.out.println("Removing created collections ..."); - params.clear(); - params.addElement(sourceColl.toString()); - xmlrpc.execute("removeCollection", params); - - params.setElementAt(targetColl1.toString(), 0); - xmlrpc.execute("removeCollection", params); - System.out.println("Collections removed."); - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - } - } - - private class CheckThread extends Thread { - - public void run() { - String reqUrl = REST_URI + "/db?_query=" + URLEncoder.encode("collection('/db')//SPEECH[SPEAKER = 'JULIET']"); - for (int i = 0; i < 200; i++) { - try { - URL url = new URL(reqUrl); - HttpURLConnection connect = (HttpURLConnection) url.openConnection(); - connect.setRequestMethod("GET"); - connect.connect(); - - int r = connect.getResponseCode(); - assertEquals("Server returned response code " + r, 200, r); - - System.out.println(readResponse(connect.getInputStream())); - - synchronized (this) { - wait(250); - } - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - } - - protected String readResponse(InputStream is) { - try { - BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); - String line; - StringBuffer out = new StringBuffer(); - while ((line = reader.readLine()) != null) { - out.append(line); - out.append("\r\n"); - } - return out.toString(); - } catch (Exception e) { - fail(e.getMessage()); - } - return null; - } - } - - protected void setUp() { - //Don't worry about closing the server : the shutdownDB hook will do the job - initServer(); - } - - protected static XmlRpcClient getClient() { - try { - XmlRpcClient client = new XmlRpcClient(); - XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); - config.setEnabledForExtensions(true); - config.setServerURL(new URL(URI)); - config.setBasicUserName("admin"); - config.setBasicPassword(""); - client.setConfig(config); - return client; - } catch (MalformedURLException e) { - return null; - } - } - - private void initServer() { - try { - if (server == null) { - server = new JettyStart(); - System.out.println("Starting standalone server..."); - server.run(); - } - } catch (Exception e) { - fail(e.getMessage()); - } - } -} +package org.exist.xmlrpc; + +import junit.framework.TestCase; +import junit.textui.TestRunner; +import org.apache.log4j.BasicConfigurator; +import org.apache.xmlrpc.XmlRpcException; +import org.apache.xmlrpc.client.XmlRpcClient; +import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; +import org.exist.jetty.JettyStart; +import org.exist.xmldb.XmldbURI; + +import java.io.*; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLEncoder; +import java.util.Hashtable; +import java.util.Vector; + +/** + * Test for deadlocks when moving resources from one collection to another. + * Uses two threads: one stores a document, then moves it to another collection. + * Based on XML-RPC. The second thread tries to execute a query via REST. + * + * Due to the complex move task, threads will deadlock almost immediately if + * something's wrong with collection locking. + */ +public class MoveResourceTest extends TestCase { + + public static void main(String[] args) { + BasicConfigurator.configure(); + TestRunner.run(MoveResourceTest.class); + } + + private JettyStart server; + + // jetty.port.standalone + private final static String URI = "http://localhost:" + System.getProperty("jetty.port") + "/xmlrpc"; + + private final static String REST_URI = "http://localhost:" + System.getProperty("jetty.port"); + + public MoveResourceTest(String string) { + super(string); + } + + public void testMove() { + Thread thread1 = new MoveThread(); + Thread thread2 = new CheckThread(); + Thread thread3 = new CheckThread(); + + thread1.start(); + thread2.start(); + thread3.start(); + try { + thread1.join(); + thread2.join(); + thread3.join(); + } catch (InterruptedException e) { + } + + System.out.println("DONE."); + } + + private void createCollection(XmlRpcClient client, XmldbURI collection) throws IOException, XmlRpcException { + Vector params = new Vector(); + params.addElement(collection.toString()); + Boolean result = (Boolean)client.execute("createCollection", params); + assertTrue(result.booleanValue()); + } + + private String readData() throws IOException { + String existHome = System.getProperty("exist.home"); + File existDir = existHome==null ? new File(".") : new File(existHome); + File f = new File(existDir,"samples/shakespeare/r_and_j.xml"); + assertNotNull(f); + + Reader reader = new BufferedReader(new InputStreamReader(new FileInputStream(f), "UTF-8")); + StringBuffer buf = new StringBuffer(); + char[] ch = new char[1024]; + int len; + while ((len = reader.read(ch)) > 0) { + buf.append(ch, 0, len); + } + return buf.toString(); + } + + private class MoveThread extends Thread { + + public void run() { + for (int i = 0; i < 100; i++) { + try { + XmldbURI sourceColl = XmldbURI.ROOT_COLLECTION_URI.append("source" + i); + XmldbURI targetColl1 = XmldbURI.ROOT_COLLECTION_URI.append("target"); + XmldbURI targetColl2 = targetColl1.append("test" + i); + XmldbURI sourceResource = sourceColl.append("source.xml"); + XmldbURI targetResource = targetColl2.append("copied.xml"); + + System.out.println("Creating collections ..."); + XmlRpcClient xmlrpc = getClient(); + + createCollection(xmlrpc, sourceColl); + createCollection(xmlrpc, targetColl1); + createCollection(xmlrpc, targetColl2); + + System.out.println("Storing document ..."); + Vector params = new Vector(); + params.addElement(readData()); + params.addElement(sourceResource.toString()); + params.addElement(new Integer(1)); + + Boolean result = (Boolean)xmlrpc.execute("parse", params); + assertTrue(result.booleanValue()); + + System.out.println("Document stored."); + + System.out.println("Moving resource ..."); + params.clear(); + params.addElement(sourceResource.toString()); + params.addElement(targetColl2.toString()); + params.addElement("copied.xml"); + + xmlrpc.execute( "moveResource", params ); + + System.out.println("Retrieving document " + targetResource); + Hashtable options = new Hashtable(); + options.put("indent", "yes"); + options.put("encoding", "UTF-8"); + options.put("expand-xincludes", "yes"); + options.put("process-xsl-pi", "no"); + + params.clear(); + params.addElement( targetResource.toString() ); + params.addElement( options ); + + byte[] data = (byte[]) xmlrpc.execute( "getDocument", params ); + assertTrue(data != null && data.length > 0); +// System.out.println( new String(data, "UTF-8") ); + + synchronized (this) { + wait(250); + } + + System.out.println("Removing created collections ..."); + params.clear(); + params.addElement(sourceColl.toString()); + xmlrpc.execute("removeCollection", params); + + params.setElementAt(targetColl1.toString(), 0); + xmlrpc.execute("removeCollection", params); + System.out.println("Collections removed."); + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } + } + } + + private class CheckThread extends Thread { + + public void run() { + String reqUrl = REST_URI + "/db?_query=" + URLEncoder.encode("collection('/db')//SPEECH[SPEAKER = 'JULIET']"); + for (int i = 0; i < 200; i++) { + try { + URL url = new URL(reqUrl); + HttpURLConnection connect = (HttpURLConnection) url.openConnection(); + connect.setRequestMethod("GET"); + connect.connect(); + + int r = connect.getResponseCode(); + assertEquals("Server returned response code " + r, 200, r); + + System.out.println(readResponse(connect.getInputStream())); + + synchronized (this) { + wait(250); + } + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } + } + + protected String readResponse(InputStream is) { + try { + BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); + String line; + StringBuffer out = new StringBuffer(); + while ((line = reader.readLine()) != null) { + out.append(line); + out.append("\r\n"); + } + return out.toString(); + } catch (Exception e) { + fail(e.getMessage()); + } + return null; + } + } + + protected void setUp() { + //Don't worry about closing the server : the shutdownDB hook will do the job + initServer(); + } + + protected static XmlRpcClient getClient() { + try { + XmlRpcClient client = new XmlRpcClient(); + XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); + config.setEnabledForExtensions(true); + config.setServerURL(new URL(URI)); + config.setBasicUserName("admin"); + config.setBasicPassword(""); + client.setConfig(config); + return client; + } catch (MalformedURLException e) { + return null; + } + } + + private void initServer() { + try { + if (server == null) { + server = new JettyStart(); + System.out.println("Starting standalone server..."); + server.run(); + } + } catch (Exception e) { + fail(e.getMessage()); + } + } +} diff --git a/test/src/org/exist/xmlrpc/QuerySessionTest.java b/test/src/org/exist/xmlrpc/QuerySessionTest.java index cfb65c73450..b079fe40a87 100755 --- a/test/src/org/exist/xmlrpc/QuerySessionTest.java +++ b/test/src/org/exist/xmlrpc/QuerySessionTest.java @@ -1,182 +1,182 @@ -package org.exist.xmlrpc; - -import org.exist.jetty.JettyStart; -import org.exist.TestDataGenerator; -import org.exist.xmldb.IndexQueryService; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.xmldb.api.DatabaseManager; -import org.xmldb.api.base.*; -import org.xmldb.api.modules.CollectionManagementService; -import org.xmldb.api.modules.XQueryService; - -import java.io.File; -import java.util.Random; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -/** - */ -public class QuerySessionTest { - - private final static String generateXQ = "" - + " " - + " {pt:random-text(7)}" - + " {" - + " for $section in 1 to 8 return" - + "
" - + " {pt:random-text(7)}" - + " {" - + " for $para in 1 to 10 return" - + " {pt:random-text(40)}" - + " }" - + "
" - + " }" - + "
" + "
"; - - private final static String COLLECTION_CONFIG = - "" + - " " + - " " + - " " + - " " + - " " + - " " + - ""; - - private final static String QUERY = - "declare variable $n external;" + - "//chapter[@xml:id = $n]"; - // jetty.port.standalone - private final static String baseURI = "xmldb:exist://localhost:" + System.getProperty("jetty.port") + "/xmlrpc"; - - private final static int N_THREADS = 10; - - private final static int DOC_COUNT = 100; - - private static JettyStart server; - - private Random random = new Random(); - - @Test (expected=XMLDBException.class) - public void manualRelease() throws XMLDBException { - System.out.println("---manualRelease"); - Collection test = DatabaseManager.getCollection(baseURI + "/db/rpctest", "admin", ""); - XQueryService service = (XQueryService) test.getService("XQueryService", "1.0"); - ResourceSet result = service.query("//chapter[@xml:id = 'chapter1']"); - Assert.assertEquals(1, result.getSize()); - - // clear should release the query result on the server - result.clear(); - - // the result has been cleared already. we should get an exception here - Resource members = result.getMembersAsResource(); - System.out.println("members: " + members.getContent().toString()); - } - - @Test - public void runTasks() { - System.out.println("---runTasks"); - ExecutorService executor = Executors.newFixedThreadPool(N_THREADS); - for (int i = 0; i < 1000; i++) { - if(i % 10 == 0) - System.out.print("."); - else - System.out.print("."); - executor.submit(new QueryTask(QUERY)); - } - - executor.shutdown(); - boolean terminated = false; - try { - terminated = executor.awaitTermination(60 * 60, TimeUnit.SECONDS); - } catch (InterruptedException e) { - } - Assert.assertTrue(terminated); - } - - private class QueryTask implements Runnable { - - private String query; - - private QueryTask(String query) { - this.query = query; - } - - public void run() { - try { - Collection test = DatabaseManager.getCollection(baseURI + "/db/rpctest", "admin", ""); - XQueryService service = (XQueryService) test.getService("XQueryService", "1.0"); - int n = random.nextInt(DOC_COUNT) + 1; - service.declareVariable("n", "chapter" + n); - ResourceSet result = service.query(query); - Assert.assertEquals(1, result.getSize()); - } catch (XMLDBException e) { - e.printStackTrace(); - Assert.fail(e.getMessage()); - } - } - } - - @BeforeClass - public static void startServer() throws Exception { - - System.out.println("\n\n==================================\n\n"); - - server = new JettyStart(); - System.out.println("Starting standalone server..."); - System.out.println("Waiting for server to start..."); - server.run(); - - // initialize XML:DB driver - Class cl = Class.forName("org.exist.xmldb.DatabaseImpl"); - Database database = (Database) cl.newInstance(); - DatabaseManager.registerDatabase(database); - - Collection root = DatabaseManager.getCollection(baseURI + "/db", "admin", ""); - - CollectionManagementService mgmt = - (CollectionManagementService) root.getService("CollectionManagementService", "1.0"); - Collection test = mgmt.createCollection("rpctest"); - IndexQueryService idxs = (IndexQueryService) test.getService("IndexQueryService", "1.0"); - idxs.configureCollection(COLLECTION_CONFIG); - - Resource resource = test.createResource("strings.xml", "XMLResource"); - resource.setContent(new File("samples/shakespeare/macbeth.xml")); - test.storeResource(resource); - - TestDataGenerator generator = new TestDataGenerator("xdb", DOC_COUNT); - File[] files = generator.generate(test, generateXQ); - for (int i = 0; i < files.length; i++) { - resource = test.createResource(files[i].getName(), "XMLResource"); - resource.setContent(files[i]); - test.storeResource(resource); - } - generator.releaseAll(); - } - - @AfterClass - public static void stopServer() { - - System.out.println("\n\nStop server...\n"); - - try { - Collection root = DatabaseManager.getCollection(baseURI + "/db", "admin", ""); - CollectionManagementService mgmt = - (CollectionManagementService) root.getService("CollectionManagementService", "1.0"); - mgmt.removeCollection("rpctest"); - - Collection config = DatabaseManager.getCollection(baseURI + "/db/system/config/db", "admin", ""); - mgmt = - (CollectionManagementService) config.getService("CollectionManagementService", "1.0"); - mgmt.removeCollection("rpctest"); - } catch (XMLDBException e) { - e.printStackTrace(); - } - server.shutdown(); - server = null; - } -} +package org.exist.xmlrpc; + +import org.exist.jetty.JettyStart; +import org.exist.TestDataGenerator; +import org.exist.xmldb.IndexQueryService; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.xmldb.api.DatabaseManager; +import org.xmldb.api.base.*; +import org.xmldb.api.modules.CollectionManagementService; +import org.xmldb.api.modules.XQueryService; + +import java.io.File; +import java.util.Random; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +/** + */ +public class QuerySessionTest { + + private final static String generateXQ = "" + + " " + + " {pt:random-text(7)}" + + " {" + + " for $section in 1 to 8 return" + + "
" + + " {pt:random-text(7)}" + + " {" + + " for $para in 1 to 10 return" + + " {pt:random-text(40)}" + + " }" + + "
" + + " }" + + "
" + "
"; + + private final static String COLLECTION_CONFIG = + "" + + " " + + " " + + " " + + " " + + " " + + " " + + ""; + + private final static String QUERY = + "declare variable $n external;" + + "//chapter[@xml:id = $n]"; + // jetty.port.standalone + private final static String baseURI = "xmldb:exist://localhost:" + System.getProperty("jetty.port") + "/xmlrpc"; + + private final static int N_THREADS = 10; + + private final static int DOC_COUNT = 100; + + private static JettyStart server; + + private Random random = new Random(); + + @Test (expected=XMLDBException.class) + public void manualRelease() throws XMLDBException { + System.out.println("---manualRelease"); + Collection test = DatabaseManager.getCollection(baseURI + "/db/rpctest", "admin", ""); + XQueryService service = (XQueryService) test.getService("XQueryService", "1.0"); + ResourceSet result = service.query("//chapter[@xml:id = 'chapter1']"); + Assert.assertEquals(1, result.getSize()); + + // clear should release the query result on the server + result.clear(); + + // the result has been cleared already. we should get an exception here + Resource members = result.getMembersAsResource(); + System.out.println("members: " + members.getContent().toString()); + } + + @Test + public void runTasks() { + System.out.println("---runTasks"); + ExecutorService executor = Executors.newFixedThreadPool(N_THREADS); + for (int i = 0; i < 1000; i++) { + if(i % 10 == 0) + System.out.print("."); + else + System.out.print("."); + executor.submit(new QueryTask(QUERY)); + } + + executor.shutdown(); + boolean terminated = false; + try { + terminated = executor.awaitTermination(60 * 60, TimeUnit.SECONDS); + } catch (InterruptedException e) { + } + Assert.assertTrue(terminated); + } + + private class QueryTask implements Runnable { + + private String query; + + private QueryTask(String query) { + this.query = query; + } + + public void run() { + try { + Collection test = DatabaseManager.getCollection(baseURI + "/db/rpctest", "admin", ""); + XQueryService service = (XQueryService) test.getService("XQueryService", "1.0"); + int n = random.nextInt(DOC_COUNT) + 1; + service.declareVariable("n", "chapter" + n); + ResourceSet result = service.query(query); + Assert.assertEquals(1, result.getSize()); + } catch (XMLDBException e) { + e.printStackTrace(); + Assert.fail(e.getMessage()); + } + } + } + + @BeforeClass + public static void startServer() throws Exception { + + System.out.println("\n\n==================================\n\n"); + + server = new JettyStart(); + System.out.println("Starting standalone server..."); + System.out.println("Waiting for server to start..."); + server.run(); + + // initialize XML:DB driver + Class cl = Class.forName("org.exist.xmldb.DatabaseImpl"); + Database database = (Database) cl.newInstance(); + DatabaseManager.registerDatabase(database); + + Collection root = DatabaseManager.getCollection(baseURI + "/db", "admin", ""); + + CollectionManagementService mgmt = + (CollectionManagementService) root.getService("CollectionManagementService", "1.0"); + Collection test = mgmt.createCollection("rpctest"); + IndexQueryService idxs = (IndexQueryService) test.getService("IndexQueryService", "1.0"); + idxs.configureCollection(COLLECTION_CONFIG); + + Resource resource = test.createResource("strings.xml", "XMLResource"); + resource.setContent(new File("samples/shakespeare/macbeth.xml")); + test.storeResource(resource); + + TestDataGenerator generator = new TestDataGenerator("xdb", DOC_COUNT); + File[] files = generator.generate(test, generateXQ); + for (int i = 0; i < files.length; i++) { + resource = test.createResource(files[i].getName(), "XMLResource"); + resource.setContent(files[i]); + test.storeResource(resource); + } + generator.releaseAll(); + } + + @AfterClass + public static void stopServer() { + + System.out.println("\n\nStop server...\n"); + + try { + Collection root = DatabaseManager.getCollection(baseURI + "/db", "admin", ""); + CollectionManagementService mgmt = + (CollectionManagementService) root.getService("CollectionManagementService", "1.0"); + mgmt.removeCollection("rpctest"); + + Collection config = DatabaseManager.getCollection(baseURI + "/db/system/config/db", "admin", ""); + mgmt = + (CollectionManagementService) config.getService("CollectionManagementService", "1.0"); + mgmt.removeCollection("rpctest"); + } catch (XMLDBException e) { + e.printStackTrace(); + } + server.shutdown(); + server = null; + } +} diff --git a/test/src/org/exist/xquery/JavaFunctionsTest.java b/test/src/org/exist/xquery/JavaFunctionsTest.java index 9ef46fc7f64..df0c78cb3ef 100644 --- a/test/src/org/exist/xquery/JavaFunctionsTest.java +++ b/test/src/org/exist/xquery/JavaFunctionsTest.java @@ -1,99 +1,99 @@ -/* - * Created on 17.03.2005 - $Id: XQueryFunctionsTest.java 3080 2006-04-07 22:17:14Z dizzzz $ - */ -package org.exist.xquery; - -import junit.framework.TestCase; -import junit.textui.TestRunner; - -import org.exist.util.Configuration; -import org.exist.xmldb.DatabaseInstanceManager; -import org.exist.xmldb.XmldbURI; -import org.xmldb.api.DatabaseManager; -import org.xmldb.api.base.Collection; -import org.xmldb.api.base.Database; -import org.xmldb.api.base.ResourceSet; -import org.xmldb.api.base.XMLDBException; -import org.xmldb.api.modules.XPathQueryService; - -/** Tests for various standart XQuery functions - * @author jens - */ -public class JavaFunctionsTest extends TestCase { - - private XPathQueryService service; - private Collection root = null; - private Database database = null; - - private boolean javabindingenabled = false; - - - public static void main(String[] args) throws XPathException { - TestRunner.run(JavaFunctionsTest.class); - } - - /** Tests simple list functions to make sure java functions are being - * called properly - */ - public void testLists() throws XPathException { - try - { - String query = "declare namespace list='java:java.util.ArrayList'; " + - "let $list := list:new() "+ - "let $actions := (list:add($list,'a'),list:add($list,'b'),list:add($list,'c')) "+ - "return list:get($list,1)"; - ResourceSet result = service.query( query ); - String r = (String) result.getResource(0).getContent(); - assertEquals( "b", r ); - } - catch (XMLDBException e) - { - //if exception is a java binding exception and java binding is disabled then this is a success - if(e.getMessage().indexOf("Java binding is disabled in the current configuration") > -1 && !javabindingenabled) - { - return; - } - - e.printStackTrace(); - fail(e.getMessage()); - } - } - - /* - * @see TestCase#setUp() - */ - protected void setUp() throws Exception { - // initialize driver - Class cl = Class.forName("org.exist.xmldb.DatabaseImpl"); - database = (Database) cl.newInstance(); - database.setProperty("create-database", "true"); - DatabaseManager.registerDatabase(database); - root = DatabaseManager.getCollection(XmldbURI.LOCAL_DB, "admin", ""); - service = (XPathQueryService) root.getService( "XQueryService", "1.0" ); - - //Check the configuration file to see if Java binding is enabled - //if it is not enabled then we expect an exception when trying to - //perform Java binding. - Configuration config = new Configuration(); - String javabinding = (String)config.getProperty(FunctionFactory.PROPERTY_ENABLE_JAVA_BINDING); - if(javabinding != null) - { - if(javabinding.equals("yes")) - { - javabindingenabled = true; - } - } - } - - /* - * @see TestCase#tearDown() - */ - protected void tearDown() throws Exception { - DatabaseManager.deregisterDatabase(database); - DatabaseInstanceManager dim = - (DatabaseInstanceManager) root.getService("DatabaseInstanceManager", "1.0"); - dim.shutdown(); - //System.out.println("tearDown PASSED"); - } - -} +/* + * Created on 17.03.2005 - $Id: XQueryFunctionsTest.java 3080 2006-04-07 22:17:14Z dizzzz $ + */ +package org.exist.xquery; + +import junit.framework.TestCase; +import junit.textui.TestRunner; + +import org.exist.util.Configuration; +import org.exist.xmldb.DatabaseInstanceManager; +import org.exist.xmldb.XmldbURI; +import org.xmldb.api.DatabaseManager; +import org.xmldb.api.base.Collection; +import org.xmldb.api.base.Database; +import org.xmldb.api.base.ResourceSet; +import org.xmldb.api.base.XMLDBException; +import org.xmldb.api.modules.XPathQueryService; + +/** Tests for various standart XQuery functions + * @author jens + */ +public class JavaFunctionsTest extends TestCase { + + private XPathQueryService service; + private Collection root = null; + private Database database = null; + + private boolean javabindingenabled = false; + + + public static void main(String[] args) throws XPathException { + TestRunner.run(JavaFunctionsTest.class); + } + + /** Tests simple list functions to make sure java functions are being + * called properly + */ + public void testLists() throws XPathException { + try + { + String query = "declare namespace list='java:java.util.ArrayList'; " + + "let $list := list:new() "+ + "let $actions := (list:add($list,'a'),list:add($list,'b'),list:add($list,'c')) "+ + "return list:get($list,1)"; + ResourceSet result = service.query( query ); + String r = (String) result.getResource(0).getContent(); + assertEquals( "b", r ); + } + catch (XMLDBException e) + { + //if exception is a java binding exception and java binding is disabled then this is a success + if(e.getMessage().indexOf("Java binding is disabled in the current configuration") > -1 && !javabindingenabled) + { + return; + } + + e.printStackTrace(); + fail(e.getMessage()); + } + } + + /* + * @see TestCase#setUp() + */ + protected void setUp() throws Exception { + // initialize driver + Class cl = Class.forName("org.exist.xmldb.DatabaseImpl"); + database = (Database) cl.newInstance(); + database.setProperty("create-database", "true"); + DatabaseManager.registerDatabase(database); + root = DatabaseManager.getCollection(XmldbURI.LOCAL_DB, "admin", ""); + service = (XPathQueryService) root.getService( "XQueryService", "1.0" ); + + //Check the configuration file to see if Java binding is enabled + //if it is not enabled then we expect an exception when trying to + //perform Java binding. + Configuration config = new Configuration(); + String javabinding = (String)config.getProperty(FunctionFactory.PROPERTY_ENABLE_JAVA_BINDING); + if(javabinding != null) + { + if(javabinding.equals("yes")) + { + javabindingenabled = true; + } + } + } + + /* + * @see TestCase#tearDown() + */ + protected void tearDown() throws Exception { + DatabaseManager.deregisterDatabase(database); + DatabaseInstanceManager dim = + (DatabaseInstanceManager) root.getService("DatabaseInstanceManager", "1.0"); + dim.shutdown(); + //System.out.println("tearDown PASSED"); + } + +} diff --git a/test/src/org/exist/xquery/OptimizerTest.java b/test/src/org/exist/xquery/OptimizerTest.java index bc77bb02355..510b3d78222 100644 --- a/test/src/org/exist/xquery/OptimizerTest.java +++ b/test/src/org/exist/xquery/OptimizerTest.java @@ -1,309 +1,309 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.xquery; - -import org.exist.TestUtils; -import org.exist.storage.BrokerPool; -import org.exist.util.Configuration; -import org.exist.util.XMLFilenameFilter; -import org.exist.xmldb.DatabaseInstanceManager; -import org.exist.xmldb.IndexQueryService; -import org.exist.xmldb.XmldbURI; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.xmldb.api.DatabaseManager; -import org.xmldb.api.base.Collection; -import org.xmldb.api.base.Database; -import org.xmldb.api.base.ResourceSet; -import org.xmldb.api.base.XMLDBException; -import org.xmldb.api.modules.CollectionManagementService; -import org.xmldb.api.modules.XMLResource; -import org.xmldb.api.modules.XQueryService; - -import java.io.File; -import java.io.IOException; - -/** - * - */ -public class OptimizerTest { - - private final static String OPTIMIZE = "declare option exist:optimize 'enable=yes';"; - private final static String NO_OPTIMIZE = "declare option exist:optimize 'enable=no';"; - private final static String NAMESPACES = "declare namespace mods='http://www.loc.gov/mods/v3';"; - - private static final String MSG_OPT_ERROR = "Optimized query should return same number of results."; - - private final static String XML = - "" + - " one" + - " one" + - " two" + - ""; - - private final static String COLLECTION_CONFIG = - "" + - " " + - " " + - " " + - " " + - " " + - " " + - " " + - " " + - " " + - ""; - private static Collection testCollection; - - @Test - public void nestedQuery() { - execute("/root/a[descendant::b = 'one']", true, "Inner b node should be returned.", 2); - execute("/root/a[b = 'one']", true, "Inner b node should not be returned.", 1); - execute("/root/a[b = 'one']", false, "Inner b node should not be returned.", 1); - } - - @Test - public void simplePredicates() { - int r = execute("//SPEECH[ft:query(LINE, 'king')]", false); - execute("//SPEECH[ft:query(LINE, 'king')]", true, MSG_OPT_ERROR, r); - - r = execute("//SPEECH[SPEAKER = 'HAMLET']", false); - execute("//SPEECH[SPEAKER = 'HAMLET']", true, MSG_OPT_ERROR, r); - - r = execute("//SPEECH[descendant::SPEAKER = 'HAMLET']", false); - execute("//SPEECH[descendant::SPEAKER = 'HAMLET']", true, MSG_OPT_ERROR, r); - - r = execute("//SCENE[ft:query(descendant::LINE, 'king')]", false); - execute("//SCENE[ft:query(descendant::LINE, 'king')]", true, MSG_OPT_ERROR, r); - - r = execute("//LINE[ft:query(., 'king')]", false); - execute("//LINE[ft:query(., 'king')]", true, MSG_OPT_ERROR, r); - - r = execute("//SPEAKER[. = 'HAMLET']", false); - execute("//SPEAKER[. = 'HAMLET']", true, MSG_OPT_ERROR, r); - -// r = execute("//LINE[descendant-or-self::LINE &= 'king']", false); -// execute("//LINE[descendant-or-self::LINE &= 'king']", true, MSG_OPT_ERROR, r); - - r = execute("//SPEAKER[descendant-or-self::SPEAKER = 'HAMLET']", false); - execute("//SPEAKER[descendant-or-self::SPEAKER = 'HAMLET']", true, MSG_OPT_ERROR, r); - - r = execute("//SPEECH/LINE[ft:query(., 'king')]", false); - execute("//SPEECH/LINE[ft:query(., 'king')]", true, MSG_OPT_ERROR, r); - - r = execute("//*[ft:query(LINE, 'king')]", false); - execute("//*[ft:query(LINE, 'king')]", true, MSG_OPT_ERROR, r); - - r = execute("//*[SPEAKER = 'HAMLET']", false); - execute("//*[SPEAKER = 'HAMLET']", true, MSG_OPT_ERROR, r); - } - - @Test - public void simplePredicatesRegex() { - int r = execute("//SPEECH[matches(SPEAKER, '^HAM.*')]", false); - execute("//SPEECH[matches(SPEAKER, '^HAM.*')]", true, MSG_OPT_ERROR, r); - r = execute("//SPEECH[starts-with(SPEAKER, 'HAML')]", false); - execute("//SPEECH[starts-with(SPEAKER, 'HAML')]", true, MSG_OPT_ERROR, r); - r = execute("//SPEECH[ends-with(SPEAKER, 'EO')]", false); - execute("//SPEECH[ends-with(SPEAKER, 'EO')]", true, MSG_OPT_ERROR, r); - r = execute("//SPEECH[matches(descendant::SPEAKER, 'HAML.*')]", false); - execute("//SPEECH[matches(descendant::SPEAKER, 'HAML.*')]", true, MSG_OPT_ERROR, r); - } - - @Test - public void twoPredicates() { - int r = execute("//SPEECH[ft:query(LINE, 'king')][SPEAKER='HAMLET']", false); - execute("//SPEECH[ft:query(LINE, 'king')][SPEAKER='HAMLET']", true, MSG_OPT_ERROR, r); - r = execute("//SPEECH[SPEAKER='HAMLET'][ft:query(LINE, 'king')]", false); - execute("//SPEECH[SPEAKER='HAMLET'][ft:query(LINE, 'king')]", true, MSG_OPT_ERROR, r); - } - - @Test - public void twoPredicatesNPEBug808() { - // Bug #808 NPE $docs[ngram:contains(first, "luke")][ngram:contains(last, "sky")] - int r = execute("let $sps := collection('/db/test')//SPEECH return $sps[ngram:contains(SPEAKER, 'HAMLET')][ngram:contains(LINE, 'king')]", false); - execute("let $sps := collection('/db/test')//SPEECH return $sps[ngram:contains(SPEAKER, 'HAMLET')][ngram:contains(LINE, 'king')]", true, MSG_OPT_ERROR, r); - } - - @Test - public void noOptimization() { - int r = execute("/root//b[parent::c/b = 'two']", false); - Assert.assertEquals(1, r); - execute("/root//b[parent::c/b = 'two']", true, "Parent axis should not be optimized.", r); - - r = execute("/root//b[ancestor::a/c/b = 'two']", false); - Assert.assertEquals(1, r); - execute("/root//b[ancestor::a/c/b = 'two']", true, "Ancestor axis should not be optimized.", r); - - r = execute("/root//b[ancestor::a/b = 'two']", false); - Assert.assertEquals(0, r); - execute("/root//b[ancestor::a/b = 'two']", true, "Ancestor axis should not be optimized.", r); - - r = execute("/root//b[text()/parent::b = 'two']", false); - Assert.assertEquals(1, r); - execute("/root//b[text()/parent::b = 'two']", true, "Parent axis should not be optimized.", r); - - r = execute("/root//b[matches(text()/parent::b, 'two')]", false); - Assert.assertEquals(1, r); - execute("/root//b[matches(text()/parent::b, 'two')]", true, "Parent axis should not be optimized.", r); - } - - @Test - public void reversePaths() { - - int r = execute("/root//b/parent::c[b = 'two']", false); - Assert.assertEquals(1, r); - execute("/root//b/parent::c[b = 'two']", true, MSG_OPT_ERROR, r); - } - - @Test @Ignore - public void reversePathsWithWildcard() { - //parent with wildcard - int r = execute("/root//b/parent::*[b = 'two']", false); - Assert.assertEquals(1, r); - execute("/root//b/parent::*[b = 'two']", true, MSG_OPT_ERROR, r); - } - - @Test - public void booleanOperator() { - int r = execute("//SPEECH[ft:query(LINE, 'king')][SPEAKER='HAMLET']", false); - execute("//SPEECH[ft:query(LINE, 'king') and SPEAKER='HAMLET']", false, MSG_OPT_ERROR, r); - execute("//SPEECH[ft:query(LINE, 'king') and SPEAKER='HAMLET']", true, MSG_OPT_ERROR, r); - r = execute("//SPEECH[ft:query(LINE, 'king') or SPEAKER='HAMLET']", false); - execute("//SPEECH[ft:query(LINE, 'king') or SPEAKER='HAMLET']", true, MSG_OPT_ERROR, r); - - r = execute("//SPEECH[ft:query(LINE, 'love') and ft:query(LINE, \"woman's\") and SPEAKER='HAMLET']", false); - execute("//SPEECH[ft:query(LINE, 'love') and ft:query(LINE, \"woman's\") and SPEAKER='HAMLET']", true, MSG_OPT_ERROR, r); - - r = execute("//SPEECH[(ft:query(LINE, 'king') or ft:query(LINE, 'love')) and SPEAKER='HAMLET']", false); - execute("//SPEECH[(ft:query(LINE, 'king') or ft:query(LINE, 'love')) and SPEAKER='HAMLET']", true, MSG_OPT_ERROR, r); - - r = execute("//SPEECH[(ft:query(LINE, 'juliet') and ft:query(LINE, 'romeo')) or SPEAKER='HAMLET']", false); - Assert.assertEquals(368, r); - execute("//SPEECH[(ft:query(LINE, 'juliet') and ft:query(LINE, 'romeo')) or SPEAKER='HAMLET']", true, MSG_OPT_ERROR, r); - - - execute("//SPEECH[true() and false()]", true, MSG_OPT_ERROR, 0); - execute("//SPEECH[true() and true()]", true, MSG_OPT_ERROR, 2628); - } - - private int execute(String query, boolean optimize) { - try { - System.out.println("--- Query: " + query + "; Optimize: " + Boolean.toString(optimize)); - XQueryService service = (XQueryService) testCollection.getService("XQueryService", "1.0"); - if (optimize) - query = OPTIMIZE + query; - else - query = NO_OPTIMIZE + query; - query = NAMESPACES + query; - ResourceSet result = service.query(query); - System.out.println("-- Found: " + result.getSize()); - return (int) result.getSize(); - } catch (XMLDBException e) { - e.printStackTrace(); - Assert.fail(e.getMessage()); - } - return 0; - } - - private void execute(String query, boolean optimize, String message, int expected) { - try { - System.out.println("--- Query: " + query + "; Optimize: " + Boolean.toString(optimize)); - XQueryService service = (XQueryService) testCollection.getService("XQueryService", "1.0"); - if (optimize) - query = NAMESPACES + OPTIMIZE + query; - else - query = NAMESPACES + NO_OPTIMIZE + query; - ResourceSet result = service.query(query); - System.out.println("-- Found: " + result.getSize()); - Assert.assertEquals(message, expected, result.getSize()); - } catch (XMLDBException e) { - e.printStackTrace(); - Assert.fail(e.getMessage()); - } - } - - @BeforeClass - public static void initDatabase() { - try { - //Since we use the deprecated text:match-all() function, we have to be sure is is enabled - Configuration config = new Configuration(); - config.setProperty(FunctionFactory.PROPERTY_DISABLE_DEPRECATED_FUNCTIONS, new Boolean(false)); - BrokerPool.configure(1, 5, config); - - // initialize driver - Class cl = Class.forName("org.exist.xmldb.DatabaseImpl"); - Database database = (Database) cl.newInstance(); - database.setProperty("create-database", "true"); - DatabaseManager.registerDatabase(database); - - Collection root = DatabaseManager.getCollection(XmldbURI.LOCAL_DB, "admin", ""); - CollectionManagementService service = - (CollectionManagementService) root.getService("CollectionManagementService", "1.0"); - testCollection = service.createCollection("test"); - Assert.assertNotNull(testCollection); - - IndexQueryService idxConf = (IndexQueryService) testCollection.getService("IndexQueryService", "1.0"); - idxConf.configureCollection(COLLECTION_CONFIG); - - XMLResource resource = (XMLResource) testCollection.createResource("test.xml", "XMLResource"); - resource.setContent(XML); - testCollection.storeResource(resource); - - String existHome = System.getProperty("exist.home"); - File existDir = existHome==null ? new File(".") : new File(existHome); - File dir = new File(existDir, "samples/shakespeare"); - if (!dir.canRead()) - throw new IOException("Unable to read samples directory"); - File[] files = dir.listFiles(new XMLFilenameFilter()); - for (File file : files) { - System.out.println("Create resource from "+file.getAbsolutePath()); - resource = (XMLResource) testCollection.createResource(file.getName(), "XMLResource"); - resource.setContent(file); - testCollection.storeResource(resource); - } - } catch (Exception e) { - e.printStackTrace(); - Assert.fail(e.getMessage()); - } - } - - @AfterClass - public static void shutdownDB() { - try { - TestUtils.cleanupDB(); - DatabaseInstanceManager dim = - (DatabaseInstanceManager) testCollection.getService( - "DatabaseInstanceManager", "1.0"); - dim.shutdown(); - } catch (XMLDBException e) { - e.printStackTrace(); - Assert.fail(e.getMessage()); - } - testCollection = null; - - System.out.println("tearDown PASSED"); - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.xquery; + +import org.exist.TestUtils; +import org.exist.storage.BrokerPool; +import org.exist.util.Configuration; +import org.exist.util.XMLFilenameFilter; +import org.exist.xmldb.DatabaseInstanceManager; +import org.exist.xmldb.IndexQueryService; +import org.exist.xmldb.XmldbURI; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; +import org.xmldb.api.DatabaseManager; +import org.xmldb.api.base.Collection; +import org.xmldb.api.base.Database; +import org.xmldb.api.base.ResourceSet; +import org.xmldb.api.base.XMLDBException; +import org.xmldb.api.modules.CollectionManagementService; +import org.xmldb.api.modules.XMLResource; +import org.xmldb.api.modules.XQueryService; + +import java.io.File; +import java.io.IOException; + +/** + * + */ +public class OptimizerTest { + + private final static String OPTIMIZE = "declare option exist:optimize 'enable=yes';"; + private final static String NO_OPTIMIZE = "declare option exist:optimize 'enable=no';"; + private final static String NAMESPACES = "declare namespace mods='http://www.loc.gov/mods/v3';"; + + private static final String MSG_OPT_ERROR = "Optimized query should return same number of results."; + + private final static String XML = + "" + + " one" + + " one" + + " two" + + ""; + + private final static String COLLECTION_CONFIG = + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + ""; + private static Collection testCollection; + + @Test + public void nestedQuery() { + execute("/root/a[descendant::b = 'one']", true, "Inner b node should be returned.", 2); + execute("/root/a[b = 'one']", true, "Inner b node should not be returned.", 1); + execute("/root/a[b = 'one']", false, "Inner b node should not be returned.", 1); + } + + @Test + public void simplePredicates() { + int r = execute("//SPEECH[ft:query(LINE, 'king')]", false); + execute("//SPEECH[ft:query(LINE, 'king')]", true, MSG_OPT_ERROR, r); + + r = execute("//SPEECH[SPEAKER = 'HAMLET']", false); + execute("//SPEECH[SPEAKER = 'HAMLET']", true, MSG_OPT_ERROR, r); + + r = execute("//SPEECH[descendant::SPEAKER = 'HAMLET']", false); + execute("//SPEECH[descendant::SPEAKER = 'HAMLET']", true, MSG_OPT_ERROR, r); + + r = execute("//SCENE[ft:query(descendant::LINE, 'king')]", false); + execute("//SCENE[ft:query(descendant::LINE, 'king')]", true, MSG_OPT_ERROR, r); + + r = execute("//LINE[ft:query(., 'king')]", false); + execute("//LINE[ft:query(., 'king')]", true, MSG_OPT_ERROR, r); + + r = execute("//SPEAKER[. = 'HAMLET']", false); + execute("//SPEAKER[. = 'HAMLET']", true, MSG_OPT_ERROR, r); + +// r = execute("//LINE[descendant-or-self::LINE &= 'king']", false); +// execute("//LINE[descendant-or-self::LINE &= 'king']", true, MSG_OPT_ERROR, r); + + r = execute("//SPEAKER[descendant-or-self::SPEAKER = 'HAMLET']", false); + execute("//SPEAKER[descendant-or-self::SPEAKER = 'HAMLET']", true, MSG_OPT_ERROR, r); + + r = execute("//SPEECH/LINE[ft:query(., 'king')]", false); + execute("//SPEECH/LINE[ft:query(., 'king')]", true, MSG_OPT_ERROR, r); + + r = execute("//*[ft:query(LINE, 'king')]", false); + execute("//*[ft:query(LINE, 'king')]", true, MSG_OPT_ERROR, r); + + r = execute("//*[SPEAKER = 'HAMLET']", false); + execute("//*[SPEAKER = 'HAMLET']", true, MSG_OPT_ERROR, r); + } + + @Test + public void simplePredicatesRegex() { + int r = execute("//SPEECH[matches(SPEAKER, '^HAM.*')]", false); + execute("//SPEECH[matches(SPEAKER, '^HAM.*')]", true, MSG_OPT_ERROR, r); + r = execute("//SPEECH[starts-with(SPEAKER, 'HAML')]", false); + execute("//SPEECH[starts-with(SPEAKER, 'HAML')]", true, MSG_OPT_ERROR, r); + r = execute("//SPEECH[ends-with(SPEAKER, 'EO')]", false); + execute("//SPEECH[ends-with(SPEAKER, 'EO')]", true, MSG_OPT_ERROR, r); + r = execute("//SPEECH[matches(descendant::SPEAKER, 'HAML.*')]", false); + execute("//SPEECH[matches(descendant::SPEAKER, 'HAML.*')]", true, MSG_OPT_ERROR, r); + } + + @Test + public void twoPredicates() { + int r = execute("//SPEECH[ft:query(LINE, 'king')][SPEAKER='HAMLET']", false); + execute("//SPEECH[ft:query(LINE, 'king')][SPEAKER='HAMLET']", true, MSG_OPT_ERROR, r); + r = execute("//SPEECH[SPEAKER='HAMLET'][ft:query(LINE, 'king')]", false); + execute("//SPEECH[SPEAKER='HAMLET'][ft:query(LINE, 'king')]", true, MSG_OPT_ERROR, r); + } + + @Test + public void twoPredicatesNPEBug808() { + // Bug #808 NPE $docs[ngram:contains(first, "luke")][ngram:contains(last, "sky")] + int r = execute("let $sps := collection('/db/test')//SPEECH return $sps[ngram:contains(SPEAKER, 'HAMLET')][ngram:contains(LINE, 'king')]", false); + execute("let $sps := collection('/db/test')//SPEECH return $sps[ngram:contains(SPEAKER, 'HAMLET')][ngram:contains(LINE, 'king')]", true, MSG_OPT_ERROR, r); + } + + @Test + public void noOptimization() { + int r = execute("/root//b[parent::c/b = 'two']", false); + Assert.assertEquals(1, r); + execute("/root//b[parent::c/b = 'two']", true, "Parent axis should not be optimized.", r); + + r = execute("/root//b[ancestor::a/c/b = 'two']", false); + Assert.assertEquals(1, r); + execute("/root//b[ancestor::a/c/b = 'two']", true, "Ancestor axis should not be optimized.", r); + + r = execute("/root//b[ancestor::a/b = 'two']", false); + Assert.assertEquals(0, r); + execute("/root//b[ancestor::a/b = 'two']", true, "Ancestor axis should not be optimized.", r); + + r = execute("/root//b[text()/parent::b = 'two']", false); + Assert.assertEquals(1, r); + execute("/root//b[text()/parent::b = 'two']", true, "Parent axis should not be optimized.", r); + + r = execute("/root//b[matches(text()/parent::b, 'two')]", false); + Assert.assertEquals(1, r); + execute("/root//b[matches(text()/parent::b, 'two')]", true, "Parent axis should not be optimized.", r); + } + + @Test + public void reversePaths() { + + int r = execute("/root//b/parent::c[b = 'two']", false); + Assert.assertEquals(1, r); + execute("/root//b/parent::c[b = 'two']", true, MSG_OPT_ERROR, r); + } + + @Test @Ignore + public void reversePathsWithWildcard() { + //parent with wildcard + int r = execute("/root//b/parent::*[b = 'two']", false); + Assert.assertEquals(1, r); + execute("/root//b/parent::*[b = 'two']", true, MSG_OPT_ERROR, r); + } + + @Test + public void booleanOperator() { + int r = execute("//SPEECH[ft:query(LINE, 'king')][SPEAKER='HAMLET']", false); + execute("//SPEECH[ft:query(LINE, 'king') and SPEAKER='HAMLET']", false, MSG_OPT_ERROR, r); + execute("//SPEECH[ft:query(LINE, 'king') and SPEAKER='HAMLET']", true, MSG_OPT_ERROR, r); + r = execute("//SPEECH[ft:query(LINE, 'king') or SPEAKER='HAMLET']", false); + execute("//SPEECH[ft:query(LINE, 'king') or SPEAKER='HAMLET']", true, MSG_OPT_ERROR, r); + + r = execute("//SPEECH[ft:query(LINE, 'love') and ft:query(LINE, \"woman's\") and SPEAKER='HAMLET']", false); + execute("//SPEECH[ft:query(LINE, 'love') and ft:query(LINE, \"woman's\") and SPEAKER='HAMLET']", true, MSG_OPT_ERROR, r); + + r = execute("//SPEECH[(ft:query(LINE, 'king') or ft:query(LINE, 'love')) and SPEAKER='HAMLET']", false); + execute("//SPEECH[(ft:query(LINE, 'king') or ft:query(LINE, 'love')) and SPEAKER='HAMLET']", true, MSG_OPT_ERROR, r); + + r = execute("//SPEECH[(ft:query(LINE, 'juliet') and ft:query(LINE, 'romeo')) or SPEAKER='HAMLET']", false); + Assert.assertEquals(368, r); + execute("//SPEECH[(ft:query(LINE, 'juliet') and ft:query(LINE, 'romeo')) or SPEAKER='HAMLET']", true, MSG_OPT_ERROR, r); + + + execute("//SPEECH[true() and false()]", true, MSG_OPT_ERROR, 0); + execute("//SPEECH[true() and true()]", true, MSG_OPT_ERROR, 2628); + } + + private int execute(String query, boolean optimize) { + try { + System.out.println("--- Query: " + query + "; Optimize: " + Boolean.toString(optimize)); + XQueryService service = (XQueryService) testCollection.getService("XQueryService", "1.0"); + if (optimize) + query = OPTIMIZE + query; + else + query = NO_OPTIMIZE + query; + query = NAMESPACES + query; + ResourceSet result = service.query(query); + System.out.println("-- Found: " + result.getSize()); + return (int) result.getSize(); + } catch (XMLDBException e) { + e.printStackTrace(); + Assert.fail(e.getMessage()); + } + return 0; + } + + private void execute(String query, boolean optimize, String message, int expected) { + try { + System.out.println("--- Query: " + query + "; Optimize: " + Boolean.toString(optimize)); + XQueryService service = (XQueryService) testCollection.getService("XQueryService", "1.0"); + if (optimize) + query = NAMESPACES + OPTIMIZE + query; + else + query = NAMESPACES + NO_OPTIMIZE + query; + ResourceSet result = service.query(query); + System.out.println("-- Found: " + result.getSize()); + Assert.assertEquals(message, expected, result.getSize()); + } catch (XMLDBException e) { + e.printStackTrace(); + Assert.fail(e.getMessage()); + } + } + + @BeforeClass + public static void initDatabase() { + try { + //Since we use the deprecated text:match-all() function, we have to be sure is is enabled + Configuration config = new Configuration(); + config.setProperty(FunctionFactory.PROPERTY_DISABLE_DEPRECATED_FUNCTIONS, new Boolean(false)); + BrokerPool.configure(1, 5, config); + + // initialize driver + Class cl = Class.forName("org.exist.xmldb.DatabaseImpl"); + Database database = (Database) cl.newInstance(); + database.setProperty("create-database", "true"); + DatabaseManager.registerDatabase(database); + + Collection root = DatabaseManager.getCollection(XmldbURI.LOCAL_DB, "admin", ""); + CollectionManagementService service = + (CollectionManagementService) root.getService("CollectionManagementService", "1.0"); + testCollection = service.createCollection("test"); + Assert.assertNotNull(testCollection); + + IndexQueryService idxConf = (IndexQueryService) testCollection.getService("IndexQueryService", "1.0"); + idxConf.configureCollection(COLLECTION_CONFIG); + + XMLResource resource = (XMLResource) testCollection.createResource("test.xml", "XMLResource"); + resource.setContent(XML); + testCollection.storeResource(resource); + + String existHome = System.getProperty("exist.home"); + File existDir = existHome==null ? new File(".") : new File(existHome); + File dir = new File(existDir, "samples/shakespeare"); + if (!dir.canRead()) + throw new IOException("Unable to read samples directory"); + File[] files = dir.listFiles(new XMLFilenameFilter()); + for (File file : files) { + System.out.println("Create resource from "+file.getAbsolutePath()); + resource = (XMLResource) testCollection.createResource(file.getName(), "XMLResource"); + resource.setContent(file); + testCollection.storeResource(resource); + } + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(e.getMessage()); + } + } + + @AfterClass + public static void shutdownDB() { + try { + TestUtils.cleanupDB(); + DatabaseInstanceManager dim = + (DatabaseInstanceManager) testCollection.getService( + "DatabaseInstanceManager", "1.0"); + dim.shutdown(); + } catch (XMLDBException e) { + e.printStackTrace(); + Assert.fail(e.getMessage()); + } + testCollection = null; + + System.out.println("tearDown PASSED"); + } +} diff --git a/test/src/org/exist/xquery/functions/request/GetHeaderTest.java b/test/src/org/exist/xquery/functions/request/GetHeaderTest.java index a025aeb2ecf..b15836e2503 100644 --- a/test/src/org/exist/xquery/functions/request/GetHeaderTest.java +++ b/test/src/org/exist/xquery/functions/request/GetHeaderTest.java @@ -1,92 +1,92 @@ -package org.exist.xquery.functions.request; - -import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -import java.io.IOException; -import java.io.InputStream; - -import org.apache.commons.httpclient.HttpException; -import org.apache.commons.httpclient.HttpStatus; -import org.apache.commons.httpclient.NameValuePair; -import org.apache.commons.httpclient.methods.GetMethod; -import org.exist.http.RESTTest; -import org.junit.Test; -import org.xml.sax.SAXException; - -/** - * Tests expected behaviour of request:get-header() XQuery function - * - * @author Adam Retter - * @version 1.0 - */ -public class GetHeaderTest extends RESTTest { - - private final static String HTTP_HEADER_NAME = "header1"; - private final static String xquery = "{request:get-header(\"" + HTTP_HEADER_NAME - + "\")}"; - - @Test - public void testGetNoHeader() { - testGetHeader(null); - } - - @Test - public void testEmptyHeader() { - testGetHeader(""); - } - - @Test - public void testHeaderValue() { - testGetHeader("value1"); - } - - private void testGetHeader(String headerValue) { - GetMethod get = new GetMethod(COLLECTION_ROOT_URL); - - NameValuePair qsParams[] = { new NameValuePair("_query", xquery), - new NameValuePair("_indent", "no") }; - - StringBuilder xmlExpectedResponse = new StringBuilder( - ""); - - if (headerValue != null) { - get.setRequestHeader(HTTP_HEADER_NAME, headerValue); - - xmlExpectedResponse.append(headerValue); - } - - xmlExpectedResponse.append(""); - - get.setQueryString(qsParams); - - try { - int httpResult = client.executeMethod(get); - - byte buf[] = new byte[1024]; - int read = -1; - StringBuilder xmlActualResponse = new StringBuilder(); - InputStream is = get.getResponseBodyAsStream(); - while ((read = is.read(buf)) > -1) { - xmlActualResponse.append(new String(buf, 0, read)); - } - - assertEquals(httpResult, HttpStatus.SC_OK); - - assertXMLEqual(xmlActualResponse.toString(), xmlExpectedResponse - .toString()); - - } catch (HttpException he) { - fail(he.getMessage()); - } catch (IOException ioe) { - fail(ioe.getMessage()); - } catch (SAXException sae) { - fail(sae.getMessage()); - } finally { - get.releaseConnection(); - } - } +package org.exist.xquery.functions.request; + +import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.io.IOException; +import java.io.InputStream; + +import org.apache.commons.httpclient.HttpException; +import org.apache.commons.httpclient.HttpStatus; +import org.apache.commons.httpclient.NameValuePair; +import org.apache.commons.httpclient.methods.GetMethod; +import org.exist.http.RESTTest; +import org.junit.Test; +import org.xml.sax.SAXException; + +/** + * Tests expected behaviour of request:get-header() XQuery function + * + * @author Adam Retter + * @version 1.0 + */ +public class GetHeaderTest extends RESTTest { + + private final static String HTTP_HEADER_NAME = "header1"; + private final static String xquery = "{request:get-header(\"" + HTTP_HEADER_NAME + + "\")}"; + + @Test + public void testGetNoHeader() { + testGetHeader(null); + } + + @Test + public void testEmptyHeader() { + testGetHeader(""); + } + + @Test + public void testHeaderValue() { + testGetHeader("value1"); + } + + private void testGetHeader(String headerValue) { + GetMethod get = new GetMethod(COLLECTION_ROOT_URL); + + NameValuePair qsParams[] = { new NameValuePair("_query", xquery), + new NameValuePair("_indent", "no") }; + + StringBuilder xmlExpectedResponse = new StringBuilder( + ""); + + if (headerValue != null) { + get.setRequestHeader(HTTP_HEADER_NAME, headerValue); + + xmlExpectedResponse.append(headerValue); + } + + xmlExpectedResponse.append(""); + + get.setQueryString(qsParams); + + try { + int httpResult = client.executeMethod(get); + + byte buf[] = new byte[1024]; + int read = -1; + StringBuilder xmlActualResponse = new StringBuilder(); + InputStream is = get.getResponseBodyAsStream(); + while ((read = is.read(buf)) > -1) { + xmlActualResponse.append(new String(buf, 0, read)); + } + + assertEquals(httpResult, HttpStatus.SC_OK); + + assertXMLEqual(xmlActualResponse.toString(), xmlExpectedResponse + .toString()); + + } catch (HttpException he) { + fail(he.getMessage()); + } catch (IOException ioe) { + fail(ioe.getMessage()); + } catch (SAXException sae) { + fail(sae.getMessage()); + } finally { + get.releaseConnection(); + } + } } \ No newline at end of file diff --git a/test/src/org/exist/xquery/functions/request/GetParameterTest.java b/test/src/org/exist/xquery/functions/request/GetParameterTest.java index f63e4a6318f..820313d0f50 100644 --- a/test/src/org/exist/xquery/functions/request/GetParameterTest.java +++ b/test/src/org/exist/xquery/functions/request/GetParameterTest.java @@ -1,513 +1,513 @@ -package org.exist.xquery.functions.request; - -import java.io.ByteArrayInputStream; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.httpclient.HttpException; -import org.apache.commons.httpclient.HttpMethod; -import org.apache.commons.httpclient.HttpStatus; -import org.apache.commons.httpclient.NameValuePair; -import org.apache.commons.httpclient.methods.GetMethod; -import org.apache.commons.httpclient.methods.PostMethod; -import org.apache.commons.httpclient.methods.multipart.FilePart; -import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity; -import org.apache.commons.httpclient.methods.multipart.Part; -import org.apache.commons.httpclient.methods.multipart.PartSource; -import org.apache.commons.httpclient.methods.multipart.StringPart; -import org.exist.http.RESTTest; -import org.exist.xmldb.EXistResource; -import org.exist.xmldb.UserManagementService; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.xmldb.api.DatabaseManager; -import org.xmldb.api.base.Collection; -import org.xmldb.api.base.XMLDBException; -import org.xmldb.api.modules.BinaryResource; - -/** - * Tests expected behaviour of request:get-parameter() XQuery function - * - * @author Adam Retter - * @version 1.0 - */ -public class GetParameterTest extends RESTTest { - - private final static String XQUERY = "for $param-name in request:get-parameter-names() return for $param-value in request:get-parameter($param-name, ()) return fn:concat($param-name, '=', $param-value)"; - private final static String XQUERY_FILENAME = "test-get-parameter.xql"; - - private final static String TEST_FILE_CONTENT = "hello world"; - private final static String TEST_FILE_NAME = "helloworld.txt"; - - private static Collection root; - - - @BeforeClass - public static void beforeClass() throws XMLDBException { - // jetty.port.standalone - root = DatabaseManager.getCollection("xmldb:exist://localhost:" + System.getProperty("jetty.port") + "/xmlrpc/db", "admin", ""); - BinaryResource res = (BinaryResource)root.createResource(XQUERY_FILENAME, "BinaryResource"); - ((EXistResource) res).setMimeType("application/xquery"); - res.setContent(XQUERY); - root.storeResource(res); - UserManagementService ums = (UserManagementService)root.getService("UserManagementService", "1.0"); - ums.chmod(res, 0777); - } - - @AfterClass - public static void afterClass() throws XMLDBException { - BinaryResource res = (BinaryResource)root.getResource(XQUERY_FILENAME); - root.removeResource(res); - } - - @Test - public void testGetNoParameter() throws XMLDBException { - testGet(null); - } - - @Test - public void testPostNoParameter() throws XMLDBException { - testPost(null); - } - - @Test - public void testGetEmptyParameter() { - testGet(new NameValues[] { - new NameValues("param1", new String[]{}) - }); - } - - @Test - public void testPostEmptyParameter() { - testPost(new NameValues[] { - new NameValues("param1", new String[]{}) - }); - } - - @Test - public void testGetSingleValueParameter() { - testGet(new NameValues[] { - new NameValues("param1", new String[] { - "value1" - }) - }); - } - - @Test - public void testPostSingleValueParameter() { - testPost(new NameValues[] { - new NameValues("param1", new String[] { - "value1" - }) - }); - } - - @Test - public void testGetMultiValueParameter() { - testGet(new NameValues[]{ - new NameValues("param1", new String[] { - "value1", - "value2", - "value3", - "value4" - }) - }); - } - - @Test - public void testPostMultiValueParameter() { - testPost(new NameValues[]{ - new NameValues("param1", new String[] { - "value1", - "value2", - "value3", - "value4" - }) - }); - } - - @Test - public void testPostMultiValueParameterWithQueryStringMultiValueParameter() { - testPost( - new NameValues[]{ - new NameValues("param1", new String[] { - "value1", - "value2", - "value3", - "value4" - }), - }, - new NameValues[]{ - new NameValues("param2", new String[] { - "valueA", - "valueB", - "valueC", - "valueD" - }), - } - ); - } - - @Test - public void testPostMultiValueParameterWithQueryStringMultiValueParameterMerge() { - testPost( - new NameValues[]{ - new NameValues("param1", new String[] { - "value1", - "value2", - "value3", - "value4" - }), - }, - new NameValues[]{ - new NameValues("param1", new String[] { - "valueA", - "valueB", - "valueC", - "valueD" - }), - } - ); - } - - @Test - public void testMultipartPostMultiValueParameterAndFile() { - testMultipartPost( - new Param[]{ - new NameValues("param1", new String[] { - "value1", - "value2", - "value3", - "value4" - }), - new TextFileUpload(TEST_FILE_NAME, TEST_FILE_CONTENT) - } - ); - } - - @Test - public void testMultipartPostFileAndMultiValueParameter() { - testMultipartPost( - new Param[]{ - new TextFileUpload(TEST_FILE_NAME, TEST_FILE_CONTENT), - new NameValues("param1", new String[] { - "value1", - "value2", - "value3", - "value4" - }) - } - ); - } - - @Test - public void testMultipartPostMultiValueParameterAndFileAndMultiValueParameter() { - testMultipartPost( - new Param[]{ - new NameValues("param1", new String[] { - "value1", - "value2", - "value3", - "value4" - }), - new TextFileUpload(TEST_FILE_NAME, TEST_FILE_CONTENT), - new NameValues("param2", new String[] { - "valueA", - "valueB", - "valueC", - "valueD" - }) - } - ); - } - - @Test - public void testMultipartPostAndMultiValueParameterAndFileAndMultiValueParameterWithQueryStringMultiValueParameters() { - testMultipartPost( - new NameValues[]{ - new NameValues("param1", new String[] { - "value1", - "value2", - "value3", - "value4" - }) - }, - new Param[]{ - new NameValues("param2", new String[] { - "valueA", - "valueB", - "valueC", - "valueD" - }), - new TextFileUpload(TEST_FILE_NAME, TEST_FILE_CONTENT), - new NameValues("param3", new String[] { - "valueZ", - "valueY", - "valueX", - "valueW" - }) - } - ); - } - - @Test - public void testMultipartPostAndMultiValueParameterAndFileAndMultiValueParameterWithQueryStringMultiValueParametersMerged() { - testMultipartPost( - new NameValues[]{ - new NameValues("param1", new String[] { - "value1", - "value2", - "value3", - "value4" - }) - }, - new Param[]{ - new NameValues("param1", new String[] { - "value5", - "value6", - "value7", - "value8" - }), - new TextFileUpload(TEST_FILE_NAME, TEST_FILE_CONTENT), - new NameValues("param2", new String[] { - "valueA", - "valueB", - "valueC", - "valueD" - }) - } - ); - } - - private void testGet(NameValues queryStringParams[]) { - - StringBuilder expectedResponse = new StringBuilder(); - NameValuePair qsParams[] = convertNameValuesToNameValuePairs(queryStringParams, expectedResponse); - - GetMethod get = new GetMethod(COLLECTION_ROOT_URL + "/" + XQUERY_FILENAME); - if(qsParams.length > 0) { - get.setQueryString(qsParams); - } - - testRequest(get, expectedResponse); - } - - private void testPost(NameValues formParams[]) { - - StringBuilder expectedResponse = new StringBuilder(); - NameValuePair fParams[] = convertNameValuesToNameValuePairs(formParams, expectedResponse); - - PostMethod post = new PostMethod(COLLECTION_ROOT_URL + "/" + XQUERY_FILENAME); - - if(fParams.length > 0) { - post.setRequestBody(fParams); - } - - testRequest(post, expectedResponse); - } - - private void testPost(NameValues queryStringParams[], NameValues formParams[]) { - - StringBuilder expectedResponse = new StringBuilder(); - NameValuePair qsParams[] = convertNameValuesToNameValuePairs(queryStringParams, expectedResponse); - NameValuePair fParams[] = convertNameValuesToNameValuePairs(formParams, expectedResponse); - - PostMethod post = new PostMethod(COLLECTION_ROOT_URL + "/" + XQUERY_FILENAME); - - if(qsParams.length > 0) { - post.setQueryString(qsParams); - } - - if(fParams.length > 0) { - post.setRequestBody(fParams); - } - - testRequest(post, expectedResponse); - } - - private void testMultipartPost(Param multipartParams[]) { - - List parts = new ArrayList(); - - StringBuilder expectedResponse = new StringBuilder(); - - for(Param multipartParam : multipartParams) { - if(multipartParam instanceof NameValues) { - for(NameValuePair nameValuePair : convertNameValueToNameValuePairs((NameValues)multipartParam, expectedResponse)) { - parts.add(new StringPart(nameValuePair.getName(), nameValuePair.getValue())); - } - } else if(multipartParam instanceof TextFileUpload) { - parts.add(convertFileUploadToFilePart((TextFileUpload)multipartParam, expectedResponse)); - } - } - - PostMethod post = new PostMethod(COLLECTION_ROOT_URL + "/" + XQUERY_FILENAME); - post.setRequestEntity(new MultipartRequestEntity(parts.toArray(new Part[parts.size()]), post.getParams())); - - testRequest(post, expectedResponse); - } - - private void testMultipartPost(NameValues queryStringParams[], Param multipartParams[]) { - - List parts = new ArrayList(); - - StringBuilder expectedResponse = new StringBuilder(); - - NameValuePair qsParams[] = convertNameValuesToNameValuePairs(queryStringParams, expectedResponse); - - for(Param multipartParam : multipartParams) { - if(multipartParam instanceof NameValues) { - for(NameValuePair nameValuePair : convertNameValueToNameValuePairs((NameValues)multipartParam, expectedResponse)) { - parts.add(new StringPart(nameValuePair.getName(), nameValuePair.getValue())); - } - } else if(multipartParam instanceof TextFileUpload) { - parts.add(convertFileUploadToFilePart((TextFileUpload)multipartParam, expectedResponse)); - } - } - - PostMethod post = new PostMethod(COLLECTION_ROOT_URL + "/" + XQUERY_FILENAME); - - if(qsParams.length > 0) { - post.setQueryString(qsParams); - } - - post.setRequestEntity(new MultipartRequestEntity(parts.toArray(new Part[parts.size()]), post.getParams())); - - testRequest(post, expectedResponse); - } - - private void testRequest(HttpMethod method, StringBuilder expectedResponse) { - - try { - int httpResult = client.executeMethod(method); - - byte buf[] = new byte[1024]; - int read = -1; - StringBuilder responseBody = new StringBuilder(); - InputStream is = method.getResponseBodyAsStream(); - while((read = is.read(buf)) > -1) { - responseBody.append(new String(buf, 0, read)); - } - - assertEquals(HttpStatus.SC_OK, httpResult); - - assertEquals(expectedResponse.toString(), responseBody.toString()); - - } catch(HttpException he) { - fail(he.getMessage()); - } catch(IOException ioe) { - fail(ioe.getMessage()); - } finally { - method.releaseConnection(); - } - } - - private NameValuePair[] convertNameValuesToNameValuePairs(NameValues nameValues[], StringBuilder expectedResponse) { - - List nameValuePairs = new ArrayList(); - - if(nameValues != null) { - for(NameValues param : nameValues) { - nameValuePairs.addAll(convertNameValueToNameValuePairs(param, expectedResponse)); - } - } - - return nameValuePairs.toArray(new NameValuePair[nameValuePairs.size()]); - } - - private List convertNameValueToNameValuePairs(NameValues nameValues, StringBuilder expectedResponse) { - - List nameValuePairs = new ArrayList(); - - for(String paramValue : nameValues.getData()) { - nameValuePairs.add(new NameValuePair(nameValues.getName(), paramValue)); - - expectedResponse.append(nameValues.getName()); - expectedResponse.append("="); - expectedResponse.append(paramValue); - } - - return nameValuePairs; - } - - private FilePart convertFileUploadToFilePart(final TextFileUpload txtFileUpload, StringBuilder expectedResponse) { - - final String filePartName = "fileUpload"; - - FilePart filePart = new FilePart(filePartName, new PartSource() { - private byte data[] = txtFileUpload.getData().getBytes(); - - @Override - public long getLength() { - return data.length; - } - - @Override - public String getFileName() { - return txtFileUpload.getName(); - } - - @Override - public InputStream createInputStream() throws IOException { - return new ByteArrayInputStream(data); - } - }); - - expectedResponse.append(filePartName); - expectedResponse.append("="); - expectedResponse.append(txtFileUpload.getData()); - - return filePart; - } - - public class NameValues implements Param { - - final String name; - final String values[]; - - public NameValues(String name, String values[]) { - this.name = name; - this.values = values; - } - - @Override - public String getName() { - return name; - } - - public String[] getData() { - return values; - } - } - - public class TextFileUpload implements Param { - final String name; - final String content; - - public TextFileUpload(String name, String content) { - this.name = name; - this.content = content; - } - - @Override - public String getData() { - return content; - } - - @Override - public String getName() { - return name; - } - } - - public interface Param { - public String getName(); - public T getData(); - } -} +package org.exist.xquery.functions.request; + +import java.io.ByteArrayInputStream; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.httpclient.HttpException; +import org.apache.commons.httpclient.HttpMethod; +import org.apache.commons.httpclient.HttpStatus; +import org.apache.commons.httpclient.NameValuePair; +import org.apache.commons.httpclient.methods.GetMethod; +import org.apache.commons.httpclient.methods.PostMethod; +import org.apache.commons.httpclient.methods.multipart.FilePart; +import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity; +import org.apache.commons.httpclient.methods.multipart.Part; +import org.apache.commons.httpclient.methods.multipart.PartSource; +import org.apache.commons.httpclient.methods.multipart.StringPart; +import org.exist.http.RESTTest; +import org.exist.xmldb.EXistResource; +import org.exist.xmldb.UserManagementService; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.xmldb.api.DatabaseManager; +import org.xmldb.api.base.Collection; +import org.xmldb.api.base.XMLDBException; +import org.xmldb.api.modules.BinaryResource; + +/** + * Tests expected behaviour of request:get-parameter() XQuery function + * + * @author Adam Retter + * @version 1.0 + */ +public class GetParameterTest extends RESTTest { + + private final static String XQUERY = "for $param-name in request:get-parameter-names() return for $param-value in request:get-parameter($param-name, ()) return fn:concat($param-name, '=', $param-value)"; + private final static String XQUERY_FILENAME = "test-get-parameter.xql"; + + private final static String TEST_FILE_CONTENT = "hello world"; + private final static String TEST_FILE_NAME = "helloworld.txt"; + + private static Collection root; + + + @BeforeClass + public static void beforeClass() throws XMLDBException { + // jetty.port.standalone + root = DatabaseManager.getCollection("xmldb:exist://localhost:" + System.getProperty("jetty.port") + "/xmlrpc/db", "admin", ""); + BinaryResource res = (BinaryResource)root.createResource(XQUERY_FILENAME, "BinaryResource"); + ((EXistResource) res).setMimeType("application/xquery"); + res.setContent(XQUERY); + root.storeResource(res); + UserManagementService ums = (UserManagementService)root.getService("UserManagementService", "1.0"); + ums.chmod(res, 0777); + } + + @AfterClass + public static void afterClass() throws XMLDBException { + BinaryResource res = (BinaryResource)root.getResource(XQUERY_FILENAME); + root.removeResource(res); + } + + @Test + public void testGetNoParameter() throws XMLDBException { + testGet(null); + } + + @Test + public void testPostNoParameter() throws XMLDBException { + testPost(null); + } + + @Test + public void testGetEmptyParameter() { + testGet(new NameValues[] { + new NameValues("param1", new String[]{}) + }); + } + + @Test + public void testPostEmptyParameter() { + testPost(new NameValues[] { + new NameValues("param1", new String[]{}) + }); + } + + @Test + public void testGetSingleValueParameter() { + testGet(new NameValues[] { + new NameValues("param1", new String[] { + "value1" + }) + }); + } + + @Test + public void testPostSingleValueParameter() { + testPost(new NameValues[] { + new NameValues("param1", new String[] { + "value1" + }) + }); + } + + @Test + public void testGetMultiValueParameter() { + testGet(new NameValues[]{ + new NameValues("param1", new String[] { + "value1", + "value2", + "value3", + "value4" + }) + }); + } + + @Test + public void testPostMultiValueParameter() { + testPost(new NameValues[]{ + new NameValues("param1", new String[] { + "value1", + "value2", + "value3", + "value4" + }) + }); + } + + @Test + public void testPostMultiValueParameterWithQueryStringMultiValueParameter() { + testPost( + new NameValues[]{ + new NameValues("param1", new String[] { + "value1", + "value2", + "value3", + "value4" + }), + }, + new NameValues[]{ + new NameValues("param2", new String[] { + "valueA", + "valueB", + "valueC", + "valueD" + }), + } + ); + } + + @Test + public void testPostMultiValueParameterWithQueryStringMultiValueParameterMerge() { + testPost( + new NameValues[]{ + new NameValues("param1", new String[] { + "value1", + "value2", + "value3", + "value4" + }), + }, + new NameValues[]{ + new NameValues("param1", new String[] { + "valueA", + "valueB", + "valueC", + "valueD" + }), + } + ); + } + + @Test + public void testMultipartPostMultiValueParameterAndFile() { + testMultipartPost( + new Param[]{ + new NameValues("param1", new String[] { + "value1", + "value2", + "value3", + "value4" + }), + new TextFileUpload(TEST_FILE_NAME, TEST_FILE_CONTENT) + } + ); + } + + @Test + public void testMultipartPostFileAndMultiValueParameter() { + testMultipartPost( + new Param[]{ + new TextFileUpload(TEST_FILE_NAME, TEST_FILE_CONTENT), + new NameValues("param1", new String[] { + "value1", + "value2", + "value3", + "value4" + }) + } + ); + } + + @Test + public void testMultipartPostMultiValueParameterAndFileAndMultiValueParameter() { + testMultipartPost( + new Param[]{ + new NameValues("param1", new String[] { + "value1", + "value2", + "value3", + "value4" + }), + new TextFileUpload(TEST_FILE_NAME, TEST_FILE_CONTENT), + new NameValues("param2", new String[] { + "valueA", + "valueB", + "valueC", + "valueD" + }) + } + ); + } + + @Test + public void testMultipartPostAndMultiValueParameterAndFileAndMultiValueParameterWithQueryStringMultiValueParameters() { + testMultipartPost( + new NameValues[]{ + new NameValues("param1", new String[] { + "value1", + "value2", + "value3", + "value4" + }) + }, + new Param[]{ + new NameValues("param2", new String[] { + "valueA", + "valueB", + "valueC", + "valueD" + }), + new TextFileUpload(TEST_FILE_NAME, TEST_FILE_CONTENT), + new NameValues("param3", new String[] { + "valueZ", + "valueY", + "valueX", + "valueW" + }) + } + ); + } + + @Test + public void testMultipartPostAndMultiValueParameterAndFileAndMultiValueParameterWithQueryStringMultiValueParametersMerged() { + testMultipartPost( + new NameValues[]{ + new NameValues("param1", new String[] { + "value1", + "value2", + "value3", + "value4" + }) + }, + new Param[]{ + new NameValues("param1", new String[] { + "value5", + "value6", + "value7", + "value8" + }), + new TextFileUpload(TEST_FILE_NAME, TEST_FILE_CONTENT), + new NameValues("param2", new String[] { + "valueA", + "valueB", + "valueC", + "valueD" + }) + } + ); + } + + private void testGet(NameValues queryStringParams[]) { + + StringBuilder expectedResponse = new StringBuilder(); + NameValuePair qsParams[] = convertNameValuesToNameValuePairs(queryStringParams, expectedResponse); + + GetMethod get = new GetMethod(COLLECTION_ROOT_URL + "/" + XQUERY_FILENAME); + if(qsParams.length > 0) { + get.setQueryString(qsParams); + } + + testRequest(get, expectedResponse); + } + + private void testPost(NameValues formParams[]) { + + StringBuilder expectedResponse = new StringBuilder(); + NameValuePair fParams[] = convertNameValuesToNameValuePairs(formParams, expectedResponse); + + PostMethod post = new PostMethod(COLLECTION_ROOT_URL + "/" + XQUERY_FILENAME); + + if(fParams.length > 0) { + post.setRequestBody(fParams); + } + + testRequest(post, expectedResponse); + } + + private void testPost(NameValues queryStringParams[], NameValues formParams[]) { + + StringBuilder expectedResponse = new StringBuilder(); + NameValuePair qsParams[] = convertNameValuesToNameValuePairs(queryStringParams, expectedResponse); + NameValuePair fParams[] = convertNameValuesToNameValuePairs(formParams, expectedResponse); + + PostMethod post = new PostMethod(COLLECTION_ROOT_URL + "/" + XQUERY_FILENAME); + + if(qsParams.length > 0) { + post.setQueryString(qsParams); + } + + if(fParams.length > 0) { + post.setRequestBody(fParams); + } + + testRequest(post, expectedResponse); + } + + private void testMultipartPost(Param multipartParams[]) { + + List parts = new ArrayList(); + + StringBuilder expectedResponse = new StringBuilder(); + + for(Param multipartParam : multipartParams) { + if(multipartParam instanceof NameValues) { + for(NameValuePair nameValuePair : convertNameValueToNameValuePairs((NameValues)multipartParam, expectedResponse)) { + parts.add(new StringPart(nameValuePair.getName(), nameValuePair.getValue())); + } + } else if(multipartParam instanceof TextFileUpload) { + parts.add(convertFileUploadToFilePart((TextFileUpload)multipartParam, expectedResponse)); + } + } + + PostMethod post = new PostMethod(COLLECTION_ROOT_URL + "/" + XQUERY_FILENAME); + post.setRequestEntity(new MultipartRequestEntity(parts.toArray(new Part[parts.size()]), post.getParams())); + + testRequest(post, expectedResponse); + } + + private void testMultipartPost(NameValues queryStringParams[], Param multipartParams[]) { + + List parts = new ArrayList(); + + StringBuilder expectedResponse = new StringBuilder(); + + NameValuePair qsParams[] = convertNameValuesToNameValuePairs(queryStringParams, expectedResponse); + + for(Param multipartParam : multipartParams) { + if(multipartParam instanceof NameValues) { + for(NameValuePair nameValuePair : convertNameValueToNameValuePairs((NameValues)multipartParam, expectedResponse)) { + parts.add(new StringPart(nameValuePair.getName(), nameValuePair.getValue())); + } + } else if(multipartParam instanceof TextFileUpload) { + parts.add(convertFileUploadToFilePart((TextFileUpload)multipartParam, expectedResponse)); + } + } + + PostMethod post = new PostMethod(COLLECTION_ROOT_URL + "/" + XQUERY_FILENAME); + + if(qsParams.length > 0) { + post.setQueryString(qsParams); + } + + post.setRequestEntity(new MultipartRequestEntity(parts.toArray(new Part[parts.size()]), post.getParams())); + + testRequest(post, expectedResponse); + } + + private void testRequest(HttpMethod method, StringBuilder expectedResponse) { + + try { + int httpResult = client.executeMethod(method); + + byte buf[] = new byte[1024]; + int read = -1; + StringBuilder responseBody = new StringBuilder(); + InputStream is = method.getResponseBodyAsStream(); + while((read = is.read(buf)) > -1) { + responseBody.append(new String(buf, 0, read)); + } + + assertEquals(HttpStatus.SC_OK, httpResult); + + assertEquals(expectedResponse.toString(), responseBody.toString()); + + } catch(HttpException he) { + fail(he.getMessage()); + } catch(IOException ioe) { + fail(ioe.getMessage()); + } finally { + method.releaseConnection(); + } + } + + private NameValuePair[] convertNameValuesToNameValuePairs(NameValues nameValues[], StringBuilder expectedResponse) { + + List nameValuePairs = new ArrayList(); + + if(nameValues != null) { + for(NameValues param : nameValues) { + nameValuePairs.addAll(convertNameValueToNameValuePairs(param, expectedResponse)); + } + } + + return nameValuePairs.toArray(new NameValuePair[nameValuePairs.size()]); + } + + private List convertNameValueToNameValuePairs(NameValues nameValues, StringBuilder expectedResponse) { + + List nameValuePairs = new ArrayList(); + + for(String paramValue : nameValues.getData()) { + nameValuePairs.add(new NameValuePair(nameValues.getName(), paramValue)); + + expectedResponse.append(nameValues.getName()); + expectedResponse.append("="); + expectedResponse.append(paramValue); + } + + return nameValuePairs; + } + + private FilePart convertFileUploadToFilePart(final TextFileUpload txtFileUpload, StringBuilder expectedResponse) { + + final String filePartName = "fileUpload"; + + FilePart filePart = new FilePart(filePartName, new PartSource() { + private byte data[] = txtFileUpload.getData().getBytes(); + + @Override + public long getLength() { + return data.length; + } + + @Override + public String getFileName() { + return txtFileUpload.getName(); + } + + @Override + public InputStream createInputStream() throws IOException { + return new ByteArrayInputStream(data); + } + }); + + expectedResponse.append(filePartName); + expectedResponse.append("="); + expectedResponse.append(txtFileUpload.getData()); + + return filePart; + } + + public class NameValues implements Param { + + final String name; + final String values[]; + + public NameValues(String name, String values[]) { + this.name = name; + this.values = values; + } + + @Override + public String getName() { + return name; + } + + public String[] getData() { + return values; + } + } + + public class TextFileUpload implements Param { + final String name; + final String content; + + public TextFileUpload(String name, String content) { + this.name = name; + this.content = content; + } + + @Override + public String getData() { + return content; + } + + @Override + public String getName() { + return name; + } + } + + public interface Param { + public String getName(); + public T getData(); + } +} diff --git a/test/src/org/exist/xquery/functions/util/Base64FunctionsTest.java b/test/src/org/exist/xquery/functions/util/Base64FunctionsTest.java index c0e66e14733..8b92d85ec57 100644 --- a/test/src/org/exist/xquery/functions/util/Base64FunctionsTest.java +++ b/test/src/org/exist/xquery/functions/util/Base64FunctionsTest.java @@ -1,140 +1,140 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2009 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $Id: BaseConverterTest.java 10599 2009-11-26 05:23:12Z shabanovd $ - */ -package org.exist.xquery.functions.util; - -import org.junit.After; - -import static org.junit.Assert.*; - -import org.junit.Before; -import org.junit.Test; - -import org.xmldb.api.DatabaseManager; -import org.xmldb.api.base.Collection; -import org.xmldb.api.base.Database; -import org.xmldb.api.base.ResourceSet; -import org.xmldb.api.base.XMLDBException; -import org.xmldb.api.modules.XPathQueryService; - -import org.exist.xmldb.DatabaseInstanceManager; -import org.exist.xmldb.XmldbURI; -import org.exist.xquery.XPathException; - - -/** - * DOCUMENT ME! - * - * @author Andrzej Taramina (andrzej@chaeron.com) - */ -public class Base64FunctionsTest -{ - private XPathQueryService service; - private Collection root = null; - private Database database = null; - - public Base64FunctionsTest() - { - } - - @Before public void setUp() throws Exception - { - // initialize driver - Class cl = Class.forName( "org.exist.xmldb.DatabaseImpl" ); - database = (Database)cl.newInstance(); - database.setProperty( "create-database", "true" ); - DatabaseManager.registerDatabase( database ); - root = DatabaseManager.getCollection( XmldbURI.LOCAL_DB, "admin", "" ); - service = (XPathQueryService)root.getService( "XQueryService", "1.0" ); - } - - - @After public void tearDown() throws Exception - { - DatabaseManager.deregisterDatabase( database ); - DatabaseInstanceManager dim = (DatabaseInstanceManager)root.getService( "DatabaseInstanceManager", "1.0" ); - dim.shutdown(); - - // clear instance variables - service = null; - root = null; - } - - - @Test public void testBase64Encode() throws XPathException - { - ResourceSet result = null; - String r = ""; - String query; - - try { - query = "util:base64-encode( 'This is a test!' )"; - result = service.query( query ); - r = (String)result.getResource( 0 ).getContent(); - assertEquals( "VGhpcyBpcyBhIHRlc3Qh", r ); - } - catch( XMLDBException e ) { - System.out.println( "testBase64Encode(): " + e ); - fail( e.getMessage() ); - } - - } - - @Test public void testBase64Decode() throws XPathException - { - ResourceSet result = null; - String r = ""; - String query; - - try { - query = "util:base64-decode( 'VGhpcyBpcyBhIHRlc3Qh' )"; - result = service.query( query ); - r = (String)result.getResource( 0 ).getContent(); - assertEquals( "This is a test!", r ); - } - catch( XMLDBException e ) { - System.out.println( "testBase64Decode(): " + e ); - fail( e.getMessage() ); - } - - } - - @Test public void testBase64EncodeDecode() throws XPathException - { - ResourceSet result = null; - String r = ""; - String query; - - try { - query = "util:base64-decode( util:base64-encode( 'This is a test!' ) )"; - result = service.query( query ); - r = (String)result.getResource( 0 ).getContent(); - assertEquals( "This is a test!", r ); - } - catch( XMLDBException e ) { - System.out.println( "testBase64EncodeDecode(): " + e ); - fail( e.getMessage() ); - } - - } - - -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2009 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $Id: BaseConverterTest.java 10599 2009-11-26 05:23:12Z shabanovd $ + */ +package org.exist.xquery.functions.util; + +import org.junit.After; + +import static org.junit.Assert.*; + +import org.junit.Before; +import org.junit.Test; + +import org.xmldb.api.DatabaseManager; +import org.xmldb.api.base.Collection; +import org.xmldb.api.base.Database; +import org.xmldb.api.base.ResourceSet; +import org.xmldb.api.base.XMLDBException; +import org.xmldb.api.modules.XPathQueryService; + +import org.exist.xmldb.DatabaseInstanceManager; +import org.exist.xmldb.XmldbURI; +import org.exist.xquery.XPathException; + + +/** + * DOCUMENT ME! + * + * @author Andrzej Taramina (andrzej@chaeron.com) + */ +public class Base64FunctionsTest +{ + private XPathQueryService service; + private Collection root = null; + private Database database = null; + + public Base64FunctionsTest() + { + } + + @Before public void setUp() throws Exception + { + // initialize driver + Class cl = Class.forName( "org.exist.xmldb.DatabaseImpl" ); + database = (Database)cl.newInstance(); + database.setProperty( "create-database", "true" ); + DatabaseManager.registerDatabase( database ); + root = DatabaseManager.getCollection( XmldbURI.LOCAL_DB, "admin", "" ); + service = (XPathQueryService)root.getService( "XQueryService", "1.0" ); + } + + + @After public void tearDown() throws Exception + { + DatabaseManager.deregisterDatabase( database ); + DatabaseInstanceManager dim = (DatabaseInstanceManager)root.getService( "DatabaseInstanceManager", "1.0" ); + dim.shutdown(); + + // clear instance variables + service = null; + root = null; + } + + + @Test public void testBase64Encode() throws XPathException + { + ResourceSet result = null; + String r = ""; + String query; + + try { + query = "util:base64-encode( 'This is a test!' )"; + result = service.query( query ); + r = (String)result.getResource( 0 ).getContent(); + assertEquals( "VGhpcyBpcyBhIHRlc3Qh", r ); + } + catch( XMLDBException e ) { + System.out.println( "testBase64Encode(): " + e ); + fail( e.getMessage() ); + } + + } + + @Test public void testBase64Decode() throws XPathException + { + ResourceSet result = null; + String r = ""; + String query; + + try { + query = "util:base64-decode( 'VGhpcyBpcyBhIHRlc3Qh' )"; + result = service.query( query ); + r = (String)result.getResource( 0 ).getContent(); + assertEquals( "This is a test!", r ); + } + catch( XMLDBException e ) { + System.out.println( "testBase64Decode(): " + e ); + fail( e.getMessage() ); + } + + } + + @Test public void testBase64EncodeDecode() throws XPathException + { + ResourceSet result = null; + String r = ""; + String query; + + try { + query = "util:base64-decode( util:base64-encode( 'This is a test!' ) )"; + result = service.query( query ); + r = (String)result.getResource( 0 ).getContent(); + assertEquals( "This is a test!", r ); + } + catch( XMLDBException e ) { + System.out.println( "testBase64EncodeDecode(): " + e ); + fail( e.getMessage() ); + } + + } + + +} diff --git a/test/src/org/exist/xquery/functions/util/ExpandTest.java b/test/src/org/exist/xquery/functions/util/ExpandTest.java index 7af8b85d91e..c296de1ed67 100644 --- a/test/src/org/exist/xquery/functions/util/ExpandTest.java +++ b/test/src/org/exist/xquery/functions/util/ExpandTest.java @@ -1,108 +1,108 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2012 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.xquery.functions.util; - -import static org.junit.Assert.*; - -import org.exist.xmldb.DatabaseInstanceManager; -import org.exist.xmldb.XQueryService; -import org.exist.xmldb.XmldbURI; -import org.exist.xquery.XPathException; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.xmldb.api.DatabaseManager; -import org.xmldb.api.base.Collection; -import org.xmldb.api.base.Database; -import org.xmldb.api.base.ResourceSet; -import org.xmldb.api.base.XMLDBException; - -/** - * @author Casey Jordan - * @author Dmitriy Shabanov - * - */ -public class ExpandTest { - - private XQueryService service; - private Collection root = null; - private Database database = null; - - @Before - public void setUp() throws Exception { - // initialize driver - Class cl = Class.forName("org.exist.xmldb.DatabaseImpl"); - database = (Database) cl.newInstance(); - database.setProperty("create-database", "true"); - DatabaseManager.registerDatabase(database); - root = DatabaseManager.getCollection(XmldbURI.LOCAL_DB, "admin", ""); - service = (XQueryService) root.getService("XQueryService", "1.0"); - } - - @After - public void tearDown() throws Exception { - - DatabaseManager.deregisterDatabase(database); - DatabaseInstanceManager dim = (DatabaseInstanceManager) root.getService("DatabaseInstanceManager", "1.0"); - dim.shutdown(); - - // clear instance variables - service = null; - root = null; - } - - @Test - public void testExpandWithDefaultNS() throws XPathException { - - String expected = "\n \n"; - - ResourceSet result = null; - String r = null; - try { - String query = "" + - "let $doc-path := xmldb:store('/db', 'test.xml', )\n" + - "let $doc := doc($doc-path)\n" + - "return\n" + - "\n" + - "{util:expand($doc)}\n" + - ""; - result = service.query(query); - r = (String) result.getResource(0).getContent(); - assertEquals(expected, r); - - query = "" + - "let $doc-path := xmldb:store('/db', 'test.xml', )\n" + - "let $doc := doc($doc-path)\n" + - "return\n" + - "\n" + - "{$doc}\n" + - ""; - result = service.query(query); - r = (String) result.getResource(0).getContent(); - assertEquals(expected, r); - - } catch (XMLDBException e) { - System.out.println("testEval(): " + e); - fail(e.getMessage()); - } - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2012 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.xquery.functions.util; + +import static org.junit.Assert.*; + +import org.exist.xmldb.DatabaseInstanceManager; +import org.exist.xmldb.XQueryService; +import org.exist.xmldb.XmldbURI; +import org.exist.xquery.XPathException; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.xmldb.api.DatabaseManager; +import org.xmldb.api.base.Collection; +import org.xmldb.api.base.Database; +import org.xmldb.api.base.ResourceSet; +import org.xmldb.api.base.XMLDBException; + +/** + * @author Casey Jordan + * @author Dmitriy Shabanov + * + */ +public class ExpandTest { + + private XQueryService service; + private Collection root = null; + private Database database = null; + + @Before + public void setUp() throws Exception { + // initialize driver + Class cl = Class.forName("org.exist.xmldb.DatabaseImpl"); + database = (Database) cl.newInstance(); + database.setProperty("create-database", "true"); + DatabaseManager.registerDatabase(database); + root = DatabaseManager.getCollection(XmldbURI.LOCAL_DB, "admin", ""); + service = (XQueryService) root.getService("XQueryService", "1.0"); + } + + @After + public void tearDown() throws Exception { + + DatabaseManager.deregisterDatabase(database); + DatabaseInstanceManager dim = (DatabaseInstanceManager) root.getService("DatabaseInstanceManager", "1.0"); + dim.shutdown(); + + // clear instance variables + service = null; + root = null; + } + + @Test + public void testExpandWithDefaultNS() throws XPathException { + + String expected = "\n \n"; + + ResourceSet result = null; + String r = null; + try { + String query = "" + + "let $doc-path := xmldb:store('/db', 'test.xml', )\n" + + "let $doc := doc($doc-path)\n" + + "return\n" + + "\n" + + "{util:expand($doc)}\n" + + ""; + result = service.query(query); + r = (String) result.getResource(0).getContent(); + assertEquals(expected, r); + + query = "" + + "let $doc-path := xmldb:store('/db', 'test.xml', )\n" + + "let $doc := doc($doc-path)\n" + + "return\n" + + "\n" + + "{$doc}\n" + + ""; + result = service.query(query); + r = (String) result.getResource(0).getContent(); + assertEquals(expected, r); + + } catch (XMLDBException e) { + System.out.println("testEval(): " + e); + fail(e.getMessage()); + } + } +} diff --git a/test/src/org/exist/xquery/value/AnyURITest.java b/test/src/org/exist/xquery/value/AnyURITest.java index cee43f74802..c9e55d637df 100644 --- a/test/src/org/exist/xquery/value/AnyURITest.java +++ b/test/src/org/exist/xquery/value/AnyURITest.java @@ -1,66 +1,66 @@ -package org.exist.xquery.value; - -import java.net.URI; - -import junit.framework.TestCase; - -import org.exist.test.TestConstants; -import org.exist.xquery.ValueIndexByQNameTest; - -/** - * - * @author cgeorg - */ -public class AnyURITest extends TestCase { - - public static void main(String[] args) { - junit.textui.TestRunner.run(ValueIndexByQNameTest.class); - } - - public void testFullyEscapedStringToXmldbURI() { - try { - String escaped = TestConstants.SPECIAL_NAME; - AnyURIValue anyUri = new AnyURIValue(escaped); - assertEquals(anyUri.toXmldbURI(),TestConstants.SPECIAL_URI); - } catch(Exception e) { - fail(e.toString()); - } - } - - public void testFullyEscapedStringToURI() { - try { - URI uri = TestConstants.SPECIAL_URI.getXmldbURI(); - String escaped = TestConstants.SPECIAL_NAME; - AnyURIValue anyUri = new AnyURIValue(escaped); - assertEquals(anyUri.toURI(),uri); - } catch(Exception e) { - fail(e.toString()); - } - } - - /** - * TODO: change AnyURIValue to directly store the escaped value? - */ - public void todoTestPartiallyEscapedStringToXmldbURI() { - try { - String escaped = TestConstants.SPECIAL_NAME.replaceAll("%20"," ").replaceAll("%C3%A0","\u00E0"); - AnyURIValue anyUri = new AnyURIValue(escaped); - assertEquals(anyUri.toXmldbURI(), TestConstants.SPECIAL_URI); - } catch(Exception e) { - e.printStackTrace(); - fail(e.toString()); - } - } - - public void testPartiallyEscapedStringToURI() { - try { - URI uri = TestConstants.SPECIAL_URI.getXmldbURI(); - String escaped = TestConstants.SPECIAL_NAME.replaceAll("%20"," ").replaceAll("%C3%A0","\u00E0"); - AnyURIValue anyUri = new AnyURIValue(escaped); - assertEquals(anyUri.toURI(),uri); - } catch(Exception e) { - fail(e.toString()); - } - } - -} +package org.exist.xquery.value; + +import java.net.URI; + +import junit.framework.TestCase; + +import org.exist.test.TestConstants; +import org.exist.xquery.ValueIndexByQNameTest; + +/** + * + * @author cgeorg + */ +public class AnyURITest extends TestCase { + + public static void main(String[] args) { + junit.textui.TestRunner.run(ValueIndexByQNameTest.class); + } + + public void testFullyEscapedStringToXmldbURI() { + try { + String escaped = TestConstants.SPECIAL_NAME; + AnyURIValue anyUri = new AnyURIValue(escaped); + assertEquals(anyUri.toXmldbURI(),TestConstants.SPECIAL_URI); + } catch(Exception e) { + fail(e.toString()); + } + } + + public void testFullyEscapedStringToURI() { + try { + URI uri = TestConstants.SPECIAL_URI.getXmldbURI(); + String escaped = TestConstants.SPECIAL_NAME; + AnyURIValue anyUri = new AnyURIValue(escaped); + assertEquals(anyUri.toURI(),uri); + } catch(Exception e) { + fail(e.toString()); + } + } + + /** + * TODO: change AnyURIValue to directly store the escaped value? + */ + public void todoTestPartiallyEscapedStringToXmldbURI() { + try { + String escaped = TestConstants.SPECIAL_NAME.replaceAll("%20"," ").replaceAll("%C3%A0","\u00E0"); + AnyURIValue anyUri = new AnyURIValue(escaped); + assertEquals(anyUri.toXmldbURI(), TestConstants.SPECIAL_URI); + } catch(Exception e) { + e.printStackTrace(); + fail(e.toString()); + } + } + + public void testPartiallyEscapedStringToURI() { + try { + URI uri = TestConstants.SPECIAL_URI.getXmldbURI(); + String escaped = TestConstants.SPECIAL_NAME.replaceAll("%20"," ").replaceAll("%C3%A0","\u00E0"); + AnyURIValue anyUri = new AnyURIValue(escaped); + assertEquals(anyUri.toURI(),uri); + } catch(Exception e) { + fail(e.toString()); + } + } + +} diff --git a/test/src/org/exist/xupdate/modifications/rename_including_namespace.xml b/test/src/org/exist/xupdate/modifications/rename_including_namespace.xml index 0310b67887d..69b6b20ceea 100644 --- a/test/src/org/exist/xupdate/modifications/rename_including_namespace.xml +++ b/test/src/org/exist/xupdate/modifications/rename_including_namespace.xml @@ -1,18 +1,18 @@ - - - - new:name - - - - - - new:name - - + + + + new:name + + + + + + new:name + + diff --git a/test/src/org/exist/xupdate/modifications/rename_root_element.xml b/test/src/org/exist/xupdate/modifications/rename_root_element.xml index 8ad47426311..34354483e07 100644 --- a/test/src/org/exist/xupdate/modifications/rename_root_element.xml +++ b/test/src/org/exist/xupdate/modifications/rename_root_element.xml @@ -1,12 +1,12 @@ - - - - contacts - - - - - - contacts - - + + + + contacts + + + + + + contacts + + diff --git a/test/src/xquery/matchHighlighting.xml b/test/src/xquery/matchHighlighting.xml index b1a3f53452c..ff98f803eca 100644 --- a/test/src/xquery/matchHighlighting.xml +++ b/test/src/xquery/matchHighlighting.xml @@ -1,189 +1,189 @@ - - tests for match highlighting behaviour on different index types - -

These tests test whether matches are highlighted correctly. Tests are grouped - per index type supporting match highlighting (old FT, lucene FT, ngram), and - repeated -

    -
  • for matches in both elements and attributes
  • -
  • for each setting of highlight-matches: none, attributes, elements, both
  • -
- Note: the kind of index definition (qname / path) doesn't seem to effect this - behaviour, so for clarity's sake, only qname-based indexes are included in these tests. -

- Ron Van den Branden -
- - - - - - - - - - - - - - - - - - - - - - onetwo tree - - - - - - - - - [lucene FT] element match, match-highlighting=none - - - onetwo tree - - - - [lucene FT] element match, match-highlighting=attributes - - - onetwo tree - - - - [lucene FT] element match, match-highlighting=elements - - - onetwo tree - - - - [lucene FT] element match, match-highlighting=both - - - onetwo tree - - - - [lucene FT] attribute match, match-highlighting=none - - - onetwo tree - - - - [lucene FT] attribute match, match-highlighting=attributes - - - onetwo tree - - - - [lucene FT] attribute match, match-highlighting=elements - - - onetwo tree - - - - [lucene FT] attribute match, match-highlighting=both - - - onetwo tree - - - - [ngram] element match, match-highlighting=none - - - onetwo tree - - - - [ngram] element match, match-highlighting=attributes - - - onetwo tree - - - - [ngram] element match, match-highlighting=elements - - - onetwo tree - - - - [ngram] element match, match-highlighting=both - - - onetwo tree - - - - [ngram] attribute match, match-highlighting=none - - - onetwo tree - - - - [ngram] attribute match, match-highlighting=attributes - - - onetwo tree - - - - [ngram] attribute match, match-highlighting=elements - - - onetwo tree - - - - [ngram] attribute match, match-highlighting=both - - - onetwo tree - - + + tests for match highlighting behaviour on different index types + +

These tests test whether matches are highlighted correctly. Tests are grouped + per index type supporting match highlighting (old FT, lucene FT, ngram), and + repeated +

    +
  • for matches in both elements and attributes
  • +
  • for each setting of highlight-matches: none, attributes, elements, both
  • +
+ Note: the kind of index definition (qname / path) doesn't seem to effect this + behaviour, so for clarity's sake, only qname-based indexes are included in these tests. +

+ Ron Van den Branden +
+ + + + + + + + + + + + + + + + + + + + + + onetwo tree + + + + + + + + + [lucene FT] element match, match-highlighting=none + + + onetwo tree + + + + [lucene FT] element match, match-highlighting=attributes + + + onetwo tree + + + + [lucene FT] element match, match-highlighting=elements + + + onetwo tree + + + + [lucene FT] element match, match-highlighting=both + + + onetwo tree + + + + [lucene FT] attribute match, match-highlighting=none + + + onetwo tree + + + + [lucene FT] attribute match, match-highlighting=attributes + + + onetwo tree + + + + [lucene FT] attribute match, match-highlighting=elements + + + onetwo tree + + + + [lucene FT] attribute match, match-highlighting=both + + + onetwo tree + + + + [ngram] element match, match-highlighting=none + + + onetwo tree + + + + [ngram] element match, match-highlighting=attributes + + + onetwo tree + + + + [ngram] element match, match-highlighting=elements + + + onetwo tree + + + + [ngram] element match, match-highlighting=both + + + onetwo tree + + + + [ngram] attribute match, match-highlighting=none + + + onetwo tree + + + + [ngram] attribute match, match-highlighting=attributes + + + onetwo tree + + + + [ngram] attribute match, match-highlighting=elements + + + onetwo tree + + + + [ngram] attribute match, match-highlighting=both + + + onetwo tree + +
\ No newline at end of file diff --git a/test/src/xquery/namespaces.xml b/test/src/xquery/namespaces.xml index 4016b47e768..dac0ee149d2 100644 --- a/test/src/xquery/namespaces.xml +++ b/test/src/xquery/namespaces.xml @@ -1,64 +1,64 @@ - - tests for namespaces - -

tests for namespace inheritance

- Ron Van den Branden -
- - in-scope namespace should not be inherited across function boundary #1 - somemap -}; - -
-{ local:build-node() } -
- ]]>
- -
- somemap -
-
-
- - in-scope namespace should not be inherited across function boundary #2 - somemap -}; - -
-{ - let $result := local:build-node() return - $result -} -
- ]]>
- -
- somemap -
-
-
- - in-scope namespace should not be inherited across function boundary #3 - somemap -}; - -let $result := local:build-node() return - -
-{ $result } -
- ]]>
- -
- somemap -
-
-
- + + tests for namespaces + +

tests for namespace inheritance

+ Ron Van den Branden +
+ + in-scope namespace should not be inherited across function boundary #1 + somemap +}; + +
+{ local:build-node() } +
+ ]]>
+ +
+ somemap +
+
+
+ + in-scope namespace should not be inherited across function boundary #2 + somemap +}; + +
+{ + let $result := local:build-node() return + $result +} +
+ ]]>
+ +
+ somemap +
+
+
+ + in-scope namespace should not be inherited across function boundary #3 + somemap +}; + +let $result := local:build-node() return + +
+{ $result } +
+ ]]>
+ +
+ somemap +
+
+
+
\ No newline at end of file diff --git a/test/src/xquery/parenthesizedContext.xml b/test/src/xquery/parenthesizedContext.xml index 2fd4935cacb..8b8a41571f7 100644 --- a/test/src/xquery/parenthesizedContext.xml +++ b/test/src/xquery/parenthesizedContext.xml @@ -1,545 +1,545 @@ - - tests for queries on entirely parenthesized contexts - -

Tests for behaviour of retrieval, query and index functions on different index types, on entirely parenthesised contexts. - Three major sections: -

    -
  • [retrieval]: bare retrieval of parenthesized nodes (tests #1-#6)
  • -
  • [query]: queries on different index types (tests #7-#54)
  • -
  • [index]: lookup of index terms on different index types (tests #55-#78)
  • -

-

The degree of the problems depends on the type of index and search context. Influencing factors are: -

    -
  • index definition: qname / path-based
  • -
  • type of query: expressed directly (XPath expression) / indirectly (FLWR expression)
  • -
  • context node: parenthesized context node / parenthesized location step + self axis location step
  • -
  • type of node: element / attribute
  • -
  • location step: parenthesized attribute node in child step / parenthesized attribute node in descendant step (attributes only)
  • -
-

- Ron Van den Branden -
- - - - - - - - - - - - - - - - - - - - - - - - - - this is a test document - this is a test document - - - - {$term} - }; - ]]> - - - - - - [retrieval, qname] fully parenthesized element node - - - this is a test document - - - - [retrieval, path] fully parenthesized element node - - - this is a test document - - - - [retrieval, qname] child step with fully parenthesized attribute node - - test - - - [retrieval, qname] descendant step with fully parenthesized attribute node - - test - - - [retrieval, path] child step with fully parenthesized attribute node - - test - - - [retrieval, path] descendant step with fully parenthesized attribute node - - test - - - [query, Lucene FT index, qname, direct] fully parenthesized element node - - - this is a test document - - - - [query, Lucene FT index, qname, indirect] fully parenthesized element node - - - this is a test document - - - - [query, Lucene FT index, path, direct] fully parenthesized element node - - - this is a test document - - - - [query, Lucene FT index, path, indirect] fully parenthesized element node - - - this is a test document - - - - [query, Lucene FT index, qname, direct] fully parenthesized element node + self axis - - - this is a test document - - - - [query, Lucene FT index, qname, indirect] fully parenthesized element node + self axis - - - this is a test document - - - - [query, Lucene FT index, path, direct] fully parenthesized element node + self axis - - - this is a test document - - - - [query, Lucene FT index, path, indirect] fully parenthesized element node + self axis - - - this is a test document - - - - [query, Lucene FT index, qname, direct] child step with fully parenthesized attribute node - - test - - - [query, Lucene FT index, qname, indirect] child step with fully parenthesized attribute node - - test - - - [query, Lucene FT index, qname, direct] descendant step with fully parenthesized attribute node - - test - - - [query, Lucene FT index, qname, indirect] descendant step with fully parenthesized attribute node - - test - - - [query, Lucene FT index, path, direct] child step with fully parenthesized attribute node - - test - - - [query, Lucene FT index, path, indirect] child step with fully parenthesized attribute node - - test - - - [query, Lucene FT index, path, direct] descendant step with fully parenthesized attribute node - - test - - - [query, Lucene FT index, path, indirect] descendant step with fully parenthesized attribute node - - test - - - - [query, range index, qname, direct] fully parenthesized element node - - - this is a test document - - - - [query, range index, qname, indirect] fully parenthesized element node - - - this is a test document - - - - [query, range index, path, direct] fully parenthesized element node - - - this is a test document - - - - [query, range index, path, indirect] fully parenthesized element node - - - this is a test document - - - - [query, range index, qname, direct] fully parenthesized element node + self axis - - - this is a test document - - - - [query, range index, qname, indirect] fully parenthesized element node + self axis - - - this is a test document - - - - [query, range index, path, direct] fully parenthesized element node + self axis - - - this is a test document - - - - [query, range index, path, indirect] fully parenthesized element node + self axis - - - this is a test document - - - - [query, range index, qname, direct] child step with fully parenthesized attribute node - - test - - - [query, range index, qname, indirect] child step with fully parenthesized attribute node - - test - - - [query, range index, qname, direct] descendant step with fully parenthesized attribute node - - test - - - [query, range index, qname, indirect] descendant step with fully parenthesized attribute node - - test - - - [query, range index, path, direct] child step with fully parenthesized attribute node - - test - - - [query, range index, path, indirect] child step with fully parenthesized attribute node - - test - - - [query, range index, path, direct] descendant step with fully parenthesized attribute node - - test - - - [query, range index, path, indirect] descendant step with fully parenthesized attribute node - - test - - - - [index, Lucene FT index, qname] fully parenthesized element node - - - document - test - - - - [index, Lucene FT index, path] fully parenthesized element node - - - document - test - - - - [index, Lucene FT index, qname] fully parenthesized element node + self axis - - - document - test - - - - [index, Lucene FT index, path] fully parenthesized element node + self axis - - - document - test - - - - [index, Lucene FT index, qname] child step with fully parenthesized attribute node - - - test - - - - [index, Lucene FT index, qname] descendant step with fully parenthesized attribute node - - - test - - - - [index, Lucene FT index, path] child step with fully parenthesized attribute node - - - test - - - - [index, Lucene FT index, path] descendant step with fully parenthesized attribute node - - - test - - - - [index, range index, qname] fully parenthesized element node - - - this is a test document - - - - [index, range index, path] fully parenthesized element node - - - this is a test document - - - - [index, range index, qname] fully parenthesized element node + self axis - - - this is a test document - - - - [index, range index, path] fully parenthesized element node + self axis - - - this is a test document - - - - [index, range index, qname] child step with fully parenthesized attribute node - - - test - - - - [index, range index, qname] descendant step with fully parenthesized attribute node - - - test - - - - [index, range index, path] child step with fully parenthesized attribute node - - - test - - - - [index, range index, path] descendant step with fully parenthesized attribute node - - - test - - -
+ + tests for queries on entirely parenthesized contexts + +

Tests for behaviour of retrieval, query and index functions on different index types, on entirely parenthesised contexts. + Three major sections: +

    +
  • [retrieval]: bare retrieval of parenthesized nodes (tests #1-#6)
  • +
  • [query]: queries on different index types (tests #7-#54)
  • +
  • [index]: lookup of index terms on different index types (tests #55-#78)
  • +

+

The degree of the problems depends on the type of index and search context. Influencing factors are: +

    +
  • index definition: qname / path-based
  • +
  • type of query: expressed directly (XPath expression) / indirectly (FLWR expression)
  • +
  • context node: parenthesized context node / parenthesized location step + self axis location step
  • +
  • type of node: element / attribute
  • +
  • location step: parenthesized attribute node in child step / parenthesized attribute node in descendant step (attributes only)
  • +
+

+ Ron Van den Branden +
+ + + + + + + + + + + + + + + + + + + + + + + + + + this is a test document + this is a test document + + + + {$term} + }; + ]]> + + + + + + [retrieval, qname] fully parenthesized element node + + + this is a test document + + + + [retrieval, path] fully parenthesized element node + + + this is a test document + + + + [retrieval, qname] child step with fully parenthesized attribute node + + test + + + [retrieval, qname] descendant step with fully parenthesized attribute node + + test + + + [retrieval, path] child step with fully parenthesized attribute node + + test + + + [retrieval, path] descendant step with fully parenthesized attribute node + + test + + + [query, Lucene FT index, qname, direct] fully parenthesized element node + + + this is a test document + + + + [query, Lucene FT index, qname, indirect] fully parenthesized element node + + + this is a test document + + + + [query, Lucene FT index, path, direct] fully parenthesized element node + + + this is a test document + + + + [query, Lucene FT index, path, indirect] fully parenthesized element node + + + this is a test document + + + + [query, Lucene FT index, qname, direct] fully parenthesized element node + self axis + + + this is a test document + + + + [query, Lucene FT index, qname, indirect] fully parenthesized element node + self axis + + + this is a test document + + + + [query, Lucene FT index, path, direct] fully parenthesized element node + self axis + + + this is a test document + + + + [query, Lucene FT index, path, indirect] fully parenthesized element node + self axis + + + this is a test document + + + + [query, Lucene FT index, qname, direct] child step with fully parenthesized attribute node + + test + + + [query, Lucene FT index, qname, indirect] child step with fully parenthesized attribute node + + test + + + [query, Lucene FT index, qname, direct] descendant step with fully parenthesized attribute node + + test + + + [query, Lucene FT index, qname, indirect] descendant step with fully parenthesized attribute node + + test + + + [query, Lucene FT index, path, direct] child step with fully parenthesized attribute node + + test + + + [query, Lucene FT index, path, indirect] child step with fully parenthesized attribute node + + test + + + [query, Lucene FT index, path, direct] descendant step with fully parenthesized attribute node + + test + + + [query, Lucene FT index, path, indirect] descendant step with fully parenthesized attribute node + + test + + + + [query, range index, qname, direct] fully parenthesized element node + + + this is a test document + + + + [query, range index, qname, indirect] fully parenthesized element node + + + this is a test document + + + + [query, range index, path, direct] fully parenthesized element node + + + this is a test document + + + + [query, range index, path, indirect] fully parenthesized element node + + + this is a test document + + + + [query, range index, qname, direct] fully parenthesized element node + self axis + + + this is a test document + + + + [query, range index, qname, indirect] fully parenthesized element node + self axis + + + this is a test document + + + + [query, range index, path, direct] fully parenthesized element node + self axis + + + this is a test document + + + + [query, range index, path, indirect] fully parenthesized element node + self axis + + + this is a test document + + + + [query, range index, qname, direct] child step with fully parenthesized attribute node + + test + + + [query, range index, qname, indirect] child step with fully parenthesized attribute node + + test + + + [query, range index, qname, direct] descendant step with fully parenthesized attribute node + + test + + + [query, range index, qname, indirect] descendant step with fully parenthesized attribute node + + test + + + [query, range index, path, direct] child step with fully parenthesized attribute node + + test + + + [query, range index, path, indirect] child step with fully parenthesized attribute node + + test + + + [query, range index, path, direct] descendant step with fully parenthesized attribute node + + test + + + [query, range index, path, indirect] descendant step with fully parenthesized attribute node + + test + + + + [index, Lucene FT index, qname] fully parenthesized element node + + + document + test + + + + [index, Lucene FT index, path] fully parenthesized element node + + + document + test + + + + [index, Lucene FT index, qname] fully parenthesized element node + self axis + + + document + test + + + + [index, Lucene FT index, path] fully parenthesized element node + self axis + + + document + test + + + + [index, Lucene FT index, qname] child step with fully parenthesized attribute node + + + test + + + + [index, Lucene FT index, qname] descendant step with fully parenthesized attribute node + + + test + + + + [index, Lucene FT index, path] child step with fully parenthesized attribute node + + + test + + + + [index, Lucene FT index, path] descendant step with fully parenthesized attribute node + + + test + + + + [index, range index, qname] fully parenthesized element node + + + this is a test document + + + + [index, range index, path] fully parenthesized element node + + + this is a test document + + + + [index, range index, qname] fully parenthesized element node + self axis + + + this is a test document + + + + [index, range index, path] fully parenthesized element node + self axis + + + this is a test document + + + + [index, range index, qname] child step with fully parenthesized attribute node + + + test + + + + [index, range index, qname] descendant step with fully parenthesized attribute node + + + test + + + + [index, range index, path] child step with fully parenthesized attribute node + + + test + + + + [index, range index, path] descendant step with fully parenthesized attribute node + + + test + + +
diff --git a/test/src/xquery/parenthesizedLocationStep.xml b/test/src/xquery/parenthesizedLocationStep.xml index 559e7922fe2..5563b0638e8 100644 --- a/test/src/xquery/parenthesizedLocationStep.xml +++ b/test/src/xquery/parenthesizedLocationStep.xml @@ -1,555 +1,555 @@ - - tests for queries on context nodes in a parenthesized location step - -

Tests for behaviour of retrieval, query and index functions on different index types, on context nodes in a parenthesized location step. - Three major sections: -

    -
  • [retrieval]: bare retrieval of parenthesized nodes (tests #1-#6)
  • -
  • [query]: queries on different index types (tests #7-#54)
  • -
  • [index]: lookup of index terms on different index types (tests #55-#78)
  • -

-

The degree of the problems depends on the type of index and search context. Influencing factors are: -

    -
  • index definition: qname / path-based
  • -
  • type of query: expressed directly (XPath expression) / indirectly (FLWR expression)
  • -
  • context node: parenthesized context node / parenthesized location step + self axis location step
  • -
  • type of node: element / attribute
  • -
  • location step: parenthesized attribute node in child step / parenthesized attribute node in descendant step (attributes only)
  • -
-

- Ron Van den Branden -
- - - - - - - - - - - - - - - - - - - - - - - - - - this is a test document - this is a test document - - - - {$term} - }; - ]]> - - - - - - [retrieval, qname] parenthesized element node - - - this is a test document - - - - [retrieval, path] parenthesized element node - - - this is a test document - - - - [retrieval, qname] child step with parenthesized attribute node - - test - - - [retrieval, qname] descendant step with parenthesized attribute node - - test - - - [retrieval, path] child step with parenthesized attribute node - - test - - - [retrieval, path] descendant step with parenthesized attribute node - - test - - - [query, old FT index, qname, indirect] parenthesized element node - - - this is a test document - - - - [query, Lucene FT index, qname, direct] parenthesized element node - - - this is a test document - - - - [query, Lucene FT index, qname, indirect] parenthesized element node - - - this is a test document - - - - [query, Lucene FT index, path, direct] parenthesized element node - - - this is a test document - - - - [query, Lucene FT index, path, indirect] parenthesized element node - - - this is a test document - - - - [query, Lucene FT index, qname, direct] parenthesized element node + self axis - - - this is a test document - - - - [query, Lucene FT index, qname, indirect] parenthesized element node + self axis - - - this is a test document - - - - [query, Lucene FT index, path, direct] parenthesized element node + self axis - - - this is a test document - - - - [query, Lucene FT index, path, indirect] parenthesized element node + self axis - - - this is a test document - - - - [query, Lucene FT index, qname, direct] child step with parenthesized attribute node - - test - - - [query, Lucene FT index, qname, indirect] child step with parenthesized attribute node - - test - - - [query, Lucene FT index, qname, direct] descendant step with parenthesized attribute node - - test - - - [query, Lucene FT index, qname, indirect] descendant step with parenthesized attribute node - - test - - - [query, Lucene FT index, path, direct] child step with parenthesized attribute node - - test - - - [query, Lucene FT index, path, indirect] child step with parenthesized attribute node - - test - - - [query, Lucene FT index, path, direct] descendant step with parenthesized attribute node - - test - - - [query, Lucene FT index, path, indirect] descendant step with parenthesized attribute node - - test - - - - [query, range index, qname, direct] parenthesized element node - - - this is a test document - - - - [query, range index, qname, indirect] parenthesized element node - - - this is a test document - - - - [query, range index, path, direct] parenthesized element node - - - this is a test document - - - - [query, range index, path, indirect] parenthesized element node - - - this is a test document - - - - [query, range index, qname, direct] parenthesized element node + self axis - - - this is a test document - - - - [query, range index, qname, indirect] parenthesized element node + self axis - - - this is a test document - - - - [query, range index, path, direct] parenthesized element node + self axis - - - this is a test document - - - - [query, range index, path, indirect] parenthesized element node + self axis - - - this is a test document - - - - [query, range index, qname, direct] child step with parenthesized attribute node - - test - - - [query, range index, qname, indirect] child step with parenthesized attribute node - - test - - - [query, range index, qname, direct] descendant step with parenthesized attribute node - - test - - - [query, range index, qname, indirect] descendant step with parenthesized attribute node - - test - - - [query, range index, path, direct] child step with parenthesized attribute node - - test - - - [query, range index, path, indirect] child step with parenthesized attribute node - - test - - - [query, range index, path, direct] descendant step with parenthesized attribute node - - test - - - [query, range index, path, indirect] descendant step with parenthesized attribute node - - test - - - - [index, Lucene FT index, qname] parenthesized element node - - - document - test - - - - [index, Lucene FT index, path] parenthesized element node - - - document - test - - - - [index, Lucene FT index, qname] parenthesized element node + self axis - - - document - test - - - - [index, Lucene FT index, path] parenthesized element node + self axis - - - document - test - - - - [index, Lucene FT index, qname] child step with parenthesized attribute node - - - test - - - - [index, Lucene FT index, qname] descendant step with parenthesized attribute node - - - test - - - - [index, Lucene FT index, path] child step with parenthesized attribute node - - - test - - - - [index, Lucene FT index, path] descendant step with parenthesized attribute node - - - test - - - - [index, range index, qname] parenthesized element node - - - this is a test document - - - - [index, range index, path] parenthesized element node - - - this is a test document - - - - [index, range index, qname] parenthesized element node + self axis - - - this is a test document - - - - [index, range index, path] parenthesized element node + self axis - - - this is a test document - - - - [index, range index, qname] child step with parenthesized attribute node - - - test - - - - [index, range index, qname] descendant step with parenthesized attribute node - - - test - - - - [index, range index, path] child step with parenthesized attribute node - - - test - - - - [index, range index, path] descendant step with parenthesized attribute node - - - test - - -
+ + tests for queries on context nodes in a parenthesized location step + +

Tests for behaviour of retrieval, query and index functions on different index types, on context nodes in a parenthesized location step. + Three major sections: +

    +
  • [retrieval]: bare retrieval of parenthesized nodes (tests #1-#6)
  • +
  • [query]: queries on different index types (tests #7-#54)
  • +
  • [index]: lookup of index terms on different index types (tests #55-#78)
  • +

+

The degree of the problems depends on the type of index and search context. Influencing factors are: +

    +
  • index definition: qname / path-based
  • +
  • type of query: expressed directly (XPath expression) / indirectly (FLWR expression)
  • +
  • context node: parenthesized context node / parenthesized location step + self axis location step
  • +
  • type of node: element / attribute
  • +
  • location step: parenthesized attribute node in child step / parenthesized attribute node in descendant step (attributes only)
  • +
+

+ Ron Van den Branden +
+ + + + + + + + + + + + + + + + + + + + + + + + + + this is a test document + this is a test document + + + + {$term} + }; + ]]> + + + + + + [retrieval, qname] parenthesized element node + + + this is a test document + + + + [retrieval, path] parenthesized element node + + + this is a test document + + + + [retrieval, qname] child step with parenthesized attribute node + + test + + + [retrieval, qname] descendant step with parenthesized attribute node + + test + + + [retrieval, path] child step with parenthesized attribute node + + test + + + [retrieval, path] descendant step with parenthesized attribute node + + test + + + [query, old FT index, qname, indirect] parenthesized element node + + + this is a test document + + + + [query, Lucene FT index, qname, direct] parenthesized element node + + + this is a test document + + + + [query, Lucene FT index, qname, indirect] parenthesized element node + + + this is a test document + + + + [query, Lucene FT index, path, direct] parenthesized element node + + + this is a test document + + + + [query, Lucene FT index, path, indirect] parenthesized element node + + + this is a test document + + + + [query, Lucene FT index, qname, direct] parenthesized element node + self axis + + + this is a test document + + + + [query, Lucene FT index, qname, indirect] parenthesized element node + self axis + + + this is a test document + + + + [query, Lucene FT index, path, direct] parenthesized element node + self axis + + + this is a test document + + + + [query, Lucene FT index, path, indirect] parenthesized element node + self axis + + + this is a test document + + + + [query, Lucene FT index, qname, direct] child step with parenthesized attribute node + + test + + + [query, Lucene FT index, qname, indirect] child step with parenthesized attribute node + + test + + + [query, Lucene FT index, qname, direct] descendant step with parenthesized attribute node + + test + + + [query, Lucene FT index, qname, indirect] descendant step with parenthesized attribute node + + test + + + [query, Lucene FT index, path, direct] child step with parenthesized attribute node + + test + + + [query, Lucene FT index, path, indirect] child step with parenthesized attribute node + + test + + + [query, Lucene FT index, path, direct] descendant step with parenthesized attribute node + + test + + + [query, Lucene FT index, path, indirect] descendant step with parenthesized attribute node + + test + + + + [query, range index, qname, direct] parenthesized element node + + + this is a test document + + + + [query, range index, qname, indirect] parenthesized element node + + + this is a test document + + + + [query, range index, path, direct] parenthesized element node + + + this is a test document + + + + [query, range index, path, indirect] parenthesized element node + + + this is a test document + + + + [query, range index, qname, direct] parenthesized element node + self axis + + + this is a test document + + + + [query, range index, qname, indirect] parenthesized element node + self axis + + + this is a test document + + + + [query, range index, path, direct] parenthesized element node + self axis + + + this is a test document + + + + [query, range index, path, indirect] parenthesized element node + self axis + + + this is a test document + + + + [query, range index, qname, direct] child step with parenthesized attribute node + + test + + + [query, range index, qname, indirect] child step with parenthesized attribute node + + test + + + [query, range index, qname, direct] descendant step with parenthesized attribute node + + test + + + [query, range index, qname, indirect] descendant step with parenthesized attribute node + + test + + + [query, range index, path, direct] child step with parenthesized attribute node + + test + + + [query, range index, path, indirect] child step with parenthesized attribute node + + test + + + [query, range index, path, direct] descendant step with parenthesized attribute node + + test + + + [query, range index, path, indirect] descendant step with parenthesized attribute node + + test + + + + [index, Lucene FT index, qname] parenthesized element node + + + document + test + + + + [index, Lucene FT index, path] parenthesized element node + + + document + test + + + + [index, Lucene FT index, qname] parenthesized element node + self axis + + + document + test + + + + [index, Lucene FT index, path] parenthesized element node + self axis + + + document + test + + + + [index, Lucene FT index, qname] child step with parenthesized attribute node + + + test + + + + [index, Lucene FT index, qname] descendant step with parenthesized attribute node + + + test + + + + [index, Lucene FT index, path] child step with parenthesized attribute node + + + test + + + + [index, Lucene FT index, path] descendant step with parenthesized attribute node + + + test + + + + [index, range index, qname] parenthesized element node + + + this is a test document + + + + [index, range index, path] parenthesized element node + + + this is a test document + + + + [index, range index, qname] parenthesized element node + self axis + + + this is a test document + + + + [index, range index, path] parenthesized element node + self axis + + + this is a test document + + + + [index, range index, qname] child step with parenthesized attribute node + + + test + + + + [index, range index, qname] descendant step with parenthesized attribute node + + + test + + + + [index, range index, path] child step with parenthesized attribute node + + + test + + + + [index, range index, path] descendant step with parenthesized attribute node + + + test + + +
diff --git a/test/src/xquery/parenthesizedLocationStep_ftquery_Tests.xml b/test/src/xquery/parenthesizedLocationStep_ftquery_Tests.xml index dc5bb75bc7a..320eacccbf2 100644 --- a/test/src/xquery/parenthesizedLocationStep_ftquery_Tests.xml +++ b/test/src/xquery/parenthesizedLocationStep_ftquery_Tests.xml @@ -1,180 +1,180 @@ - - tests for queries on context nodes in a parenthesized location step - -

Tests for behaviour of ft:query() function on context nodes in a parenthesized location step. - Two major sections: -

    -
  • [element]: ft:query() on parenthesized context node selecting an element (tests #1-#4)
  • -
  • [attribute]: ft:query() on parenthesized context node selecting an attribute (tests #5-#8)
  • -
  • [attribute retrieval]: retrieval of parenthesized context node selecting an attribute (tests #9-#12)
  • -

-

The degree of the problems depends on the context node type: -

    -
  • elements: queries fail when parenthesized context node is not immediately preceded by a non-parenthesized location step (unless immediately preceding location step selects self::* axis)
  • -
  • attributes: queries always fail with parenthesized context nodes, though the problem seems to lie at retrieval level (see tests #9-#12)
  • -
-

-

Note: additional tests #-11-#12 illustrate some kind of erroneous 'bleed-through' behaviour: when a parenthesized context node selects a non-existent attribute whose name corresponds to an element name, ft:query will produce (incorrect) results (failing test #9). This behaviour does not occur when context node is not parenthesized (succeeding test #10).

- Ron Van den Branden -
- - - - - - - - - - - - - - - - - - - - - - -

this is text with test strings in test elements

-
-
- - -

this is text with test strings in test elements

-
-
-
-
-
- - - - - - - [element] parenthesized final location step, non-parenthesized preceding step - - - test - test - - - - [element] parenthesized final location step, no preceding step - - - test - test - - - - [element] parenthesized final location step, parenthesized preceding step - - - test - test - - - - [element] parenthesized final location step, non-parenthesized preceding step with self selector - - - test - test - - - - [attribute] parenthesized final location step, non-parenthesized preceding step - {$a} - ]]> - - - - - - - [attribute] parenthesized final location step, no preceding step - {$a} - ]]> - - - - - - - [attribute] parenthesized final location step, parenthesized preceding step - {$a} - ]]> - - - - - - - [attribute] parenthesized final location step, non-parenthesized preceding step with self selector - {$a} - ]]> - - - - - - - [attribute retrieval] parenthesized final location step - {$a} - ]]> - - - - - - - [attribute retrieval] non-parenthesized final location step - {$a} - ]]> - - - - - - - [attribute retrieval] parenthesized attribute context node causes 'bleed-through' when name equals element name - {$a} - ]]> - - - - [attribute retrieval] non-parenthesized attribute context behaves correctly - {$a} - ]]> - - + + tests for queries on context nodes in a parenthesized location step + +

Tests for behaviour of ft:query() function on context nodes in a parenthesized location step. + Two major sections: +

    +
  • [element]: ft:query() on parenthesized context node selecting an element (tests #1-#4)
  • +
  • [attribute]: ft:query() on parenthesized context node selecting an attribute (tests #5-#8)
  • +
  • [attribute retrieval]: retrieval of parenthesized context node selecting an attribute (tests #9-#12)
  • +

+

The degree of the problems depends on the context node type: +

    +
  • elements: queries fail when parenthesized context node is not immediately preceded by a non-parenthesized location step (unless immediately preceding location step selects self::* axis)
  • +
  • attributes: queries always fail with parenthesized context nodes, though the problem seems to lie at retrieval level (see tests #9-#12)
  • +
+

+

Note: additional tests #-11-#12 illustrate some kind of erroneous 'bleed-through' behaviour: when a parenthesized context node selects a non-existent attribute whose name corresponds to an element name, ft:query will produce (incorrect) results (failing test #9). This behaviour does not occur when context node is not parenthesized (succeeding test #10).

+ Ron Van den Branden +
+ + + + + + + + + + + + + + + + + + + + + + +

this is text with test strings in test elements

+
+
+ + +

this is text with test strings in test elements

+
+
+
+
+
+ + + + + + + [element] parenthesized final location step, non-parenthesized preceding step + + + test + test + + + + [element] parenthesized final location step, no preceding step + + + test + test + + + + [element] parenthesized final location step, parenthesized preceding step + + + test + test + + + + [element] parenthesized final location step, non-parenthesized preceding step with self selector + + + test + test + + + + [attribute] parenthesized final location step, non-parenthesized preceding step + {$a} + ]]> + + + + + + + [attribute] parenthesized final location step, no preceding step + {$a} + ]]> + + + + + + + [attribute] parenthesized final location step, parenthesized preceding step + {$a} + ]]> + + + + + + + [attribute] parenthesized final location step, non-parenthesized preceding step with self selector + {$a} + ]]> + + + + + + + [attribute retrieval] parenthesized final location step + {$a} + ]]> + + + + + + + [attribute retrieval] non-parenthesized final location step + {$a} + ]]> + + + + + + + [attribute retrieval] parenthesized attribute context node causes 'bleed-through' when name equals element name + {$a} + ]]> + + + + [attribute retrieval] non-parenthesized attribute context behaves correctly + {$a} + ]]> + +
\ No newline at end of file diff --git a/test/src/xquery/pathExpression_operators.xml b/test/src/xquery/pathExpression_operators.xml index a4a6632d0df..a64349211a1 100644 --- a/test/src/xquery/pathExpression_operators.xml +++ b/test/src/xquery/pathExpression_operators.xml @@ -1,37 +1,37 @@ - - tests for behaviour of operators in path expressions - -

tests for behaviour of operators when used in path expressions: -

    -
  • | (union operator) mustn't shift current node to children of context node
  • -
  • , (comma operator) must remove duplicates (due to '/' operator in path expression)
  • -
-

- Ron Van den Branden -
- - - - this is text with an embedded element - - - - - - - union operator: should select context node (not its child nodes) - - this is text with an embedded element - - - comma operator: should remove duplicates (due to '/' operator) - - this is text with an embedded element - + + tests for behaviour of operators in path expressions + +

tests for behaviour of operators when used in path expressions: +

    +
  • | (union operator) mustn't shift current node to children of context node
  • +
  • , (comma operator) must remove duplicates (due to '/' operator in path expression)
  • +
+

+ Ron Van den Branden +
+ + + + this is text with an embedded element + + + + + + + union operator: should select context node (not its child nodes) + + this is text with an embedded element + + + comma operator: should remove duplicates (due to '/' operator) + + this is text with an embedded element +
\ No newline at end of file diff --git a/test/src/xquery/selfAxis.xml b/test/src/xquery/selfAxis.xml index e141ddc981d..6714093488d 100644 --- a/test/src/xquery/selfAxis.xml +++ b/test/src/xquery/selfAxis.xml @@ -1,182 +1,182 @@ - - tests for self axis - -

tests for selection of nodes with self axis, both -

    -
  • abbreviated (.) and full (self::)
  • -
  • in location step and predicate
  • -
  • in 'bare' and parenthesized contexts
  • -
-

- Ron Van den Branden -
- - - - test - - - - - - - [bare context] self axis in location step, abbreviated - - - test - - - - [bare context] self axis in location step, full - - - test - - - - [bare context] self axis in location step, full with name test - - - test - - - - [bare context] self axis in predicate, abbreviated - - - test - - - - [bare context] self axis in predicate, full - - - test - - - - [bare context] self axis in predicate, full with name test - - - test - - - - - [parenthesized context] self axis in location step, abbreviated - - - test - - - - [parenthesized context] self axis in location step, full - - - test - - - - [parenthesized context] self axis in location step, full with name test - - - test - - - - [parenthesized context] self axis in predicate, abbreviated - - - test - - - - [parenthesized context] self axis in predicate, full - - - test - - - - [parenthesized context] self axis in predicate, full with name test - - - test - - - - [filter context] use self within filter step - - let $values := 1 to 10 - return $values[. = 5] - - 5 - - - [filter context] use self in function call within filter step - - let $values := (3,4,6,6 ,2,7, 3,1,2) - return $values[index-of($values, .)[2]] - - 6 3 2 - - - Self axis step used inside enclosed expression - - One - - return - $data/elem/{.,1} - ]]> - - - One - 1 - - - - - Context item should not be touched by nested let clause - title - return - $xml/title/ - { - let $title := ./text() - return - let $text := text() - return - $text - } - ]]> - - title - - + + tests for self axis + +

tests for selection of nodes with self axis, both +

    +
  • abbreviated (.) and full (self::)
  • +
  • in location step and predicate
  • +
  • in 'bare' and parenthesized contexts
  • +
+

+ Ron Van den Branden +
+ + + + test + + + + + + + [bare context] self axis in location step, abbreviated + + + test + + + + [bare context] self axis in location step, full + + + test + + + + [bare context] self axis in location step, full with name test + + + test + + + + [bare context] self axis in predicate, abbreviated + + + test + + + + [bare context] self axis in predicate, full + + + test + + + + [bare context] self axis in predicate, full with name test + + + test + + + + + [parenthesized context] self axis in location step, abbreviated + + + test + + + + [parenthesized context] self axis in location step, full + + + test + + + + [parenthesized context] self axis in location step, full with name test + + + test + + + + [parenthesized context] self axis in predicate, abbreviated + + + test + + + + [parenthesized context] self axis in predicate, full + + + test + + + + [parenthesized context] self axis in predicate, full with name test + + + test + + + + [filter context] use self within filter step + + let $values := 1 to 10 + return $values[. = 5] + + 5 + + + [filter context] use self in function call within filter step + + let $values := (3,4,6,6 ,2,7, 3,1,2) + return $values[index-of($values, .)[2]] + + 6 3 2 + + + Self axis step used inside enclosed expression + + One + + return + $data/elem/{.,1} + ]]> + + + One + 1 + + + + + Context item should not be touched by nested let clause + title + return + $xml/title/ + { + let $title := ./text() + return + let $text := text() + return + $text + } + ]]> + + title + +
\ No newline at end of file diff --git a/test/src/xquery/unionOperator.xml b/test/src/xquery/unionOperator.xml index b8f33a62355..75b9bc39bda 100644 --- a/test/src/xquery/unionOperator.xml +++ b/test/src/xquery/unionOperator.xml @@ -1,97 +1,97 @@ - - tests for union operator in path step - -

tests for union operator in path step

- Ron Van den Branden -
- - - - union operator, stand-alone - - return ($a|$a) - ]]> - - - - inside location step, self axis - - return $a/(.|.) - ]]> - - - - inside location step, child axis - - return $a/(*|*) - ]]> - - - - inside location step, parent axis - - return $a/el2/(parent::*|parent::*) - ]]> - - - - inside location step, descendant axis - - return $a/(descendant::*[1]|descendant::*[1]) - ]]> - - - - inside location step, descendant-or-self axis - - return $a/(descendant-or-self::*[1]|descendant-or-self::*[1]) - ]]> - - - - inside location step, ancestor axis - - return $a/el2/(ancestor::*[1]|ancestor::*[1]) - ]]> - - - - inside location step, ancestor-or-self axis - - return $a/el2/(ancestor-or-self::*[1]|ancestor-or-self::*[1]) - ]]> - - - - inside location step, sibling axis - - return $a/el2/(preceding-sibling::*|following-sibling::*) - ]]> - - - - inside location step, preceding/following axis - - return $a/el2/(preceding::*|following::*) - ]]> - - - - inside location step, attribute axis - - return $a/el2/(@*[1]|@*[1])/string() - ]]> - val - + + tests for union operator in path step + +

tests for union operator in path step

+ Ron Van den Branden +
+ + + + union operator, stand-alone + + return ($a|$a) + ]]> + + + + inside location step, self axis + + return $a/(.|.) + ]]> + + + + inside location step, child axis + + return $a/(*|*) + ]]> + + + + inside location step, parent axis + + return $a/el2/(parent::*|parent::*) + ]]> + + + + inside location step, descendant axis + + return $a/(descendant::*[1]|descendant::*[1]) + ]]> + + + + inside location step, descendant-or-self axis + + return $a/(descendant-or-self::*[1]|descendant-or-self::*[1]) + ]]> + + + + inside location step, ancestor axis + + return $a/el2/(ancestor::*[1]|ancestor::*[1]) + ]]> + + + + inside location step, ancestor-or-self axis + + return $a/el2/(ancestor-or-self::*[1]|ancestor-or-self::*[1]) + ]]> + + + + inside location step, sibling axis + + return $a/el2/(preceding-sibling::*|following-sibling::*) + ]]> + + + + inside location step, preceding/following axis + + return $a/el2/(preceding::*|following::*) + ]]> + + + + inside location step, attribute axis + + return $a/el2/(@*[1]|@*[1])/string() + ]]> + val +
\ No newline at end of file diff --git a/tools/ant/LICENSE.txt b/tools/ant/LICENSE.txt index cdf6ff8b222..e7789e03327 100644 --- a/tools/ant/LICENSE.txt +++ b/tools/ant/LICENSE.txt @@ -1,272 +1,272 @@ -/* - * Apache License - * Version 2.0, January 2004 - * http://www.apache.org/licenses/ - * - * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - * - * 1. Definitions. - * - * "License" shall mean the terms and conditions for use, reproduction, - * and distribution as defined by Sections 1 through 9 of this document. - * - * "Licensor" shall mean the copyright owner or entity authorized by - * the copyright owner that is granting the License. - * - * "Legal Entity" shall mean the union of the acting entity and all - * other entities that control, are controlled by, or are under common - * control with that entity. For the purposes of this definition, - * "control" means (i) the power, direct or indirect, to cause the - * direction or management of such entity, whether by contract or - * otherwise, or (ii) ownership of fifty percent (50%) or more of the - * outstanding shares, or (iii) beneficial ownership of such entity. - * - * "You" (or "Your") shall mean an individual or Legal Entity - * exercising permissions granted by this License. - * - * "Source" form shall mean the preferred form for making modifications, - * including but not limited to software source code, documentation - * source, and configuration files. - * - * "Object" form shall mean any form resulting from mechanical - * transformation or translation of a Source form, including but - * not limited to compiled object code, generated documentation, - * and conversions to other media types. - * - * "Work" shall mean the work of authorship, whether in Source or - * Object form, made available under the License, as indicated by a - * copyright notice that is included in or attached to the work - * (an example is provided in the Appendix below). - * - * "Derivative Works" shall mean any work, whether in Source or Object - * form, that is based on (or derived from) the Work and for which the - * editorial revisions, annotations, elaborations, or other modifications - * represent, as a whole, an original work of authorship. For the purposes - * of this License, Derivative Works shall not include works that remain - * separable from, or merely link (or bind by name) to the interfaces of, - * the Work and Derivative Works thereof. - * - * "Contribution" shall mean any work of authorship, including - * the original version of the Work and any modifications or additions - * to that Work or Derivative Works thereof, that is intentionally - * submitted to Licensor for inclusion in the Work by the copyright owner - * or by an individual or Legal Entity authorized to submit on behalf of - * the copyright owner. For the purposes of this definition, "submitted" - * means any form of electronic, verbal, or written communication sent - * to the Licensor or its representatives, including but not limited to - * communication on electronic mailing lists, source code control systems, - * and issue tracking systems that are managed by, or on behalf of, the - * Licensor for the purpose of discussing and improving the Work, but - * excluding communication that is conspicuously marked or otherwise - * designated in writing by the copyright owner as "Not a Contribution." - * - * "Contributor" shall mean Licensor and any individual or Legal Entity - * on behalf of whom a Contribution has been received by Licensor and - * subsequently incorporated within the Work. - * - * 2. Grant of Copyright License. Subject to the terms and conditions of - * this License, each Contributor hereby grants to You a perpetual, - * worldwide, non-exclusive, no-charge, royalty-free, irrevocable - * copyright license to reproduce, prepare Derivative Works of, - * publicly display, publicly perform, sublicense, and distribute the - * Work and such Derivative Works in Source or Object form. - * - * 3. Grant of Patent License. Subject to the terms and conditions of - * this License, each Contributor hereby grants to You a perpetual, - * worldwide, non-exclusive, no-charge, royalty-free, irrevocable - * (except as stated in this section) patent license to make, have made, - * use, offer to sell, sell, import, and otherwise transfer the Work, - * where such license applies only to those patent claims licensable - * by such Contributor that are necessarily infringed by their - * Contribution(s) alone or by combination of their Contribution(s) - * with the Work to which such Contribution(s) was submitted. If You - * institute patent litigation against any entity (including a - * cross-claim or counterclaim in a lawsuit) alleging that the Work - * or a Contribution incorporated within the Work constitutes direct - * or contributory patent infringement, then any patent licenses - * granted to You under this License for that Work shall terminate - * as of the date such litigation is filed. - * - * 4. Redistribution. You may reproduce and distribute copies of the - * Work or Derivative Works thereof in any medium, with or without - * modifications, and in Source or Object form, provided that You - * meet the following conditions: - * - * (a) You must give any other recipients of the Work or - * Derivative Works a copy of this License; and - * - * (b) You must cause any modified files to carry prominent notices - * stating that You changed the files; and - * - * (c) You must retain, in the Source form of any Derivative Works - * that You distribute, all copyright, patent, trademark, and - * attribution notices from the Source form of the Work, - * excluding those notices that do not pertain to any part of - * the Derivative Works; and - * - * (d) If the Work includes a "NOTICE" text file as part of its - * distribution, then any Derivative Works that You distribute must - * include a readable copy of the attribution notices contained - * within such NOTICE file, excluding those notices that do not - * pertain to any part of the Derivative Works, in at least one - * of the following places: within a NOTICE text file distributed - * as part of the Derivative Works; within the Source form or - * documentation, if provided along with the Derivative Works; or, - * within a display generated by the Derivative Works, if and - * wherever such third-party notices normally appear. The contents - * of the NOTICE file are for informational purposes only and - * do not modify the License. You may add Your own attribution - * notices within Derivative Works that You distribute, alongside - * or as an addendum to the NOTICE text from the Work, provided - * that such additional attribution notices cannot be construed - * as modifying the License. - * - * You may add Your own copyright statement to Your modifications and - * may provide additional or different license terms and conditions - * for use, reproduction, or distribution of Your modifications, or - * for any such Derivative Works as a whole, provided Your use, - * reproduction, and distribution of the Work otherwise complies with - * the conditions stated in this License. - * - * 5. Submission of Contributions. Unless You explicitly state otherwise, - * any Contribution intentionally submitted for inclusion in the Work - * by You to the Licensor shall be under the terms and conditions of - * this License, without any additional terms or conditions. - * Notwithstanding the above, nothing herein shall supersede or modify - * the terms of any separate license agreement you may have executed - * with Licensor regarding such Contributions. - * - * 6. Trademarks. This License does not grant permission to use the trade - * names, trademarks, service marks, or product names of the Licensor, - * except as required for reasonable and customary use in describing the - * origin of the Work and reproducing the content of the NOTICE file. - * - * 7. Disclaimer of Warranty. Unless required by applicable law or - * agreed to in writing, Licensor provides the Work (and each - * Contributor provides its Contributions) on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied, including, without limitation, any warranties or conditions - * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - * PARTICULAR PURPOSE. You are solely responsible for determining the - * appropriateness of using or redistributing the Work and assume any - * risks associated with Your exercise of permissions under this License. - * - * 8. Limitation of Liability. In no event and under no legal theory, - * whether in tort (including negligence), contract, or otherwise, - * unless required by applicable law (such as deliberate and grossly - * negligent acts) or agreed to in writing, shall any Contributor be - * liable to You for damages, including any direct, indirect, special, - * incidental, or consequential damages of any character arising as a - * result of this License or out of the use or inability to use the - * Work (including but not limited to damages for loss of goodwill, - * work stoppage, computer failure or malfunction, or any and all - * other commercial damages or losses), even if such Contributor - * has been advised of the possibility of such damages. - * - * 9. Accepting Warranty or Additional Liability. While redistributing - * the Work or Derivative Works thereof, You may choose to offer, - * and charge a fee for, acceptance of support, warranty, indemnity, - * or other liability obligations and/or rights consistent with this - * License. However, in accepting such obligations, You may act only - * on Your own behalf and on Your sole responsibility, not on behalf - * of any other Contributor, and only if You agree to indemnify, - * defend, and hold each Contributor harmless for any liability - * incurred by, or claims asserted against, such Contributor by reason - * of your accepting any such warranty or additional liability. - * - * END OF TERMS AND CONDITIONS - * - * APPENDIX: How to apply the Apache License to your work. - * - * To apply the Apache License to your work, attach the following - * boilerplate notice, with the fields enclosed by brackets "[]" - * replaced with your own identifying information. (Don't include - * the brackets!) The text should be enclosed in the appropriate - * comment syntax for the file format. We also recommend that a - * file or class name and description of purpose be included on the - * same "printed page" as the copyright notice for easier - * identification within third-party archives. - * - * Copyright [yyyy] [name of copyright owner] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -W3C® SOFTWARE NOTICE AND LICENSE -http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 - -This work (and included software, documentation such as READMEs, or other -related items) is being provided by the copyright holders under the following -license. By obtaining, using and/or copying this work, you (the licensee) agree -that you have read, understood, and will comply with the following terms and -conditions. - -Permission to copy, modify, and distribute this software and its documentation, -with or without modification, for any purpose and without fee or royalty is -hereby granted, provided that you include the following on ALL copies of the -software and documentation or portions thereof, including modifications: - - 1. The full text of this NOTICE in a location viewable to users of the - redistributed or derivative work. - 2. Any pre-existing intellectual property disclaimers, notices, or terms - and conditions. If none exist, the W3C Software Short Notice should be - included (hypertext is preferred, text is permitted) within the body - of any redistributed or derivative code. - 3. Notice of any changes or modifications to the files, including the date - changes were made. (We recommend you provide URIs to the location from - which the code is derived.) - -THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE -NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT -THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY -PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. - -COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION. - -The name and trademarks of copyright holders may NOT be used in advertising or -publicity pertaining to the software without specific, written prior permission. -Title to copyright in this software and any associated documentation will at -all times remain with copyright holders. - -____________________________________ - -This formulation of W3C's notice and license became active on December 31 2002. -This version removes the copyright ownership notice such that this license can -be used with materials other than those owned by the W3C, reflects that ERCIM -is now a host of the W3C, includes references to this specific dated version of -the license, and removes the ambiguous grant of "use". Otherwise, this version -is the same as the previous version and is written so as to preserve the Free -Software Foundation's assessment of GPL compatibility and OSI's certification -under the Open Source Definition. Please see our Copyright FAQ for common -questions about using materials from our site, including specific terms and -conditions for packages like libwww, Amaya, and Jigsaw. Other questions about -this notice can be directed to site-policy@w3.org. - -Joseph Reagle - -This license came from: http://www.megginson.com/SAX/copying.html - However please note future versions of SAX may be covered - under http://saxproject.org/?selected=pd - -SAX2 is Free! - -I hereby abandon any property rights to SAX 2.0 (the Simple API for -XML), and release all of the SAX 2.0 source code, compiled code, and -documentation contained in this distribution into the Public Domain. -SAX comes with NO WARRANTY or guarantee of fitness for any -purpose. - -David Megginson, david@megginson.com -2000-05-05 +/* + * Apache License + * Version 2.0, January 2004 + * http://www.apache.org/licenses/ + * + * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + * + * 1. Definitions. + * + * "License" shall mean the terms and conditions for use, reproduction, + * and distribution as defined by Sections 1 through 9 of this document. + * + * "Licensor" shall mean the copyright owner or entity authorized by + * the copyright owner that is granting the License. + * + * "Legal Entity" shall mean the union of the acting entity and all + * other entities that control, are controlled by, or are under common + * control with that entity. For the purposes of this definition, + * "control" means (i) the power, direct or indirect, to cause the + * direction or management of such entity, whether by contract or + * otherwise, or (ii) ownership of fifty percent (50%) or more of the + * outstanding shares, or (iii) beneficial ownership of such entity. + * + * "You" (or "Your") shall mean an individual or Legal Entity + * exercising permissions granted by this License. + * + * "Source" form shall mean the preferred form for making modifications, + * including but not limited to software source code, documentation + * source, and configuration files. + * + * "Object" form shall mean any form resulting from mechanical + * transformation or translation of a Source form, including but + * not limited to compiled object code, generated documentation, + * and conversions to other media types. + * + * "Work" shall mean the work of authorship, whether in Source or + * Object form, made available under the License, as indicated by a + * copyright notice that is included in or attached to the work + * (an example is provided in the Appendix below). + * + * "Derivative Works" shall mean any work, whether in Source or Object + * form, that is based on (or derived from) the Work and for which the + * editorial revisions, annotations, elaborations, or other modifications + * represent, as a whole, an original work of authorship. For the purposes + * of this License, Derivative Works shall not include works that remain + * separable from, or merely link (or bind by name) to the interfaces of, + * the Work and Derivative Works thereof. + * + * "Contribution" shall mean any work of authorship, including + * the original version of the Work and any modifications or additions + * to that Work or Derivative Works thereof, that is intentionally + * submitted to Licensor for inclusion in the Work by the copyright owner + * or by an individual or Legal Entity authorized to submit on behalf of + * the copyright owner. For the purposes of this definition, "submitted" + * means any form of electronic, verbal, or written communication sent + * to the Licensor or its representatives, including but not limited to + * communication on electronic mailing lists, source code control systems, + * and issue tracking systems that are managed by, or on behalf of, the + * Licensor for the purpose of discussing and improving the Work, but + * excluding communication that is conspicuously marked or otherwise + * designated in writing by the copyright owner as "Not a Contribution." + * + * "Contributor" shall mean Licensor and any individual or Legal Entity + * on behalf of whom a Contribution has been received by Licensor and + * subsequently incorporated within the Work. + * + * 2. Grant of Copyright License. Subject to the terms and conditions of + * this License, each Contributor hereby grants to You a perpetual, + * worldwide, non-exclusive, no-charge, royalty-free, irrevocable + * copyright license to reproduce, prepare Derivative Works of, + * publicly display, publicly perform, sublicense, and distribute the + * Work and such Derivative Works in Source or Object form. + * + * 3. Grant of Patent License. Subject to the terms and conditions of + * this License, each Contributor hereby grants to You a perpetual, + * worldwide, non-exclusive, no-charge, royalty-free, irrevocable + * (except as stated in this section) patent license to make, have made, + * use, offer to sell, sell, import, and otherwise transfer the Work, + * where such license applies only to those patent claims licensable + * by such Contributor that are necessarily infringed by their + * Contribution(s) alone or by combination of their Contribution(s) + * with the Work to which such Contribution(s) was submitted. If You + * institute patent litigation against any entity (including a + * cross-claim or counterclaim in a lawsuit) alleging that the Work + * or a Contribution incorporated within the Work constitutes direct + * or contributory patent infringement, then any patent licenses + * granted to You under this License for that Work shall terminate + * as of the date such litigation is filed. + * + * 4. Redistribution. You may reproduce and distribute copies of the + * Work or Derivative Works thereof in any medium, with or without + * modifications, and in Source or Object form, provided that You + * meet the following conditions: + * + * (a) You must give any other recipients of the Work or + * Derivative Works a copy of this License; and + * + * (b) You must cause any modified files to carry prominent notices + * stating that You changed the files; and + * + * (c) You must retain, in the Source form of any Derivative Works + * that You distribute, all copyright, patent, trademark, and + * attribution notices from the Source form of the Work, + * excluding those notices that do not pertain to any part of + * the Derivative Works; and + * + * (d) If the Work includes a "NOTICE" text file as part of its + * distribution, then any Derivative Works that You distribute must + * include a readable copy of the attribution notices contained + * within such NOTICE file, excluding those notices that do not + * pertain to any part of the Derivative Works, in at least one + * of the following places: within a NOTICE text file distributed + * as part of the Derivative Works; within the Source form or + * documentation, if provided along with the Derivative Works; or, + * within a display generated by the Derivative Works, if and + * wherever such third-party notices normally appear. The contents + * of the NOTICE file are for informational purposes only and + * do not modify the License. You may add Your own attribution + * notices within Derivative Works that You distribute, alongside + * or as an addendum to the NOTICE text from the Work, provided + * that such additional attribution notices cannot be construed + * as modifying the License. + * + * You may add Your own copyright statement to Your modifications and + * may provide additional or different license terms and conditions + * for use, reproduction, or distribution of Your modifications, or + * for any such Derivative Works as a whole, provided Your use, + * reproduction, and distribution of the Work otherwise complies with + * the conditions stated in this License. + * + * 5. Submission of Contributions. Unless You explicitly state otherwise, + * any Contribution intentionally submitted for inclusion in the Work + * by You to the Licensor shall be under the terms and conditions of + * this License, without any additional terms or conditions. + * Notwithstanding the above, nothing herein shall supersede or modify + * the terms of any separate license agreement you may have executed + * with Licensor regarding such Contributions. + * + * 6. Trademarks. This License does not grant permission to use the trade + * names, trademarks, service marks, or product names of the Licensor, + * except as required for reasonable and customary use in describing the + * origin of the Work and reproducing the content of the NOTICE file. + * + * 7. Disclaimer of Warranty. Unless required by applicable law or + * agreed to in writing, Licensor provides the Work (and each + * Contributor provides its Contributions) on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied, including, without limitation, any warranties or conditions + * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + * PARTICULAR PURPOSE. You are solely responsible for determining the + * appropriateness of using or redistributing the Work and assume any + * risks associated with Your exercise of permissions under this License. + * + * 8. Limitation of Liability. In no event and under no legal theory, + * whether in tort (including negligence), contract, or otherwise, + * unless required by applicable law (such as deliberate and grossly + * negligent acts) or agreed to in writing, shall any Contributor be + * liable to You for damages, including any direct, indirect, special, + * incidental, or consequential damages of any character arising as a + * result of this License or out of the use or inability to use the + * Work (including but not limited to damages for loss of goodwill, + * work stoppage, computer failure or malfunction, or any and all + * other commercial damages or losses), even if such Contributor + * has been advised of the possibility of such damages. + * + * 9. Accepting Warranty or Additional Liability. While redistributing + * the Work or Derivative Works thereof, You may choose to offer, + * and charge a fee for, acceptance of support, warranty, indemnity, + * or other liability obligations and/or rights consistent with this + * License. However, in accepting such obligations, You may act only + * on Your own behalf and on Your sole responsibility, not on behalf + * of any other Contributor, and only if You agree to indemnify, + * defend, and hold each Contributor harmless for any liability + * incurred by, or claims asserted against, such Contributor by reason + * of your accepting any such warranty or additional liability. + * + * END OF TERMS AND CONDITIONS + * + * APPENDIX: How to apply the Apache License to your work. + * + * To apply the Apache License to your work, attach the following + * boilerplate notice, with the fields enclosed by brackets "[]" + * replaced with your own identifying information. (Don't include + * the brackets!) The text should be enclosed in the appropriate + * comment syntax for the file format. We also recommend that a + * file or class name and description of purpose be included on the + * same "printed page" as the copyright notice for easier + * identification within third-party archives. + * + * Copyright [yyyy] [name of copyright owner] + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +W3C® SOFTWARE NOTICE AND LICENSE +http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 + +This work (and included software, documentation such as READMEs, or other +related items) is being provided by the copyright holders under the following +license. By obtaining, using and/or copying this work, you (the licensee) agree +that you have read, understood, and will comply with the following terms and +conditions. + +Permission to copy, modify, and distribute this software and its documentation, +with or without modification, for any purpose and without fee or royalty is +hereby granted, provided that you include the following on ALL copies of the +software and documentation or portions thereof, including modifications: + + 1. The full text of this NOTICE in a location viewable to users of the + redistributed or derivative work. + 2. Any pre-existing intellectual property disclaimers, notices, or terms + and conditions. If none exist, the W3C Software Short Notice should be + included (hypertext is preferred, text is permitted) within the body + of any redistributed or derivative code. + 3. Notice of any changes or modifications to the files, including the date + changes were made. (We recommend you provide URIs to the location from + which the code is derived.) + +THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE +NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT +THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY +PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. + +COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION. + +The name and trademarks of copyright holders may NOT be used in advertising or +publicity pertaining to the software without specific, written prior permission. +Title to copyright in this software and any associated documentation will at +all times remain with copyright holders. + +____________________________________ + +This formulation of W3C's notice and license became active on December 31 2002. +This version removes the copyright ownership notice such that this license can +be used with materials other than those owned by the W3C, reflects that ERCIM +is now a host of the W3C, includes references to this specific dated version of +the license, and removes the ambiguous grant of "use". Otherwise, this version +is the same as the previous version and is written so as to preserve the Free +Software Foundation's assessment of GPL compatibility and OSI's certification +under the Open Source Definition. Please see our Copyright FAQ for common +questions about using materials from our site, including specific terms and +conditions for packages like libwww, Amaya, and Jigsaw. Other questions about +this notice can be directed to site-policy@w3.org. + +Joseph Reagle + +This license came from: http://www.megginson.com/SAX/copying.html + However please note future versions of SAX may be covered + under http://saxproject.org/?selected=pd + +SAX2 is Free! + +I hereby abandon any property rights to SAX 2.0 (the Simple API for +XML), and release all of the SAX 2.0 source code, compiled code, and +documentation contained in this distribution into the Public Domain. +SAX comes with NO WARRANTY or guarantee of fitness for any +purpose. + +David Megginson, david@megginson.com +2000-05-05 diff --git a/tools/ant/lib/asocat-exist.LICENSE.txt b/tools/ant/lib/asocat-exist.LICENSE.txt index 65c5ca88a67..b14ca0a552d 100644 --- a/tools/ant/lib/asocat-exist.LICENSE.txt +++ b/tools/ant/lib/asocat-exist.LICENSE.txt @@ -1,165 +1,165 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/tools/ant/lib/jdepend-LICENSE.txt b/tools/ant/lib/jdepend-LICENSE.txt index 50b326dd8d5..c817a4f6e43 100644 --- a/tools/ant/lib/jdepend-LICENSE.txt +++ b/tools/ant/lib/jdepend-LICENSE.txt @@ -1,29 +1,29 @@ -Copyright (C) 2001 Clarkware Consulting, Inc. -All Rights Reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. Neither the name of Clarkware Consulting, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without prior written permission. For written - permission, please contact clarkware@clarkware.com. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, -OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +Copyright (C) 2001 Clarkware Consulting, Inc. +All Rights Reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. Neither the name of Clarkware Consulting, Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without prior written permission. For written + permission, please contact clarkware@clarkware.com. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +CLARKWARE CONSULTING OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, +OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/tools/backrest/build.xml b/tools/backrest/build.xml index 596ec8ab473..56b1ef794ec 100644 --- a/tools/backrest/build.xml +++ b/tools/backrest/build.xml @@ -1,96 +1,96 @@ - - - - - Create eXist standalone backup/restore distribution - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + Create eXist standalone backup/restore distribution + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/backrest/src/backup.bat b/tools/backrest/src/backup.bat index 264fa03b11b..b15f1713056 100644 --- a/tools/backrest/src/backup.bat +++ b/tools/backrest/src/backup.bat @@ -1,54 +1,54 @@ -@echo off - -rem $Id: backup.bat 10899 2009-12-28 18:07:14Z dizzzz $ - -rem Slurp the command line arguments. This loop allows for an unlimited number -rem of arguments (up to the command line limit, anyway). - -set CMD_LINE_ARGS=%1 -if ""%1""=="""" goto doneStart -shift -:setupArgs -if ""%1""=="""" goto doneStart -set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 -shift -goto setupArgs - -rem This label provides a place for the argument list loop to break out -rem and for NT handling to skip to. - -:doneStart - -if not "%JAVA_HOME%" == "" goto gotJavaHome - -rem @WINDOWS_INSTALLER_1@ - -echo Java environment not found. Please set -echo your JAVA_HOME environment variable to -echo the home of your JDK. -goto :eof - -:gotJavaHome -if not "%EXIST_BACKREST_HOME%" == "" goto gotExistHome - -rem try to guess (will be overridden by the installer) -set EXIST_BACKREST_HOME=. - -rem @WINDOWS_INSTALLER_2@ - -if exist "%EXIST_BACKREST_HOME%\lib\exist-backrest.jar" goto gotExistHome - -set EXIST_BACKREST_HOME=.. -if exist "%EXIST_BACKREST_HOME%\lib\exist-backrest.jar" goto gotExistHome - -echo EXIST_BACKREST_HOME not found. Please set your -echo EXIST_BACKREST_HOME environment variable to the -echo home directory of eXist BackRest. -goto :eof - -:gotExistHome -set JAVA_OPTS=-Xms128m -Xmx512m -Dfile.encoding=UTF-8 - -"%JAVA_HOME%\bin\java" %JAVA_OPTS% -Dexist.home="%EXIST_BACKREST_HOME%" -cp "%EXIST_BACKREST_HOME%\lib\exist-backrest.jar" org.exist.backup.Main %CMD_LINE_ARGS% -:eof - +@echo off + +rem $Id: backup.bat 10899 2009-12-28 18:07:14Z dizzzz $ + +rem Slurp the command line arguments. This loop allows for an unlimited number +rem of arguments (up to the command line limit, anyway). + +set CMD_LINE_ARGS=%1 +if ""%1""=="""" goto doneStart +shift +:setupArgs +if ""%1""=="""" goto doneStart +set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 +shift +goto setupArgs + +rem This label provides a place for the argument list loop to break out +rem and for NT handling to skip to. + +:doneStart + +if not "%JAVA_HOME%" == "" goto gotJavaHome + +rem @WINDOWS_INSTALLER_1@ + +echo Java environment not found. Please set +echo your JAVA_HOME environment variable to +echo the home of your JDK. +goto :eof + +:gotJavaHome +if not "%EXIST_BACKREST_HOME%" == "" goto gotExistHome + +rem try to guess (will be overridden by the installer) +set EXIST_BACKREST_HOME=. + +rem @WINDOWS_INSTALLER_2@ + +if exist "%EXIST_BACKREST_HOME%\lib\exist-backrest.jar" goto gotExistHome + +set EXIST_BACKREST_HOME=.. +if exist "%EXIST_BACKREST_HOME%\lib\exist-backrest.jar" goto gotExistHome + +echo EXIST_BACKREST_HOME not found. Please set your +echo EXIST_BACKREST_HOME environment variable to the +echo home directory of eXist BackRest. +goto :eof + +:gotExistHome +set JAVA_OPTS=-Xms128m -Xmx512m -Dfile.encoding=UTF-8 + +"%JAVA_HOME%\bin\java" %JAVA_OPTS% -Dexist.home="%EXIST_BACKREST_HOME%" -cp "%EXIST_BACKREST_HOME%\lib\exist-backrest.jar" org.exist.backup.Main %CMD_LINE_ARGS% +:eof + diff --git a/tools/backrest/src/backup.properties b/tools/backrest/src/backup.properties index 909f5fb6cfe..ed011a857c1 100644 --- a/tools/backrest/src/backup.properties +++ b/tools/backrest/src/backup.properties @@ -1,18 +1,18 @@ -# properties used for backup/restore - -# XMLDB driver -driver=org.exist.xmldb.DatabaseImpl - -# uncomment following line if you want to access a -# stand-alone server -#uri=xmldb:exist://localhost:8088/xmlrpc - -# access eXist via XML-RPC provided by remote Tomcat -uri=xmldb:exist://localhost/xmlrpc - -# access a local instance of the database -#uri=xmldb:exist:// - -# user settings for backup/restore -user=admin -password= +# properties used for backup/restore + +# XMLDB driver +driver=org.exist.xmldb.DatabaseImpl + +# uncomment following line if you want to access a +# stand-alone server +#uri=xmldb:exist://localhost:8088/xmlrpc + +# access eXist via XML-RPC provided by remote Tomcat +uri=xmldb:exist://localhost/xmlrpc + +# access a local instance of the database +#uri=xmldb:exist:// + +# user settings for backup/restore +user=admin +password= diff --git a/tools/ircbot/build.xml b/tools/ircbot/build.xml index 652a2293209..f64bd0f12a8 100644 --- a/tools/ircbot/build.xml +++ b/tools/ircbot/build.xml @@ -1,58 +1,58 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/ircbot/run.bat b/tools/ircbot/run.bat index c94c1ccad97..e333ce7f348 100644 --- a/tools/ircbot/run.bat +++ b/tools/ircbot/run.bat @@ -1,7 +1,7 @@ -@echo off - -set EXIST=..\.. - -set CP="%EXIST%\exist.jar;lib\pircbot.jar;%EXIST%\lib\core\log4j-1.2.16.jar;%EXIST%\lib\core\xmldb.jar;%EXIST%\lib\core\xmlrpc-1.2-patched.jar;classes" - -java -classpath %CP% org.exist.irc.XBot %1 %2 +@echo off + +set EXIST=..\.. + +set CP="%EXIST%\exist.jar;lib\pircbot.jar;%EXIST%\lib\core\log4j-1.2.16.jar;%EXIST%\lib\core\xmldb.jar;%EXIST%\lib\core\xmlrpc-1.2-patched.jar;classes" + +java -classpath %CP% org.exist.irc.XBot %1 %2 diff --git a/tools/ircbot/src/org/exist/irc/IRCProxy.java b/tools/ircbot/src/org/exist/irc/IRCProxy.java index 0ff13852c9b..bff705fa15b 100644 --- a/tools/ircbot/src/org/exist/irc/IRCProxy.java +++ b/tools/ircbot/src/org/exist/irc/IRCProxy.java @@ -1,146 +1,146 @@ -package org.exist.irc; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.jibble.pircbot.IrcException; -import org.jibble.pircbot.NickAlreadyInUseException; - -public class IRCProxy extends HttpServlet { - - // private String server = "irc.freenode.net"; - - private static final long serialVersionUID = -1599826284082032574L; - - private static final String SESSION_ATTR = "org.exist.irc.sessions"; - - private String server = "localhost"; - private String channel = "#testaabb"; - - private boolean modProxyHack = false; - - public void init(ServletConfig config) throws ServletException { - super.init(config); - - String param = config.getInitParameter("mod-proxy"); - if (param != null) - modProxyHack = param.equalsIgnoreCase("true"); - param = config.getInitParameter("server"); - if (param != null) - server = param; - Map channels = new HashMap(); - getServletContext().setAttribute(SESSION_ATTR, channels); - } - - /** - * The GET method opens a connection to the client and keeps it open, i.e. the - * method will only return if the client does explicitely close the session (via a POST) - * or the session is killed. The server sends all input it receives from the IRC server down - * this stream. - * - * Before calling GET, the client has to create a session by sending a POST request - * with just the channel and the nick as parameters (but no 'session' parameter). After - * the session was created successfully, the client can call GET and start listening. - */ - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - String sessionId = request.getParameter("session"); - if (sessionId == null) { - response.sendError(HttpServletResponse.SC_NOT_FOUND, "No session specified"); - return; - } - - Map channels = (Map) getServletContext().getAttribute(SESSION_ATTR); - IRCSession session = channels.get(sessionId); - if (session == null) { - response.sendError(HttpServletResponse.SC_NOT_FOUND, "Session " + sessionId + " not found"); - return; - } - log("Starting/refreshing session ..."); - if (session.started()) { - session.closeTunnel(); - } - session.run(response); - } - - /** - * The POST method is used to initialize a session and to process - * commands. The client will use POST to pass the user input to the - * server asynchronously. - */ - protected void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - String sessionId = request.getParameter("session"); - String nick = request.getParameter("nick"); - String channelParam = request.getParameter("channel"); - String close = request.getParameter("close"); - String send = request.getParameter("send"); - String pong = request.getParameter("pong"); - String reconnect = request.getParameter("refresh"); - Map channels = (Map) getServletContext().getAttribute(SESSION_ATTR); - if (sessionId == null) { - // No session yet: connect and create a new one - if (channelParam != null && channelParam.length() > 0) - channel = channelParam; - try { - IRCSession session = new IRCSession(server, channel, nick, modProxyHack); - sessionId = session.getSessionId(); - log("New session created: " + sessionId); - // add the session to the list of channels - synchronized(channels) { - channels.put(sessionId, session); - } - response.setContentType("text/text"); - response.setContentLength(0); - response.setHeader("X-IRC-Session", sessionId); - response.setHeader("X-IRC-Nick", session.getName()); - } catch (NickAlreadyInUseException e) { - response.sendError(HttpServletResponse.SC_CONFLICT, "Nick is already in use"); - } catch (IOException e) { - response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); - } catch (IrcException e) { - response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); - } - } else { - IRCSession session = channels.get(sessionId); - if (session == null) { - response.sendError(HttpServletResponse.SC_NOT_FOUND, "Session " + sessionId + " not found"); - return; - } - // we have a valid session, so check for commands and process them - if (pong != null) { - log("Received pong from client."); - session.pingResponse(); - } else if (close != null) { - log("Closing session " + sessionId); - session.quit(); - } else if (reconnect != null) { - try { - session.attemptReconnect(); - } catch (NickAlreadyInUseException e) { - response.sendError(HttpServletResponse.SC_CONFLICT, "Nick is already in use"); - } catch (IOException e) { - response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); - } catch (IrcException e) { - response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); - } - } else if (send != null) { - log("Sending message: " + send + "; id: " + sessionId); - session.send(send); - } - } - } - - public void destroy() { - Map channels = (Map) getServletContext().getAttribute(SESSION_ATTR); - for (IRCSession session : channels.values()) { - session.quit(); - } - } -} +package org.exist.irc; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import javax.servlet.ServletConfig; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.jibble.pircbot.IrcException; +import org.jibble.pircbot.NickAlreadyInUseException; + +public class IRCProxy extends HttpServlet { + + // private String server = "irc.freenode.net"; + + private static final long serialVersionUID = -1599826284082032574L; + + private static final String SESSION_ATTR = "org.exist.irc.sessions"; + + private String server = "localhost"; + private String channel = "#testaabb"; + + private boolean modProxyHack = false; + + public void init(ServletConfig config) throws ServletException { + super.init(config); + + String param = config.getInitParameter("mod-proxy"); + if (param != null) + modProxyHack = param.equalsIgnoreCase("true"); + param = config.getInitParameter("server"); + if (param != null) + server = param; + Map channels = new HashMap(); + getServletContext().setAttribute(SESSION_ATTR, channels); + } + + /** + * The GET method opens a connection to the client and keeps it open, i.e. the + * method will only return if the client does explicitely close the session (via a POST) + * or the session is killed. The server sends all input it receives from the IRC server down + * this stream. + * + * Before calling GET, the client has to create a session by sending a POST request + * with just the channel and the nick as parameters (but no 'session' parameter). After + * the session was created successfully, the client can call GET and start listening. + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + String sessionId = request.getParameter("session"); + if (sessionId == null) { + response.sendError(HttpServletResponse.SC_NOT_FOUND, "No session specified"); + return; + } + + Map channels = (Map) getServletContext().getAttribute(SESSION_ATTR); + IRCSession session = channels.get(sessionId); + if (session == null) { + response.sendError(HttpServletResponse.SC_NOT_FOUND, "Session " + sessionId + " not found"); + return; + } + log("Starting/refreshing session ..."); + if (session.started()) { + session.closeTunnel(); + } + session.run(response); + } + + /** + * The POST method is used to initialize a session and to process + * commands. The client will use POST to pass the user input to the + * server asynchronously. + */ + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + String sessionId = request.getParameter("session"); + String nick = request.getParameter("nick"); + String channelParam = request.getParameter("channel"); + String close = request.getParameter("close"); + String send = request.getParameter("send"); + String pong = request.getParameter("pong"); + String reconnect = request.getParameter("refresh"); + Map channels = (Map) getServletContext().getAttribute(SESSION_ATTR); + if (sessionId == null) { + // No session yet: connect and create a new one + if (channelParam != null && channelParam.length() > 0) + channel = channelParam; + try { + IRCSession session = new IRCSession(server, channel, nick, modProxyHack); + sessionId = session.getSessionId(); + log("New session created: " + sessionId); + // add the session to the list of channels + synchronized(channels) { + channels.put(sessionId, session); + } + response.setContentType("text/text"); + response.setContentLength(0); + response.setHeader("X-IRC-Session", sessionId); + response.setHeader("X-IRC-Nick", session.getName()); + } catch (NickAlreadyInUseException e) { + response.sendError(HttpServletResponse.SC_CONFLICT, "Nick is already in use"); + } catch (IOException e) { + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); + } catch (IrcException e) { + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); + } + } else { + IRCSession session = channels.get(sessionId); + if (session == null) { + response.sendError(HttpServletResponse.SC_NOT_FOUND, "Session " + sessionId + " not found"); + return; + } + // we have a valid session, so check for commands and process them + if (pong != null) { + log("Received pong from client."); + session.pingResponse(); + } else if (close != null) { + log("Closing session " + sessionId); + session.quit(); + } else if (reconnect != null) { + try { + session.attemptReconnect(); + } catch (NickAlreadyInUseException e) { + response.sendError(HttpServletResponse.SC_CONFLICT, "Nick is already in use"); + } catch (IOException e) { + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); + } catch (IrcException e) { + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); + } + } else if (send != null) { + log("Sending message: " + send + "; id: " + sessionId); + session.send(send); + } + } + } + + public void destroy() { + Map channels = (Map) getServletContext().getAttribute(SESSION_ATTR); + for (IRCSession session : channels.values()) { + session.quit(); + } + } +} diff --git a/tools/ircbot/src/org/exist/irc/IRCSession.java b/tools/ircbot/src/org/exist/irc/IRCSession.java index fe6dcc75d61..c66a39dc65f 100644 --- a/tools/ircbot/src/org/exist/irc/IRCSession.java +++ b/tools/ircbot/src/org/exist/irc/IRCSession.java @@ -1,403 +1,403 @@ -package org.exist.irc; - -import java.io.*; -import java.util.Arrays; -import java.util.StringTokenizer; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.servlet.ServletOutputStream; -import javax.servlet.http.HttpServletResponse; - -import org.jibble.pircbot.*; - -public class IRCSession extends PircBot { - - private static final int PING_PERIOD = 20000; - private static final int TIMEOUT = 240000; - - private static final String EV_MESSAGE = "message"; - private static final String EV_NOTICE = "notice"; - private static final String EV_JOIN = "join"; - private static final String EV_PART = "part"; - private static final String EV_USERS_LIST = "users"; - private static final String EV_PING = "ping"; - - private static char[] CHUNK = new char[8192]; - static { - Arrays.fill(CHUNK, ' '); - } - - // server and channel settings - private String server; - private String channel; - - private String sessionId; - - private HttpServletResponse response = null; - private Writer responseWriter = null; - - private StringWriter writer = new StringWriter(); - - private boolean fillChunks = false; - - private boolean disconnect = false; - - private long lastPing; - - private boolean isRunning = false; - - private Pattern cmdRegex = Pattern.compile("^/\\s*(\\w+)\\s+(.*)$"); - private Matcher matcher = cmdRegex.matcher(""); - - public IRCSession(String server, String channel, String nick, boolean modProxyHack) throws IOException, NickAlreadyInUseException, IrcException { - super(); - - this.server = server; - this.channel = channel; - this.sessionId = Integer.toString(hashCode()); - this.fillChunks = modProxyHack; - - this.setVersion("XIRCProxy 0.1"); - this.setLogin("XIRCProxy"); - - this.setName(nick); - this.setVerbose(true); - this.setEncoding("UTF-8"); - connect(); - } - - protected void connect() throws IOException, IrcException, NickAlreadyInUseException { - log("Connecting to " + server); - - connect(server); - - log("Join channel: " + channel); - joinChannel(channel); - } - - public String getSessionId() { - return sessionId; - } - - public boolean started() { - return isRunning; - } - - public void run(HttpServletResponse servletResponse) { - setResponseObject(servletResponse); - - log("Listening to chat events ..."); - disconnect = false; - lastPing = System.currentTimeMillis(); - isRunning = true; - while (!disconnect) { - synchronized (this) { - try { - wait(PING_PERIOD); - } catch (InterruptedException e) { - } - } - if (!disconnect) { - long now = System.currentTimeMillis(); - if (now - lastPing > TIMEOUT) { - log("No response from client, disconnecting user " + getNick() + " from channel " + channel + " ..."); - partChannel(channel, "Connection Timed Out"); - quitServer(); - } else { - pingClient(); - } - } - } - isRunning = false; - flush(); - log("Exiting ..."); - synchronized(this) { - notifyAll(); - } - } - - public synchronized void closeTunnel() { - disconnect = true; - notifyAll(); - try { - wait(); - } catch (InterruptedException e) { - } - } - - public synchronized boolean setResponseObject(HttpServletResponse servletResponse) { - this.response = servletResponse; - response.setContentType("text/html"); - response.setBufferSize(64); - try { - ServletOutputStream os = response.getOutputStream(); - responseWriter = new PrintWriter(new OutputStreamWriter(os, "UTF-8"), false); - responseWriter.write(""); - responseWriter.write("IRCProxy"); - responseWriter.write(""); - responseWriter.write(""); - writeEvent("Connection to proxy opened.", EV_NOTICE); - flush(); - } catch (IOException e) { - log("Exception while opening push stream: " + e.getMessage()); - return true; - } - return false; - } - - public void quit() { - quit("Client Quit"); - } - - private void quit(String partMessage) { - partChannel(channel, partMessage); - quitServer(); - } - - public synchronized void send(String message) { - matcher.reset(message); - if (matcher.find()) { - String cmd = matcher.group(1); - message = matcher.group(2); - processCommand(cmd, message); - } else { - sendMessage(channel, message); - writeMessage(getNick(), message); - } - } - - public synchronized void attemptReconnect() throws IOException, IrcException { - log("Reconnecting ..."); - disconnect = true; - lastPing = System.currentTimeMillis(); - writer = new StringWriter(); - notifyAll(); - if (!isConnected()) { - connect(); - } - } - - protected void onConnect() { - writeEvent("Connected to server " + this.server + ".", EV_NOTICE); - flush(); - } - - protected synchronized void onDisconnect() { - disconnect = true; - notifyAll(); - } - - protected void onMessage(String channel, String sender, String login, String hostname, String message) { - log("Message from " + sender); - writeMessage(sender, message); - } - - protected void onJoin(String channel, String sender, String login, String hostname) { - try { - writer.write("\n\n"); - flush(); - } catch (Exception e) { - e.printStackTrace(); - closeConnection(e.getMessage()); - } - } - - protected void onPart(String channel, String sender, String login, String hostname) { - try { - writer.write("\n\n"); - flush(); - } catch (Exception e) { - e.printStackTrace(); - closeConnection(e.getMessage()); - } - } - - protected void onQuit(String sourceNick, String sourceLogin, String sourceHostname, String reason) { - try { - writer.write("\n\n"); - flush(); - } catch (Exception e) { - e.printStackTrace(); - closeConnection(e.getMessage()); - } - } - - protected void onNotice(String sourceNick, String sourceLogin, String sourceHostname, String target, String notice) { - writeEvent("Notice from " + sourceNick + " [" + sourceHostname + "] to " + target + ": " + notice, EV_NOTICE); - } - - protected void onUserList(String channel, User[] users) { - String args[] = new String[users.length + 1]; - args[0] = EV_USERS_LIST; - for (int i = 0; i < users.length; i++) { - args[i + 1] = users[i].getNick(); - } - try { - writer.write("\n\n"); - flush(); - } catch (Exception e) { - e.printStackTrace(); - closeConnection(e.getMessage()); - } - } - - - protected void onServerResponse(int i, String string) { - if (i == ReplyConstants.RPL_MOTDSTART || i == ReplyConstants.RPL_MOTD || - i == ReplyConstants.RPL_ENDOFMOTD) { - writeEvent(string, EV_NOTICE); - } - } - - public void pingResponse() { - log("Received ping reponse ..."); - lastPing = System.currentTimeMillis(); - } - - private void pingClient() { - String js = jsCall("dispatchEvent", new String[] { EV_PING }); - writeLine(js); - } - - private void writeMessage(String sender, String message) { - String js = jsCall("dispatchEvent", new String[] { EV_MESSAGE, sender, message }); - writeLine(js); - } - - private void writeEvent(String message, String cls) { - String js = jsCall("dispatchEvent", new String[] { cls, message }); - writeLine(js); - } - - private void writeLine(String data) { - try { - writer.write("\n\n"); - flush(); - } catch (Exception e) { - e.printStackTrace(); - closeConnection(e.getMessage()); - } - } - - private String jsCall(String func, String[] params) { - StringBuffer buf = new StringBuffer(); - buf.append("top.").append(func).append("('"); - buf.append(sessionId); - buf.append('\''); - for (int i = 0; i < params.length; i++) { - buf.append(", '"); - buf.append(escape(params[i])); - buf.append('\''); - } - buf.append(");"); - return buf.toString(); - } - - private void flush() { - if (response == null) - return; - String data = writer.toString(); - writer = new StringWriter(); - try { - if (data.length() > 0) { - responseWriter.write(data); - if (fillChunks) - responseWriter.write(CHUNK); - } - responseWriter.flush(); - } catch (IOException e) { - log("Exception while flushing servlet output: " + e.getMessage()); - outputStreamClosed(); - } - } - - private void outputStreamClosed() { - log("HttpServletResponse closed."); - response = null; - responseWriter = null; - } - - private void closeConnection(String message) { - if (writer != null) { - writer.write("

Error

"); - writer.write("

Error found: " + message + "

"); - writer.write("

Closing connection.

"); - flush(); - } - partChannel(channel); - quitServer(); - } - - private String escape(String in) { - StringBuffer buf = new StringBuffer(); - for (int i = 0; i < in.length(); i++) { - char ch = in.charAt(i); - switch (ch) { - case '\\' : - break; - case '"' : - case '\'' : - buf.append("""); - break; - case '<' : - buf.append("<"); - break; - case '>' : - buf.append(">"); - break; - case '&' : - buf.append("&"); - break; - default: - buf.append(ch); - break; - } - } - return buf.toString(); - } - - private void processCommand(String command, String message) { - if ("MSG".equalsIgnoreCase(command)) { - String target = new StringTokenizer(message).nextToken(); - sendMessage(target, message.substring(target.length() + 1)); - } else if ("QUIT".equalsIgnoreCase(command)) { - writeMessage(getNick(), "QUIT: " + message); - quit(message); - } else if ("NICK".equalsIgnoreCase(command)) { - writeMessage(getNick(), "Trying to change nick to " + message); - changeNick(message); - send("/list"); - } - } - - public static void main(String[] args) { - Pattern cmdRegex = Pattern.compile("^/\\s*(\\w+)\\s+(.*)$"); - Matcher matcher = cmdRegex.matcher(""); - matcher.reset("/quit abcdefg"); - if (matcher.find()) { - System.out.println("Command: " + matcher.group(1) + " - " + matcher.group(2)); - } else { - System.out.println("Nothing"); - } - } +package org.exist.irc; + +import java.io.*; +import java.util.Arrays; +import java.util.StringTokenizer; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; + +import org.jibble.pircbot.*; + +public class IRCSession extends PircBot { + + private static final int PING_PERIOD = 20000; + private static final int TIMEOUT = 240000; + + private static final String EV_MESSAGE = "message"; + private static final String EV_NOTICE = "notice"; + private static final String EV_JOIN = "join"; + private static final String EV_PART = "part"; + private static final String EV_USERS_LIST = "users"; + private static final String EV_PING = "ping"; + + private static char[] CHUNK = new char[8192]; + static { + Arrays.fill(CHUNK, ' '); + } + + // server and channel settings + private String server; + private String channel; + + private String sessionId; + + private HttpServletResponse response = null; + private Writer responseWriter = null; + + private StringWriter writer = new StringWriter(); + + private boolean fillChunks = false; + + private boolean disconnect = false; + + private long lastPing; + + private boolean isRunning = false; + + private Pattern cmdRegex = Pattern.compile("^/\\s*(\\w+)\\s+(.*)$"); + private Matcher matcher = cmdRegex.matcher(""); + + public IRCSession(String server, String channel, String nick, boolean modProxyHack) throws IOException, NickAlreadyInUseException, IrcException { + super(); + + this.server = server; + this.channel = channel; + this.sessionId = Integer.toString(hashCode()); + this.fillChunks = modProxyHack; + + this.setVersion("XIRCProxy 0.1"); + this.setLogin("XIRCProxy"); + + this.setName(nick); + this.setVerbose(true); + this.setEncoding("UTF-8"); + connect(); + } + + protected void connect() throws IOException, IrcException, NickAlreadyInUseException { + log("Connecting to " + server); + + connect(server); + + log("Join channel: " + channel); + joinChannel(channel); + } + + public String getSessionId() { + return sessionId; + } + + public boolean started() { + return isRunning; + } + + public void run(HttpServletResponse servletResponse) { + setResponseObject(servletResponse); + + log("Listening to chat events ..."); + disconnect = false; + lastPing = System.currentTimeMillis(); + isRunning = true; + while (!disconnect) { + synchronized (this) { + try { + wait(PING_PERIOD); + } catch (InterruptedException e) { + } + } + if (!disconnect) { + long now = System.currentTimeMillis(); + if (now - lastPing > TIMEOUT) { + log("No response from client, disconnecting user " + getNick() + " from channel " + channel + " ..."); + partChannel(channel, "Connection Timed Out"); + quitServer(); + } else { + pingClient(); + } + } + } + isRunning = false; + flush(); + log("Exiting ..."); + synchronized(this) { + notifyAll(); + } + } + + public synchronized void closeTunnel() { + disconnect = true; + notifyAll(); + try { + wait(); + } catch (InterruptedException e) { + } + } + + public synchronized boolean setResponseObject(HttpServletResponse servletResponse) { + this.response = servletResponse; + response.setContentType("text/html"); + response.setBufferSize(64); + try { + ServletOutputStream os = response.getOutputStream(); + responseWriter = new PrintWriter(new OutputStreamWriter(os, "UTF-8"), false); + responseWriter.write(""); + responseWriter.write("IRCProxy"); + responseWriter.write(""); + responseWriter.write(""); + writeEvent("Connection to proxy opened.", EV_NOTICE); + flush(); + } catch (IOException e) { + log("Exception while opening push stream: " + e.getMessage()); + return true; + } + return false; + } + + public void quit() { + quit("Client Quit"); + } + + private void quit(String partMessage) { + partChannel(channel, partMessage); + quitServer(); + } + + public synchronized void send(String message) { + matcher.reset(message); + if (matcher.find()) { + String cmd = matcher.group(1); + message = matcher.group(2); + processCommand(cmd, message); + } else { + sendMessage(channel, message); + writeMessage(getNick(), message); + } + } + + public synchronized void attemptReconnect() throws IOException, IrcException { + log("Reconnecting ..."); + disconnect = true; + lastPing = System.currentTimeMillis(); + writer = new StringWriter(); + notifyAll(); + if (!isConnected()) { + connect(); + } + } + + protected void onConnect() { + writeEvent("Connected to server " + this.server + ".", EV_NOTICE); + flush(); + } + + protected synchronized void onDisconnect() { + disconnect = true; + notifyAll(); + } + + protected void onMessage(String channel, String sender, String login, String hostname, String message) { + log("Message from " + sender); + writeMessage(sender, message); + } + + protected void onJoin(String channel, String sender, String login, String hostname) { + try { + writer.write("\n\n"); + flush(); + } catch (Exception e) { + e.printStackTrace(); + closeConnection(e.getMessage()); + } + } + + protected void onPart(String channel, String sender, String login, String hostname) { + try { + writer.write("\n\n"); + flush(); + } catch (Exception e) { + e.printStackTrace(); + closeConnection(e.getMessage()); + } + } + + protected void onQuit(String sourceNick, String sourceLogin, String sourceHostname, String reason) { + try { + writer.write("\n\n"); + flush(); + } catch (Exception e) { + e.printStackTrace(); + closeConnection(e.getMessage()); + } + } + + protected void onNotice(String sourceNick, String sourceLogin, String sourceHostname, String target, String notice) { + writeEvent("Notice from " + sourceNick + " [" + sourceHostname + "] to " + target + ": " + notice, EV_NOTICE); + } + + protected void onUserList(String channel, User[] users) { + String args[] = new String[users.length + 1]; + args[0] = EV_USERS_LIST; + for (int i = 0; i < users.length; i++) { + args[i + 1] = users[i].getNick(); + } + try { + writer.write("\n\n"); + flush(); + } catch (Exception e) { + e.printStackTrace(); + closeConnection(e.getMessage()); + } + } + + + protected void onServerResponse(int i, String string) { + if (i == ReplyConstants.RPL_MOTDSTART || i == ReplyConstants.RPL_MOTD || + i == ReplyConstants.RPL_ENDOFMOTD) { + writeEvent(string, EV_NOTICE); + } + } + + public void pingResponse() { + log("Received ping reponse ..."); + lastPing = System.currentTimeMillis(); + } + + private void pingClient() { + String js = jsCall("dispatchEvent", new String[] { EV_PING }); + writeLine(js); + } + + private void writeMessage(String sender, String message) { + String js = jsCall("dispatchEvent", new String[] { EV_MESSAGE, sender, message }); + writeLine(js); + } + + private void writeEvent(String message, String cls) { + String js = jsCall("dispatchEvent", new String[] { cls, message }); + writeLine(js); + } + + private void writeLine(String data) { + try { + writer.write("\n\n"); + flush(); + } catch (Exception e) { + e.printStackTrace(); + closeConnection(e.getMessage()); + } + } + + private String jsCall(String func, String[] params) { + StringBuffer buf = new StringBuffer(); + buf.append("top.").append(func).append("('"); + buf.append(sessionId); + buf.append('\''); + for (int i = 0; i < params.length; i++) { + buf.append(", '"); + buf.append(escape(params[i])); + buf.append('\''); + } + buf.append(");"); + return buf.toString(); + } + + private void flush() { + if (response == null) + return; + String data = writer.toString(); + writer = new StringWriter(); + try { + if (data.length() > 0) { + responseWriter.write(data); + if (fillChunks) + responseWriter.write(CHUNK); + } + responseWriter.flush(); + } catch (IOException e) { + log("Exception while flushing servlet output: " + e.getMessage()); + outputStreamClosed(); + } + } + + private void outputStreamClosed() { + log("HttpServletResponse closed."); + response = null; + responseWriter = null; + } + + private void closeConnection(String message) { + if (writer != null) { + writer.write("

Error

"); + writer.write("

Error found: " + message + "

"); + writer.write("

Closing connection.

"); + flush(); + } + partChannel(channel); + quitServer(); + } + + private String escape(String in) { + StringBuffer buf = new StringBuffer(); + for (int i = 0; i < in.length(); i++) { + char ch = in.charAt(i); + switch (ch) { + case '\\' : + break; + case '"' : + case '\'' : + buf.append("""); + break; + case '<' : + buf.append("<"); + break; + case '>' : + buf.append(">"); + break; + case '&' : + buf.append("&"); + break; + default: + buf.append(ch); + break; + } + } + return buf.toString(); + } + + private void processCommand(String command, String message) { + if ("MSG".equalsIgnoreCase(command)) { + String target = new StringTokenizer(message).nextToken(); + sendMessage(target, message.substring(target.length() + 1)); + } else if ("QUIT".equalsIgnoreCase(command)) { + writeMessage(getNick(), "QUIT: " + message); + quit(message); + } else if ("NICK".equalsIgnoreCase(command)) { + writeMessage(getNick(), "Trying to change nick to " + message); + changeNick(message); + send("/list"); + } + } + + public static void main(String[] args) { + Pattern cmdRegex = Pattern.compile("^/\\s*(\\w+)\\s+(.*)$"); + Matcher matcher = cmdRegex.matcher(""); + matcher.reset("/quit abcdefg"); + if (matcher.find()) { + System.out.println("Command: " + matcher.group(1) + " - " + matcher.group(2)); + } else { + System.out.println("Nothing"); + } + } } \ No newline at end of file diff --git a/tools/ircbot/src/org/exist/irc/XBot.java b/tools/ircbot/src/org/exist/irc/XBot.java index 92ffb3842da..bf23b6b4444 100644 --- a/tools/ircbot/src/org/exist/irc/XBot.java +++ b/tools/ircbot/src/org/exist/irc/XBot.java @@ -1,462 +1,462 @@ -package org.exist.irc; - -import org.exist.security.Permission; -import org.exist.security.PermissionFactory; -import org.exist.xmldb.UserManagementService; -import org.jibble.pircbot.IrcException; -import org.jibble.pircbot.NickAlreadyInUseException; -import org.jibble.pircbot.PircBot; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xmldb.api.DatabaseManager; -import org.xmldb.api.base.Collection; -import org.xmldb.api.base.Database; -import org.xmldb.api.base.ResourceSet; -import org.xmldb.api.base.XMLDBException; -import org.xmldb.api.modules.CollectionManagementService; -import org.xmldb.api.modules.XMLResource; -import org.xmldb.api.modules.XPathQueryService; -import org.xmldb.api.modules.XUpdateQueryService; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Properties; -import java.util.TimeZone; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Implements a simple IRC drone, which logs IRC events to a collection in an eXist database. - * One log file is created every day. Messages are appended using XUpdate. - * - * @author wolf - * - */ -public class XBot extends PircBot { - - private final static String VERSION = "0.2"; - - private final static String URI = "xmldb:exist://localhost:8080/exist/xmlrpc/db"; - - private final static String COLLECTION = "ircbot"; - - private final static Properties DEFAULTS = new Properties(); - static { - DEFAULTS.setProperty("xmldb.user", "guest"); - DEFAULTS.setProperty("xmldb.password", "guest"); - DEFAULTS.setProperty("xmldb.uri", URI); - DEFAULTS.setProperty("xmldb.collection", COLLECTION); - DEFAULTS.setProperty("irc.server", "irc.freenode.net"); - DEFAULTS.setProperty("irc.channel", "#existdb"); - DEFAULTS.setProperty("irc.nickname", "XDrone"); - DEFAULTS.setProperty("irc.password", ""); - } - - private final static String XUPDATE_START = - "\n" + - " \n"; - - private final static String URL_REGEX = - "((http|ftp)s{0,1}://[\\-\\.\\,/\\%\\~\\=\\@\\_\\&\\:\\?\\#a-zA-Z0-9]*[/\\=\\#a-zA-Z0-9])"; - - private final static int MAX_CONNECT_ATTEMPTS = 50; - - // these commands may be passed in a private message to the bot - private final Command[] commands = { - new HelpCommand(), - new QuitCommand(), - new FunctionLookup() - }; - - private Properties properties = new Properties(DEFAULTS); - - // the base collection - private Collection collection; - - private DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - - private Pattern urlPattern; - private Matcher matcher = null; - - private boolean disconnect = false; - - public XBot() throws IrcException { - super(); - - File f = new File("xbot.properties"); - if (f.canRead()) { - System.out.println("Reading properties file: " + f.getAbsolutePath()); - try { - FileInputStream stream = new FileInputStream(f); - try { - properties.load(stream); - } finally { - stream.close(); - } - } catch (IOException e) { - System.err.println("Failed to load properties: " + e.getMessage()); - } - } - this.setName(properties.getProperty("irc.nickname")); - this.setVerbose(true); - setupDb(); - - urlPattern = Pattern.compile(URL_REGEX); - } - - /** - * Connect to the server. - * - * @throws IrcException - * @throws IOException - */ - public void connect() throws IrcException, IOException { - log("Connecting to " + properties.getProperty("irc.server")); - attemptConnect(); - } - - protected void onDisconnect() { - if (disconnect) - return; - log("We were disconnected from the server. Trying to reconnect ..."); - try { - attemptConnect(); - } catch (IrcException e) { - log("Reconnect failed. Giving up."); - } - } - - protected void attemptConnect() throws IrcException { - int attempts = 0; - boolean connected = false; - while (!connected) { - ++attempts; - try { - connect(properties.getProperty("irc.server")); - connected = true; - } catch (NickAlreadyInUseException e) { - this.setName(this.getName() + '_'); - } catch (IOException e) { - log("Failed to connect. Reason: " + e.getMessage()); - } - if (attempts == MAX_CONNECT_ATTEMPTS) { - log("Reached max connection attempts. Giving up."); - return; - } - } - log("Join channel: " + properties.getProperty("irc.channel")); - joinChannel(properties.getProperty("irc.channel")); - sendMessage("NickServ", "IDENTIFY " + properties.getProperty("irc.password")); - } - - /** - * Callback method called after a user has joined the channel. - */ - protected void onJoin(String channel, String sender, String login, String hostname) { - try { - String xupdate = - "" + - "" + - ""; - doUpdate(xupdate); - } catch (XMLDBException e) { - log("An error occurred: " + e.getMessage()); - } - } - - - /** - * Callback method: a user has parted. - */ - protected void onPart(String channel, String sender, String login, String hostname) { - try { - String xupdate = - "" + - "" + - ""; - doUpdate(xupdate); - } catch (XMLDBException e) { - log("An error occurred: " + e.getMessage()); - } - } - - /** - * Callback method: a user disconnected from the server. - */ - protected void onQuit(String sourceNick, String sourceLogin, String sourceHostname, String reason) { - try { - String xupdate = - "" + - "" + - ""; - doUpdate(xupdate); - } catch (XMLDBException e) { - log("An error occurred: " + e.getMessage()); - } - } - - /** - * Callback method: a message was sent. - */ - protected void onMessage(String channel, String sender, String login, String hostname, String message) { - try { - String xupdate = - "" + - "" + - "" + - "\n"; - doUpdate(xupdate); - } catch (XMLDBException e) { - log("An error occurred: " + e.getMessage()); - } - } - - /** - * Callback method: a private message has been sent to the bot. Check if it contains a known - * command and execute it. - */ - protected void onPrivateMessage(String sender, String login, String hostname, String message) { - String args[] = message.split("\\s+"); - log("Arguments: " + args.length + "; command: " + args[0]); - boolean recognized = false; - for (int i = 0; i < commands.length; i++) { - if (args[0].equalsIgnoreCase(commands[i].name)) { - // executing command - try { - commands[i].execute(sender, args); - } catch (IrcException e) { - log("An exception occurred while executing command '" + message + "': " + e.getMessage()); - } - recognized = true; - } - } - if (!recognized) { - sendMessage(sender, "Don't know what to respond. Send me a message 'HELP' to see a list of " + - "commands I understand."); - } - } - - /** - * Helper method to xupdate the log file. - * - * @param content - * @throws XMLDBException - */ - private void doUpdate(String content) throws XMLDBException { - String xupdate = - XUPDATE_START + - " \n" + - content + - " \n" + - ""; - log("XUpdate:\n" + xupdate); - XUpdateQueryService service = (XUpdateQueryService) - collection.getService("XUpdateQueryService", "1.0"); - service.update(xupdate); - } - - /** - * Parse a message. Tries to detect URLs in the message and transforms them - * into an HTML link. - * - * @param message - * @return - */ - private String preprocessMessage(String message) { - if (matcher == null) - matcher = urlPattern.matcher(message); - else - matcher.reset(message); - return matcher.replaceAll("]]>$1 cl = Class.forName("org.exist.xmldb.DatabaseImpl"); - Database database = (Database) cl.newInstance(); - database.setProperty("create-database", "true"); - DatabaseManager.registerDatabase(database); - - collection = DatabaseManager.getCollection(properties.getProperty("xmldb.uri") + '/' + properties.getProperty("xmldb.collection"), - properties.getProperty("xmldb.user"), properties.getProperty("xmldb.password")); - - if (collection == null) { - Collection root = DatabaseManager.getCollection(properties.getProperty("xmldb.uri"), - properties.getProperty("xmldb.user"), properties.getProperty("xmldb.password")); - CollectionManagementService mgr = (CollectionManagementService) - root.getService("CollectionManagementService", "1.0"); - UserManagementService umgr = (UserManagementService) - root.getService("UserManagementService", "1.0"); - collection = mgr.createCollection(COLLECTION); - Permission perms = umgr.getPermissions(collection); - perms.setMode(0744); - umgr.setPermissions(collection, perms); - } - } catch (Exception e) { - throw new IrcException("Failed to initialize the database: " + e.getMessage()); - } - } - - /** - * Returns the full database path to the current log document. - * - * @return - * @throws XMLDBException - */ - private String getLogPath() throws XMLDBException { - return "/db/" + COLLECTION + '/' + getCurrentLog(); - } - - /** - * Returns the name of the current log document. If no document - * has been created for today yet, create a new, empty one. - * - * @return - * @throws XMLDBException - */ - private String getCurrentLog() throws XMLDBException { - Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - String date = dateFormat.format(cal.getTime()); - String resourceName = date + ".xlog"; - XMLResource res = (XMLResource) collection.getResource(resourceName); - if (res == null) { - // create a new log for today's date - String xml = - ""; - res = (XMLResource) collection.createResource(resourceName, "XMLResource"); - res.setContent(xml); - collection.storeResource(res); - UserManagementService umgr = (UserManagementService) - collection.getService("UserManagementService", "1.0"); - umgr.setPermissions(res, - PermissionFactory.getPermission( - properties.getProperty("xmldb.user"), - properties.getProperty("xmldb.password"), - 0744)); - } - return resourceName; - } - - /** - * Base class for all commands that can be send in a private message. - * - * @author wolf - * - */ - private abstract class Command { - String name; - String description; - - public Command(String name, String description) { - this.name = name; - this.description = description; - } - - public abstract void execute(String target, String[] args) throws IrcException; - } - - private class HelpCommand extends Command { - - public HelpCommand() { - super("help", "List available commands."); - } - - public void execute(String target, String args[]) throws IrcException { - sendMessage(target, "XBot " + VERSION + " - Available commands:"); - for (int i = 0; i < commands.length; i++) { - sendMessage(target, commands[i].name + "\t\t" + commands[i].description); - } - } - } - - private class QuitCommand extends Command { - - public QuitCommand() { - super("quit", "Disconnect from the server."); - } - - public void execute(String target, String[] args) throws IrcException { - if (args.length < 2) { - sendMessage(target, "Usage: QUIT password"); - return; - } - if (!args[1].equals(properties.getProperty("irc.password"))) { - sendMessage(target, "Wrong password specified!"); - return; - } - disconnect = true; - quitServer("Even a bot needs to rest sometimes..."); - System.exit(0); - } - } - - private class FunctionLookup extends Command { - - public FunctionLookup() { - super("lookup", "Lookup a function definition"); - } - - public void execute(String target, String[] args) throws IrcException { - try { - XPathQueryService service = (XPathQueryService) - collection.getService("XPathQueryService", "1.0"); - ResourceSet result = service.query("util:describe-function('" + args[1] + "')"); - if (result.getSize() == 0) { - sendMessage(target, "Function " + args[1] + " is unknown!"); - return; - } - Node node = ((XMLResource) result.getResource(0)).getContentAsDOM(); - if (node.getNodeType() == Node.DOCUMENT_NODE) - node = ((Document)node).getDocumentElement(); - NodeList children = ((Element)node).getElementsByTagName("prototype"); - for (int i = 0; i < children.getLength(); i++) { - Element elem = (Element) children.item(i); - NodeList nl = elem.getChildNodes(); - for (int j = 0; j < nl.getLength(); j++) { - node = nl.item(j); - if (node.getNodeType() == Node.ELEMENT_NODE) { - if ("signature".equals(node.getLocalName())) { - sendMessage(target, "[signature] " + getNodeValue(node)); - } else if ("description".equals(node.getLocalName())) { - sendMessage(target, "[description] " + getNodeValue(node)); - } - } - } - } - } catch (XMLDBException e) { - sendMessage(target, "An exception occurred: " + e.getMessage()); - } - } - - private String getNodeValue(Node node) { - StringBuffer buf = new StringBuffer(); - node = node.getFirstChild(); - while (node != null) { - buf.append(node.getNodeValue()); - node = node.getNextSibling(); - } - return buf.toString(); - } - } - - /** - * @param args - * @throws IrcException - */ - public static void main(String[] args) throws Exception { - XBot bot = new XBot(); - bot.connect(); - } -} +package org.exist.irc; + +import org.exist.security.Permission; +import org.exist.security.PermissionFactory; +import org.exist.xmldb.UserManagementService; +import org.jibble.pircbot.IrcException; +import org.jibble.pircbot.NickAlreadyInUseException; +import org.jibble.pircbot.PircBot; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xmldb.api.DatabaseManager; +import org.xmldb.api.base.Collection; +import org.xmldb.api.base.Database; +import org.xmldb.api.base.ResourceSet; +import org.xmldb.api.base.XMLDBException; +import org.xmldb.api.modules.CollectionManagementService; +import org.xmldb.api.modules.XMLResource; +import org.xmldb.api.modules.XPathQueryService; +import org.xmldb.api.modules.XUpdateQueryService; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Properties; +import java.util.TimeZone; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Implements a simple IRC drone, which logs IRC events to a collection in an eXist database. + * One log file is created every day. Messages are appended using XUpdate. + * + * @author wolf + * + */ +public class XBot extends PircBot { + + private final static String VERSION = "0.2"; + + private final static String URI = "xmldb:exist://localhost:8080/exist/xmlrpc/db"; + + private final static String COLLECTION = "ircbot"; + + private final static Properties DEFAULTS = new Properties(); + static { + DEFAULTS.setProperty("xmldb.user", "guest"); + DEFAULTS.setProperty("xmldb.password", "guest"); + DEFAULTS.setProperty("xmldb.uri", URI); + DEFAULTS.setProperty("xmldb.collection", COLLECTION); + DEFAULTS.setProperty("irc.server", "irc.freenode.net"); + DEFAULTS.setProperty("irc.channel", "#existdb"); + DEFAULTS.setProperty("irc.nickname", "XDrone"); + DEFAULTS.setProperty("irc.password", ""); + } + + private final static String XUPDATE_START = + "\n" + + " \n"; + + private final static String URL_REGEX = + "((http|ftp)s{0,1}://[\\-\\.\\,/\\%\\~\\=\\@\\_\\&\\:\\?\\#a-zA-Z0-9]*[/\\=\\#a-zA-Z0-9])"; + + private final static int MAX_CONNECT_ATTEMPTS = 50; + + // these commands may be passed in a private message to the bot + private final Command[] commands = { + new HelpCommand(), + new QuitCommand(), + new FunctionLookup() + }; + + private Properties properties = new Properties(DEFAULTS); + + // the base collection + private Collection collection; + + private DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + + private Pattern urlPattern; + private Matcher matcher = null; + + private boolean disconnect = false; + + public XBot() throws IrcException { + super(); + + File f = new File("xbot.properties"); + if (f.canRead()) { + System.out.println("Reading properties file: " + f.getAbsolutePath()); + try { + FileInputStream stream = new FileInputStream(f); + try { + properties.load(stream); + } finally { + stream.close(); + } + } catch (IOException e) { + System.err.println("Failed to load properties: " + e.getMessage()); + } + } + this.setName(properties.getProperty("irc.nickname")); + this.setVerbose(true); + setupDb(); + + urlPattern = Pattern.compile(URL_REGEX); + } + + /** + * Connect to the server. + * + * @throws IrcException + * @throws IOException + */ + public void connect() throws IrcException, IOException { + log("Connecting to " + properties.getProperty("irc.server")); + attemptConnect(); + } + + protected void onDisconnect() { + if (disconnect) + return; + log("We were disconnected from the server. Trying to reconnect ..."); + try { + attemptConnect(); + } catch (IrcException e) { + log("Reconnect failed. Giving up."); + } + } + + protected void attemptConnect() throws IrcException { + int attempts = 0; + boolean connected = false; + while (!connected) { + ++attempts; + try { + connect(properties.getProperty("irc.server")); + connected = true; + } catch (NickAlreadyInUseException e) { + this.setName(this.getName() + '_'); + } catch (IOException e) { + log("Failed to connect. Reason: " + e.getMessage()); + } + if (attempts == MAX_CONNECT_ATTEMPTS) { + log("Reached max connection attempts. Giving up."); + return; + } + } + log("Join channel: " + properties.getProperty("irc.channel")); + joinChannel(properties.getProperty("irc.channel")); + sendMessage("NickServ", "IDENTIFY " + properties.getProperty("irc.password")); + } + + /** + * Callback method called after a user has joined the channel. + */ + protected void onJoin(String channel, String sender, String login, String hostname) { + try { + String xupdate = + "" + + "" + + ""; + doUpdate(xupdate); + } catch (XMLDBException e) { + log("An error occurred: " + e.getMessage()); + } + } + + + /** + * Callback method: a user has parted. + */ + protected void onPart(String channel, String sender, String login, String hostname) { + try { + String xupdate = + "" + + "" + + ""; + doUpdate(xupdate); + } catch (XMLDBException e) { + log("An error occurred: " + e.getMessage()); + } + } + + /** + * Callback method: a user disconnected from the server. + */ + protected void onQuit(String sourceNick, String sourceLogin, String sourceHostname, String reason) { + try { + String xupdate = + "" + + "" + + ""; + doUpdate(xupdate); + } catch (XMLDBException e) { + log("An error occurred: " + e.getMessage()); + } + } + + /** + * Callback method: a message was sent. + */ + protected void onMessage(String channel, String sender, String login, String hostname, String message) { + try { + String xupdate = + "" + + "" + + "" + + "\n"; + doUpdate(xupdate); + } catch (XMLDBException e) { + log("An error occurred: " + e.getMessage()); + } + } + + /** + * Callback method: a private message has been sent to the bot. Check if it contains a known + * command and execute it. + */ + protected void onPrivateMessage(String sender, String login, String hostname, String message) { + String args[] = message.split("\\s+"); + log("Arguments: " + args.length + "; command: " + args[0]); + boolean recognized = false; + for (int i = 0; i < commands.length; i++) { + if (args[0].equalsIgnoreCase(commands[i].name)) { + // executing command + try { + commands[i].execute(sender, args); + } catch (IrcException e) { + log("An exception occurred while executing command '" + message + "': " + e.getMessage()); + } + recognized = true; + } + } + if (!recognized) { + sendMessage(sender, "Don't know what to respond. Send me a message 'HELP' to see a list of " + + "commands I understand."); + } + } + + /** + * Helper method to xupdate the log file. + * + * @param content + * @throws XMLDBException + */ + private void doUpdate(String content) throws XMLDBException { + String xupdate = + XUPDATE_START + + " \n" + + content + + " \n" + + ""; + log("XUpdate:\n" + xupdate); + XUpdateQueryService service = (XUpdateQueryService) + collection.getService("XUpdateQueryService", "1.0"); + service.update(xupdate); + } + + /** + * Parse a message. Tries to detect URLs in the message and transforms them + * into an HTML link. + * + * @param message + * @return + */ + private String preprocessMessage(String message) { + if (matcher == null) + matcher = urlPattern.matcher(message); + else + matcher.reset(message); + return matcher.replaceAll("]]>$1 cl = Class.forName("org.exist.xmldb.DatabaseImpl"); + Database database = (Database) cl.newInstance(); + database.setProperty("create-database", "true"); + DatabaseManager.registerDatabase(database); + + collection = DatabaseManager.getCollection(properties.getProperty("xmldb.uri") + '/' + properties.getProperty("xmldb.collection"), + properties.getProperty("xmldb.user"), properties.getProperty("xmldb.password")); + + if (collection == null) { + Collection root = DatabaseManager.getCollection(properties.getProperty("xmldb.uri"), + properties.getProperty("xmldb.user"), properties.getProperty("xmldb.password")); + CollectionManagementService mgr = (CollectionManagementService) + root.getService("CollectionManagementService", "1.0"); + UserManagementService umgr = (UserManagementService) + root.getService("UserManagementService", "1.0"); + collection = mgr.createCollection(COLLECTION); + Permission perms = umgr.getPermissions(collection); + perms.setMode(0744); + umgr.setPermissions(collection, perms); + } + } catch (Exception e) { + throw new IrcException("Failed to initialize the database: " + e.getMessage()); + } + } + + /** + * Returns the full database path to the current log document. + * + * @return + * @throws XMLDBException + */ + private String getLogPath() throws XMLDBException { + return "/db/" + COLLECTION + '/' + getCurrentLog(); + } + + /** + * Returns the name of the current log document. If no document + * has been created for today yet, create a new, empty one. + * + * @return + * @throws XMLDBException + */ + private String getCurrentLog() throws XMLDBException { + Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + String date = dateFormat.format(cal.getTime()); + String resourceName = date + ".xlog"; + XMLResource res = (XMLResource) collection.getResource(resourceName); + if (res == null) { + // create a new log for today's date + String xml = + ""; + res = (XMLResource) collection.createResource(resourceName, "XMLResource"); + res.setContent(xml); + collection.storeResource(res); + UserManagementService umgr = (UserManagementService) + collection.getService("UserManagementService", "1.0"); + umgr.setPermissions(res, + PermissionFactory.getPermission( + properties.getProperty("xmldb.user"), + properties.getProperty("xmldb.password"), + 0744)); + } + return resourceName; + } + + /** + * Base class for all commands that can be send in a private message. + * + * @author wolf + * + */ + private abstract class Command { + String name; + String description; + + public Command(String name, String description) { + this.name = name; + this.description = description; + } + + public abstract void execute(String target, String[] args) throws IrcException; + } + + private class HelpCommand extends Command { + + public HelpCommand() { + super("help", "List available commands."); + } + + public void execute(String target, String args[]) throws IrcException { + sendMessage(target, "XBot " + VERSION + " - Available commands:"); + for (int i = 0; i < commands.length; i++) { + sendMessage(target, commands[i].name + "\t\t" + commands[i].description); + } + } + } + + private class QuitCommand extends Command { + + public QuitCommand() { + super("quit", "Disconnect from the server."); + } + + public void execute(String target, String[] args) throws IrcException { + if (args.length < 2) { + sendMessage(target, "Usage: QUIT password"); + return; + } + if (!args[1].equals(properties.getProperty("irc.password"))) { + sendMessage(target, "Wrong password specified!"); + return; + } + disconnect = true; + quitServer("Even a bot needs to rest sometimes..."); + System.exit(0); + } + } + + private class FunctionLookup extends Command { + + public FunctionLookup() { + super("lookup", "Lookup a function definition"); + } + + public void execute(String target, String[] args) throws IrcException { + try { + XPathQueryService service = (XPathQueryService) + collection.getService("XPathQueryService", "1.0"); + ResourceSet result = service.query("util:describe-function('" + args[1] + "')"); + if (result.getSize() == 0) { + sendMessage(target, "Function " + args[1] + " is unknown!"); + return; + } + Node node = ((XMLResource) result.getResource(0)).getContentAsDOM(); + if (node.getNodeType() == Node.DOCUMENT_NODE) + node = ((Document)node).getDocumentElement(); + NodeList children = ((Element)node).getElementsByTagName("prototype"); + for (int i = 0; i < children.getLength(); i++) { + Element elem = (Element) children.item(i); + NodeList nl = elem.getChildNodes(); + for (int j = 0; j < nl.getLength(); j++) { + node = nl.item(j); + if (node.getNodeType() == Node.ELEMENT_NODE) { + if ("signature".equals(node.getLocalName())) { + sendMessage(target, "[signature] " + getNodeValue(node)); + } else if ("description".equals(node.getLocalName())) { + sendMessage(target, "[description] " + getNodeValue(node)); + } + } + } + } + } catch (XMLDBException e) { + sendMessage(target, "An exception occurred: " + e.getMessage()); + } + } + + private String getNodeValue(Node node) { + StringBuffer buf = new StringBuffer(); + node = node.getFirstChild(); + while (node != null) { + buf.append(node.getNodeValue()); + node = node.getNextSibling(); + } + return buf.toString(); + } + } + + /** + * @param args + * @throws IrcException + */ + public static void main(String[] args) throws Exception { + XBot bot = new XBot(); + bot.connect(); + } +} diff --git a/tools/ircbot/webapp/WEB-INF/web.xml b/tools/ircbot/webapp/WEB-INF/web.xml index f1cc3b6f780..f2133690073 100644 --- a/tools/ircbot/webapp/WEB-INF/web.xml +++ b/tools/ircbot/webapp/WEB-INF/web.xml @@ -1,28 +1,28 @@ - - - - - eXist IRC Proxy - eXist IRC Proxy - - - - IRCServlet - IRC Proxy Servlet - org.exist.irc.IRCProxy - - - mod-proxy - true - - - - - - IRCServlet - /irc/IRCServlet - - + + + + + eXist IRC Proxy + eXist IRC Proxy + + + + IRCServlet + IRC Proxy Servlet + org.exist.irc.IRCProxy + + + mod-proxy + true + + + + + + IRCServlet + /irc/IRCServlet + + \ No newline at end of file diff --git a/tools/izpack/src/org/exist/izpack/PasswordValidator.java b/tools/izpack/src/org/exist/izpack/PasswordValidator.java index 2d5e4cfb310..6132ab19190 100644 --- a/tools/izpack/src/org/exist/izpack/PasswordValidator.java +++ b/tools/izpack/src/org/exist/izpack/PasswordValidator.java @@ -1,36 +1,36 @@ -/* - * eXist Open Source Native XML Database - * Copyright (C) 2001-07 The eXist Project - * http://exist-db.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * $Id$ - */ -package org.exist.izpack; - -import com.izforge.izpack.panels.ProcessingClient; - -/** - * Code to check if the entered passwords are equal. - */ -public class PasswordValidator implements com.izforge.izpack.panels.Validator { - - public boolean validate(ProcessingClient client) { - String content = client.getFieldContents (0); - String content1 = client.getFieldContents(1); - return content.equals(content1); - } -} +/* + * eXist Open Source Native XML Database + * Copyright (C) 2001-07 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.izpack; + +import com.izforge.izpack.panels.ProcessingClient; + +/** + * Code to check if the entered passwords are equal. + */ +public class PasswordValidator implements com.izforge.izpack.panels.Validator { + + public boolean validate(ProcessingClient client) { + String content = client.getFieldContents (0); + String content1 = client.getFieldContents(1); + return content.equals(content1); + } +} diff --git a/tools/rulesets/basic.xml b/tools/rulesets/basic.xml index f90d91422ff..e9992aa185c 100644 --- a/tools/rulesets/basic.xml +++ b/tools/rulesets/basic.xml @@ -1,1003 +1,1003 @@ - - - - -The Basic Ruleset contains a collection of good practices which everyone should follow. - - - - - -Empty Catch Block finds instances where an exception is caught, -but nothing is done. In most circumstances, this swallows an exception -which should either be acted on or reported. - - - - - - - - - false - - - 3 - - - - - - - -Empty If Statement finds instances where a condition is checked but nothing is done about it. - - 3 - - - - - - - - - - - - - - - -Empty While Statement finds all instances where a while statement -does nothing. If it is a timing loop, then you should use Thread.sleep() for it; if -it's a while loop that does a lot in the exit expression, rewrite it to make it clearer. - - - - - - - - - 3 - - - - - - - - - -Avoid empty try blocks - what's the point? - - - - - - - - - 3 - - - - - - - - -Avoid empty finally blocks - these can be deleted. - - - - - - - - - 3 - - - - - - - - - -Avoid empty switch statements. - - - - - - - - - 3 - - - - - - - - - -Avoid jumbled loop incrementers - it's usually a mistake, and it's confusing even if it's what's intended. - - - - - - - - - 3 - - - - - - - -Some for loops can be simplified to while loops - this makes them more concise. - - - - - 1] - [not(ForInit)] - [not(ForUpdate)] - [not(Type and Expression and Statement)] - ]]> - - - - 3 - - - - - - - - -Avoid unnecessary temporaries when converting primitives to Strings - - 3 - - - - - - - -Override both public boolean Object.equals(Object other), and public int Object.hashCode(), or override neither. Even if you are inheriting a hashCode() from a parent class, consider implementing hashCode and explicitly delegating to your superclass. - - - - - - - - - 3 - - - - - - - - -Partially created objects can be returned by the Double Checked Locking pattern when used in Java. -An optimizing JRE may assign a reference to the baz variable before it creates the object the - reference is intended to point to. For more details see http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-double.html. - - 1 - - - - - - - -Avoid returning from a finally block - this can discard exceptions. - - - - - - - - - 3 - - - - - - - - - Avoid empty synchronized blocks - they're useless. - - - - - - - - - 3 - - - - - - - - -Avoid unnecessary return statements - - - - - - - - - 3 - - - - - - - - -An empty static initializer was found. - - - - - - - - - 3 - - - - - - - -Do not use "if" statements that are always true or always false. - - - - - - - - - 3 - - - - - - - -An empty statement (aka a semicolon by itself) that is not used -as the sole body of a for loop or while loop is probably a bug. It -could also be a double semicolon, which is useless and should be -removed. - - - - - - - - - 3 - - - - - - - -Avoid instantiating Boolean objects, instead use the constants Boolean.TRUE or Boolean.FALSE. - - - - - - - - - 2 - - - - - - - -When a class has the final modifier, all the methods are automatically final. - - - - - - - - - 3 - - - - - - - - -Sometimes two 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator. - - - - - - - - - 3 - - - - - - - -The overriding method merely calls the same method defined in a superclass - - 3 - - - - - - -if you need to get an array of a class from your Collection, -you should pass an array of the desidered class -as the parameter of the toArray method. Otherwise you will get a -ClassCastException. - - - - - - - - - 3 - - - - - - - - - One might assume that "new BigDecimal(.1)" is exactly equal - to .1, but it is actually equal - to .1000000000000000055511151231257827021181583404541015625. - This is so because .1 cannot be represented exactly as a double - (or, for that matter, as a binary fraction of any finite length). - Thus, the long value that is being passed in to the constructor - is not exactly equal to .1, appearances notwithstanding. - - The (String) constructor, on the other hand, is perfectly predictable: - 'new BigDecimal(".1")' is exactly equal to .1, as one - would expect. Therefore, it is generally recommended that the (String) - constructor be used in preference to this one. - - - - - - - - - 3 - - - - - - - - - An operation on an Immutable object (BigDecimal or BigInteger) won't change the object itself. The - result of the operation is a new object. Therefore, ignoring the operation result is an error. - - - - - - - - - 3 - - - - - - - - The null check here is misplaced. if the variable is null you'll get a NullPointerException. - Either the check is useless (the variable will never be "null") or it's incorrect. - - - - - - - - - 3 - - - - - - - - After checking an object reference for null, you should invoke equals() on that object rather than passing it to another object's equals() method. - - - - - - - - -3 - - - - - - - + + + + +The Basic Ruleset contains a collection of good practices which everyone should follow. + + + + + +Empty Catch Block finds instances where an exception is caught, +but nothing is done. In most circumstances, this swallows an exception +which should either be acted on or reported. + + + + + + + + + false + + + 3 + + + + + + + +Empty If Statement finds instances where a condition is checked but nothing is done about it. + + 3 + + + + + + + + + + + + + + + +Empty While Statement finds all instances where a while statement +does nothing. If it is a timing loop, then you should use Thread.sleep() for it; if +it's a while loop that does a lot in the exit expression, rewrite it to make it clearer. + + + + + + + + + 3 + + + + + + + + + +Avoid empty try blocks - what's the point? + + + + + + + + + 3 + + + + + + + + +Avoid empty finally blocks - these can be deleted. + + + + + + + + + 3 + + + + + + + + + +Avoid empty switch statements. + + + + + + + + + 3 + + + + + + + + + +Avoid jumbled loop incrementers - it's usually a mistake, and it's confusing even if it's what's intended. + + + + + + + + + 3 + + + + + + + +Some for loops can be simplified to while loops - this makes them more concise. + + + + + 1] + [not(ForInit)] + [not(ForUpdate)] + [not(Type and Expression and Statement)] + ]]> + + + + 3 + + + + + + + + +Avoid unnecessary temporaries when converting primitives to Strings + + 3 + + + + + + + +Override both public boolean Object.equals(Object other), and public int Object.hashCode(), or override neither. Even if you are inheriting a hashCode() from a parent class, consider implementing hashCode and explicitly delegating to your superclass. + + + + + + + + + 3 + + + + + + + + +Partially created objects can be returned by the Double Checked Locking pattern when used in Java. +An optimizing JRE may assign a reference to the baz variable before it creates the object the + reference is intended to point to. For more details see http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-double.html. + + 1 + + + + + + + +Avoid returning from a finally block - this can discard exceptions. + + + + + + + + + 3 + + + + + + + + + Avoid empty synchronized blocks - they're useless. + + + + + + + + + 3 + + + + + + + + +Avoid unnecessary return statements + + + + + + + + + 3 + + + + + + + + +An empty static initializer was found. + + + + + + + + + 3 + + + + + + + +Do not use "if" statements that are always true or always false. + + + + + + + + + 3 + + + + + + + +An empty statement (aka a semicolon by itself) that is not used +as the sole body of a for loop or while loop is probably a bug. It +could also be a double semicolon, which is useless and should be +removed. + + + + + + + + + 3 + + + + + + + +Avoid instantiating Boolean objects, instead use the constants Boolean.TRUE or Boolean.FALSE. + + + + + + + + + 2 + + + + + + + +When a class has the final modifier, all the methods are automatically final. + + + + + + + + + 3 + + + + + + + + +Sometimes two 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator. + + + + + + + + + 3 + + + + + + + +The overriding method merely calls the same method defined in a superclass + + 3 + + + + + + +if you need to get an array of a class from your Collection, +you should pass an array of the desidered class +as the parameter of the toArray method. Otherwise you will get a +ClassCastException. + + + + + + + + + 3 + + + + + + + + + One might assume that "new BigDecimal(.1)" is exactly equal + to .1, but it is actually equal + to .1000000000000000055511151231257827021181583404541015625. + This is so because .1 cannot be represented exactly as a double + (or, for that matter, as a binary fraction of any finite length). + Thus, the long value that is being passed in to the constructor + is not exactly equal to .1, appearances notwithstanding. + + The (String) constructor, on the other hand, is perfectly predictable: + 'new BigDecimal(".1")' is exactly equal to .1, as one + would expect. Therefore, it is generally recommended that the (String) + constructor be used in preference to this one. + + + + + + + + + 3 + + + + + + + + + An operation on an Immutable object (BigDecimal or BigInteger) won't change the object itself. The + result of the operation is a new object. Therefore, ignoring the operation result is an error. + + + + + + + + + 3 + + + + + + + + The null check here is misplaced. if the variable is null you'll get a NullPointerException. + Either the check is useless (the variable will never be "null") or it's incorrect. + + + + + + + + + 3 + + + + + + + + After checking an object reference for null, you should invoke equals() on that object rather than passing it to another object's equals() method. + + + + + + + + +3 + + + + + + + diff --git a/tools/rulesets/migrating.xml b/tools/rulesets/migrating.xml index 14d414a1e92..852a28ed00e 100644 --- a/tools/rulesets/migrating.xml +++ b/tools/rulesets/migrating.xml @@ -1,178 +1,178 @@ - - - - -Contains rules about migrating from one JDK version to another. Don't use these rules directly, - rather, use a wrapper ruleset such as migrating_to_13.xml. - - - - - Consider replacing this Vector with the newer java.util.List - - - - - - - - - 3 - - - - - - - - Consider replacing this Hashtable with the newer java.util.Map - - - - - - - - - 3 - - - - - - - - Consider replacing this Enumeration with the newer java.util.Iterator - - - - - - - - - 3 - - - - - - - Finds all places 'enum' is used as an identifier is used - - - - - - - - 2 - - - - - - - Finds all places 'assert' is used as an identifier is used - - - - - - - - 2 - - - - - - - In JDK 1.5, calling new Integer() causes memory allocation. Integer.valueOf() is more memory friendly. - - - - - - - - 2 - - - - - - - + + + + +Contains rules about migrating from one JDK version to another. Don't use these rules directly, + rather, use a wrapper ruleset such as migrating_to_13.xml. + + + + + Consider replacing this Vector with the newer java.util.List + + + + + + + + + 3 + + + + + + + + Consider replacing this Hashtable with the newer java.util.Map + + + + + + + + + 3 + + + + + + + + Consider replacing this Enumeration with the newer java.util.Iterator + + + + + + + + + 3 + + + + + + + Finds all places 'enum' is used as an identifier is used + + + + + + + + 2 + + + + + + + Finds all places 'assert' is used as an identifier is used + + + + + + + + 2 + + + + + + + In JDK 1.5, calling new Integer() causes memory allocation. Integer.valueOf() is more memory friendly. + + + + + + + + 2 + + + + + + + diff --git a/tools/rulesets/optimizations.xml b/tools/rulesets/optimizations.xml index 16cbdc3ac3b..3b8c7d7a8c0 100644 --- a/tools/rulesets/optimizations.xml +++ b/tools/rulesets/optimizations.xml @@ -1,313 +1,313 @@ - - - - -These rules deal with different optimizations that generally apply to performance best practices. - - - - - - -ArrayList is a much better Collection implementation than Vector. - - - - - - - - - 3 - - - - - - - -Since it passes in a literal of length 1, this call to String.startsWith can be rewritten using String.charAt(0) to save some time. - - - - - - - - - 3 - - - - - - - -Finds usages of += for appending strings. - - - - - - - - - 3 - - - - - - - - The class java.util.Arrays has a "asList" method that - should be use when you want to create a new List from - an array of objects. It is faster than executing a loop to - cpy all the elements of the array one by one - - - - - - - - - 3 - - - - - - - - - Instead of copying data between two arrays, use - System.arrayCopy method - - - - - - - - - 3 - - - - - - - - - - - - - - + + + + +These rules deal with different optimizations that generally apply to performance best practices. + + + + + + +ArrayList is a much better Collection implementation than Vector. + + + + + + + + + 3 + + + + + + + +Since it passes in a literal of length 1, this call to String.startsWith can be rewritten using String.charAt(0) to save some time. + + + + + + + + + 3 + + + + + + + +Finds usages of += for appending strings. + + + + + + + + + 3 + + + + + + + + The class java.util.Arrays has a "asList" method that + should be use when you want to create a new List from + an array of objects. It is faster than executing a loop to + cpy all the elements of the array one by one + + + + + + + + + 3 + + + + + + + + + Instead of copying data between two arrays, use + System.arrayCopy method + + + + + + + + + 3 + + + + + + + + + + + + + + diff --git a/tools/rulesets/scratchpad.xml b/tools/rulesets/scratchpad.xml index 37c6e6b5c1e..19c1066f1db 100644 --- a/tools/rulesets/scratchpad.xml +++ b/tools/rulesets/scratchpad.xml @@ -1,94 +1,94 @@ - - - - -These are new rules that are still in progress - - - - - -Avoid unnecessarily creating local variables - - 3 - - - - - - - - - - - + + + + +These are new rules that are still in progress + + + + + +Avoid unnecessarily creating local variables + + 3 + + + + + + + + + + + diff --git a/tools/wrapper/bin/exist.bat b/tools/wrapper/bin/exist.bat index 69752e2e0a8..28deb76b062 100644 --- a/tools/wrapper/bin/exist.bat +++ b/tools/wrapper/bin/exist.bat @@ -1,135 +1,135 @@ -@echo off -setlocal - -rem -rem Copyright (c) 1999, 2013 Tanuki Software, Ltd. -rem http://www.tanukisoftware.com -rem All rights reserved. -rem -rem This software is the proprietary information of Tanuki Software. -rem You shall use it only in accordance with the terms of the -rem license agreement you entered into with Tanuki Software. -rem http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html -rem -rem Java Service Wrapper general passthrough startup script. -rem -rem ----------------------------------------------------------------------------- -rem These settings can be modified to fit the needs of your application -rem Optimized for use with version 3.5.23 of the Wrapper. - -rem The base name for the Wrapper binary. -set _WRAPPER_BASE=wrapper - -rem The directory where the Wrapper binary (.exe) file is located, this can be -rem either a absolute or relative path. If the path contains any special characters, -rem please make sure to quote the variable. -set _WRAPPER_DIR= - -rem The name and location of the Wrapper configuration file. This will be used -rem if the user does not specify a configuration file as the first parameter to -rem this script. It will not be possible to specify a configuration file on the -rem command line if _PASS_THROUGH is set. -rem If a relative path is specified, please note that the location is based on the -rem location. -set _WRAPPER_CONF_DEFAULT=../conf/wrapper.conf - -rem Makes it possible to override the Wrapper configuration file by specifying it -rem as the first parameter. -rem set _WRAPPER_CONF_OVERRIDE=true - -rem _PASS_THROUGH tells the script to pass all parameters through to the JVM as -rem is. -rem set _PASS_THROUGH=true - -rem Do not modify anything beyond this point -rem ----------------------------------------------------------------------------- - -rem -rem Resolve the real path of the wrapper.exe -rem For non NT systems, the _REALPATH and _WRAPPER_CONF values -rem can be hard-coded below and the following test removed. -rem -if "%OS%"=="Windows_NT" goto nt -echo This script only works with NT-based versions of Windows. -goto :eof - -:nt -rem Find the application home. -rem if no path path specified do the default action -IF not DEFINED _WRAPPER_DIR goto dir_undefined -set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR:"=%" -if not "%_WRAPPER_DIR:~-2,1%" == "\" set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR_QUOTED:"=%\" -rem check if absolute path -if "%_WRAPPER_DIR_QUOTED:~2,1%" == ":" goto absolute_path -if "%_WRAPPER_DIR_QUOTED:~1,1%" == "\" goto absolute_path -rem everythig else means relative path -set _REALPATH="%~dp0%_WRAPPER_DIR_QUOTED:"=%" -goto pathfound - -:dir_undefined -rem Use a relative path to the wrapper %~dp0 is location of current script under NT -set _REALPATH="%~dp0" -goto pathfound -:absolute_path -rem Use an absolute path to the wrapper -set _REALPATH="%_WRAPPER_DIR_QUOTED:"=%" - -:pathfound -rem -rem Decide on the specific Wrapper binary to use (See delta-pack) -rem -if "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto amd64 -if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto amd64 -if "%PROCESSOR_ARCHITECTURE%"=="IA64" goto ia64 -set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-32.exe" -goto search -:amd64 -set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-64.exe" -goto search -:ia64 -set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-ia-64.exe" -goto search -:search -set _WRAPPER_EXE="%_WRAPPER_L_EXE:"=%" -if exist %_WRAPPER_EXE% goto conf -set _WRAPPER_EXE="%_REALPATH:"=%%_WRAPPER_BASE%.exe" -if exist %_WRAPPER_EXE% goto conf -echo Unable to locate a Wrapper executable using any of the following names: -echo %_WRAPPER_L_EXE% -echo %_WRAPPER_EXE% -pause -goto :eof - -rem -rem Find the wrapper.conf -rem -:conf -if not [%_WRAPPER_CONF_OVERRIDE%]==[] ( - set _WRAPPER_CONF="%~f1" - if not [%_WRAPPER_CONF%]==[""] ( - shift - goto :startup - ) -) -set _WRAPPER_CONF="%_WRAPPER_CONF_DEFAULT:"=%" - -rem -rem Start the Wrapper -rem -:startup - -rem Collect an parameters -:parameters -set _PARAMETERS=%_PARAMETERS% %1 -shift -if not [%1]==[] goto :parameters - -if [%_PASS_THROUGH%]==[] ( - %_WRAPPER_EXE% -c %_WRAPPER_CONF% -) else ( - %_WRAPPER_EXE% -c %_WRAPPER_CONF% -- %_PARAMETERS% -) -if not errorlevel 1 goto :eof -pause - - +@echo off +setlocal + +rem +rem Copyright (c) 1999, 2013 Tanuki Software, Ltd. +rem http://www.tanukisoftware.com +rem All rights reserved. +rem +rem This software is the proprietary information of Tanuki Software. +rem You shall use it only in accordance with the terms of the +rem license agreement you entered into with Tanuki Software. +rem http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html +rem +rem Java Service Wrapper general passthrough startup script. +rem +rem ----------------------------------------------------------------------------- +rem These settings can be modified to fit the needs of your application +rem Optimized for use with version 3.5.23 of the Wrapper. + +rem The base name for the Wrapper binary. +set _WRAPPER_BASE=wrapper + +rem The directory where the Wrapper binary (.exe) file is located, this can be +rem either a absolute or relative path. If the path contains any special characters, +rem please make sure to quote the variable. +set _WRAPPER_DIR= + +rem The name and location of the Wrapper configuration file. This will be used +rem if the user does not specify a configuration file as the first parameter to +rem this script. It will not be possible to specify a configuration file on the +rem command line if _PASS_THROUGH is set. +rem If a relative path is specified, please note that the location is based on the +rem location. +set _WRAPPER_CONF_DEFAULT=../conf/wrapper.conf + +rem Makes it possible to override the Wrapper configuration file by specifying it +rem as the first parameter. +rem set _WRAPPER_CONF_OVERRIDE=true + +rem _PASS_THROUGH tells the script to pass all parameters through to the JVM as +rem is. +rem set _PASS_THROUGH=true + +rem Do not modify anything beyond this point +rem ----------------------------------------------------------------------------- + +rem +rem Resolve the real path of the wrapper.exe +rem For non NT systems, the _REALPATH and _WRAPPER_CONF values +rem can be hard-coded below and the following test removed. +rem +if "%OS%"=="Windows_NT" goto nt +echo This script only works with NT-based versions of Windows. +goto :eof + +:nt +rem Find the application home. +rem if no path path specified do the default action +IF not DEFINED _WRAPPER_DIR goto dir_undefined +set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR:"=%" +if not "%_WRAPPER_DIR:~-2,1%" == "\" set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR_QUOTED:"=%\" +rem check if absolute path +if "%_WRAPPER_DIR_QUOTED:~2,1%" == ":" goto absolute_path +if "%_WRAPPER_DIR_QUOTED:~1,1%" == "\" goto absolute_path +rem everythig else means relative path +set _REALPATH="%~dp0%_WRAPPER_DIR_QUOTED:"=%" +goto pathfound + +:dir_undefined +rem Use a relative path to the wrapper %~dp0 is location of current script under NT +set _REALPATH="%~dp0" +goto pathfound +:absolute_path +rem Use an absolute path to the wrapper +set _REALPATH="%_WRAPPER_DIR_QUOTED:"=%" + +:pathfound +rem +rem Decide on the specific Wrapper binary to use (See delta-pack) +rem +if "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="IA64" goto ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-32.exe" +goto search +:amd64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-64.exe" +goto search +:ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-ia-64.exe" +goto search +:search +set _WRAPPER_EXE="%_WRAPPER_L_EXE:"=%" +if exist %_WRAPPER_EXE% goto conf +set _WRAPPER_EXE="%_REALPATH:"=%%_WRAPPER_BASE%.exe" +if exist %_WRAPPER_EXE% goto conf +echo Unable to locate a Wrapper executable using any of the following names: +echo %_WRAPPER_L_EXE% +echo %_WRAPPER_EXE% +pause +goto :eof + +rem +rem Find the wrapper.conf +rem +:conf +if not [%_WRAPPER_CONF_OVERRIDE%]==[] ( + set _WRAPPER_CONF="%~f1" + if not [%_WRAPPER_CONF%]==[""] ( + shift + goto :startup + ) +) +set _WRAPPER_CONF="%_WRAPPER_CONF_DEFAULT:"=%" + +rem +rem Start the Wrapper +rem +:startup + +rem Collect an parameters +:parameters +set _PARAMETERS=%_PARAMETERS% %1 +shift +if not [%1]==[] goto :parameters + +if [%_PASS_THROUGH%]==[] ( + %_WRAPPER_EXE% -c %_WRAPPER_CONF% +) else ( + %_WRAPPER_EXE% -c %_WRAPPER_CONF% -- %_PARAMETERS% +) +if not errorlevel 1 goto :eof +pause + + diff --git a/tools/wrapper/bin/install.bat b/tools/wrapper/bin/install.bat index 373c9503ce1..ea5aa27cd86 100644 --- a/tools/wrapper/bin/install.bat +++ b/tools/wrapper/bin/install.bat @@ -1,135 +1,135 @@ -@echo off -setlocal - -rem -rem Copyright (c) 1999, 2013 Tanuki Software, Ltd. -rem http://www.tanukisoftware.com -rem All rights reserved. -rem -rem This software is the proprietary information of Tanuki Software. -rem You shall use it only in accordance with the terms of the -rem license agreement you entered into with Tanuki Software. -rem http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html -rem -rem Java Service Wrapper general passthrough startup script. -rem -rem ----------------------------------------------------------------------------- -rem These settings can be modified to fit the needs of your application -rem Optimized for use with version 3.5.23 of the Wrapper. - -rem The base name for the Wrapper binary. -set _WRAPPER_BASE=wrapper - -rem The directory where the Wrapper binary (.exe) file is located, this can be -rem either a absolute or relative path. If the path contains any special characters, -rem please make sure to quote the variable. -set _WRAPPER_DIR= - -rem The name and location of the Wrapper configuration file. This will be used -rem if the user does not specify a configuration file as the first parameter to -rem this script. It will not be possible to specify a configuration file on the -rem command line if _PASS_THROUGH is set. -rem If a relative path is specified, please note that the location is based on the -rem location. -set _WRAPPER_CONF_DEFAULT="../conf/%_WRAPPER_BASE%.conf" - -rem Makes it possible to override the Wrapper configuration file by specifying it -rem as the first parameter. -rem set _WRAPPER_CONF_OVERRIDE=true - -rem _PASS_THROUGH tells the script to pass all parameters through to the JVM as -rem is. -set _PASS_THROUGH=true - -rem Do not modify anything beyond this point -rem ----------------------------------------------------------------------------- - -rem -rem Resolve the real path of the wrapper.exe -rem For non NT systems, the _REALPATH and _WRAPPER_CONF values -rem can be hard-coded below and the following test removed. -rem -if "%OS%"=="Windows_NT" goto nt -echo This script only works with NT-based versions of Windows. -goto :eof - -:nt -rem Find the application home. -rem if no path path specified do the default action -IF not DEFINED _WRAPPER_DIR goto dir_undefined -set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR:"=%" -if not "%_WRAPPER_DIR:~-2,1%" == "\" set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR_QUOTED:"=%\" -rem check if absolute path -if "%_WRAPPER_DIR_QUOTED:~2,1%" == ":" goto absolute_path -if "%_WRAPPER_DIR_QUOTED:~1,1%" == "\" goto absolute_path -rem everythig else means relative path -set _REALPATH="%~dp0%_WRAPPER_DIR_QUOTED:"=%" -goto pathfound - -:dir_undefined -rem Use a relative path to the wrapper %~dp0 is location of current script under NT -set _REALPATH="%~dp0" -goto pathfound -:absolute_path -rem Use an absolute path to the wrapper -set _REALPATH="%_WRAPPER_DIR_QUOTED:"=%" - -:pathfound -rem -rem Decide on the specific Wrapper binary to use (See delta-pack) -rem -if "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto amd64 -if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto amd64 -if "%PROCESSOR_ARCHITECTURE%"=="IA64" goto ia64 -set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-32.exe" -goto search -:amd64 -set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-64.exe" -goto search -:ia64 -set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-ia-64.exe" -goto search -:search -set _WRAPPER_EXE="%_WRAPPER_L_EXE:"=%" -if exist %_WRAPPER_EXE% goto conf -set _WRAPPER_EXE="%_REALPATH:"=%%_WRAPPER_BASE%.exe" -if exist %_WRAPPER_EXE% goto conf -echo Unable to locate a Wrapper executable using any of the following names: -echo %_WRAPPER_L_EXE% -echo %_WRAPPER_EXE% -pause -goto :eof - -rem -rem Find the wrapper.conf -rem -:conf -if not [%_WRAPPER_CONF_OVERRIDE%]==[] ( - set _WRAPPER_CONF="%~f1" - if not [%_WRAPPER_CONF%]==[""] ( - shift - goto :startup - ) -) -set _WRAPPER_CONF="%_WRAPPER_CONF_DEFAULT:"=%" - -rem -rem Start the Wrapper -rem -:startup - -rem Collect an parameters -:parameters -set _PARAMETERS=%_PARAMETERS% %1 -shift -if not [%1]==[] goto :parameters - -if [%_PASS_THROUGH%]==[] ( - %_WRAPPER_EXE% -i %_WRAPPER_CONF% -) else ( - %_WRAPPER_EXE% -i %_WRAPPER_CONF% -- %_PARAMETERS% -) -if not errorlevel 1 goto :eof -pause - - +@echo off +setlocal + +rem +rem Copyright (c) 1999, 2013 Tanuki Software, Ltd. +rem http://www.tanukisoftware.com +rem All rights reserved. +rem +rem This software is the proprietary information of Tanuki Software. +rem You shall use it only in accordance with the terms of the +rem license agreement you entered into with Tanuki Software. +rem http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html +rem +rem Java Service Wrapper general passthrough startup script. +rem +rem ----------------------------------------------------------------------------- +rem These settings can be modified to fit the needs of your application +rem Optimized for use with version 3.5.23 of the Wrapper. + +rem The base name for the Wrapper binary. +set _WRAPPER_BASE=wrapper + +rem The directory where the Wrapper binary (.exe) file is located, this can be +rem either a absolute or relative path. If the path contains any special characters, +rem please make sure to quote the variable. +set _WRAPPER_DIR= + +rem The name and location of the Wrapper configuration file. This will be used +rem if the user does not specify a configuration file as the first parameter to +rem this script. It will not be possible to specify a configuration file on the +rem command line if _PASS_THROUGH is set. +rem If a relative path is specified, please note that the location is based on the +rem location. +set _WRAPPER_CONF_DEFAULT="../conf/%_WRAPPER_BASE%.conf" + +rem Makes it possible to override the Wrapper configuration file by specifying it +rem as the first parameter. +rem set _WRAPPER_CONF_OVERRIDE=true + +rem _PASS_THROUGH tells the script to pass all parameters through to the JVM as +rem is. +set _PASS_THROUGH=true + +rem Do not modify anything beyond this point +rem ----------------------------------------------------------------------------- + +rem +rem Resolve the real path of the wrapper.exe +rem For non NT systems, the _REALPATH and _WRAPPER_CONF values +rem can be hard-coded below and the following test removed. +rem +if "%OS%"=="Windows_NT" goto nt +echo This script only works with NT-based versions of Windows. +goto :eof + +:nt +rem Find the application home. +rem if no path path specified do the default action +IF not DEFINED _WRAPPER_DIR goto dir_undefined +set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR:"=%" +if not "%_WRAPPER_DIR:~-2,1%" == "\" set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR_QUOTED:"=%\" +rem check if absolute path +if "%_WRAPPER_DIR_QUOTED:~2,1%" == ":" goto absolute_path +if "%_WRAPPER_DIR_QUOTED:~1,1%" == "\" goto absolute_path +rem everythig else means relative path +set _REALPATH="%~dp0%_WRAPPER_DIR_QUOTED:"=%" +goto pathfound + +:dir_undefined +rem Use a relative path to the wrapper %~dp0 is location of current script under NT +set _REALPATH="%~dp0" +goto pathfound +:absolute_path +rem Use an absolute path to the wrapper +set _REALPATH="%_WRAPPER_DIR_QUOTED:"=%" + +:pathfound +rem +rem Decide on the specific Wrapper binary to use (See delta-pack) +rem +if "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="IA64" goto ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-32.exe" +goto search +:amd64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-64.exe" +goto search +:ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-ia-64.exe" +goto search +:search +set _WRAPPER_EXE="%_WRAPPER_L_EXE:"=%" +if exist %_WRAPPER_EXE% goto conf +set _WRAPPER_EXE="%_REALPATH:"=%%_WRAPPER_BASE%.exe" +if exist %_WRAPPER_EXE% goto conf +echo Unable to locate a Wrapper executable using any of the following names: +echo %_WRAPPER_L_EXE% +echo %_WRAPPER_EXE% +pause +goto :eof + +rem +rem Find the wrapper.conf +rem +:conf +if not [%_WRAPPER_CONF_OVERRIDE%]==[] ( + set _WRAPPER_CONF="%~f1" + if not [%_WRAPPER_CONF%]==[""] ( + shift + goto :startup + ) +) +set _WRAPPER_CONF="%_WRAPPER_CONF_DEFAULT:"=%" + +rem +rem Start the Wrapper +rem +:startup + +rem Collect an parameters +:parameters +set _PARAMETERS=%_PARAMETERS% %1 +shift +if not [%1]==[] goto :parameters + +if [%_PASS_THROUGH%]==[] ( + %_WRAPPER_EXE% -i %_WRAPPER_CONF% +) else ( + %_WRAPPER_EXE% -i %_WRAPPER_CONF% -- %_PARAMETERS% +) +if not errorlevel 1 goto :eof +pause + + diff --git a/tools/wrapper/bin/uninstall.bat b/tools/wrapper/bin/uninstall.bat index 2ffadc9cfac..ba4af9212da 100644 --- a/tools/wrapper/bin/uninstall.bat +++ b/tools/wrapper/bin/uninstall.bat @@ -1,133 +1,133 @@ -@echo off -setlocal - -rem -rem Copyright (c) 1999, 2013 Tanuki Software, Ltd. -rem http://www.tanukisoftware.com -rem All rights reserved. -rem -rem This software is the proprietary information of Tanuki Software. -rem You shall use it only in accordance with the terms of the -rem license agreement you entered into with Tanuki Software. -rem http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html -rem -rem Java Service Wrapper general startup script. -rem - -rem ----------------------------------------------------------------------------- -rem These settings can be modified to fit the needs of your application -rem Optimized for use with version 3.5.23 of the Wrapper. - -rem The base name for the Wrapper binary. -set _WRAPPER_BASE=wrapper - -rem The directory where the Wrapper binary (.exe) file is located, this can be -rem either a absolute or relative path. If the path contains any special characters, -rem please make sure to quote the variable. -set _WRAPPER_DIR= - -rem The name and location of the Wrapper configuration file. This will be used -rem if the user does not specify a configuration file as the first parameter to -rem this script. It will not be possible to specify a configuration file on the -rem command line if _PASS_THROUGH is set. -rem If a relative path is specified, please note that the location is based on the -rem location. -set _WRAPPER_CONF_DEFAULT="../conf/%_WRAPPER_BASE%.conf" - -rem Makes it possible to override the Wrapper configuration file by specifying it -rem as the first parameter. -rem set _WRAPPER_CONF_OVERRIDE=true - -rem Note that it is only possible to pass parameters through to the JVM when -rem installing the service, or when running in a console. - -rem Do not modify anything beyond this point -rem ----------------------------------------------------------------------------- - -rem -rem Resolve the real path of the wrapper.exe -rem For non NT systems, the _REALPATH and _WRAPPER_CONF values -rem can be hard-coded below and the following test removed. -rem -if "%OS%"=="Windows_NT" goto nt -echo This script only works with NT-based versions of Windows. -goto :eof - -:nt -rem Find the application home. -rem if no path path specified do the default action -IF not DEFINED _WRAPPER_DIR goto dir_undefined -set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR:"=%" -if not "%_WRAPPER_DIR:~-2,1%" == "\" set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR_QUOTED:"=%\" -rem check if absolute path -if "%_WRAPPER_DIR_QUOTED:~2,1%" == ":" goto absolute_path -if "%_WRAPPER_DIR_QUOTED:~1,1%" == "\" goto absolute_path -rem everythig else means relative path -set _REALPATH="%~dp0%_WRAPPER_DIR_QUOTED:"=%" -goto pathfound - -:dir_undefined -rem Use a relative path to the wrapper %~dp0 is location of current script under NT -set _REALPATH="%~dp0" -goto pathfound -:absolute_path -rem Use an absolute path to the wrapper -set _REALPATH="%_WRAPPER_DIR_QUOTED:"=%" - -:pathfound -rem -rem Decide on the specific Wrapper binary to use (See delta-pack) -rem -if "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto amd64 -if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto amd64 -if "%PROCESSOR_ARCHITECTURE%"=="IA64" goto ia64 -set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-32.exe" -goto search -:amd64 -set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-64.exe" -goto search -:ia64 -set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-ia-64.exe" -goto search -:search -set _WRAPPER_EXE="%_WRAPPER_L_EXE:"=%" -if exist %_WRAPPER_EXE% goto conf -set _WRAPPER_EXE="%_REALPATH:"=%%_WRAPPER_BASE%.exe" -if exist %_WRAPPER_EXE% goto conf -echo Unable to locate a Wrapper executable using any of the following names: -echo %_WRAPPER_L_EXE% -echo %_WRAPPER_EXE% -pause -goto :eof - -rem -rem Find the wrapper.conf -rem -:conf -if not [%_WRAPPER_CONF_OVERRIDE%]==[] ( - set _WRAPPER_CONF="%~f1" - if not [%_WRAPPER_CONF%]==[""] ( - shift - goto :startup - ) -) -set _WRAPPER_CONF="%_WRAPPER_CONF_DEFAULT:"=%" - -rem -rem Start the Wrapper -rem -:startup - -rem Collect an parameters -:parameters -set _PARAMETERS=%_PARAMETERS% %1 -shift -if not [%1]==[] goto :parameters - -if [%_PASS_THROUGH%]==[] ( - %_WRAPPER_EXE% -r %_WRAPPER_CONF% -) else ( - %_WRAPPER_EXE% -r %_WRAPPER_CONF% -- %_PARAMETERS% -) -if not errorlevel 1 goto :eof -pause +@echo off +setlocal + +rem +rem Copyright (c) 1999, 2013 Tanuki Software, Ltd. +rem http://www.tanukisoftware.com +rem All rights reserved. +rem +rem This software is the proprietary information of Tanuki Software. +rem You shall use it only in accordance with the terms of the +rem license agreement you entered into with Tanuki Software. +rem http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html +rem +rem Java Service Wrapper general startup script. +rem + +rem ----------------------------------------------------------------------------- +rem These settings can be modified to fit the needs of your application +rem Optimized for use with version 3.5.23 of the Wrapper. + +rem The base name for the Wrapper binary. +set _WRAPPER_BASE=wrapper + +rem The directory where the Wrapper binary (.exe) file is located, this can be +rem either a absolute or relative path. If the path contains any special characters, +rem please make sure to quote the variable. +set _WRAPPER_DIR= + +rem The name and location of the Wrapper configuration file. This will be used +rem if the user does not specify a configuration file as the first parameter to +rem this script. It will not be possible to specify a configuration file on the +rem command line if _PASS_THROUGH is set. +rem If a relative path is specified, please note that the location is based on the +rem location. +set _WRAPPER_CONF_DEFAULT="../conf/%_WRAPPER_BASE%.conf" + +rem Makes it possible to override the Wrapper configuration file by specifying it +rem as the first parameter. +rem set _WRAPPER_CONF_OVERRIDE=true + +rem Note that it is only possible to pass parameters through to the JVM when +rem installing the service, or when running in a console. + +rem Do not modify anything beyond this point +rem ----------------------------------------------------------------------------- + +rem +rem Resolve the real path of the wrapper.exe +rem For non NT systems, the _REALPATH and _WRAPPER_CONF values +rem can be hard-coded below and the following test removed. +rem +if "%OS%"=="Windows_NT" goto nt +echo This script only works with NT-based versions of Windows. +goto :eof + +:nt +rem Find the application home. +rem if no path path specified do the default action +IF not DEFINED _WRAPPER_DIR goto dir_undefined +set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR:"=%" +if not "%_WRAPPER_DIR:~-2,1%" == "\" set _WRAPPER_DIR_QUOTED="%_WRAPPER_DIR_QUOTED:"=%\" +rem check if absolute path +if "%_WRAPPER_DIR_QUOTED:~2,1%" == ":" goto absolute_path +if "%_WRAPPER_DIR_QUOTED:~1,1%" == "\" goto absolute_path +rem everythig else means relative path +set _REALPATH="%~dp0%_WRAPPER_DIR_QUOTED:"=%" +goto pathfound + +:dir_undefined +rem Use a relative path to the wrapper %~dp0 is location of current script under NT +set _REALPATH="%~dp0" +goto pathfound +:absolute_path +rem Use an absolute path to the wrapper +set _REALPATH="%_WRAPPER_DIR_QUOTED:"=%" + +:pathfound +rem +rem Decide on the specific Wrapper binary to use (See delta-pack) +rem +if "%PROCESSOR_ARCHITEW6432%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto amd64 +if "%PROCESSOR_ARCHITECTURE%"=="IA64" goto ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-32.exe" +goto search +:amd64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-x86-64.exe" +goto search +:ia64 +set _WRAPPER_L_EXE="%_REALPATH:"=%%_WRAPPER_BASE%-windows-ia-64.exe" +goto search +:search +set _WRAPPER_EXE="%_WRAPPER_L_EXE:"=%" +if exist %_WRAPPER_EXE% goto conf +set _WRAPPER_EXE="%_REALPATH:"=%%_WRAPPER_BASE%.exe" +if exist %_WRAPPER_EXE% goto conf +echo Unable to locate a Wrapper executable using any of the following names: +echo %_WRAPPER_L_EXE% +echo %_WRAPPER_EXE% +pause +goto :eof + +rem +rem Find the wrapper.conf +rem +:conf +if not [%_WRAPPER_CONF_OVERRIDE%]==[] ( + set _WRAPPER_CONF="%~f1" + if not [%_WRAPPER_CONF%]==[""] ( + shift + goto :startup + ) +) +set _WRAPPER_CONF="%_WRAPPER_CONF_DEFAULT:"=%" + +rem +rem Start the Wrapper +rem +:startup + +rem Collect an parameters +:parameters +set _PARAMETERS=%_PARAMETERS% %1 +shift +if not [%1]==[] goto :parameters + +if [%_PASS_THROUGH%]==[] ( + %_WRAPPER_EXE% -r %_WRAPPER_CONF% +) else ( + %_WRAPPER_EXE% -r %_WRAPPER_CONF% -- %_PARAMETERS% +) +if not errorlevel 1 goto :eof +pause diff --git a/tools/wrapper/wrapper-log4j.xsl b/tools/wrapper/wrapper-log4j.xsl index fe03fa544ca..281c0a00b64 100644 --- a/tools/wrapper/wrapper-log4j.xsl +++ b/tools/wrapper/wrapper-log4j.xsl @@ -1,18 +1,18 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/webapp/WEB-INF/entities/play.xsd b/webapp/WEB-INF/entities/play.xsd index 60b1fd1d4d8..c29de824795 100644 --- a/webapp/WEB-INF/entities/play.xsd +++ b/webapp/WEB-INF/entities/play.xsd @@ -1,140 +1,140 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/webapp/WEB-INF/entities/xml.xsd b/webapp/WEB-INF/entities/xml.xsd index de11f7e07b2..87f17970dc3 100644 --- a/webapp/WEB-INF/entities/xml.xsd +++ b/webapp/WEB-INF/entities/xml.xsd @@ -1,133 +1,133 @@ - - - - - See http://www.w3.org/XML/1998/namespace.html and - http://www.w3.org/TR/REC-xml for information about this namespace. - - This schema document describes the XML namespace, in a form - suitable for import by other schema documents. - - Note that local names in this namespace are intended to be defined - only by the World Wide Web Consortium or its subgroups. The - following names are currently defined in this namespace and should - not be used with conflicting semantics by any Working Group, - specification, or document instance: - - base (as an attribute name): denotes an attribute whose value - provides a URI to be used as the base for interpreting any - relative URIs in the scope of the element on which it - appears; its value is inherited. This name is reserved - by virtue of its definition in the XML Base specification. - - id (as an attribute name): denotes an attribute whose value - should be interpreted as if declared to be of type ID. - The xml:id specification is not yet a W3C Recommendation, - but this attribute is included here to facilitate experimentation - with the mechanisms it proposes. Note that it is _not_ included - in the specialAttrs attribute group. - - lang (as an attribute name): denotes an attribute whose value - is a language code for the natural language of the content of - any element; its value is inherited. This name is reserved - by virtue of its definition in the XML specification. - - space (as an attribute name): denotes an attribute whose - value is a keyword indicating what whitespace processing - discipline is intended for the content of the element; its - value is inherited. This name is reserved by virtue of its - definition in the XML specification. - - Father (in any context at all): denotes Jon Bosak, the chair of - the original XML Working Group. This name is reserved by - the following decision of the W3C XML Plenary and - XML Coordination groups: - - In appreciation for his vision, leadership and dedication - the W3C XML Plenary on this 10th day of February, 2000 - reserves for Jon Bosak in perpetuity the XML name - xml:Father - - - - - This schema defines attributes and an attribute group - suitable for use by - schemas wishing to allow xml:base, xml:lang or xml:space attributes - on elements they define. - - To enable this, such a schema must import this schema - for the XML namespace, e.g. as follows: - <schema . . .> - . . . - <import namespace="http://www.w3.org/XML/1998/namespace" - schemaLocation="http://www.w3.org/2001/03/xml.xsd"/> - - Subsequently, qualified reference to any of the attributes - or the group defined below will have the desired effect, e.g. - - <type . . .> - . . . - <attributeGroup ref="xml:specialAttrs"/> - - will define a type which will schema-validate an instance - element with any of those attributes - - - - In keeping with the XML Schema WG's standard versioning - policy, this schema document will persist at - http://www.w3.org/2004/10/xml.xsd. - At the date of issue it can also be found at - http://www.w3.org/2001/xml.xsd. - The schema document at that URI may however change in the future, - in order to remain compatible with the latest version of XML Schema - itself, or with the XML namespace itself. In other words, if the XML - Schema or XML namespaces change, the version of this document at - http://www.w3.org/2001/xml.xsd will change - accordingly; the version at - http://www.w3.org/2004/10/xml.xsd will not change. - - - - - - Attempting to install the relevant ISO 2- and 3-letter - codes as the enumerated possible values is probably never - going to be a realistic possibility. See - RFC 3066 at http://www.ietf.org/rfc/rfc3066.txt and the IANA registry - at http://www.iana.org/assignments/lang-tag-apps.htm for - further information. - - - - - - - - - - - - - - - See http://www.w3.org/TR/xmlbase/ for - information about this attribute. - - - - - - See http://www.w3.org/TR/xml-id/ for - information about this attribute. - - - - - - - - - - + + + + + See http://www.w3.org/XML/1998/namespace.html and + http://www.w3.org/TR/REC-xml for information about this namespace. + + This schema document describes the XML namespace, in a form + suitable for import by other schema documents. + + Note that local names in this namespace are intended to be defined + only by the World Wide Web Consortium or its subgroups. The + following names are currently defined in this namespace and should + not be used with conflicting semantics by any Working Group, + specification, or document instance: + + base (as an attribute name): denotes an attribute whose value + provides a URI to be used as the base for interpreting any + relative URIs in the scope of the element on which it + appears; its value is inherited. This name is reserved + by virtue of its definition in the XML Base specification. + + id (as an attribute name): denotes an attribute whose value + should be interpreted as if declared to be of type ID. + The xml:id specification is not yet a W3C Recommendation, + but this attribute is included here to facilitate experimentation + with the mechanisms it proposes. Note that it is _not_ included + in the specialAttrs attribute group. + + lang (as an attribute name): denotes an attribute whose value + is a language code for the natural language of the content of + any element; its value is inherited. This name is reserved + by virtue of its definition in the XML specification. + + space (as an attribute name): denotes an attribute whose + value is a keyword indicating what whitespace processing + discipline is intended for the content of the element; its + value is inherited. This name is reserved by virtue of its + definition in the XML specification. + + Father (in any context at all): denotes Jon Bosak, the chair of + the original XML Working Group. This name is reserved by + the following decision of the W3C XML Plenary and + XML Coordination groups: + + In appreciation for his vision, leadership and dedication + the W3C XML Plenary on this 10th day of February, 2000 + reserves for Jon Bosak in perpetuity the XML name + xml:Father + + + + + This schema defines attributes and an attribute group + suitable for use by + schemas wishing to allow xml:base, xml:lang or xml:space attributes + on elements they define. + + To enable this, such a schema must import this schema + for the XML namespace, e.g. as follows: + <schema . . .> + . . . + <import namespace="http://www.w3.org/XML/1998/namespace" + schemaLocation="http://www.w3.org/2001/03/xml.xsd"/> + + Subsequently, qualified reference to any of the attributes + or the group defined below will have the desired effect, e.g. + + <type . . .> + . . . + <attributeGroup ref="xml:specialAttrs"/> + + will define a type which will schema-validate an instance + element with any of those attributes + + + + In keeping with the XML Schema WG's standard versioning + policy, this schema document will persist at + http://www.w3.org/2004/10/xml.xsd. + At the date of issue it can also be found at + http://www.w3.org/2001/xml.xsd. + The schema document at that URI may however change in the future, + in order to remain compatible with the latest version of XML Schema + itself, or with the XML namespace itself. In other words, if the XML + Schema or XML namespaces change, the version of this document at + http://www.w3.org/2001/xml.xsd will change + accordingly; the version at + http://www.w3.org/2004/10/xml.xsd will not change. + + + + + + Attempting to install the relevant ISO 2- and 3-letter + codes as the enumerated possible values is probably never + going to be a realistic possibility. See + RFC 3066 at http://www.ietf.org/rfc/rfc3066.txt and the IANA registry + at http://www.iana.org/assignments/lang-tag-apps.htm for + further information. + + + + + + + + + + + + + + + See http://www.w3.org/TR/xmlbase/ for + information about this attribute. + + + + + + See http://www.w3.org/TR/xml-id/ for + information about this attribute. + + + + + + + + + + diff --git a/webapp/xqts/hacked-tests.xml b/webapp/xqts/hacked-tests.xml index 8b58903ebfb..b8dbcbdfe6c 100644 --- a/webapp/xqts/hacked-tests.xml +++ b/webapp/xqts/hacked-tests.xml @@ -1,17 +1,17 @@ - - - - - - - - - - - - - - - true - + + + + + + + + + + + + + + + true + \ No newline at end of file diff --git a/webapp/xqts/scripts/container.js b/webapp/xqts/scripts/container.js index 40af1969acc..535208ee49a 100644 --- a/webapp/xqts/scripts/container.js +++ b/webapp/xqts/scripts/container.js @@ -1,3918 +1,3918 @@ -/* -Copyright (c) 2006, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -Version 0.11.1 -*/ - -/** -* @class -* Config is a utility used within an object to allow the implementer to maintain a list of local configuration properties and listen for changes to those properties dynamically using CustomEvent. The initial values are also maintained so that the configuration can be reset at any given point to its initial state. -* @param {object} owner The owner object to which this Config object belongs -* @constructor -*/ -YAHOO.util.Config = function(owner) { - if (owner) { - this.init(owner); - } -} - -YAHOO.util.Config.prototype = { - - /** - * Object reference to the owner of this Config object - * @type object - */ - owner : null, - - /** - * Object reference to the owner of this Config object - * args: key, value - * @type YAHOO.util.CustomEvent - */ - configChangedEvent : null, - - /** - * Boolean flag that specifies whether a queue is currently being executed - * @type boolean - */ - queueInProgress : false, - - /** - * Adds a property to the Config object's private config hash. - * @param {string} key The configuration property's name - * @param {object} propertyObject The object containing all of this property's arguments - */ - addProperty : function(key, propertyObject){}, - - /** - * Returns a key-value configuration map of the values currently set in the Config object. - * @return {object} The current config, represented in a key-value map - */ - getConfig : function(){}, - - /** - * Returns the value of specified property. - * @param {key} The name of the property - * @return {object} The value of the specified property - */ - getProperty : function(key){}, - - /** - * Resets the specified property's value to its initial value. - * @param {key} The name of the property - */ - resetProperty : function(key){}, - - /** - * Sets the value of a property. If the silent property is passed as true, the property's event will not be fired. - * @param {key} The name of the property - * @param {value} The value to set the property to - * @param {boolean} Whether the value should be set silently, without firing the property event. - * @return {boolean} true, if the set was successful, false if it failed. - */ - setProperty : function(key,value,silent){}, - - /** - * Sets the value of a property and queues its event to execute. If the event is already scheduled to execute, it is - * moved from its current position to the end of the queue. - * @param {key} The name of the property - * @param {value} The value to set the property to - * @return {boolean} true, if the set was successful, false if it failed. - */ - queueProperty : function(key,value){}, - - /** - * Fires the event for a property using the property's current value. - * @param {key} The name of the property - */ - refireEvent : function(key){}, - - /** - * Applies a key-value object literal to the configuration, replacing any existing values, and queueing the property events. - * Although the values will be set, fireQueue() must be called for their associated events to execute. - * @param {object} userConfig The configuration object literal - * @param {boolean} init When set to true, the initialConfig will be set to the userConfig passed in, so that calling a reset will reset the properties to the passed values. - */ - applyConfig : function(userConfig,init){}, - - /** - * Refires the events for all configuration properties using their current values. - */ - refresh : function(){}, - - /** - * Fires the normalized list of queued property change events - */ - fireQueue : function(){}, - - /** - * Subscribes an external handler to the change event for any given property. - * @param {string} key The property name - * @param {Function} handler The handler function to use subscribe to the property's event - * @param {object} obj The object to use for scoping the event handler (see CustomEvent documentation) - * @param {boolean} override Optional. If true, will override "this" within the handler to map to the scope object passed into the method. - */ - subscribeToConfigEvent : function(key,handler,obj,override){}, - - /** - * Unsubscribes an external handler from the change event for any given property. - * @param {string} key The property name - * @param {Function} handler The handler function to use subscribe to the property's event - * @param {object} obj The object to use for scoping the event handler (see CustomEvent documentation) - */ - unsubscribeFromConfigEvent: function(key,handler,obj){}, - - /** - * Validates that the value passed in is a boolean. - * @param {object} val The value to validate - * @return {boolean} true, if the value is valid - */ - checkBoolean: function(val) { - if (typeof val == 'boolean') { - return true; - } else { - return false; - } - }, - - /** - * Validates that the value passed in is a number. - * @param {object} val The value to validate - * @return {boolean} true, if the value is valid - */ - checkNumber: function(val) { - if (isNaN(val)) { - return false; - } else { - return true; - } - } -} - - -/** -* Initializes the configuration object and all of its local members. -* @param {object} owner The owner object to which this Config object belongs -*/ -YAHOO.util.Config.prototype.init = function(owner) { - - this.owner = owner; - this.configChangedEvent = new YAHOO.util.CustomEvent("configChanged"); - this.queueInProgress = false; - - /* Private Members */ - - var config = {}; - var initialConfig = {}; - var eventQueue = []; - - /** - * @private - * Fires a configuration property event using the specified value. - * @param {string} key The configuration property's name - * @param {value} object The value of the correct type for the property - */ - var fireEvent = function( key, value ) { - key = key.toLowerCase(); - - var property = config[key]; - - if (typeof property != 'undefined' && property.event) { - property.event.fire(value); - } - } - /* End Private Members */ - - this.addProperty = function( key, propertyObject ) { - key = key.toLowerCase(); - - config[key] = propertyObject; - - propertyObject.event = new YAHOO.util.CustomEvent(key); - propertyObject.key = key; - - if (propertyObject.handler) { - propertyObject.event.subscribe(propertyObject.handler, this.owner, true); - } - - this.setProperty(key, propertyObject.value, true); - - if (! propertyObject.suppressEvent) { - this.queueProperty(key, propertyObject.value); - } - } - - this.getConfig = function() { - var cfg = {}; - - for (var prop in config) { - var property = config[prop] - if (typeof property != 'undefined' && property.event) { - cfg[prop] = property.value; - } - } - - return cfg; - } - - this.getProperty = function(key) { - key = key.toLowerCase(); - - var property = config[key]; - if (typeof property != 'undefined' && property.event) { - return property.value; - } else { - return undefined; - } - } - - this.resetProperty = function(key) { - key = key.toLowerCase(); - - var property = config[key]; - if (typeof property != 'undefined' && property.event) { - this.setProperty(key, initialConfig[key].value); - } else { - return undefined; - } - } - - this.setProperty = function(key, value, silent) { - key = key.toLowerCase(); - - if (this.queueInProgress && ! silent) { - this.queueProperty(key,value); // Currently running through a queue... - return true; - } else { - var property = config[key]; - if (typeof property != 'undefined' && property.event) { - if (property.validator && ! property.validator(value)) { // validator - return false; - } else { - property.value = value; - if (! silent) { - fireEvent(key, value); - this.configChangedEvent.fire([key, value]); - } - return true; - } - } else { - return false; - } - } - } - - this.queueProperty = function(key, value) { - key = key.toLowerCase(); - - var property = config[key]; - - if (typeof property != 'undefined' && property.event) { - if (typeof value != 'undefined' && property.validator && ! property.validator(value)) { // validator - return false; - } else { - - if (typeof value != 'undefined') { - property.value = value; - } else { - value = property.value; - } - - var foundDuplicate = false; - - for (var i=0;iOR -* @param {Element} el The element representing the Module -* @param {object} userConfig The configuration object literal containing the configuration that should be set for this module. See configuration documentation for more details. -* @constructor -*/ -YAHOO.widget.Module = function(el, userConfig) { - if (el) { - this.init(el, userConfig); - } -} - -/** -* Constant representing the prefix path to use for non-secure images -* @type string -*/ -YAHOO.widget.Module.IMG_ROOT = "http://us.i1.yimg.com/us.yimg.com/i/"; - -/** -* Constant representing the prefix path to use for securely served images -* @type string -*/ -YAHOO.widget.Module.IMG_ROOT_SSL = "https://a248.e.akamai.net/sec.yimg.com/i/"; - -/** -* Constant for the default CSS class name that represents a Module -* @type string -* @final -*/ -YAHOO.widget.Module.CSS_MODULE = "module"; - -/** -* Constant representing the module header -* @type string -* @final -*/ -YAHOO.widget.Module.CSS_HEADER = "hd"; - -/** -* Constant representing the module body -* @type string -* @final -*/ -YAHOO.widget.Module.CSS_BODY = "bd"; - -/** -* Constant representing the module footer -* @type string -* @final -*/ -YAHOO.widget.Module.CSS_FOOTER = "ft"; - -/** -* Constant representing the url for the "src" attribute of the iframe used to monitor changes to the browser's base font size -* @type string -* @final -*/ -YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL = null; - -YAHOO.widget.Module.prototype = { - - /** - * The class's constructor function - * @type function - */ - constructor : YAHOO.widget.Module, - - /** - * The main module element that contains the header, body, and footer - * @type Element - */ - element : null, - - /** - * The header element, denoted with CSS class "hd" - * @type Element - */ - header : null, - - /** - * The body element, denoted with CSS class "bd" - * @type Element - */ - body : null, - - /** - * The footer element, denoted with CSS class "ft" - * @type Element - */ - footer : null, - - /** - * The id of the element - * @type string - */ - id : null, - - /** - * Array of elements - * @type Element[] - */ - childNodesInDOM : null, - - /** - * The string representing the image root - * @type string - */ - imageRoot : YAHOO.widget.Module.IMG_ROOT, - - /** - * CustomEvent fired prior to class initalization. - * args: class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module) - * @type YAHOO.util.CustomEvent - */ - beforeInitEvent : null, - - /** - * CustomEvent fired after class initalization. - * args: class reference of the initializing class, such as this.initEvent.fire(YAHOO.widget.Module) - * @type YAHOO.util.CustomEvent - */ - initEvent : null, - - /** - * CustomEvent fired when the Module is appended to the DOM - * args: none - * @type YAHOO.util.CustomEvent - */ - appendEvent : null, - - /** - * CustomEvent fired before the Module is rendered - * args: none - * @type YAHOO.util.CustomEvent - */ - beforeRenderEvent : null, - - /** - * CustomEvent fired after the Module is rendered - * args: none - * @type YAHOO.util.CustomEvent - */ - renderEvent : null, - - /** - * CustomEvent fired when the header content of the Module is modified - * args: string/element representing the new header content - * @type YAHOO.util.CustomEvent - */ - changeHeaderEvent : null, - - /** - * CustomEvent fired when the body content of the Module is modified - * args: string/element representing the new body content - * @type YAHOO.util.CustomEvent - */ - changeBodyEvent : null, - - /** - * CustomEvent fired when the footer content of the Module is modified - * args: string/element representing the new footer content - * @type YAHOO.util.CustomEvent - */ - changeFooterEvent : null, - - /** - * CustomEvent fired when the content of the Module is modified - * args: none - * @type YAHOO.util.CustomEvent - */ - changeContentEvent : null, - - /** - * CustomEvent fired when the Module is destroyed - * args: none - * @type YAHOO.util.CustomEvent - */ - destroyEvent : null, - - /** - * CustomEvent fired before the Module is shown - * args: none - * @type YAHOO.util.CustomEvent - */ - beforeShowEvent : null, - - /** - * CustomEvent fired after the Module is shown - * args: none - * @type YAHOO.util.CustomEvent - */ - showEvent : null, - - /** - * CustomEvent fired before the Module is hidden - * args: none - * @type YAHOO.util.CustomEvent - */ - beforeHideEvent : null, - - /** - * CustomEvent fired after the Module is hidden - * args: none - * @type YAHOO.util.CustomEvent - */ - hideEvent : null, - - /** - * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class. - */ - initEvents : function() { - - this.beforeInitEvent = new YAHOO.util.CustomEvent("beforeInit"); - this.initEvent = new YAHOO.util.CustomEvent("init"); - - this.appendEvent = new YAHOO.util.CustomEvent("append"); - - this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender"); - this.renderEvent = new YAHOO.util.CustomEvent("render"); - - this.changeHeaderEvent = new YAHOO.util.CustomEvent("changeHeader"); - this.changeBodyEvent = new YAHOO.util.CustomEvent("changeBody"); - this.changeFooterEvent = new YAHOO.util.CustomEvent("changeFooter"); - - this.changeContentEvent = new YAHOO.util.CustomEvent("changeContent"); - - this.destroyEvent = new YAHOO.util.CustomEvent("destroy"); - this.beforeShowEvent = new YAHOO.util.CustomEvent("beforeShow"); - this.showEvent = new YAHOO.util.CustomEvent("show"); - this.beforeHideEvent = new YAHOO.util.CustomEvent("beforeHide"); - this.hideEvent = new YAHOO.util.CustomEvent("hide"); - }, - - /** - * String representing the current user-agent platform - * @type string - */ - platform : function() { - var ua = navigator.userAgent.toLowerCase(); - if (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1) { - return "windows"; - } else if (ua.indexOf("macintosh") != -1) { - return "mac"; - } else { - return false; - } - }(), - - /** - * String representing the current user-agent browser - * @type string - */ - browser : function() { - var ua = navigator.userAgent.toLowerCase(); - if (ua.indexOf('opera')!=-1) { // Opera (check first in case of spoof) - return 'opera'; - } else if (ua.indexOf('msie 7')!=-1) { // IE7 - return 'ie7'; - } else if (ua.indexOf('msie') !=-1) { // IE - return 'ie'; - } else if (ua.indexOf('safari')!=-1) { // Safari (check before Gecko because it includes "like Gecko") - return 'safari'; - } else if (ua.indexOf('gecko') != -1) { // Gecko - return 'gecko'; - } else { - return false; - } - }(), - - /** - * Boolean representing whether or not the current browsing context is secure (https) - * @type boolean - */ - isSecure : function() { - if (window.location.href.toLowerCase().indexOf("https") == 0) { - return true; - } else { - return false; - } - }(), - - /** - * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class. - */ - initDefaultConfig : function() { - // Add properties // - - this.cfg.addProperty("visible", { value:true, handler:this.configVisible, validator:this.cfg.checkBoolean } ); - this.cfg.addProperty("effect", { suppressEvent:true, supercedes:["visible"] } ); - this.cfg.addProperty("monitorresize", { value:true, handler:this.configMonitorResize } ); - }, - - /** - * The Module class's initialization method, which is executed for Module and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present. - * @param {string} el The element ID representing the Module OR - * @param {Element} el The element representing the Module - * @param {object} userConfig The configuration object literal containing the configuration that should be set for this module. See configuration documentation for more details. - */ - init : function(el, userConfig) { - - this.initEvents(); - - this.beforeInitEvent.fire(YAHOO.widget.Module); - - this.cfg = new YAHOO.util.Config(this); - - if (this.isSecure) { - this.imageRoot = YAHOO.widget.Module.IMG_ROOT_SSL; - } - - if (typeof el == "string") { - var elId = el; - - el = document.getElementById(el); - if (! el) { - el = document.createElement("DIV"); - el.id = elId; - } - } - - this.element = el; - - if (el.id) { - this.id = el.id; - } - - var childNodes = this.element.childNodes; - - if (childNodes) { - for (var i=0;iOR - * @param {Element} headerContent The Element to append to the header - */ - setHeader : function(headerContent) { - if (! this.header) { - this.header = document.createElement("DIV"); - this.header.className = YAHOO.widget.Module.CSS_HEADER; - } - - if (typeof headerContent == "string") { - this.header.innerHTML = headerContent; - } else { - this.header.innerHTML = ""; - this.header.appendChild(headerContent); - } - - this.changeHeaderEvent.fire(headerContent); - this.changeContentEvent.fire(); - }, - - /** - * Appends the passed element to the header. If no header is present, one will be automatically created. - * @param {Element} element The element to append to the header - */ - appendToHeader : function(element) { - if (! this.header) { - this.header = document.createElement("DIV"); - this.header.className = YAHOO.widget.Module.CSS_HEADER; - } - - this.header.appendChild(element); - this.changeHeaderEvent.fire(element); - this.changeContentEvent.fire(); - }, - - /** - * Sets the Module's body content to the HTML specified, or appends the passed element to the body. If no body is present, one will be automatically created. - * @param {string} bodyContent The HTML used to set the body OR - * @param {Element} bodyContent The Element to append to the body - */ - setBody : function(bodyContent) { - if (! this.body) { - this.body = document.createElement("DIV"); - this.body.className = YAHOO.widget.Module.CSS_BODY; - } - - if (typeof bodyContent == "string") - { - this.body.innerHTML = bodyContent; - } else { - this.body.innerHTML = ""; - this.body.appendChild(bodyContent); - } - - this.changeBodyEvent.fire(bodyContent); - this.changeContentEvent.fire(); - }, - - /** - * Appends the passed element to the body. If no body is present, one will be automatically created. - * @param {Element} element The element to append to the body - */ - appendToBody : function(element) { - if (! this.body) { - this.body = document.createElement("DIV"); - this.body.className = YAHOO.widget.Module.CSS_BODY; - } - - this.body.appendChild(element); - this.changeBodyEvent.fire(element); - this.changeContentEvent.fire(); - }, - - /** - * Sets the Module's footer content to the HTML specified, or appends the passed element to the footer. If no footer is present, one will be automatically created. - * @param {string} footerContent The HTML used to set the footer OR - * @param {Element} footerContent The Element to append to the footer - */ - setFooter : function(footerContent) { - if (! this.footer) { - this.footer = document.createElement("DIV"); - this.footer.className = YAHOO.widget.Module.CSS_FOOTER; - } - - if (typeof footerContent == "string") { - this.footer.innerHTML = footerContent; - } else { - this.footer.innerHTML = ""; - this.footer.appendChild(footerContent); - } - - this.changeFooterEvent.fire(footerContent); - this.changeContentEvent.fire(); - }, - - /** - * Appends the passed element to the footer. If no footer is present, one will be automatically created. - * @param {Element} element The element to append to the footer - */ - appendToFooter : function(element) { - if (! this.footer) { - this.footer = document.createElement("DIV"); - this.footer.className = YAHOO.widget.Module.CSS_FOOTER; - } - - this.footer.appendChild(element); - this.changeFooterEvent.fire(element); - this.changeContentEvent.fire(); - }, - - /** - * Renders the Module by inserting the elements that are not already in the main Module into their correct places. Optionally appends the Module to the specified node prior to the render's execution. NOTE: For Modules without existing markup, the appendToNode argument is REQUIRED. If this argument is ommitted and the current element is not present in the document, the function will return false, indicating that the render was a failure. - * @param {string} appendToNode The element id to which the Module should be appended to prior to rendering OR - * @param {Element} appendToNode The element to which the Module should be appended to prior to rendering - * @param {Element} moduleElement OPTIONAL. The element that represents the actual Standard Module container. - * @return {boolean} Success or failure of the render - */ - render : function(appendToNode, moduleElement) { - this.beforeRenderEvent.fire(); - - if (! moduleElement) { - moduleElement = this.element; - } - - var me = this; - var appendTo = function(element) { - if (typeof element == "string") { - element = document.getElementById(element); - } - - if (element) { - element.appendChild(me.element); - me.appendEvent.fire(); - } - } - - if (appendToNode) { - appendTo(appendToNode); - } else { // No node was passed in. If the element is not pre-marked up, this fails - if (! YAHOO.util.Dom.inDocument(this.element)) { - return false; - } - } - - // Need to get everything into the DOM if it isn't already - - if (this.header && ! YAHOO.util.Dom.inDocument(this.header)) { - // There is a header, but it's not in the DOM yet... need to add it - var firstChild = moduleElement.firstChild; - if (firstChild) { // Insert before first child if exists - moduleElement.insertBefore(this.header, firstChild); - } else { // Append to empty body because there are no children - moduleElement.appendChild(this.header); - } - } - - if (this.body && ! YAHOO.util.Dom.inDocument(this.body)) { - // There is a body, but it's not in the DOM yet... need to add it - if (this.footer && YAHOO.util.Dom.isAncestor(this.moduleElement, this.footer)) { // Insert before footer if exists in DOM - moduleElement.insertBefore(this.body, this.footer); - } else { // Append to element because there is no footer - moduleElement.appendChild(this.body); - } - } - - if (this.footer && ! YAHOO.util.Dom.inDocument(this.footer)) { - // There is a footer, but it's not in the DOM yet... need to add it - moduleElement.appendChild(this.footer); - } - - this.renderEvent.fire(); - return true; - }, - - /** - * Removes the Module element from the DOM and sets all child elements to null. - */ - destroy : function() { - if (this.element) { - var parent = this.element.parentNode; - } - if (parent) { - parent.removeChild(this.element); - } - - this.element = null; - this.header = null; - this.body = null; - this.footer = null; - - this.destroyEvent.fire(); - }, - - /** - * Shows the Module element by setting the visible configuration property to true. Also fires two events: beforeShowEvent prior to the visibility change, and showEvent after. - */ - show : function() { - this.cfg.setProperty("visible", true); - }, - - /** - * Hides the Module element by setting the visible configuration property to false. Also fires two events: beforeHideEvent prior to the visibility change, and hideEvent after. - */ - hide : function() { - this.cfg.setProperty("visible", false); - }, - - // BUILT-IN EVENT HANDLERS FOR MODULE // - - /** - * Default event handler for changing the visibility property of a Module. By default, this is achieved by switching the "display" style between "block" and "none". - * This method is responsible for firing showEvent and hideEvent. - */ - configVisible : function(type, args, obj) { - var visible = args[0]; - if (visible) { - this.beforeShowEvent.fire(); - YAHOO.util.Dom.setStyle(this.element, "display", "block"); - this.showEvent.fire(); - } else { - this.beforeHideEvent.fire(); - YAHOO.util.Dom.setStyle(this.element, "display", "none"); - this.hideEvent.fire(); - } - }, - - /** - * Default event handler for the "monitorresize" configuration property - */ - configMonitorResize : function(type, args, obj) { - var monitor = args[0]; - if (monitor) { - this.initResizeMonitor(); - } else { - YAHOO.util.Event.removeListener(this.resizeMonitor, "resize", this.onDomResize); - this.resizeMonitor = null; - } - } -} - -/** -* Returns a string representation of the object. -* @type string -*/ -YAHOO.widget.Module.prototype.toString = function() { - return "Module " + this.id; -} - -/** -* @class Overlay is a Module that is absolutely positioned above the page flow. It has convenience methods for positioning and sizing, as well as options for controlling zIndex and constraining the Overlay's position to the current visible viewport. Overlay also contains a dynamicly generated IFRAME which is placed beneath it for Internet Explorer 6 and 5.x so that it will be properly rendered above SELECT elements. -* @param {string} el The element ID representing the Overlay OR -* @param {Element} el The element representing the Overlay -* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details. -* @constructor -*/ -YAHOO.widget.Overlay = function(el, userConfig) { - YAHOO.widget.Overlay.superclass.constructor.call(this, el, userConfig); -} - -YAHOO.extend(YAHOO.widget.Overlay, YAHOO.widget.Module); - -/** -* The URL of the blank image that will be placed in the iframe -* @type string -* @final -*/ -YAHOO.widget.Overlay.IFRAME_SRC = "promo/m/irs/blank.gif"; - -/** -* Constant representing the top left corner of an element, used for configuring the context element alignment -* @type string -* @final -*/ -YAHOO.widget.Overlay.TOP_LEFT = "tl"; - -/** -* Constant representing the top right corner of an element, used for configuring the context element alignment -* @type string -* @final -*/ -YAHOO.widget.Overlay.TOP_RIGHT = "tr"; - -/** -* Constant representing the top bottom left corner of an element, used for configuring the context element alignment -* @type string -* @final -*/ -YAHOO.widget.Overlay.BOTTOM_LEFT = "bl"; - -/** -* Constant representing the bottom right corner of an element, used for configuring the context element alignment -* @type string -* @final -*/ -YAHOO.widget.Overlay.BOTTOM_RIGHT = "br"; - -/** -* Constant representing the default CSS class used for an Overlay -* @type string -* @final -*/ -YAHOO.widget.Overlay.CSS_OVERLAY = "overlay"; - -/** -* CustomEvent fired before the Overlay is moved. -* args: x,y that the Overlay will be moved to -* @type YAHOO.util.CustomEvent -*/ -YAHOO.widget.Overlay.prototype.beforeMoveEvent = null; - -/** -* CustomEvent fired after the Overlay is moved. -* args: x,y that the Overlay was moved to -* @type YAHOO.util.CustomEvent -*/ -YAHOO.widget.Overlay.prototype.moveEvent = null; - -/** -* The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present. -* @param {string} el The element ID representing the Overlay OR -* @param {Element} el The element representing the Overlay -* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details. -*/ -YAHOO.widget.Overlay.prototype.init = function(el, userConfig) { - YAHOO.widget.Overlay.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level - - this.beforeInitEvent.fire(YAHOO.widget.Overlay); - - YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Overlay.CSS_OVERLAY); - - if (userConfig) { - this.cfg.applyConfig(userConfig, true); - } - - if (this.platform == "mac" && this.browser == "gecko") { - if (! YAHOO.util.Config.alreadySubscribed(this.showEvent,this.showMacGeckoScrollbars,this)) { - this.showEvent.subscribe(this.showMacGeckoScrollbars,this,true); - } - if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent,this.hideMacGeckoScrollbars,this)) { - this.hideEvent.subscribe(this.hideMacGeckoScrollbars,this,true); - } - } - - this.initEvent.fire(YAHOO.widget.Overlay); - -} - -/** -* Initializes the custom events for Overlay which are fired automatically at appropriate times by the Overlay class. -*/ -YAHOO.widget.Overlay.prototype.initEvents = function() { - YAHOO.widget.Overlay.superclass.initEvents.call(this); - - this.beforeMoveEvent = new YAHOO.util.CustomEvent("beforeMove", this); - this.moveEvent = new YAHOO.util.CustomEvent("move", this); -} - -/** -* Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg). -*/ -YAHOO.widget.Overlay.prototype.initDefaultConfig = function() { - YAHOO.widget.Overlay.superclass.initDefaultConfig.call(this); - - // Add overlay config properties // - this.cfg.addProperty("x", { handler:this.configX, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } ); - this.cfg.addProperty("y", { handler:this.configY, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } ); - this.cfg.addProperty("xy",{ handler:this.configXY, suppressEvent:true, supercedes:["iframe"] } ); - - this.cfg.addProperty("context", { handler:this.configContext, suppressEvent:true, supercedes:["iframe"] } ); - this.cfg.addProperty("fixedcenter", { value:false, handler:this.configFixedCenter, validator:this.cfg.checkBoolean, supercedes:["iframe","visible"] } ); - - this.cfg.addProperty("width", { handler:this.configWidth, suppressEvent:true, supercedes:["iframe"] } ); - this.cfg.addProperty("height", { handler:this.configHeight, suppressEvent:true, supercedes:["iframe"] } ); - - this.cfg.addProperty("zIndex", { value:null, handler:this.configzIndex } ); - - this.cfg.addProperty("constraintoviewport", { value:false, handler:this.configConstrainToViewport, validator:this.cfg.checkBoolean, supercedes:["iframe","x","y","xy"] } ); - this.cfg.addProperty("iframe", { value:(this.browser == "ie" ? true : false), handler:this.configIframe, validator:this.cfg.checkBoolean, supercedes:["zIndex"] } ); -} - -/** -* Moves the Overlay to the specified position. This function is identical to calling this.cfg.setProperty("xy", [x,y]); -* @param {int} x The Overlay's new x position -* @param {int} y The Overlay's new y position -*/ -YAHOO.widget.Overlay.prototype.moveTo = function(x, y) { - this.cfg.setProperty("xy",[x,y]); -} - -/** -* Adds a special CSS class to the Overlay when Mac/Gecko is in use, to work around a Gecko bug where -* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435 -*/ -YAHOO.widget.Overlay.prototype.hideMacGeckoScrollbars = function() { - YAHOO.util.Dom.removeClass(this.element, "show-scrollbars"); - YAHOO.util.Dom.addClass(this.element, "hide-scrollbars"); -} - -/** -* Removes a special CSS class from the Overlay when Mac/Gecko is in use, to work around a Gecko bug where -* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435 -*/ -YAHOO.widget.Overlay.prototype.showMacGeckoScrollbars = function() { - YAHOO.util.Dom.removeClass(this.element, "hide-scrollbars"); - YAHOO.util.Dom.addClass(this.element, "show-scrollbars"); -} - -// BEGIN BUILT-IN PROPERTY EVENT HANDLERS // - -/** -* The default event handler fired when the "visible" property is changed. This method is responsible for firing showEvent and hideEvent. -*/ -YAHOO.widget.Overlay.prototype.configVisible = function(type, args, obj) { - var visible = args[0]; - var currentVis = YAHOO.util.Dom.getStyle(this.element, "visibility"); - - var effect = this.cfg.getProperty("effect"); - - var effectInstances = new Array(); - if (effect) { - if (effect instanceof Array) { - for (var i=0;i0?width:this.element.offsetWidth); //this.element.offsetWidth; - - var viewPortWidth = YAHOO.util.Dom.getViewportWidth(); - var viewPortHeight = YAHOO.util.Dom.getViewportHeight(); - - var scrollX = window.scrollX || document.documentElement.scrollLeft; - var scrollY = window.scrollY || document.documentElement.scrollTop; - - var topConstraint = scrollY + 10; - var leftConstraint = scrollX + 10; - var bottomConstraint = scrollY + viewPortHeight - offsetHeight - 10; - var rightConstraint = scrollX + viewPortWidth - offsetWidth - 10; - - if (x < leftConstraint) { - x = leftConstraint; - } else if (x > rightConstraint) { - x = rightConstraint; - } - - if (y < topConstraint) { - y = topConstraint; - } else if (y > bottomConstraint) { - y = bottomConstraint; - } - - this.cfg.setProperty("x", x, true); - this.cfg.setProperty("y", y, true); - this.cfg.setProperty("xy", [x,y], true); -} - -/** -* Centers the container in the viewport. -*/ -YAHOO.widget.Overlay.prototype.center = function() { - var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft; - var scrollY = document.documentElement.scrollTop || document.body.scrollTop; - - var viewPortWidth = YAHOO.util.Dom.getClientWidth(); - var viewPortHeight = YAHOO.util.Dom.getClientHeight(); - - var elementWidth = this.element.offsetWidth; - var elementHeight = this.element.offsetHeight; - - var x = (viewPortWidth / 2) - (elementWidth / 2) + scrollX; - var y = (viewPortHeight / 2) - (elementHeight / 2) + scrollY; - - this.element.style.left = parseInt(x) + "px"; - this.element.style.top = parseInt(y) + "px"; - this.syncPosition(); - - this.cfg.refireEvent("iframe"); -} - -/** -* Synchronizes the Panel's "xy", "x", and "y" properties with the Panel's position in the DOM. This is primarily used to update position information during drag & drop. -*/ -YAHOO.widget.Overlay.prototype.syncPosition = function() { - var pos = YAHOO.util.Dom.getXY(this.element); - this.cfg.setProperty("x", pos[0], true); - this.cfg.setProperty("y", pos[1], true); - this.cfg.setProperty("xy", pos, true); -} - -/** -* Event handler fired when the resize monitor element is resized. -*/ -YAHOO.widget.Overlay.prototype.onDomResize = function(e, obj) { - YAHOO.widget.Overlay.superclass.onDomResize.call(this, e, obj); - this.cfg.refireEvent("iframe"); -} - -/** -* Removes the Overlay element from the DOM and sets all child elements to null. -*/ -YAHOO.widget.Overlay.prototype.destroy = function() { - if (this.iframe) { - this.iframe.parentNode.removeChild(this.iframe); - } - - this.iframe = null; - - YAHOO.widget.Overlay.superclass.destroy.call(this); -}; - -/** -* Returns a string representation of the object. -* @type string -*/ -YAHOO.widget.Overlay.prototype.toString = function() { - return "Overlay " + this.id; -} - -/** -* A singleton CustomEvent used for reacting to the DOM event for window scroll -* @type YAHOO.util.CustomEvent -*/ -YAHOO.widget.Overlay.windowScrollEvent = new YAHOO.util.CustomEvent("windowScroll"); - -/** -* A singleton CustomEvent used for reacting to the DOM event for window resize -* @type YAHOO.util.CustomEvent -*/ -YAHOO.widget.Overlay.windowResizeEvent = new YAHOO.util.CustomEvent("windowResize"); - -/** -* The DOM event handler used to fire the CustomEvent for window scroll -* @type Function -*/ -YAHOO.widget.Overlay.windowScrollHandler = function(e) { - YAHOO.widget.Overlay.windowScrollEvent.fire(); -} - -/** -* The DOM event handler used to fire the CustomEvent for window resize -* @type Function -*/ -YAHOO.widget.Overlay.windowResizeHandler = function(e) { - YAHOO.widget.Overlay.windowResizeEvent.fire(); -} - -/** -* @private -*/ -YAHOO.widget.Overlay._initialized == null; - -if (YAHOO.widget.Overlay._initialized == null) { - YAHOO.util.Event.addListener(window, "scroll", YAHOO.widget.Overlay.windowScrollHandler); - YAHOO.util.Event.addListener(window, "resize", YAHOO.widget.Overlay.windowResizeHandler); - - YAHOO.widget.Overlay._initialized = true; -} - -/** -* @class -* OverlayManager is used for maintaining the focus status of multiple Overlays. -* @param {Array} overlays Optional. A collection of Overlays to register with the manager. -* @param {object} userConfig The object literal representing the user configuration of the OverlayManager -* @constructor -*/ -YAHOO.widget.OverlayManager = function(userConfig) { - this.init(userConfig); -} - -/** -* The CSS class representing a focused Overlay -* @type string -*/ -YAHOO.widget.OverlayManager.CSS_FOCUSED = "focused"; - -YAHOO.widget.OverlayManager.prototype = { - - constructor : YAHOO.widget.OverlayManager, - - /** - * The array of Overlays that are currently registered - * @type Array - */ - overlays : null, - - /** - * Initializes the default configuration of the OverlayManager - */ - initDefaultConfig : function() { - this.cfg.addProperty("overlays", { suppressEvent:true } ); - this.cfg.addProperty("focusevent", { value:"mousedown" } ); - }, - - /** - * Returns the currently focused Overlay - * @return {Overlay} The currently focused Overlay - */ - getActive : function() {}, - - /** - * Focuses the specified Overlay - * @param {Overlay} The Overlay to focus - * @param {string} The id of the Overlay to focus - */ - focus : function(overlay) {}, - - /** - * Removes the specified Overlay from the manager - * @param {Overlay} The Overlay to remove - * @param {string} The id of the Overlay to remove - */ - remove: function(overlay) {}, - - /** - * Removes focus from all registered Overlays in the manager - */ - blurAll : function() {}, - - /** - * Initializes the OverlayManager - * @param {Array} overlays Optional. A collection of Overlays to register with the manager. - * @param {object} userConfig The object literal representing the user configuration of the OverlayManager - */ - init : function(userConfig) { - this.cfg = new YAHOO.util.Config(this); - - this.initDefaultConfig(); - - if (userConfig) { - this.cfg.applyConfig(userConfig, true); - } - this.cfg.fireQueue(); - - var activeOverlay = null; - - this.getActive = function() { - return activeOverlay; - } - - this.focus = function(overlay) { - var o = this.find(overlay); - if (o) { - this.blurAll(); - activeOverlay = o; - YAHOO.util.Dom.addClass(activeOverlay.element, YAHOO.widget.OverlayManager.CSS_FOCUSED); - this.overlays.sort(this.compareZIndexDesc); - var topZIndex = YAHOO.util.Dom.getStyle(this.overlays[0].element, "zIndex"); - if (! isNaN(topZIndex) && this.overlays[0] != overlay) { - activeOverlay.cfg.setProperty("zIndex", (parseInt(topZIndex) + 1)); - } - this.overlays.sort(this.compareZIndexDesc); - } - } - - this.remove = function(overlay) { - var o = this.find(overlay); - if (o) { - var originalZ = YAHOO.util.Dom.getStyle(o.element, "zIndex"); - o.cfg.setProperty("zIndex", -1000, true); - this.overlays.sort(this.compareZIndexDesc); - this.overlays = this.overlays.slice(0, this.overlays.length-1); - o.cfg.setProperty("zIndex", originalZ, true); - - o.cfg.setProperty("manager", null); - o.focusEvent = null - o.blurEvent = null; - o.focus = null; - o.blur = null; - } - } - - this.blurAll = function() { - activeOverlay = null; - for (var o=0;o 0) { - return true; - } - } else { - return false; - } - }, - - /** - * Attempts to locate an Overlay by instance or ID. - * @param {Overlay} overlay An Overlay to locate within the manager - * @param {string} overlay An Overlay id to locate within the manager - * @return {Overlay} The requested Overlay, if found, or null if it cannot be located. - */ - find : function(overlay) { - if (overlay instanceof YAHOO.widget.Overlay) { - for (var o=0;o zIndex2) { - return -1; - } else if (zIndex1 < zIndex2) { - return 1; - } else { - return 0; - } - }, - - /** - * Shows all Overlays in the manager. - */ - showAll : function() { - for (var o=0;oOR -* @param {Element} el The element representing the Tooltip -* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details. -* @constructor -*/ -YAHOO.widget.Tooltip = function(el, userConfig) { - YAHOO.widget.Tooltip.superclass.constructor.call(this, el, userConfig); -} - -YAHOO.extend(YAHOO.widget.Tooltip, YAHOO.widget.Overlay); - -/** -* Constant representing the Tooltip CSS class -* @type string -* @final -*/ -YAHOO.widget.Tooltip.CSS_TOOLTIP = "tt"; - -/** -* The Tooltip initialization method. This method is automatically called by the constructor. A Tooltip is automatically rendered by the init method, and it also is set to be invisible by default, and constrained to viewport by default as well. -* @param {string} el The element ID representing the Tooltip OR -* @param {Element} el The element representing the Tooltip -* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Tooltip. See configuration documentation for more details. -*/ -YAHOO.widget.Tooltip.prototype.init = function(el, userConfig) { - if (document.readyState && document.readyState != "complete") { - var deferredInit = function() { - this.init(el, userConfig); - } - YAHOO.util.Event.addListener(window, "load", deferredInit, this, true); - } else { - YAHOO.widget.Tooltip.superclass.init.call(this, el); - - this.beforeInitEvent.fire(YAHOO.widget.Tooltip); - - YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Tooltip.CSS_TOOLTIP); - - if (userConfig) { - this.cfg.applyConfig(userConfig, true); - } - - this.cfg.queueProperty("visible",false); - this.cfg.queueProperty("constraintoviewport",true); - - this.setBody(""); - this.render(this.cfg.getProperty("container")); - - this.initEvent.fire(YAHOO.widget.Tooltip); - } -} - -/** -* Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg). -*/ -YAHOO.widget.Tooltip.prototype.initDefaultConfig = function() { - YAHOO.widget.Tooltip.superclass.initDefaultConfig.call(this); - - this.cfg.addProperty("preventoverlap", { value:true, validator:this.cfg.checkBoolean, supercedes:["x","y","xy"] } ); - - this.cfg.addProperty("showdelay", { value:200, handler:this.configShowDelay, validator:this.cfg.checkNumber } ); - this.cfg.addProperty("autodismissdelay", { value:5000, handler:this.configAutoDismissDelay, validator:this.cfg.checkNumber } ); - this.cfg.addProperty("hidedelay", { value:250, handler:this.configHideDelay, validator:this.cfg.checkNumber } ); - - this.cfg.addProperty("text", { handler:this.configText, suppressEvent:true } ); - this.cfg.addProperty("container", { value:document.body, handler:this.configContainer } ); -} - -// BEGIN BUILT-IN PROPERTY EVENT HANDLERS // - -/** -* The default event handler fired when the "text" property is changed. -*/ -YAHOO.widget.Tooltip.prototype.configText = function(type, args, obj) { - var text = args[0]; - if (text) { - this.setBody(text); - } -} - -/** -* The default event handler fired when the "container" property is changed. -*/ -YAHOO.widget.Tooltip.prototype.configContainer = function(type, args, obj) { - var container = args[0]; - if (typeof container == 'string') { - this.cfg.setProperty("container", document.getElementById(container), true); - } -} - -/** -* The default event handler fired when the "context" property is changed. -*/ -YAHOO.widget.Tooltip.prototype.configContext = function(type, args, obj) { - var context = args[0]; - if (context) { - - // Normalize parameter into an array - if (! (context instanceof Array)) { - if (typeof context == "string") { - this.cfg.setProperty("context", [document.getElementById(context)], true); - } else { // Assuming this is an element - this.cfg.setProperty("context", [context], true); - } - context = this.cfg.getProperty("context"); - } - - - // Remove any existing mouseover/mouseout listeners - if (this._context) { - for (var c=0;cOR -* @param {Element} el The element representing the Panel -* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Panel. See configuration documentation for more details. -* @constructor -*/ -YAHOO.widget.Panel = function(el, userConfig) { - YAHOO.widget.Panel.superclass.constructor.call(this, el, userConfig); -} - -YAHOO.extend(YAHOO.widget.Panel, YAHOO.widget.Overlay); - -/** -* Constant representing the default CSS class used for a Panel -* @type string -* @final -*/ -YAHOO.widget.Panel.CSS_PANEL = "panel"; - -/** -* Constant representing the default CSS class used for a Panel's wrapping container -* @type string -* @final -*/ -YAHOO.widget.Panel.CSS_PANEL_CONTAINER = "panel-container"; - -/** -* CustomEvent fired after the modality mask is shown -* args: none -* @type YAHOO.util.CustomEvent -*/ -YAHOO.widget.Panel.prototype.showMaskEvent = null; - -/** -* CustomEvent fired after the modality mask is hidden -* args: none -* @type YAHOO.util.CustomEvent -*/ -YAHOO.widget.Panel.prototype.hideMaskEvent = null; - -/** -* The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present. -* @param {string} el The element ID representing the Overlay OR -* @param {Element} el The element representing the Overlay -* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details. -*/ -YAHOO.widget.Panel.prototype.init = function(el, userConfig) { - YAHOO.widget.Panel.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level - - this.beforeInitEvent.fire(YAHOO.widget.Panel); - - YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Panel.CSS_PANEL); - - this.buildWrapper(); - - if (userConfig) { - this.cfg.applyConfig(userConfig, true); - } - - this.beforeRenderEvent.subscribe(function() { - var draggable = this.cfg.getProperty("draggable"); - if (draggable) { - if (! this.header) { - this.setHeader(" "); - } - } - }, this, true); - - this.initEvent.fire(YAHOO.widget.Panel); - -} - -/** -* Initializes the custom events for Module which are fired automatically at appropriate times by the Module class. -*/ -YAHOO.widget.Panel.prototype.initEvents = function() { - YAHOO.widget.Panel.superclass.initEvents.call(this); - - this.showMaskEvent = new YAHOO.util.CustomEvent("showMask"); - this.hideMaskEvent = new YAHOO.util.CustomEvent("hideMask"); - - this.dragEvent = new YAHOO.util.CustomEvent("drag"); -} - -/** -* Initializes the class's configurable properties which can be changed using the Panel's Config object (cfg). -*/ -YAHOO.widget.Panel.prototype.initDefaultConfig = function() { - YAHOO.widget.Panel.superclass.initDefaultConfig.call(this); - - // Add panel config properties // - - this.cfg.addProperty("close", { value:true, handler:this.configClose, validator:this.cfg.checkBoolean, supercedes:["visible"] } ); - this.cfg.addProperty("draggable", { value:true, handler:this.configDraggable, validator:this.cfg.checkBoolean, supercedes:["visible"] } ); - - this.cfg.addProperty("underlay", { value:"shadow", handler:this.configUnderlay, supercedes:["visible"] } ); - this.cfg.addProperty("modal", { value:false, handler:this.configModal, validator:this.cfg.checkBoolean, supercedes:["visible"] } ); - - this.cfg.addProperty("keylisteners", { handler:this.configKeyListeners, suppressEvent:true, supercedes:["visible"] } ); -} - -// BEGIN BUILT-IN PROPERTY EVENT HANDLERS // - -/** -* The default event handler fired when the "close" property is changed. The method controls the appending or hiding of the close icon at the top right of the Panel. -*/ -YAHOO.widget.Panel.prototype.configClose = function(type, args, obj) { - var val = args[0]; - - var doHide = function(e, obj) { - obj.hide(); - } - - if (val) { - if (! this.close) { - this.close = document.createElement("DIV"); - YAHOO.util.Dom.addClass(this.close, "close"); - - if (this.isSecure) { - YAHOO.util.Dom.addClass(this.close, "secure"); - } else { - YAHOO.util.Dom.addClass(this.close, "nonsecure"); - } - - this.close.innerHTML = " "; - this.innerElement.appendChild(this.close); - YAHOO.util.Event.addListener(this.close, "click", doHide, this); - } else { - this.close.style.display = "block"; - } - } else { - if (this.close) { - this.close.style.display = "none"; - } - } -} - -/** -* The default event handler fired when the "draggable" property is changed. -*/ -YAHOO.widget.Panel.prototype.configDraggable = function(type, args, obj) { - var val = args[0]; - if (val) { - if (this.header) { - YAHOO.util.Dom.setStyle(this.header,"cursor","move"); - this.registerDragDrop(); - } - } else { - if (this.dd) { - this.dd.unreg(); - } - if (this.header) { - YAHOO.util.Dom.setStyle(this.header,"cursor","auto"); - } - } -} - -/** -* The default event handler fired when the "underlay" property is changed. -*/ -YAHOO.widget.Panel.prototype.configUnderlay = function(type, args, obj) { - var val = args[0]; - - switch (val.toLowerCase()) { - case "shadow": - YAHOO.util.Dom.removeClass(this.element, "matte"); - YAHOO.util.Dom.addClass(this.element, "shadow"); - - if (! this.underlay) { // create if not already in DOM - this.underlay = document.createElement("DIV"); - this.underlay.className = "underlay"; - this.underlay.innerHTML = " "; - this.element.appendChild(this.underlay); - } - - this.sizeUnderlay(); - break; - case "matte": - YAHOO.util.Dom.removeClass(this.element, "shadow"); - YAHOO.util.Dom.addClass(this.element, "matte"); - break; - case "none": - default: - YAHOO.util.Dom.removeClass(this.element, "shadow"); - YAHOO.util.Dom.removeClass(this.element, "matte"); - break; - } -} - -/** -* The default event handler fired when the "modal" property is changed. This handler subscribes or unsubscribes to the show and hide events to handle the display or hide of the modality mask. -*/ -YAHOO.widget.Panel.prototype.configModal = function(type, args, obj) { - var modal = args[0]; - - if (modal) { - this.buildMask(); - - if (! YAHOO.util.Config.alreadySubscribed( this.showEvent, this.showMask, this ) ) { - this.showEvent.subscribe(this.showMask, this, true); - } - if (! YAHOO.util.Config.alreadySubscribed( this.hideEvent, this.hideMask, this) ) { - this.hideEvent.subscribe(this.hideMask, this, true); - } - if (! YAHOO.util.Config.alreadySubscribed( YAHOO.widget.Overlay.windowResizeEvent, this.sizeMask, this ) ) { - YAHOO.widget.Overlay.windowResizeEvent.subscribe(this.sizeMask, this, true); - } - if (! YAHOO.util.Config.alreadySubscribed( YAHOO.widget.Overlay.windowScrollEvent, this.sizeMask, this ) ) { - YAHOO.widget.Overlay.windowScrollEvent.subscribe(this.sizeMask, this, true); - } - } else { - this.beforeShowEvent.unsubscribe(this.showMask, this); - this.hideEvent.unsubscribe(this.hideMask, this); - YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.sizeMask); - YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.sizeMask); - } -} - -/** -* The default event handler fired when the "keylisteners" property is changed. -*/ -YAHOO.widget.Panel.prototype.configKeyListeners = function(type, args, obj) { - var listeners = args[0]; - - if (listeners) { - if (listeners instanceof Array) { - for (var i=0;iOR -* @param {Element} appendToNode The element to which the Module should be appended to prior to rendering -* @return {boolean} Success or failure of the render -*/ -YAHOO.widget.Panel.prototype.render = function(appendToNode) { - return YAHOO.widget.Panel.superclass.render.call(this, appendToNode, this.innerElement); -} - -/** -* Returns a string representation of the object. -* @type string -*/ -YAHOO.widget.Panel.prototype.toString = function() { - return "Panel " + this.id; -} - -/** -* @class -* Dialog is an implementation of Panel that can be used to submit form data. Built-in functionality for buttons with event handlers is included, and button sets can be build dynamically, or the preincluded ones for Submit/Cancel and OK/Cancel can be utilized. Forms can be processed in 3 ways -- via an asynchronous Connection utility call, a simple form POST or GET, or manually. -* @param {string} el The element ID representing the Dialog OR -* @param {Element} el The element representing the Dialog -* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Dialog. See configuration documentation for more details. -* @constructor -*/ -YAHOO.widget.Dialog = function(el, userConfig) { - YAHOO.widget.Dialog.superclass.constructor.call(this, el, userConfig); -} - -YAHOO.extend(YAHOO.widget.Dialog, YAHOO.widget.Panel); - -/** -* Constant representing the default CSS class used for a Dialog -* @type string -* @final -*/ -YAHOO.widget.Dialog.CSS_DIALOG = "dialog"; - - -/** -* CustomEvent fired prior to submission -* @type YAHOO.util.CustomEvent -*/ -YAHOO.widget.Dialog.prototype.beforeSubmitEvent = null; - -/** -* CustomEvent fired after submission -* @type YAHOO.util.CustomEvent -*/ -YAHOO.widget.Dialog.prototype.submitEvent = null; - -/** -* CustomEvent fired prior to manual submission -* @type YAHOO.util.CustomEvent -*/ -YAHOO.widget.Dialog.prototype.manualSubmitEvent = null; - -/** -* CustomEvent fired prior to asynchronous submission -* @type YAHOO.util.CustomEvent -*/ -YAHOO.widget.Dialog.prototype.asyncSubmitEvent = null; - -/** -* CustomEvent fired prior to form-based submission -* @type YAHOO.util.CustomEvent -*/ -YAHOO.widget.Dialog.prototype.formSubmitEvent = null; - -/** -* CustomEvent fired after cancel -* @type YAHOO.util.CustomEvent -*/ -YAHOO.widget.Dialog.prototype.cancelEvent = null; - - -/** -* Initializes the class's configurable properties which can be changed using the Dialog's Config object (cfg). -*/ -YAHOO.widget.Dialog.prototype.initDefaultConfig = function() { - YAHOO.widget.Dialog.superclass.initDefaultConfig.call(this); - - /** - * The internally maintained callback object for use with the Connection utility - * @type object - * @private - */ - this.callback = { - success : null, - failure : null, - argument: null, - scope : this - } - - this.doSubmit = function() { - var method = this.cfg.getProperty("postmethod"); - switch (method) { - case "async": - YAHOO.util.Connect.setForm(this.form.name); - var cObj = YAHOO.util.Connect.asyncRequest('POST', this.form.action, this.callback); - this.asyncSubmitEvent.fire(); - break; - case "form": - this.form.submit(); - this.formSubmitEvent.fire(); - break; - case "none": - case "manual": - this.manualSubmitEvent.fire(); - break; - } - } - - // Add form dialog config properties // - this.cfg.addProperty("postmethod", { value:"async", validator:function(val) { - if (val != "form" && val != "async" && val != "none" && val != "manual") { - return false; - } else { - return true; - } - } }); - - this.cfg.addProperty("buttons", { value:"none", handler:this.configButtons } ); -} - -/** -* Initializes the custom events for Dialog which are fired automatically at appropriate times by the Dialog class. -*/ -YAHOO.widget.Dialog.prototype.initEvents = function() { - YAHOO.widget.Dialog.superclass.initEvents.call(this); - - this.beforeSubmitEvent = new YAHOO.util.CustomEvent("beforeSubmit"); - this.submitEvent = new YAHOO.util.CustomEvent("submit"); - - this.manualSubmitEvent = new YAHOO.util.CustomEvent("manualSubmit"); - this.asyncSubmitEvent = new YAHOO.util.CustomEvent("asyncSubmit"); - this.formSubmitEvent = new YAHOO.util.CustomEvent("formSubmit"); - - this.cancelEvent = new YAHOO.util.CustomEvent("cancel"); -} - -/** -* The Dialog initialization method, which is executed for Dialog and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present. -* @param {string} el The element ID representing the Dialog OR -* @param {Element} el The element representing the Dialog -* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Dialog. See configuration documentation for more details. -*/ -YAHOO.widget.Dialog.prototype.init = function(el, userConfig) { - YAHOO.widget.Dialog.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level - - this.beforeInitEvent.fire(YAHOO.widget.Dialog); - - YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Dialog.CSS_DIALOG); - - this.cfg.setProperty("visible", false); - - if (userConfig) { - this.cfg.applyConfig(userConfig, true); - } - - this.renderEvent.subscribe(this.registerForm, this, true); - - this.showEvent.subscribe(this.focusFirst, this, true); - this.beforeHideEvent.subscribe(this.blurButtons, this, true); - - this.beforeRenderEvent.subscribe(function() { - var buttonCfg = this.cfg.getProperty("buttons"); - if (buttonCfg && buttonCfg != "none") { - if (! this.footer) { - this.setFooter(""); - } - } - }, this, true); - - this.initEvent.fire(YAHOO.widget.Dialog); -} - -/** -* Prepares the Dialog's internal FORM object, creating one if one is not currently present. -*/ -YAHOO.widget.Dialog.prototype.registerForm = function() { - var form = this.element.getElementsByTagName("FORM")[0]; - - if (! form) { - var formHTML = "
"; - this.body.innerHTML += formHTML; - form = this.element.getElementsByTagName("FORM")[0]; - } - - this.firstFormElement = function() { - for (var f=0;f=0;f-- ) { - var el = form.elements[f]; - if (el.focus) { - if (el.type && el.type != "hidden") { - return el; - break; - } - } - } - return null; - }(); - - this.form = form; - - if (this.cfg.getProperty("modal") && this.form) { - - var me = this; - - var firstElement = this.firstFormElement || this.firstButton; - if (firstElement) { - this.preventBackTab = new YAHOO.util.KeyListener(firstElement, { shift:true, keys:9 }, {fn:me.focusLast, scope:me, correctScope:true} ); - this.showEvent.subscribe(this.preventBackTab.enable, this.preventBackTab, true); - this.hideEvent.subscribe(this.preventBackTab.disable, this.preventBackTab, true); - } - - var lastElement = this.lastButton || this.lastFormElement; - if (lastElement) { - this.preventTabOut = new YAHOO.util.KeyListener(lastElement, { shift:false, keys:9 }, {fn:me.focusFirst, scope:me, correctScope:true} ); - this.showEvent.subscribe(this.preventTabOut.enable, this.preventTabOut, true); - this.hideEvent.subscribe(this.preventTabOut.disable, this.preventTabOut, true); - } - } -} - -// BEGIN BUILT-IN PROPERTY EVENT HANDLERS // - -/** -* The default event handler for the "buttons" configuration property -*/ -YAHOO.widget.Dialog.prototype.configButtons = function(type, args, obj) { - var buttons = args[0]; - if (buttons != "none") { - this.buttonSpan = null; - this.buttonSpan = document.createElement("SPAN"); - this.buttonSpan.className = "button-group"; - - for (var b=0;bOR -* @param {Element} el The element representing the SimpleDialog -* @param {object} userConfig The configuration object literal containing the configuration that should be set for this SimpleDialog. See configuration documentation for more details. -* @constructor -*/ -YAHOO.widget.SimpleDialog = function(el, userConfig) { - YAHOO.widget.SimpleDialog.superclass.constructor.call(this, el, userConfig); -} - -YAHOO.extend(YAHOO.widget.SimpleDialog, YAHOO.widget.Dialog); - -/** -* Constant for the standard network icon for a blocking action -* @type string -* @final -*/ -YAHOO.widget.SimpleDialog.ICON_BLOCK = "nt/ic/ut/bsc/blck16_1.gif"; - -/** -* Constant for the standard network icon for alarm -* @type string -* @final -*/ -YAHOO.widget.SimpleDialog.ICON_ALARM = "nt/ic/ut/bsc/alrt16_1.gif"; - -/** -* Constant for the standard network icon for help -* @type string -* @final -*/ -YAHOO.widget.SimpleDialog.ICON_HELP = "nt/ic/ut/bsc/hlp16_1.gif"; - -/** -* Constant for the standard network icon for info -* @type string -* @final -*/ -YAHOO.widget.SimpleDialog.ICON_INFO = "nt/ic/ut/bsc/info16_1.gif"; - -/** -* Constant for the standard network icon for warn -* @type string -* @final -*/ -YAHOO.widget.SimpleDialog.ICON_WARN = "nt/ic/ut/bsc/warn16_1.gif"; - -/** -* Constant for the standard network icon for a tip -* @type string -* @final -*/ -YAHOO.widget.SimpleDialog.ICON_TIP = "nt/ic/ut/bsc/tip16_1.gif"; - -/** -* Constant representing the default CSS class used for a SimpleDialog -* @type string -* @final -*/ -YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG = "simple-dialog"; - -/** -* Initializes the class's configurable properties which can be changed using the SimpleDialog's Config object (cfg). -*/ -YAHOO.widget.SimpleDialog.prototype.initDefaultConfig = function() { - YAHOO.widget.SimpleDialog.superclass.initDefaultConfig.call(this); - - // Add dialog config properties // - this.cfg.addProperty("icon", { value:"none", handler:this.configIcon, suppressEvent:true } ); - this.cfg.addProperty("text", { value:"", handler:this.configText, suppressEvent:true, supercedes:["icon"] } ); -} - - -/** -* The SimpleDialog initialization method, which is executed for SimpleDialog and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present. -* @param {string} el The element ID representing the SimpleDialog OR -* @param {Element} el The element representing the SimpleDialog -* @param {object} userConfig The configuration object literal containing the configuration that should be set for this SimpleDialog. See configuration documentation for more details. -*/ -YAHOO.widget.SimpleDialog.prototype.init = function(el, userConfig) { - YAHOO.widget.SimpleDialog.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level - - this.beforeInitEvent.fire(YAHOO.widget.SimpleDialog); - - YAHOO.util.Dom.addClass(this.element, YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG); - - this.cfg.queueProperty("postmethod", "manual"); - - if (userConfig) { - this.cfg.applyConfig(userConfig, true); - } - - this.beforeRenderEvent.subscribe(function() { - if (! this.body) { - this.setBody(""); - } - }, this, true); - - this.initEvent.fire(YAHOO.widget.SimpleDialog); - -} -/** -* Prepares the SimpleDialog's internal FORM object, creating one if one is not currently present, and adding the value hidden field. -*/ -YAHOO.widget.SimpleDialog.prototype.registerForm = function() { - YAHOO.widget.SimpleDialog.superclass.registerForm.call(this); - this.form.innerHTML += ""; -} - -// BEGIN BUILT-IN PROPERTY EVENT HANDLERS // - -/** -* Fired when the "icon" property is set. -*/ -YAHOO.widget.SimpleDialog.prototype.configIcon = function(type,args,obj) { - var icon = args[0]; - if (icon && icon != "none") { - var iconHTML = ""; - this.body.innerHTML = iconHTML + this.body.innerHTML; - } -} - -/** -* Fired when the "text" property is set. -*/ -YAHOO.widget.SimpleDialog.prototype.configText = function(type,args,obj) { - var text = args[0]; - if (text) { - this.setBody(text); - this.cfg.refireEvent("icon"); - } -} -// END BUILT-IN PROPERTY EVENT HANDLERS // - -/** -* Returns a string representation of the object. -* @type string -*/ -YAHOO.widget.SimpleDialog.prototype.toString = function() { - return "SimpleDialog " + this.id; -} - -/** -* @class -* ContainerEffect encapsulates animation transitions that are executed when an Overlay is shown or hidden. -* @param {Overlay} overlay The Overlay that the animation should be associated with -* @param {object} attrIn The object literal representing the animation arguments to be used for the animate-in transition. The arguments for this literal are: attributes(object, see YAHOO.util.Anim for description), duration(float), and method(i.e. YAHOO.util.Easing.easeIn). -* @param {object} attrOut The object literal representing the animation arguments to be used for the animate-out transition. The arguments for this literal are: attributes(object, see YAHOO.util.Anim for description), duration(float), and method(i.e. YAHOO.util.Easing.easeIn). -* @param {Element} targetElement Optional. The target element that should be animated during the transition. Defaults to overlay.element. -* @param {class} Optional. The animation class to instantiate. Defaults to YAHOO.util.Anim. Other options include YAHOO.util.Motion. -* @constructor -*/ -YAHOO.widget.ContainerEffect = function(overlay, attrIn, attrOut, targetElement, animClass) { - if (! animClass) { - animClass = YAHOO.util.Anim; - } - - /** - * The overlay to animate - */ - this.overlay = overlay; - /** - * The animation attributes to use when transitioning into view - */ - this.attrIn = attrIn; - /** - * The animation attributes to use when transitioning out of view - */ - this.attrOut = attrOut; - /** - * The target element to be animated - */ - this.targetElement = targetElement || overlay.element; - /** - * The animation class to use for animating the overlay - */ - this.animClass = animClass; -} - -/** -* Initializes the animation classes and events. -*/ -YAHOO.widget.ContainerEffect.prototype.init = function() { - this.beforeAnimateInEvent = new YAHOO.util.CustomEvent("beforeAnimateIn"); - this.beforeAnimateOutEvent = new YAHOO.util.CustomEvent("beforeAnimateOut"); - - this.animateInCompleteEvent = new YAHOO.util.CustomEvent("animateInComplete"); - this.animateOutCompleteEvent = new YAHOO.util.CustomEvent("animateOutComplete"); - - this.animIn = new this.animClass(this.targetElement, this.attrIn.attributes, this.attrIn.duration, this.attrIn.method); - this.animIn.onStart.subscribe(this.handleStartAnimateIn, this); - this.animIn.onTween.subscribe(this.handleTweenAnimateIn, this); - this.animIn.onComplete.subscribe(this.handleCompleteAnimateIn, this); - - this.animOut = new this.animClass(this.targetElement, this.attrOut.attributes, this.attrOut.duration, this.attrOut.method); - this.animOut.onStart.subscribe(this.handleStartAnimateOut, this); - this.animOut.onTween.subscribe(this.handleTweenAnimateOut, this); - this.animOut.onComplete.subscribe(this.handleCompleteAnimateOut, this); -} - -/** -* Triggers the in-animation. -*/ -YAHOO.widget.ContainerEffect.prototype.animateIn = function() { - this.beforeAnimateInEvent.fire(); - this.animIn.animate(); -} - -/** -* Triggers the out-animation. -*/ -YAHOO.widget.ContainerEffect.prototype.animateOut = function() { - this.beforeAnimateOutEvent.fire(); - this.animOut.animate(); -} - -/** -* The default onStart handler for the in-animation. -*/ -YAHOO.widget.ContainerEffect.prototype.handleStartAnimateIn = function(type, args, obj) { } -/** -* The default onTween handler for the in-animation. -*/ -YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateIn = function(type, args, obj) { } -/** -* The default onComplete handler for the in-animation. -*/ -YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateIn = function(type, args, obj) { } - -/** -* The default onStart handler for the out-animation. -*/ -YAHOO.widget.ContainerEffect.prototype.handleStartAnimateOut = function(type, args, obj) { } -/** -* The default onTween handler for the out-animation. -*/ -YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateOut = function(type, args, obj) { } -/** -* The default onComplete handler for the out-animation. -*/ -YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateOut = function(type, args, obj) { } - -/** -* Returns a string representation of the object. -* @type string -*/ -YAHOO.widget.ContainerEffect.prototype.toString = function() { - var output = "ContainerEffect"; - if (this.overlay) { - output += " [" + this.overlay.toString() + "]"; - } - return output; -} - -/** -* A pre-configured ContainerEffect instance that can be used for fading an overlay in and out. -* @param {Overlay} The Overlay object to animate -* @param {float} The duration of the animation -* @type ContainerEffect -*/ -YAHOO.widget.ContainerEffect.FADE = function(overlay, dur) { - var fade = new YAHOO.widget.ContainerEffect(overlay, { attributes:{opacity: {from:0, to:1}}, duration:dur, method:YAHOO.util.Easing.easeIn }, { attributes:{opacity: {to:0}}, duration:dur, method:YAHOO.util.Easing.easeOut}, overlay.element ); - - fade.handleStartAnimateIn = function(type,args,obj) { - YAHOO.util.Dom.addClass(obj.overlay.element, "hide-select"); - - if (! obj.overlay.underlay) { - obj.overlay.cfg.refireEvent("underlay"); - } - - if (obj.overlay.underlay) { - obj.initialUnderlayOpacity = YAHOO.util.Dom.getStyle(obj.overlay.underlay, "opacity"); - obj.overlay.underlay.style.filter = null; - } - - YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "visible"); - YAHOO.util.Dom.setStyle(obj.overlay.element, "opacity", 0); - } - - fade.handleCompleteAnimateIn = function(type,args,obj) { - YAHOO.util.Dom.removeClass(obj.overlay.element, "hide-select"); - - if (obj.overlay.element.style.filter) { - obj.overlay.element.style.filter = null; - } - - if (obj.overlay.underlay) { - YAHOO.util.Dom.setStyle(obj.overlay.underlay, "opacity", obj.initialUnderlayOpacity); - } - - obj.overlay.cfg.refireEvent("iframe"); - obj.animateInCompleteEvent.fire(); - } - - fade.handleStartAnimateOut = function(type, args, obj) { - YAHOO.util.Dom.addClass(obj.overlay.element, "hide-select"); - - if (obj.overlay.underlay) { - obj.overlay.underlay.style.filter = null; - } - } - - fade.handleCompleteAnimateOut = function(type, args, obj) { - YAHOO.util.Dom.removeClass(obj.overlay.element, "hide-select"); - if (obj.overlay.element.style.filter) { - obj.overlay.element.style.filter = null; - } - YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "hidden"); - YAHOO.util.Dom.setStyle(obj.overlay.element, "opacity", 1); - - obj.overlay.cfg.refireEvent("iframe"); - - obj.animateOutCompleteEvent.fire(); - }; - - fade.init(); - return fade; -}; - - -/** -* A pre-configured ContainerEffect instance that can be used for sliding an overlay in and out. -* @param {Overlay} The Overlay object to animate -* @param {float} The duration of the animation -* @type ContainerEffect -*/ -YAHOO.widget.ContainerEffect.SLIDE = function(overlay, dur) { - var x = overlay.cfg.getProperty("x") || YAHOO.util.Dom.getX(overlay.element); - var y = overlay.cfg.getProperty("y") || YAHOO.util.Dom.getY(overlay.element); - - var clientWidth = YAHOO.util.Dom.getClientWidth(); - var offsetWidth = overlay.element.offsetWidth; - - var slide = new YAHOO.widget.ContainerEffect(overlay, { - attributes:{ points: { to:[x, y] } }, - duration:dur, - method:YAHOO.util.Easing.easeIn - }, - { - attributes:{ points: { to:[(clientWidth+25), y] } }, - duration:dur, - method:YAHOO.util.Easing.easeOut - }, - overlay.element, - YAHOO.util.Motion - ); - - slide.handleStartAnimateIn = function(type,args,obj) { - obj.overlay.element.style.left = (-25-offsetWidth) + "px"; - obj.overlay.element.style.top = y + "px"; - } - - slide.handleTweenAnimateIn = function(type, args, obj) { - - - var pos = YAHOO.util.Dom.getXY(obj.overlay.element); - - var currentX = pos[0]; - var currentY = pos[1]; - - if (YAHOO.util.Dom.getStyle(obj.overlay.element, "visibility") == "hidden" && currentX < x) { - YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "visible"); - } - - obj.overlay.cfg.setProperty("xy", [currentX,currentY], true); - obj.overlay.cfg.refireEvent("iframe"); - } - - slide.handleCompleteAnimateIn = function(type, args, obj) { - obj.overlay.cfg.setProperty("xy", [x,y], true); - obj.startX = x; - obj.startY = y; - obj.overlay.cfg.refireEvent("iframe"); - obj.animateInCompleteEvent.fire(); - } - - slide.handleStartAnimateOut = function(type, args, obj) { - var clientWidth = YAHOO.util.Dom.getViewportWidth(); - - var pos = YAHOO.util.Dom.getXY(obj.overlay.element); - - var x = pos[0]; - var y = pos[1]; - - var currentTo = obj.animOut.attributes.points.to; - obj.animOut.attributes.points.to = [(clientWidth+25), y]; - } - - slide.handleTweenAnimateOut = function(type, args, obj) { - var pos = YAHOO.util.Dom.getXY(obj.overlay.element); - - var x = pos[0]; - var y = pos[1]; - - obj.overlay.cfg.setProperty("xy", [x,y], true); - obj.overlay.cfg.refireEvent("iframe"); - } - - slide.handleCompleteAnimateOut = function(type, args, obj) { - YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "hidden"); - var offsetWidth = obj.overlay.element.offsetWidth; - - obj.overlay.cfg.setProperty("xy", [x,y]); - obj.animateOutCompleteEvent.fire(); - }; - - slide.init(); - return slide; +/* +Copyright (c) 2006, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +Version 0.11.1 +*/ + +/** +* @class +* Config is a utility used within an object to allow the implementer to maintain a list of local configuration properties and listen for changes to those properties dynamically using CustomEvent. The initial values are also maintained so that the configuration can be reset at any given point to its initial state. +* @param {object} owner The owner object to which this Config object belongs +* @constructor +*/ +YAHOO.util.Config = function(owner) { + if (owner) { + this.init(owner); + } +} + +YAHOO.util.Config.prototype = { + + /** + * Object reference to the owner of this Config object + * @type object + */ + owner : null, + + /** + * Object reference to the owner of this Config object + * args: key, value + * @type YAHOO.util.CustomEvent + */ + configChangedEvent : null, + + /** + * Boolean flag that specifies whether a queue is currently being executed + * @type boolean + */ + queueInProgress : false, + + /** + * Adds a property to the Config object's private config hash. + * @param {string} key The configuration property's name + * @param {object} propertyObject The object containing all of this property's arguments + */ + addProperty : function(key, propertyObject){}, + + /** + * Returns a key-value configuration map of the values currently set in the Config object. + * @return {object} The current config, represented in a key-value map + */ + getConfig : function(){}, + + /** + * Returns the value of specified property. + * @param {key} The name of the property + * @return {object} The value of the specified property + */ + getProperty : function(key){}, + + /** + * Resets the specified property's value to its initial value. + * @param {key} The name of the property + */ + resetProperty : function(key){}, + + /** + * Sets the value of a property. If the silent property is passed as true, the property's event will not be fired. + * @param {key} The name of the property + * @param {value} The value to set the property to + * @param {boolean} Whether the value should be set silently, without firing the property event. + * @return {boolean} true, if the set was successful, false if it failed. + */ + setProperty : function(key,value,silent){}, + + /** + * Sets the value of a property and queues its event to execute. If the event is already scheduled to execute, it is + * moved from its current position to the end of the queue. + * @param {key} The name of the property + * @param {value} The value to set the property to + * @return {boolean} true, if the set was successful, false if it failed. + */ + queueProperty : function(key,value){}, + + /** + * Fires the event for a property using the property's current value. + * @param {key} The name of the property + */ + refireEvent : function(key){}, + + /** + * Applies a key-value object literal to the configuration, replacing any existing values, and queueing the property events. + * Although the values will be set, fireQueue() must be called for their associated events to execute. + * @param {object} userConfig The configuration object literal + * @param {boolean} init When set to true, the initialConfig will be set to the userConfig passed in, so that calling a reset will reset the properties to the passed values. + */ + applyConfig : function(userConfig,init){}, + + /** + * Refires the events for all configuration properties using their current values. + */ + refresh : function(){}, + + /** + * Fires the normalized list of queued property change events + */ + fireQueue : function(){}, + + /** + * Subscribes an external handler to the change event for any given property. + * @param {string} key The property name + * @param {Function} handler The handler function to use subscribe to the property's event + * @param {object} obj The object to use for scoping the event handler (see CustomEvent documentation) + * @param {boolean} override Optional. If true, will override "this" within the handler to map to the scope object passed into the method. + */ + subscribeToConfigEvent : function(key,handler,obj,override){}, + + /** + * Unsubscribes an external handler from the change event for any given property. + * @param {string} key The property name + * @param {Function} handler The handler function to use subscribe to the property's event + * @param {object} obj The object to use for scoping the event handler (see CustomEvent documentation) + */ + unsubscribeFromConfigEvent: function(key,handler,obj){}, + + /** + * Validates that the value passed in is a boolean. + * @param {object} val The value to validate + * @return {boolean} true, if the value is valid + */ + checkBoolean: function(val) { + if (typeof val == 'boolean') { + return true; + } else { + return false; + } + }, + + /** + * Validates that the value passed in is a number. + * @param {object} val The value to validate + * @return {boolean} true, if the value is valid + */ + checkNumber: function(val) { + if (isNaN(val)) { + return false; + } else { + return true; + } + } +} + + +/** +* Initializes the configuration object and all of its local members. +* @param {object} owner The owner object to which this Config object belongs +*/ +YAHOO.util.Config.prototype.init = function(owner) { + + this.owner = owner; + this.configChangedEvent = new YAHOO.util.CustomEvent("configChanged"); + this.queueInProgress = false; + + /* Private Members */ + + var config = {}; + var initialConfig = {}; + var eventQueue = []; + + /** + * @private + * Fires a configuration property event using the specified value. + * @param {string} key The configuration property's name + * @param {value} object The value of the correct type for the property + */ + var fireEvent = function( key, value ) { + key = key.toLowerCase(); + + var property = config[key]; + + if (typeof property != 'undefined' && property.event) { + property.event.fire(value); + } + } + /* End Private Members */ + + this.addProperty = function( key, propertyObject ) { + key = key.toLowerCase(); + + config[key] = propertyObject; + + propertyObject.event = new YAHOO.util.CustomEvent(key); + propertyObject.key = key; + + if (propertyObject.handler) { + propertyObject.event.subscribe(propertyObject.handler, this.owner, true); + } + + this.setProperty(key, propertyObject.value, true); + + if (! propertyObject.suppressEvent) { + this.queueProperty(key, propertyObject.value); + } + } + + this.getConfig = function() { + var cfg = {}; + + for (var prop in config) { + var property = config[prop] + if (typeof property != 'undefined' && property.event) { + cfg[prop] = property.value; + } + } + + return cfg; + } + + this.getProperty = function(key) { + key = key.toLowerCase(); + + var property = config[key]; + if (typeof property != 'undefined' && property.event) { + return property.value; + } else { + return undefined; + } + } + + this.resetProperty = function(key) { + key = key.toLowerCase(); + + var property = config[key]; + if (typeof property != 'undefined' && property.event) { + this.setProperty(key, initialConfig[key].value); + } else { + return undefined; + } + } + + this.setProperty = function(key, value, silent) { + key = key.toLowerCase(); + + if (this.queueInProgress && ! silent) { + this.queueProperty(key,value); // Currently running through a queue... + return true; + } else { + var property = config[key]; + if (typeof property != 'undefined' && property.event) { + if (property.validator && ! property.validator(value)) { // validator + return false; + } else { + property.value = value; + if (! silent) { + fireEvent(key, value); + this.configChangedEvent.fire([key, value]); + } + return true; + } + } else { + return false; + } + } + } + + this.queueProperty = function(key, value) { + key = key.toLowerCase(); + + var property = config[key]; + + if (typeof property != 'undefined' && property.event) { + if (typeof value != 'undefined' && property.validator && ! property.validator(value)) { // validator + return false; + } else { + + if (typeof value != 'undefined') { + property.value = value; + } else { + value = property.value; + } + + var foundDuplicate = false; + + for (var i=0;iOR +* @param {Element} el The element representing the Module +* @param {object} userConfig The configuration object literal containing the configuration that should be set for this module. See configuration documentation for more details. +* @constructor +*/ +YAHOO.widget.Module = function(el, userConfig) { + if (el) { + this.init(el, userConfig); + } +} + +/** +* Constant representing the prefix path to use for non-secure images +* @type string +*/ +YAHOO.widget.Module.IMG_ROOT = "http://us.i1.yimg.com/us.yimg.com/i/"; + +/** +* Constant representing the prefix path to use for securely served images +* @type string +*/ +YAHOO.widget.Module.IMG_ROOT_SSL = "https://a248.e.akamai.net/sec.yimg.com/i/"; + +/** +* Constant for the default CSS class name that represents a Module +* @type string +* @final +*/ +YAHOO.widget.Module.CSS_MODULE = "module"; + +/** +* Constant representing the module header +* @type string +* @final +*/ +YAHOO.widget.Module.CSS_HEADER = "hd"; + +/** +* Constant representing the module body +* @type string +* @final +*/ +YAHOO.widget.Module.CSS_BODY = "bd"; + +/** +* Constant representing the module footer +* @type string +* @final +*/ +YAHOO.widget.Module.CSS_FOOTER = "ft"; + +/** +* Constant representing the url for the "src" attribute of the iframe used to monitor changes to the browser's base font size +* @type string +* @final +*/ +YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL = null; + +YAHOO.widget.Module.prototype = { + + /** + * The class's constructor function + * @type function + */ + constructor : YAHOO.widget.Module, + + /** + * The main module element that contains the header, body, and footer + * @type Element + */ + element : null, + + /** + * The header element, denoted with CSS class "hd" + * @type Element + */ + header : null, + + /** + * The body element, denoted with CSS class "bd" + * @type Element + */ + body : null, + + /** + * The footer element, denoted with CSS class "ft" + * @type Element + */ + footer : null, + + /** + * The id of the element + * @type string + */ + id : null, + + /** + * Array of elements + * @type Element[] + */ + childNodesInDOM : null, + + /** + * The string representing the image root + * @type string + */ + imageRoot : YAHOO.widget.Module.IMG_ROOT, + + /** + * CustomEvent fired prior to class initalization. + * args: class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module) + * @type YAHOO.util.CustomEvent + */ + beforeInitEvent : null, + + /** + * CustomEvent fired after class initalization. + * args: class reference of the initializing class, such as this.initEvent.fire(YAHOO.widget.Module) + * @type YAHOO.util.CustomEvent + */ + initEvent : null, + + /** + * CustomEvent fired when the Module is appended to the DOM + * args: none + * @type YAHOO.util.CustomEvent + */ + appendEvent : null, + + /** + * CustomEvent fired before the Module is rendered + * args: none + * @type YAHOO.util.CustomEvent + */ + beforeRenderEvent : null, + + /** + * CustomEvent fired after the Module is rendered + * args: none + * @type YAHOO.util.CustomEvent + */ + renderEvent : null, + + /** + * CustomEvent fired when the header content of the Module is modified + * args: string/element representing the new header content + * @type YAHOO.util.CustomEvent + */ + changeHeaderEvent : null, + + /** + * CustomEvent fired when the body content of the Module is modified + * args: string/element representing the new body content + * @type YAHOO.util.CustomEvent + */ + changeBodyEvent : null, + + /** + * CustomEvent fired when the footer content of the Module is modified + * args: string/element representing the new footer content + * @type YAHOO.util.CustomEvent + */ + changeFooterEvent : null, + + /** + * CustomEvent fired when the content of the Module is modified + * args: none + * @type YAHOO.util.CustomEvent + */ + changeContentEvent : null, + + /** + * CustomEvent fired when the Module is destroyed + * args: none + * @type YAHOO.util.CustomEvent + */ + destroyEvent : null, + + /** + * CustomEvent fired before the Module is shown + * args: none + * @type YAHOO.util.CustomEvent + */ + beforeShowEvent : null, + + /** + * CustomEvent fired after the Module is shown + * args: none + * @type YAHOO.util.CustomEvent + */ + showEvent : null, + + /** + * CustomEvent fired before the Module is hidden + * args: none + * @type YAHOO.util.CustomEvent + */ + beforeHideEvent : null, + + /** + * CustomEvent fired after the Module is hidden + * args: none + * @type YAHOO.util.CustomEvent + */ + hideEvent : null, + + /** + * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class. + */ + initEvents : function() { + + this.beforeInitEvent = new YAHOO.util.CustomEvent("beforeInit"); + this.initEvent = new YAHOO.util.CustomEvent("init"); + + this.appendEvent = new YAHOO.util.CustomEvent("append"); + + this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender"); + this.renderEvent = new YAHOO.util.CustomEvent("render"); + + this.changeHeaderEvent = new YAHOO.util.CustomEvent("changeHeader"); + this.changeBodyEvent = new YAHOO.util.CustomEvent("changeBody"); + this.changeFooterEvent = new YAHOO.util.CustomEvent("changeFooter"); + + this.changeContentEvent = new YAHOO.util.CustomEvent("changeContent"); + + this.destroyEvent = new YAHOO.util.CustomEvent("destroy"); + this.beforeShowEvent = new YAHOO.util.CustomEvent("beforeShow"); + this.showEvent = new YAHOO.util.CustomEvent("show"); + this.beforeHideEvent = new YAHOO.util.CustomEvent("beforeHide"); + this.hideEvent = new YAHOO.util.CustomEvent("hide"); + }, + + /** + * String representing the current user-agent platform + * @type string + */ + platform : function() { + var ua = navigator.userAgent.toLowerCase(); + if (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1) { + return "windows"; + } else if (ua.indexOf("macintosh") != -1) { + return "mac"; + } else { + return false; + } + }(), + + /** + * String representing the current user-agent browser + * @type string + */ + browser : function() { + var ua = navigator.userAgent.toLowerCase(); + if (ua.indexOf('opera')!=-1) { // Opera (check first in case of spoof) + return 'opera'; + } else if (ua.indexOf('msie 7')!=-1) { // IE7 + return 'ie7'; + } else if (ua.indexOf('msie') !=-1) { // IE + return 'ie'; + } else if (ua.indexOf('safari')!=-1) { // Safari (check before Gecko because it includes "like Gecko") + return 'safari'; + } else if (ua.indexOf('gecko') != -1) { // Gecko + return 'gecko'; + } else { + return false; + } + }(), + + /** + * Boolean representing whether or not the current browsing context is secure (https) + * @type boolean + */ + isSecure : function() { + if (window.location.href.toLowerCase().indexOf("https") == 0) { + return true; + } else { + return false; + } + }(), + + /** + * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class. + */ + initDefaultConfig : function() { + // Add properties // + + this.cfg.addProperty("visible", { value:true, handler:this.configVisible, validator:this.cfg.checkBoolean } ); + this.cfg.addProperty("effect", { suppressEvent:true, supercedes:["visible"] } ); + this.cfg.addProperty("monitorresize", { value:true, handler:this.configMonitorResize } ); + }, + + /** + * The Module class's initialization method, which is executed for Module and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present. + * @param {string} el The element ID representing the Module OR + * @param {Element} el The element representing the Module + * @param {object} userConfig The configuration object literal containing the configuration that should be set for this module. See configuration documentation for more details. + */ + init : function(el, userConfig) { + + this.initEvents(); + + this.beforeInitEvent.fire(YAHOO.widget.Module); + + this.cfg = new YAHOO.util.Config(this); + + if (this.isSecure) { + this.imageRoot = YAHOO.widget.Module.IMG_ROOT_SSL; + } + + if (typeof el == "string") { + var elId = el; + + el = document.getElementById(el); + if (! el) { + el = document.createElement("DIV"); + el.id = elId; + } + } + + this.element = el; + + if (el.id) { + this.id = el.id; + } + + var childNodes = this.element.childNodes; + + if (childNodes) { + for (var i=0;iOR + * @param {Element} headerContent The Element to append to the header + */ + setHeader : function(headerContent) { + if (! this.header) { + this.header = document.createElement("DIV"); + this.header.className = YAHOO.widget.Module.CSS_HEADER; + } + + if (typeof headerContent == "string") { + this.header.innerHTML = headerContent; + } else { + this.header.innerHTML = ""; + this.header.appendChild(headerContent); + } + + this.changeHeaderEvent.fire(headerContent); + this.changeContentEvent.fire(); + }, + + /** + * Appends the passed element to the header. If no header is present, one will be automatically created. + * @param {Element} element The element to append to the header + */ + appendToHeader : function(element) { + if (! this.header) { + this.header = document.createElement("DIV"); + this.header.className = YAHOO.widget.Module.CSS_HEADER; + } + + this.header.appendChild(element); + this.changeHeaderEvent.fire(element); + this.changeContentEvent.fire(); + }, + + /** + * Sets the Module's body content to the HTML specified, or appends the passed element to the body. If no body is present, one will be automatically created. + * @param {string} bodyContent The HTML used to set the body OR + * @param {Element} bodyContent The Element to append to the body + */ + setBody : function(bodyContent) { + if (! this.body) { + this.body = document.createElement("DIV"); + this.body.className = YAHOO.widget.Module.CSS_BODY; + } + + if (typeof bodyContent == "string") + { + this.body.innerHTML = bodyContent; + } else { + this.body.innerHTML = ""; + this.body.appendChild(bodyContent); + } + + this.changeBodyEvent.fire(bodyContent); + this.changeContentEvent.fire(); + }, + + /** + * Appends the passed element to the body. If no body is present, one will be automatically created. + * @param {Element} element The element to append to the body + */ + appendToBody : function(element) { + if (! this.body) { + this.body = document.createElement("DIV"); + this.body.className = YAHOO.widget.Module.CSS_BODY; + } + + this.body.appendChild(element); + this.changeBodyEvent.fire(element); + this.changeContentEvent.fire(); + }, + + /** + * Sets the Module's footer content to the HTML specified, or appends the passed element to the footer. If no footer is present, one will be automatically created. + * @param {string} footerContent The HTML used to set the footer OR + * @param {Element} footerContent The Element to append to the footer + */ + setFooter : function(footerContent) { + if (! this.footer) { + this.footer = document.createElement("DIV"); + this.footer.className = YAHOO.widget.Module.CSS_FOOTER; + } + + if (typeof footerContent == "string") { + this.footer.innerHTML = footerContent; + } else { + this.footer.innerHTML = ""; + this.footer.appendChild(footerContent); + } + + this.changeFooterEvent.fire(footerContent); + this.changeContentEvent.fire(); + }, + + /** + * Appends the passed element to the footer. If no footer is present, one will be automatically created. + * @param {Element} element The element to append to the footer + */ + appendToFooter : function(element) { + if (! this.footer) { + this.footer = document.createElement("DIV"); + this.footer.className = YAHOO.widget.Module.CSS_FOOTER; + } + + this.footer.appendChild(element); + this.changeFooterEvent.fire(element); + this.changeContentEvent.fire(); + }, + + /** + * Renders the Module by inserting the elements that are not already in the main Module into their correct places. Optionally appends the Module to the specified node prior to the render's execution. NOTE: For Modules without existing markup, the appendToNode argument is REQUIRED. If this argument is ommitted and the current element is not present in the document, the function will return false, indicating that the render was a failure. + * @param {string} appendToNode The element id to which the Module should be appended to prior to rendering OR + * @param {Element} appendToNode The element to which the Module should be appended to prior to rendering + * @param {Element} moduleElement OPTIONAL. The element that represents the actual Standard Module container. + * @return {boolean} Success or failure of the render + */ + render : function(appendToNode, moduleElement) { + this.beforeRenderEvent.fire(); + + if (! moduleElement) { + moduleElement = this.element; + } + + var me = this; + var appendTo = function(element) { + if (typeof element == "string") { + element = document.getElementById(element); + } + + if (element) { + element.appendChild(me.element); + me.appendEvent.fire(); + } + } + + if (appendToNode) { + appendTo(appendToNode); + } else { // No node was passed in. If the element is not pre-marked up, this fails + if (! YAHOO.util.Dom.inDocument(this.element)) { + return false; + } + } + + // Need to get everything into the DOM if it isn't already + + if (this.header && ! YAHOO.util.Dom.inDocument(this.header)) { + // There is a header, but it's not in the DOM yet... need to add it + var firstChild = moduleElement.firstChild; + if (firstChild) { // Insert before first child if exists + moduleElement.insertBefore(this.header, firstChild); + } else { // Append to empty body because there are no children + moduleElement.appendChild(this.header); + } + } + + if (this.body && ! YAHOO.util.Dom.inDocument(this.body)) { + // There is a body, but it's not in the DOM yet... need to add it + if (this.footer && YAHOO.util.Dom.isAncestor(this.moduleElement, this.footer)) { // Insert before footer if exists in DOM + moduleElement.insertBefore(this.body, this.footer); + } else { // Append to element because there is no footer + moduleElement.appendChild(this.body); + } + } + + if (this.footer && ! YAHOO.util.Dom.inDocument(this.footer)) { + // There is a footer, but it's not in the DOM yet... need to add it + moduleElement.appendChild(this.footer); + } + + this.renderEvent.fire(); + return true; + }, + + /** + * Removes the Module element from the DOM and sets all child elements to null. + */ + destroy : function() { + if (this.element) { + var parent = this.element.parentNode; + } + if (parent) { + parent.removeChild(this.element); + } + + this.element = null; + this.header = null; + this.body = null; + this.footer = null; + + this.destroyEvent.fire(); + }, + + /** + * Shows the Module element by setting the visible configuration property to true. Also fires two events: beforeShowEvent prior to the visibility change, and showEvent after. + */ + show : function() { + this.cfg.setProperty("visible", true); + }, + + /** + * Hides the Module element by setting the visible configuration property to false. Also fires two events: beforeHideEvent prior to the visibility change, and hideEvent after. + */ + hide : function() { + this.cfg.setProperty("visible", false); + }, + + // BUILT-IN EVENT HANDLERS FOR MODULE // + + /** + * Default event handler for changing the visibility property of a Module. By default, this is achieved by switching the "display" style between "block" and "none". + * This method is responsible for firing showEvent and hideEvent. + */ + configVisible : function(type, args, obj) { + var visible = args[0]; + if (visible) { + this.beforeShowEvent.fire(); + YAHOO.util.Dom.setStyle(this.element, "display", "block"); + this.showEvent.fire(); + } else { + this.beforeHideEvent.fire(); + YAHOO.util.Dom.setStyle(this.element, "display", "none"); + this.hideEvent.fire(); + } + }, + + /** + * Default event handler for the "monitorresize" configuration property + */ + configMonitorResize : function(type, args, obj) { + var monitor = args[0]; + if (monitor) { + this.initResizeMonitor(); + } else { + YAHOO.util.Event.removeListener(this.resizeMonitor, "resize", this.onDomResize); + this.resizeMonitor = null; + } + } +} + +/** +* Returns a string representation of the object. +* @type string +*/ +YAHOO.widget.Module.prototype.toString = function() { + return "Module " + this.id; +} + +/** +* @class Overlay is a Module that is absolutely positioned above the page flow. It has convenience methods for positioning and sizing, as well as options for controlling zIndex and constraining the Overlay's position to the current visible viewport. Overlay also contains a dynamicly generated IFRAME which is placed beneath it for Internet Explorer 6 and 5.x so that it will be properly rendered above SELECT elements. +* @param {string} el The element ID representing the Overlay OR +* @param {Element} el The element representing the Overlay +* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details. +* @constructor +*/ +YAHOO.widget.Overlay = function(el, userConfig) { + YAHOO.widget.Overlay.superclass.constructor.call(this, el, userConfig); +} + +YAHOO.extend(YAHOO.widget.Overlay, YAHOO.widget.Module); + +/** +* The URL of the blank image that will be placed in the iframe +* @type string +* @final +*/ +YAHOO.widget.Overlay.IFRAME_SRC = "promo/m/irs/blank.gif"; + +/** +* Constant representing the top left corner of an element, used for configuring the context element alignment +* @type string +* @final +*/ +YAHOO.widget.Overlay.TOP_LEFT = "tl"; + +/** +* Constant representing the top right corner of an element, used for configuring the context element alignment +* @type string +* @final +*/ +YAHOO.widget.Overlay.TOP_RIGHT = "tr"; + +/** +* Constant representing the top bottom left corner of an element, used for configuring the context element alignment +* @type string +* @final +*/ +YAHOO.widget.Overlay.BOTTOM_LEFT = "bl"; + +/** +* Constant representing the bottom right corner of an element, used for configuring the context element alignment +* @type string +* @final +*/ +YAHOO.widget.Overlay.BOTTOM_RIGHT = "br"; + +/** +* Constant representing the default CSS class used for an Overlay +* @type string +* @final +*/ +YAHOO.widget.Overlay.CSS_OVERLAY = "overlay"; + +/** +* CustomEvent fired before the Overlay is moved. +* args: x,y that the Overlay will be moved to +* @type YAHOO.util.CustomEvent +*/ +YAHOO.widget.Overlay.prototype.beforeMoveEvent = null; + +/** +* CustomEvent fired after the Overlay is moved. +* args: x,y that the Overlay was moved to +* @type YAHOO.util.CustomEvent +*/ +YAHOO.widget.Overlay.prototype.moveEvent = null; + +/** +* The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present. +* @param {string} el The element ID representing the Overlay OR +* @param {Element} el The element representing the Overlay +* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details. +*/ +YAHOO.widget.Overlay.prototype.init = function(el, userConfig) { + YAHOO.widget.Overlay.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level + + this.beforeInitEvent.fire(YAHOO.widget.Overlay); + + YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Overlay.CSS_OVERLAY); + + if (userConfig) { + this.cfg.applyConfig(userConfig, true); + } + + if (this.platform == "mac" && this.browser == "gecko") { + if (! YAHOO.util.Config.alreadySubscribed(this.showEvent,this.showMacGeckoScrollbars,this)) { + this.showEvent.subscribe(this.showMacGeckoScrollbars,this,true); + } + if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent,this.hideMacGeckoScrollbars,this)) { + this.hideEvent.subscribe(this.hideMacGeckoScrollbars,this,true); + } + } + + this.initEvent.fire(YAHOO.widget.Overlay); + +} + +/** +* Initializes the custom events for Overlay which are fired automatically at appropriate times by the Overlay class. +*/ +YAHOO.widget.Overlay.prototype.initEvents = function() { + YAHOO.widget.Overlay.superclass.initEvents.call(this); + + this.beforeMoveEvent = new YAHOO.util.CustomEvent("beforeMove", this); + this.moveEvent = new YAHOO.util.CustomEvent("move", this); +} + +/** +* Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg). +*/ +YAHOO.widget.Overlay.prototype.initDefaultConfig = function() { + YAHOO.widget.Overlay.superclass.initDefaultConfig.call(this); + + // Add overlay config properties // + this.cfg.addProperty("x", { handler:this.configX, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } ); + this.cfg.addProperty("y", { handler:this.configY, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } ); + this.cfg.addProperty("xy",{ handler:this.configXY, suppressEvent:true, supercedes:["iframe"] } ); + + this.cfg.addProperty("context", { handler:this.configContext, suppressEvent:true, supercedes:["iframe"] } ); + this.cfg.addProperty("fixedcenter", { value:false, handler:this.configFixedCenter, validator:this.cfg.checkBoolean, supercedes:["iframe","visible"] } ); + + this.cfg.addProperty("width", { handler:this.configWidth, suppressEvent:true, supercedes:["iframe"] } ); + this.cfg.addProperty("height", { handler:this.configHeight, suppressEvent:true, supercedes:["iframe"] } ); + + this.cfg.addProperty("zIndex", { value:null, handler:this.configzIndex } ); + + this.cfg.addProperty("constraintoviewport", { value:false, handler:this.configConstrainToViewport, validator:this.cfg.checkBoolean, supercedes:["iframe","x","y","xy"] } ); + this.cfg.addProperty("iframe", { value:(this.browser == "ie" ? true : false), handler:this.configIframe, validator:this.cfg.checkBoolean, supercedes:["zIndex"] } ); +} + +/** +* Moves the Overlay to the specified position. This function is identical to calling this.cfg.setProperty("xy", [x,y]); +* @param {int} x The Overlay's new x position +* @param {int} y The Overlay's new y position +*/ +YAHOO.widget.Overlay.prototype.moveTo = function(x, y) { + this.cfg.setProperty("xy",[x,y]); +} + +/** +* Adds a special CSS class to the Overlay when Mac/Gecko is in use, to work around a Gecko bug where +* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435 +*/ +YAHOO.widget.Overlay.prototype.hideMacGeckoScrollbars = function() { + YAHOO.util.Dom.removeClass(this.element, "show-scrollbars"); + YAHOO.util.Dom.addClass(this.element, "hide-scrollbars"); +} + +/** +* Removes a special CSS class from the Overlay when Mac/Gecko is in use, to work around a Gecko bug where +* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435 +*/ +YAHOO.widget.Overlay.prototype.showMacGeckoScrollbars = function() { + YAHOO.util.Dom.removeClass(this.element, "hide-scrollbars"); + YAHOO.util.Dom.addClass(this.element, "show-scrollbars"); +} + +// BEGIN BUILT-IN PROPERTY EVENT HANDLERS // + +/** +* The default event handler fired when the "visible" property is changed. This method is responsible for firing showEvent and hideEvent. +*/ +YAHOO.widget.Overlay.prototype.configVisible = function(type, args, obj) { + var visible = args[0]; + var currentVis = YAHOO.util.Dom.getStyle(this.element, "visibility"); + + var effect = this.cfg.getProperty("effect"); + + var effectInstances = new Array(); + if (effect) { + if (effect instanceof Array) { + for (var i=0;i0?width:this.element.offsetWidth); //this.element.offsetWidth; + + var viewPortWidth = YAHOO.util.Dom.getViewportWidth(); + var viewPortHeight = YAHOO.util.Dom.getViewportHeight(); + + var scrollX = window.scrollX || document.documentElement.scrollLeft; + var scrollY = window.scrollY || document.documentElement.scrollTop; + + var topConstraint = scrollY + 10; + var leftConstraint = scrollX + 10; + var bottomConstraint = scrollY + viewPortHeight - offsetHeight - 10; + var rightConstraint = scrollX + viewPortWidth - offsetWidth - 10; + + if (x < leftConstraint) { + x = leftConstraint; + } else if (x > rightConstraint) { + x = rightConstraint; + } + + if (y < topConstraint) { + y = topConstraint; + } else if (y > bottomConstraint) { + y = bottomConstraint; + } + + this.cfg.setProperty("x", x, true); + this.cfg.setProperty("y", y, true); + this.cfg.setProperty("xy", [x,y], true); +} + +/** +* Centers the container in the viewport. +*/ +YAHOO.widget.Overlay.prototype.center = function() { + var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft; + var scrollY = document.documentElement.scrollTop || document.body.scrollTop; + + var viewPortWidth = YAHOO.util.Dom.getClientWidth(); + var viewPortHeight = YAHOO.util.Dom.getClientHeight(); + + var elementWidth = this.element.offsetWidth; + var elementHeight = this.element.offsetHeight; + + var x = (viewPortWidth / 2) - (elementWidth / 2) + scrollX; + var y = (viewPortHeight / 2) - (elementHeight / 2) + scrollY; + + this.element.style.left = parseInt(x) + "px"; + this.element.style.top = parseInt(y) + "px"; + this.syncPosition(); + + this.cfg.refireEvent("iframe"); +} + +/** +* Synchronizes the Panel's "xy", "x", and "y" properties with the Panel's position in the DOM. This is primarily used to update position information during drag & drop. +*/ +YAHOO.widget.Overlay.prototype.syncPosition = function() { + var pos = YAHOO.util.Dom.getXY(this.element); + this.cfg.setProperty("x", pos[0], true); + this.cfg.setProperty("y", pos[1], true); + this.cfg.setProperty("xy", pos, true); +} + +/** +* Event handler fired when the resize monitor element is resized. +*/ +YAHOO.widget.Overlay.prototype.onDomResize = function(e, obj) { + YAHOO.widget.Overlay.superclass.onDomResize.call(this, e, obj); + this.cfg.refireEvent("iframe"); +} + +/** +* Removes the Overlay element from the DOM and sets all child elements to null. +*/ +YAHOO.widget.Overlay.prototype.destroy = function() { + if (this.iframe) { + this.iframe.parentNode.removeChild(this.iframe); + } + + this.iframe = null; + + YAHOO.widget.Overlay.superclass.destroy.call(this); +}; + +/** +* Returns a string representation of the object. +* @type string +*/ +YAHOO.widget.Overlay.prototype.toString = function() { + return "Overlay " + this.id; +} + +/** +* A singleton CustomEvent used for reacting to the DOM event for window scroll +* @type YAHOO.util.CustomEvent +*/ +YAHOO.widget.Overlay.windowScrollEvent = new YAHOO.util.CustomEvent("windowScroll"); + +/** +* A singleton CustomEvent used for reacting to the DOM event for window resize +* @type YAHOO.util.CustomEvent +*/ +YAHOO.widget.Overlay.windowResizeEvent = new YAHOO.util.CustomEvent("windowResize"); + +/** +* The DOM event handler used to fire the CustomEvent for window scroll +* @type Function +*/ +YAHOO.widget.Overlay.windowScrollHandler = function(e) { + YAHOO.widget.Overlay.windowScrollEvent.fire(); +} + +/** +* The DOM event handler used to fire the CustomEvent for window resize +* @type Function +*/ +YAHOO.widget.Overlay.windowResizeHandler = function(e) { + YAHOO.widget.Overlay.windowResizeEvent.fire(); +} + +/** +* @private +*/ +YAHOO.widget.Overlay._initialized == null; + +if (YAHOO.widget.Overlay._initialized == null) { + YAHOO.util.Event.addListener(window, "scroll", YAHOO.widget.Overlay.windowScrollHandler); + YAHOO.util.Event.addListener(window, "resize", YAHOO.widget.Overlay.windowResizeHandler); + + YAHOO.widget.Overlay._initialized = true; +} + +/** +* @class +* OverlayManager is used for maintaining the focus status of multiple Overlays. +* @param {Array} overlays Optional. A collection of Overlays to register with the manager. +* @param {object} userConfig The object literal representing the user configuration of the OverlayManager +* @constructor +*/ +YAHOO.widget.OverlayManager = function(userConfig) { + this.init(userConfig); +} + +/** +* The CSS class representing a focused Overlay +* @type string +*/ +YAHOO.widget.OverlayManager.CSS_FOCUSED = "focused"; + +YAHOO.widget.OverlayManager.prototype = { + + constructor : YAHOO.widget.OverlayManager, + + /** + * The array of Overlays that are currently registered + * @type Array + */ + overlays : null, + + /** + * Initializes the default configuration of the OverlayManager + */ + initDefaultConfig : function() { + this.cfg.addProperty("overlays", { suppressEvent:true } ); + this.cfg.addProperty("focusevent", { value:"mousedown" } ); + }, + + /** + * Returns the currently focused Overlay + * @return {Overlay} The currently focused Overlay + */ + getActive : function() {}, + + /** + * Focuses the specified Overlay + * @param {Overlay} The Overlay to focus + * @param {string} The id of the Overlay to focus + */ + focus : function(overlay) {}, + + /** + * Removes the specified Overlay from the manager + * @param {Overlay} The Overlay to remove + * @param {string} The id of the Overlay to remove + */ + remove: function(overlay) {}, + + /** + * Removes focus from all registered Overlays in the manager + */ + blurAll : function() {}, + + /** + * Initializes the OverlayManager + * @param {Array} overlays Optional. A collection of Overlays to register with the manager. + * @param {object} userConfig The object literal representing the user configuration of the OverlayManager + */ + init : function(userConfig) { + this.cfg = new YAHOO.util.Config(this); + + this.initDefaultConfig(); + + if (userConfig) { + this.cfg.applyConfig(userConfig, true); + } + this.cfg.fireQueue(); + + var activeOverlay = null; + + this.getActive = function() { + return activeOverlay; + } + + this.focus = function(overlay) { + var o = this.find(overlay); + if (o) { + this.blurAll(); + activeOverlay = o; + YAHOO.util.Dom.addClass(activeOverlay.element, YAHOO.widget.OverlayManager.CSS_FOCUSED); + this.overlays.sort(this.compareZIndexDesc); + var topZIndex = YAHOO.util.Dom.getStyle(this.overlays[0].element, "zIndex"); + if (! isNaN(topZIndex) && this.overlays[0] != overlay) { + activeOverlay.cfg.setProperty("zIndex", (parseInt(topZIndex) + 1)); + } + this.overlays.sort(this.compareZIndexDesc); + } + } + + this.remove = function(overlay) { + var o = this.find(overlay); + if (o) { + var originalZ = YAHOO.util.Dom.getStyle(o.element, "zIndex"); + o.cfg.setProperty("zIndex", -1000, true); + this.overlays.sort(this.compareZIndexDesc); + this.overlays = this.overlays.slice(0, this.overlays.length-1); + o.cfg.setProperty("zIndex", originalZ, true); + + o.cfg.setProperty("manager", null); + o.focusEvent = null + o.blurEvent = null; + o.focus = null; + o.blur = null; + } + } + + this.blurAll = function() { + activeOverlay = null; + for (var o=0;o 0) { + return true; + } + } else { + return false; + } + }, + + /** + * Attempts to locate an Overlay by instance or ID. + * @param {Overlay} overlay An Overlay to locate within the manager + * @param {string} overlay An Overlay id to locate within the manager + * @return {Overlay} The requested Overlay, if found, or null if it cannot be located. + */ + find : function(overlay) { + if (overlay instanceof YAHOO.widget.Overlay) { + for (var o=0;o zIndex2) { + return -1; + } else if (zIndex1 < zIndex2) { + return 1; + } else { + return 0; + } + }, + + /** + * Shows all Overlays in the manager. + */ + showAll : function() { + for (var o=0;oOR +* @param {Element} el The element representing the Tooltip +* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details. +* @constructor +*/ +YAHOO.widget.Tooltip = function(el, userConfig) { + YAHOO.widget.Tooltip.superclass.constructor.call(this, el, userConfig); +} + +YAHOO.extend(YAHOO.widget.Tooltip, YAHOO.widget.Overlay); + +/** +* Constant representing the Tooltip CSS class +* @type string +* @final +*/ +YAHOO.widget.Tooltip.CSS_TOOLTIP = "tt"; + +/** +* The Tooltip initialization method. This method is automatically called by the constructor. A Tooltip is automatically rendered by the init method, and it also is set to be invisible by default, and constrained to viewport by default as well. +* @param {string} el The element ID representing the Tooltip OR +* @param {Element} el The element representing the Tooltip +* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Tooltip. See configuration documentation for more details. +*/ +YAHOO.widget.Tooltip.prototype.init = function(el, userConfig) { + if (document.readyState && document.readyState != "complete") { + var deferredInit = function() { + this.init(el, userConfig); + } + YAHOO.util.Event.addListener(window, "load", deferredInit, this, true); + } else { + YAHOO.widget.Tooltip.superclass.init.call(this, el); + + this.beforeInitEvent.fire(YAHOO.widget.Tooltip); + + YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Tooltip.CSS_TOOLTIP); + + if (userConfig) { + this.cfg.applyConfig(userConfig, true); + } + + this.cfg.queueProperty("visible",false); + this.cfg.queueProperty("constraintoviewport",true); + + this.setBody(""); + this.render(this.cfg.getProperty("container")); + + this.initEvent.fire(YAHOO.widget.Tooltip); + } +} + +/** +* Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg). +*/ +YAHOO.widget.Tooltip.prototype.initDefaultConfig = function() { + YAHOO.widget.Tooltip.superclass.initDefaultConfig.call(this); + + this.cfg.addProperty("preventoverlap", { value:true, validator:this.cfg.checkBoolean, supercedes:["x","y","xy"] } ); + + this.cfg.addProperty("showdelay", { value:200, handler:this.configShowDelay, validator:this.cfg.checkNumber } ); + this.cfg.addProperty("autodismissdelay", { value:5000, handler:this.configAutoDismissDelay, validator:this.cfg.checkNumber } ); + this.cfg.addProperty("hidedelay", { value:250, handler:this.configHideDelay, validator:this.cfg.checkNumber } ); + + this.cfg.addProperty("text", { handler:this.configText, suppressEvent:true } ); + this.cfg.addProperty("container", { value:document.body, handler:this.configContainer } ); +} + +// BEGIN BUILT-IN PROPERTY EVENT HANDLERS // + +/** +* The default event handler fired when the "text" property is changed. +*/ +YAHOO.widget.Tooltip.prototype.configText = function(type, args, obj) { + var text = args[0]; + if (text) { + this.setBody(text); + } +} + +/** +* The default event handler fired when the "container" property is changed. +*/ +YAHOO.widget.Tooltip.prototype.configContainer = function(type, args, obj) { + var container = args[0]; + if (typeof container == 'string') { + this.cfg.setProperty("container", document.getElementById(container), true); + } +} + +/** +* The default event handler fired when the "context" property is changed. +*/ +YAHOO.widget.Tooltip.prototype.configContext = function(type, args, obj) { + var context = args[0]; + if (context) { + + // Normalize parameter into an array + if (! (context instanceof Array)) { + if (typeof context == "string") { + this.cfg.setProperty("context", [document.getElementById(context)], true); + } else { // Assuming this is an element + this.cfg.setProperty("context", [context], true); + } + context = this.cfg.getProperty("context"); + } + + + // Remove any existing mouseover/mouseout listeners + if (this._context) { + for (var c=0;cOR +* @param {Element} el The element representing the Panel +* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Panel. See configuration documentation for more details. +* @constructor +*/ +YAHOO.widget.Panel = function(el, userConfig) { + YAHOO.widget.Panel.superclass.constructor.call(this, el, userConfig); +} + +YAHOO.extend(YAHOO.widget.Panel, YAHOO.widget.Overlay); + +/** +* Constant representing the default CSS class used for a Panel +* @type string +* @final +*/ +YAHOO.widget.Panel.CSS_PANEL = "panel"; + +/** +* Constant representing the default CSS class used for a Panel's wrapping container +* @type string +* @final +*/ +YAHOO.widget.Panel.CSS_PANEL_CONTAINER = "panel-container"; + +/** +* CustomEvent fired after the modality mask is shown +* args: none +* @type YAHOO.util.CustomEvent +*/ +YAHOO.widget.Panel.prototype.showMaskEvent = null; + +/** +* CustomEvent fired after the modality mask is hidden +* args: none +* @type YAHOO.util.CustomEvent +*/ +YAHOO.widget.Panel.prototype.hideMaskEvent = null; + +/** +* The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present. +* @param {string} el The element ID representing the Overlay OR +* @param {Element} el The element representing the Overlay +* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details. +*/ +YAHOO.widget.Panel.prototype.init = function(el, userConfig) { + YAHOO.widget.Panel.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level + + this.beforeInitEvent.fire(YAHOO.widget.Panel); + + YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Panel.CSS_PANEL); + + this.buildWrapper(); + + if (userConfig) { + this.cfg.applyConfig(userConfig, true); + } + + this.beforeRenderEvent.subscribe(function() { + var draggable = this.cfg.getProperty("draggable"); + if (draggable) { + if (! this.header) { + this.setHeader(" "); + } + } + }, this, true); + + this.initEvent.fire(YAHOO.widget.Panel); + +} + +/** +* Initializes the custom events for Module which are fired automatically at appropriate times by the Module class. +*/ +YAHOO.widget.Panel.prototype.initEvents = function() { + YAHOO.widget.Panel.superclass.initEvents.call(this); + + this.showMaskEvent = new YAHOO.util.CustomEvent("showMask"); + this.hideMaskEvent = new YAHOO.util.CustomEvent("hideMask"); + + this.dragEvent = new YAHOO.util.CustomEvent("drag"); +} + +/** +* Initializes the class's configurable properties which can be changed using the Panel's Config object (cfg). +*/ +YAHOO.widget.Panel.prototype.initDefaultConfig = function() { + YAHOO.widget.Panel.superclass.initDefaultConfig.call(this); + + // Add panel config properties // + + this.cfg.addProperty("close", { value:true, handler:this.configClose, validator:this.cfg.checkBoolean, supercedes:["visible"] } ); + this.cfg.addProperty("draggable", { value:true, handler:this.configDraggable, validator:this.cfg.checkBoolean, supercedes:["visible"] } ); + + this.cfg.addProperty("underlay", { value:"shadow", handler:this.configUnderlay, supercedes:["visible"] } ); + this.cfg.addProperty("modal", { value:false, handler:this.configModal, validator:this.cfg.checkBoolean, supercedes:["visible"] } ); + + this.cfg.addProperty("keylisteners", { handler:this.configKeyListeners, suppressEvent:true, supercedes:["visible"] } ); +} + +// BEGIN BUILT-IN PROPERTY EVENT HANDLERS // + +/** +* The default event handler fired when the "close" property is changed. The method controls the appending or hiding of the close icon at the top right of the Panel. +*/ +YAHOO.widget.Panel.prototype.configClose = function(type, args, obj) { + var val = args[0]; + + var doHide = function(e, obj) { + obj.hide(); + } + + if (val) { + if (! this.close) { + this.close = document.createElement("DIV"); + YAHOO.util.Dom.addClass(this.close, "close"); + + if (this.isSecure) { + YAHOO.util.Dom.addClass(this.close, "secure"); + } else { + YAHOO.util.Dom.addClass(this.close, "nonsecure"); + } + + this.close.innerHTML = " "; + this.innerElement.appendChild(this.close); + YAHOO.util.Event.addListener(this.close, "click", doHide, this); + } else { + this.close.style.display = "block"; + } + } else { + if (this.close) { + this.close.style.display = "none"; + } + } +} + +/** +* The default event handler fired when the "draggable" property is changed. +*/ +YAHOO.widget.Panel.prototype.configDraggable = function(type, args, obj) { + var val = args[0]; + if (val) { + if (this.header) { + YAHOO.util.Dom.setStyle(this.header,"cursor","move"); + this.registerDragDrop(); + } + } else { + if (this.dd) { + this.dd.unreg(); + } + if (this.header) { + YAHOO.util.Dom.setStyle(this.header,"cursor","auto"); + } + } +} + +/** +* The default event handler fired when the "underlay" property is changed. +*/ +YAHOO.widget.Panel.prototype.configUnderlay = function(type, args, obj) { + var val = args[0]; + + switch (val.toLowerCase()) { + case "shadow": + YAHOO.util.Dom.removeClass(this.element, "matte"); + YAHOO.util.Dom.addClass(this.element, "shadow"); + + if (! this.underlay) { // create if not already in DOM + this.underlay = document.createElement("DIV"); + this.underlay.className = "underlay"; + this.underlay.innerHTML = " "; + this.element.appendChild(this.underlay); + } + + this.sizeUnderlay(); + break; + case "matte": + YAHOO.util.Dom.removeClass(this.element, "shadow"); + YAHOO.util.Dom.addClass(this.element, "matte"); + break; + case "none": + default: + YAHOO.util.Dom.removeClass(this.element, "shadow"); + YAHOO.util.Dom.removeClass(this.element, "matte"); + break; + } +} + +/** +* The default event handler fired when the "modal" property is changed. This handler subscribes or unsubscribes to the show and hide events to handle the display or hide of the modality mask. +*/ +YAHOO.widget.Panel.prototype.configModal = function(type, args, obj) { + var modal = args[0]; + + if (modal) { + this.buildMask(); + + if (! YAHOO.util.Config.alreadySubscribed( this.showEvent, this.showMask, this ) ) { + this.showEvent.subscribe(this.showMask, this, true); + } + if (! YAHOO.util.Config.alreadySubscribed( this.hideEvent, this.hideMask, this) ) { + this.hideEvent.subscribe(this.hideMask, this, true); + } + if (! YAHOO.util.Config.alreadySubscribed( YAHOO.widget.Overlay.windowResizeEvent, this.sizeMask, this ) ) { + YAHOO.widget.Overlay.windowResizeEvent.subscribe(this.sizeMask, this, true); + } + if (! YAHOO.util.Config.alreadySubscribed( YAHOO.widget.Overlay.windowScrollEvent, this.sizeMask, this ) ) { + YAHOO.widget.Overlay.windowScrollEvent.subscribe(this.sizeMask, this, true); + } + } else { + this.beforeShowEvent.unsubscribe(this.showMask, this); + this.hideEvent.unsubscribe(this.hideMask, this); + YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.sizeMask); + YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.sizeMask); + } +} + +/** +* The default event handler fired when the "keylisteners" property is changed. +*/ +YAHOO.widget.Panel.prototype.configKeyListeners = function(type, args, obj) { + var listeners = args[0]; + + if (listeners) { + if (listeners instanceof Array) { + for (var i=0;iOR +* @param {Element} appendToNode The element to which the Module should be appended to prior to rendering +* @return {boolean} Success or failure of the render +*/ +YAHOO.widget.Panel.prototype.render = function(appendToNode) { + return YAHOO.widget.Panel.superclass.render.call(this, appendToNode, this.innerElement); +} + +/** +* Returns a string representation of the object. +* @type string +*/ +YAHOO.widget.Panel.prototype.toString = function() { + return "Panel " + this.id; +} + +/** +* @class +* Dialog is an implementation of Panel that can be used to submit form data. Built-in functionality for buttons with event handlers is included, and button sets can be build dynamically, or the preincluded ones for Submit/Cancel and OK/Cancel can be utilized. Forms can be processed in 3 ways -- via an asynchronous Connection utility call, a simple form POST or GET, or manually. +* @param {string} el The element ID representing the Dialog OR +* @param {Element} el The element representing the Dialog +* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Dialog. See configuration documentation for more details. +* @constructor +*/ +YAHOO.widget.Dialog = function(el, userConfig) { + YAHOO.widget.Dialog.superclass.constructor.call(this, el, userConfig); +} + +YAHOO.extend(YAHOO.widget.Dialog, YAHOO.widget.Panel); + +/** +* Constant representing the default CSS class used for a Dialog +* @type string +* @final +*/ +YAHOO.widget.Dialog.CSS_DIALOG = "dialog"; + + +/** +* CustomEvent fired prior to submission +* @type YAHOO.util.CustomEvent +*/ +YAHOO.widget.Dialog.prototype.beforeSubmitEvent = null; + +/** +* CustomEvent fired after submission +* @type YAHOO.util.CustomEvent +*/ +YAHOO.widget.Dialog.prototype.submitEvent = null; + +/** +* CustomEvent fired prior to manual submission +* @type YAHOO.util.CustomEvent +*/ +YAHOO.widget.Dialog.prototype.manualSubmitEvent = null; + +/** +* CustomEvent fired prior to asynchronous submission +* @type YAHOO.util.CustomEvent +*/ +YAHOO.widget.Dialog.prototype.asyncSubmitEvent = null; + +/** +* CustomEvent fired prior to form-based submission +* @type YAHOO.util.CustomEvent +*/ +YAHOO.widget.Dialog.prototype.formSubmitEvent = null; + +/** +* CustomEvent fired after cancel +* @type YAHOO.util.CustomEvent +*/ +YAHOO.widget.Dialog.prototype.cancelEvent = null; + + +/** +* Initializes the class's configurable properties which can be changed using the Dialog's Config object (cfg). +*/ +YAHOO.widget.Dialog.prototype.initDefaultConfig = function() { + YAHOO.widget.Dialog.superclass.initDefaultConfig.call(this); + + /** + * The internally maintained callback object for use with the Connection utility + * @type object + * @private + */ + this.callback = { + success : null, + failure : null, + argument: null, + scope : this + } + + this.doSubmit = function() { + var method = this.cfg.getProperty("postmethod"); + switch (method) { + case "async": + YAHOO.util.Connect.setForm(this.form.name); + var cObj = YAHOO.util.Connect.asyncRequest('POST', this.form.action, this.callback); + this.asyncSubmitEvent.fire(); + break; + case "form": + this.form.submit(); + this.formSubmitEvent.fire(); + break; + case "none": + case "manual": + this.manualSubmitEvent.fire(); + break; + } + } + + // Add form dialog config properties // + this.cfg.addProperty("postmethod", { value:"async", validator:function(val) { + if (val != "form" && val != "async" && val != "none" && val != "manual") { + return false; + } else { + return true; + } + } }); + + this.cfg.addProperty("buttons", { value:"none", handler:this.configButtons } ); +} + +/** +* Initializes the custom events for Dialog which are fired automatically at appropriate times by the Dialog class. +*/ +YAHOO.widget.Dialog.prototype.initEvents = function() { + YAHOO.widget.Dialog.superclass.initEvents.call(this); + + this.beforeSubmitEvent = new YAHOO.util.CustomEvent("beforeSubmit"); + this.submitEvent = new YAHOO.util.CustomEvent("submit"); + + this.manualSubmitEvent = new YAHOO.util.CustomEvent("manualSubmit"); + this.asyncSubmitEvent = new YAHOO.util.CustomEvent("asyncSubmit"); + this.formSubmitEvent = new YAHOO.util.CustomEvent("formSubmit"); + + this.cancelEvent = new YAHOO.util.CustomEvent("cancel"); +} + +/** +* The Dialog initialization method, which is executed for Dialog and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present. +* @param {string} el The element ID representing the Dialog OR +* @param {Element} el The element representing the Dialog +* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Dialog. See configuration documentation for more details. +*/ +YAHOO.widget.Dialog.prototype.init = function(el, userConfig) { + YAHOO.widget.Dialog.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level + + this.beforeInitEvent.fire(YAHOO.widget.Dialog); + + YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Dialog.CSS_DIALOG); + + this.cfg.setProperty("visible", false); + + if (userConfig) { + this.cfg.applyConfig(userConfig, true); + } + + this.renderEvent.subscribe(this.registerForm, this, true); + + this.showEvent.subscribe(this.focusFirst, this, true); + this.beforeHideEvent.subscribe(this.blurButtons, this, true); + + this.beforeRenderEvent.subscribe(function() { + var buttonCfg = this.cfg.getProperty("buttons"); + if (buttonCfg && buttonCfg != "none") { + if (! this.footer) { + this.setFooter(""); + } + } + }, this, true); + + this.initEvent.fire(YAHOO.widget.Dialog); +} + +/** +* Prepares the Dialog's internal FORM object, creating one if one is not currently present. +*/ +YAHOO.widget.Dialog.prototype.registerForm = function() { + var form = this.element.getElementsByTagName("FORM")[0]; + + if (! form) { + var formHTML = "
"; + this.body.innerHTML += formHTML; + form = this.element.getElementsByTagName("FORM")[0]; + } + + this.firstFormElement = function() { + for (var f=0;f=0;f-- ) { + var el = form.elements[f]; + if (el.focus) { + if (el.type && el.type != "hidden") { + return el; + break; + } + } + } + return null; + }(); + + this.form = form; + + if (this.cfg.getProperty("modal") && this.form) { + + var me = this; + + var firstElement = this.firstFormElement || this.firstButton; + if (firstElement) { + this.preventBackTab = new YAHOO.util.KeyListener(firstElement, { shift:true, keys:9 }, {fn:me.focusLast, scope:me, correctScope:true} ); + this.showEvent.subscribe(this.preventBackTab.enable, this.preventBackTab, true); + this.hideEvent.subscribe(this.preventBackTab.disable, this.preventBackTab, true); + } + + var lastElement = this.lastButton || this.lastFormElement; + if (lastElement) { + this.preventTabOut = new YAHOO.util.KeyListener(lastElement, { shift:false, keys:9 }, {fn:me.focusFirst, scope:me, correctScope:true} ); + this.showEvent.subscribe(this.preventTabOut.enable, this.preventTabOut, true); + this.hideEvent.subscribe(this.preventTabOut.disable, this.preventTabOut, true); + } + } +} + +// BEGIN BUILT-IN PROPERTY EVENT HANDLERS // + +/** +* The default event handler for the "buttons" configuration property +*/ +YAHOO.widget.Dialog.prototype.configButtons = function(type, args, obj) { + var buttons = args[0]; + if (buttons != "none") { + this.buttonSpan = null; + this.buttonSpan = document.createElement("SPAN"); + this.buttonSpan.className = "button-group"; + + for (var b=0;bOR +* @param {Element} el The element representing the SimpleDialog +* @param {object} userConfig The configuration object literal containing the configuration that should be set for this SimpleDialog. See configuration documentation for more details. +* @constructor +*/ +YAHOO.widget.SimpleDialog = function(el, userConfig) { + YAHOO.widget.SimpleDialog.superclass.constructor.call(this, el, userConfig); +} + +YAHOO.extend(YAHOO.widget.SimpleDialog, YAHOO.widget.Dialog); + +/** +* Constant for the standard network icon for a blocking action +* @type string +* @final +*/ +YAHOO.widget.SimpleDialog.ICON_BLOCK = "nt/ic/ut/bsc/blck16_1.gif"; + +/** +* Constant for the standard network icon for alarm +* @type string +* @final +*/ +YAHOO.widget.SimpleDialog.ICON_ALARM = "nt/ic/ut/bsc/alrt16_1.gif"; + +/** +* Constant for the standard network icon for help +* @type string +* @final +*/ +YAHOO.widget.SimpleDialog.ICON_HELP = "nt/ic/ut/bsc/hlp16_1.gif"; + +/** +* Constant for the standard network icon for info +* @type string +* @final +*/ +YAHOO.widget.SimpleDialog.ICON_INFO = "nt/ic/ut/bsc/info16_1.gif"; + +/** +* Constant for the standard network icon for warn +* @type string +* @final +*/ +YAHOO.widget.SimpleDialog.ICON_WARN = "nt/ic/ut/bsc/warn16_1.gif"; + +/** +* Constant for the standard network icon for a tip +* @type string +* @final +*/ +YAHOO.widget.SimpleDialog.ICON_TIP = "nt/ic/ut/bsc/tip16_1.gif"; + +/** +* Constant representing the default CSS class used for a SimpleDialog +* @type string +* @final +*/ +YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG = "simple-dialog"; + +/** +* Initializes the class's configurable properties which can be changed using the SimpleDialog's Config object (cfg). +*/ +YAHOO.widget.SimpleDialog.prototype.initDefaultConfig = function() { + YAHOO.widget.SimpleDialog.superclass.initDefaultConfig.call(this); + + // Add dialog config properties // + this.cfg.addProperty("icon", { value:"none", handler:this.configIcon, suppressEvent:true } ); + this.cfg.addProperty("text", { value:"", handler:this.configText, suppressEvent:true, supercedes:["icon"] } ); +} + + +/** +* The SimpleDialog initialization method, which is executed for SimpleDialog and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present. +* @param {string} el The element ID representing the SimpleDialog OR +* @param {Element} el The element representing the SimpleDialog +* @param {object} userConfig The configuration object literal containing the configuration that should be set for this SimpleDialog. See configuration documentation for more details. +*/ +YAHOO.widget.SimpleDialog.prototype.init = function(el, userConfig) { + YAHOO.widget.SimpleDialog.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level + + this.beforeInitEvent.fire(YAHOO.widget.SimpleDialog); + + YAHOO.util.Dom.addClass(this.element, YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG); + + this.cfg.queueProperty("postmethod", "manual"); + + if (userConfig) { + this.cfg.applyConfig(userConfig, true); + } + + this.beforeRenderEvent.subscribe(function() { + if (! this.body) { + this.setBody(""); + } + }, this, true); + + this.initEvent.fire(YAHOO.widget.SimpleDialog); + +} +/** +* Prepares the SimpleDialog's internal FORM object, creating one if one is not currently present, and adding the value hidden field. +*/ +YAHOO.widget.SimpleDialog.prototype.registerForm = function() { + YAHOO.widget.SimpleDialog.superclass.registerForm.call(this); + this.form.innerHTML += ""; +} + +// BEGIN BUILT-IN PROPERTY EVENT HANDLERS // + +/** +* Fired when the "icon" property is set. +*/ +YAHOO.widget.SimpleDialog.prototype.configIcon = function(type,args,obj) { + var icon = args[0]; + if (icon && icon != "none") { + var iconHTML = ""; + this.body.innerHTML = iconHTML + this.body.innerHTML; + } +} + +/** +* Fired when the "text" property is set. +*/ +YAHOO.widget.SimpleDialog.prototype.configText = function(type,args,obj) { + var text = args[0]; + if (text) { + this.setBody(text); + this.cfg.refireEvent("icon"); + } +} +// END BUILT-IN PROPERTY EVENT HANDLERS // + +/** +* Returns a string representation of the object. +* @type string +*/ +YAHOO.widget.SimpleDialog.prototype.toString = function() { + return "SimpleDialog " + this.id; +} + +/** +* @class +* ContainerEffect encapsulates animation transitions that are executed when an Overlay is shown or hidden. +* @param {Overlay} overlay The Overlay that the animation should be associated with +* @param {object} attrIn The object literal representing the animation arguments to be used for the animate-in transition. The arguments for this literal are: attributes(object, see YAHOO.util.Anim for description), duration(float), and method(i.e. YAHOO.util.Easing.easeIn). +* @param {object} attrOut The object literal representing the animation arguments to be used for the animate-out transition. The arguments for this literal are: attributes(object, see YAHOO.util.Anim for description), duration(float), and method(i.e. YAHOO.util.Easing.easeIn). +* @param {Element} targetElement Optional. The target element that should be animated during the transition. Defaults to overlay.element. +* @param {class} Optional. The animation class to instantiate. Defaults to YAHOO.util.Anim. Other options include YAHOO.util.Motion. +* @constructor +*/ +YAHOO.widget.ContainerEffect = function(overlay, attrIn, attrOut, targetElement, animClass) { + if (! animClass) { + animClass = YAHOO.util.Anim; + } + + /** + * The overlay to animate + */ + this.overlay = overlay; + /** + * The animation attributes to use when transitioning into view + */ + this.attrIn = attrIn; + /** + * The animation attributes to use when transitioning out of view + */ + this.attrOut = attrOut; + /** + * The target element to be animated + */ + this.targetElement = targetElement || overlay.element; + /** + * The animation class to use for animating the overlay + */ + this.animClass = animClass; +} + +/** +* Initializes the animation classes and events. +*/ +YAHOO.widget.ContainerEffect.prototype.init = function() { + this.beforeAnimateInEvent = new YAHOO.util.CustomEvent("beforeAnimateIn"); + this.beforeAnimateOutEvent = new YAHOO.util.CustomEvent("beforeAnimateOut"); + + this.animateInCompleteEvent = new YAHOO.util.CustomEvent("animateInComplete"); + this.animateOutCompleteEvent = new YAHOO.util.CustomEvent("animateOutComplete"); + + this.animIn = new this.animClass(this.targetElement, this.attrIn.attributes, this.attrIn.duration, this.attrIn.method); + this.animIn.onStart.subscribe(this.handleStartAnimateIn, this); + this.animIn.onTween.subscribe(this.handleTweenAnimateIn, this); + this.animIn.onComplete.subscribe(this.handleCompleteAnimateIn, this); + + this.animOut = new this.animClass(this.targetElement, this.attrOut.attributes, this.attrOut.duration, this.attrOut.method); + this.animOut.onStart.subscribe(this.handleStartAnimateOut, this); + this.animOut.onTween.subscribe(this.handleTweenAnimateOut, this); + this.animOut.onComplete.subscribe(this.handleCompleteAnimateOut, this); +} + +/** +* Triggers the in-animation. +*/ +YAHOO.widget.ContainerEffect.prototype.animateIn = function() { + this.beforeAnimateInEvent.fire(); + this.animIn.animate(); +} + +/** +* Triggers the out-animation. +*/ +YAHOO.widget.ContainerEffect.prototype.animateOut = function() { + this.beforeAnimateOutEvent.fire(); + this.animOut.animate(); +} + +/** +* The default onStart handler for the in-animation. +*/ +YAHOO.widget.ContainerEffect.prototype.handleStartAnimateIn = function(type, args, obj) { } +/** +* The default onTween handler for the in-animation. +*/ +YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateIn = function(type, args, obj) { } +/** +* The default onComplete handler for the in-animation. +*/ +YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateIn = function(type, args, obj) { } + +/** +* The default onStart handler for the out-animation. +*/ +YAHOO.widget.ContainerEffect.prototype.handleStartAnimateOut = function(type, args, obj) { } +/** +* The default onTween handler for the out-animation. +*/ +YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateOut = function(type, args, obj) { } +/** +* The default onComplete handler for the out-animation. +*/ +YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateOut = function(type, args, obj) { } + +/** +* Returns a string representation of the object. +* @type string +*/ +YAHOO.widget.ContainerEffect.prototype.toString = function() { + var output = "ContainerEffect"; + if (this.overlay) { + output += " [" + this.overlay.toString() + "]"; + } + return output; +} + +/** +* A pre-configured ContainerEffect instance that can be used for fading an overlay in and out. +* @param {Overlay} The Overlay object to animate +* @param {float} The duration of the animation +* @type ContainerEffect +*/ +YAHOO.widget.ContainerEffect.FADE = function(overlay, dur) { + var fade = new YAHOO.widget.ContainerEffect(overlay, { attributes:{opacity: {from:0, to:1}}, duration:dur, method:YAHOO.util.Easing.easeIn }, { attributes:{opacity: {to:0}}, duration:dur, method:YAHOO.util.Easing.easeOut}, overlay.element ); + + fade.handleStartAnimateIn = function(type,args,obj) { + YAHOO.util.Dom.addClass(obj.overlay.element, "hide-select"); + + if (! obj.overlay.underlay) { + obj.overlay.cfg.refireEvent("underlay"); + } + + if (obj.overlay.underlay) { + obj.initialUnderlayOpacity = YAHOO.util.Dom.getStyle(obj.overlay.underlay, "opacity"); + obj.overlay.underlay.style.filter = null; + } + + YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "visible"); + YAHOO.util.Dom.setStyle(obj.overlay.element, "opacity", 0); + } + + fade.handleCompleteAnimateIn = function(type,args,obj) { + YAHOO.util.Dom.removeClass(obj.overlay.element, "hide-select"); + + if (obj.overlay.element.style.filter) { + obj.overlay.element.style.filter = null; + } + + if (obj.overlay.underlay) { + YAHOO.util.Dom.setStyle(obj.overlay.underlay, "opacity", obj.initialUnderlayOpacity); + } + + obj.overlay.cfg.refireEvent("iframe"); + obj.animateInCompleteEvent.fire(); + } + + fade.handleStartAnimateOut = function(type, args, obj) { + YAHOO.util.Dom.addClass(obj.overlay.element, "hide-select"); + + if (obj.overlay.underlay) { + obj.overlay.underlay.style.filter = null; + } + } + + fade.handleCompleteAnimateOut = function(type, args, obj) { + YAHOO.util.Dom.removeClass(obj.overlay.element, "hide-select"); + if (obj.overlay.element.style.filter) { + obj.overlay.element.style.filter = null; + } + YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "hidden"); + YAHOO.util.Dom.setStyle(obj.overlay.element, "opacity", 1); + + obj.overlay.cfg.refireEvent("iframe"); + + obj.animateOutCompleteEvent.fire(); + }; + + fade.init(); + return fade; +}; + + +/** +* A pre-configured ContainerEffect instance that can be used for sliding an overlay in and out. +* @param {Overlay} The Overlay object to animate +* @param {float} The duration of the animation +* @type ContainerEffect +*/ +YAHOO.widget.ContainerEffect.SLIDE = function(overlay, dur) { + var x = overlay.cfg.getProperty("x") || YAHOO.util.Dom.getX(overlay.element); + var y = overlay.cfg.getProperty("y") || YAHOO.util.Dom.getY(overlay.element); + + var clientWidth = YAHOO.util.Dom.getClientWidth(); + var offsetWidth = overlay.element.offsetWidth; + + var slide = new YAHOO.widget.ContainerEffect(overlay, { + attributes:{ points: { to:[x, y] } }, + duration:dur, + method:YAHOO.util.Easing.easeIn + }, + { + attributes:{ points: { to:[(clientWidth+25), y] } }, + duration:dur, + method:YAHOO.util.Easing.easeOut + }, + overlay.element, + YAHOO.util.Motion + ); + + slide.handleStartAnimateIn = function(type,args,obj) { + obj.overlay.element.style.left = (-25-offsetWidth) + "px"; + obj.overlay.element.style.top = y + "px"; + } + + slide.handleTweenAnimateIn = function(type, args, obj) { + + + var pos = YAHOO.util.Dom.getXY(obj.overlay.element); + + var currentX = pos[0]; + var currentY = pos[1]; + + if (YAHOO.util.Dom.getStyle(obj.overlay.element, "visibility") == "hidden" && currentX < x) { + YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "visible"); + } + + obj.overlay.cfg.setProperty("xy", [currentX,currentY], true); + obj.overlay.cfg.refireEvent("iframe"); + } + + slide.handleCompleteAnimateIn = function(type, args, obj) { + obj.overlay.cfg.setProperty("xy", [x,y], true); + obj.startX = x; + obj.startY = y; + obj.overlay.cfg.refireEvent("iframe"); + obj.animateInCompleteEvent.fire(); + } + + slide.handleStartAnimateOut = function(type, args, obj) { + var clientWidth = YAHOO.util.Dom.getViewportWidth(); + + var pos = YAHOO.util.Dom.getXY(obj.overlay.element); + + var x = pos[0]; + var y = pos[1]; + + var currentTo = obj.animOut.attributes.points.to; + obj.animOut.attributes.points.to = [(clientWidth+25), y]; + } + + slide.handleTweenAnimateOut = function(type, args, obj) { + var pos = YAHOO.util.Dom.getXY(obj.overlay.element); + + var x = pos[0]; + var y = pos[1]; + + obj.overlay.cfg.setProperty("xy", [x,y], true); + obj.overlay.cfg.refireEvent("iframe"); + } + + slide.handleCompleteAnimateOut = function(type, args, obj) { + YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "hidden"); + var offsetWidth = obj.overlay.element.offsetWidth; + + obj.overlay.cfg.setProperty("xy", [x,y]); + obj.animateOutCompleteEvent.fire(); + }; + + slide.init(); + return slide; } \ No newline at end of file diff --git a/webapp/xqts/scripts/dom.js b/webapp/xqts/scripts/dom.js index abf350a820d..a053ed91b66 100644 --- a/webapp/xqts/scripts/dom.js +++ b/webapp/xqts/scripts/dom.js @@ -1,887 +1,887 @@ -/* -Copyright (c) 2006, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -Version: 0.11.1 -*/ - -/** - * @class Provides helper methods for DOM elements. - */ -YAHOO.util.Dom = function() { - var ua = navigator.userAgent.toLowerCase(); - var isOpera = (ua.indexOf('opera') > -1); - var isSafari = (ua.indexOf('safari') > -1); - var isIE = (window.ActiveXObject); - - var id_counter = 0; - var util = YAHOO.util; // internal shorthand - var property_cache = {}; // to cache case conversion for set/getStyle - - var toCamel = function(property) { - var convert = function(prop) { - var test = /(-[a-z])/i.exec(prop); - return prop.replace(RegExp.$1, RegExp.$1.substr(1).toUpperCase()); - }; - - while(property.indexOf('-') > -1) { - property = convert(property); - } - - return property; - //return property.replace(/-([a-z])/gi, function(m0, m1) {return m1.toUpperCase()}) // cant use function as 2nd arg yet due to safari bug - }; - - var toHyphen = function(property) { - if (property.indexOf('-') > -1) { // assume hyphen - return property; - } - - var converted = ''; - for (var i = 0, len = property.length;i < len; ++i) { - if (property.charAt(i) == property.charAt(i).toUpperCase()) { - converted = converted + '-' + property.charAt(i).toLowerCase(); - } else { - converted = converted + property.charAt(i); - } - } - - return converted; - //return property.replace(/([a-z])([A-Z]+)/g, function(m0, m1, m2) {return (m1 + '-' + m2.toLowerCase())}); - }; - - // improve performance by only looking up once - var cacheConvertedProperties = function(property) { - property_cache[property] = { - camel: toCamel(property), - hyphen: toHyphen(property) - }; - }; - - return { - /** - * Returns an HTMLElement reference - * @param {String/HTMLElement/Array} el Accepts a string to use as an ID for getting a DOM reference, an actual DOM reference, or an Array of IDs and/or HTMLElements. - * @return {HTMLElement/Array} A DOM reference to an HTML element or an array of HTMLElements. - */ - get: function(el) { - if (!el) { return null; } // nothing to work with - - if (typeof el != 'string' && !(el instanceof Array) ) { // assuming HTMLElement or HTMLCollection, so pass back as is - return el; - } - - if (typeof el == 'string') { // ID - return document.getElementById(el); - } - else { // array of ID's and/or elements - var collection = []; - for (var i = 0, len = el.length; i < len; ++i) { - collection[collection.length] = util.Dom.get(el[i]); - } - - return collection; - } - - return null; // safety, should never happen - }, - - /** - * Normalizes currentStyle and ComputedStyle. - * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements. - * @param {String} property The style property whose value is returned. - * @return {String/Array} The current value of the style property for the element(s). - */ - getStyle: function(el, property) { - var f = function(el) { - var value = null; - var dv = document.defaultView; - - if (!property_cache[property]) { - cacheConvertedProperties(property); - } - - var camel = property_cache[property]['camel']; - var hyphen = property_cache[property]['hyphen']; - - if (property == 'opacity' && el.filters) {// IE opacity - value = 1; - try { - value = el.filters.item('DXImageTransform.Microsoft.Alpha').opacity / 100; - } catch(e) { - try { - value = el.filters.item('alpha').opacity / 100; - } catch(e) {} - } - } else if (el.style[camel]) { // camelCase for valid styles - value = el.style[camel]; - } - else if (isIE && el.currentStyle && el.currentStyle[camel]) { // camelCase for currentStyle; isIE to workaround broken Opera 9 currentStyle - value = el.currentStyle[camel]; - } - else if ( dv && dv.getComputedStyle ) { // hyphen-case for computedStyle - var computed = dv.getComputedStyle(el, ''); - - if (computed && computed.getPropertyValue(hyphen)) { - value = computed.getPropertyValue(hyphen); - } - } - - return value; - }; - - return util.Dom.batch(el, f, util.Dom, true); - }, - - /** - * Wrapper for setting style properties of HTMLElements. Normalizes "opacity" across modern browsers. - * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements. - * @param {String} property The style property to be set. - * @param {String} val The value to apply to the given property. - */ - setStyle: function(el, property, val) { - if (!property_cache[property]) { - cacheConvertedProperties(property); - } - - var camel = property_cache[property]['camel']; - - var f = function(el) { - switch(property) { - case 'opacity' : - if (isIE && typeof el.style.filter == 'string') { // in case not appended - el.style.filter = 'alpha(opacity=' + val * 100 + ')'; - - if (!el.currentStyle || !el.currentStyle.hasLayout) { - el.style.zoom = 1; // when no layout or cant tell - } - } else { - el.style.opacity = val; - el.style['-moz-opacity'] = val; - el.style['-khtml-opacity'] = val; - } - - break; - default : - el.style[camel] = val; - } - - - }; - - util.Dom.batch(el, f, util.Dom, true); - }, - - /** - * Gets the current position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). - * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements - @ return {Array} The XY position of the element(s) - */ - getXY: function(el) { - var f = function(el) { - - // has to be part of document to have pageXY - if (el.offsetParent === null || this.getStyle(el, 'display') == 'none') { - return false; - } - - var parentNode = null; - var pos = []; - var box; - - if (el.getBoundingClientRect) { // IE - box = el.getBoundingClientRect(); - var doc = document; - if ( !this.inDocument(el) && parent.document != document) {// might be in a frame, need to get its scroll - doc = parent.document; - - if ( !this.isAncestor(doc.documentElement, el) ) { - return false; - } - - } - - var scrollTop = Math.max(doc.documentElement.scrollTop, doc.body.scrollTop); - var scrollLeft = Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft); - - return [box.left + scrollLeft, box.top + scrollTop]; - } - else { // safari, opera, & gecko - pos = [el.offsetLeft, el.offsetTop]; - parentNode = el.offsetParent; - if (parentNode != el) { - while (parentNode) { - pos[0] += parentNode.offsetLeft; - pos[1] += parentNode.offsetTop; - parentNode = parentNode.offsetParent; - } - } - if (isSafari && this.getStyle(el, 'position') == 'absolute' ) { // safari doubles in some cases - pos[0] -= document.body.offsetLeft; - pos[1] -= document.body.offsetTop; - } - } - - if (el.parentNode) { parentNode = el.parentNode; } - else { parentNode = null; } - - while (parentNode && parentNode.tagName.toUpperCase() != 'BODY' && parentNode.tagName.toUpperCase() != 'HTML') - { // account for any scrolled ancestors - pos[0] -= parentNode.scrollLeft; - pos[1] -= parentNode.scrollTop; - - if (parentNode.parentNode) { parentNode = parentNode.parentNode; } - else { parentNode = null; } - } - - - return pos; - }; - - return util.Dom.batch(el, f, util.Dom, true); - }, - - /** - * Gets the current X position of an element based on page coordinates. The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). - * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements - * @return {String/Array} The X position of the element(s) - */ - getX: function(el) { - return util.Dom.getXY(el)[0]; - }, - - /** - * Gets the current Y position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). - * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements - * @return {String/Array} The Y position of the element(s) - */ - getY: function(el) { - return util.Dom.getXY(el)[1]; - }, - - /** - * Set the position of an html element in page coordinates, regardless of how the element is positioned. - * The element(s) must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). - * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements - * @param {Array} pos Contains X & Y values for new position (coordinates are page-based) - * @param {Boolean} noRetry By default we try and set the position a second time if the first fails - */ - setXY: function(el, pos, noRetry) { - var f = function(el) { - var style_pos = this.getStyle(el, 'position'); - if (style_pos == 'static') { // default to relative - this.setStyle(el, 'position', 'relative'); - style_pos = 'relative'; - } - - var pageXY = this.getXY(el); - if (pageXY === false) { // has to be part of doc to have pageXY - return false; - } - - var delta = [ // assuming pixels; if not we will have to retry - parseInt( this.getStyle(el, 'left'), 10 ), - parseInt( this.getStyle(el, 'top'), 10 ) - ]; - - if ( isNaN(delta[0]) ) {// in case of 'auto' - delta[0] = (style_pos == 'relative') ? 0 : el.offsetLeft; - } - if ( isNaN(delta[1]) ) { // in case of 'auto' - delta[1] = (style_pos == 'relative') ? 0 : el.offsetTop; - } - - if (pos[0] !== null) { el.style.left = pos[0] - pageXY[0] + delta[0] + 'px'; } - if (pos[1] !== null) { el.style.top = pos[1] - pageXY[1] + delta[1] + 'px'; } - - var newXY = this.getXY(el); - - // if retry is true, try one more time if we miss - if (!noRetry && (newXY[0] != pos[0] || newXY[1] != pos[1]) ) { - this.setXY(el, pos, true); - } - - }; - - util.Dom.batch(el, f, util.Dom, true); - }, - - /** - * Set the X position of an html element in page coordinates, regardless of how the element is positioned. - * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). - * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements. - * @param {Int} x to use as the X coordinate for the element(s). - */ - setX: function(el, x) { - util.Dom.setXY(el, [x, null]); - }, - - /** - * Set the Y position of an html element in page coordinates, regardless of how the element is positioned. - * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). - * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements. - * @param {Int} x to use as the Y coordinate for the element(s). - */ - setY: function(el, y) { - util.Dom.setXY(el, [null, y]); - }, - - /** - * Returns the region position of the given element. - * The element must be part of the DOM tree to have a region (display:none or elements not appended return false). - * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements. - * @return {Region/Array} A Region or array of Region instances containing "top, left, bottom, right" member data. - */ - getRegion: function(el) { - var f = function(el) { - var region = new YAHOO.util.Region.getRegion(el); - return region; - }; - - return util.Dom.batch(el, f, util.Dom, true); - }, - - /** - * Returns the width of the client (viewport). - * Now using getViewportWidth. This interface left intact for back compat. - * @return {Int} The width of the viewable area of the page. - */ - getClientWidth: function() { - return util.Dom.getViewportWidth(); - }, - - /** - * Returns the height of the client (viewport). - * Now using getViewportHeight. This interface left intact for back compat. - * @return {Int} The height of the viewable area of the page. - */ - getClientHeight: function() { - return util.Dom.getViewportHeight(); - }, - - /** - * Returns a array of HTMLElements with the given class - * For optimized performance, include a tag and/or root node if possible - * @param {String} className The class name to match against - * @param {String} tag (optional) The tag name of the elements being collected - * @param {String/HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point - * @return {Array} An array of elements that have the given class name - */ - getElementsByClassName: function(className, tag, root) { - var method = function(el) { return util.Dom.hasClass(el, className) }; - return util.Dom.getElementsBy(method, tag, root); - }, - - /** - * Determines whether an HTMLElement has the given className - * @param {String/HTMLElement/Array} el The element or collection to test - * @param {String} className the class name to search for - * @return {Boolean/Array} A boolean value or array of boolean values - */ - hasClass: function(el, className) { - var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)'); - - var f = function(el) { - return re.test(el['className']); - }; - - return util.Dom.batch(el, f, util.Dom, true); - }, - - /** - * Adds a class name to a given element or collection of elements - * @param {String/HTMLElement/Array} el The element or collection to add the class to - * @param {String} className the class name to add to the class attribute - */ - addClass: function(el, className) { - var f = function(el) { - if (this.hasClass(el, className)) { return; } // already present - - - el['className'] = [el['className'], className].join(' '); - }; - - util.Dom.batch(el, f, util.Dom, true); - }, - - /** - * Removes a class name from a given element or collection of elements - * @param {String/HTMLElement/Array} el The element or collection to remove the class from - * @param {String} className the class name to remove from the class attribute - */ - removeClass: function(el, className) { - var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)', 'g'); - - var f = function(el) { - if (!this.hasClass(el, className)) { return; } // not present - - - var c = el['className']; - el['className'] = c.replace(re, ' '); - if ( this.hasClass(el, className) ) { // in case of multiple adjacent - this.removeClass(el, className); - } - - }; - - util.Dom.batch(el, f, util.Dom, true); - }, - - /** - * Replace a class with another class for a given element or collection of elements. - * If no oldClassName is present, the newClassName is simply added. - * @param {String/HTMLElement/Array} el The element or collection to remove the class from - * @param {String} oldClassName the class name to be replaced - * @param {String} newClassName the class name that will be replacing the old class name - */ - replaceClass: function(el, oldClassName, newClassName) { - var re = new RegExp('(?:^|\\s+)' + oldClassName + '(?:\\s+|$)', 'g'); - - var f = function(el) { - - if ( !this.hasClass(el, oldClassName) ) { - this.addClass(el, newClassName); // just add it if nothing to replace - return; // note return - } - - el['className'] = el['className'].replace(re, ' ' + newClassName + ' '); - - if ( this.hasClass(el, oldClassName) ) { // in case of multiple adjacent - this.replaceClass(el, oldClassName, newClassName); - } - }; - - util.Dom.batch(el, f, util.Dom, true); - }, - - /** - * Generates a unique ID - * @param {String/HTMLElement/Array} el (optional) An optional element array of elements to add an ID to (no ID is added if one is already present) - * @param {String} prefix (optional) an optional prefix to use (defaults to "yui-gen") - * @return {String/Array} The generated ID, or array of generated IDs (or original ID if already present on an element) - */ - generateId: function(el, prefix) { - prefix = prefix || 'yui-gen'; - el = el || {}; - - var f = function(el) { - if (el) { - el = util.Dom.get(el); - } else { - el = {}; // just generating ID in this case - } - - if (!el.id) { - el.id = prefix + id_counter++; - } // dont override existing - - - return el.id; - }; - - return util.Dom.batch(el, f, util.Dom, true); - }, - - /** - * Determines whether an HTMLElement is an ancestor of another HTML element in the DOM hierarchy - * @param {String/HTMLElement} haystack The possible ancestor - * @param {String/HTMLElement} needle The possible descendent - * @return {Boolean} Whether or not the haystack is an ancestor of needle - */ - isAncestor: function(haystack, needle) { - haystack = util.Dom.get(haystack); - if (!haystack || !needle) { return false; } - - var f = function(needle) { - if (haystack.contains && !isSafari) { // safari "contains" is broken - return haystack.contains(needle); - } - else if ( haystack.compareDocumentPosition ) { - return !!(haystack.compareDocumentPosition(needle) & 16); - } - else { // loop up and test each parent - var parent = needle.parentNode; - - while (parent) { - if (parent == haystack) { - return true; - } - else if (parent.tagName.toUpperCase() == 'HTML') { - return false; - } - - parent = parent.parentNode; - } - return false; - } - }; - - return util.Dom.batch(needle, f, util.Dom, true); - }, - - /** - * Determines whether an HTMLElement is present in the current document - * @param {String/HTMLElement} el The element to search for - * @return {Boolean} Whether or not the element is present in the current document - */ - inDocument: function(el) { - var f = function(el) { - return this.isAncestor(document.documentElement, el); - }; - - return util.Dom.batch(el, f, util.Dom, true); - }, - - /** - * Returns a array of HTMLElements that pass the test applied by supplied boolean method - * For optimized performance, include a tag and/or root node if possible - * @param {Function} method A boolean method to test elements with - * @param {String} tag (optional) The tag name of the elements being collected - * @param {String/HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point - */ - getElementsBy: function(method, tag, root) { - tag = tag || '*'; - root = util.Dom.get(root) || document; - - var nodes = []; - var elements = root.getElementsByTagName(tag); - - if ( !elements.length && (tag == '*' && root.all) ) { - elements = root.all; // IE < 6 - } - - for (var i = 0, len = elements.length; i < len; ++i) - { - if ( method(elements[i]) ) { nodes[nodes.length] = elements[i]; } - } - - - return nodes; - }, - - /** - * Returns an array of elements that have had the supplied method applied. - * The method is called with the element(s) as the first arg, and the optional param as the second ( method(el, o) ) - * @param {String/HTMLElement/Array} el (optional) An element or array of elements to apply the method to - * @param {Function} method The method to apply to the element(s) - * @param {Generic} (optional) o An optional arg that is passed to the supplied method - * @param {Boolean} (optional) override Whether or not to override the scope of "method" with "o" - * @return {HTMLElement/Array} The element(s) with the method applied - */ - batch: function(el, method, o, override) { - var id = el; - el = util.Dom.get(el); - - var scope = (override) ? o : window; - - if (!el || el.tagName || !el.length) { // is null or not a collection (tagName for SELECT and others that can be both an element and a collection) - if (!el) { - return false; - } - return method.call(scope, el, o); - } - - var collection = []; - - for (var i = 0, len = el.length; i < len; ++i) { - if (!el[i]) { - id = id[i]; - } - collection[collection.length] = method.call(scope, el[i], o); - } - - return collection; - }, - - /** - * Returns the height of the document. - * @return {Int} The height of the actual document (which includes the body and its margin). - */ - getDocumentHeight: function() { - var scrollHeight=-1,windowHeight=-1,bodyHeight=-1; - var marginTop = parseInt(util.Dom.getStyle(document.body, 'marginTop'), 10); - var marginBottom = parseInt(util.Dom.getStyle(document.body, 'marginBottom'), 10); - - var mode = document.compatMode; - - if ( (mode || isIE) && !isOpera ) { // (IE, Gecko) - switch (mode) { - case 'CSS1Compat': // Standards mode - scrollHeight = ((window.innerHeight && window.scrollMaxY) ? window.innerHeight+window.scrollMaxY : -1); - windowHeight = [document.documentElement.clientHeight,self.innerHeight||-1].sort(function(a, b){return(a-b);})[1]; - bodyHeight = document.body.offsetHeight + marginTop + marginBottom; - break; - - default: // Quirks - scrollHeight = document.body.scrollHeight; - bodyHeight = document.body.clientHeight; - } - } else { // Safari & Opera - scrollHeight = document.documentElement.scrollHeight; - windowHeight = self.innerHeight; - bodyHeight = document.documentElement.clientHeight; - } - - var h = [scrollHeight,windowHeight,bodyHeight].sort(function(a, b){return(a-b);}); - return h[2]; - }, - - /** - * Returns the width of the document. - * @return {Int} The width of the actual document (which includes the body and its margin). - */ - getDocumentWidth: function() { - var docWidth=-1,bodyWidth=-1,winWidth=-1; - var marginRight = parseInt(util.Dom.getStyle(document.body, 'marginRight'), 10); - var marginLeft = parseInt(util.Dom.getStyle(document.body, 'marginLeft'), 10); - - var mode = document.compatMode; - - if (mode || isIE) { // (IE, Gecko, Opera) - switch (mode) { - case 'CSS1Compat': // Standards mode - docWidth = document.documentElement.clientWidth; - bodyWidth = document.body.offsetWidth + marginLeft + marginRight; - winWidth = self.innerWidth || -1; - break; - - default: // Quirks - bodyWidth = document.body.clientWidth; - winWidth = document.body.scrollWidth; - break; - } - } else { // Safari - docWidth = document.documentElement.clientWidth; - bodyWidth = document.body.offsetWidth + marginLeft + marginRight; - winWidth = self.innerWidth; - } - - var w = [docWidth,bodyWidth,winWidth].sort(function(a, b){return(a-b);}); - return w[2]; - }, - - /** - * Returns the current height of the viewport. - * @return {Int} The height of the viewable area of the page (excludes scrollbars). - */ - getViewportHeight: function() { - var height = -1; - var mode = document.compatMode; - - if ( (mode || isIE) && !isOpera ) { - switch (mode) { // (IE, Gecko) - case 'CSS1Compat': // Standards mode - height = document.documentElement.clientHeight; - break; - - default: // Quirks - height = document.body.clientHeight; - } - } else { // Safari, Opera - height = self.innerHeight; - } - - return height; - }, - - /** - * Returns the current width of the viewport. - * @return {Int} The width of the viewable area of the page (excludes scrollbars). - */ - - getViewportWidth: function() { - var width = -1; - var mode = document.compatMode; - - if (mode || isIE) { // (IE, Gecko, Opera) - switch (mode) { - case 'CSS1Compat': // Standards mode - width = document.documentElement.clientWidth; - break; - - default: // Quirks - width = document.body.clientWidth; - } - } else { // Safari - width = self.innerWidth; - } - return width; - } - }; -}(); - -/** - * @class A region is a representation of an object on a grid. It is defined - * by the top, right, bottom, left extents, so is rectangular by default. If - * other shapes are required, this class could be extended to support it. - * - * @param {int} t the top extent - * @param {int} r the right extent - * @param {int} b the bottom extent - * @param {int} l the left extent - * @constructor - */ -YAHOO.util.Region = function(t, r, b, l) { - - /** - * The region's top extent - * @type int - */ - this.top = t; - - /** - * The region's top extent as index, for symmetry with set/getXY - * @type int - */ - this[1] = t; - - /** - * The region's right extent - * @type int - */ - this.right = r; - - /** - * The region's bottom extent - * @type int - */ - this.bottom = b; - - /** - * The region's left extent - * @type int - */ - this.left = l; - - /** - * The region's left extent as index, for symmetry with set/getXY - * @type int - */ - this[0] = l; -}; - -/** - * Returns true if this region contains the region passed in - * - * @param {Region} region The region to evaluate - * @return {boolean} True if the region is contained with this region, - * else false - */ -YAHOO.util.Region.prototype.contains = function(region) { - return ( region.left >= this.left && - region.right <= this.right && - region.top >= this.top && - region.bottom <= this.bottom ); - -}; - -/** - * Returns the area of the region - * - * @return {int} the region's area - */ -YAHOO.util.Region.prototype.getArea = function() { - return ( (this.bottom - this.top) * (this.right - this.left) ); -}; - -/** - * Returns the region where the passed in region overlaps with this one - * - * @param {Region} region The region that intersects - * @return {Region} The overlap region, or null if there is no overlap - */ -YAHOO.util.Region.prototype.intersect = function(region) { - var t = Math.max( this.top, region.top ); - var r = Math.min( this.right, region.right ); - var b = Math.min( this.bottom, region.bottom ); - var l = Math.max( this.left, region.left ); - - if (b >= t && r >= l) { - return new YAHOO.util.Region(t, r, b, l); - } else { - return null; - } -}; - -/** - * Returns the region representing the smallest region that can contain both - * the passed in region and this region. - * - * @param {Region} region The region that to create the union with - * @return {Region} The union region - */ -YAHOO.util.Region.prototype.union = function(region) { - var t = Math.min( this.top, region.top ); - var r = Math.max( this.right, region.right ); - var b = Math.max( this.bottom, region.bottom ); - var l = Math.min( this.left, region.left ); - - return new YAHOO.util.Region(t, r, b, l); -}; - -/** - * toString - * @return string the region properties - */ -YAHOO.util.Region.prototype.toString = function() { - return ( "Region {" + - "top: " + this.top + - ", right: " + this.right + - ", bottom: " + this.bottom + - ", left: " + this.left + - "}" ); -}; - -/** - * Returns a region that is occupied by the DOM element - * - * @param {HTMLElement} el The element - * @return {Region} The region that the element occupies - * @static - */ -YAHOO.util.Region.getRegion = function(el) { - var p = YAHOO.util.Dom.getXY(el); - - var t = p[1]; - var r = p[0] + el.offsetWidth; - var b = p[1] + el.offsetHeight; - var l = p[0]; - - return new YAHOO.util.Region(t, r, b, l); -}; - -///////////////////////////////////////////////////////////////////////////// - -/** - * @class - * - * A point is a region that is special in that it represents a single point on - * the grid. - * - * @param {int} x The X position of the point - * @param {int} y The Y position of the point - * @constructor - * @extends Region - */ -YAHOO.util.Point = function(x, y) { - if (x instanceof Array) { // accept output from Dom.getXY - y = x[1]; - x = x[0]; - } - - /** - * The X position of the point, which is also the right, left and index zero (for Dom.getXY symmetry) - * @type int - */ - - this.x = this.right = this.left = this[0] = x; - - /** - * The Y position of the point, which is also the top, bottom and index one (for Dom.getXY symmetry) - * @type int - */ - this.y = this.top = this.bottom = this[1] = y; -}; - -YAHOO.util.Point.prototype = new YAHOO.util.Region(); - +/* +Copyright (c) 2006, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +Version: 0.11.1 +*/ + +/** + * @class Provides helper methods for DOM elements. + */ +YAHOO.util.Dom = function() { + var ua = navigator.userAgent.toLowerCase(); + var isOpera = (ua.indexOf('opera') > -1); + var isSafari = (ua.indexOf('safari') > -1); + var isIE = (window.ActiveXObject); + + var id_counter = 0; + var util = YAHOO.util; // internal shorthand + var property_cache = {}; // to cache case conversion for set/getStyle + + var toCamel = function(property) { + var convert = function(prop) { + var test = /(-[a-z])/i.exec(prop); + return prop.replace(RegExp.$1, RegExp.$1.substr(1).toUpperCase()); + }; + + while(property.indexOf('-') > -1) { + property = convert(property); + } + + return property; + //return property.replace(/-([a-z])/gi, function(m0, m1) {return m1.toUpperCase()}) // cant use function as 2nd arg yet due to safari bug + }; + + var toHyphen = function(property) { + if (property.indexOf('-') > -1) { // assume hyphen + return property; + } + + var converted = ''; + for (var i = 0, len = property.length;i < len; ++i) { + if (property.charAt(i) == property.charAt(i).toUpperCase()) { + converted = converted + '-' + property.charAt(i).toLowerCase(); + } else { + converted = converted + property.charAt(i); + } + } + + return converted; + //return property.replace(/([a-z])([A-Z]+)/g, function(m0, m1, m2) {return (m1 + '-' + m2.toLowerCase())}); + }; + + // improve performance by only looking up once + var cacheConvertedProperties = function(property) { + property_cache[property] = { + camel: toCamel(property), + hyphen: toHyphen(property) + }; + }; + + return { + /** + * Returns an HTMLElement reference + * @param {String/HTMLElement/Array} el Accepts a string to use as an ID for getting a DOM reference, an actual DOM reference, or an Array of IDs and/or HTMLElements. + * @return {HTMLElement/Array} A DOM reference to an HTML element or an array of HTMLElements. + */ + get: function(el) { + if (!el) { return null; } // nothing to work with + + if (typeof el != 'string' && !(el instanceof Array) ) { // assuming HTMLElement or HTMLCollection, so pass back as is + return el; + } + + if (typeof el == 'string') { // ID + return document.getElementById(el); + } + else { // array of ID's and/or elements + var collection = []; + for (var i = 0, len = el.length; i < len; ++i) { + collection[collection.length] = util.Dom.get(el[i]); + } + + return collection; + } + + return null; // safety, should never happen + }, + + /** + * Normalizes currentStyle and ComputedStyle. + * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements. + * @param {String} property The style property whose value is returned. + * @return {String/Array} The current value of the style property for the element(s). + */ + getStyle: function(el, property) { + var f = function(el) { + var value = null; + var dv = document.defaultView; + + if (!property_cache[property]) { + cacheConvertedProperties(property); + } + + var camel = property_cache[property]['camel']; + var hyphen = property_cache[property]['hyphen']; + + if (property == 'opacity' && el.filters) {// IE opacity + value = 1; + try { + value = el.filters.item('DXImageTransform.Microsoft.Alpha').opacity / 100; + } catch(e) { + try { + value = el.filters.item('alpha').opacity / 100; + } catch(e) {} + } + } else if (el.style[camel]) { // camelCase for valid styles + value = el.style[camel]; + } + else if (isIE && el.currentStyle && el.currentStyle[camel]) { // camelCase for currentStyle; isIE to workaround broken Opera 9 currentStyle + value = el.currentStyle[camel]; + } + else if ( dv && dv.getComputedStyle ) { // hyphen-case for computedStyle + var computed = dv.getComputedStyle(el, ''); + + if (computed && computed.getPropertyValue(hyphen)) { + value = computed.getPropertyValue(hyphen); + } + } + + return value; + }; + + return util.Dom.batch(el, f, util.Dom, true); + }, + + /** + * Wrapper for setting style properties of HTMLElements. Normalizes "opacity" across modern browsers. + * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements. + * @param {String} property The style property to be set. + * @param {String} val The value to apply to the given property. + */ + setStyle: function(el, property, val) { + if (!property_cache[property]) { + cacheConvertedProperties(property); + } + + var camel = property_cache[property]['camel']; + + var f = function(el) { + switch(property) { + case 'opacity' : + if (isIE && typeof el.style.filter == 'string') { // in case not appended + el.style.filter = 'alpha(opacity=' + val * 100 + ')'; + + if (!el.currentStyle || !el.currentStyle.hasLayout) { + el.style.zoom = 1; // when no layout or cant tell + } + } else { + el.style.opacity = val; + el.style['-moz-opacity'] = val; + el.style['-khtml-opacity'] = val; + } + + break; + default : + el.style[camel] = val; + } + + + }; + + util.Dom.batch(el, f, util.Dom, true); + }, + + /** + * Gets the current position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). + * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements + @ return {Array} The XY position of the element(s) + */ + getXY: function(el) { + var f = function(el) { + + // has to be part of document to have pageXY + if (el.offsetParent === null || this.getStyle(el, 'display') == 'none') { + return false; + } + + var parentNode = null; + var pos = []; + var box; + + if (el.getBoundingClientRect) { // IE + box = el.getBoundingClientRect(); + var doc = document; + if ( !this.inDocument(el) && parent.document != document) {// might be in a frame, need to get its scroll + doc = parent.document; + + if ( !this.isAncestor(doc.documentElement, el) ) { + return false; + } + + } + + var scrollTop = Math.max(doc.documentElement.scrollTop, doc.body.scrollTop); + var scrollLeft = Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft); + + return [box.left + scrollLeft, box.top + scrollTop]; + } + else { // safari, opera, & gecko + pos = [el.offsetLeft, el.offsetTop]; + parentNode = el.offsetParent; + if (parentNode != el) { + while (parentNode) { + pos[0] += parentNode.offsetLeft; + pos[1] += parentNode.offsetTop; + parentNode = parentNode.offsetParent; + } + } + if (isSafari && this.getStyle(el, 'position') == 'absolute' ) { // safari doubles in some cases + pos[0] -= document.body.offsetLeft; + pos[1] -= document.body.offsetTop; + } + } + + if (el.parentNode) { parentNode = el.parentNode; } + else { parentNode = null; } + + while (parentNode && parentNode.tagName.toUpperCase() != 'BODY' && parentNode.tagName.toUpperCase() != 'HTML') + { // account for any scrolled ancestors + pos[0] -= parentNode.scrollLeft; + pos[1] -= parentNode.scrollTop; + + if (parentNode.parentNode) { parentNode = parentNode.parentNode; } + else { parentNode = null; } + } + + + return pos; + }; + + return util.Dom.batch(el, f, util.Dom, true); + }, + + /** + * Gets the current X position of an element based on page coordinates. The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). + * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements + * @return {String/Array} The X position of the element(s) + */ + getX: function(el) { + return util.Dom.getXY(el)[0]; + }, + + /** + * Gets the current Y position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). + * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements + * @return {String/Array} The Y position of the element(s) + */ + getY: function(el) { + return util.Dom.getXY(el)[1]; + }, + + /** + * Set the position of an html element in page coordinates, regardless of how the element is positioned. + * The element(s) must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). + * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements + * @param {Array} pos Contains X & Y values for new position (coordinates are page-based) + * @param {Boolean} noRetry By default we try and set the position a second time if the first fails + */ + setXY: function(el, pos, noRetry) { + var f = function(el) { + var style_pos = this.getStyle(el, 'position'); + if (style_pos == 'static') { // default to relative + this.setStyle(el, 'position', 'relative'); + style_pos = 'relative'; + } + + var pageXY = this.getXY(el); + if (pageXY === false) { // has to be part of doc to have pageXY + return false; + } + + var delta = [ // assuming pixels; if not we will have to retry + parseInt( this.getStyle(el, 'left'), 10 ), + parseInt( this.getStyle(el, 'top'), 10 ) + ]; + + if ( isNaN(delta[0]) ) {// in case of 'auto' + delta[0] = (style_pos == 'relative') ? 0 : el.offsetLeft; + } + if ( isNaN(delta[1]) ) { // in case of 'auto' + delta[1] = (style_pos == 'relative') ? 0 : el.offsetTop; + } + + if (pos[0] !== null) { el.style.left = pos[0] - pageXY[0] + delta[0] + 'px'; } + if (pos[1] !== null) { el.style.top = pos[1] - pageXY[1] + delta[1] + 'px'; } + + var newXY = this.getXY(el); + + // if retry is true, try one more time if we miss + if (!noRetry && (newXY[0] != pos[0] || newXY[1] != pos[1]) ) { + this.setXY(el, pos, true); + } + + }; + + util.Dom.batch(el, f, util.Dom, true); + }, + + /** + * Set the X position of an html element in page coordinates, regardless of how the element is positioned. + * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). + * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements. + * @param {Int} x to use as the X coordinate for the element(s). + */ + setX: function(el, x) { + util.Dom.setXY(el, [x, null]); + }, + + /** + * Set the Y position of an html element in page coordinates, regardless of how the element is positioned. + * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false). + * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements. + * @param {Int} x to use as the Y coordinate for the element(s). + */ + setY: function(el, y) { + util.Dom.setXY(el, [null, y]); + }, + + /** + * Returns the region position of the given element. + * The element must be part of the DOM tree to have a region (display:none or elements not appended return false). + * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements. + * @return {Region/Array} A Region or array of Region instances containing "top, left, bottom, right" member data. + */ + getRegion: function(el) { + var f = function(el) { + var region = new YAHOO.util.Region.getRegion(el); + return region; + }; + + return util.Dom.batch(el, f, util.Dom, true); + }, + + /** + * Returns the width of the client (viewport). + * Now using getViewportWidth. This interface left intact for back compat. + * @return {Int} The width of the viewable area of the page. + */ + getClientWidth: function() { + return util.Dom.getViewportWidth(); + }, + + /** + * Returns the height of the client (viewport). + * Now using getViewportHeight. This interface left intact for back compat. + * @return {Int} The height of the viewable area of the page. + */ + getClientHeight: function() { + return util.Dom.getViewportHeight(); + }, + + /** + * Returns a array of HTMLElements with the given class + * For optimized performance, include a tag and/or root node if possible + * @param {String} className The class name to match against + * @param {String} tag (optional) The tag name of the elements being collected + * @param {String/HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point + * @return {Array} An array of elements that have the given class name + */ + getElementsByClassName: function(className, tag, root) { + var method = function(el) { return util.Dom.hasClass(el, className) }; + return util.Dom.getElementsBy(method, tag, root); + }, + + /** + * Determines whether an HTMLElement has the given className + * @param {String/HTMLElement/Array} el The element or collection to test + * @param {String} className the class name to search for + * @return {Boolean/Array} A boolean value or array of boolean values + */ + hasClass: function(el, className) { + var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)'); + + var f = function(el) { + return re.test(el['className']); + }; + + return util.Dom.batch(el, f, util.Dom, true); + }, + + /** + * Adds a class name to a given element or collection of elements + * @param {String/HTMLElement/Array} el The element or collection to add the class to + * @param {String} className the class name to add to the class attribute + */ + addClass: function(el, className) { + var f = function(el) { + if (this.hasClass(el, className)) { return; } // already present + + + el['className'] = [el['className'], className].join(' '); + }; + + util.Dom.batch(el, f, util.Dom, true); + }, + + /** + * Removes a class name from a given element or collection of elements + * @param {String/HTMLElement/Array} el The element or collection to remove the class from + * @param {String} className the class name to remove from the class attribute + */ + removeClass: function(el, className) { + var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)', 'g'); + + var f = function(el) { + if (!this.hasClass(el, className)) { return; } // not present + + + var c = el['className']; + el['className'] = c.replace(re, ' '); + if ( this.hasClass(el, className) ) { // in case of multiple adjacent + this.removeClass(el, className); + } + + }; + + util.Dom.batch(el, f, util.Dom, true); + }, + + /** + * Replace a class with another class for a given element or collection of elements. + * If no oldClassName is present, the newClassName is simply added. + * @param {String/HTMLElement/Array} el The element or collection to remove the class from + * @param {String} oldClassName the class name to be replaced + * @param {String} newClassName the class name that will be replacing the old class name + */ + replaceClass: function(el, oldClassName, newClassName) { + var re = new RegExp('(?:^|\\s+)' + oldClassName + '(?:\\s+|$)', 'g'); + + var f = function(el) { + + if ( !this.hasClass(el, oldClassName) ) { + this.addClass(el, newClassName); // just add it if nothing to replace + return; // note return + } + + el['className'] = el['className'].replace(re, ' ' + newClassName + ' '); + + if ( this.hasClass(el, oldClassName) ) { // in case of multiple adjacent + this.replaceClass(el, oldClassName, newClassName); + } + }; + + util.Dom.batch(el, f, util.Dom, true); + }, + + /** + * Generates a unique ID + * @param {String/HTMLElement/Array} el (optional) An optional element array of elements to add an ID to (no ID is added if one is already present) + * @param {String} prefix (optional) an optional prefix to use (defaults to "yui-gen") + * @return {String/Array} The generated ID, or array of generated IDs (or original ID if already present on an element) + */ + generateId: function(el, prefix) { + prefix = prefix || 'yui-gen'; + el = el || {}; + + var f = function(el) { + if (el) { + el = util.Dom.get(el); + } else { + el = {}; // just generating ID in this case + } + + if (!el.id) { + el.id = prefix + id_counter++; + } // dont override existing + + + return el.id; + }; + + return util.Dom.batch(el, f, util.Dom, true); + }, + + /** + * Determines whether an HTMLElement is an ancestor of another HTML element in the DOM hierarchy + * @param {String/HTMLElement} haystack The possible ancestor + * @param {String/HTMLElement} needle The possible descendent + * @return {Boolean} Whether or not the haystack is an ancestor of needle + */ + isAncestor: function(haystack, needle) { + haystack = util.Dom.get(haystack); + if (!haystack || !needle) { return false; } + + var f = function(needle) { + if (haystack.contains && !isSafari) { // safari "contains" is broken + return haystack.contains(needle); + } + else if ( haystack.compareDocumentPosition ) { + return !!(haystack.compareDocumentPosition(needle) & 16); + } + else { // loop up and test each parent + var parent = needle.parentNode; + + while (parent) { + if (parent == haystack) { + return true; + } + else if (parent.tagName.toUpperCase() == 'HTML') { + return false; + } + + parent = parent.parentNode; + } + return false; + } + }; + + return util.Dom.batch(needle, f, util.Dom, true); + }, + + /** + * Determines whether an HTMLElement is present in the current document + * @param {String/HTMLElement} el The element to search for + * @return {Boolean} Whether or not the element is present in the current document + */ + inDocument: function(el) { + var f = function(el) { + return this.isAncestor(document.documentElement, el); + }; + + return util.Dom.batch(el, f, util.Dom, true); + }, + + /** + * Returns a array of HTMLElements that pass the test applied by supplied boolean method + * For optimized performance, include a tag and/or root node if possible + * @param {Function} method A boolean method to test elements with + * @param {String} tag (optional) The tag name of the elements being collected + * @param {String/HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point + */ + getElementsBy: function(method, tag, root) { + tag = tag || '*'; + root = util.Dom.get(root) || document; + + var nodes = []; + var elements = root.getElementsByTagName(tag); + + if ( !elements.length && (tag == '*' && root.all) ) { + elements = root.all; // IE < 6 + } + + for (var i = 0, len = elements.length; i < len; ++i) + { + if ( method(elements[i]) ) { nodes[nodes.length] = elements[i]; } + } + + + return nodes; + }, + + /** + * Returns an array of elements that have had the supplied method applied. + * The method is called with the element(s) as the first arg, and the optional param as the second ( method(el, o) ) + * @param {String/HTMLElement/Array} el (optional) An element or array of elements to apply the method to + * @param {Function} method The method to apply to the element(s) + * @param {Generic} (optional) o An optional arg that is passed to the supplied method + * @param {Boolean} (optional) override Whether or not to override the scope of "method" with "o" + * @return {HTMLElement/Array} The element(s) with the method applied + */ + batch: function(el, method, o, override) { + var id = el; + el = util.Dom.get(el); + + var scope = (override) ? o : window; + + if (!el || el.tagName || !el.length) { // is null or not a collection (tagName for SELECT and others that can be both an element and a collection) + if (!el) { + return false; + } + return method.call(scope, el, o); + } + + var collection = []; + + for (var i = 0, len = el.length; i < len; ++i) { + if (!el[i]) { + id = id[i]; + } + collection[collection.length] = method.call(scope, el[i], o); + } + + return collection; + }, + + /** + * Returns the height of the document. + * @return {Int} The height of the actual document (which includes the body and its margin). + */ + getDocumentHeight: function() { + var scrollHeight=-1,windowHeight=-1,bodyHeight=-1; + var marginTop = parseInt(util.Dom.getStyle(document.body, 'marginTop'), 10); + var marginBottom = parseInt(util.Dom.getStyle(document.body, 'marginBottom'), 10); + + var mode = document.compatMode; + + if ( (mode || isIE) && !isOpera ) { // (IE, Gecko) + switch (mode) { + case 'CSS1Compat': // Standards mode + scrollHeight = ((window.innerHeight && window.scrollMaxY) ? window.innerHeight+window.scrollMaxY : -1); + windowHeight = [document.documentElement.clientHeight,self.innerHeight||-1].sort(function(a, b){return(a-b);})[1]; + bodyHeight = document.body.offsetHeight + marginTop + marginBottom; + break; + + default: // Quirks + scrollHeight = document.body.scrollHeight; + bodyHeight = document.body.clientHeight; + } + } else { // Safari & Opera + scrollHeight = document.documentElement.scrollHeight; + windowHeight = self.innerHeight; + bodyHeight = document.documentElement.clientHeight; + } + + var h = [scrollHeight,windowHeight,bodyHeight].sort(function(a, b){return(a-b);}); + return h[2]; + }, + + /** + * Returns the width of the document. + * @return {Int} The width of the actual document (which includes the body and its margin). + */ + getDocumentWidth: function() { + var docWidth=-1,bodyWidth=-1,winWidth=-1; + var marginRight = parseInt(util.Dom.getStyle(document.body, 'marginRight'), 10); + var marginLeft = parseInt(util.Dom.getStyle(document.body, 'marginLeft'), 10); + + var mode = document.compatMode; + + if (mode || isIE) { // (IE, Gecko, Opera) + switch (mode) { + case 'CSS1Compat': // Standards mode + docWidth = document.documentElement.clientWidth; + bodyWidth = document.body.offsetWidth + marginLeft + marginRight; + winWidth = self.innerWidth || -1; + break; + + default: // Quirks + bodyWidth = document.body.clientWidth; + winWidth = document.body.scrollWidth; + break; + } + } else { // Safari + docWidth = document.documentElement.clientWidth; + bodyWidth = document.body.offsetWidth + marginLeft + marginRight; + winWidth = self.innerWidth; + } + + var w = [docWidth,bodyWidth,winWidth].sort(function(a, b){return(a-b);}); + return w[2]; + }, + + /** + * Returns the current height of the viewport. + * @return {Int} The height of the viewable area of the page (excludes scrollbars). + */ + getViewportHeight: function() { + var height = -1; + var mode = document.compatMode; + + if ( (mode || isIE) && !isOpera ) { + switch (mode) { // (IE, Gecko) + case 'CSS1Compat': // Standards mode + height = document.documentElement.clientHeight; + break; + + default: // Quirks + height = document.body.clientHeight; + } + } else { // Safari, Opera + height = self.innerHeight; + } + + return height; + }, + + /** + * Returns the current width of the viewport. + * @return {Int} The width of the viewable area of the page (excludes scrollbars). + */ + + getViewportWidth: function() { + var width = -1; + var mode = document.compatMode; + + if (mode || isIE) { // (IE, Gecko, Opera) + switch (mode) { + case 'CSS1Compat': // Standards mode + width = document.documentElement.clientWidth; + break; + + default: // Quirks + width = document.body.clientWidth; + } + } else { // Safari + width = self.innerWidth; + } + return width; + } + }; +}(); + +/** + * @class A region is a representation of an object on a grid. It is defined + * by the top, right, bottom, left extents, so is rectangular by default. If + * other shapes are required, this class could be extended to support it. + * + * @param {int} t the top extent + * @param {int} r the right extent + * @param {int} b the bottom extent + * @param {int} l the left extent + * @constructor + */ +YAHOO.util.Region = function(t, r, b, l) { + + /** + * The region's top extent + * @type int + */ + this.top = t; + + /** + * The region's top extent as index, for symmetry with set/getXY + * @type int + */ + this[1] = t; + + /** + * The region's right extent + * @type int + */ + this.right = r; + + /** + * The region's bottom extent + * @type int + */ + this.bottom = b; + + /** + * The region's left extent + * @type int + */ + this.left = l; + + /** + * The region's left extent as index, for symmetry with set/getXY + * @type int + */ + this[0] = l; +}; + +/** + * Returns true if this region contains the region passed in + * + * @param {Region} region The region to evaluate + * @return {boolean} True if the region is contained with this region, + * else false + */ +YAHOO.util.Region.prototype.contains = function(region) { + return ( region.left >= this.left && + region.right <= this.right && + region.top >= this.top && + region.bottom <= this.bottom ); + +}; + +/** + * Returns the area of the region + * + * @return {int} the region's area + */ +YAHOO.util.Region.prototype.getArea = function() { + return ( (this.bottom - this.top) * (this.right - this.left) ); +}; + +/** + * Returns the region where the passed in region overlaps with this one + * + * @param {Region} region The region that intersects + * @return {Region} The overlap region, or null if there is no overlap + */ +YAHOO.util.Region.prototype.intersect = function(region) { + var t = Math.max( this.top, region.top ); + var r = Math.min( this.right, region.right ); + var b = Math.min( this.bottom, region.bottom ); + var l = Math.max( this.left, region.left ); + + if (b >= t && r >= l) { + return new YAHOO.util.Region(t, r, b, l); + } else { + return null; + } +}; + +/** + * Returns the region representing the smallest region that can contain both + * the passed in region and this region. + * + * @param {Region} region The region that to create the union with + * @return {Region} The union region + */ +YAHOO.util.Region.prototype.union = function(region) { + var t = Math.min( this.top, region.top ); + var r = Math.max( this.right, region.right ); + var b = Math.max( this.bottom, region.bottom ); + var l = Math.min( this.left, region.left ); + + return new YAHOO.util.Region(t, r, b, l); +}; + +/** + * toString + * @return string the region properties + */ +YAHOO.util.Region.prototype.toString = function() { + return ( "Region {" + + "top: " + this.top + + ", right: " + this.right + + ", bottom: " + this.bottom + + ", left: " + this.left + + "}" ); +}; + +/** + * Returns a region that is occupied by the DOM element + * + * @param {HTMLElement} el The element + * @return {Region} The region that the element occupies + * @static + */ +YAHOO.util.Region.getRegion = function(el) { + var p = YAHOO.util.Dom.getXY(el); + + var t = p[1]; + var r = p[0] + el.offsetWidth; + var b = p[1] + el.offsetHeight; + var l = p[0]; + + return new YAHOO.util.Region(t, r, b, l); +}; + +///////////////////////////////////////////////////////////////////////////// + +/** + * @class + * + * A point is a region that is special in that it represents a single point on + * the grid. + * + * @param {int} x The X position of the point + * @param {int} y The Y position of the point + * @constructor + * @extends Region + */ +YAHOO.util.Point = function(x, y) { + if (x instanceof Array) { // accept output from Dom.getXY + y = x[1]; + x = x[0]; + } + + /** + * The X position of the point, which is also the right, left and index zero (for Dom.getXY symmetry) + * @type int + */ + + this.x = this.right = this.left = this[0] = x; + + /** + * The Y position of the point, which is also the top, bottom and index one (for Dom.getXY symmetry) + * @type int + */ + this.y = this.top = this.bottom = this[1] = y; +}; + +YAHOO.util.Point.prototype = new YAHOO.util.Region(); + diff --git a/webapp/xqts/scripts/event.js b/webapp/xqts/scripts/event.js index 80487bc61f0..78ddd0800a9 100644 --- a/webapp/xqts/scripts/event.js +++ b/webapp/xqts/scripts/event.js @@ -1,1200 +1,1200 @@ -/* -Copyright (c) 2006, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -version: 0.11.0 -*/ - -/** - * The CustomEvent class lets you define events for your application - * that can be subscribed to by one or more independent component. - * - * @param {String} type The type of event, which is passed to the callback - * when the event fires - * @param {Object} oScope The context the event will fire from. "this" will - * refer to this object in the callback. Default value: - * the window object. The listener can override this. - * @constructor - */ -YAHOO.util.CustomEvent = function(type, oScope, silent) { - - /** - * The type of event, returned to subscribers when the event fires - * @type string - */ - this.type = type; - - /** - * The scope the the event will fire from by default. Defaults to the window - * obj - * @type object - */ - this.scope = oScope || window; - - /** - * By default all custom events are logged in the debug build, set silent - * to true to disable logging for this event. - * @type boolean - */ - this.silent = silent; - - /** - * The subscribers to this event - * @type Subscriber[] - */ - this.subscribers = []; - - // Register with the event utility for automatic cleanup. Made optional - // so that CustomEvent can be used independently of pe.event - if (YAHOO.util.Event) { - YAHOO.util.Event.regCE(this); - } - - if (!this.silent) { - } -}; - -YAHOO.util.CustomEvent.prototype = { - /** - * Subscribes the caller to this event - * @param {Function} fn The function to execute - * @param {Object} obj An object to be passed along when the event fires - * @param {boolean} bOverride If true, the obj passed in becomes the execution - * scope of the listener - */ - subscribe: function(fn, obj, bOverride) { - this.subscribers.push( new YAHOO.util.Subscriber(fn, obj, bOverride) ); - }, - - /** - * Unsubscribes the caller from this event - * @param {Function} fn The function to execute - * @param {Object} obj An object to be passed along when the event fires - * @return {boolean} True if the subscriber was found and detached. - */ - unsubscribe: function(fn, obj) { - var found = false; - for (var i=0, len=this.subscribers.length; i - * - The type of event - * - All of the arguments fire() was executed with as an array - * - The custom object (if any) that was passed into the subscribe() method - * - * - * @param {Array} an arbitrary set of parameters to pass to the handler - */ - fire: function() { - var len=this.subscribers.length; - - var args = []; - - for (var i=0; i= 0) { - cacheItem = listeners[index]; - } - - if (!el || !cacheItem) { - return false; - } - - if (el.removeEventListener) { - el.removeEventListener(sType, cacheItem[this.WFN], false); - } else if (el.detachEvent) { - el.detachEvent("on" + sType, cacheItem[this.WFN]); - } - - // removed the wrapped handler - delete listeners[index][this.WFN]; - delete listeners[index][this.FN]; - delete listeners[index]; - - return true; - - }, - - /** - * Returns the event's target element - * @param {Event} ev the event - * @param {boolean} resolveTextNode when set to true the target's - * parent will be returned if the target is a - * text node. @deprecated, the text node is - * now resolved automatically - * @return {HTMLElement} the event's target - */ - getTarget: function(ev, resolveTextNode) { - var t = ev.target || ev.srcElement; - return this.resolveTextNode(t); - }, - - /** - * In some cases, some browsers will return a text node inside - * the actual element that was targeted. This normalizes the - * return value for getTarget and getRelatedTarget. - * @param {HTMLElement} node to resolve - * @return the normized node - */ - resolveTextNode: function(node) { - if (node && node.nodeName && - "#TEXT" == node.nodeName.toUpperCase()) { - return node.parentNode; - } else { - return node; - } - }, - - /** - * Returns the event's pageX - * @param {Event} ev the event - * @return {int} the event's pageX - */ - getPageX: function(ev) { - var x = ev.pageX; - if (!x && 0 !== x) { - x = ev.clientX || 0; - - if ( this.isIE ) { - x += this._getScrollLeft(); - } - } - - return x; - }, - - /** - * Returns the event's pageY - * @param {Event} ev the event - * @return {int} the event's pageY - */ - getPageY: function(ev) { - var y = ev.pageY; - if (!y && 0 !== y) { - y = ev.clientY || 0; - - if ( this.isIE ) { - y += this._getScrollTop(); - } - } - - return y; - }, - - /** - * Returns the pageX and pageY properties as an indexed array. - * @type int[] - */ - getXY: function(ev) { - return [this.getPageX(ev), this.getPageY(ev)]; - }, - - /** - * Returns the event's related target - * @param {Event} ev the event - * @return {HTMLElement} the event's relatedTarget - */ - getRelatedTarget: function(ev) { - var t = ev.relatedTarget; - if (!t) { - if (ev.type == "mouseout") { - t = ev.toElement; - } else if (ev.type == "mouseover") { - t = ev.fromElement; - } - } - - return this.resolveTextNode(t); - }, - - /** - * Returns the time of the event. If the time is not included, the - * event is modified using the current time. - * @param {Event} ev the event - * @return {Date} the time of the event - */ - getTime: function(ev) { - if (!ev.time) { - var t = new Date().getTime(); - try { - ev.time = t; - } catch(e) { - // can't set the time property - return t; - } - } - - return ev.time; - }, - - /** - * Convenience method for stopPropagation + preventDefault - * @param {Event} ev the event - */ - stopEvent: function(ev) { - this.stopPropagation(ev); - this.preventDefault(ev); - }, - - /** - * Stops event propagation - * @param {Event} ev the event - */ - stopPropagation: function(ev) { - if (ev.stopPropagation) { - ev.stopPropagation(); - } else { - ev.cancelBubble = true; - } - }, - - /** - * Prevents the default behavior of the event - * @param {Event} ev the event - */ - preventDefault: function(ev) { - if (ev.preventDefault) { - ev.preventDefault(); - } else { - ev.returnValue = false; - } - }, - - /** - * Finds the event in the window object, the caller's arguments, or - * in the arguments of another method in the callstack. This is - * executed automatically for events registered through the event - * manager, so the implementer should not normally need to execute - * this function at all. - * @param {Event} the event parameter from the handler - * @return {Event} the event - */ - getEvent: function(e) { - var ev = e || window.event; - - if (!ev) { - var c = this.getEvent.caller; - while (c) { - ev = c.arguments[0]; - if (ev && Event == ev.constructor) { - break; - } - c = c.caller; - } - } - - return ev; - }, - - /** - * Returns the charcode for an event - * @param {Event} ev the event - * @return {int} the event's charCode - */ - getCharCode: function(ev) { - return ev.charCode || ((ev.type == "keypress") ? ev.keyCode : 0); - }, - - /** - * @private - * Locating the saved event handler data by function ref - */ - _getCacheIndex: function(el, sType, fn) { - for (var i=0,len=listeners.length; i 0); - } - - // Delayed listeners - var stillDelayed = []; - - for (var i=0,len=delayedListeners.length; i 0) { - for (var i=0,len=listeners.length; i 0) { - for (i=0,len=listeners.length; i + * - The type of event + * - All of the arguments fire() was executed with as an array + * - The custom object (if any) that was passed into the subscribe() method + * + * + * @param {Array} an arbitrary set of parameters to pass to the handler + */ + fire: function() { + var len=this.subscribers.length; + + var args = []; + + for (var i=0; i= 0) { + cacheItem = listeners[index]; + } + + if (!el || !cacheItem) { + return false; + } + + if (el.removeEventListener) { + el.removeEventListener(sType, cacheItem[this.WFN], false); + } else if (el.detachEvent) { + el.detachEvent("on" + sType, cacheItem[this.WFN]); + } + + // removed the wrapped handler + delete listeners[index][this.WFN]; + delete listeners[index][this.FN]; + delete listeners[index]; + + return true; + + }, + + /** + * Returns the event's target element + * @param {Event} ev the event + * @param {boolean} resolveTextNode when set to true the target's + * parent will be returned if the target is a + * text node. @deprecated, the text node is + * now resolved automatically + * @return {HTMLElement} the event's target + */ + getTarget: function(ev, resolveTextNode) { + var t = ev.target || ev.srcElement; + return this.resolveTextNode(t); + }, + + /** + * In some cases, some browsers will return a text node inside + * the actual element that was targeted. This normalizes the + * return value for getTarget and getRelatedTarget. + * @param {HTMLElement} node to resolve + * @return the normized node + */ + resolveTextNode: function(node) { + if (node && node.nodeName && + "#TEXT" == node.nodeName.toUpperCase()) { + return node.parentNode; + } else { + return node; + } + }, + + /** + * Returns the event's pageX + * @param {Event} ev the event + * @return {int} the event's pageX + */ + getPageX: function(ev) { + var x = ev.pageX; + if (!x && 0 !== x) { + x = ev.clientX || 0; + + if ( this.isIE ) { + x += this._getScrollLeft(); + } + } + + return x; + }, + + /** + * Returns the event's pageY + * @param {Event} ev the event + * @return {int} the event's pageY + */ + getPageY: function(ev) { + var y = ev.pageY; + if (!y && 0 !== y) { + y = ev.clientY || 0; + + if ( this.isIE ) { + y += this._getScrollTop(); + } + } + + return y; + }, + + /** + * Returns the pageX and pageY properties as an indexed array. + * @type int[] + */ + getXY: function(ev) { + return [this.getPageX(ev), this.getPageY(ev)]; + }, + + /** + * Returns the event's related target + * @param {Event} ev the event + * @return {HTMLElement} the event's relatedTarget + */ + getRelatedTarget: function(ev) { + var t = ev.relatedTarget; + if (!t) { + if (ev.type == "mouseout") { + t = ev.toElement; + } else if (ev.type == "mouseover") { + t = ev.fromElement; + } + } + + return this.resolveTextNode(t); + }, + + /** + * Returns the time of the event. If the time is not included, the + * event is modified using the current time. + * @param {Event} ev the event + * @return {Date} the time of the event + */ + getTime: function(ev) { + if (!ev.time) { + var t = new Date().getTime(); + try { + ev.time = t; + } catch(e) { + // can't set the time property + return t; + } + } + + return ev.time; + }, + + /** + * Convenience method for stopPropagation + preventDefault + * @param {Event} ev the event + */ + stopEvent: function(ev) { + this.stopPropagation(ev); + this.preventDefault(ev); + }, + + /** + * Stops event propagation + * @param {Event} ev the event + */ + stopPropagation: function(ev) { + if (ev.stopPropagation) { + ev.stopPropagation(); + } else { + ev.cancelBubble = true; + } + }, + + /** + * Prevents the default behavior of the event + * @param {Event} ev the event + */ + preventDefault: function(ev) { + if (ev.preventDefault) { + ev.preventDefault(); + } else { + ev.returnValue = false; + } + }, + + /** + * Finds the event in the window object, the caller's arguments, or + * in the arguments of another method in the callstack. This is + * executed automatically for events registered through the event + * manager, so the implementer should not normally need to execute + * this function at all. + * @param {Event} the event parameter from the handler + * @return {Event} the event + */ + getEvent: function(e) { + var ev = e || window.event; + + if (!ev) { + var c = this.getEvent.caller; + while (c) { + ev = c.arguments[0]; + if (ev && Event == ev.constructor) { + break; + } + c = c.caller; + } + } + + return ev; + }, + + /** + * Returns the charcode for an event + * @param {Event} ev the event + * @return {int} the event's charCode + */ + getCharCode: function(ev) { + return ev.charCode || ((ev.type == "keypress") ? ev.keyCode : 0); + }, + + /** + * @private + * Locating the saved event handler data by function ref + */ + _getCacheIndex: function(el, sType, fn) { + for (var i=0,len=listeners.length; i 0); + } + + // Delayed listeners + var stillDelayed = []; + + for (var i=0,len=delayedListeners.length; i 0) { + for (var i=0,len=listeners.length; i 0) { + for (i=0,len=listeners.length; i) - | () - | (<)*(\w+)*\s*(\w+)\s*=\s*(".*?"|'.*?'|\w+)(/*>)* - | () - */ - var index = 0; - var match = null; - var regex = null; - - this.GetMatches(new RegExp(this.GetKeywords(keywords), 'gm'), 'keyword'); - - this.GetMatches(dp.sh.RegexLib.DoubleQuotedString, 'string'); - this.GetMatches(dp.sh.RegexLib.SingleQuotedString, 'string'); - - this.GetMatches(new RegExp('\\$[\\w-_.]+', 'g'), 'variable'); - - // Match CDATA in the following format - // <\!\[[\w\s]*?\[(.|\s)*?\]\]> - this.GetMatches(new RegExp('<\\!\\[[\\w\\s]*?\\[(.|\\s)*?\\]\\]>', 'gm'), 'cdata'); - - // Match comments - // - this.GetMatches(new RegExp('', 'gm'), 'comments'); - - // Match comments - // (:\s*.*\s*:) - this.GetMatches(new RegExp('\\(:\\s*.*\\s*?:\\)', 'gm'), 'comments'); - - // Match attributes and their values - // (\w+)\s*=\s*(".*?"|\'.*?\'|\w+)* - regex = new RegExp('([\\w-\.]+)\\s*=\\s*(".*?"|\'.*?\'|\\w+)*', 'gm'); - while((match = regex.exec(this.code)) != null) - { - push(this.matches, new dp.sh.Match(match[1], match.index, 'attribute')); - - // if xml is invalid and attribute has no property value, ignore it - if(match[2] != undefined) - { - push(this.matches, new dp.sh.Match(match[2], match.index + match[0].indexOf(match[2]), 'attribute-value')); - } - } - - // Match opening and closing tag brackets - // - this.GetMatches(new RegExp('', 'gm'), 'tag'); - - // Match tag names - // ) + | () + | (<)*(\w+)*\s*(\w+)\s*=\s*(".*?"|'.*?'|\w+)(/*>)* + | () + */ + var index = 0; + var match = null; + var regex = null; + + this.GetMatches(new RegExp(this.GetKeywords(keywords), 'gm'), 'keyword'); + + this.GetMatches(dp.sh.RegexLib.DoubleQuotedString, 'string'); + this.GetMatches(dp.sh.RegexLib.SingleQuotedString, 'string'); + + this.GetMatches(new RegExp('\\$[\\w-_.]+', 'g'), 'variable'); + + // Match CDATA in the following format + // <\!\[[\w\s]*?\[(.|\s)*?\]\]> + this.GetMatches(new RegExp('<\\!\\[[\\w\\s]*?\\[(.|\\s)*?\\]\\]>', 'gm'), 'cdata'); + + // Match comments + // + this.GetMatches(new RegExp('', 'gm'), 'comments'); + + // Match comments + // (:\s*.*\s*:) + this.GetMatches(new RegExp('\\(:\\s*.*\\s*?:\\)', 'gm'), 'comments'); + + // Match attributes and their values + // (\w+)\s*=\s*(".*?"|\'.*?\'|\w+)* + regex = new RegExp('([\\w-\.]+)\\s*=\\s*(".*?"|\'.*?\'|\\w+)*', 'gm'); + while((match = regex.exec(this.code)) != null) + { + push(this.matches, new dp.sh.Match(match[1], match.index, 'attribute')); + + // if xml is invalid and attribute has no property value, ignore it + if(match[2] != undefined) + { + push(this.matches, new dp.sh.Match(match[2], match.index + match[0].indexOf(match[2]), 'attribute-value')); + } + } + + // Match opening and closing tag brackets + // + this.GetMatches(new RegExp('', 'gm'), 'tag'); + + // Match tag names + // ) - | () - | (<)*(\w+)*\s*(\w+)\s*=\s*(".*?"|'.*?'|\w+)(/*>)* - | () - */ - var index = 0; - var match = null; - var regex = null; - - // Match CDATA in the following format - // <\!\[[\w\s]*?\[(.|\s)*?\]\]> - this.GetMatches(new RegExp('<\\!\\[[\\w\\s]*?\\[(.|\\s)*?\\]\\]>', 'gm'), 'cdata'); - - // Match comments - // - this.GetMatches(new RegExp('', 'gm'), 'comments'); - - // Match attributes and their values - // (\w+)\s*=\s*(".*?"|\'.*?\'|\w+)* - regex = new RegExp('([\\w-\.]+)\\s*=\\s*(".*?"|\'.*?\'|\\w+)*', 'gm'); - while((match = regex.exec(this.code)) != null) - { - push(this.matches, new dp.sh.Match(match[1], match.index, 'attribute')); - - // if xml is invalid and attribute has no property value, ignore it - if(match[2] != undefined) - { - push(this.matches, new dp.sh.Match(match[2], match.index + match[0].indexOf(match[2]), 'attribute-value')); - } - } - - // Match opening and closing tag brackets - // - this.GetMatches(new RegExp('', 'gm'), 'tag'); - - // Match tag names - // ) + | () + | (<)*(\w+)*\s*(\w+)\s*=\s*(".*?"|'.*?'|\w+)(/*>)* + | () + */ + var index = 0; + var match = null; + var regex = null; + + // Match CDATA in the following format + // <\!\[[\w\s]*?\[(.|\s)*?\]\]> + this.GetMatches(new RegExp('<\\!\\[[\\w\\s]*?\\[(.|\\s)*?\\]\\]>', 'gm'), 'cdata'); + + // Match comments + // + this.GetMatches(new RegExp('', 'gm'), 'comments'); + + // Match attributes and their values + // (\w+)\s*=\s*(".*?"|\'.*?\'|\w+)* + regex = new RegExp('([\\w-\.]+)\\s*=\\s*(".*?"|\'.*?\'|\\w+)*', 'gm'); + while((match = regex.exec(this.code)) != null) + { + push(this.matches, new dp.sh.Match(match[1], match.index, 'attribute')); + + // if xml is invalid and attribute has no property value, ignore it + if(match[2] != undefined) + { + push(this.matches, new dp.sh.Match(match[2], match.index + match[0].indexOf(match[2]), 'attribute-value')); + } + } + + // Match opening and closing tag brackets + // + this.GetMatches(new RegExp('', 'gm'), 'tag'); + + // Match tag names + // - - + + + diff --git a/webapp/xqts/styles/SyntaxHighlighter.css b/webapp/xqts/styles/SyntaxHighlighter.css index 8237a9ce9c7..15d2fec304b 100644 --- a/webapp/xqts/styles/SyntaxHighlighter.css +++ b/webapp/xqts/styles/SyntaxHighlighter.css @@ -1,251 +1,251 @@ -/* Main style for the table */ - -.dp-highlighter -{ - font-family: "Courier New" , Courier, mono; - font-size: 12px; - background-color: #fff; - width: 99%; - overflow-x: auto; - overflow-y: hidden; - padding-bottom: 10px; - line-height: 100% !important; - clear: left; -} - -.dp-highlighter .bar -{ - padding-left: 45px; -} - -.dp-highlighter ol -{ - margin: 0px 0px 0px 45px; - padding: 0px; - color: #2B91AF; -} - -.dp-highlighter ol li, .dp-highlighter .columns div -{ - border-left: 3px solid #6CE26C; - background-color: #fff; - padding-left: 10px; - line-height: 14px; -} - -.dp-highlighter .columns -{ - color: gray; - overflow: hidden; - width: 100%; -} - -.dp-highlighter .columns div -{ - padding-bottom: 5px; -} - -.dp-highlighter ol li.alt -{ - background-color: #f8f8f8; -} - -.dp-highlighter ol li span -{ - color: Black; -} - -/* Adjust some properties when wollapsed */ - -.dp-highlighter.collapsed ol -{ - margin: 0px; -} - -.dp-highlighter.collapsed ol li -{ - display: none; -} - -.dp-highlighter.collapsed .tools -{ - border-bottom: none; -} - -/* Additional modifications when in print-view */ - -.dp-highlighter.printing -{ - border: none; -} - -.dp-highlighter.printing .tools -{ - display: none !important; - border: 5px solid black; -} - -.dp-highlighter.printing li -{ - display: list-item !important; -} - -/* Styles for the tools */ - -.dp-highlighter .tools -{ - padding: 3px 8px 3px 10px; - border-bottom: 1px solid #2B91AF; - font: 9px Verdana, Geneva, Arial, Helvetica, sans-serif; - color: silver; -} - -.dp-highlighter .tools a -{ - font-size: 9px; - color: gray; - text-decoration: none; - margin-right: 10px; -} - -.dp-highlighter .tools a:hover -{ - color: red; - text-decoration: underline; -} - -/* About dialog styles */ - -.dp-about -{ - background-color: #fff; - margin: 0px; -} - -.dp-about table -{ - width: 100%; - height: 100%; - font-size: 11px; - font-family: Tahoma, Verdana, Arial, sans-serif !important; -} - -.dp-about td -{ - padding: 10px; - vertical-align: top; -} - -.dp-about .copy -{ - border-bottom: 1px solid #ACA899; - height: 95%; -} - -.dp-about .title -{ - color: red; - font-weight: bold; -} - -.dp-about .para -{ - margin-bottom: 4px; -} - -.dp-about .footer -{ - background-color: #ECEADB; - border-top: 1px solid #fff; - text-align: right; -} - -.dp-about .close -{ - font-size: 11px; - font-family: Tahoma, Verdana, Arial, sans-serif !important; - background-color: #ECEADB; - width: 60px; - height: 22px; -} - -/* Language specific styles */ - -.dp-c {} -.dp-c .comment { color: green; } -.dp-c .string { color: blue; } -.dp-c .preprocessor { color: gray; } -.dp-c .keyword { color: blue; } -.dp-c .vars { color: #d00; } - -.dp-vb {} -.dp-vb .comment { color: green; } -.dp-vb .string { color: blue; } -.dp-vb .preprocessor { color: gray; } -.dp-vb .keyword { color: blue; } - -.dp-sql {} -.dp-sql .comment { color: green; } -.dp-sql .string { color: red; } -.dp-sql .keyword { color: blue; } -.dp-sql .func { color: #ff1493; } -.dp-sql .op { color: #808080; } - -.dp-xml {} -.dp-xml .cdata { color: #ff1493; } -.dp-xml .comments { color: green; } -.dp-xml .tag { font-weight: bold; color: blue; } -.dp-xml .tag-name { color: black; font-weight: bold; } -.dp-xml .attribute { color: red; } -.dp-xml .attribute-value { color: blue; } - -.dp-xquery {} -.dp-xquery .cdata { color: #ff1493; } -.dp-xquery .comments { color: #cccccc; } -.dp-xquery .tag { font-weight: bold; color: black; } -.dp-xquery .tag-name { color: black; font-weight: bold; } -.dp-xquery .attribute { color: red; } -.dp-xquery .attribute-value { color: blue; } -.dp-xquery .keyword { color: #8014FD; } -.dp-xquery .string { color: #141DFE; } -.dp-xquery .variable { color: #ff8a00; } - -.dp-delphi {} -.dp-delphi .comment { color: #008200; font-style: italic; } -.dp-delphi .string { color: blue; } -.dp-delphi .number { color: blue; } -.dp-delphi .directive { color: #008284; } -.dp-delphi .keyword { font-weight: bold; color: navy; } -.dp-delphi .vars { color: #000; } - -.dp-py {} -.dp-py .comment { color: green; } -.dp-py .string { color: red; } -.dp-py .docstring { color: green; } -.dp-py .keyword { color: blue; font-weight: bold;} -.dp-py .builtins { color: #ff1493; } -.dp-py .magicmethods { color: #808080; } -.dp-py .exceptions { color: brown; } -.dp-py .types { color: brown; font-style: italic; } -.dp-py .commonlibs { color: #8A2BE2; font-style: italic; } - -.dp-rb {} -.dp-rb .comment { color: #c00; } -.dp-rb .string { color: #f0c; } -.dp-rb .symbol { color: #02b902; } -.dp-rb .keyword { color: #069; } -.dp-rb .variable { color: #6cf; } - -.dp-css {} -.dp-css .comment { color: green; } -.dp-css .string { color: red; } -.dp-css .keyword { color: blue; } -.dp-css .colors { color: darkred; } -.dp-css .vars { color: #d00; } - -.dp-j {} -.dp-j .comment { color: rgb(63,127,95); } -.dp-j .string { color: rgb(42,0,255); } -.dp-j .keyword { color: rgb(127,0,85); font-weight: bold } -.dp-j .annotation { color: #646464; } -.dp-j .number { color: #C00000; } +/* Main style for the table */ + +.dp-highlighter +{ + font-family: "Courier New" , Courier, mono; + font-size: 12px; + background-color: #fff; + width: 99%; + overflow-x: auto; + overflow-y: hidden; + padding-bottom: 10px; + line-height: 100% !important; + clear: left; +} + +.dp-highlighter .bar +{ + padding-left: 45px; +} + +.dp-highlighter ol +{ + margin: 0px 0px 0px 45px; + padding: 0px; + color: #2B91AF; +} + +.dp-highlighter ol li, .dp-highlighter .columns div +{ + border-left: 3px solid #6CE26C; + background-color: #fff; + padding-left: 10px; + line-height: 14px; +} + +.dp-highlighter .columns +{ + color: gray; + overflow: hidden; + width: 100%; +} + +.dp-highlighter .columns div +{ + padding-bottom: 5px; +} + +.dp-highlighter ol li.alt +{ + background-color: #f8f8f8; +} + +.dp-highlighter ol li span +{ + color: Black; +} + +/* Adjust some properties when wollapsed */ + +.dp-highlighter.collapsed ol +{ + margin: 0px; +} + +.dp-highlighter.collapsed ol li +{ + display: none; +} + +.dp-highlighter.collapsed .tools +{ + border-bottom: none; +} + +/* Additional modifications when in print-view */ + +.dp-highlighter.printing +{ + border: none; +} + +.dp-highlighter.printing .tools +{ + display: none !important; + border: 5px solid black; +} + +.dp-highlighter.printing li +{ + display: list-item !important; +} + +/* Styles for the tools */ + +.dp-highlighter .tools +{ + padding: 3px 8px 3px 10px; + border-bottom: 1px solid #2B91AF; + font: 9px Verdana, Geneva, Arial, Helvetica, sans-serif; + color: silver; +} + +.dp-highlighter .tools a +{ + font-size: 9px; + color: gray; + text-decoration: none; + margin-right: 10px; +} + +.dp-highlighter .tools a:hover +{ + color: red; + text-decoration: underline; +} + +/* About dialog styles */ + +.dp-about +{ + background-color: #fff; + margin: 0px; +} + +.dp-about table +{ + width: 100%; + height: 100%; + font-size: 11px; + font-family: Tahoma, Verdana, Arial, sans-serif !important; +} + +.dp-about td +{ + padding: 10px; + vertical-align: top; +} + +.dp-about .copy +{ + border-bottom: 1px solid #ACA899; + height: 95%; +} + +.dp-about .title +{ + color: red; + font-weight: bold; +} + +.dp-about .para +{ + margin-bottom: 4px; +} + +.dp-about .footer +{ + background-color: #ECEADB; + border-top: 1px solid #fff; + text-align: right; +} + +.dp-about .close +{ + font-size: 11px; + font-family: Tahoma, Verdana, Arial, sans-serif !important; + background-color: #ECEADB; + width: 60px; + height: 22px; +} + +/* Language specific styles */ + +.dp-c {} +.dp-c .comment { color: green; } +.dp-c .string { color: blue; } +.dp-c .preprocessor { color: gray; } +.dp-c .keyword { color: blue; } +.dp-c .vars { color: #d00; } + +.dp-vb {} +.dp-vb .comment { color: green; } +.dp-vb .string { color: blue; } +.dp-vb .preprocessor { color: gray; } +.dp-vb .keyword { color: blue; } + +.dp-sql {} +.dp-sql .comment { color: green; } +.dp-sql .string { color: red; } +.dp-sql .keyword { color: blue; } +.dp-sql .func { color: #ff1493; } +.dp-sql .op { color: #808080; } + +.dp-xml {} +.dp-xml .cdata { color: #ff1493; } +.dp-xml .comments { color: green; } +.dp-xml .tag { font-weight: bold; color: blue; } +.dp-xml .tag-name { color: black; font-weight: bold; } +.dp-xml .attribute { color: red; } +.dp-xml .attribute-value { color: blue; } + +.dp-xquery {} +.dp-xquery .cdata { color: #ff1493; } +.dp-xquery .comments { color: #cccccc; } +.dp-xquery .tag { font-weight: bold; color: black; } +.dp-xquery .tag-name { color: black; font-weight: bold; } +.dp-xquery .attribute { color: red; } +.dp-xquery .attribute-value { color: blue; } +.dp-xquery .keyword { color: #8014FD; } +.dp-xquery .string { color: #141DFE; } +.dp-xquery .variable { color: #ff8a00; } + +.dp-delphi {} +.dp-delphi .comment { color: #008200; font-style: italic; } +.dp-delphi .string { color: blue; } +.dp-delphi .number { color: blue; } +.dp-delphi .directive { color: #008284; } +.dp-delphi .keyword { font-weight: bold; color: navy; } +.dp-delphi .vars { color: #000; } + +.dp-py {} +.dp-py .comment { color: green; } +.dp-py .string { color: red; } +.dp-py .docstring { color: green; } +.dp-py .keyword { color: blue; font-weight: bold;} +.dp-py .builtins { color: #ff1493; } +.dp-py .magicmethods { color: #808080; } +.dp-py .exceptions { color: brown; } +.dp-py .types { color: brown; font-style: italic; } +.dp-py .commonlibs { color: #8A2BE2; font-style: italic; } + +.dp-rb {} +.dp-rb .comment { color: #c00; } +.dp-rb .string { color: #f0c; } +.dp-rb .symbol { color: #02b902; } +.dp-rb .keyword { color: #069; } +.dp-rb .variable { color: #6cf; } + +.dp-css {} +.dp-css .comment { color: green; } +.dp-css .string { color: red; } +.dp-css .keyword { color: blue; } +.dp-css .colors { color: darkred; } +.dp-css .vars { color: #d00; } + +.dp-j {} +.dp-j .comment { color: rgb(63,127,95); } +.dp-j .string { color: rgb(42,0,255); } +.dp-j .keyword { color: rgb(127,0,85); font-weight: bold } +.dp-j .annotation { color: #646464; } +.dp-j .number { color: #C00000; } diff --git a/webapp/xqts/styles/container.css b/webapp/xqts/styles/container.css index bb7e1097914..9580fc8ee6e 100644 --- a/webapp/xqts/styles/container.css +++ b/webapp/xqts/styles/container.css @@ -1,210 +1,210 @@ -/* -Copyright (c) 2006, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.net/yui/license.txt -Version 0.11.0 -*/ - -.overlay { - position:absolute; - display:block; -} - -.tt { - visibility:hidden; - position:absolute; - color:#333; - background-color:#FDFFB4; - font-family:arial,helvetica,verdana,sans-serif; - padding:2px; - border:1px solid #FCC90D; - font:100% sans-serif; - width:auto; -} - -* html body.masked select { - visibility:hidden; -} - -* html div.panel-container select { - visibility:inherit; -} - -* html div.drag select { - visibility:hidden; -} - -* html div.hide-select select { - visibility:hidden; -} - -.mask { - z-index:0; - display:none; - position:absolute; - top:0; - left:0; - -moz-opacity: 0.5; - opacity:.50; - filter: alpha(opacity=50); - background-color:#CCC; -} - -.hide-scrollbars * { - overflow:hidden; -} - -.hide-scrollbars textarea, .hide-scrollbars select { - overflow:hidden; - display:none; -} - -.show-scrollbars textarea, .show-scrollbars select { - overflow:visible; -} - -.panel-container { - position:absolute; - background-color:transparent; - z-index:6; - visibility:hidden; - overflow:visible; - width:auto; -} - -.panel-container.matte { - padding:3px; - background-color:#FFF; -} - -.panel-container.matte .underlay { - display:none; -} - -.panel-container.shadow { - padding:0px; - background-color:transparent; -} - -.panel-container.shadow .underlay { - visibility:inherit; - position:absolute; - background-color:#CCC; - top:3px;left:3px; - z-index:0; - width:100%; - height:100%; - -moz-opacity: 0.7; - opacity:.70; - filter:alpha(opacity=70); -} - -.panel { - visibility:hidden; - border-collapse:separate; - position:relative; - left:0px;top:0px; - font:1em Arial; - background-color:#FFF; - border:1px solid #000; - z-index:1; - overflow:auto; -} - -.panel .hd { - background-color:#3d77cb; - color:#FFF; - font-size:100%; - line-height:100%; - border:1px solid #FFF; - border-bottom:1px solid #000; - font-weight:bold; - overflow:hidden; - padding:4px; -} - -.panel .bd { - overflow:hidden; - padding:4px; -} - -.panel .bd p { - margin:0 0 1em; -} - -.panel .close { - position:absolute; - top:5px; - right:4px; - z-index:6; - height:12px; - width:12px; - margin:0px; - padding:0px; - background-repeat:no-repeat; - cursor:pointer; - visibility:inherit; -} - -.panel .close.nonsecure { - background-image:url(http://us.i1.yimg.com/us.yimg.com/i/nt/ic/ut/alt3/close12_1.gif); -} - -.panel .close.secure { - background-image:url(https://a248.e.akamai.net/sec.yimg.com/i/nt/ic/ut/alt3/close12_1.gif); -} - -.panel .ft { - padding:4px; - overflow:hidden; -} - -.simple-dialog .bd .icon { - background-repeat:no-repeat; - width:16px; - height:16px; - margin-right:10px; - float:left; -} - -.dialog .ft, .simple-dialog .ft { - padding-bottom:5px; - padding-right:5px; - text-align:right; -} - -.dialog form, .simple-dialog form { - margin:0; -} - -.button-group button { - font:100 76% verdana; - text-decoration:none; - background-color: #E4E4E4; - color: #333; - cursor: hand; - vertical-align: middle; - border: 2px solid #797979; - border-top-color:#FFF; - border-left-color:#FFF; - margin:2px; - padding:2px; -} - -.button-group button.default { - font-weight:bold; -} - -.button-group button:hover, .button-group button.hover { - border:2px solid #90A029; - background-color:#EBF09E; - border-top-color:#FFF; - border-left-color:#FFF; -} - -.button-group button:active { - border:2px solid #E4E4E4; - background-color:#BBB; - border-top-color:#333; - border-left-color:#333; -} +/* +Copyright (c) 2006, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.net/yui/license.txt +Version 0.11.0 +*/ + +.overlay { + position:absolute; + display:block; +} + +.tt { + visibility:hidden; + position:absolute; + color:#333; + background-color:#FDFFB4; + font-family:arial,helvetica,verdana,sans-serif; + padding:2px; + border:1px solid #FCC90D; + font:100% sans-serif; + width:auto; +} + +* html body.masked select { + visibility:hidden; +} + +* html div.panel-container select { + visibility:inherit; +} + +* html div.drag select { + visibility:hidden; +} + +* html div.hide-select select { + visibility:hidden; +} + +.mask { + z-index:0; + display:none; + position:absolute; + top:0; + left:0; + -moz-opacity: 0.5; + opacity:.50; + filter: alpha(opacity=50); + background-color:#CCC; +} + +.hide-scrollbars * { + overflow:hidden; +} + +.hide-scrollbars textarea, .hide-scrollbars select { + overflow:hidden; + display:none; +} + +.show-scrollbars textarea, .show-scrollbars select { + overflow:visible; +} + +.panel-container { + position:absolute; + background-color:transparent; + z-index:6; + visibility:hidden; + overflow:visible; + width:auto; +} + +.panel-container.matte { + padding:3px; + background-color:#FFF; +} + +.panel-container.matte .underlay { + display:none; +} + +.panel-container.shadow { + padding:0px; + background-color:transparent; +} + +.panel-container.shadow .underlay { + visibility:inherit; + position:absolute; + background-color:#CCC; + top:3px;left:3px; + z-index:0; + width:100%; + height:100%; + -moz-opacity: 0.7; + opacity:.70; + filter:alpha(opacity=70); +} + +.panel { + visibility:hidden; + border-collapse:separate; + position:relative; + left:0px;top:0px; + font:1em Arial; + background-color:#FFF; + border:1px solid #000; + z-index:1; + overflow:auto; +} + +.panel .hd { + background-color:#3d77cb; + color:#FFF; + font-size:100%; + line-height:100%; + border:1px solid #FFF; + border-bottom:1px solid #000; + font-weight:bold; + overflow:hidden; + padding:4px; +} + +.panel .bd { + overflow:hidden; + padding:4px; +} + +.panel .bd p { + margin:0 0 1em; +} + +.panel .close { + position:absolute; + top:5px; + right:4px; + z-index:6; + height:12px; + width:12px; + margin:0px; + padding:0px; + background-repeat:no-repeat; + cursor:pointer; + visibility:inherit; +} + +.panel .close.nonsecure { + background-image:url(http://us.i1.yimg.com/us.yimg.com/i/nt/ic/ut/alt3/close12_1.gif); +} + +.panel .close.secure { + background-image:url(https://a248.e.akamai.net/sec.yimg.com/i/nt/ic/ut/alt3/close12_1.gif); +} + +.panel .ft { + padding:4px; + overflow:hidden; +} + +.simple-dialog .bd .icon { + background-repeat:no-repeat; + width:16px; + height:16px; + margin-right:10px; + float:left; +} + +.dialog .ft, .simple-dialog .ft { + padding-bottom:5px; + padding-right:5px; + text-align:right; +} + +.dialog form, .simple-dialog form { + margin:0; +} + +.button-group button { + font:100 76% verdana; + text-decoration:none; + background-color: #E4E4E4; + color: #333; + cursor: hand; + vertical-align: middle; + border: 2px solid #797979; + border-top-color:#FFF; + border-left-color:#FFF; + margin:2px; + padding:2px; +} + +.button-group button.default { + font-weight:bold; +} + +.button-group button:hover, .button-group button.hover { + border:2px solid #90A029; + background-color:#EBF09E; + border-top-color:#FFF; + border-left-color:#FFF; +} + +.button-group button:active { + border:2px solid #E4E4E4; + background-color:#BBB; + border-top-color:#333; + border-left-color:#333; +} From 3f4acad17d5d738426ff61c4547be56cb0b4c647 Mon Sep 17 00:00:00 2001 From: Dmitriy Shabanov Date: Wed, 30 Apr 2014 15:58:47 +0400 Subject: [PATCH 4/5] missing @Override --- src/org/exist/storage/DBBroker.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/org/exist/storage/DBBroker.java b/src/org/exist/storage/DBBroker.java index d686b65d55d..417d723c547 100644 --- a/src/org/exist/storage/DBBroker.java +++ b/src/org/exist/storage/DBBroker.java @@ -840,6 +840,7 @@ public abstract EmbeddedXMLStreamReader newXMLStreamReader(NodeHandle node, bool public abstract void readCollectionEntry(SubCollectionEntry entry); + @Override public void close() throws Exception { pool.release(this); } From 6ef8c3ec8a87302a4250b32cd49c48b56f68715d Mon Sep 17 00:00:00 2001 From: Dmitriy Shabanov Date: Wed, 30 Apr 2014 19:58:53 +0400 Subject: [PATCH 5/5] switch to java 7 compiler --- build.properties | 158 +++++++++++++++++++++++------------------------ 1 file changed, 79 insertions(+), 79 deletions(-) diff --git a/build.properties b/build.properties index f93f3823c2b..69866ed1d3c 100644 --- a/build.properties +++ b/build.properties @@ -1,79 +1,79 @@ -# -# Don't directly modify this file. Instead, copy it to local.build.properties and -# edit that. -# -# $Id$ -project.name = eXist-db -project.version = 2.1 -project.version.numeric = 2.1 -project.codename = Ruesselsheim - -# build settings -build.debug = on -build.optimize = on -build.deprecation = off -build.encoding = UTF-8 -build.compiler.pedantic = false -build.compiler=modern -build.compiler.source=1.6 -build.compiler.target=1.6 - -autodeploy=dashboard,shared,eXide -autodeploy.repo=http://demo.exist-db.org/exist/apps/public-repo -use.autodeploy.feature=true - -# output dir for junit reports -junit.reports = test -junit.output = true -junit.forked.VM.maxmemory = 300m -# Converted junit tests from external testsuites -# reuire more memory, e g -# XSLTS requires 512m -# XQTS requires more than 400m -junit.forked.VM.maxmemory.external = 512m -proxy.nonproxyhosts = -proxy.host = -proxy.port = 0 -proxy.password = -proxy.user = -proxy.socks.host = -proxy.socks.port = 0 -#proxy.ntlm.domain = - -# Ant -tools.ant = ./tools/ant - -#aspectj -tools.aspectj = ./tools/aspectj - -# Common libs -lib.core = ./lib/core -lib.optional = ./lib/optional -lib.endorsed = ./lib/endorsed -lib.user = ./lib/user -lib.extensions = ./lib/extensions -lib.test = ./lib/test - -# antlr is only needed if you change the XPath/XQuery parser -# set these properties to true to get a lot of debugging output -antlr.traceParser = false -antlr.traceLexer = false -antlr.traceTreeWalker = false - -# IZPack is required to create the installer package. -# We currently require IzPack 4.3.5. The Izpack 5.0 beta does NOT work. -# If you change this property value for a reason, -# please use a version indicator in directory name, -# eg /izpack-dir-path/izpack-5.0-beta-11. -# You might need to change PermSpace to atleast 84 MB eg -XX:MaxPermSize=84m -# If you only want to point to your own izpack installation directory -# add this in local.build.properties instead so you don't commit it by mistake. -izpack.dir = /Applications/IzPack/ - -# Launch4J is required to create the windows installer -# If you change this property value for a reason, -# please use a version indicator in directory name, -# eg /launch4j-dir-path/launch4j-x.x.x. -# If you only want to point to your own launch4j installation directory -# add this in local.build.properties instead so you don't commit it by mistake. -launch4j.dir = /Applications/launch4j/ +# +# Don't directly modify this file. Instead, copy it to local.build.properties and +# edit that. +# +# $Id$ +project.name = eXist-db +project.version = 2.1 +project.version.numeric = 2.1 +project.codename = Ruesselsheim + +# build settings +build.debug = on +build.optimize = on +build.deprecation = off +build.encoding = UTF-8 +build.compiler.pedantic = false +build.compiler=modern +build.compiler.source=1.7 +build.compiler.target=1.7 + +autodeploy=dashboard,shared,eXide +autodeploy.repo=http://demo.exist-db.org/exist/apps/public-repo +use.autodeploy.feature=true + +# output dir for junit reports +junit.reports = test +junit.output = true +junit.forked.VM.maxmemory = 300m +# Converted junit tests from external testsuites +# reuire more memory, e g +# XSLTS requires 512m +# XQTS requires more than 400m +junit.forked.VM.maxmemory.external = 512m +proxy.nonproxyhosts = +proxy.host = +proxy.port = 0 +proxy.password = +proxy.user = +proxy.socks.host = +proxy.socks.port = 0 +#proxy.ntlm.domain = + +# Ant +tools.ant = ./tools/ant + +#aspectj +tools.aspectj = ./tools/aspectj + +# Common libs +lib.core = ./lib/core +lib.optional = ./lib/optional +lib.endorsed = ./lib/endorsed +lib.user = ./lib/user +lib.extensions = ./lib/extensions +lib.test = ./lib/test + +# antlr is only needed if you change the XPath/XQuery parser +# set these properties to true to get a lot of debugging output +antlr.traceParser = false +antlr.traceLexer = false +antlr.traceTreeWalker = false + +# IZPack is required to create the installer package. +# We currently require IzPack 4.3.5. The Izpack 5.0 beta does NOT work. +# If you change this property value for a reason, +# please use a version indicator in directory name, +# eg /izpack-dir-path/izpack-5.0-beta-11. +# You might need to change PermSpace to atleast 84 MB eg -XX:MaxPermSize=84m +# If you only want to point to your own izpack installation directory +# add this in local.build.properties instead so you don't commit it by mistake. +izpack.dir = /Applications/IzPack/ + +# Launch4J is required to create the windows installer +# If you change this property value for a reason, +# please use a version indicator in directory name, +# eg /launch4j-dir-path/launch4j-x.x.x. +# If you only want to point to your own launch4j installation directory +# add this in local.build.properties instead so you don't commit it by mistake. +launch4j.dir = /Applications/launch4j/