[Mulgara-svn] r1844 - in branches/distinct_queries: . KOWARI-MODIFICATIONS conf jxdata/iTQL jxdata/iTQL/vargraph src/jar/content-n3/java/org/mulgara/content/n3 src/jar/query/java/org/mulgara/connection src/jar/query/java/org/mulgara/query src/jar/query/java/org/mulgara/query/filter/value src/jar/query/java/org/mulgara/query/functions src/jar/query/java/org/mulgara/query/operation src/jar/query/java/org/mulgara/query/rdf src/jar/query/java/org/mulgara/query/xpath src/jar/querylang/java/org/mulgara/itql src/jar/querylang/java/org/mulgara/protocol src/jar/querylang/java/org/mulgara/protocol/http src/jar/querylang/java/org/mulgara/sparql src/jar/querylang/java/org/mulgara/sparql/parser src/jar/querylang/java/org/mulgara/sparql/parser/cst src/jar/querylang/javacc/org/mulgara/sparql/parser src/jar/resolver/java/org/mulgara/resolver src/jar/resolver-lucene/java/org/mulgara/resolver/lucene src/jar/resolver-prefix/java/org/mulgara/resolver/prefix src/jar/resolver-spi/java/org/mulgara/resolver/spi src/jar/resolver-store/java/org/mulgara/store/statement/xa src/jar/resolver-store/java/org/mulgara/store/statement/xa11 src/jar/server/java/org/mulgara/server src/jar/server-rmi/java/org/mulgara/server/rmi src/jar/store-stringpool-memory/java/org/mulgara/store/stringpool/memory src/jar/swrl/java/org/mulgara/swrl src/jar/tuples/java/org/mulgara/store/tuples src/jar/tuples-hybrid/java/org/mulgara/store/xa src/jar/util/java/org/mulgara/util src/jar/util/java/org/mulgara/util/functional src/jar/util-xa/java/org/mulgara/store/xa src/jar/web/java/org/mulgara/webquery

pag at mulgara.org pag at mulgara.org
Fri Nov 13 19:31:40 UTC 2009


Author: pag
Date: 2009-11-13 11:31:38 -0800 (Fri, 13 Nov 2009)
New Revision: 1844

Added:
   branches/distinct_queries/KOWARI-MODIFICATIONS/mods-mulgara-2.1.3.txt
   branches/distinct_queries/KOWARI-MODIFICATIONS/mods-mulgara-2.1.4.txt
   branches/distinct_queries/jxdata/iTQL/vargraph/
   branches/distinct_queries/jxdata/iTQL/vargraph/queryResult1.txt
   branches/distinct_queries/jxdata/iTQL/vargraph/queryResult2.txt
   branches/distinct_queries/jxdata/iTQL/vargraph/queryResult3.txt
   branches/distinct_queries/jxdata/iTQL/vargraph/result1.txt
   branches/distinct_queries/jxdata/iTQL/vargraph/result2.txt
   branches/distinct_queries/jxdata/iTQL/vargraph/result3.txt
   branches/distinct_queries/jxdata/iTQL/vargraph/test.jxu
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/FunctionResolverRegistry.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraFunction.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraFunctionGroup.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraFunctionResolver.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraUnsafeFunctionResolver.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraXFunctionGroup.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/ListAlias.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/FnFunctionGroup.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/MulgaraXPathFunctionResolver.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/OpFunctionGroup.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/SparqlFunctionGroup.java
Removed:
   branches/distinct_queries/jxdata/iTQL/vargraph/queryResult1.txt
   branches/distinct_queries/jxdata/iTQL/vargraph/queryResult2.txt
   branches/distinct_queries/jxdata/iTQL/vargraph/queryResult3.txt
   branches/distinct_queries/jxdata/iTQL/vargraph/result1.txt
   branches/distinct_queries/jxdata/iTQL/vargraph/result2.txt
   branches/distinct_queries/jxdata/iTQL/vargraph/result3.txt
   branches/distinct_queries/jxdata/iTQL/vargraph/test.jxu
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraFunction.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraFunctionGroup.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraFunctionResolver.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraUnsafeFunctionResolver.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraXFunctionGroup.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/FnFunctionGroup.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/MulgaraXPathFunctionResolver.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/OpFunctionGroup.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/SparqlFunctionGroup.java
Modified:
   branches/distinct_queries/build.properties
   branches/distinct_queries/build.xml
   branches/distinct_queries/common.properties
   branches/distinct_queries/conf/mulgara-config.xml
   branches/distinct_queries/conf/mulgara-embedded.xsd
   branches/distinct_queries/conf/mulgara-rmi.policy
   branches/distinct_queries/conf/mulgara-test.policy
   branches/distinct_queries/conf/mulgara.policy
   branches/distinct_queries/src/jar/content-n3/java/org/mulgara/content/n3/N3WriterUnitTest.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/connection/CommandExecutor.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/connection/Connection.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/connection/ConnectionException.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/connection/ConnectionFactory.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/connection/ConnectionFactoryUnitTest.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/connection/DummyConnection.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/connection/JenaConnection.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/connection/JenaConnectionImpl.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/connection/SessionConnection.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/AskQuery.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/ConstraintDifference.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/ConstraintIn.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/ConstraintOptionalJoin.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/ConstructQuery.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/Query.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/RdfXmlEmitter.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/filter/value/ExternalFn.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/filter/value/IRI.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/filter/value/TypedLiteral.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/AddAlias.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/ApplyRules.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Backup.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/BooleanSetCommand.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Command.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Commit.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/CreateGraph.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/DataInputTx.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/DataOutputTx.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/DataTx.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Deletion.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/DropGraph.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/ExecuteScript.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Export.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Help.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Insertion.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Load.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/LocalCommand.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Modification.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/NullOp.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Quit.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Restore.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Rollback.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/SetAutoCommit.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/SetCommand.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/SetTime.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/SetUser.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/TransactionCommand.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/TxOp.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/rdf/Mulgara.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/rdf/SWRL.java
   branches/distinct_queries/src/jar/query/java/org/mulgara/query/rdf/XSDAbbrev.java
   branches/distinct_queries/src/jar/querylang/java/org/mulgara/itql/TqlInterpreter.java
   branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/AbstractStreamedAnswer.java
   branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/AbstractStreamedXMLAnswer.java
   branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/StreamedN3Answer.java
   branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlJSONAnswer.java
   branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlJSONObject.java
   branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlXMLAnswer.java
   branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlXMLAnswerUnitTest.java
   branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlXMLObject.java
   branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/http/LocalTriple.java
   branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/http/MulgaraServlet.java
   branches/distinct_queries/src/jar/querylang/java/org/mulgara/sparql/FilterMapper.java
   branches/distinct_queries/src/jar/querylang/java/org/mulgara/sparql/parser/QueryStructureImpl.java
   branches/distinct_queries/src/jar/querylang/java/org/mulgara/sparql/parser/cst/IRIReference.java
   branches/distinct_queries/src/jar/querylang/javacc/org/mulgara/sparql/parser/SparqlParser.java
   branches/distinct_queries/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndexException.java
   branches/distinct_queries/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndexUnitTest.java
   branches/distinct_queries/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneConstraint.java
   branches/distinct_queries/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneIndexerCache.java
   branches/distinct_queries/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolver.java
   branches/distinct_queries/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolverUnitTest.java
   branches/distinct_queries/src/jar/resolver-prefix/java/org/mulgara/resolver/prefix/PrefixResolver.java
   branches/distinct_queries/src/jar/resolver-prefix/java/org/mulgara/resolver/prefix/PrefixResolverFactory.java
   branches/distinct_queries/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ResolverException.java
   branches/distinct_queries/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleAVLFile.java
   branches/distinct_queries/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleAVLFileUnitTest.java
   branches/distinct_queries/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleWriteThread.java
   branches/distinct_queries/src/jar/resolver-store/java/org/mulgara/store/statement/xa/XAStatementStoreImplUnitTest.java
   branches/distinct_queries/src/jar/resolver-store/java/org/mulgara/store/statement/xa11/XA11StatementStoreImpl.java
   branches/distinct_queries/src/jar/resolver/java/org/mulgara/resolver/ContentFactory.java
   branches/distinct_queries/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java
   branches/distinct_queries/src/jar/resolver/java/org/mulgara/resolver/ExportOperation.java
   branches/distinct_queries/src/jar/resolver/java/org/mulgara/resolver/ModifyGraphOperation.java
   branches/distinct_queries/src/jar/resolver/java/org/mulgara/resolver/OutputOperation.java
   branches/distinct_queries/src/jar/resolver/java/org/mulgara/resolver/StringPoolSession.java
   branches/distinct_queries/src/jar/server-rmi/java/org/mulgara/server/rmi/RmiServer.java
   branches/distinct_queries/src/jar/server/java/org/mulgara/server/EmbeddedMulgaraServer.java
   branches/distinct_queries/src/jar/server/java/org/mulgara/server/MulgaraUserConfig.java
   branches/distinct_queries/src/jar/store-stringpool-memory/java/org/mulgara/store/stringpool/memory/MemoryStringPoolImpl.java
   branches/distinct_queries/src/jar/swrl/java/org/mulgara/swrl/SWRLLoader.java
   branches/distinct_queries/src/jar/swrl/java/org/mulgara/swrl/SWRLStructureException.java
   branches/distinct_queries/src/jar/tuples-hybrid/java/org/mulgara/store/xa/BlockCacheLine.java
   branches/distinct_queries/src/jar/tuples/java/org/mulgara/store/tuples/TuplesOperations.java
   branches/distinct_queries/src/jar/tuples/java/org/mulgara/store/tuples/UnorderedProjection.java
   branches/distinct_queries/src/jar/util-xa/java/org/mulgara/store/xa/FreeList.java
   branches/distinct_queries/src/jar/util/java/org/mulgara/util/AbstractMulgaraResultSet.java
   branches/distinct_queries/src/jar/util/java/org/mulgara/util/Bootstrap.java
   branches/distinct_queries/src/jar/util/java/org/mulgara/util/ServerInfoRef.java
   branches/distinct_queries/src/jar/util/java/org/mulgara/util/functional/C.java
   branches/distinct_queries/src/jar/web/java/org/mulgara/webquery/QueryServlet.java
Log:
Merging from trunk 1774:1836

Copied: branches/distinct_queries/KOWARI-MODIFICATIONS/mods-mulgara-2.1.3.txt (from rev 1836, trunk/KOWARI-MODIFICATIONS/mods-mulgara-2.1.3.txt)
===================================================================
--- branches/distinct_queries/KOWARI-MODIFICATIONS/mods-mulgara-2.1.3.txt	                        (rev 0)
+++ branches/distinct_queries/KOWARI-MODIFICATIONS/mods-mulgara-2.1.3.txt	2009-11-13 19:31:38 UTC (rev 1844)
@@ -0,0 +1,157 @@
+------------------------------------------------------------------------
+r1776 | pag | 2009-08-13 18:27:31 -0500 (Thu, 13 Aug 2009) | 1 line
+
+Building the serverURI from a string as this is more forgiving for some hostnames, such as one PLoS test system that has a number for the TLD
+------------------------------------------------------------------------
+r1773 | pag | 2009-08-12 14:05:26 -0500 (Wed, 12 Aug 2009) | 1 line
+
+Added the base URI to fields in the form. This was required in a Tomcat environment
+------------------------------------------------------------------------
+r1772 | pag | 2009-08-12 14:04:17 -0500 (Wed, 12 Aug 2009) | 1 line
+
+added generics to, and a new private class to reduce the reuse of the same generics code over and over
+------------------------------------------------------------------------
+r1771 | pag | 2009-08-12 14:01:41 -0500 (Wed, 12 Aug 2009) | 1 line
+
+A query transformation that moves OR expressions up to the root of the expression tree
+------------------------------------------------------------------------
+r1770 | pag | 2009-08-12 13:54:16 -0500 (Wed, 12 Aug 2009) | 1 line
+
+implemented getRowCardinality locally to be more efficient
+------------------------------------------------------------------------
+r1769 | pag | 2009-08-12 11:49:11 -0500 (Wed, 12 Aug 2009) | 1 line
+
+Added an unorderedAppend method. This uses unsorted tuples in an UnorderedAppend, as opposed to sorting tuples in an OrderedAppend
+------------------------------------------------------------------------
+r1768 | pag | 2009-08-12 11:47:47 -0500 (Wed, 12 Aug 2009) | 1 line
+
+Adding a modifyThread permission to compliment the modifyThreadGroup permission
+------------------------------------------------------------------------
+r1767 | pag | 2009-08-12 11:47:08 -0500 (Wed, 12 Aug 2009) | 1 line
+
+Moving up to 2.1.3 to avoid conflicts with 2.1.2
+------------------------------------------------------------------------
+r1766 | pag | 2009-08-10 19:23:57 -0500 (Mon, 10 Aug 2009) | 1 line
+
+Isolated the Jena interfaces into an external object, so that Jena is not needed in the classpath unless explicitly required.
+------------------------------------------------------------------------
+r1765 | pag | 2009-07-10 11:42:21 -0500 (Fri, 10 Jul 2009) | 1 line
+
+Added quotes to build script to allow for paths with spaces
+------------------------------------------------------------------------
+r1764 | pag | 2009-07-10 11:41:34 -0500 (Fri, 10 Jul 2009) | 1 line
+
+Added the getRowExpectedCount method to supplant getRowUpperBound
+------------------------------------------------------------------------
+r1763 | pag | 2009-07-10 11:40:35 -0500 (Fri, 10 Jul 2009) | 1 line
+
+Added help text for EXPORT, and updated all references to 'model' to say'graph'
+------------------------------------------------------------------------
+r1762 | pag | 2009-07-10 11:39:20 -0500 (Fri, 10 Jul 2009) | 1 line
+
+Added in grammar optimizations through the PatternTransformer. This was always supposed to be attached, but had been missed.
+------------------------------------------------------------------------
+r1761 | pag | 2009-07-10 11:37:58 -0500 (Fri, 10 Jul 2009) | 1 line
+
+Added the getRowExpectedCount method to supplant getRowUpperBound
+------------------------------------------------------------------------
+r1760 | pag | 2009-07-10 11:37:20 -0500 (Fri, 10 Jul 2009) | 1 line
+
+Added the getRowExpectedCount method to supplant getRowUpperBound, and removed warnings by adding generics
+------------------------------------------------------------------------
+r1759 | pag | 2009-07-10 11:35:27 -0500 (Fri, 10 Jul 2009) | 1 line
+
+Added the getRowExpectedCount method to supplant getRowUpperBound
+------------------------------------------------------------------------
+r1758 | pag | 2009-07-10 11:31:20 -0500 (Fri, 10 Jul 2009) | 1 line
+
+Added support for typed and language coded literals
+------------------------------------------------------------------------
+r1757 | pag | 2009-07-10 11:29:09 -0500 (Fri, 10 Jul 2009) | 1 line
+
+Fixed a bug where the wrong object was tested for null
+------------------------------------------------------------------------
+r1756 | pag | 2009-07-10 11:28:24 -0500 (Fri, 10 Jul 2009) | 1 line
+
+Adding in the ability to use non-QName URIs, for future expressions
+------------------------------------------------------------------------
+r1755 | pag | 2009-07-10 11:26:53 -0500 (Fri, 10 Jul 2009) | 1 line
+
+Added the getRowExpectedCount method to supplant getRowUpperBound
+------------------------------------------------------------------------
+r1754 | pag | 2009-07-10 11:25:25 -0500 (Fri, 10 Jul 2009) | 1 line
+
+Added the getRowExpectedCount method to supplant getRowUpperBound, plus cleaned up warnings by removing unused imports and adding generics
+------------------------------------------------------------------------
+r1753 | pag | 2009-07-06 17:40:35 -0500 (Mon, 06 Jul 2009) | 1 line
+
+Added in JSON escapes for literal strings. Not having them was a bug
+------------------------------------------------------------------------
+r1752 | pag | 2009-07-03 12:35:47 -0500 (Fri, 03 Jul 2009) | 1 line
+
+Missed the new CST class for variable assignment in commit 1751
+------------------------------------------------------------------------
+r1751 | pag | 2009-07-03 12:34:49 -0500 (Fri, 03 Jul 2009) | 1 line
+
+Added variable assignment as a SPARQL extension. This touches the parser and CST, the mapper to the AST, the AST, and the query execution (including Tuples operations)
+------------------------------------------------------------------------
+r1750 | pag | 2009-07-03 12:33:12 -0500 (Fri, 03 Jul 2009) | 1 line
+
+Added a necessary library to the test path so that BlockFile is available. Don't know why this didn't fail before, but it's been failing now
+------------------------------------------------------------------------
+r1749 | pag | 2009-07-03 12:31:40 -0500 (Fri, 03 Jul 2009) | 1 line
+
+Fixed the license
+------------------------------------------------------------------------
+r1748 | pag | 2009-07-03 12:31:08 -0500 (Fri, 03 Jul 2009) | 1 line
+
+More reasonably assumption about the expected value for the size of a join. This needs a major overhaul
+------------------------------------------------------------------------
+r1747 | pag | 2009-07-03 12:26:51 -0500 (Fri, 03 Jul 2009) | 1 line
+
+Added setIO permission for Jetty
+------------------------------------------------------------------------
+r1746 | pag | 2009-06-29 17:06:41 -0500 (Mon, 29 Jun 2009) | 1 line
+
+Adjustment of fudge-factor used for probabilistic weighting of row counts
+------------------------------------------------------------------------
+r1745 | pag | 2009-06-29 17:04:10 -0500 (Mon, 29 Jun 2009) | 1 line
+
+Removed call to optimize indexes on every commit
+------------------------------------------------------------------------
+r1744 | pag | 2009-06-29 17:03:09 -0500 (Mon, 29 Jun 2009) | 1 line
+
+New option allows user configuration files to be partial
+------------------------------------------------------------------------
+r1743 | pag | 2009-06-29 17:01:31 -0500 (Mon, 29 Jun 2009) | 1 line
+
+Removed references to obsolete libraries
+------------------------------------------------------------------------
+r1742 | pag | 2009-06-29 17:00:44 -0500 (Mon, 29 Jun 2009) | 1 line
+
+Added comments to the system configuration
+------------------------------------------------------------------------
+r1741 | pag | 2009-06-29 16:47:19 -0500 (Mon, 29 Jun 2009) | 1 line
+
+Made fields non-compulsory so a user can write partial files. The system file must be complete though.
+------------------------------------------------------------------------
+r1740 | pag | 2009-06-26 15:19:39 -0500 (Fri, 26 Jun 2009) | 1 line
+
+Integrated Andy Seaborne's JenaMulgara bridge. Added the JenaTest jar to properly test this bridge. Lots of optimizations are still possible.
+------------------------------------------------------------------------
+r1739 | pag | 2009-06-26 15:16:26 -0500 (Fri, 26 Jun 2009) | 1 line
+
+Cleaned up some formatting, and removed warnings through added generics, annotating unused loggers, and removing unused imports
+------------------------------------------------------------------------
+r1738 | pag | 2009-06-26 13:49:07 -0500 (Fri, 26 Jun 2009) | 1 line
+
+Changed an info message down to debug. I expected this would be rare and notable, but it is common
+------------------------------------------------------------------------
+r1737 | pag | 2009-06-23 02:40:21 -0500 (Tue, 23 Jun 2009) | 1 line
+
+Escaping entities in SPARQL XML results
+------------------------------------------------------------------------
+r1736 | alexhall | 2009-06-11 19:35:28 -0500 (Thu, 11 Jun 2009) | 1 line
+
+Modify the rule engine to support any multiple of 3 columns in the selection variables of a rule's query.  This allows rules to have multiple atoms in their heads, and is a more efficient implementation than splitting such rules into multiple rules with the same body and one head atom each.
+------------------------------------------------------------------------

Copied: branches/distinct_queries/KOWARI-MODIFICATIONS/mods-mulgara-2.1.4.txt (from rev 1836, trunk/KOWARI-MODIFICATIONS/mods-mulgara-2.1.4.txt)
===================================================================
--- branches/distinct_queries/KOWARI-MODIFICATIONS/mods-mulgara-2.1.4.txt	                        (rev 0)
+++ branches/distinct_queries/KOWARI-MODIFICATIONS/mods-mulgara-2.1.4.txt	2009-11-13 19:31:38 UTC (rev 1844)
@@ -0,0 +1,272 @@
+------------------------------------------------------------------------
+r1818 | pag | 2009-10-07 14:34:54 -0400 (Wed, 07 Oct 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/tuples/java/org/mulgara/store/tuples/UnorderedProjection.java
+
+Changed info message to debug
+------------------------------------------------------------------------
+r1817 | pag | 2009-10-06 23:04:28 -0400 (Tue, 06 Oct 2009) | 1 line
+Changed paths:
+   A /trunk/src/jar/query/java/org/mulgara/query/functions/MulgaraFunctionResolver.java
+   A /trunk/src/jar/query/java/org/mulgara/query/functions/MulgaraUnsafeFunctionResolver.java
+   A /trunk/src/jar/query/java/org/mulgara/query/functions/MulgaraXFunctionGroup.java
+
+The new 'unsafe' set of functions that missed the checking in r1816. Documentation on the use of these functions is at http://mulgara.org/trac/wiki/UnsafeFunctions
+------------------------------------------------------------------------
+r1816 | pag | 2009-10-06 23:02:38 -0400 (Tue, 06 Oct 2009) | 1 line
+Changed paths:
+   A /trunk/src/jar/query/java/org/mulgara/query/functions
+   A /trunk/src/jar/query/java/org/mulgara/query/functions/MulgaraFunction.java (from /trunk/src/jar/query/java/org/mulgara/query/xpath/MulgaraFunction.java:1797)
+   A /trunk/src/jar/query/java/org/mulgara/query/functions/MulgaraFunctionGroup.java (from /trunk/src/jar/query/java/org/mulgara/query/xpath/MulgaraFunctionGroup.java:1797)
+   M /trunk/src/jar/query/java/org/mulgara/query/xpath/FnFunctionGroup.java
+   D /trunk/src/jar/query/java/org/mulgara/query/xpath/MulgaraFunction.java
+   D /trunk/src/jar/query/java/org/mulgara/query/xpath/MulgaraFunctionGroup.java
+   M /trunk/src/jar/query/java/org/mulgara/query/xpath/MulgaraXPathFunctionResolver.java
+   M /trunk/src/jar/query/java/org/mulgara/query/xpath/OpFunctionGroup.java
+   M /trunk/src/jar/query/java/org/mulgara/query/xpath/SparqlFunctionGroup.java
+
+Refactored out common function loading code into MulgaraFunctionResolver. This meant changing static methods to instance methods (but that's OK, since they are only instantiated once). Also, took the completely abstract class of MulgaraFunctionGroup and converted to an interface. Common code was then moved to a new functions package. Finally, a new 'unsafe' set of functions was created. Documentation on the use of these functions is at http://mulgara.org/trac/wiki/UnsafeFunctions
+------------------------------------------------------------------------
+r1815 | pag | 2009-10-06 22:57:04 -0400 (Tue, 06 Oct 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/query/java/org/mulgara/query/FunctionResolverRegistry.java
+
+Changed the registry to use a list instead of a set, so that preference can be provided to the functions that are loaded first
+------------------------------------------------------------------------
+r1814 | pag | 2009-10-06 02:45:58 -0400 (Tue, 06 Oct 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/resolver/java/org/mulgara/resolver/StringPoolSession.java
+
+No longer canonicalizing URIs if they don't appear in the rmi scheme. The only exception is the system graph, which is always stored as relative.
+------------------------------------------------------------------------
+r1813 | pag | 2009-10-06 02:44:48 -0400 (Tue, 06 Oct 2009) | 1 line
+Changed paths:
+   M /trunk/conf/mulgara-config.xml
+
+Added Xalan and Mulgara function libraries
+------------------------------------------------------------------------
+r1812 | pag | 2009-10-06 02:44:13 -0400 (Tue, 06 Oct 2009) | 1 line
+Changed paths:
+   M /trunk/build.xml
+
+No longer allowing extra XML files to be loaded into JAR files that are created in the build
+------------------------------------------------------------------------
+r1811 | pag | 2009-10-06 02:43:18 -0400 (Tue, 06 Oct 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/server/java/org/mulgara/server/EmbeddedMulgaraServer.java
+
+Loading up XPathFunctionResolvers, as specified in the config files
+------------------------------------------------------------------------
+r1810 | pag | 2009-10-06 02:42:20 -0400 (Tue, 06 Oct 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/query/java/org/mulgara/query/filter/value/IRI.java
+
+Added support for IRIs to carry QNames with them
+------------------------------------------------------------------------
+r1809 | pag | 2009-10-06 02:41:42 -0400 (Tue, 06 Oct 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/query/java/org/mulgara/query/filter/value/ExternalFn.java
+
+Added support for calling external functions, provided through XPathFunctionResolvers and identified by QName
+------------------------------------------------------------------------
+r1808 | pag | 2009-10-06 02:40:35 -0400 (Tue, 06 Oct 2009) | 1 line
+Changed paths:
+   M /trunk/conf/mulgara-embedded.xsd
+   M /trunk/src/jar/server/java/org/mulgara/server/MulgaraUserConfig.java
+
+Added field for XpathFunctionResolvers
+------------------------------------------------------------------------
+r1807 | pag | 2009-10-06 02:39:27 -0400 (Tue, 06 Oct 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleAVLFileUnitTest.java
+
+removed warnings
+------------------------------------------------------------------------
+r1806 | pag | 2009-10-06 02:38:39 -0400 (Tue, 06 Oct 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/XAStatementStoreImplUnitTest.java
+
+added generics and refactored a fixed IF statement to remove warnings
+------------------------------------------------------------------------
+r1805 | pag | 2009-10-06 02:37:07 -0400 (Tue, 06 Oct 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleWriteThread.java
+
+Added generics to avoid warnings
+------------------------------------------------------------------------
+r1804 | pag | 2009-10-06 02:36:36 -0400 (Tue, 06 Oct 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleAVLFile.java
+
+removed stack traces from phases to save on memory
+------------------------------------------------------------------------
+r1803 | pag | 2009-10-06 02:35:20 -0400 (Tue, 06 Oct 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/util/java/org/mulgara/util/AbstractMulgaraResultSet.java
+
+removed unnecessary annotations
+------------------------------------------------------------------------
+r1802 | pag | 2009-10-06 02:34:38 -0400 (Tue, 06 Oct 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/querylang/java/org/mulgara/sparql/FilterMapper.java
+
+Providing external functions with QNames and not just a URI
+------------------------------------------------------------------------
+r1801 | pag | 2009-10-06 02:33:44 -0400 (Tue, 06 Oct 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/querylang/java/org/mulgara/sparql/parser/QueryStructureImpl.java
+
+Provides hints to IRIs to find QNames
+------------------------------------------------------------------------
+r1800 | pag | 2009-10-06 02:32:47 -0400 (Tue, 06 Oct 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/querylang/java/org/mulgara/sparql/parser/cst/IRIReference.java
+
+Now includes QNames. Also scanning known namespaces to attempt to build up QNames
+------------------------------------------------------------------------
+r1799 | pag | 2009-10-06 02:31:49 -0400 (Tue, 06 Oct 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/query/java/org/mulgara/query/filter/value/TypedLiteral.java
+
+allowing unknown types to be converted to strings instead of throwing an error
+------------------------------------------------------------------------
+r1798 | pag | 2009-10-06 02:30:35 -0400 (Tue, 06 Oct 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/query/java/org/mulgara/query/rdf/Mulgara.java
+
+Added namespace data
+------------------------------------------------------------------------
+r1797 | pag | 2009-10-06 02:29:59 -0400 (Tue, 06 Oct 2009) | 1 line
+Changed paths:
+   A /trunk/src/jar/query/java/org/mulgara/query/xpath
+   A /trunk/src/jar/query/java/org/mulgara/query/xpath/FnFunctionGroup.java
+   A /trunk/src/jar/query/java/org/mulgara/query/xpath/MulgaraFunction.java
+   A /trunk/src/jar/query/java/org/mulgara/query/xpath/MulgaraFunctionGroup.java
+   A /trunk/src/jar/query/java/org/mulgara/query/xpath/MulgaraXPathFunctionResolver.java
+   A /trunk/src/jar/query/java/org/mulgara/query/xpath/OpFunctionGroup.java
+   A /trunk/src/jar/query/java/org/mulgara/query/xpath/SparqlFunctionGroup.java
+
+Initial implementation of a set of functions for Mulgara, and the XPathFunctionResolver
+------------------------------------------------------------------------
+r1796 | pag | 2009-10-06 02:28:57 -0400 (Tue, 06 Oct 2009) | 1 line
+Changed paths:
+   A /trunk/src/jar/query/java/org/mulgara/query/FunctionResolverRegistry.java
+
+Added a central registry for loading XPathFunctionResolvers
+------------------------------------------------------------------------
+r1795 | pag | 2009-09-26 11:23:34 -0400 (Sat, 26 Sep 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/util/java/org/mulgara/util/ServerInfoRef.java
+
+Extended findSetter method to look for supertypes on provided parameters
+------------------------------------------------------------------------
+r1794 | pag | 2009-09-24 19:39:23 -0400 (Thu, 24 Sep 2009) | 1 line
+Changed paths:
+   M /trunk/common.properties
+
+Moving to new version early
+------------------------------------------------------------------------
+r1793 | pag | 2009-09-24 19:38:37 -0400 (Thu, 24 Sep 2009) | 1 line
+Changed paths:
+   M /trunk/conf/mulgara-rmi.policy
+   M /trunk/conf/mulgara-test.policy
+
+Added permission for Apple systems to access the keychain for HTTPS requests
+------------------------------------------------------------------------
+r1792 | pag | 2009-09-24 19:13:24 -0400 (Thu, 24 Sep 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/util-xa/java/org/mulgara/store/xa/FreeList.java
+
+Moved stack traces out of the Phase constructor and into the Phase.use method. Stack traces are not debug only
+------------------------------------------------------------------------
+r1791 | pag | 2009-09-24 19:12:38 -0400 (Thu, 24 Sep 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java
+
+Moved stack traces out of the Phase constructor and into the Phase.use method. Stack traces are not debug only
+------------------------------------------------------------------------
+r1790 | pag | 2009-09-24 19:10:48 -0400 (Thu, 24 Sep 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/util/java/org/mulgara/util/functional/C.java
+
+Added string join() methods for lists
+------------------------------------------------------------------------
+r1789 | pag | 2009-09-24 17:33:53 -0400 (Thu, 24 Sep 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/querylang/java/org/mulgara/protocol/http/LocalTriple.java
+   M /trunk/src/jar/querylang/java/org/mulgara/protocol/http/MulgaraServlet.java
+
+Fixed license
+------------------------------------------------------------------------
+r1788 | pag | 2009-09-24 10:56:54 -0400 (Thu, 24 Sep 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/tuples/java/org/mulgara/store/tuples/TuplesOperations.java
+
+Tweaking weighted terms for operand ordering. This definitely helps Topaz queries.
+------------------------------------------------------------------------
+r1787 | pag | 2009-09-12 01:41:24 -0400 (Sat, 12 Sep 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/content-n3/java/org/mulgara/content/n3/N3WriterUnitTest.java
+   M /trunk/src/jar/querylang/java/org/mulgara/protocol/StreamedN3Answer.java
+
+Added the option to set the charset encoding, with a default of UTF-8
+------------------------------------------------------------------------
+r1786 | pag | 2009-09-12 01:39:37 -0400 (Sat, 12 Sep 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/querylang/java/org/mulgara/protocol/AbstractStreamedAnswer.java
+   M /trunk/src/jar/querylang/java/org/mulgara/protocol/AbstractStreamedXMLAnswer.java
+   M /trunk/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlJSONAnswer.java
+   M /trunk/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlXMLAnswer.java
+   M /trunk/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlXMLAnswerUnitTest.java
+
+Changed default encoding to UTF-8, added encoding to the XML header, and added constructor variants to set the encoding
+------------------------------------------------------------------------
+r1785 | alexhall | 2009-08-26 12:53:58 -0400 (Wed, 26 Aug 2009) | 1 line
+Changed paths:
+   M /trunk/conf/mulgara.policy
+
+Accidentally committed with the wrong permissions.
+------------------------------------------------------------------------
+r1784 | alexhall | 2009-08-26 12:49:41 -0400 (Wed, 26 Aug 2009) | 1 line
+Changed paths:
+   M /trunk/conf/mulgara-rmi.policy
+   M /trunk/conf/mulgara.policy
+   M /trunk/src/jar/resolver/java/org/mulgara/resolver/ContentFactory.java
+
+Fix handling of content with an https: URL
+------------------------------------------------------------------------
+r1783 | alexhall | 2009-08-26 11:16:52 -0400 (Wed, 26 Aug 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/resolver/java/org/mulgara/resolver/ContentFactory.java
+
+Add generics and fix warnings.
+------------------------------------------------------------------------
+r1782 | pag | 2009-08-20 09:48:04 -0400 (Thu, 20 Aug 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneConstraint.java
+
+removed unused variables
+------------------------------------------------------------------------
+r1781 | pag | 2009-08-20 09:47:45 -0400 (Thu, 20 Aug 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolver.java
+
+Added stack trace to exceptions that are not being chained to their cause
+------------------------------------------------------------------------
+r1780 | pag | 2009-08-20 01:11:03 -0400 (Thu, 20 Aug 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndexException.java
+   M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndexUnitTest.java
+   M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneConstraint.java
+   M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneIndexerCache.java
+   M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolverUnitTest.java
+   M /trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ResolverException.java
+
+Removed warnings by adding serialization IDs and removing unused variables. Also fixed some TODO Javadocs and cleaned up some of the formatting
+------------------------------------------------------------------------
+r1779 | pag | 2009-08-20 01:09:53 -0400 (Thu, 20 Aug 2009) | 1 line
+Changed paths:
+   M /trunk/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolver.java
+
+Removed exception chains for FullTextStringIndexExceptions as these may not be instantiated at the client side.
+------------------------------------------------------------------------

Modified: branches/distinct_queries/build.properties
===================================================================
--- branches/distinct_queries/build.properties	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/build.properties	2009-11-13 19:31:38 UTC (rev 1844)
@@ -148,6 +148,7 @@
 beaver.jar               =beaver-0.9.6.1.jar
 mulgara-sparql.jar       =mulgara-sparql-0.0.2.jar
 velocity.jar             =velocity-1.5.jar
+xalan.jar                =xalan-2.7.0.jar
 
 # The following are JSP libs to be removed when JSP is excised
 jsp-core.jar             =core-3.1.1.jar

Modified: branches/distinct_queries/build.xml
===================================================================
--- branches/distinct_queries/build.xml	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/build.xml	2009-11-13 19:31:38 UTC (rev 1844)
@@ -526,11 +526,12 @@
       <zipfileset src="${lib.dir}/${lucene.core.jar}" excludes="META-INF/**"/>
       <zipfileset src="${lib.dir}/${mail.jar}" excludes="META-INF/**"/>
       <zipfileset src="${lib.dir}/${saaj.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${servlet.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${servlet.jar}" excludes="META-INF/**, **/*.xml"/>
       <zipfileset src="${lib.dir}/${servlet-jsp.jar}" excludes="META-INF/**"/>
       <zipfileset src="${lib.dir}/${sesame-model.jar}" excludes="META-INF/**"/>
       <zipfileset src="${lib.dir}/${trove.jar}" excludes="META-INF/**"/>
       <zipfileset src="${lib.dir}/${wsdl4j.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${xalan.jar}" excludes="META-INF/**"/>
 
 
       <zipfileset src="${bin.dir}/${config.jar}" excludes="META-INF/**"/>
@@ -544,8 +545,8 @@
       <zipfileset src="${bin.dir}/${dtd.jar}" excludes="META-INF/**"/>
       <zipfileset src="${bin.dir}/${jrdf.base.jar}" excludes="META-INF/**"/>
       <zipfileset src="${bin.dir}/${query.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${querylang.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${rmi.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${querylang.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${rmi.jar}" excludes="META-INF/**, **/*.xml"/>
       <zipfileset src="${bin.dir}/${resolver.jar}" excludes="META-INF/**"/>
       <zipfileset src="${bin.dir}/${resolver-distributed.jar}" excludes="META-INF/**"/>
       <zipfileset src="${bin.dir}/${resolver-file.jar}" excludes="META-INF/**"/>
@@ -1701,10 +1702,11 @@
       <zipfileset src="${lib.dir}/${mail.jar}" excludes="META-INF/**"/>
       <zipfileset src="${lib.dir}/${saaj.jar}" excludes="META-INF/**"/>
       <zipfileset src="${lib.dir}/${serializer.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${lib.dir}/${servlet.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${servlet.jar}" excludes="META-INF/**, **/*.xml"/>
       <zipfileset src="${lib.dir}/${sesame-model.jar}" excludes="META-INF/**"/>
       <zipfileset src="${lib.dir}/${trove.jar}" excludes="META-INF/**"/>
       <zipfileset src="${lib.dir}/${wsdl4j.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${xalan.jar}" excludes="META-INF/**"/>
 
       <!-- Libs needed for JSP. Remove these when JSP is eliminated. -->
       <zipfileset src="${jsp-lib.dir}/${jsp-core.jar}" excludes="META-INF/**"/>
@@ -1714,8 +1716,8 @@
       <!-- core libraries -->
       <zipfileset src="${bin.dir}/${query.jar}" excludes="META-INF/**"/>
       <zipfileset src="${bin.dir}/${driver.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${querylang.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${rmi.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${querylang.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${rmi.jar}" excludes="META-INF/**, **/*.xml"/>
       <zipfileset src="${bin.dir}/${server.jar}" excludes="META-INF/**"/>
       <zipfileset src="${bin.dir}/${server-rmi.jar}" excludes="META-INF/**"/>
       <zipfileset src="${bin.dir}/${util.jar}" excludes="META-INF/**"/>
@@ -1854,8 +1856,8 @@
 
       <zipfileset src="${bin.dir}/${query.jar}" excludes="META-INF/**"/>
       <zipfileset src="${bin.dir}/${driver.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${querylang.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${rmi.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${querylang.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${rmi.jar}" excludes="META-INF/**, **/*.xml"/>
       <zipfileset src="${bin.dir}/${server.jar}" excludes="META-INF/**"/>
       <zipfileset src="${bin.dir}/${server-rmi.jar}" excludes="META-INF/**"/>
       <zipfileset src="${bin.dir}/${util.jar}" excludes="META-INF/**"/>
@@ -2150,58 +2152,59 @@
       <zipfileset src="${lib.dir}/${sesame-model.jar}" excludes="META-INF/**"/>
       <zipfileset src="${lib.dir}/${trove.jar}" excludes="META-INF/**"/>
       <zipfileset src="${lib.dir}/${wsdl4j.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${lib.dir}/${xalan.jar}" excludes="META-INF/**"/>
 
       <!-- core libraries -->
-      <zipfileset src="${bin.dir}/${query.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${driver.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${querylang.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${rmi.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${server.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${server-rmi.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${util.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${config.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${descriptor.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${server-local.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-spi.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-filesystem.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${store.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${store-xa.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${store-nodepool.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${store-nodepool-memory.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${store-nodepool-xa.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${store-stringpool.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${store-stringpool-memory.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${store-stringpool-xa.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${store-stringpool-xa11.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${util-xa.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-null.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-file.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-http.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-lucene.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-memory.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-store.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-url.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-view.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${tuples.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${tuples-hybrid.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${content-mp3.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${content-n3.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${content-mbox.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${content-rdfxml.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${content-rlog.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-nodetype.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-prefix.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-relational.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-distributed.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-xsd.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-test.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${resolver-jar.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${dtd.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${jrdf.base.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${krule.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${swrl.jar}" excludes="META-INF/**"/>
-      <zipfileset src="${bin.dir}/${web.jar}" excludes="META-INF/**"/>
+      <zipfileset src="${bin.dir}/${query.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${driver.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${querylang.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${rmi.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${server.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${server-rmi.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${util.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${config.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${descriptor.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${server-local.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${resolver.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${resolver-spi.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${resolver-filesystem.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${store.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${store-xa.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${store-nodepool.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${store-nodepool-memory.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${store-nodepool-xa.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${store-stringpool.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${store-stringpool-memory.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${store-stringpool-xa.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${store-stringpool-xa11.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${util-xa.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${resolver-null.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${resolver-file.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${resolver-http.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${resolver-lucene.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${resolver-memory.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${resolver-store.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${resolver-url.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${resolver-view.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${tuples.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${tuples-hybrid.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${content-mp3.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${content-n3.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${content-mbox.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${content-rdfxml.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${content-rlog.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${resolver-nodetype.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${resolver-prefix.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${resolver-relational.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${resolver-distributed.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${resolver-xsd.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${resolver-test.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${resolver-jar.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${dtd.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${jrdf.base.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${krule.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${swrl.jar}" excludes="META-INF/**, **/*.xml"/>
+      <zipfileset src="${bin.dir}/${web.jar}" excludes="META-INF/**, **/*.xml"/>
 
 
       <zipfileset file="${obj.dir}/mulgara-x-config.xml" prefix="conf" />

Modified: branches/distinct_queries/common.properties
===================================================================
--- branches/distinct_queries/common.properties	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/common.properties	2009-11-13 19:31:38 UTC (rev 1844)
@@ -5,7 +5,7 @@
 # Product properties
 project        =mulgara
 description    =Mulgara Semantic Store
-mulgara-version=2.1.3
+mulgara-version=2.1.4
 year           =2001-2009
 default.build.label=${description} Version ${mulgara-version} (Build @@build@@)
 

Modified: branches/distinct_queries/conf/mulgara-config.xml
===================================================================
--- branches/distinct_queries/conf/mulgara-config.xml	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/conf/mulgara-config.xml	2009-11-13 19:31:38 UTC (rev 1844)
@@ -140,6 +140,12 @@
   <ResolverFactory type="org.mulgara.resolver.distributed.DistributedResolverFactory"/>
   <ResolverFactory type="org.mulgara.resolver.nullres.NullResolverFactory"/>
 
+  <!--
+    External libraries for implementing functions
+  -->
+  <XpathFunctionResolver type="org.mulgara.query.xpath.MulgaraXPathFunctionResolver"/>
+  <XpathFunctionResolver type="org.apache.xalan.extensions.XPathFunctionResolverImpl"/>
+
   <!-- iTQL script to run on startup -->
   <StartupScript>foo.itql</StartupScript>
 

Modified: branches/distinct_queries/conf/mulgara-embedded.xsd
===================================================================
--- branches/distinct_queries/conf/mulgara-embedded.xsd	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/conf/mulgara-embedded.xsd	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,4 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!-- When adding a new type, make sure it has a "disabled" attribute,
+     and update org.mulgara.server.MulgaraUserConfig#isDisabled(Object o) -->
 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
   <xs:element name="ExternalConfigPaths">
     <xs:complexType>
@@ -115,6 +117,12 @@
       <xs:attribute name="disabled" type="xs:boolean"/>
     </xs:complexType>
   </xs:element>
+  <xs:element name="XpathFunctionResolver">
+    <xs:complexType>
+      <xs:attribute name="type" type="xs:string" use="required"/>
+      <xs:attribute name="disabled" type="xs:boolean"/>
+    </xs:complexType>
+  </xs:element>
   <xs:element name="MulgaraConfig">
     <xs:complexType>
       <xs:sequence>
@@ -140,6 +148,7 @@
         <xs:element ref="DefaultContentHandler" minOccurs="0"/> <!-- Compulsory for server -->
         <xs:element ref="ContentHandler" minOccurs="0" maxOccurs="unbounded"/>
         <xs:element ref="ResolverFactory" minOccurs="0" maxOccurs="unbounded"/>
+        <xs:element ref="XpathFunctionResolver" minOccurs="0" maxOccurs="unbounded"/>
         <xs:element ref="StartupScript" minOccurs="0"/>
         <xs:element ref="Smtp" minOccurs="0"/> <!-- Compulsory for server -->
       </xs:sequence>

Modified: branches/distinct_queries/conf/mulgara-rmi.policy
===================================================================
--- branches/distinct_queries/conf/mulgara-rmi.policy	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/conf/mulgara-rmi.policy	2009-11-13 19:31:38 UTC (rev 1844)
@@ -15,8 +15,10 @@
   permission java.lang.RuntimePermission "shutdownHooks";
   permission java.lang.RuntimePermission "setIO";
   permission java.lang.RuntimePermission "exitVM";
+  permission java.lang.RuntimePermission "loadLibrary.keychain";
   permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
   permission java.net.SocketPermission "*:80", "listen,accept,connect,resolve";
+  permission java.net.SocketPermission "*:443", "connect,resolve";
   permission java.net.SocketPermission "*:1099", "connect,resolve";
   permission java.net.SocketPermission "*:8080", "connect,resolve";
   permission java.net.SocketPermission "*:1024-", "accept,connect,resolve";

Modified: branches/distinct_queries/conf/mulgara-test.policy
===================================================================
--- branches/distinct_queries/conf/mulgara-test.policy	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/conf/mulgara-test.policy	2009-11-13 19:31:38 UTC (rev 1844)
@@ -12,6 +12,7 @@
   permission java.lang.RuntimePermission "shutdownHooks";
   permission java.lang.RuntimePermission "getClassLoader";
   permission java.lang.RuntimePermission "accessDeclaredMembers";
+  permission java.lang.RuntimePermission "loadLibrary.keychain";
   permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
   permission java.net.SocketPermission "*:1099", "connect,resolve";
   permission java.net.SocketPermission "*:1024-", "accept,connect,resolve";

Modified: branches/distinct_queries/conf/mulgara.policy
===================================================================
--- branches/distinct_queries/conf/mulgara.policy	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/conf/mulgara.policy	2009-11-13 19:31:38 UTC (rev 1844)
@@ -16,6 +16,7 @@
   permission java.lang.RuntimePermission "exitVM";
   permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
   permission java.net.SocketPermission "*:80", "accept,connect,resolve";
+  permission java.net.SocketPermission "*:443", "connect,resolve";
   permission java.net.SocketPermission "*:1099", "connect,resolve";
   permission java.net.SocketPermission "*:8080", "connect,resolve";
   permission java.net.SocketPermission "*:1024-", "accept,connect,resolve";

Copied: branches/distinct_queries/jxdata/iTQL/vargraph (from rev 1836, trunk/jxdata/iTQL/vargraph)

Deleted: branches/distinct_queries/jxdata/iTQL/vargraph/queryResult1.txt
===================================================================
--- trunk/jxdata/iTQL/vargraph/queryResult1.txt	2009-11-12 18:26:47 UTC (rev 1836)
+++ branches/distinct_queries/jxdata/iTQL/vargraph/queryResult1.txt	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<answer xmlns="http://mulgara.org/tql#"><query><variables><graph/></variables><solution><graph resource="@server@#graph3"/></solution></query></answer>

Copied: branches/distinct_queries/jxdata/iTQL/vargraph/queryResult1.txt (from rev 1836, trunk/jxdata/iTQL/vargraph/queryResult1.txt)
===================================================================
--- branches/distinct_queries/jxdata/iTQL/vargraph/queryResult1.txt	                        (rev 0)
+++ branches/distinct_queries/jxdata/iTQL/vargraph/queryResult1.txt	2009-11-13 19:31:38 UTC (rev 1844)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<answer xmlns="http://mulgara.org/tql#"><query><variables><graph/></variables><solution><graph resource="@server@#graph3"/></solution></query></answer>

Deleted: branches/distinct_queries/jxdata/iTQL/vargraph/queryResult2.txt
===================================================================
--- trunk/jxdata/iTQL/vargraph/queryResult2.txt	2009-11-12 18:26:47 UTC (rev 1836)
+++ branches/distinct_queries/jxdata/iTQL/vargraph/queryResult2.txt	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<answer xmlns="http://mulgara.org/tql#"><query><variables><graph/></variables><solution><graph resource="@server@#graph1"/></solution><solution><graph resource="@server@#graph2"/></solution></query></answer>

Copied: branches/distinct_queries/jxdata/iTQL/vargraph/queryResult2.txt (from rev 1836, trunk/jxdata/iTQL/vargraph/queryResult2.txt)
===================================================================
--- branches/distinct_queries/jxdata/iTQL/vargraph/queryResult2.txt	                        (rev 0)
+++ branches/distinct_queries/jxdata/iTQL/vargraph/queryResult2.txt	2009-11-13 19:31:38 UTC (rev 1844)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<answer xmlns="http://mulgara.org/tql#"><query><variables><graph/></variables><solution><graph resource="@server@#graph1"/></solution><solution><graph resource="@server@#graph2"/></solution></query></answer>

Deleted: branches/distinct_queries/jxdata/iTQL/vargraph/queryResult3.txt
===================================================================
--- trunk/jxdata/iTQL/vargraph/queryResult3.txt	2009-11-12 18:26:47 UTC (rev 1836)
+++ branches/distinct_queries/jxdata/iTQL/vargraph/queryResult3.txt	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<answer xmlns="http://mulgara.org/tql#"><query><variables><graph/></variables></query></answer>

Copied: branches/distinct_queries/jxdata/iTQL/vargraph/queryResult3.txt (from rev 1836, trunk/jxdata/iTQL/vargraph/queryResult3.txt)
===================================================================
--- branches/distinct_queries/jxdata/iTQL/vargraph/queryResult3.txt	                        (rev 0)
+++ branches/distinct_queries/jxdata/iTQL/vargraph/queryResult3.txt	2009-11-13 19:31:38 UTC (rev 1844)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<answer xmlns="http://mulgara.org/tql#"><query><variables><graph/></variables></query></answer>

Deleted: branches/distinct_queries/jxdata/iTQL/vargraph/result1.txt
===================================================================
--- trunk/jxdata/iTQL/vargraph/result1.txt	2009-11-12 18:26:47 UTC (rev 1836)
+++ branches/distinct_queries/jxdata/iTQL/vargraph/result1.txt	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<answer xmlns="http://mulgara.org/tql#"><query><message>Successfully loaded 16 statements from @baseuri@/jxdata/iTQL/coins.rdf into @server@#graph1</message></query></answer>

Copied: branches/distinct_queries/jxdata/iTQL/vargraph/result1.txt (from rev 1836, trunk/jxdata/iTQL/vargraph/result1.txt)
===================================================================
--- branches/distinct_queries/jxdata/iTQL/vargraph/result1.txt	                        (rev 0)
+++ branches/distinct_queries/jxdata/iTQL/vargraph/result1.txt	2009-11-13 19:31:38 UTC (rev 1844)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<answer xmlns="http://mulgara.org/tql#"><query><message>Successfully loaded 16 statements from @baseuri@/jxdata/iTQL/coins.rdf into @server@#graph1</message></query></answer>

Deleted: branches/distinct_queries/jxdata/iTQL/vargraph/result2.txt
===================================================================
--- trunk/jxdata/iTQL/vargraph/result2.txt	2009-11-12 18:26:47 UTC (rev 1836)
+++ branches/distinct_queries/jxdata/iTQL/vargraph/result2.txt	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<answer xmlns="http://mulgara.org/tql#"><query><message>Successfully loaded 16 statements from @baseuri@/jxdata/iTQL/coins.rdf into @server@#graph2</message></query></answer>

Copied: branches/distinct_queries/jxdata/iTQL/vargraph/result2.txt (from rev 1836, trunk/jxdata/iTQL/vargraph/result2.txt)
===================================================================
--- branches/distinct_queries/jxdata/iTQL/vargraph/result2.txt	                        (rev 0)
+++ branches/distinct_queries/jxdata/iTQL/vargraph/result2.txt	2009-11-13 19:31:38 UTC (rev 1844)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<answer xmlns="http://mulgara.org/tql#"><query><message>Successfully loaded 16 statements from @baseuri@/jxdata/iTQL/coins.rdf into @server@#graph2</message></query></answer>

Deleted: branches/distinct_queries/jxdata/iTQL/vargraph/result3.txt
===================================================================
--- trunk/jxdata/iTQL/vargraph/result3.txt	2009-11-12 18:26:47 UTC (rev 1836)
+++ branches/distinct_queries/jxdata/iTQL/vargraph/result3.txt	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<answer xmlns="http://mulgara.org/tql#"><query><message>Successfully loaded 79 statements from @baseuri@/jxdata/iTQL/vcards.rdf into @server@#graph3</message></query></answer>

Copied: branches/distinct_queries/jxdata/iTQL/vargraph/result3.txt (from rev 1836, trunk/jxdata/iTQL/vargraph/result3.txt)
===================================================================
--- branches/distinct_queries/jxdata/iTQL/vargraph/result3.txt	                        (rev 0)
+++ branches/distinct_queries/jxdata/iTQL/vargraph/result3.txt	2009-11-13 19:31:38 UTC (rev 1844)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<answer xmlns="http://mulgara.org/tql#"><query><message>Successfully loaded 79 statements from @baseuri@/jxdata/iTQL/vcards.rdf into @server@#graph3</message></query></answer>

Deleted: branches/distinct_queries/jxdata/iTQL/vargraph/test.jxu
===================================================================
--- trunk/jxdata/iTQL/vargraph/test.jxu	2009-11-12 18:26:47 UTC (rev 1836)
+++ branches/distinct_queries/jxdata/iTQL/vargraph/test.jxu	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,59 +0,0 @@
-<jxu>
-  <set name="debug" value="false" />
-
-  <set name="modelName" value="@server@#graph1" />
-  <set name="loadCommand" value="load &lt;@baseuri@/jxdata/iTQL/coins.rdf&gt; into &lt;@server@#graph1&gt; ;" />
-  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
-
-  <ifEqual converse="true" file="result1.txt" name="loadResult">
-    <save name="loadResult" file="badLoadResult.xml"/>
-    <fail>Output failed.  Check badLoadResult.xml for output.</fail>
-  </ifEqual>
-
-  <set name="modelName" value="@server@#graph2" />
-  <set name="loadCommand" value="load &lt;@baseuri@/jxdata/iTQL/coins.rdf&gt; into &lt;@server@#graph2&gt; ;" />
-  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
-
-  <ifEqual converse="true" file="result2.txt" name="loadResult">
-    <save name="loadResult" file="badLoadResult2.xml"/>
-    <fail>Output failed.  Check badLoadResult2.xml for output.</fail>
-  </ifEqual>
-
-  <set name="modelName" value="@server@#graph3" />
-  <set name="loadCommand" value="load &lt;@baseuri@/jxdata/iTQL/vcards.rdf&gt; into &lt;@server@#graph3&gt; ;" />
-  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
-
-  <ifEqual converse="true" file="result3.txt" name="loadResult">
-    <save name="loadResult" file="badLoadResult3.xml"/>
-    <fail>Output failed.  Check badLoadResult3.xml for output.</fail>
-  </ifEqual>
-
-  <!-- now query the graphs -->
-
-  <set name="query" value="select $graph from &lt;@server@#graph1&gt; where &lt;http://qqq.com/staff/corky&gt; &lt;http://www.w3.org/2001/vcard-rdf/3.0#FN&gt; 'Corky Crystal' in $graph order by $graph;"/>
-
-  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
-  <ifEqual converse="true" file="queryResult1.txt" name="queryResult">
-    <save name="queryResult" file="badQuery1Result.xml"/>
-    <fail>Output failed.  Check badQuery1Result.xml for output.</fail>
-  </ifEqual>
-
-
-  <set name="query" value="select $graph from &lt;@server@#graph1&gt; where &lt;coin:SP&gt; &lt;coin:metal&gt; &lt;coin:silver&gt; in $graph order by $graph;"/>
-
-  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
-  <ifEqual converse="true" file="queryResult2.txt" name="queryResult">
-    <save name="queryResult" file="badQuery2Result.xml"/>
-    <fail>Output failed.  Check badQuery2Result.xml for output.</fail>
-  </ifEqual>
-
-  <set name="query" value="select $graph from &lt;@server@#graph1&gt; where &lt;foo:bar&gt; &lt;foo:baz&gt; &lt;foo:bop&gt; in $graph order by $graph;"/>
-
-  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
-  <ifEqual converse="true" file="queryResult3.txt" name="queryResult">
-    <save name="queryResult" file="badQuery3Result.xml"/>
-    <fail>Output failed.  Check badQuery3Result.xml for output.</fail>
-  </ifEqual>
-
-</jxu>
-

Copied: branches/distinct_queries/jxdata/iTQL/vargraph/test.jxu (from rev 1836, trunk/jxdata/iTQL/vargraph/test.jxu)
===================================================================
--- branches/distinct_queries/jxdata/iTQL/vargraph/test.jxu	                        (rev 0)
+++ branches/distinct_queries/jxdata/iTQL/vargraph/test.jxu	2009-11-13 19:31:38 UTC (rev 1844)
@@ -0,0 +1,59 @@
+<jxu>
+  <set name="debug" value="false" />
+
+  <set name="modelName" value="@server@#graph1" />
+  <set name="loadCommand" value="load &lt;@baseuri@/jxdata/iTQL/coins.rdf&gt; into &lt;@server@#graph1&gt; ;" />
+  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
+
+  <ifEqual converse="true" file="result1.txt" name="loadResult">
+    <save name="loadResult" file="badLoadResult.xml"/>
+    <fail>Output failed.  Check badLoadResult.xml for output.</fail>
+  </ifEqual>
+
+  <set name="modelName" value="@server@#graph2" />
+  <set name="loadCommand" value="load &lt;@baseuri@/jxdata/iTQL/coins.rdf&gt; into &lt;@server@#graph2&gt; ;" />
+  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
+
+  <ifEqual converse="true" file="result2.txt" name="loadResult">
+    <save name="loadResult" file="badLoadResult2.xml"/>
+    <fail>Output failed.  Check badLoadResult2.xml for output.</fail>
+  </ifEqual>
+
+  <set name="modelName" value="@server@#graph3" />
+  <set name="loadCommand" value="load &lt;@baseuri@/jxdata/iTQL/vcards.rdf&gt; into &lt;@server@#graph3&gt; ;" />
+  <eval stepClass="org.mulgara.store.jxunit.LoadDataJX" />
+
+  <ifEqual converse="true" file="result3.txt" name="loadResult">
+    <save name="loadResult" file="badLoadResult3.xml"/>
+    <fail>Output failed.  Check badLoadResult3.xml for output.</fail>
+  </ifEqual>
+
+  <!-- now query the graphs -->
+
+  <set name="query" value="select $graph from &lt;@server@#graph1&gt; where &lt;http://qqq.com/staff/corky&gt; &lt;http://www.w3.org/2001/vcard-rdf/3.0#FN&gt; 'Corky Crystal' in $graph order by $graph;"/>
+
+  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
+  <ifEqual converse="true" file="queryResult1.txt" name="queryResult">
+    <save name="queryResult" file="badQuery1Result.xml"/>
+    <fail>Output failed.  Check badQuery1Result.xml for output.</fail>
+  </ifEqual>
+
+
+  <set name="query" value="select $graph from &lt;@server@#graph1&gt; where &lt;coin:SP&gt; &lt;coin:metal&gt; &lt;coin:silver&gt; in $graph order by $graph;"/>
+
+  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
+  <ifEqual converse="true" file="queryResult2.txt" name="queryResult">
+    <save name="queryResult" file="badQuery2Result.xml"/>
+    <fail>Output failed.  Check badQuery2Result.xml for output.</fail>
+  </ifEqual>
+
+  <set name="query" value="select $graph from &lt;@server@#graph1&gt; where &lt;foo:bar&gt; &lt;foo:baz&gt; &lt;foo:bop&gt; in $graph order by $graph;"/>
+
+  <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
+  <ifEqual converse="true" file="queryResult3.txt" name="queryResult">
+    <save name="queryResult" file="badQuery3Result.xml"/>
+    <fail>Output failed.  Check badQuery3Result.xml for output.</fail>
+  </ifEqual>
+
+</jxu>
+

Modified: branches/distinct_queries/src/jar/content-n3/java/org/mulgara/content/n3/N3WriterUnitTest.java
===================================================================
--- branches/distinct_queries/src/jar/content-n3/java/org/mulgara/content/n3/N3WriterUnitTest.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/content-n3/java/org/mulgara/content/n3/N3WriterUnitTest.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -26,6 +26,8 @@
 import java.io.StringWriter;
 import java.net.URI;
 import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 // Java 2 enterprise packages
 import javax.activation.MimeType;
@@ -49,31 +51,93 @@
  */
 public class N3WriterUnitTest extends TestCase {
   /**
-   * Test {@link N3Writer} writing.
+   * Test {@link N3Writer} writing on a basic statement with a plain literal.
    *
    * @throws Exception if there's an error running the test (note that if the test
    *                   merely fails, this should <em>not</em> throw any exception
    */
-  public void test1() throws Exception {
-    // basic statement with plain literal
+  public void testBasic() throws Exception {
     runTest("<foo:bar> <foo:baz> \"42\" .\n", null);
-    // basic statement with blank-node and datatyped literal
+  }
+
+  /**
+   * Test {@link N3Writer} writing on a basic statement with blank-node and datatyped literal.
+   *
+   * @throws Exception if there's an error running the test (note that if the test
+   *                   merely fails, this should <em>not</em> throw any exception
+   */
+  public void testBasicBlankDataTyped() throws Exception {
     runTest("_:node1000001 <foo:baz> \"42\"^^<xsd:int> .\n", null);
-    // literal and uri with non-ascii characters
+  }
+
+  /**
+   * Test {@link N3Writer} writing on a statement with non-ascii characters.
+   *
+   * @throws Exception if there's an error running the test (note that if the test
+   *                   merely fails, this should <em>not</em> throw any exception
+   */
+  public void testNonAscii() throws Exception {
     runTest("<foo:i18n:øé> <foo:baz> \"Some text with \\\" in it, and 日本 chars, and \\u00E0 \" .",
             "<foo:i18n:%C3%B8%C3%A9> <foo:baz> \"Some text with \\\" in it, and \\u65E5\\u672C chars, and \\u00E0 \" .\n");
+  }
+
+
+  /**
+   * Test {@link N3Writer} writing with escaped characters.
+   *
+   * @throws Exception if there's an error running the test (note that if the test
+   *                   merely fails, this should <em>not</em> throw any exception
+   */
+  public void testEscapedChars() throws Exception {
     // literal with newlines, ff, etc
     runTest("<foo:bar> <foo:baz> \"Some text with \n, \r, \f, \u0000 in it\" .",
             "<foo:bar> <foo:baz> \"Some text with \\n, \\r, \\u000C, \\u0000 in it\" .\n");
     runTest("<foo:bar> <foo:baz> \"Some text with \\n, \\r, \\f, \\u0000 in it\" .",
             "<foo:bar> <foo:baz> \"Some text with \\n, \\r, \\u000C, \\u0000 in it\" .\n");
+  }
+
+  /**
+   * Test {@link N3Writer} writing statements with multiple blank nodes and a language tag.
+   *
+   * @throws Exception if there's an error running the test (note that if the test
+   *                   merely fails, this should <em>not</em> throw any exception
+   */
+  public void testMultiBlank() throws Exception {
     // multiple blank-nodes, and language-tag
-    runTest("_:bn1 <baz:baz> _:bn2 .\n" +
-            "_:bn2 <bar:bar> <foo:foo> .\n" +
-            "<foo:foo> <dc:title> \"hello\"@en .",
-            "_:node1000002 <baz:baz> _:node1000001 .\n" +
-            "_:node1000001 <bar:bar> <foo:foo> .\n" +
-            "<foo:foo> <dc:title> \"hello\"@en .\n");
+    String n3 = "_:bn1 <baz:baz> _:bn2 .\n" +
+                "_:bn2 <bar:bar> <foo:foo> .\n" +
+                "<foo:foo> <dc:title> \"hello\"@en .";
+    // Obtain a resolver session
+    ResolverSession resolverSession = new TestResolverSession();
+
+    // create the statements
+    Statements statements = new N3Statements(new StringContent(n3), resolverSession);
+
+    // test
+    StringWriter out = new StringWriter();
+    new N3Writer().write(statements, resolverSession, out);
+
+    // don't know what blank nodes will be returned, so we need just need to check that they are used consistently
+    Matcher m = Pattern.compile("(_:node[^ ]*) <baz:baz> (_:node[^ ]*)").matcher(out.toString());
+    assertTrue(m.find());
+    assertEquals(2, m.groupCount());
+    String bn1 = m.group(1);
+    String bn2 = m.group(2);
+    assertNotSame(bn1, bn2);
+
+    String exp = bn1 + " <baz:baz> " + bn2 + " .\n" +
+                 bn2 + " <bar:bar> <foo:foo> .\n" +
+                 "<foo:foo> <dc:title> \"hello\"@en .\n";    
+    assertEquals(exp != null ? exp : n3, out.toString());
+  }
+
+  /**
+   * Test {@link N3Writer} writing with multiple blank nodes using internal IDs.
+   *
+   * @throws Exception if there's an error running the test (note that if the test
+   *                   merely fails, this should <em>not</em> throw any exception
+   */
+  public void testInternalBlank() throws Exception {
     // multiple blank-nodes using internal-ids (numbers)
     runTest("_:42 <baz:baz> _:987 .\n" +
             "_:987 <bar:bar> <foo:foo> .\n",

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/connection/CommandExecutor.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/connection/CommandExecutor.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/connection/CommandExecutor.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,14 +1,19 @@
-/**
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+/*
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
+
 package org.mulgara.connection;
 
 import org.mulgara.query.Answer;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/connection/Connection.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/connection/Connection.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/connection/Connection.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,14 +1,19 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
+
 package org.mulgara.connection;
 
 import java.net.URI;
@@ -179,4 +184,4 @@
    */
   public BooleanAnswer execute(AskQuery cmd) throws QueryException, TuplesException;
 
-}
\ No newline at end of file
+}

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/connection/ConnectionException.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/connection/ConnectionException.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/connection/ConnectionException.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,14 +1,19 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
+
 package org.mulgara.connection;
 
 /**

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/connection/ConnectionFactory.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/connection/ConnectionFactory.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/connection/ConnectionFactory.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,14 +1,19 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
+
 package org.mulgara.connection;
 
 import java.net.InetAddress;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/connection/ConnectionFactoryUnitTest.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/connection/ConnectionFactoryUnitTest.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/connection/ConnectionFactoryUnitTest.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,13 +1,17 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 Revelytix.
  *
- * 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.
+ * 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.
  */
 package org.mulgara.connection;
 

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/connection/DummyConnection.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/connection/DummyConnection.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/connection/DummyConnection.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,14 +1,19 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
+
 package org.mulgara.connection;
 
 import java.net.URI;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/connection/JenaConnection.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/connection/JenaConnection.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/connection/JenaConnection.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,13 +1,17 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
 
 package org.mulgara.connection;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/connection/JenaConnectionImpl.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/connection/JenaConnectionImpl.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/connection/JenaConnectionImpl.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,13 +1,17 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
 
 package org.mulgara.connection;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/connection/SessionConnection.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/connection/SessionConnection.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/connection/SessionConnection.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,14 +1,19 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
+
 package org.mulgara.connection;
 
 import java.net.URI;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/AskQuery.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/AskQuery.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/AskQuery.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,13 +1,17 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
 
 package org.mulgara.query;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/ConstraintDifference.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/ConstraintDifference.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/ConstraintDifference.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,28 +1,17 @@
 /*
- * The contents of this file are subject to the Mozilla 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/MPL/
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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
  *
- * The Original Code is the Kowari Metadata Store.
+ * http://www.apache.org/licenses/LICENSE-2.0
  *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): N/A.
- *
- * [NOTE: The text of this Exhibit A may differ slightly from the text
- * of the notices in the Source Code files of the Original Code. You
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
+ * 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.
  */
 
 package org.mulgara.query;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/ConstraintIn.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/ConstraintIn.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/ConstraintIn.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -43,6 +43,8 @@
 
   /** The IN element to set subconstraints to. */
   private ConstraintElement graph;
+  
+  private Set<Variable> variables;
 
   /**
    * Construct a filtered constraint.
@@ -83,7 +85,16 @@
 
   /** {@inheritDoc} */
   public Set<Variable> getVariables() {
-    return constraint.getVariables();
+    if (variables == null) {
+      if (graph instanceof Variable) {
+        Set<Variable> vars = new HashSet<Variable>(constraint.getVariables());
+        vars.add((Variable)graph);
+        variables = Collections.unmodifiableSet(vars);
+      } else {
+        variables = constraint.getVariables();
+      }
+    }
+    return variables;
   }
 
 

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/ConstraintOptionalJoin.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/ConstraintOptionalJoin.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/ConstraintOptionalJoin.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,28 +1,17 @@
 /*
- * The contents of this file are subject to the Mozilla 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/MPL/
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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
  *
- * The Original Code is the Kowari Metadata Store.
+ * http://www.apache.org/licenses/LICENSE-2.0
  *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): N/A.
- *
- * [NOTE: The text of this Exhibit A may differ slightly from the text
- * of the notices in the Source Code files of the Original Code. You
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
+ * 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.
  */
 
 package org.mulgara.query;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/ConstructQuery.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/ConstructQuery.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/ConstructQuery.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,13 +1,17 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
 
 package org.mulgara.query;

Copied: branches/distinct_queries/src/jar/query/java/org/mulgara/query/FunctionResolverRegistry.java (from rev 1836, trunk/src/jar/query/java/org/mulgara/query/FunctionResolverRegistry.java)
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/FunctionResolverRegistry.java	                        (rev 0)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/FunctionResolverRegistry.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2009 DuraSpace.
+ *
+ * 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.
+ */
+
+package org.mulgara.query;
+
+import org.mulgara.util.Reflect;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.xpath.XPathFunctionResolver;
+
+/**
+ * A singleton registry for XPathFunctionResolvers.
+ *
+ * @created Sep 27, 2009
+ * @author Paul Gearon
+ * @copyright &copy; 2009 <a href="http://www.duraspace.org/">DuraSpace</a>
+ */
+public class FunctionResolverRegistry implements Iterable<XPathFunctionResolver> {
+
+  /** The singleton of this object */
+  static private FunctionResolverRegistry registry = new FunctionResolverRegistry();
+
+  /** The list of registered resolvers */
+  private List<XPathFunctionResolver> registered;
+
+  /**
+   * Constructs the singleton resolver.
+   */
+  private FunctionResolverRegistry() {
+    registered = new ArrayList<XPathFunctionResolver>();
+  }
+
+  /**
+   * Gets the singleton registry.
+   * @return The registry for resolvers.
+   */
+  public static FunctionResolverRegistry getFunctionResolverRegistry() {
+    return registry;
+  }
+
+  /**
+   * Registered a resolver instance.
+   * @param resolver The resolver instance to register.
+   */
+  public void register(XPathFunctionResolver resolver) {
+    registered.add(resolver);
+  }
+
+  /**
+   * Registered a resolver by name.
+   * @param resolver The name of a resolver type to register.
+   * @throws ClassNotFoundException Unable to find the specified class.
+   * @throws RuntimeException If the class could not be instantiated for any reason.
+   */
+  @SuppressWarnings("unchecked")
+  public void register(String resolverName) throws ClassNotFoundException {
+    Class<XPathFunctionResolver> resolverType = (Class<XPathFunctionResolver>)Class.forName(resolverName);
+    registered.add(Reflect.newInstance(resolverType));
+  }
+
+  /**
+   * Get an iterator for all the registered resolvers.
+   * @see java.lang.Iterable#iterator()
+   * @return an Iterator for the registry.
+   */
+  public Iterator<XPathFunctionResolver> iterator() {
+    return Collections.unmodifiableList(registered).iterator();
+  }
+}

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/Query.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/Query.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/Query.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -175,7 +175,7 @@
         if (o instanceof Variable) {
           Variable var = (Variable)o;
           if (!variableSet.contains(var)) {
-            logger.warn("Failed to find " + var + " in " + variableSet);
+            if (logger.isDebugEnabled()) logger.debug("Failed to find " + var + " in " + variableSet);
             throw new IllegalArgumentException("Failed to constrain all variables: " + var +
                 " not constrained in WHERE or GIVEN clauses");
           }

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/RdfXmlEmitter.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/RdfXmlEmitter.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/RdfXmlEmitter.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,13 +1,17 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 Revelytix.
  *
- * 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.
+ * 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.
  */
 package org.mulgara.query;
 

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/filter/value/ExternalFn.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/filter/value/ExternalFn.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/filter/value/ExternalFn.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -14,16 +14,26 @@
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
+import java.util.WeakHashMap;
 
 import org.apache.log4j.Logger;
 import org.jrdf.vocabulary.RDF;
 import org.mulgara.parser.MulgaraParserException;
+import org.mulgara.query.FunctionResolverRegistry;
 import org.mulgara.query.QueryException;
 import org.mulgara.query.filter.RDFTerm;
 import org.mulgara.query.rdf.XSD;
 
+import javax.xml.namespace.QName;
+import javax.xml.xpath.XPathFunction;
+import javax.xml.xpath.XPathFunctionException;
+import javax.xml.xpath.XPathFunctionResolver;
+
 /**
- * Executes a function that isn't defined in these packages.
+ * Executes a function that isn't defined in these packages. If the function is external
+ * then the answer is presumed to be scalar. URIs are automatically treated as IRIs, and anything else
+ * is treated as a literal.
  *
  * @created Apr 22, 2008
  * @author Paul Gearon
@@ -53,6 +63,15 @@
   /** This is a constructor function. */
   private boolean isConstructor = false;
 
+  /** The external function to execute. */
+  XPathFunction extFn = null;
+
+  /** Caches functions by their label of iri/#args. */
+  private static Map<String,XPathFunction> fnCache = new WeakHashMap<String,XPathFunction>();
+
+  /** Indicates that an error will always be returned from this method. */
+  private boolean unrecoverableError = false;
+
   /**
    * Create a new function instance.
    * @param fn The function to run.
@@ -65,7 +84,8 @@
       if (operands.length != 1) throw new MulgaraParserException("Cast operation can only take a single parameter");
       isConstructor = true;
     } else {
-      logger.error("Unknown function URI: " + fn);
+      extFn = findFunction(fn, operands.length);
+      if (extFn == null) logger.error("Unknown function: " + fn);
     }
   }
 
@@ -140,6 +160,12 @@
     return getContextOwner() == null ? true : resolve().isLiteral();
   }
 
+  /** @see java.lang.Object#toString() */
+  public String toString() {
+    String result = "function[" + fnUri + "]";
+    if (extFn != null) result += " -> " + extFn.getClass().getName();
+    return result;
+  }
 
   /**
    * Resolve the value of the function.
@@ -156,8 +182,24 @@
       if (XSD.isNumericType(fnUri) && value instanceof Number) return new NumericLiteral(NumericLiteral.getValueFor((Number)value, fnUri), fnUri);
       return TypedLiteral.newLiteral(value.toString(), fnUri, null);
     }
-    logger.warn("Attempting to execute an unsupported function: " + fnUri + "(" + resolveArgs() + ")");
-    return Bool.TRUE;
+    if (extFn == null) {
+      logger.debug("Attempting to execute an unsupported function: " + fnUri + "(" + resolveArgs() + ")");
+      return Bool.FALSE;
+    }
+    if (unrecoverableError) return Bool.FALSE;
+    Object result;
+    try {
+      result = extFn.evaluate(resolveArgs());
+    } catch (XPathFunctionException e) {
+      if (invalidFunctionException(e)) {
+        unrecoverableError = true;
+        logger.error("Error executing XPathFunction", e);
+      } else {
+        if (logger.isDebugEnabled()) logger.debug("Error executing XPathFunction", e);
+      }
+      throw new QueryException("Error executing external function", e);
+    }
+    return (result.getClass().equals(URI.class)) ? new IRI((URI)result) : TypedLiteral.newLiteral(result);
   }
 
   /**
@@ -186,4 +228,41 @@
     if (!result.isLiteral() && !(result instanceof NumericExpression)) throw new QueryException("Type Error: Not valid to ask the numeric form of a: " + result.getClass().getSimpleName());
     return ((NumericExpression)result).getNumber();
   }
+
+  /**
+   * Look for a function in the registered XPathFunctionResolvers.
+   * @param iri The URI of the function to find.
+   * @return The requested XPathFunction, or <code>null</code> if not found.
+   */
+  private XPathFunction findFunction(IRI iri, int argCount) {
+    String label = iri.toString() + "/" + argCount;
+    XPathFunction result = fnCache.get(label);
+    if (result == null) {
+      QName fnName = iri.getQName();
+      if (fnName == null) return null;
+      for (XPathFunctionResolver resolver: FunctionResolverRegistry.getFunctionResolverRegistry()) {
+        try {
+          result = resolver.resolveFunction(fnName, argCount);
+        } catch (Exception e) {
+          // this resolver is unable to handle the given QName
+        }
+        if (result != null) break;
+      }
+      if (result != null) fnCache.put(label, result);
+    }
+    return result;
+  }
+
+  /**
+   * Test if an exception indicates that a method is unavailable.
+   * @param e An exception thrown when an external method is invoked.
+   * @return <code>true</code> if the exception indicates that the method can never be successful.
+   */
+  private static boolean invalidFunctionException(Exception e) {
+    Throwable t = e;
+    do {
+      if (t instanceof NoSuchMethodException) return true;
+    } while ((t = t.getCause()) != null);
+    return false;
+  }
 }

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/filter/value/IRI.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/filter/value/IRI.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/filter/value/IRI.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -13,6 +13,8 @@
 
 import java.net.URI;
 
+import javax.xml.namespace.QName;
+
 import org.jrdf.graph.Node;
 import org.mulgara.query.QueryException;
 import org.mulgara.query.filter.Context;
@@ -38,19 +40,40 @@
   /** The URI held by this object */
   private final URI value;
 
+  private final QName qname;
+
   /**
    * Creates the value to wrap the uri.
    * @param u The URI to wrap
    */
   public IRI(URI u) {
     value = u;
+    qname = null;
   }
 
+  /**
+   * Creates the value to wrap the uri.
+   * @param u The URI to wrap
+   * @param q The QName for this uri.
+   */
+  public IRI(URI u, QName q) {
+    value = u;
+    this.qname = q;
+  }
+
   /** {@inheritDoc} */
   public URI getValue() {
     return value;
   }
 
+  /**
+   * Gets the qname for this IRI, if one exists.
+   * @return The QName of the IRI, or <code>null</code> if none exists.
+   */
+  public QName getQName() {
+    return qname;
+  }
+
   /** {@inheritDoc} */
   public Node getJRDFValue() {
     return new URIReferenceImpl(value);
@@ -105,4 +128,7 @@
   /** This value does not need a context */
   public void addContextListener(ContextOwner l) { }
 
+  public String toString() {
+    return qname == null ? value.toString() : value.toString() + " (" + qname + ")";
+  }
 }

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/filter/value/TypedLiteral.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/filter/value/TypedLiteral.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/filter/value/TypedLiteral.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -17,6 +17,7 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.log4j.Logger;
 import org.jrdf.graph.Node;
 import org.mulgara.query.QueryException;
 import org.mulgara.query.filter.Context;
@@ -39,6 +40,9 @@
   /** Generated Serialization ID for RMI */
   private static final long serialVersionUID = -6070455650703063913L;
 
+  /** The logger */
+  private final static Logger logger = Logger.getLogger(TypedLiteral.class.getName());
+
   /** The type URI for this literal */
   private URI type;
   
@@ -82,7 +86,10 @@
    */
   public static ValueLiteral newLiteral(Object value) throws QueryException {
     DataCompare dc = typeMap.get(value.getClass());
-    if (dc == null) throw new QueryException("Unrecognized data type: " + value.getClass().getSimpleName());
+    if (dc == null) {
+      logger.info("Unrecognized data type: " + value.getClass().getSimpleName());
+      return new SimpleLiteral(value.toString());
+    }
     return dc.newLiteral(value);
   }
 

Copied: branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions (from rev 1836, trunk/src/jar/query/java/org/mulgara/query/functions)

Deleted: branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraFunction.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/functions/MulgaraFunction.java	2009-11-12 18:26:47 UTC (rev 1836)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraFunction.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,120 +0,0 @@
-/*
- * Copyright 2009 DuraSpace.
- *
- * 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.
- */
-
-package org.mulgara.query.functions;
-
-import java.util.List;
-
-import javax.xml.xpath.XPathFunction;
-import javax.xml.xpath.XPathFunctionException;
-
-import org.jrdf.graph.Literal;
-import org.mulgara.query.QueryException;
-import org.mulgara.query.filter.value.SimpleLiteral;
-
-/**
- * General class for providing management information for XPath function implementations.
- *
- * @created Oct 5, 2009
- * @author Paul Gearon
- * @copyright &copy; 2009 <a href="http://www.duraspace.org/">DuraSpace</a>
- */
- at SuppressWarnings("unchecked")
-public abstract class MulgaraFunction implements XPathFunction {
-
-  /**
-   * Evaluate the method represented by this class, using the supplied arguments.
-   * @see javax.xml.xpath.XPathFunction#evaluate(java.util.List)
-   */
-  public Object evaluate(List args) throws XPathFunctionException {
-    checkArgs(getArity(), args);
-    try {
-      return eval(args);
-    } catch (ClassCastException e) {
-      throw new XPathFunctionException("Incorrect parameter types passed to function: " + e.getMessage());
-    }
-  }
-
-  /**
-   * Test that the correct number of arguments were provided to the function call.
-   * @param expected The expected number of arguments.
-   * @param args The list of arguments.
-   * @throws XPathFunctionException Thrown if the argument list is the wrong length.
-   */
-  protected void checkArgs(int expected, List args) throws XPathFunctionException {
-    if (expected >= 0 && args.size() != expected) {
-      throw new XPathFunctionException("Incorrect number of parameters. Should be " + expected + ", but was: " + args.size());
-    }
-  }
-
-  /**
-   * Returns the number of arguments required to use this function. Default is 1. 
-   * @return The number of arguments for this function.
-   */
-  protected int getArity() { return 1; }
-
-  /**
-   * The name of this function, followed by its arity.
-   * If not overridden then this will be the function class's name, starting with a lower-case letter.
-   * @return The name/arity of this function.
-   */
-  public String getName() {
-    StringBuilder name = new StringBuilder(getClass().getSimpleName());
-    char c = name.charAt(0);
-    if (Character.isUpperCase(c)) {
-      name.setCharAt(0, Character.toLowerCase(c));
-    }
-    for (int i = 1; i < name.length(); i++) {
-      c = name.charAt(0);
-      if (Character.isUpperCase(c)) name.replace(i, i + 1, "-" + Character.toLowerCase(c));
-    }
-    name.append("/");
-    int arity = getArity();
-    if (arity >= 0) name.append(getArity());
-    else name.append("*");
-    return name.toString();
-  }
-
-  /**
-   * Evaluates the operation of the function. The argument list will be the correct length.
-   * @param args The arguments for the function.
-   * @return The return value of the function.
-   * @throws XPathFunctionException If there was an error executing the function.
-   */
-  protected abstract Object eval(List<?> args) throws XPathFunctionException;
-
-  /**
-   * Convert a singleton value into its effective boolean value (EBV).
-   * @param o The singleton to test.
-   * @return The EBV of the value.
-   * @throws XPathFunctionException If a complex evaluation throws an exception.
-   */
-  protected static final boolean toBool(Object o) throws XPathFunctionException {
-    if (o == null) return false;
-    if (o instanceof String) return ((String)o).length() != 0;
-    if (o instanceof Number) return ((Number)o).doubleValue() != 0 && ((Number)o).doubleValue() != Double.NaN;
-    if (o instanceof Boolean) return ((Boolean)o).booleanValue();
-    try {
-      if (o instanceof Literal) return new SimpleLiteral(((Literal)o).getLexicalForm(), ((Literal)o).getLanguage()).test(null);
-    } catch (NullPointerException e) {
-      throw new XPathFunctionException("Conversion of data to a simple literal requires a context: " + e.getMessage());
-    } catch (QueryException e) {
-      throw new XPathFunctionException("Unable to convert data to a simple literal: " + e.getMessage());
-    }
-    throw new XPathFunctionException("Type error: " + o + " [" + o.getClass() + "]");
-  }
-
-}

Copied: branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraFunction.java (from rev 1836, trunk/src/jar/query/java/org/mulgara/query/functions/MulgaraFunction.java)
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraFunction.java	                        (rev 0)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraFunction.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2009 DuraSpace.
+ *
+ * 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.
+ */
+
+package org.mulgara.query.functions;
+
+import java.util.List;
+
+import javax.xml.xpath.XPathFunction;
+import javax.xml.xpath.XPathFunctionException;
+
+import org.jrdf.graph.Literal;
+import org.mulgara.query.QueryException;
+import org.mulgara.query.filter.value.SimpleLiteral;
+
+/**
+ * General class for providing management information for XPath function implementations.
+ *
+ * @created Oct 5, 2009
+ * @author Paul Gearon
+ * @copyright &copy; 2009 <a href="http://www.duraspace.org/">DuraSpace</a>
+ */
+ at SuppressWarnings("unchecked")
+public abstract class MulgaraFunction implements XPathFunction {
+
+  /**
+   * Evaluate the method represented by this class, using the supplied arguments.
+   * @see javax.xml.xpath.XPathFunction#evaluate(java.util.List)
+   */
+  public Object evaluate(List args) throws XPathFunctionException {
+    checkArgs(getArity(), args);
+    try {
+      return eval(args);
+    } catch (ClassCastException e) {
+      throw new XPathFunctionException("Incorrect parameter types passed to function: " + e.getMessage());
+    }
+  }
+
+  /**
+   * Test that the correct number of arguments were provided to the function call.
+   * @param expected The expected number of arguments.
+   * @param args The list of arguments.
+   * @throws XPathFunctionException Thrown if the argument list is the wrong length.
+   */
+  protected void checkArgs(int expected, List args) throws XPathFunctionException {
+    if (expected >= 0 && args.size() != expected) {
+      throw new XPathFunctionException("Incorrect number of parameters. Should be " + expected + ", but was: " + args.size());
+    }
+  }
+
+  /**
+   * Returns the number of arguments required to use this function. Default is 1. 
+   * @return The number of arguments for this function.
+   */
+  protected int getArity() { return 1; }
+
+  /**
+   * The name of this function, followed by its arity.
+   * If not overridden then this will be the function class's name, starting with a lower-case letter.
+   * @return The name/arity of this function.
+   */
+  public String getName() {
+    StringBuilder name = new StringBuilder(getClass().getSimpleName());
+    char c = name.charAt(0);
+    if (Character.isUpperCase(c)) {
+      name.setCharAt(0, Character.toLowerCase(c));
+    }
+    for (int i = 1; i < name.length(); i++) {
+      c = name.charAt(0);
+      if (Character.isUpperCase(c)) name.replace(i, i + 1, "-" + Character.toLowerCase(c));
+    }
+    name.append("/");
+    int arity = getArity();
+    if (arity >= 0) name.append(getArity());
+    else name.append("*");
+    return name.toString();
+  }
+
+  /**
+   * Evaluates the operation of the function. The argument list will be the correct length.
+   * @param args The arguments for the function.
+   * @return The return value of the function.
+   * @throws XPathFunctionException If there was an error executing the function.
+   */
+  protected abstract Object eval(List<?> args) throws XPathFunctionException;
+
+  /**
+   * Convert a singleton value into its effective boolean value (EBV).
+   * @param o The singleton to test.
+   * @return The EBV of the value.
+   * @throws XPathFunctionException If a complex evaluation throws an exception.
+   */
+  protected static final boolean toBool(Object o) throws XPathFunctionException {
+    if (o == null) return false;
+    if (o instanceof String) return ((String)o).length() != 0;
+    if (o instanceof Number) return ((Number)o).doubleValue() != 0 && ((Number)o).doubleValue() != Double.NaN;
+    if (o instanceof Boolean) return ((Boolean)o).booleanValue();
+    try {
+      if (o instanceof Literal) return new SimpleLiteral(((Literal)o).getLexicalForm(), ((Literal)o).getLanguage()).test(null);
+    } catch (NullPointerException e) {
+      throw new XPathFunctionException("Conversion of data to a simple literal requires a context: " + e.getMessage());
+    } catch (QueryException e) {
+      throw new XPathFunctionException("Unable to convert data to a simple literal: " + e.getMessage());
+    }
+    throw new XPathFunctionException("Type error: " + o + " [" + o.getClass() + "]");
+  }
+
+}

Deleted: branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraFunctionGroup.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/functions/MulgaraFunctionGroup.java	2009-11-12 18:26:47 UTC (rev 1836)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraFunctionGroup.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,49 +0,0 @@
-/*
- * Copyright 2009 DuraSpace.
- *
- * 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.
- */
-
-package org.mulgara.query.functions;
-
-import java.util.Set;
-
-
-/**
- * Represents a group of functions exposed as XPathFunctions in a single namespace.
- *
- * @created Oct 5, 2009
- * @author Paul Gearon
- * @copyright &copy; 2009 <a href="http://www.duraspace.org/">DuraSpace</a>
- */
-public interface MulgaraFunctionGroup {
-
-  /**
-   * Get the prefix used for the namespace of these operations.
-   * @return The short string used for a prefix in a QName.
-   */
-  public String getPrefix();
-
-  /**
-   * Get the namespace of these operations.
-   * @return The string of the namespace URI.
-   */
-  public String getNamespace();
-
-  /**
-   * Get the set of function in this group.
-   * @return A set of MulgaraFunction for this entire group.
-   */
-  public Set<MulgaraFunction> getAllFunctions();
-
-}

Copied: branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraFunctionGroup.java (from rev 1836, trunk/src/jar/query/java/org/mulgara/query/functions/MulgaraFunctionGroup.java)
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraFunctionGroup.java	                        (rev 0)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraFunctionGroup.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2009 DuraSpace.
+ *
+ * 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.
+ */
+
+package org.mulgara.query.functions;
+
+import java.util.Set;
+
+
+/**
+ * Represents a group of functions exposed as XPathFunctions in a single namespace.
+ *
+ * @created Oct 5, 2009
+ * @author Paul Gearon
+ * @copyright &copy; 2009 <a href="http://www.duraspace.org/">DuraSpace</a>
+ */
+public interface MulgaraFunctionGroup {
+
+  /**
+   * Get the prefix used for the namespace of these operations.
+   * @return The short string used for a prefix in a QName.
+   */
+  public String getPrefix();
+
+  /**
+   * Get the namespace of these operations.
+   * @return The string of the namespace URI.
+   */
+  public String getNamespace();
+
+  /**
+   * Get the set of function in this group.
+   * @return A set of MulgaraFunction for this entire group.
+   */
+  public Set<MulgaraFunction> getAllFunctions();
+
+}

Deleted: branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraFunctionResolver.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/functions/MulgaraFunctionResolver.java	2009-11-12 18:26:47 UTC (rev 1836)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraFunctionResolver.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,75 +0,0 @@
-/*
- * Copyright 2009 DuraSpace.
- *
- * 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.
- */
-
-package org.mulgara.query.functions;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-import javax.xml.xpath.XPathFunction;
-import javax.xml.xpath.XPathFunctionResolver;
-
-
-/**
- * Retrieves Mulgara functions.
- *
- * @created Oct 6, 2009
- * @author Paul Gearon
- * @copyright &copy; 2009 <a href="http://www.duraspace.org/">DuraSpace</a>
- */
-public abstract class MulgaraFunctionResolver implements XPathFunctionResolver {
-
-  /**
-   * A mapping of namespace URIs to the map of (name->functions) in that namespace.
-   * This is used to look up the requested function object.
-   */
-  private final Map<String,Map<String,XPathFunction>> functionGroups = new HashMap<String,Map<String,XPathFunction>>();
-
-
-  /**
-   * @see javax.xml.xpath.XPathFunctionResolver#resolveFunction(javax.xml.namespace.QName, int)
-   */
-  public XPathFunction resolveFunction(QName functionName, int arity) {
-    XPathFunction result = null;
-    String namespace = functionName.getNamespaceURI();
-    if (namespace != null) {
-      Map<String,XPathFunction> fnGroupMap = functionGroups.get(namespace);
-      if (fnGroupMap != null) {
-        result = fnGroupMap.get(functionName.getLocalPart() + "/" + arity);
-        // fall back to multiple arity
-        if (result == null) result = fnGroupMap.get(functionName.getLocalPart() + "/*");
-      }
-    }
-    return result;
-  }
-
-
-  /**
-   * A helper method to create a mapping of function names to their implementing classes,
-   * and of namespaces to these mappings.
-   * @param fnGroup A group of functions to be added into a single namespace.
-   *        This group also provides that namespace.
-   */
-  protected final void addFunctionGroup(MulgaraFunctionGroup fnGroup) {
-    // map the function names to the functions
-    Map<String,XPathFunction> functionMap = new HashMap<String,XPathFunction>();
-    for (MulgaraFunction fn: fnGroup.getAllFunctions()) functionMap.put(fn.getName(), fn);
-    // map the namespace to the name->function map
-    functionGroups.put(fnGroup.getNamespace(), functionMap);
-  }
-
-}

Copied: branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraFunctionResolver.java (from rev 1836, trunk/src/jar/query/java/org/mulgara/query/functions/MulgaraFunctionResolver.java)
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraFunctionResolver.java	                        (rev 0)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraFunctionResolver.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2009 DuraSpace.
+ *
+ * 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.
+ */
+
+package org.mulgara.query.functions;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.xpath.XPathFunction;
+import javax.xml.xpath.XPathFunctionResolver;
+
+
+/**
+ * Retrieves Mulgara functions.
+ *
+ * @created Oct 6, 2009
+ * @author Paul Gearon
+ * @copyright &copy; 2009 <a href="http://www.duraspace.org/">DuraSpace</a>
+ */
+public abstract class MulgaraFunctionResolver implements XPathFunctionResolver {
+
+  /**
+   * A mapping of namespace URIs to the map of (name->functions) in that namespace.
+   * This is used to look up the requested function object.
+   */
+  private final Map<String,Map<String,XPathFunction>> functionGroups = new HashMap<String,Map<String,XPathFunction>>();
+
+
+  /**
+   * @see javax.xml.xpath.XPathFunctionResolver#resolveFunction(javax.xml.namespace.QName, int)
+   */
+  public XPathFunction resolveFunction(QName functionName, int arity) {
+    XPathFunction result = null;
+    String namespace = functionName.getNamespaceURI();
+    if (namespace != null) {
+      Map<String,XPathFunction> fnGroupMap = functionGroups.get(namespace);
+      if (fnGroupMap != null) {
+        result = fnGroupMap.get(functionName.getLocalPart() + "/" + arity);
+        // fall back to multiple arity
+        if (result == null) result = fnGroupMap.get(functionName.getLocalPart() + "/*");
+      }
+    }
+    return result;
+  }
+
+
+  /**
+   * A helper method to create a mapping of function names to their implementing classes,
+   * and of namespaces to these mappings.
+   * @param fnGroup A group of functions to be added into a single namespace.
+   *        This group also provides that namespace.
+   */
+  protected final void addFunctionGroup(MulgaraFunctionGroup fnGroup) {
+    // map the function names to the functions
+    Map<String,XPathFunction> functionMap = new HashMap<String,XPathFunction>();
+    for (MulgaraFunction fn: fnGroup.getAllFunctions()) functionMap.put(fn.getName(), fn);
+    // map the namespace to the name->function map
+    functionGroups.put(fnGroup.getNamespace(), functionMap);
+  }
+
+}

Deleted: branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraUnsafeFunctionResolver.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/functions/MulgaraUnsafeFunctionResolver.java	2009-11-12 18:26:47 UTC (rev 1836)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraUnsafeFunctionResolver.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,34 +0,0 @@
-/*
- * Copyright 2009 DuraSpace.
- *
- * 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.
- */
-
-package org.mulgara.query.functions;
-
-
-/**
- * Retrieves Mulgara functions.
- *
- * @created Oct 6, 2009
- * @author Paul Gearon
- * @copyright &copy; 2009 <a href="http://www.duraspace.org/">DuraSpace</a>
- */
-public class MulgaraUnsafeFunctionResolver extends MulgaraFunctionResolver {
-
-  // initialize the maps of requested parameters to the function object being asked for
-  public MulgaraUnsafeFunctionResolver() {
-    addFunctionGroup(new MulgaraXFunctionGroup());
-  }
-
-}

Copied: branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraUnsafeFunctionResolver.java (from rev 1836, trunk/src/jar/query/java/org/mulgara/query/functions/MulgaraUnsafeFunctionResolver.java)
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraUnsafeFunctionResolver.java	                        (rev 0)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraUnsafeFunctionResolver.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2009 DuraSpace.
+ *
+ * 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.
+ */
+
+package org.mulgara.query.functions;
+
+
+/**
+ * Retrieves Mulgara functions.
+ *
+ * @created Oct 6, 2009
+ * @author Paul Gearon
+ * @copyright &copy; 2009 <a href="http://www.duraspace.org/">DuraSpace</a>
+ */
+public class MulgaraUnsafeFunctionResolver extends MulgaraFunctionResolver {
+
+  // initialize the maps of requested parameters to the function object being asked for
+  public MulgaraUnsafeFunctionResolver() {
+    addFunctionGroup(new MulgaraXFunctionGroup());
+  }
+
+}

Deleted: branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraXFunctionGroup.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/functions/MulgaraXFunctionGroup.java	2009-11-12 18:26:47 UTC (rev 1836)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraXFunctionGroup.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,139 +0,0 @@
-/*
- * Copyright 2009 DuraSpace.
- *
- * 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.
- */
-
-package org.mulgara.query.functions;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.xml.xpath.XPathFunctionException;
-
-import org.mulgara.query.functions.MulgaraFunction;
-import org.mulgara.query.functions.MulgaraFunctionGroup;
-
-/**
- * Container for functions in the mulgarax domain.
- *
- * @created Oct 5, 2009
- * @author Paul Gearon
- * @copyright &copy; 2009 <a href="http://www.duraspace.org/">DuraSpace</a>
- */
- at SuppressWarnings("unchecked")
-public class MulgaraXFunctionGroup implements MulgaraFunctionGroup {
-
-  /** The prefix for the mulgarax: namespace */
-  static final String PREFIX = "mulgarax";
-
-  /** The mulgarax: namespace */
-  static final String NAMESPACE = "http://mulgara.org/mulgarax#";
-
-  /** Internal buffer size for reading from external processes */
-  private static final int BUFFER_SIZE = 1024;
-
-  /**
-   * Get the prefix used for the namespace of these operations.
-   * @return The short string used for a prefix in a QName.
-   */
-  public String getPrefix() {
-    return PREFIX;
-  }
-
-  /**
-   * Get the namespace of these operations.
-   * @return The string of the namespace URI.
-   */
-  public String getNamespace() {
-    return NAMESPACE;
-  }
-
-  /**
-   * Get the set of MulgaraX functions.
-   * @return A set of MulgaraFunction for this entire group.
-   */
-  public Set<MulgaraFunction> getAllFunctions() {
-    Set<MulgaraFunction> functions = new HashSet<MulgaraFunction>();
-    functions.add(new System());
-    functions.add(new System2());
-    return functions;
-  }
-
-  /**
-   * Function to execute a command in a shell. Stdout is captured and returned as a string.
-   * @see http://www.w3.org/TR/xpath-functions/#func-matches
-   */
-  static private class System extends MulgaraFunction {
-    public Object eval(List args) throws XPathFunctionException {
-      String str = (String)args.get(0);
-      StringBuilder outputString = new StringBuilder();
-      try {
-        Process proc = Runtime.getRuntime().exec(str);
-        proc.getOutputStream().close();
-        BufferedReader procStdOut = new BufferedReader(new InputStreamReader(proc.getInputStream()));
-        char[] buffer = new char[BUFFER_SIZE];
-        int len;
-        while ((len = procStdOut.read(buffer)) >= 0) outputString.append(buffer, 0, len);
-        procStdOut.close();
-        proc.getErrorStream().close();
-      } catch (IOException e) {
-        throw new XPathFunctionException("I/O error communicating with external process.");
-      }
-      return outputString.toString();
-    }
-  }
-
-  /**
-   * Function to execute a command in a shell. A second parameter provides stdin for the process.
-   * Stdout is captured and returned as a string.
-   */
-  static private class System2 extends MulgaraFunction {
-    public String getName() { return "system/2"; }
-    public int getArity() { return 2; }
-    public Object eval(List args) throws XPathFunctionException {
-      // get the command and arguments
-      String str = (String)args.get(0);
-      // get the data to feed to stdin
-      String inputString = args.get(1).toString();
-
-      StringBuilder outputString = new StringBuilder();
-      try {
-        Process proc = Runtime.getRuntime().exec(str);
-        // get stdin for the process
-        Writer procStdIn = new OutputStreamWriter(proc.getOutputStream());
-        // get stdout for the process
-        BufferedReader procStdOut = new BufferedReader(new InputStreamReader(proc.getInputStream()));
-
-        // write to stdin
-        procStdIn.append(inputString);
-        procStdIn.close();
-        // read from stdout
-        char[] buffer = new char[BUFFER_SIZE];
-        int len;
-        while ((len = procStdOut.read(buffer)) >= 0) outputString.append(buffer, 0, len);
-        procStdOut.close();
-        proc.getErrorStream().close();
-      } catch (IOException e) {
-        throw new XPathFunctionException("I/O error communicating with external process.");
-      }
-      return outputString.toString();
-    }
-  }
-}

Copied: branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraXFunctionGroup.java (from rev 1836, trunk/src/jar/query/java/org/mulgara/query/functions/MulgaraXFunctionGroup.java)
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraXFunctionGroup.java	                        (rev 0)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/functions/MulgaraXFunctionGroup.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -0,0 +1,139 @@
+/*
+ * Copyright 2009 DuraSpace.
+ *
+ * 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.
+ */
+
+package org.mulgara.query.functions;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.xpath.XPathFunctionException;
+
+import org.mulgara.query.functions.MulgaraFunction;
+import org.mulgara.query.functions.MulgaraFunctionGroup;
+
+/**
+ * Container for functions in the mulgarax domain.
+ *
+ * @created Oct 5, 2009
+ * @author Paul Gearon
+ * @copyright &copy; 2009 <a href="http://www.duraspace.org/">DuraSpace</a>
+ */
+ at SuppressWarnings("unchecked")
+public class MulgaraXFunctionGroup implements MulgaraFunctionGroup {
+
+  /** The prefix for the mulgarax: namespace */
+  static final String PREFIX = "mulgarax";
+
+  /** The mulgarax: namespace */
+  static final String NAMESPACE = "http://mulgara.org/mulgarax#";
+
+  /** Internal buffer size for reading from external processes */
+  private static final int BUFFER_SIZE = 1024;
+
+  /**
+   * Get the prefix used for the namespace of these operations.
+   * @return The short string used for a prefix in a QName.
+   */
+  public String getPrefix() {
+    return PREFIX;
+  }
+
+  /**
+   * Get the namespace of these operations.
+   * @return The string of the namespace URI.
+   */
+  public String getNamespace() {
+    return NAMESPACE;
+  }
+
+  /**
+   * Get the set of MulgaraX functions.
+   * @return A set of MulgaraFunction for this entire group.
+   */
+  public Set<MulgaraFunction> getAllFunctions() {
+    Set<MulgaraFunction> functions = new HashSet<MulgaraFunction>();
+    functions.add(new System());
+    functions.add(new System2());
+    return functions;
+  }
+
+  /**
+   * Function to execute a command in a shell. Stdout is captured and returned as a string.
+   * @see http://www.w3.org/TR/xpath-functions/#func-matches
+   */
+  static private class System extends MulgaraFunction {
+    public Object eval(List args) throws XPathFunctionException {
+      String str = (String)args.get(0);
+      StringBuilder outputString = new StringBuilder();
+      try {
+        Process proc = Runtime.getRuntime().exec(str);
+        proc.getOutputStream().close();
+        BufferedReader procStdOut = new BufferedReader(new InputStreamReader(proc.getInputStream()));
+        char[] buffer = new char[BUFFER_SIZE];
+        int len;
+        while ((len = procStdOut.read(buffer)) >= 0) outputString.append(buffer, 0, len);
+        procStdOut.close();
+        proc.getErrorStream().close();
+      } catch (IOException e) {
+        throw new XPathFunctionException("I/O error communicating with external process.");
+      }
+      return outputString.toString();
+    }
+  }
+
+  /**
+   * Function to execute a command in a shell. A second parameter provides stdin for the process.
+   * Stdout is captured and returned as a string.
+   */
+  static private class System2 extends MulgaraFunction {
+    public String getName() { return "system/2"; }
+    public int getArity() { return 2; }
+    public Object eval(List args) throws XPathFunctionException {
+      // get the command and arguments
+      String str = (String)args.get(0);
+      // get the data to feed to stdin
+      String inputString = args.get(1).toString();
+
+      StringBuilder outputString = new StringBuilder();
+      try {
+        Process proc = Runtime.getRuntime().exec(str);
+        // get stdin for the process
+        Writer procStdIn = new OutputStreamWriter(proc.getOutputStream());
+        // get stdout for the process
+        BufferedReader procStdOut = new BufferedReader(new InputStreamReader(proc.getInputStream()));
+
+        // write to stdin
+        procStdIn.append(inputString);
+        procStdIn.close();
+        // read from stdout
+        char[] buffer = new char[BUFFER_SIZE];
+        int len;
+        while ((len = procStdOut.read(buffer)) >= 0) outputString.append(buffer, 0, len);
+        procStdOut.close();
+        proc.getErrorStream().close();
+      } catch (IOException e) {
+        throw new XPathFunctionException("I/O error communicating with external process.");
+      }
+      return outputString.toString();
+    }
+  }
+}

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/AddAlias.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/AddAlias.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/AddAlias.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,13 +1,17 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
 
 package org.mulgara.query.operation;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/ApplyRules.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/ApplyRules.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/ApplyRules.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,14 +1,19 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
+
 package org.mulgara.query.operation;
 
 import java.net.URI;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Backup.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Backup.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Backup.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,14 +1,19 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
+
 package org.mulgara.query.operation;
 
 import java.io.IOException;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/BooleanSetCommand.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/BooleanSetCommand.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/BooleanSetCommand.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,14 +1,19 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
+
 package org.mulgara.query.operation;
 
 /**

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Command.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Command.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Command.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,13 +1,17 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
 
 package org.mulgara.query.operation;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Commit.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Commit.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Commit.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,13 +1,17 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
 
 package org.mulgara.query.operation;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/CreateGraph.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/CreateGraph.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/CreateGraph.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,14 +1,19 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
+
 package org.mulgara.query.operation;
 
 import java.net.URI;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/DataInputTx.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/DataInputTx.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/DataInputTx.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,14 +1,19 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 Revelytix.
  *
- * 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.
+ * 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.
  */
+
 package org.mulgara.query.operation;
 
 import java.io.IOException;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/DataOutputTx.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/DataOutputTx.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/DataOutputTx.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,14 +1,19 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 Revelytix.
  *
- * 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.
+ * 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.
  */
+
 package org.mulgara.query.operation;
 
 import java.io.FileNotFoundException;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/DataTx.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/DataTx.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/DataTx.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,14 +1,19 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
+
 package org.mulgara.query.operation;
 
 import java.net.URI;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Deletion.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Deletion.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Deletion.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,14 +1,19 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
+
 package org.mulgara.query.operation;
 
 import java.net.URI;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/DropGraph.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/DropGraph.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/DropGraph.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,14 +1,19 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
+
 package org.mulgara.query.operation;
 
 import java.net.URI;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/ExecuteScript.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/ExecuteScript.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/ExecuteScript.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,14 +1,19 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
+
 package org.mulgara.query.operation;
 
 import java.io.BufferedReader;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Export.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Export.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Export.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,14 +1,19 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 Revelytix.
  *
- * 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.
+ * 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.
  */
+
 package org.mulgara.query.operation;
 
 import java.io.IOException;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Help.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Help.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Help.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,13 +1,17 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
 
 package org.mulgara.query.operation;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Insertion.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Insertion.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Insertion.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,14 +1,19 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
+
 package org.mulgara.query.operation;
 
 import java.net.URI;

Copied: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/ListAlias.java (from rev 1836, trunk/src/jar/query/java/org/mulgara/query/operation/ListAlias.java)
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/ListAlias.java	                        (rev 0)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/ListAlias.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2009 DuraSpace.
+ *
+ * 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.
+ */
+
+package org.mulgara.query.operation;
+
+import java.net.URI;
+import java.util.Map;
+
+import org.mulgara.connection.Connection;
+
+
+/**
+ * An AST element for the ALIAS command.
+ *
+ * @created 2009-10-19
+ * @author Paul Gearon
+ */
+public class ListAlias extends LocalCommand {
+
+  private final Map<String,URI> aliases;
+
+  /**
+   * Creates a new list alias command.
+   */
+  public ListAlias(Map<String,URI> aliases) {
+    this.aliases = aliases;
+    setResultMessage(buildAliasList(aliases));
+  }
+  
+  /**
+   * Indicates that this operation is for a UI.
+   * @return <code>true</code> as operation is for UI output only.
+   */
+  public boolean isUICommand() {
+    return true;
+  }
+
+  /**
+   * Asks for the dictionary of aliases.
+   * @param conn ignored.
+   * @return A Map object that maps namespace prefixes to the namespace URI.
+   */
+  public Object execute(Connection conn) {
+    return aliases;
+  }
+
+  /**
+   * Writes the alias map as a set of URI/namespace pairs to a string for printing.
+   * @return A String containing all the alias mappings.
+   */
+  private static String buildAliasList(Map<String,URI> aliases) {
+    StringBuilder buffer = new StringBuilder();
+    for (Map.Entry<String,URI> alias: aliases.entrySet()) {
+      buffer.append(alias.getKey()).append(":  <").append(alias.getValue()).append(">\n");
+    }
+    return buffer.toString();
+  }
+
+}

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Load.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Load.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Load.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,14 +1,19 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
+
 package org.mulgara.query.operation;
 
 import java.io.IOException;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/LocalCommand.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/LocalCommand.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/LocalCommand.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,13 +1,17 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
 
 package org.mulgara.query.operation;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Modification.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Modification.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Modification.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,13 +1,17 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
 
 package org.mulgara.query.operation;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/NullOp.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/NullOp.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/NullOp.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,14 +1,19 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
+
 package org.mulgara.query.operation;
 
 import org.mulgara.connection.Connection;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Quit.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Quit.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Quit.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,13 +1,17 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
 
 package org.mulgara.query.operation;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Restore.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Restore.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Restore.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,14 +1,19 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
+
 package org.mulgara.query.operation;
 
 import java.io.IOException;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Rollback.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Rollback.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/Rollback.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,13 +1,17 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
 
 package org.mulgara.query.operation;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,14 +1,19 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
+
 package org.mulgara.query.operation;
 
 import java.net.URI;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/SetAutoCommit.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/SetAutoCommit.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/SetAutoCommit.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,14 +1,19 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
+
 package org.mulgara.query.operation;
 
 import org.mulgara.connection.Connection;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/SetCommand.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/SetCommand.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/SetCommand.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,14 +1,19 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
+
 package org.mulgara.query.operation;
 
 /**

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/SetTime.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/SetTime.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/SetTime.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,14 +1,19 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
+
 package org.mulgara.query.operation;
 
 import org.mulgara.connection.Connection;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/SetUser.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/SetUser.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/SetUser.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,13 +1,17 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
 
 package org.mulgara.query.operation;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/TransactionCommand.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/TransactionCommand.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/TransactionCommand.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,13 +1,17 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
 
 package org.mulgara.query.operation;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/TxOp.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/TxOp.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/operation/TxOp.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,14 +1,19 @@
-/**
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+/*
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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.
  */
+
 package org.mulgara.query.operation;
 
 import org.mulgara.connection.Connection;

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/rdf/Mulgara.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/rdf/Mulgara.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/rdf/Mulgara.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -42,10 +42,17 @@
  * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
  */
 public class Mulgara {
+  
+  /** The Mulgara prefix for use in place of the namespace */
+  public final static String NS_PREFIX = "mulgara";
+
   /** Mulgara RDF namespace. */
   public final static String NAMESPACE = "http://mulgara.org/mulgara#";
   
-  /** Mulgara RDF namespace. */
+  /** Mulgara virtual RDF namespace. */
+  public final static URI NS_URI = URI.create("http://mulgara.org/mulgara#");
+
+  /** Mulgara virtual RDF namespace. */
   public final static String VIRTUAL_NS = "http://mulgara.org/virtual/";
 
   /** A general identifier for an empty graph */
@@ -66,10 +73,13 @@
   /** The URI for prefix graph types. */
   public final static URI PREFIX_GRAPH_TYPE_URI = URI.create(NAMESPACE + "PrefixGraph");
 
-  /** The URI for prefixes. */
+  /** The URI for URI prefixes. */
   public final static URI PREFIX_URI = URI.create(NAMESPACE + "prefix");
 
-  /** The URI for prefixes. */
+  /** The URI for string prefixes. */
+  public final static URI STR_PREFIX_URI = URI.create(NAMESPACE + "stringPrefix");
+
+  /** The URI for binding variables. */
   public final static URI IS_URI = URI.create(NAMESPACE + "is");
 
 }

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/rdf/SWRL.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/rdf/SWRL.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/rdf/SWRL.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,13 +1,17 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 Revelytix.
  *
- * 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.
+ * 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.
  */
 package org.mulgara.query.rdf;
 

Modified: branches/distinct_queries/src/jar/query/java/org/mulgara/query/rdf/XSDAbbrev.java
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/rdf/XSDAbbrev.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/rdf/XSDAbbrev.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,28 +1,17 @@
 /*
- * The contents of this file are subject to the Mozilla 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/MPL/
+ * Copyright 2009 DuraSpace.
  *
- * 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.
+ * 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
  *
- * The Original Code is the Kowari Metadata Store.
+ * http://www.apache.org/licenses/LICENSE-2.0
  *
- * The Initial Developer of the Original Code is Plugged In Software Pty
- * Ltd (http://www.pisoftware.com, mailto:info at pisoftware.com). Portions
- * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
- * Plugged In Software Pty Ltd. All Rights Reserved.
- *
- * Contributor(s): N/A.
- *
- * [NOTE: The text of this Exhibit A may differ slightly from the text
- * of the notices in the Source Code files of the Original Code. You
- * should use the text of this Exhibit A rather than the text found in the
- * Original Code Source Code for Your Modifications.]
- *
+ * 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.
  */
 
 package org.mulgara.query.rdf;

Copied: branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath (from rev 1836, trunk/src/jar/query/java/org/mulgara/query/xpath)

Deleted: branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/FnFunctionGroup.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/xpath/FnFunctionGroup.java	2009-11-12 18:26:47 UTC (rev 1836)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/FnFunctionGroup.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,369 +0,0 @@
-/*
- * Copyright 2009 DuraSpace.
- *
- * 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.
- */
-
-package org.mulgara.query.xpath;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.xml.xpath.XPathFunctionException;
-
-import org.apache.xerces.impl.xpath.regex.RegularExpression;
-import org.mulgara.query.functions.MulgaraFunction;
-import org.mulgara.query.functions.MulgaraFunctionGroup;
-
-/**
- * Container for functions in the fn domain.
- *
- * @created Oct 5, 2009
- * @author Paul Gearon
- * @copyright &copy; 2009 <a href="http://www.duraspace.org/">DuraSpace</a>
- */
- at SuppressWarnings("unchecked")
-public class FnFunctionGroup implements MulgaraFunctionGroup {
-
-  /** The prefix for the fn: namespace */
-  static final String PREFIX = "fn";
-
-  /** The fn: namespace */
-  static final String NAMESPACE = "http://www.w3.org/2005/xpath-functions/#";
-
-  /** The name of the UTF-8 encoding scheme */
-  static private final String UTF8 = "UTF-8";
-
-  /**
-   * Get the prefix used for the namespace of these operations.
-   * @return The short string used for a prefix in a QName.
-   */
-  public String getPrefix() {
-    return PREFIX;
-  }
-
-  /**
-   * Get the namespace of these operations.
-   * @return The string of the namespace URI.
-   */
-  public String getNamespace() {
-    return NAMESPACE;
-  }
-
-  /**
-   * Get the set of SPARQL functions.
-   * @return A set of MulgaraFunction for this entire group.
-   */
-  public Set<MulgaraFunction> getAllFunctions() {
-    Set<MulgaraFunction> functions = new HashSet<MulgaraFunction>();
-    functions.add(new Matches2());
-    functions.add(new Matches3());
-    functions.add(new FnBoolean());
-    functions.add(new Not());
-    functions.add(new Concat());
-    functions.add(new Substring2());
-    functions.add(new Substring3());
-    functions.add(new StringLength());
-    functions.add(new NormalizeSpace());
-    functions.add(new UpperCase());
-    functions.add(new LowerCase());
-    functions.add(new Translate());
-    functions.add(new EncodeForUri());
-    functions.add(new IriToUri());
-    functions.add(new EscapeHtmlUri());
-    return functions;
-  }
-
-  /**
-   * Function to evaluate if a string matches a pattern.
-   * @see http://www.w3.org/TR/xpath-functions/#func-matches
-   */
-  static private class Matches2 extends MulgaraFunction {
-    public String getName() { return "matches/2"; }
-    public int getArity() { return 2; }
-    public Object eval(List args) {
-      String str = (String)args.get(0);
-      String pattern = (String)args.get(1);
-      return new RegularExpression(pattern).matches(str);
-    }
-  }
-
-  /**
-   * Function to evaluate if a string matches a pattern, with a set of modifying flags.
-   * @see http://www.w3.org/TR/xpath-functions/#func-matches
-   */
-  static private class Matches3 extends MulgaraFunction {
-    public String getName() { return "matches/3"; }
-    public int getArity() { return 3; }
-    public Object eval(List args) {
-      String str = (String)args.get(0);
-      String pattern = (String)args.get(1);
-      String flags = (String)args.get(2);
-      return new RegularExpression(pattern, flags).matches(str);
-    }
-  }
-
-  /**
-   * Function to compute the EBV of a sequence. Unfortunately, no sequence info is available at this level.
-   * @see http://www.w3.org/TR/xpath-functions/#func-boolean
-   */
-  static private class FnBoolean extends MulgaraFunction {
-    public String getName() { return "boolean"; }
-    public int getArity() { return 1; }
-    public Object eval(List args) throws XPathFunctionException {
-      // no sequence info available here. Look at singleton only for the moment
-      return toBool(args.get(0));
-    }
-  }
-
-  // No implementation of fn:compare
-
-  /**
-   * Function to compute the inverse EBV of a sequence. See FnBoolean for restrictions.
-   * @see http://www.w3.org/TR/xpath-functions/#func-not
-   */
-  static private class Not extends MulgaraFunction {
-    public int getArity() { return 1; }
-    public Object eval(List args) throws XPathFunctionException {
-      return !toBool(args.get(0));
-    }
-  }
-
-  /**
-   * Concatenates two or more arguments cast to string.
-   * @see http://www.w3.org/TR/xpath-functions/#func-concat
-   */
-  static private class Concat extends MulgaraFunction {
-    public int getArity() { return -1; }
-    public String getName() { return "concat/*"; }
-    public Object eval(List args) throws XPathFunctionException {
-      StringBuilder s = new StringBuilder();
-      for (Object o: args) s.append(o);
-      return s.toString();
-    }
-  }
-
-  /**
-   * Returns the string located at a specified place within an argument string.
-   * @see http://www.w3.org/TR/xpath-functions/#func-substring
-   */
-  static private class Substring2 extends MulgaraFunction {
-    public int getArity() { return 2; }
-    public String getName() { return "substring/2"; }
-    public Object eval(List args) throws XPathFunctionException {
-      String source = args.get(0).toString();
-      int start = ((Number)args.get(1)).intValue();
-      // perform boundary checking
-      int len = source.length();
-      if (start < 0) start = 0;
-      if (start > len) start = len;
-      return source.substring(start);
-    }
-  }
-
-  /**
-   * Returns the string located at a specified place within an argument string.
-   * @see http://www.w3.org/TR/xpath-functions/#func-substring
-   */
-  static private class Substring3 extends MulgaraFunction {
-    public int getArity() { return 3; }
-    public String getName() { return "substring/3"; }
-    public Object eval(List args) throws XPathFunctionException {
-      String source = args.get(0).toString();
-      int start = ((Number)args.get(1)).intValue() - 1;
-      int end = ((Number)args.get(2)).intValue() + start;
-      // perform boundary checking
-      int len = source.length();
-      if (start < 0) start = 0;
-      if (start > len) {
-        start = len;
-        end = len;
-      }
-      if (end > len) end = len;
-      if (end < start) end = start;
-      
-      return source.substring(start, end);
-    }
-  }
-
-  /**
-   * Returns the length of the argument.
-   * @see http://www.w3.org/TR/xpath-functions/#func-string-length
-   */
-  static private class StringLength extends MulgaraFunction {
-    public String getName() { return "string-length/1"; }
-    public Object eval(List args) throws XPathFunctionException {
-      return args.get(0).toString().length();
-    }
-  }
-
-  /**
-   * Returns the whitespace-normalized value of the argument.
-   * @see http://www.w3.org/TR/xpath-functions/#func-normalize-space
-   */
-  static private class NormalizeSpace extends MulgaraFunction {
-    public String getName() { return "normalize-space/1"; }
-    public Object eval(List args) throws XPathFunctionException {
-      String str = args.get(0).toString().trim();
-      return str.replaceAll(" +", " ");
-    }
-  }
-
-  /**
-   * Returns the upper-cased value of the argument.
-   * @see http://www.w3.org/TR/xpath-functions/#func-upper-case
-   */
-  static private class UpperCase extends MulgaraFunction {
-    public String getName() { return "upper-case/1"; }
-    public Object eval(List args) throws XPathFunctionException {
-      return args.get(0).toString().toUpperCase();
-    }
-  }
-
-  /**
-   * Returns the lower-cased value of the argument.
-   * @see http://www.w3.org/TR/xpath-functions/#func-lower-case
-   */
-  static private class LowerCase extends MulgaraFunction {
-    public String getName() { return "lower-case/1"; }
-    public Object eval(List args) throws XPathFunctionException {
-      return args.get(0).toString().toLowerCase();
-    }
-  }
-
-  /**
-   * Returns the first xs:string argument with occurrences of characters contained
-   * in the second argument replaced by the character at the corresponding position
-   * in the third argument.
-   */
-  static private class Translate extends MulgaraFunction {
-    public int getArity() { return 3; }
-    public Object eval(List args) throws XPathFunctionException {
-      String str = args.get(0).toString();
-      String mapStr = args.get(1).toString();
-      String transStr = args.get(2).toString();
-      // iterate through the map chars
-      for (int i = 0; i < mapStr.length(); i++) {
-        char c = mapStr.charAt(i);
-        if (i < transStr.length()) str = replaceChars(str, c, transStr.charAt(i));
-        else str = removeChars(str, c);
-      }
-      return str;
-    }
-
-    private static String replaceChars(String str, char c, char r) {
-      StringBuilder s = new StringBuilder(str);
-      for (int i = 0; i < s.length(); i++) {
-        if (s.charAt(i) == c) s.setCharAt(i, r);
-      }
-      return s.toString();
-    }
-
-    private static String removeChars(String str, char c) {
-      StringBuilder s = new StringBuilder(str);
-      for (int i = 0; i < s.length(); i++) {
-        if (s.charAt(i) == c) {
-          s.replace(i, i + 1, "");
-          i--;
-        }
-      }
-      return s.toString();
-    }
-  }
-
-  /**
-   * Returns the xs:string argument with certain characters escaped to enable the
-   * resulting string to be used as a path segment in a URI.
-   * @see http://www.w3.org/TR/xpath-functions/#func-encode-for-uri
-   */
-  static private class EncodeForUri extends MulgaraFunction {
-    public String getName() { return "encode-for-uri/1"; }
-    public Object eval(List args) throws XPathFunctionException {
-      try {
-        return URLEncoder.encode(args.get(0).toString(), UTF8);
-      } catch (UnsupportedEncodingException e) {
-        throw new XPathFunctionException("Unable to encode string for URL: " + e.getMessage());
-      }
-    }
-  }
-
-  /**
-   * Returns the xs:string argument with certain characters escaped to enable the
-   * resulting string to be used as (part of) a URI.
-   * @see http://www.w3.org/TR/xpath-functions/#func-iri-to-uri
-   */
-  static private class IriToUri extends MulgaraFunction {
-    public String getName() { return "iri-to-uri/1"; }
-    public Object eval(List args) throws XPathFunctionException {
-      StringBuilder str = new StringBuilder(args.get(0).toString());
-      for (int i = 0; i < str.length(); i++) {
-        char c = str.charAt(i);
-        if (outOfRange(c)) str.replace(i, i + 1, escape(str.substring(i, i + 1)));
-      }
-      return str.toString();
-    }
-    /**
-     * Test for URI compatibility. See Errata note:
-     * @see http://www.w3.org/XML/2007/qt-errata/xpath-functions-errata.html#E8
-     * @param c The character to test.
-     * @return <code>true</code> if the character is out of range for a URI and must be encoded.
-     */
-    static private final boolean outOfRange(char c) {
-      return c < 0x20 || c > 0x7E || c == '<' || c == '>' || c == '"' ||
-             c == '{' || c == '}' || c == '|' || c == '\\' || c == '^' || c == '`';
-    }
-  }
-
-  /**
-   * Returns the string argument with certain characters escaped in the manner that html user agents
-   * handle attribute values that expect URIs.
-   * @see http://www.w3.org/TR/xpath-functions/#func-escape-html-uri
-   */
-  static private class EscapeHtmlUri extends MulgaraFunction {
-    public String getName() { return "escape-html-uri/1"; }
-    public Object eval(List args) throws XPathFunctionException {
-      StringBuilder str = new StringBuilder(args.get(0).toString());
-      for (int i = 0; i < str.length(); i++) {
-        char c = str.charAt(i);
-        if (outOfRange(c)) str.replace(i, i + 1, escape(str.substring(i, i + 1)));
-      }
-      return str.toString();
-    }
-    static private final boolean outOfRange(char c) {
-      return c < 0x20 || c > 0x7E;
-    }
-  }
-
-  /**
-   * Converts a single character to a string containing escaped UTF-8 encoding.
-   * A utility used by both EscapeHtmlUri and IriToUri.
-   * @param c The character to escape.
-   * @return A string containing a sequence of %HH representing the UTF-8 encoding of <var>c</var>
-   * @throws XPathFunctionException If UTF-8 encoding fails.
-   */
-  static private final String escape(String c) throws XPathFunctionException {
-    byte[] bytes = null;
-    try {
-      bytes = c.getBytes(UTF8);
-    } catch (UnsupportedEncodingException e) {
-      throw new XPathFunctionException("Unable to encode string for URL: " + e.getMessage());
-    }
-    StringBuilder result = new StringBuilder();
-    for (int i = 0; i < bytes.length; i++) result.append(String.format("%%%02X", bytes[i]));
-    return result.toString();
-  }
-
-}

Copied: branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/FnFunctionGroup.java (from rev 1836, trunk/src/jar/query/java/org/mulgara/query/xpath/FnFunctionGroup.java)
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/FnFunctionGroup.java	                        (rev 0)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/FnFunctionGroup.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -0,0 +1,369 @@
+/*
+ * Copyright 2009 DuraSpace.
+ *
+ * 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.
+ */
+
+package org.mulgara.query.xpath;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.xpath.XPathFunctionException;
+
+import org.apache.xerces.impl.xpath.regex.RegularExpression;
+import org.mulgara.query.functions.MulgaraFunction;
+import org.mulgara.query.functions.MulgaraFunctionGroup;
+
+/**
+ * Container for functions in the fn domain.
+ *
+ * @created Oct 5, 2009
+ * @author Paul Gearon
+ * @copyright &copy; 2009 <a href="http://www.duraspace.org/">DuraSpace</a>
+ */
+ at SuppressWarnings("unchecked")
+public class FnFunctionGroup implements MulgaraFunctionGroup {
+
+  /** The prefix for the fn: namespace */
+  static final String PREFIX = "fn";
+
+  /** The fn: namespace */
+  static final String NAMESPACE = "http://www.w3.org/2005/xpath-functions/#";
+
+  /** The name of the UTF-8 encoding scheme */
+  static private final String UTF8 = "UTF-8";
+
+  /**
+   * Get the prefix used for the namespace of these operations.
+   * @return The short string used for a prefix in a QName.
+   */
+  public String getPrefix() {
+    return PREFIX;
+  }
+
+  /**
+   * Get the namespace of these operations.
+   * @return The string of the namespace URI.
+   */
+  public String getNamespace() {
+    return NAMESPACE;
+  }
+
+  /**
+   * Get the set of SPARQL functions.
+   * @return A set of MulgaraFunction for this entire group.
+   */
+  public Set<MulgaraFunction> getAllFunctions() {
+    Set<MulgaraFunction> functions = new HashSet<MulgaraFunction>();
+    functions.add(new Matches2());
+    functions.add(new Matches3());
+    functions.add(new FnBoolean());
+    functions.add(new Not());
+    functions.add(new Concat());
+    functions.add(new Substring2());
+    functions.add(new Substring3());
+    functions.add(new StringLength());
+    functions.add(new NormalizeSpace());
+    functions.add(new UpperCase());
+    functions.add(new LowerCase());
+    functions.add(new Translate());
+    functions.add(new EncodeForUri());
+    functions.add(new IriToUri());
+    functions.add(new EscapeHtmlUri());
+    return functions;
+  }
+
+  /**
+   * Function to evaluate if a string matches a pattern.
+   * @see http://www.w3.org/TR/xpath-functions/#func-matches
+   */
+  static private class Matches2 extends MulgaraFunction {
+    public String getName() { return "matches/2"; }
+    public int getArity() { return 2; }
+    public Object eval(List args) {
+      String str = (String)args.get(0);
+      String pattern = (String)args.get(1);
+      return new RegularExpression(pattern).matches(str);
+    }
+  }
+
+  /**
+   * Function to evaluate if a string matches a pattern, with a set of modifying flags.
+   * @see http://www.w3.org/TR/xpath-functions/#func-matches
+   */
+  static private class Matches3 extends MulgaraFunction {
+    public String getName() { return "matches/3"; }
+    public int getArity() { return 3; }
+    public Object eval(List args) {
+      String str = (String)args.get(0);
+      String pattern = (String)args.get(1);
+      String flags = (String)args.get(2);
+      return new RegularExpression(pattern, flags).matches(str);
+    }
+  }
+
+  /**
+   * Function to compute the EBV of a sequence. Unfortunately, no sequence info is available at this level.
+   * @see http://www.w3.org/TR/xpath-functions/#func-boolean
+   */
+  static private class FnBoolean extends MulgaraFunction {
+    public String getName() { return "boolean"; }
+    public int getArity() { return 1; }
+    public Object eval(List args) throws XPathFunctionException {
+      // no sequence info available here. Look at singleton only for the moment
+      return toBool(args.get(0));
+    }
+  }
+
+  // No implementation of fn:compare
+
+  /**
+   * Function to compute the inverse EBV of a sequence. See FnBoolean for restrictions.
+   * @see http://www.w3.org/TR/xpath-functions/#func-not
+   */
+  static private class Not extends MulgaraFunction {
+    public int getArity() { return 1; }
+    public Object eval(List args) throws XPathFunctionException {
+      return !toBool(args.get(0));
+    }
+  }
+
+  /**
+   * Concatenates two or more arguments cast to string.
+   * @see http://www.w3.org/TR/xpath-functions/#func-concat
+   */
+  static private class Concat extends MulgaraFunction {
+    public int getArity() { return -1; }
+    public String getName() { return "concat/*"; }
+    public Object eval(List args) throws XPathFunctionException {
+      StringBuilder s = new StringBuilder();
+      for (Object o: args) s.append(o);
+      return s.toString();
+    }
+  }
+
+  /**
+   * Returns the string located at a specified place within an argument string.
+   * @see http://www.w3.org/TR/xpath-functions/#func-substring
+   */
+  static private class Substring2 extends MulgaraFunction {
+    public int getArity() { return 2; }
+    public String getName() { return "substring/2"; }
+    public Object eval(List args) throws XPathFunctionException {
+      String source = args.get(0).toString();
+      int start = ((Number)args.get(1)).intValue();
+      // perform boundary checking
+      int len = source.length();
+      if (start < 0) start = 0;
+      if (start > len) start = len;
+      return source.substring(start);
+    }
+  }
+
+  /**
+   * Returns the string located at a specified place within an argument string.
+   * @see http://www.w3.org/TR/xpath-functions/#func-substring
+   */
+  static private class Substring3 extends MulgaraFunction {
+    public int getArity() { return 3; }
+    public String getName() { return "substring/3"; }
+    public Object eval(List args) throws XPathFunctionException {
+      String source = args.get(0).toString();
+      int start = ((Number)args.get(1)).intValue() - 1;
+      int end = ((Number)args.get(2)).intValue() + start;
+      // perform boundary checking
+      int len = source.length();
+      if (start < 0) start = 0;
+      if (start > len) {
+        start = len;
+        end = len;
+      }
+      if (end > len) end = len;
+      if (end < start) end = start;
+      
+      return source.substring(start, end);
+    }
+  }
+
+  /**
+   * Returns the length of the argument.
+   * @see http://www.w3.org/TR/xpath-functions/#func-string-length
+   */
+  static private class StringLength extends MulgaraFunction {
+    public String getName() { return "string-length/1"; }
+    public Object eval(List args) throws XPathFunctionException {
+      return args.get(0).toString().length();
+    }
+  }
+
+  /**
+   * Returns the whitespace-normalized value of the argument.
+   * @see http://www.w3.org/TR/xpath-functions/#func-normalize-space
+   */
+  static private class NormalizeSpace extends MulgaraFunction {
+    public String getName() { return "normalize-space/1"; }
+    public Object eval(List args) throws XPathFunctionException {
+      String str = args.get(0).toString().trim();
+      return str.replaceAll(" +", " ");
+    }
+  }
+
+  /**
+   * Returns the upper-cased value of the argument.
+   * @see http://www.w3.org/TR/xpath-functions/#func-upper-case
+   */
+  static private class UpperCase extends MulgaraFunction {
+    public String getName() { return "upper-case/1"; }
+    public Object eval(List args) throws XPathFunctionException {
+      return args.get(0).toString().toUpperCase();
+    }
+  }
+
+  /**
+   * Returns the lower-cased value of the argument.
+   * @see http://www.w3.org/TR/xpath-functions/#func-lower-case
+   */
+  static private class LowerCase extends MulgaraFunction {
+    public String getName() { return "lower-case/1"; }
+    public Object eval(List args) throws XPathFunctionException {
+      return args.get(0).toString().toLowerCase();
+    }
+  }
+
+  /**
+   * Returns the first xs:string argument with occurrences of characters contained
+   * in the second argument replaced by the character at the corresponding position
+   * in the third argument.
+   */
+  static private class Translate extends MulgaraFunction {
+    public int getArity() { return 3; }
+    public Object eval(List args) throws XPathFunctionException {
+      String str = args.get(0).toString();
+      String mapStr = args.get(1).toString();
+      String transStr = args.get(2).toString();
+      // iterate through the map chars
+      for (int i = 0; i < mapStr.length(); i++) {
+        char c = mapStr.charAt(i);
+        if (i < transStr.length()) str = replaceChars(str, c, transStr.charAt(i));
+        else str = removeChars(str, c);
+      }
+      return str;
+    }
+
+    private static String replaceChars(String str, char c, char r) {
+      StringBuilder s = new StringBuilder(str);
+      for (int i = 0; i < s.length(); i++) {
+        if (s.charAt(i) == c) s.setCharAt(i, r);
+      }
+      return s.toString();
+    }
+
+    private static String removeChars(String str, char c) {
+      StringBuilder s = new StringBuilder(str);
+      for (int i = 0; i < s.length(); i++) {
+        if (s.charAt(i) == c) {
+          s.replace(i, i + 1, "");
+          i--;
+        }
+      }
+      return s.toString();
+    }
+  }
+
+  /**
+   * Returns the xs:string argument with certain characters escaped to enable the
+   * resulting string to be used as a path segment in a URI.
+   * @see http://www.w3.org/TR/xpath-functions/#func-encode-for-uri
+   */
+  static private class EncodeForUri extends MulgaraFunction {
+    public String getName() { return "encode-for-uri/1"; }
+    public Object eval(List args) throws XPathFunctionException {
+      try {
+        return URLEncoder.encode(args.get(0).toString(), UTF8);
+      } catch (UnsupportedEncodingException e) {
+        throw new XPathFunctionException("Unable to encode string for URL: " + e.getMessage());
+      }
+    }
+  }
+
+  /**
+   * Returns the xs:string argument with certain characters escaped to enable the
+   * resulting string to be used as (part of) a URI.
+   * @see http://www.w3.org/TR/xpath-functions/#func-iri-to-uri
+   */
+  static private class IriToUri extends MulgaraFunction {
+    public String getName() { return "iri-to-uri/1"; }
+    public Object eval(List args) throws XPathFunctionException {
+      StringBuilder str = new StringBuilder(args.get(0).toString());
+      for (int i = 0; i < str.length(); i++) {
+        char c = str.charAt(i);
+        if (outOfRange(c)) str.replace(i, i + 1, escape(str.substring(i, i + 1)));
+      }
+      return str.toString();
+    }
+    /**
+     * Test for URI compatibility. See Errata note:
+     * @see http://www.w3.org/XML/2007/qt-errata/xpath-functions-errata.html#E8
+     * @param c The character to test.
+     * @return <code>true</code> if the character is out of range for a URI and must be encoded.
+     */
+    static private final boolean outOfRange(char c) {
+      return c < 0x20 || c > 0x7E || c == '<' || c == '>' || c == '"' ||
+             c == '{' || c == '}' || c == '|' || c == '\\' || c == '^' || c == '`';
+    }
+  }
+
+  /**
+   * Returns the string argument with certain characters escaped in the manner that html user agents
+   * handle attribute values that expect URIs.
+   * @see http://www.w3.org/TR/xpath-functions/#func-escape-html-uri
+   */
+  static private class EscapeHtmlUri extends MulgaraFunction {
+    public String getName() { return "escape-html-uri/1"; }
+    public Object eval(List args) throws XPathFunctionException {
+      StringBuilder str = new StringBuilder(args.get(0).toString());
+      for (int i = 0; i < str.length(); i++) {
+        char c = str.charAt(i);
+        if (outOfRange(c)) str.replace(i, i + 1, escape(str.substring(i, i + 1)));
+      }
+      return str.toString();
+    }
+    static private final boolean outOfRange(char c) {
+      return c < 0x20 || c > 0x7E;
+    }
+  }
+
+  /**
+   * Converts a single character to a string containing escaped UTF-8 encoding.
+   * A utility used by both EscapeHtmlUri and IriToUri.
+   * @param c The character to escape.
+   * @return A string containing a sequence of %HH representing the UTF-8 encoding of <var>c</var>
+   * @throws XPathFunctionException If UTF-8 encoding fails.
+   */
+  static private final String escape(String c) throws XPathFunctionException {
+    byte[] bytes = null;
+    try {
+      bytes = c.getBytes(UTF8);
+    } catch (UnsupportedEncodingException e) {
+      throw new XPathFunctionException("Unable to encode string for URL: " + e.getMessage());
+    }
+    StringBuilder result = new StringBuilder();
+    for (int i = 0; i < bytes.length; i++) result.append(String.format("%%%02X", bytes[i]));
+    return result.toString();
+  }
+
+}

Deleted: branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/MulgaraXPathFunctionResolver.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/xpath/MulgaraXPathFunctionResolver.java	2009-11-12 18:26:47 UTC (rev 1836)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/MulgaraXPathFunctionResolver.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,39 +0,0 @@
-/*
- * Copyright 2009 DuraSpace.
- *
- * 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.
- */
-
-package org.mulgara.query.xpath;
-
-import org.mulgara.query.functions.MulgaraFunctionResolver;
-
-/**
- * Retrieves functions for SPARQL expressions.
- *
- * @created Oct 5, 2009
- * @author Paul Gearon
- * @copyright &copy; 2009 <a href="http://www.duraspace.org/">DuraSpace</a>
- */
-public class MulgaraXPathFunctionResolver extends MulgaraFunctionResolver {
-
-  /**
-   * Initialize the maps of requested parameters to the function object being asked for
-   */
-  public MulgaraXPathFunctionResolver() {
-    addFunctionGroup(new SparqlFunctionGroup());
-    addFunctionGroup(new FnFunctionGroup());
-    addFunctionGroup(new OpFunctionGroup());
-  }
-
-}

Copied: branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/MulgaraXPathFunctionResolver.java (from rev 1836, trunk/src/jar/query/java/org/mulgara/query/xpath/MulgaraXPathFunctionResolver.java)
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/MulgaraXPathFunctionResolver.java	                        (rev 0)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/MulgaraXPathFunctionResolver.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2009 DuraSpace.
+ *
+ * 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.
+ */
+
+package org.mulgara.query.xpath;
+
+import org.mulgara.query.functions.MulgaraFunctionResolver;
+
+/**
+ * Retrieves functions for SPARQL expressions.
+ *
+ * @created Oct 5, 2009
+ * @author Paul Gearon
+ * @copyright &copy; 2009 <a href="http://www.duraspace.org/">DuraSpace</a>
+ */
+public class MulgaraXPathFunctionResolver extends MulgaraFunctionResolver {
+
+  /**
+   * Initialize the maps of requested parameters to the function object being asked for
+   */
+  public MulgaraXPathFunctionResolver() {
+    addFunctionGroup(new SparqlFunctionGroup());
+    addFunctionGroup(new FnFunctionGroup());
+    addFunctionGroup(new OpFunctionGroup());
+  }
+
+}

Deleted: branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/OpFunctionGroup.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/xpath/OpFunctionGroup.java	2009-11-12 18:26:47 UTC (rev 1836)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/OpFunctionGroup.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,171 +0,0 @@
-/*
- * Copyright 2009 DuraSpace.
- *
- * 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.
- */
-
-package org.mulgara.query.xpath;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.mulgara.query.functions.MulgaraFunction;
-import org.mulgara.query.functions.MulgaraFunctionGroup;
-
-/**
- * Container for functions in the op pseudo-domain.
- *
- * @created Oct 5, 2009
- * @author Paul Gearon
- * @copyright &copy; 2009 <a href="http://www.duraspace.org/">DuraSpace</a>
- */
- at SuppressWarnings("unchecked")
-public class OpFunctionGroup implements MulgaraFunctionGroup {
-
-  /** The prefix for the fn: namespace */
-  static final String PREFIX = "op";
-
-  /** The op: namespace */
-  static final String NAMESPACE = PREFIX;
-
-  /**
-   * Get the prefix used for the namespace of these operations.
-   * @return The short string used for a prefix in a QName.
-   */
-  public String getPrefix() {
-    return PREFIX;
-  }
-
-  /**
-   * Get the namespace of these operations.
-   * @return The string of the namespace URI.
-   */
-  public String getNamespace() {
-    return NAMESPACE;
-  }
-
-  /**
-   * Get the set of SPARQL functions.
-   * @return A set of MulgaraFunction for this entire group.
-   */
-  public Set<MulgaraFunction> getAllFunctions() {
-    Set<MulgaraFunction> functions = new HashSet<MulgaraFunction>();
-    functions.add(new NumericEqual());
-    functions.add(new NumericLessThan());
-    functions.add(new NumericGreaterThan());
-    functions.add(new NumericIntegerDivision());
-    functions.add(new NumericMod());
-    return functions;
-  }
-
-  /**
-   * Function to evaluate if two numbers are equal.
-   * @see http://www.w3.org/TR/xpath-functions/#func-numeric-equal
-   */
-  static private class NumericEqual extends MulgaraFunction {
-    public String getName() { return "numeric-equal/2"; }
-    public int getArity() { return 2; }
-    public Object eval(List args) {
-      Number left = (Number)args.get(0);
-      Number right = (Number)args.get(1);
-      return left.doubleValue() == right.doubleValue();
-    }
-  }
-
-  /**
-   * Function to evaluate if one number is less than another.
-   * @see http://www.w3.org/TR/xpath-functions/#func-numeric-less-than
-   */
-  static private class NumericLessThan extends MulgaraFunction {
-    public String getName() { return "numeric-less-than/2"; }
-    public int getArity() { return 2; }
-    public Object eval(List args) {
-      Number left = (Number)args.get(0);
-      Number right = (Number)args.get(1);
-      return left.doubleValue() < right.doubleValue();
-    }
-  }
-
-  /**
-   * Function to evaluate if one number is greater than another.
-   * @see http://www.w3.org/TR/xpath-functions/#func-numeric-greater-than
-   */
-  static private class NumericGreaterThan extends MulgaraFunction {
-    public String getName() { return "numeric-greater-than/2"; }
-    public int getArity() { return 2; }
-    public Object eval(List args) {
-      Number left = (Number)args.get(0);
-      Number right = (Number)args.get(1);
-      return left.doubleValue() > right.doubleValue();
-    }
-  }
-
-  /**
-   * Function to evaluate integer division between numbers. This does not meet the XPath semantics
-   * perfectly, but will work for many situations.
-   * @see http://www.w3.org/TR/xpath-functions/#func-numeric-integer-divide
-   */
-  static private class NumericIntegerDivision extends MulgaraFunction {
-    public String getName() { return "numeric-integer-divide/2"; }
-    public int getArity() { return 2; }
-    public Object eval(List args) {
-      Number left = (Number)args.get(0);
-      Number right = (Number)args.get(1);
-      if (left instanceof BigDecimal) {
-        return ((BigDecimal)left).divide(
-            (right instanceof BigDecimal) ? (BigDecimal)right : new BigDecimal(right.toString())
-        );
-      }
-      if (left instanceof BigInteger) {
-        return ((BigInteger)left).divide(
-            (right instanceof BigInteger) ? (BigInteger)right : new BigInteger(right.toString())
-        );
-      }
-      return Double.valueOf(left.doubleValue() / right.doubleValue()).longValue();
-    }
-  }
-
-  /**
-   * Function to evaluate the numeric mod operation. This does not meet the XPath semantics
-   * perfectly, but will work for most situations.
-   * @see http://www.w3.org/TR/xpath-functions/#func-numeric-mod
-   */
-  static private class NumericMod extends MulgaraFunction {
-    public String getName() { return "numeric-mod/2"; }
-    public int getArity() { return 2; }
-    public Object eval(List args) {
-      Number left = (Number)args.get(0);
-      Number right = (Number)args.get(1);
-      if (left instanceof Byte || left instanceof Short || left instanceof Integer || left instanceof Long) {
-        return left.longValue() % right.longValue();
-      }
-      if (left instanceof Float || left instanceof Double) {
-        return left.doubleValue() % right.doubleValue();
-      }
-      if (left instanceof BigDecimal) {
-        return ((BigDecimal)left).remainder(
-            (right instanceof BigDecimal) ? (BigDecimal)right : new BigDecimal(right.toString())
-        );
-      }
-      if (left instanceof BigInteger) {
-        return ((BigInteger)left).remainder(
-            (right instanceof BigInteger) ? (BigInteger)right : new BigInteger(right.toString())
-        );
-      }
-      return Double.valueOf(left.doubleValue() % right.doubleValue()).longValue();
-    }
-  }
-}

Copied: branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/OpFunctionGroup.java (from rev 1836, trunk/src/jar/query/java/org/mulgara/query/xpath/OpFunctionGroup.java)
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/OpFunctionGroup.java	                        (rev 0)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/OpFunctionGroup.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -0,0 +1,171 @@
+/*
+ * Copyright 2009 DuraSpace.
+ *
+ * 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.
+ */
+
+package org.mulgara.query.xpath;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.mulgara.query.functions.MulgaraFunction;
+import org.mulgara.query.functions.MulgaraFunctionGroup;
+
+/**
+ * Container for functions in the op pseudo-domain.
+ *
+ * @created Oct 5, 2009
+ * @author Paul Gearon
+ * @copyright &copy; 2009 <a href="http://www.duraspace.org/">DuraSpace</a>
+ */
+ at SuppressWarnings("unchecked")
+public class OpFunctionGroup implements MulgaraFunctionGroup {
+
+  /** The prefix for the fn: namespace */
+  static final String PREFIX = "op";
+
+  /** The op: namespace */
+  static final String NAMESPACE = PREFIX;
+
+  /**
+   * Get the prefix used for the namespace of these operations.
+   * @return The short string used for a prefix in a QName.
+   */
+  public String getPrefix() {
+    return PREFIX;
+  }
+
+  /**
+   * Get the namespace of these operations.
+   * @return The string of the namespace URI.
+   */
+  public String getNamespace() {
+    return NAMESPACE;
+  }
+
+  /**
+   * Get the set of SPARQL functions.
+   * @return A set of MulgaraFunction for this entire group.
+   */
+  public Set<MulgaraFunction> getAllFunctions() {
+    Set<MulgaraFunction> functions = new HashSet<MulgaraFunction>();
+    functions.add(new NumericEqual());
+    functions.add(new NumericLessThan());
+    functions.add(new NumericGreaterThan());
+    functions.add(new NumericIntegerDivision());
+    functions.add(new NumericMod());
+    return functions;
+  }
+
+  /**
+   * Function to evaluate if two numbers are equal.
+   * @see http://www.w3.org/TR/xpath-functions/#func-numeric-equal
+   */
+  static private class NumericEqual extends MulgaraFunction {
+    public String getName() { return "numeric-equal/2"; }
+    public int getArity() { return 2; }
+    public Object eval(List args) {
+      Number left = (Number)args.get(0);
+      Number right = (Number)args.get(1);
+      return left.doubleValue() == right.doubleValue();
+    }
+  }
+
+  /**
+   * Function to evaluate if one number is less than another.
+   * @see http://www.w3.org/TR/xpath-functions/#func-numeric-less-than
+   */
+  static private class NumericLessThan extends MulgaraFunction {
+    public String getName() { return "numeric-less-than/2"; }
+    public int getArity() { return 2; }
+    public Object eval(List args) {
+      Number left = (Number)args.get(0);
+      Number right = (Number)args.get(1);
+      return left.doubleValue() < right.doubleValue();
+    }
+  }
+
+  /**
+   * Function to evaluate if one number is greater than another.
+   * @see http://www.w3.org/TR/xpath-functions/#func-numeric-greater-than
+   */
+  static private class NumericGreaterThan extends MulgaraFunction {
+    public String getName() { return "numeric-greater-than/2"; }
+    public int getArity() { return 2; }
+    public Object eval(List args) {
+      Number left = (Number)args.get(0);
+      Number right = (Number)args.get(1);
+      return left.doubleValue() > right.doubleValue();
+    }
+  }
+
+  /**
+   * Function to evaluate integer division between numbers. This does not meet the XPath semantics
+   * perfectly, but will work for many situations.
+   * @see http://www.w3.org/TR/xpath-functions/#func-numeric-integer-divide
+   */
+  static private class NumericIntegerDivision extends MulgaraFunction {
+    public String getName() { return "numeric-integer-divide/2"; }
+    public int getArity() { return 2; }
+    public Object eval(List args) {
+      Number left = (Number)args.get(0);
+      Number right = (Number)args.get(1);
+      if (left instanceof BigDecimal) {
+        return ((BigDecimal)left).divide(
+            (right instanceof BigDecimal) ? (BigDecimal)right : new BigDecimal(right.toString())
+        );
+      }
+      if (left instanceof BigInteger) {
+        return ((BigInteger)left).divide(
+            (right instanceof BigInteger) ? (BigInteger)right : new BigInteger(right.toString())
+        );
+      }
+      return Double.valueOf(left.doubleValue() / right.doubleValue()).longValue();
+    }
+  }
+
+  /**
+   * Function to evaluate the numeric mod operation. This does not meet the XPath semantics
+   * perfectly, but will work for most situations.
+   * @see http://www.w3.org/TR/xpath-functions/#func-numeric-mod
+   */
+  static private class NumericMod extends MulgaraFunction {
+    public String getName() { return "numeric-mod/2"; }
+    public int getArity() { return 2; }
+    public Object eval(List args) {
+      Number left = (Number)args.get(0);
+      Number right = (Number)args.get(1);
+      if (left instanceof Byte || left instanceof Short || left instanceof Integer || left instanceof Long) {
+        return left.longValue() % right.longValue();
+      }
+      if (left instanceof Float || left instanceof Double) {
+        return left.doubleValue() % right.doubleValue();
+      }
+      if (left instanceof BigDecimal) {
+        return ((BigDecimal)left).remainder(
+            (right instanceof BigDecimal) ? (BigDecimal)right : new BigDecimal(right.toString())
+        );
+      }
+      if (left instanceof BigInteger) {
+        return ((BigInteger)left).remainder(
+            (right instanceof BigInteger) ? (BigInteger)right : new BigInteger(right.toString())
+        );
+      }
+      return Double.valueOf(left.doubleValue() % right.doubleValue()).longValue();
+    }
+  }
+}

Deleted: branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/SparqlFunctionGroup.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/xpath/SparqlFunctionGroup.java	2009-11-12 18:26:47 UTC (rev 1836)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/SparqlFunctionGroup.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,181 +0,0 @@
-/*
- * Copyright 2009 DuraSpace.
- *
- * 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.
- */
-
-package org.mulgara.query.xpath;
-
-import java.net.URI;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.xml.xpath.XPathFunctionException;
-
-import org.jrdf.graph.BlankNode;
-import org.jrdf.graph.Literal;
-import org.mulgara.query.QueryException;
-import org.mulgara.query.filter.value.SimpleLiteral;
-import org.mulgara.query.functions.MulgaraFunction;
-import org.mulgara.query.functions.MulgaraFunctionGroup;
-
-/**
- * Container for functions in the SPARQL domain.
- *
- * @created Oct 5, 2009
- * @author Paul Gearon
- * @copyright &copy; 2009 <a href="http://www.duraspace.org/">DuraSpace</a>
- */
- at SuppressWarnings("unchecked")
-public class SparqlFunctionGroup implements MulgaraFunctionGroup {
-
-  /** The prefix for the sparql: namespace */
-  static final String PREFIX = "sparql";
-
-  /** The sparql: namespace */
-  static final String NAMESPACE = "http://www.w3.org/2006/sparql-functions#";
-
-  /**
-   * Get the prefix used for the namespace of these operations.
-   * @return The short string used for a prefix in a QName.
-   */
-  public String getPrefix() {
-    return PREFIX;
-  }
-
-  /**
-   * Get the namespace of these operations.
-   * @return The string of the namespace URI.
-   */
-  public String getNamespace() {
-    return NAMESPACE;
-  }
-
-  /**
-   * Get the set of SPARQL functions.
-   * @return A set of MulgaraFunction for this entire group.
-   */
-  public Set<MulgaraFunction> getAllFunctions() {
-    Set<MulgaraFunction> functions = new HashSet<MulgaraFunction>();
-    functions.add(new Bound());
-    functions.add(new IsIRI());
-    functions.add(new IsURI());
-    functions.add(new IsBlank());
-    functions.add(new IsLiteral());
-    functions.add(new Str());
-    functions.add(new Lang());
-    functions.add(new Datatype());
-    functions.add(new LangMatches());
-    functions.add(new LogicalOr());
-    functions.add(new LogicalAnd());
-    return functions;
-  }
-
-  /** Function to evaluate if a parameter is bound. */
-  static private class Bound extends MulgaraFunction {
-    public Object eval(List args) { return args.get(0) != null; }
-  }
-
-  /** Function to evaluate if a parameter is an IRI. */
-  static private class IsIRI extends MulgaraFunction {
-    public Object eval(List args) { return args.get(0) instanceof URI; }
-  }
-
-  /** Function to evaluate if a parameter is a URI. */
-  static private class IsURI extends MulgaraFunction {
-    public Object eval(List args) { return args.get(0) instanceof URI; }
-  }
-
-  /** Function to evaluate if a parameter is a blank node. */
-  static private class IsBlank extends MulgaraFunction {
-    public Object eval(List args) { return args.get(0) instanceof BlankNode; }
-  }
-
-  /** Function to evaluate if a parameter is a literal. */
-  static private class IsLiteral extends MulgaraFunction {
-    public Object eval(List args) {
-      Object o = args.get(0);
-      return o instanceof Literal || o instanceof String || o instanceof Number;
-    }
-  }
-
-  /** Function to convert a value to a string. */
-  static private class Str extends MulgaraFunction {
-    public Object eval(List args) { return args.get(0).toString(); }
-  }
-
-  /** Function to get the language of a literal. This information is probably not available for this implementation. */
-  static private class Lang extends MulgaraFunction {
-    public Object eval(List args) {
-      Object o = args.get(0);
-      return o instanceof Literal ? ((Literal)o).getLanguage() : "";
-    }
-  }
-    
-  /** Function to get the datatype of a literal. This information is probably not available for this implementation. */
-  static private class Datatype extends MulgaraFunction {
-    public Object eval(List args) {
-      Object o = args.get(0);
-      return o instanceof Literal ? ((Literal)o).getDatatype() : null;
-    }
-  }
-  
-  /**
-   * Function to test if a language code matches a pattern.
-   * This information is probably not available for this implementation.
-   */
-  static private class LangMatches extends MulgaraFunction {
-    protected int getArity() { return 2; }
-    public Object eval(List args) throws XPathFunctionException {
-      Object o = args.get(0);
-      if (o instanceof Literal) {
-        Literal l = (Literal)o;
-        if (l.getLanguage() == null || l.getLanguage().length() == 0) return false;
-        org.mulgara.query.filter.LangMatches match = new org.mulgara.query.filter.LangMatches(new SimpleLiteral(l.getLexicalForm(), l.getLanguage()), new SimpleLiteral((String)args.get(1)));
-        try {
-          return match.getValue();
-        } catch (QueryException e) {
-          throw new XPathFunctionException("Unable to get data from lang matching test: " + e.getMessage());
-        }
-      }
-      return false;
-    }
-  }
-
-  /** Common operations required for a logical operation. */
-  static private abstract class LogicOp extends MulgaraFunction {
-    protected int getArity() { return 2; }
-    protected abstract boolean op(Object left, Object right) throws XPathFunctionException;
-    public Object eval(List args) throws XPathFunctionException {
-      return op(args.get(0), args.get(1));
-    }
-  }
-
-  /** Function to perform a logical OR between 2 operands. */
-  static private class LogicalOr extends LogicOp {
-    public String getName() { return "logical-or"; }
-    public boolean op(Object left, Object right) throws XPathFunctionException {
-      return toBool(left) || toBool(right);
-    }
-  }
-
-  /** Function to perform a logical AND between 2 operands. */
-  static private class LogicalAnd extends LogicOp {
-    public String getName() { return "logical-and"; }
-    public boolean op(Object left, Object right) throws XPathFunctionException {
-      return toBool(left) && toBool(right);
-    }
-  }
-
-}

Copied: branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/SparqlFunctionGroup.java (from rev 1836, trunk/src/jar/query/java/org/mulgara/query/xpath/SparqlFunctionGroup.java)
===================================================================
--- branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/SparqlFunctionGroup.java	                        (rev 0)
+++ branches/distinct_queries/src/jar/query/java/org/mulgara/query/xpath/SparqlFunctionGroup.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -0,0 +1,181 @@
+/*
+ * Copyright 2009 DuraSpace.
+ *
+ * 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.
+ */
+
+package org.mulgara.query.xpath;
+
+import java.net.URI;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.xpath.XPathFunctionException;
+
+import org.jrdf.graph.BlankNode;
+import org.jrdf.graph.Literal;
+import org.mulgara.query.QueryException;
+import org.mulgara.query.filter.value.SimpleLiteral;
+import org.mulgara.query.functions.MulgaraFunction;
+import org.mulgara.query.functions.MulgaraFunctionGroup;
+
+/**
+ * Container for functions in the SPARQL domain.
+ *
+ * @created Oct 5, 2009
+ * @author Paul Gearon
+ * @copyright &copy; 2009 <a href="http://www.duraspace.org/">DuraSpace</a>
+ */
+ at SuppressWarnings("unchecked")
+public class SparqlFunctionGroup implements MulgaraFunctionGroup {
+
+  /** The prefix for the sparql: namespace */
+  static final String PREFIX = "sparql";
+
+  /** The sparql: namespace */
+  static final String NAMESPACE = "http://www.w3.org/2006/sparql-functions#";
+
+  /**
+   * Get the prefix used for the namespace of these operations.
+   * @return The short string used for a prefix in a QName.
+   */
+  public String getPrefix() {
+    return PREFIX;
+  }
+
+  /**
+   * Get the namespace of these operations.
+   * @return The string of the namespace URI.
+   */
+  public String getNamespace() {
+    return NAMESPACE;
+  }
+
+  /**
+   * Get the set of SPARQL functions.
+   * @return A set of MulgaraFunction for this entire group.
+   */
+  public Set<MulgaraFunction> getAllFunctions() {
+    Set<MulgaraFunction> functions = new HashSet<MulgaraFunction>();
+    functions.add(new Bound());
+    functions.add(new IsIRI());
+    functions.add(new IsURI());
+    functions.add(new IsBlank());
+    functions.add(new IsLiteral());
+    functions.add(new Str());
+    functions.add(new Lang());
+    functions.add(new Datatype());
+    functions.add(new LangMatches());
+    functions.add(new LogicalOr());
+    functions.add(new LogicalAnd());
+    return functions;
+  }
+
+  /** Function to evaluate if a parameter is bound. */
+  static private class Bound extends MulgaraFunction {
+    public Object eval(List args) { return args.get(0) != null; }
+  }
+
+  /** Function to evaluate if a parameter is an IRI. */
+  static private class IsIRI extends MulgaraFunction {
+    public Object eval(List args) { return args.get(0) instanceof URI; }
+  }
+
+  /** Function to evaluate if a parameter is a URI. */
+  static private class IsURI extends MulgaraFunction {
+    public Object eval(List args) { return args.get(0) instanceof URI; }
+  }
+
+  /** Function to evaluate if a parameter is a blank node. */
+  static private class IsBlank extends MulgaraFunction {
+    public Object eval(List args) { return args.get(0) instanceof BlankNode; }
+  }
+
+  /** Function to evaluate if a parameter is a literal. */
+  static private class IsLiteral extends MulgaraFunction {
+    public Object eval(List args) {
+      Object o = args.get(0);
+      return o instanceof Literal || o instanceof String || o instanceof Number;
+    }
+  }
+
+  /** Function to convert a value to a string. */
+  static private class Str extends MulgaraFunction {
+    public Object eval(List args) { return args.get(0).toString(); }
+  }
+
+  /** Function to get the language of a literal. This information is probably not available for this implementation. */
+  static private class Lang extends MulgaraFunction {
+    public Object eval(List args) {
+      Object o = args.get(0);
+      return o instanceof Literal ? ((Literal)o).getLanguage() : "";
+    }
+  }
+    
+  /** Function to get the datatype of a literal. This information is probably not available for this implementation. */
+  static private class Datatype extends MulgaraFunction {
+    public Object eval(List args) {
+      Object o = args.get(0);
+      return o instanceof Literal ? ((Literal)o).getDatatype() : null;
+    }
+  }
+  
+  /**
+   * Function to test if a language code matches a pattern.
+   * This information is probably not available for this implementation.
+   */
+  static private class LangMatches extends MulgaraFunction {
+    protected int getArity() { return 2; }
+    public Object eval(List args) throws XPathFunctionException {
+      Object o = args.get(0);
+      if (o instanceof Literal) {
+        Literal l = (Literal)o;
+        if (l.getLanguage() == null || l.getLanguage().length() == 0) return false;
+        org.mulgara.query.filter.LangMatches match = new org.mulgara.query.filter.LangMatches(new SimpleLiteral(l.getLexicalForm(), l.getLanguage()), new SimpleLiteral((String)args.get(1)));
+        try {
+          return match.getValue();
+        } catch (QueryException e) {
+          throw new XPathFunctionException("Unable to get data from lang matching test: " + e.getMessage());
+        }
+      }
+      return false;
+    }
+  }
+
+  /** Common operations required for a logical operation. */
+  static private abstract class LogicOp extends MulgaraFunction {
+    protected int getArity() { return 2; }
+    protected abstract boolean op(Object left, Object right) throws XPathFunctionException;
+    public Object eval(List args) throws XPathFunctionException {
+      return op(args.get(0), args.get(1));
+    }
+  }
+
+  /** Function to perform a logical OR between 2 operands. */
+  static private class LogicalOr extends LogicOp {
+    public String getName() { return "logical-or"; }
+    public boolean op(Object left, Object right) throws XPathFunctionException {
+      return toBool(left) || toBool(right);
+    }
+  }
+
+  /** Function to perform a logical AND between 2 operands. */
+  static private class LogicalAnd extends LogicOp {
+    public String getName() { return "logical-and"; }
+    public boolean op(Object left, Object right) throws XPathFunctionException {
+      return toBool(left) && toBool(right);
+    }
+  }
+
+}

Modified: branches/distinct_queries/src/jar/querylang/java/org/mulgara/itql/TqlInterpreter.java
===================================================================
--- branches/distinct_queries/src/jar/querylang/java/org/mulgara/itql/TqlInterpreter.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/querylang/java/org/mulgara/itql/TqlInterpreter.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -45,6 +45,7 @@
 import org.mulgara.query.operation.Export;
 import org.mulgara.query.operation.Help;
 import org.mulgara.query.operation.Insertion;
+import org.mulgara.query.operation.ListAlias;
 import org.mulgara.query.operation.Load;
 import org.mulgara.query.operation.Modification;
 import org.mulgara.query.operation.Quit;
@@ -520,7 +521,7 @@
 
     // Return an AST element, for reporting on what happened.
     // Use a Help command, with the alias listing as the help text.
-    lastCommand = new Help(buildAliasList());
+    lastCommand = new ListAlias(Collections.unmodifiableMap(aliasMap));
   }
 
   /**
@@ -1415,19 +1416,6 @@
 
 
   /**
-   * Writes the alias map as a set of URI/namespace pairs to a string for printing.
-   * @return A String containing all the alias mappings.
-   */
-  private String buildAliasList() {
-    StringBuilder buffer = new StringBuilder();
-    for (Map.Entry<String,URI> alias: getAliasMap().entrySet()) {
-      buffer.append(alias.getKey()).append(":  <").append(alias.getValue()).append(">\n");
-    }
-    return buffer.toString();
-  }
-
-
-  /**
    * Log the TQL command to a specified file
    *
    * @param command The TQL command to be validated

Modified: branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/AbstractStreamedAnswer.java
===================================================================
--- branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/AbstractStreamedAnswer.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/AbstractStreamedAnswer.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -21,6 +21,8 @@
 import java.io.OutputStreamWriter;
 import java.nio.charset.Charset;
 
+import org.apache.log4j.Logger;
+
 import org.jrdf.graph.BlankNode;
 import org.jrdf.graph.Literal;
 import org.jrdf.graph.URIReference;
@@ -37,6 +39,9 @@
  */
 public abstract class AbstractStreamedAnswer {
 
+  /** Logger. */
+  private final static Logger logger = Logger.getLogger(AbstractStreamedAnswer.class);
+
   /** The API {@link Answer} to convert to the stream. */
   protected final Answer answer;
 
@@ -53,7 +58,7 @@
   protected OutputStream output = null;
 
   /** The charset encoding to use when writing to the output stream. */
-  Charset charset = Charset.defaultCharset();
+  Charset charset = Charset.forName("UTF-8");
 
   /** Adds a literal to the stream */
   protected abstract void addLiteral(Literal literal) throws IOException;
@@ -99,6 +104,20 @@
   }
 
   /**
+   * Creates the object around the answer and output stream.
+   * @param answer The answer to encode.
+   * @param output The stream to write to.
+   */
+  public AbstractStreamedAnswer(Answer answer, OutputStream output, String charsetName) {
+    this(answer, output);
+    try {
+      charset = Charset.forName(charsetName);
+    } catch (Exception e) {
+      logger.error("Invalid charset. Using UTF-8: " + charsetName);
+    }
+  }
+
+  /**
    * @see org.mulgara.protocol.StreamedXMLAnswer#emit()
    */
   public void emit() throws TuplesException, IOException {

Modified: branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/AbstractStreamedXMLAnswer.java
===================================================================
--- branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/AbstractStreamedXMLAnswer.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/AbstractStreamedXMLAnswer.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -74,6 +74,14 @@
   }
 
   /**
+   * Create an XMLAnswer based on a given {@link Answer}.
+   * @param answer The Answer with the data to convert.
+   */
+  public AbstractStreamedXMLAnswer(Answer answer, OutputStream output, String charsetName) {
+    super(answer, output, charsetName);
+  }
+
+  /**
    * @see org.mulgara.protocol.StreamedXMLAnswer#setCharacterEncoding(java.lang.String)
    */
   public void setCharacterEncoding(String encoding) {

Modified: branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/StreamedN3Answer.java
===================================================================
--- branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/StreamedN3Answer.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/StreamedN3Answer.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -16,11 +16,13 @@
 
 package org.mulgara.protocol;
 
-import java.io.BufferedOutputStream;
+import java.io.OutputStreamWriter;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.PrintWriter;
+import java.nio.charset.Charset;
 
+import org.apache.log4j.Logger;
 import org.jrdf.graph.BlankNode;
 import org.jrdf.graph.Literal;
 import org.jrdf.graph.TypedNodeVisitable;
@@ -42,23 +44,44 @@
  */
 public class StreamedN3Answer implements StreamedAnswer {
 
+  /** Logger. */
+  private final static Logger logger = Logger.getLogger(StreamedN3Answer.class);
+
   /** The answer to convert to RDF/XML. */
   private final GraphAnswer ans;
 
   /** The writer to send the data to. */
   private final PrintWriter p;
 
+  /** The charset encoding to use when writing to the output stream. */
+  static final String UTF8 = "UTF-8";
+
   /**
    * Constructs the object and prepares to writing.
    * @param ans The answer to emit.
    * @param s The stream to write the answer to.
    */
   public StreamedN3Answer(Answer ans, OutputStream s) {
+    this(ans, s, UTF8);
+  }
+
+  /**
+   * Constructs the object and prepares to writing.
+   * @param ans The answer to emit.
+   * @param s The stream to write the answer to.
+   */
+  public StreamedN3Answer(Answer ans, OutputStream s, String charsetName) {
     if (!(ans instanceof GraphAnswer)) throw new IllegalArgumentException("N3 constructor can only be constructed from a GraphAnswer");
     this.ans = (GraphAnswer)ans;
     assert ans.getVariables().length == 3;
-    BufferedOutputStream out = new BufferedOutputStream(s);
-    p = new PrintWriter(out);
+    Charset charset = null;
+    try {
+      charset = Charset.forName(charsetName);
+    } catch (Exception e) {
+      logger.error("Invalid charset. Using UTF-8: " + charsetName);
+      charset = Charset.forName(UTF8);
+    }
+    p = new PrintWriter(new OutputStreamWriter(s, charset));
   }
 
   /**

Modified: branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlJSONAnswer.java
===================================================================
--- branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlJSONAnswer.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlJSONAnswer.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -49,8 +49,9 @@
   boolean prependComma = false;
 
   /**
-   * Creates an XML Answer conforming to SPARQL XML results.
+   * Creates a JSON Answer conforming to SPARQL JSON results.
    * @param answer The Answer to wrap.
+   * @param output The stream to write to.
    */
   public StreamedSparqlJSONAnswer(Answer answer, OutputStream output) {
     super((answer instanceof BooleanAnswer) ? null : answer, output);
@@ -58,9 +59,10 @@
   }
 
   /**
-   * Creates an XML Answer with additional metadata.
+   * Creates an JSON Answer with additional metadata.
    * @param answer The Answer to wrap.
    * @param metadata Additional metadata for the answer.
+   * @param output The stream to write to.
    */
   public StreamedSparqlJSONAnswer(Answer answer, URI metadata, OutputStream output) {
     this(answer, output);
@@ -68,8 +70,9 @@
   }
 
   /**
-   * Creates an XML Answer conforming to SPARQL XML results.
+   * Creates a JSON Answer conforming to SPARQL JSON results.
    * @param result The boolean result to encode.
+   * @param output The stream to write to.
    */
   public StreamedSparqlJSONAnswer(boolean result, OutputStream output) {
     super(null, output);
@@ -77,9 +80,10 @@
   }
 
   /**
-   * Creates an XML Answer with additional metadata.
+   * Creates a JSON Answer with additional metadata.
    * @param result The boolean result to encode.
    * @param metadata Additional metadata for the answer.
+   * @param output The stream to write to.
    */
   public StreamedSparqlJSONAnswer(boolean result, URI metadata, OutputStream output) {
     super(null, output);
@@ -87,6 +91,53 @@
     additionalMetadata = metadata;
   }
 
+  /**
+   * Creates a JSON Answer conforming to SPARQL JSON results.
+   * @param answer The Answer to wrap.
+   * @param output The stream to write to.
+   * @param charsetName The name of the character set to use, if not the default of UTF-8.
+   */
+  public StreamedSparqlJSONAnswer(Answer answer, OutputStream output, String charsetName) {
+    super((answer instanceof BooleanAnswer) ? null : answer, output, charsetName);
+    if (answer instanceof BooleanAnswer) booleanResult = ((BooleanAnswer)answer).getResult();
+  }
+
+  /**
+   * Creates an JSON Answer with additional metadata.
+   * @param answer The Answer to wrap.
+   * @param metadata Additional metadata for the answer.
+   * @param output The stream to write to.
+   * @param charsetName The name of the character set to use, if not the default of UTF-8.
+   */
+  public StreamedSparqlJSONAnswer(Answer answer, URI metadata, OutputStream output, String charsetName) {
+    this(answer, output, charsetName);
+    additionalMetadata = metadata;
+  }
+
+  /**
+   * Creates a JSON Answer conforming to SPARQL JSON results.
+   * @param result The boolean result to encode.
+   * @param output The stream to write to.
+   * @param charsetName The name of the character set to use, if not the default of UTF-8.
+   */
+  public StreamedSparqlJSONAnswer(boolean result, OutputStream output, String charsetName) {
+    super(null, output, charsetName);
+    booleanResult = result;
+  }
+
+  /**
+   * Creates a JSON Answer with additional metadata.
+   * @param result The boolean result to encode.
+   * @param metadata Additional metadata for the answer.
+   * @param output The stream to write to.
+   * @param charsetName The name of the character set to use, if not the default of UTF-8.
+   */
+  public StreamedSparqlJSONAnswer(boolean result, URI metadata, OutputStream output, String charsetName) {
+    super(null, output, charsetName);
+    booleanResult = result;
+    additionalMetadata = metadata;
+  }
+
   /** {@inheritDoc} */
   protected void addDocHeader() throws IOException {
     s.append("{ ");

Modified: branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlJSONObject.java
===================================================================
--- branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlJSONObject.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlJSONObject.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -19,6 +19,7 @@
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
+import java.util.Map;
 
 
 /**
@@ -61,9 +62,30 @@
     s.flush();
   }
 
+  /**
+   * Create a JSON string for a single Map object.
+   * @param o The object to convert to a JSON string.
+   * @return The JSON string representing the parameter.
+   */
+  static String jsonHash(Map<?,?> o) {
+    StringBuilder s = new StringBuilder("{ ");
+    boolean first = true;
+    for (Map.Entry<?,?> entry: o.entrySet()) {
+      if (!first) s.append(", ");
+      else first = false;
+      s.append("\"");
+      s.append(entry.getKey());
+      s.append("\": ");
+      s.append(jsonEscape(entry.getValue()));
+    }
+    s.append(" }");
+    return s.toString();
+  }
+
   /** Trivial escaping. */
-  public static String jsonEscape(Object o) {
+  static String jsonEscape(Object o) {
     if (o instanceof Number) return o.toString();
+    if (o instanceof Map<?,?>) return jsonHash((Map<?,?>)o);
     String data = o.toString();
     data = data.replace("\"", "\\\"");
     data = data.replace("\\", "\\\\");
@@ -73,6 +95,6 @@
     data = data.replace("\n", "\\n");
     data = data.replace("\r", "\\r");
     data = data.replace("\t", "\\t");
-    return data;
+    return "\"" + data + "\"";
   }
 }

Modified: branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlXMLAnswer.java
===================================================================
--- branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlXMLAnswer.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlXMLAnswer.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -102,7 +102,9 @@
 
   /** {@inheritDoc} */
   protected void addDocHeader() throws IOException {
-    s.append("<?xml version=\"1.0\"?>\n");
+    s.append("<?xml version=\"1.0\" encoding=\"");
+    s.append(charset.name());
+    s.append("\"?>\n");
     s.append("<sparql xmlns=\"http://www.w3.org/2005/sparql-results#\"");
     for (Map.Entry<String,URI> ns: namespaces.entrySet()) {
       s.append(prettyPrint ? HEADER_INDENT : " ");

Modified: branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlXMLAnswerUnitTest.java
===================================================================
--- branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlXMLAnswerUnitTest.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlXMLAnswerUnitTest.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -641,7 +641,7 @@
     return meta ? HEAD_META_INDENT + HEAD_META + "\n" : "";
   }
 
-  static final String DOC_HEAD = "<?xml version=\"1.0\"?>\n";
+  static final String DOC_HEAD = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
 
   static final String SPARQL_HEAD = "<sparql xmlns=\"http://www.w3.org/2005/sparql-results#\"";
 

Modified: branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlXMLObject.java
===================================================================
--- branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlXMLObject.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/StreamedSparqlXMLObject.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -21,6 +21,7 @@
 import java.io.OutputStreamWriter;
 import java.net.URI;
 import java.nio.charset.Charset;
+import java.util.Map;
 
 import org.mulgara.util.StringUtil;
 
@@ -75,8 +76,8 @@
   /** {@inheritDoc} */
   protected void addDocHeader() throws IOException {
     s.append("<?xml version=\"1.0\"?>\n");
-    s.append("<sparql xmlns=\"http://www.w3.org/2005/sparql-results#\"");
-    s.append(">");
+    s.append("<sparql xmlns=\"http://www.w3.org/2005/sparql-results#\">");
+    if (prettyPrint) s.append("\n");
   }
 
   /** {@inheritDoc} */
@@ -86,9 +87,14 @@
 
   /** {@inheritDoc} */
   protected void addResults() throws IOException {
-    if (prettyPrint) s.append(INDENT_STR).append("<data>");
-    if (objectData != null) s.append(StringUtil.quoteAV(objectData.toString()));
+    if (prettyPrint) s.append(INDENT_STR);
+    s.append("<data>");
+    if (objectData != null) {
+      if (objectData instanceof Map<?,?>) s.append(encodeMap((Map<?,?>)objectData, INDENT_STR));
+      else s.append(StringUtil.quoteAV(objectData.toString()));
+    }
     s.append("</data>");
+    if (prettyPrint) s.append("\n");
   }
 
 
@@ -123,4 +129,18 @@
     this.prettyPrint = prettyPrint;
   }
 
+  public String encodeMap(Map<?,?> map, String indent) {
+    String i2 = prettyPrint ? "\n" + indent + INDENT_STR : "";
+    StringBuilder s = new StringBuilder();
+    for (Map.Entry<?,?> entry: map.entrySet()) {
+      s.append(i2).append("<key>");
+      s.append(StringUtil.quoteAV(entry.getKey().toString()));
+      s.append("</key>");
+      s.append(i2).append("<value>");
+      s.append(StringUtil.quoteAV(entry.getValue().toString()));
+      s.append("</value>");
+    }
+    if (prettyPrint) s.append("\n").append(indent);
+    return s.toString();
+  }
 }

Modified: branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/http/LocalTriple.java
===================================================================
--- branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/http/LocalTriple.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/http/LocalTriple.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,13 +1,17 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 Fedora Commons, Inc.
  *
- * 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.
+ * 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.
  */
 
 package org.mulgara.protocol.http;

Modified: branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/http/MulgaraServlet.java
===================================================================
--- branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/http/MulgaraServlet.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/querylang/java/org/mulgara/protocol/http/MulgaraServlet.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2008 Fedora Commons, Inc.
+ *
+ * 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.
+ */
+
 package org.mulgara.protocol.http;
 
 import java.io.IOException;

Modified: branches/distinct_queries/src/jar/querylang/java/org/mulgara/sparql/FilterMapper.java
===================================================================
--- branches/distinct_queries/src/jar/querylang/java/org/mulgara/sparql/FilterMapper.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/querylang/java/org/mulgara/sparql/FilterMapper.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -351,7 +351,8 @@
       List<Expression> exprArgs = expr.getArgs();
       RDFTerm[] operands = new RDFTerm[exprArgs.size()];
       for (int i = 0; i < operands.length; i++) operands[i] = mapExpression(exprArgs.get(i));
-      return new ExternalFn(new IRI(expr.getName().getUri()), operands);
+      IRIReference fnName = expr.getName();
+      return new ExternalFn(new IRI(fnName.getUri(), fnName.getQName()), operands);
     }
   }
 

Modified: branches/distinct_queries/src/jar/querylang/java/org/mulgara/sparql/parser/QueryStructureImpl.java
===================================================================
--- branches/distinct_queries/src/jar/querylang/java/org/mulgara/sparql/parser/QueryStructureImpl.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/querylang/java/org/mulgara/sparql/parser/QueryStructureImpl.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -266,9 +266,9 @@
   }
 
   /**
-   * Create a new IRI based on a prefixed name.Note that this implementation
+   * Create a new IRI based on a prefixed name. Note that this implementation
    * only accepts URIs, and not the more complete IRI.
-   * @param r The string containing the image of the IRI
+   * @param r The string containing the image of the prefixed name.
    * @return A new {@link org.mulgara.sparql.parser.cst.IRIReference} for the string image.
    * @throws ParseException The r parameter was not a syntactically valid URI.
    */
@@ -277,11 +277,12 @@
     Matcher m = pnamePattern.matcher(r);
     if (!m.matches()) {
       // either a normal IRI, or one with a BASE
-      return isRelative(r) ? new IRIReference(base + r, "<" + r + ">") : new IRIReference(r);
+      return isRelative(r) ? new IRIReference(base, null, r) : new IRIReference(r, prefixes);
     }
-    // extract the prefix, and attempt to convert to a URI before creating the reference
-    URI ns = prefixes.get(m.group(1));
-    return ns == null ? new IRIReference(r) : new IRIReference(ns.toString() + m.group(2), r);
+    String prefix = m.group(1);
+    String localPart = m.group(2);
+    URI namespace = prefixes.get(prefix);
+    return namespace == null ? new IRIReference(r, prefixes) : new IRIReference(namespace, prefix, localPart);
   }
 
   /**

Modified: branches/distinct_queries/src/jar/querylang/java/org/mulgara/sparql/parser/cst/IRIReference.java
===================================================================
--- branches/distinct_queries/src/jar/querylang/java/org/mulgara/sparql/parser/cst/IRIReference.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/querylang/java/org/mulgara/sparql/parser/cst/IRIReference.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -16,9 +16,14 @@
 
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
 
+import org.mulgara.query.rdf.Mulgara;
 import org.mulgara.sparql.parser.ParseException;
 
+import javax.xml.namespace.QName;
 
 /**
  * Represents IRI references in SPARQL. This is a superset of URI references.
@@ -47,12 +52,38 @@
   /** Constant IRI for RDF_NIL */
   public static final IRIReference RDF_NIL = new IRIReference(URI.create(RDF_NS + "nil"));
 
+  /** The made-up namespace for op: XPath functions */
+  public static final String OP_NS = "op";
+
+  /** The "op" prefix for XPath functions */
+  public static final String OP_PREFIX = OP_NS + ":";
+
+  /** The prefix for the sparql: namespace */
+  static final String SPARQL_PREFIX = "sparql";
+
+  /** The sparql: namespace */
+  static final URI SPARQL_NS;
+
+  /** The prefix for the fn: namespace */
+  static final String FN_PREFIX = "fn";
+
+  /** The fn: namespace */
+  static final URI FN_NS;
+
   /** The internal URI value */
   private URI uri;
 
   /** The original text of the URI */
   private String text;
 
+  /** The qname form, if available */
+  private QName qname;
+
+  static {
+    SPARQL_NS = URI.create("http://www.w3.org/2006/sparql-functions#");
+    FN_NS = URI.create("http://www.w3.org/2005/xpath-functions/#");
+  }
+
   /**
    * Create an IRI reference from a URI.
    * @param uri The URI referred to.
@@ -60,13 +91,26 @@
   public IRIReference(URI uri) {
     this.uri = uri;
     text = "<" + uri.toString() + ">";
+    qname = parseQName(uri.toString());
   }
 
   /**
    * Create an IRI reference from a URI.
    * @param uri The URI referred to.
+   * @param namespaces The environment's map of prefix to namespace URIs.
    */
-  public IRIReference(String uri) throws ParseException {
+  public IRIReference(URI uri, Map<String,URI> namespaces) {
+    this.uri = uri;
+    text = "<" + uri.toString() + ">";
+    qname = parseQName(uri.toString(), namespaces);
+  }
+
+  /**
+   * Create an IRI reference from a URI.
+   * @param uri The URI referred to.
+   * @param namespaces The environment's map of prefix to namespace URIs.
+   */
+  public IRIReference(String uri, Map<String,URI> namespaces) throws ParseException {
     try {
       this.uri = new URI(uri);
     } catch (URISyntaxException e) {
@@ -75,16 +119,27 @@
       this.uri = URI.create("#");
     }
     text = "<" + uri + ">";
+    qname = parseQName(uri.toString(), namespaces);
   }
 
   /**
-   * Create an IRI reference from a URI with an abbreviated namespace.
+   * Create an IRI reference from a URI with an abbreviated namespace, with a known namespace.
    * @param uri The URI referred to.
    * @param text The abbreviated form.
    */
-  public IRIReference(String uri, String text) throws ParseException {
-    this(uri);
-    this.text = text;
+  public IRIReference(URI namespace, String prefix, String localPart) throws ParseException {
+    try {
+      this.uri = new URI(namespace + localPart);
+    } catch (URISyntaxException e) {
+      throw new ParseException("Unable to create URI: " + namespace + localPart);
+    }
+    if (prefix == null) {
+      text = "<:" + localPart + ">";
+      qname = new QName(namespace.toString(), localPart);
+    } else {
+      text = prefix + ":" + localPart;
+      qname = new QName(namespace.toString(), localPart, prefix);
+    }
   }
 
   /**
@@ -100,5 +155,100 @@
   public String getImage() {
     return text;
   }
-  
+
+  /**
+   * Retrieves the qname for this URI, if one is known.
+   * @return The known QName, or <code>null</code> if none available.
+   */
+  public QName getQName() {
+    return qname;
+  }
+
+  /**
+   * Parse a URI, looking for a valid QName structure.
+   * @param uri The URI to parse.
+   * @return a new QName if one could be parsed, or <code>null</code> if one couldn't be found.
+   * @param namespaces The environment's map of prefix to namespace URIs.
+   */
+  private QName parseQName(String uri) {
+    Map<String,URI> e = Collections.emptyMap();
+    return parseQName(uri, e);
+  }
+
+  /**
+   * Parse a URI, looking for a valid QName structure.
+   * @param uri The URI to parse.
+   * @return a new QName if one could be parsed, or <code>null</code> if one couldn't be found.
+   * @param namespaces The environment's map of prefix to namespace URIs.
+   */
+  private QName parseQName(String uri, Map<String,URI> namespaces) {
+    // the "op" prefix is special, in that it has no namespace
+    // check if the URI starts with "op:" and is followed by a valid local name character
+    if (uri.startsWith(OP_PREFIX) && localStartNameChar(uri.charAt(OP_PREFIX.length()))) {
+      return new QName(OP_NS, uri.substring(OP_PREFIX.length()), OP_PREFIX);
+    }
+
+    // expand the namespaces to include some defaults, if missing
+    namespaces = expandedNamespaces(namespaces);
+
+    // search for a namespace we know about
+    for (Map.Entry<String,URI> e: namespaces.entrySet()) {
+      String namespaceUri = e.getValue().toString();
+      if (uri.startsWith(namespaceUri)) {
+        return new QName(namespaceUri, uri.substring(namespaceUri.length()), e.getKey());
+      }
+    }
+
+    return null;
+  }
+
+  /**
+   * Expand on a namespace map to include some useful defaults.
+   * @param original The original namespace map of prefixes to namespace URIs.
+   * @return A new namespace map with the added entries.
+   */
+  private static Map<String,URI> expandedNamespaces(Map<String,URI> original) {
+    Map<String,URI> result = new HashMap<String,URI>(original);
+    if (!result.containsKey(SPARQL_PREFIX)) result.put(SPARQL_PREFIX, URI.create("http://www.w3.org/2006/sparql-functions#"));
+    if (!result.containsKey(FN_PREFIX)) result.put(FN_PREFIX, URI.create("http://www.w3.org/2005/xpath-functions/#"));
+    if (!result.containsKey(Mulgara.NS_PREFIX)) result.put(Mulgara.NS_PREFIX, Mulgara.NS_URI);
+    return result;
+  }
+
+  /**
+   * Indicates if the char is a valid XML name character, minus the colon character.
+   * @see http://www.w3.org/TR/REC-xml/#NT-NameStartChar
+   * @param c The character to test.
+   * @return <code>true</code> if the character is a valid start to an XML name.
+   */
+  @SuppressWarnings("unused")
+  private static final boolean localNameChar(char c) {
+    return localStartNameChar(c) ||
+           c == '-' || c == '.' || (c >= '0' && c <= '9') ||
+           c == 0xB7 || (c >= 0x0300 && c <= 0x036F) || (c >= 0x203F && c <= 0x2040);
+  }
+
+  /**
+   * Indicates if the char is a valid start for an XML name character, minus the colon character.
+   * @see http://www.w3.org/TR/REC-xml/#NT-NameStartChar
+   * @param c The character to test.
+   * @return <code>true</code> if the character is a valid start to an XML name.
+   */
+  private static final boolean localStartNameChar(char c) {
+    return (c >= 'A' && c <= 'Z') ||
+           (c >= 'a' && c <= 'z') ||
+           c == '_' ||
+           (c >= 0xC0 && c <= 0xD6) ||
+           (c >= 0xD8 && c <= 0xF6) ||
+           (c >= 0xF8 && c <= 0x2FF) ||
+           (c >= 0x370 && c <= 0x37D) ||
+           (c >= 0x37F && c <= 0x1FFF) ||
+           (c >= 0x200C && c <= 0x200D) ||
+           (c >= 0x2070 && c <= 0x218F) ||
+           (c >= 0x2C00 && c <= 0x2FEF) ||
+           (c >= 0x3001 && c <= 0xD7FF) ||
+           (c >= 0xF900 && c <= 0xFDCF) ||
+           (c >= 0xFDF0 && c <= 0xFFFD) ||
+           (c >= 0x10000 && c <= 0xEFFFF);
+  }
 }

Modified: branches/distinct_queries/src/jar/querylang/javacc/org/mulgara/sparql/parser/SparqlParser.java
===================================================================
--- branches/distinct_queries/src/jar/querylang/javacc/org/mulgara/sparql/parser/SparqlParser.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/querylang/javacc/org/mulgara/sparql/parser/SparqlParser.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -448,7 +448,7 @@
         break;
       case 43:
         jj_consume_token(43);
-                       asc = false;
+                         asc = false;
         break;
       default:
         jj_la1[22] = jj_gen;
@@ -501,13 +501,13 @@
         jj_consume_token(-1);
         throw new ParseException();
       }
-    queryStructure.addOrdering(e, asc);
       break;
     default:
       jj_la1[24] = jj_gen;
       jj_consume_token(-1);
       throw new ParseException();
     }
+    queryStructure.addOrdering(e, asc);
   }
 
 /* [18]    LimitClause    ::=    'LIMIT' INTEGER */
@@ -1940,15 +1940,15 @@
     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
     case INTEGER_POSITIVE:
       t = jj_consume_token(INTEGER_POSITIVE);
-                           {if (true) return new IntegerLiteral(t.image);}
+                           {if (true) return new IntegerLiteral(t.image.substring(1));}
       break;
     case DECIMAL_POSITIVE:
       t = jj_consume_token(DECIMAL_POSITIVE);
-                             {if (true) return new DecimalLiteral(t.image);}
+                             {if (true) return new DecimalLiteral(t.image.substring(1));}
       break;
     case DOUBLE_POSITIVE:
       t = jj_consume_token(DOUBLE_POSITIVE);
-                            {if (true) return new DoubleLiteral(t.image);}
+                            {if (true) return new DoubleLiteral(t.image.substring(1));}
       break;
     default:
       jj_la1[70] = jj_gen;

Modified: branches/distinct_queries/src/jar/resolver/java/org/mulgara/resolver/ContentFactory.java
===================================================================
--- branches/distinct_queries/src/jar/resolver/java/org/mulgara/resolver/ContentFactory.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/resolver/java/org/mulgara/resolver/ContentFactory.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -56,16 +56,18 @@
 public class ContentFactory
 {
   /** Logger.  */
+  @SuppressWarnings("unused")
   private static final Logger logger =
     Logger.getLogger(ContentFactory.class.getName());
 
 
-  private static Map contentClasses = new HashMap();
-  private static Map contentConstructors = new HashMap();
+  private static Map<String,String> contentClasses = new HashMap<String,String>();
+  private static Map<String,Constructor> contentConstructors = new HashMap<String,Constructor>();
 
   static {
     contentClasses.put("file", "org.mulgara.resolver.file.FileContent");
     contentClasses.put("http", "org.mulgara.resolver.http.HttpContent");
+    contentClasses.put("https", "org.mulgara.resolver.http.HttpContent");
     contentClasses.put("jar", "org.mulgara.resolver.jar.JarContent");
   }
 
@@ -81,11 +83,10 @@
       throw new IllegalArgumentException("Source URI is null");
     }
 
-    Content content;
     try {
       // Determine the source type
       String scheme = srcURI.getScheme().toLowerCase();
-      Constructor constructor = (Constructor)contentConstructors.get(scheme);
+      Constructor constructor = contentConstructors.get(scheme);
       if (constructor == null) {
         constructor = loadConstructor(scheme);
       }
@@ -99,12 +100,12 @@
   }
   
   private static Constructor loadConstructor(String scheme) throws ContentHandlerException, ClassNotFoundException, NoSuchMethodException {
-    String className = (String)contentClasses.get(scheme);
+    String className = contentClasses.get(scheme);
     if (className == null) {
       throw new ContentHandlerException("No Content wrapper available for " + scheme);
     }
 
-    Class klass = Class.forName(className);
+    Class<?> klass = Class.forName(className);
     Constructor constructor = klass.getConstructor(new Class[] { URI.class });
 
     contentConstructors.put(scheme, constructor);

Modified: branches/distinct_queries/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java
===================================================================
--- branches/distinct_queries/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -714,7 +714,11 @@
             logger.debug("Appending " + resolver);
           }
           Tuples oldTuples = tuples;
-          tuples = TuplesOperations.append(tuples, resolution);
+          try {
+            tuples = TuplesOperations.append(tuples, resolution);
+          } finally {
+            resolution.close();
+          }
           oldTuples.close();
         }
       } catch (TuplesException e) {

Modified: branches/distinct_queries/src/jar/resolver/java/org/mulgara/resolver/ExportOperation.java
===================================================================
--- branches/distinct_queries/src/jar/resolver/java/org/mulgara/resolver/ExportOperation.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/resolver/java/org/mulgara/resolver/ExportOperation.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,13 +1,17 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 Revelytix.
  *
- * 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.
+ * 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.
  */
 package org.mulgara.resolver;
 

Modified: branches/distinct_queries/src/jar/resolver/java/org/mulgara/resolver/ModifyGraphOperation.java
===================================================================
--- branches/distinct_queries/src/jar/resolver/java/org/mulgara/resolver/ModifyGraphOperation.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/resolver/java/org/mulgara/resolver/ModifyGraphOperation.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -141,9 +141,9 @@
     if (query == null) {
       throw new IllegalArgumentException("Null \"query\" parameter");
     }
-    if (query.getVariableList().size() != 3) {
+    if (!(query.getVariableList().size() == 3 || query instanceof ConstructQuery)) {
       throw new QueryException(
-          "Invalid select clause in insert/select.  Exactly 3 terms required");
+          "Invalid select clause in insert/select.  Exactly 3 terms (or ConstructQuery) required");
     }
 
     // Validate "databaseSession" parameter

Modified: branches/distinct_queries/src/jar/resolver/java/org/mulgara/resolver/OutputOperation.java
===================================================================
--- branches/distinct_queries/src/jar/resolver/java/org/mulgara/resolver/OutputOperation.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/resolver/java/org/mulgara/resolver/OutputOperation.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,13 +1,17 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 Revelytix.
  *
- * 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.
+ * 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.
  */
 package org.mulgara.resolver;
 

Modified: branches/distinct_queries/src/jar/resolver/java/org/mulgara/resolver/StringPoolSession.java
===================================================================
--- branches/distinct_queries/src/jar/resolver/java/org/mulgara/resolver/StringPoolSession.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/resolver/java/org/mulgara/resolver/StringPoolSession.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -103,6 +103,15 @@
   /** The name of the graph parameter in a URI */
   static final String GRAPH = "graph";
 
+  /** The system URI scheme */
+  static final String RMI_SCHEME = "rmi";
+
+  /** The relative name of the system graph */
+  static final String SYSTEM_GRAPH_NAME = "#";
+
+  /** The relative URI for the system graph */
+  static final URI SYSTEM_GRAPH_URI = URI.create(SYSTEM_GRAPH_NAME);
+
   /** The unique {@link URI} naming this database. */
   private final URI databaseURI;
 
@@ -663,7 +672,8 @@
       String scheme = uri.getScheme();
       String fragment = uri.getFragment();
 
-      if (scheme != null && scheme.equals(databaseURI.getScheme())) {
+      // we're only going to fiddle with this if the database scheme is RMI
+      if (scheme != null && scheme.equals(databaseURI.getScheme()) && scheme.equals(RMI_SCHEME)) {
         if (databaseURI.isOpaque()) {
           // databaseURI is opaque.
           if (fragment != null && uri.isOpaque()) {
@@ -742,6 +752,12 @@
             }
           }
         }
+      } else if (scheme != null && scheme.equals(databaseURI.getScheme())) {
+        // not RMI, but we still want to catch the system graph
+        if (uri.toString().equals(databaseURI.toString() + SYSTEM_GRAPH_NAME)) {
+          SPObjectFactory spObjectFactory = persistentStringPool.getSPObjectFactory();
+          spObject = spObjectFactory.newSPURI(SYSTEM_GRAPH_URI);
+        }
       }
     }
     return spObject;

Modified: branches/distinct_queries/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndexException.java
===================================================================
--- branches/distinct_queries/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndexException.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndexException.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -50,29 +50,29 @@
  */
 public class FullTextStringIndexException extends Exception {
 
+  /** Generated serialization ID */
+  private static final long serialVersionUID = 787298465503301231L;
+
   /**
-   * CONSTRUCTOR FullTextStringIndexException TO DO
-   *
-   * @param message PARAMETER TO DO
+   * Create a new exception for the full text string index.
+   * @param message The error message
    */
   public FullTextStringIndexException(String message) {
     super(message);
   }
 
   /**
-   * CONSTRUCTOR FullTextStringIndexException TO DO
-   *
-   * @param message PARAMETER TO DO
-   * @param cause PARAMETER TO DO
+   * Create a new exception with chaining for the full text string index.
+   * @param message The eror message
+   * @param cause The exception to be chained
    */
   public FullTextStringIndexException(String message, Throwable cause) {
     super(message, cause);
   }
 
   /**
-   * CONSTRUCTOR FullTextStringIndexException TO DO
-   *
-   * @param cause PARAMETER TO DO
+   * Create a new exception with chaining for the full text string index.
+   * @param cause The exception to be chained
    */
   public FullTextStringIndexException(Throwable cause) {
     super(cause);

Modified: branches/distinct_queries/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndexUnitTest.java
===================================================================
--- branches/distinct_queries/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndexUnitTest.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/FullTextStringIndexUnitTest.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -71,10 +71,6 @@
   private final static String indexDirectory =
       TempDir.getTempDir().getPath() + File.separator + "fulltextsp";
 
-  /** Directory for the indexes * */
-  private final static String indexDirectory2 =
-      TempDir.getTempDir().getPath() + File.separator + "fulltextsp2";
-
   /** The directory containing the text documents */
   private final static String textDirectory =
       System.getProperty("cvs.root") + File.separator + "data" + File.separator +

Modified: branches/distinct_queries/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneConstraint.java
===================================================================
--- branches/distinct_queries/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneConstraint.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneConstraint.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -44,9 +44,6 @@
   private static final Logger logger = Logger.getLogger(LuceneConstraint.class);
   private static final long serialVersionUID = 1L;
 
-  private final URIReference searchPred;
-  private final URIReference scorePred;
-
   private ConstraintElement model;
   private ConstraintElement subject;
   private ConstraintElement predicate;
@@ -58,8 +55,6 @@
    * Empty constructor. Used internally during constraint rewriting.
    */
   private LuceneConstraint() {
-    searchPred = null;
-    scorePred = null;
   }
 
   /**
@@ -86,8 +81,6 @@
    */
   LuceneConstraint(Constraint constraint, URIReference searchPred, URIReference scorePred)
       throws SymbolicTransformationException {
-    this.searchPred = searchPred;
-    this.scorePred = scorePred;
 
     // extract model
     model = constraint.getModel();

Modified: branches/distinct_queries/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneIndexerCache.java
===================================================================
--- branches/distinct_queries/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneIndexerCache.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneIndexerCache.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -320,6 +320,9 @@
   }
 
   private static class Stack<T> extends ArrayList<T> {
+    /** Serialization ID */
+    private static final long serialVersionUID = -8597253123267228667L;
+
     public void push(T obj) {
       add(obj);
     }

Modified: branches/distinct_queries/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolver.java
===================================================================
--- branches/distinct_queries/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolver.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolver.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -71,6 +71,7 @@
 import org.mulgara.resolver.spi.ResolverException;
 import org.mulgara.resolver.spi.ResolverSession;
 import org.mulgara.resolver.spi.Statements;
+import org.mulgara.util.StackTrace;
 import org.mulgara.util.conversion.html.HtmlToTextConverter;
 
 /**
@@ -263,7 +264,7 @@
           } catch (org.mulgara.util.conversion.html.ParseException e) {
             throw new ResolverException("Couldn't parse content of " + resource, e);
           } catch (FullTextStringIndexException e) {
-            throw new ResolverException("Unable to modify full text index", e);
+            throw new ResolverException("Unable to modify full text index\n" + new StackTrace(e));
           }
         } else if (objectNode instanceof Literal) {
           Literal objectLiteral = (Literal) objectNode;
@@ -292,7 +293,7 @@
             }
           } catch (FullTextStringIndexException e) {
             throw new ResolverException("Unable to " + (occurs ? "add" : "delete") + "'" +
-                                        literal + "' to full text string index", e);
+                                        literal + "' to full text string index\n" + new StackTrace(e));
           }
         } else {
           if (logger.isInfoEnabled()) {
@@ -307,7 +308,7 @@
     } catch (IOException ioe) {
       throw new ResolverException("Failed to open string index", ioe);
     } catch (FullTextStringIndexException ef) {
-      throw new ResolverException("Error in string index", ef);
+      throw new ResolverException("Error in string index\n" + new StackTrace(ef));
     }
   }
 
@@ -324,7 +325,7 @@
     } catch (IOException ioe) {
       throw new ResolverException("Failed to open string index", ioe);
     } catch (FullTextStringIndexException ef) {
-      throw new ResolverException("Query failed against string index", ef);
+      throw new ResolverException("Query failed against string index\n" + new StackTrace(ef));
     }
   }
 
@@ -361,7 +362,7 @@
     } catch (IOException ioe) {
       throw new QueryException("Failed to open string index", ioe);
     } catch (FullTextStringIndexException ef) {
-      throw new QueryException("Query failed against string index", ef);
+      throw new QueryException("Query failed against string index\n" + new StackTrace(ef));
     } catch (TuplesException te) {
       throw new QueryException("Failed to query string index", te);
     }

Modified: branches/distinct_queries/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolverUnitTest.java
===================================================================
--- branches/distinct_queries/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolverUnitTest.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/resolver-lucene/java/org/mulgara/resolver/lucene/LuceneResolverUnitTest.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -145,7 +145,6 @@
                    null,                            // no dir for temp strings
                    tempResolverFactoryClassName,    // temporary models
                    null,                            // no dir for temp models
-                   "",                              // no rule loader
                    "org.mulgara.content.rdfxml.RDFXMLContentHandler");
 
       database.addContentHandler("org.mulgara.content.n3.N3ContentHandler");

Modified: branches/distinct_queries/src/jar/resolver-prefix/java/org/mulgara/resolver/prefix/PrefixResolver.java
===================================================================
--- branches/distinct_queries/src/jar/resolver-prefix/java/org/mulgara/resolver/prefix/PrefixResolver.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/resolver-prefix/java/org/mulgara/resolver/prefix/PrefixResolver.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -18,6 +18,7 @@
 
 // Java 2 standard packages
 import java.net.*;
+
 import javax.transaction.xa.XAResource;
 
 // Third party packages
@@ -29,7 +30,6 @@
 import org.mulgara.resolver.spi.*;
 import org.mulgara.store.stringpool.SPObject;
 import org.mulgara.store.stringpool.SPObjectFactory;
-import org.mulgara.store.stringpool.SPURI;
 import org.mulgara.store.stringpool.StringPoolException;
 import org.mulgara.store.stringpool.xa.SPObjectFactoryImpl;
 import org.mulgara.store.tuples.Tuples;
@@ -56,8 +56,11 @@
   private URI modelTypeURI;
 
   /** The preallocated local node representing the mulgara:prefix property. */
-  private long mulgaraPrefix;
+  private final long mulgaraPrefix;
 
+  /** The preallocated local node representing the mulgara:stringPrefix property. */
+  private final long mulgaraStringPrefix;
+
   //
   // Constructors
   //
@@ -74,6 +77,7 @@
       ResolverSession resolverSession,
       Resolver systemResolver,
       long mulgaraPrefix,
+      long mulgaraStringPrefix,
       URI modelTypeURI
   ) throws ResolverFactoryException {
 
@@ -90,6 +94,7 @@
     this.resolverSession = resolverSession;
     this.modelTypeURI = modelTypeURI;
     this.mulgaraPrefix = mulgaraPrefix;
+    this.mulgaraStringPrefix = mulgaraStringPrefix;
   }
 
   //
@@ -144,9 +149,7 @@
    * @throws ResolverException if the <var>statements</var> can't be
    *   added to the <var>model</var>
    */
-  public void modifyModel(long model, Statements statements, boolean occurs)
-    throws ResolverException
-  {
+  public void modifyModel(long model, Statements statements, boolean occurs) throws ResolverException {
     if (logger.isDebugEnabled()) {
       logger.debug("Modify prefix model " + model);
     }
@@ -158,8 +161,7 @@
   /**
    * Remove the cached model containing the contents of a URL.
    */
-  public void removeModel(long model) throws ResolverException
-  {
+  public void removeModel(long model) throws ResolverException {
     if (logger.isDebugEnabled()) {
       logger.debug("Remove prefix model " + model);
     }
@@ -170,8 +172,7 @@
    *
    * Resolution is by filtration of a URL stream, and thus very slow.
    */
-  public Resolution resolve(Constraint constraint) throws QueryException
-  {
+  public Resolution resolve(Constraint constraint) throws QueryException {
     if (logger.isDebugEnabled()) {
       logger.debug("Resolve " + constraint);
     }
@@ -200,33 +201,15 @@
       Node prefixNode = resolverSession.globalize(object.getValue());
 
       // check the constraint for consistency
-      if (property != mulgaraPrefix || !(prefixNode instanceof Literal || prefixNode instanceof URIReference)) {
-        logger.error("property = " + property +", mulgaraPrefix = " + mulgaraPrefix);
-        logger.error("element(2): " + prefixNode + " [" + prefixNode.getClass().getName() + "]");
+      if ((property != mulgaraPrefix && property != mulgaraStringPrefix) || !(prefixNode instanceof Literal || prefixNode instanceof URIReference)) {
+        logger.debug("property = " + property +", mulgaraPrefix = " + mulgaraPrefix);
+        logger.debug("element(2): " + prefixNode + " [" + prefixNode.getClass().getName() + "]");
         throw new QueryException("Prefix resolver can only be used for prefix constraints: " + constraint);
       }
 
-      String prefix;
-      // extract the string from the literal
-      if (prefixNode instanceof Literal) {
-        prefix = ((Literal)prefixNode).getLexicalForm();
-      } else {
-        prefix = ((URIReference)prefixNode).getURI().toString();
-      }
-
       if (logger.isDebugEnabled()) {
-        logger.debug("Evaluating " + constraint.getElement(0) +
-            " has prefix " +
-            constraint.getElement(2));
+        logger.debug("Evaluating " + constraint.getElement(0) + " has prefix " + constraint.getElement(2));
       }
-      URI startPrefixUri;
-      URI endPrefixUri;
-      try {
-        startPrefixUri = new URI(prefix);
-        endPrefixUri = new URI(prefix + Character.MAX_VALUE);
-      } catch (URISyntaxException e) {
-        throw new QueryException("Prefix resolver can only be used for URI prefixes: " + e.getMessage());
-      }
 
       ConstraintElement node = constraint.getElement(0);
       assert node != null;
@@ -237,8 +220,8 @@
 
         // convert the prefix into a string pool object
         SPObjectFactory spoFact = SPObjectFactoryImpl.getInstance();
-        SPURI startPrefixObj = spoFact.newSPURI(startPrefixUri);
-        SPURI endPrefixObj = spoFact.newSPURI(endPrefixUri);
+        SPObject startPrefixObj = getStartObject(spoFact, prefixNode, property);
+        SPObject endPrefixObj = getEndObject(spoFact, prefixNode, property);
 
         // get the extents of the prefix from the string pool
         tuples = resolverSession.findStringPoolRange(startPrefixObj, true, endPrefixObj, false);
@@ -281,6 +264,14 @@
         } else {
 
           // see if the node starts with the required prefix
+
+          String prefix;
+          // extract the string from the literal
+          if (prefixNode instanceof Literal) {
+            prefix = ((Literal) prefixNode).getLexicalForm();
+          } else {
+            prefix = ((URIReference) prefixNode).getURI().toString();
+          }
           if (spo.getLexicalForm().startsWith(prefix)) {
             tuples = TuplesOperations.unconstrained();
           } else {
@@ -302,8 +293,57 @@
 
   }
 
+  /**
+   * Create a string pool object to represent the beginning of a search range.
+   * @param factory The string pool factory that will create the object
+   * @param prefixNode The data for the object.
+   * @param predType Predicate to indicate the type of data to get from the string pool.
+   * @return An object representing the start of a range of data to get from the string pool.
+   * @throws QueryException If the predicate indicates a URI but the prefix data is not a valid URI.
+   */
+  private SPObject getStartObject(SPObjectFactory factory, Node prefixNode, long predType) throws QueryException {
+    if (prefixNode instanceof Literal) {
+      String prefix = ((Literal) prefixNode).getLexicalForm();
+      if (predType == mulgaraPrefix) {
+        try {
+          return factory.newSPURI(new URI(prefix));
+        } catch (URISyntaxException e) {
+          throw new QueryException("Bad URI prefix provided: " + prefix + " (should this be using mulgara:stringPrefix?)");
+        }
+      } else return factory.newSPString(prefix);
+    } else {
+      URI startPrefixUri = ((URIReference) prefixNode).getURI();
+      if (predType == mulgaraPrefix) return factory.newSPURI(startPrefixUri);
+      else return factory.newSPString(startPrefixUri.toString());
+    }
+  }
 
   /**
+   * Create a string pool object to represent the end of a search range.
+   * @param factory The string pool factory that will create the object
+   * @param prefixNode The data for the object.
+   * @param predType Predicate to indicate the type of data to get from the string pool.
+   * @return An object representing the end of a range of data to get from the string pool.
+   * @throws QueryException If the predicate indicates a URI but the prefix data is not a valid URI.
+   */
+  private SPObject getEndObject(SPObjectFactory factory, Node prefixNode, long predType) throws QueryException {
+    String prefix;
+    if (prefixNode instanceof Literal) {
+      prefix = ((Literal) prefixNode).getLexicalForm();
+    } else {
+      prefix = ((URIReference) prefixNode).getURI().toString();
+    }
+
+    if (predType == mulgaraPrefix) {
+      try {
+        return factory.newSPURI(new URI(prefix + Character.MAX_VALUE));
+      } catch (URISyntaxException e) {
+        throw new QueryException("Bad URI prefix provided: " + prefix + " (should this be using mulgara:stringPrefix?)");
+      }
+    } else return factory.newSPString(prefix + Character.MAX_VALUE);
+  }
+
+  /**
    * Close all sessions and factories used by this resolver.
    */
   public void close() {

Modified: branches/distinct_queries/src/jar/resolver-prefix/java/org/mulgara/resolver/prefix/PrefixResolverFactory.java
===================================================================
--- branches/distinct_queries/src/jar/resolver-prefix/java/org/mulgara/resolver/prefix/PrefixResolverFactory.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/resolver-prefix/java/org/mulgara/resolver/prefix/PrefixResolverFactory.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -42,8 +42,11 @@
   private static final URI DEFAULT_GRAPH = URI.create(Mulgara.PREFIX_GRAPH);
 
   /** The preallocated local node representing the prefix predicate. */
-  private long mulgaraPrefix;
+  private final long mulgaraPrefix;
 
+  /** The preallocated local node representing the string prefix predicate. */
+  private final long mulgaraStringPrefix;
+
   //
   // Constructors
   //
@@ -61,6 +64,7 @@
 
     // intialize the fields
     mulgaraPrefix = initializer.preallocate(new URIReferenceImpl(Mulgara.PREFIX_URI));
+    mulgaraStringPrefix = initializer.preallocate(new URIReferenceImpl(Mulgara.STR_PREFIX_URI));
 
     // no need to claim the types supported by this resolver, as this is detected in the default graphs
   }
@@ -110,7 +114,7 @@
       boolean canWrite, ResolverSession resolverSession, Resolver systemResolver
   ) throws ResolverFactoryException {
     if (logger.isDebugEnabled()) logger.debug("Creating new Prefix resolver");
-    return new PrefixResolver(resolverSession, systemResolver, mulgaraPrefix, Mulgara.PREFIX_GRAPH_TYPE_URI);
+    return new PrefixResolver(resolverSession, systemResolver, mulgaraPrefix, mulgaraStringPrefix, Mulgara.PREFIX_GRAPH_TYPE_URI);
   }
 
   /**

Modified: branches/distinct_queries/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ResolverException.java
===================================================================
--- branches/distinct_queries/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ResolverException.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ResolverException.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -40,13 +40,14 @@
  * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
  */
 
-public class ResolverException extends Exception
-{
+public class ResolverException extends Exception {
+  /** Serialization ID */
+  private static final long serialVersionUID = -2032778680010965039L;
+
   /**
    * @param message  diagnostic text
    */
-  public ResolverException(String message)
-  {
+  public ResolverException(String message) {
     super(message);
   }
 
@@ -54,8 +55,7 @@
    * @param message  diagnostic text
    * @param cause  an exception to be chained as the reason for this one
    */
-  public ResolverException(String message, Throwable cause)
-  {
+  public ResolverException(String message, Throwable cause) {
     super(message, cause);
   }
 }

Modified: branches/distinct_queries/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleAVLFile.java
===================================================================
--- branches/distinct_queries/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleAVLFile.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleAVLFile.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -44,7 +44,6 @@
 import org.mulgara.store.tuples.*;
 import org.mulgara.store.xa.*;
 import org.mulgara.util.Constants;
-import org.mulgara.util.StackTrace;
 
 /**
  * @created 2001-10-13
@@ -1698,7 +1697,6 @@
     private abstract class AbstractStoreTuples implements StoreTuples {
 
       // keep a stack trace of the instantiation of this object
-      protected StackTrace stack = logger.isDebugEnabled() ? new StackTrace() : null;
       protected List<Integer> objectIds = new ArrayList<Integer>();
 
       private long[] startTriple;
@@ -2095,7 +2093,6 @@
 
           copy.variables = getVariables();
 
-          copy.stack = logger.isDebugEnabled() ? new StackTrace() : null;
           copy.objectIds = new ArrayList<Integer>(objectIds);
           copy.objectIds.add(new Integer(System.identityHashCode(this)));
 
@@ -2124,7 +2121,6 @@
           if (end.node != null) end.node.release();
           end = null;
         }
-        stack = null;
       }
 
 

Modified: branches/distinct_queries/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleAVLFileUnitTest.java
===================================================================
--- branches/distinct_queries/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleAVLFileUnitTest.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleAVLFileUnitTest.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -27,17 +27,12 @@
 package org.mulgara.store.statement.xa;
 
 import java.io.*;
-import java.nio.*;
 
-// Java 2 standard packages
-import java.util.*;
-
 // Third party packages
 import junit.framework.*;
 import org.apache.log4j.Logger;
 
 // Locally written packages
-import org.mulgara.store.*;
 import org.mulgara.store.tuples.Tuples;
 import org.mulgara.store.xa.Block;
 import org.mulgara.util.Constants;
@@ -66,9 +61,8 @@
  */
 public class TripleAVLFileUnitTest extends TestCase {
 
-  /**
-   * Logger.
-   */
+  /** Logger. */
+  @SuppressWarnings("unused")
   private final static Logger logger = Logger.getLogger(TripleAVLFileUnitTest.class);
 
   /**

Modified: branches/distinct_queries/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleWriteThread.java
===================================================================
--- branches/distinct_queries/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleWriteThread.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleWriteThread.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -33,8 +33,6 @@
 // Third party packages
 import org.apache.log4j.Logger;
 
-// Locally written packages
-import org.mulgara.store.statement.*;
 
 final class TripleWriteThread extends Thread {
 
@@ -57,7 +55,7 @@
   private int index = 0;
 
   /** The queue of triples to add to the TripleAVLFile. */
-  private LinkedList queue = new LinkedList();
+  private LinkedList<long[][]> queue = new LinkedList<long[][]>();
 
   private boolean threadRunning = true;
 

Modified: branches/distinct_queries/src/jar/resolver-store/java/org/mulgara/store/statement/xa/XAStatementStoreImplUnitTest.java
===================================================================
--- branches/distinct_queries/src/jar/resolver-store/java/org/mulgara/store/statement/xa/XAStatementStoreImplUnitTest.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/resolver-store/java/org/mulgara/store/statement/xa/XAStatementStoreImplUnitTest.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -67,9 +67,8 @@
 public class XAStatementStoreImplUnitTest
     extends StatementStoreAbstractUnitTest {
 
-  /**
-   * Logger.
-   */
+  /** Logger. */
+  @SuppressWarnings("unused")
   private final static Logger logger = Logger.getLogger(XAStatementStoreImplUnitTest.class);
 
   /**
@@ -85,7 +84,7 @@
   /**
    * Description of the Field
    */
-  private Set releasedNodes = new HashSet();
+  private Set<Long> releasedNodes = new HashSet<Long>();
 
 
   /**
@@ -134,7 +133,7 @@
    * @throws Exception EXCEPTION TO DO
    */
   public void testListeners() throws Exception {
-    if (!XAStatementStoreImpl.RELEASE_NODE_LISTENERS_ENABLED) return;
+    if (!checkIfListenersEnabled()) return;
 
     xaStore.addReleaseNodeListener(
       new ReleaseNodeListener() {
@@ -155,7 +154,17 @@
     assertEquals(Collections.singleton(new Long(5)), releasedNodes);
   }
 
+
   /**
+   * This access is hidden in a method to convince the compiler to look at it.
+   * @return <code>true</code> when listeners are enabled at build time.
+   */
+  private static boolean checkIfListenersEnabled() {
+    return XAStatementStoreImpl.RELEASE_NODE_LISTENERS_ENABLED;
+  }
+
+
+  /**
    * A method to call for each graph before running tests on it.
    *
    * @throws Exception EXCEPTION TO DO

Modified: branches/distinct_queries/src/jar/resolver-store/java/org/mulgara/store/statement/xa11/XA11StatementStoreImpl.java
===================================================================
--- branches/distinct_queries/src/jar/resolver-store/java/org/mulgara/store/statement/xa11/XA11StatementStoreImpl.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/resolver-store/java/org/mulgara/store/statement/xa11/XA11StatementStoreImpl.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -198,7 +198,7 @@
   private Phase.Token recordingPhaseToken = null;
 
   /** The list of graphs known to this statement store. */
-  private List<Long> committedGraphNodes;
+  private LinkedHashSet<Long> committedGraphNodes = null;
 
   /**
    * This flag indicates that the current object has been fully written, and may be considered
@@ -1191,7 +1191,7 @@
     private TripleAVLFile.Phase[] tripleAVLFilePhases = new TripleAVLFile.Phase[NR_INDEXES];
 
     /** The list of graphs valid in this phase. */
-    private List<Long> graphNodes = null;
+    private LinkedHashSet<Long> graphNodes = null;
 
 
     /**
@@ -1204,7 +1204,7 @@
       currentPhase = this;
       dirty = true;
       try {
-        graphNodes = committedGraphNodes == null ? scanForGraphs() : new ArrayList<Long>(committedGraphNodes);
+        graphNodes = committedGraphNodes == null ? scanForGraphs() : new LinkedHashSet<Long>(committedGraphNodes);
       } catch (StatementStoreException e) {
         throw new IOException("Unable to get metadata for phase: " + e.getMessage());
       }
@@ -1222,7 +1222,7 @@
       for (int i = 0; i < NR_INDEXES; ++i) tripleAVLFilePhases[i] = tripleAVLFiles[i].new Phase(p.tripleAVLFilePhases[i]);
       currentPhase = this;
       dirty = true;
-      graphNodes = new ArrayList<Long>(p.graphNodes);
+      graphNodes = new LinkedHashSet<Long>(p.graphNodes);
     }
 
 
@@ -1517,7 +1517,7 @@
         if (variableMask == (MASK0 | MASK1 | MASK2)) {
           LiteralGraphTuples result = new LiteralGraphTuples(false);
           for (long graphNode: graphNodes) {
-            if (tripleAVLFilePhases[TI_3012].existsTriple(node0, node1, node2, graphNode)) {
+            if (tripleAVLFilePhases[TI_3012].existsTriple(graphNode, node0, node1, node2)) {
               result.appendTuple(new long[] { graphNode });
             }
           }
@@ -1691,8 +1691,8 @@
      * Ask the system for all the known graphs.
      * @return All the known graph nodes.
      */
-    List<Long> scanForGraphs() throws StatementStoreException, IOException {
-      List<Long> nodeList = new ArrayList<Long>();
+    LinkedHashSet<Long> scanForGraphs() throws StatementStoreException, IOException {
+      LinkedHashSet<Long> nodeList = new LinkedHashSet<Long>();
 
       if (systemGraphNode == NONE || rdfTypeNode == NONE || graphTypeNode == NONE) return nodeList;
 

Modified: branches/distinct_queries/src/jar/server/java/org/mulgara/server/EmbeddedMulgaraServer.java
===================================================================
--- branches/distinct_queries/src/jar/server/java/org/mulgara/server/EmbeddedMulgaraServer.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/server/java/org/mulgara/server/EmbeddedMulgaraServer.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -48,6 +48,8 @@
 import org.mulgara.config.MulgaraConfig;
 import org.mulgara.config.Connector;
 import org.mulgara.config.PublicConnector;
+import org.mulgara.config.XpathFunctionResolver;
+import org.mulgara.query.FunctionResolverRegistry;
 import org.mulgara.server.SessionFactory;
 import org.mulgara.store.StoreException;
 import org.mulgara.store.xa.SimpleXAResourceException;
@@ -504,6 +506,9 @@
         String configURLStr = (String)parser.getOptionValue(EmbeddedMulgaraOptionParser.SERVER_CONFIG);
         mulgaraConfig = new MulgaraUserConfig(configURLStr);
 
+        // set up any local registries used in the system
+        configureRegistries();
+
         // disable automatic starting of the RMI registry
         if (parser.getOptionValue(EmbeddedMulgaraOptionParser.NO_RMI) != null) {
           // disable automatic starting of the RMI Registry
@@ -750,6 +755,19 @@
     }
   }
 
+  /**
+   * Configure any singleton registries based on the configuration file.
+   */
+  protected void configureRegistries() {
+    FunctionResolverRegistry fnReg = FunctionResolverRegistry.getFunctionResolverRegistry();
+    for (XpathFunctionResolver r: mulgaraConfig.getXpathFunctionResolver()) {
+      try {
+        fnReg.register(r.getType());
+      } catch (ClassNotFoundException e) {
+        log.error("Unable to load the XPathFunctionResolver: " + r.getType(), e);
+      }
+    }
+  }
 
   /**
    * Prints the usage instructions for starting the server.

Modified: branches/distinct_queries/src/jar/server/java/org/mulgara/server/MulgaraUserConfig.java
===================================================================
--- branches/distinct_queries/src/jar/server/java/org/mulgara/server/MulgaraUserConfig.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/server/java/org/mulgara/server/MulgaraUserConfig.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -41,6 +41,7 @@
 import org.mulgara.config.TemporaryNodePoolFactory;
 import org.mulgara.config.TemporaryResolverFactory;
 import org.mulgara.config.TemporaryStringPoolFactory;
+import org.mulgara.config.XpathFunctionResolver;
 
 /**
  * This class wraps the system configuration, and a user configuration, using any
@@ -78,6 +79,8 @@
 
   private List<SecurityAdapterFactory> securityAdapterFactories;
 
+  private List<XpathFunctionResolver> xpathFunctionResolvers;
+
   /**
    * Create the config object, to look like a standard configuration.
    * @throws IOException 
@@ -121,11 +124,14 @@
                (Enumeration<RuleLoader>)userConfig.enumerateRuleLoader());
       securityAdapterFactories = initializeList((Enumeration<SecurityAdapterFactory>)systemConfig.enumerateSecurityAdapterFactory(),
                (Enumeration<SecurityAdapterFactory>)userConfig.enumerateSecurityAdapterFactory());
+      xpathFunctionResolvers = initializeList((Enumeration<XpathFunctionResolver>)systemConfig.enumerateXpathFunctionResolver(),
+               (Enumeration<XpathFunctionResolver>)userConfig.enumerateXpathFunctionResolver());
     } else {
       contentHandlers = Collections.list((Enumeration<ContentHandler>)systemConfig.enumerateContentHandler());
       resolverFactories = Collections.list((Enumeration<ResolverFactory>)systemConfig.enumerateResolverFactory());
       ruleLoaders = Collections.list((Enumeration<RuleLoader>)systemConfig.enumerateRuleLoader());
       securityAdapterFactories = Collections.list((Enumeration<SecurityAdapterFactory>)systemConfig.enumerateSecurityAdapterFactory());
+      xpathFunctionResolvers = Collections.list((Enumeration<XpathFunctionResolver>)systemConfig.enumerateXpathFunctionResolver());
     }
   }
 
@@ -178,6 +184,7 @@
     if (o instanceof ResolverFactory) return ((ResolverFactory)o).isDisabled();
     if (o instanceof RuleLoader) return ((RuleLoader)o).isDisabled();
     if (o instanceof SecurityAdapterFactory) return ((SecurityAdapterFactory)o).isDisabled();
+    if (o instanceof XpathFunctionResolver) return ((XpathFunctionResolver)o).isDisabled();
     return true;
   }
 
@@ -231,6 +238,15 @@
   }
 
   /**
+   * @see org.mulgara.config.MulgaraConfig#enumerateXpathFunctionResolver()
+   */
+  @Override
+  public Enumeration<org.mulgara.config.XpathFunctionResolver> enumerateXpathFunctionResolver() {
+    return Collections.enumeration(xpathFunctionResolvers);
+  }
+
+
+  /**
    * @see org.mulgara.config.MulgaraConfig#getContentHandler()
    */
   @Override
@@ -408,6 +424,30 @@
   }
 
   /**
+   * @see org.mulgara.config.MulgaraConfig#getXpathFunctionResolver()
+   */
+  @Override
+  public XpathFunctionResolver[] getXpathFunctionResolver() {
+    return xpathFunctionResolvers.toArray(new XpathFunctionResolver[xpathFunctionResolvers.size()]);
+  }
+
+  /**
+   * @see org.mulgara.config.MulgaraConfig#getXpathFunctionResolver(int)
+   */
+  @Override
+  public XpathFunctionResolver getXpathFunctionResolver(int index) throws IndexOutOfBoundsException {
+    return xpathFunctionResolvers.get(index);
+  }
+
+  /**
+   * @see org.mulgara.config.MulgaraConfig#getXpathFunctionResolver()
+   */
+  @Override
+  public int getXpathFunctionResolverCount() {
+    return xpathFunctionResolvers.size();
+  }
+
+  /**
    * @see org.mulgara.config.MulgaraConfig#getRMIPort()
    */
   @Override
@@ -754,6 +794,15 @@
 
 
   /**
+   * @see org.mulgara.config.MulgaraConfig#removeAllXpathFunctionResolver()
+   */
+  @Override
+  public void removeAllXpathFunctionResolver() {
+    throw new UnsupportedOperationException("Read only class");
+  }
+
+
+  /**
    * @see org.mulgara.config.MulgaraConfig#removeContentHandler(org.mulgara.config.ContentHandler)
    */
   @Override
@@ -826,6 +875,24 @@
 
 
   /**
+   * @see org.mulgara.config.MulgaraConfig#removeXpathFunctionResolver(org.mulgara.config.XpathFunctionResolver)
+   */
+  @Override
+  public boolean removeXpathFunctionResolver(XpathFunctionResolver resolverFactory) {
+    throw new UnsupportedOperationException("Read only class");
+  }
+
+
+  /**
+   * @see org.mulgara.config.MulgaraConfig#removeXpathFunctionResolverAt(int)
+   */
+  @Override
+  public XpathFunctionResolver removeXpathFunctionResolverAt(int index) {
+    throw new UnsupportedOperationException("Read only class");
+  }
+
+
+  /**
    * @see org.mulgara.config.MulgaraConfig#setContentHandler(org.mulgara.config.ContentHandler[])
    */
   @Override
@@ -1006,6 +1073,24 @@
 
 
   /**
+   * @see org.mulgara.config.MulgaraConfig#setResolverFactory(int, org.mulgara.config.XpathFunctionResolver)
+   */
+  @Override
+  public void setXpathFunctionResolver(int index, XpathFunctionResolver functionResolver) throws IndexOutOfBoundsException {
+    throw new UnsupportedOperationException("Read only class");
+  }
+
+
+  /**
+   * @see org.mulgara.config.MulgaraConfig#setResolverFactory(org.mulgara.config.XpathFunctionResolver[])
+   */
+  @Override
+  public void setXpathFunctionResolver(XpathFunctionResolver[] xpathFunctionResolverArray) {
+    throw new UnsupportedOperationException("Read only class");
+  }
+
+
+  /**
    * @see org.mulgara.config.MulgaraConfig#setServerName(java.lang.String)
    */
   @Override

Modified: branches/distinct_queries/src/jar/server-rmi/java/org/mulgara/server/rmi/RmiServer.java
===================================================================
--- branches/distinct_queries/src/jar/server-rmi/java/org/mulgara/server/rmi/RmiServer.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/server-rmi/java/org/mulgara/server/rmi/RmiServer.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -216,8 +216,12 @@
     // Generate new server URI
     try {
       String path = "/" + (name == null ? "" : name);
-      int portValue = getPortNumber() == DEFAULT_PORT ? -1 : getPortNumber();
-      newURI = new URI("rmi", null, hostname, portValue, path, null, null);
+      int portNr = getPortNumber();
+      if (portNr == DEFAULT_PORT || portNr == -1) {
+        newURI = new URI("rmi://" + hostname + path);
+      } else {
+        newURI = new URI("rmi://" + hostname + ":" + portNr + path);
+      }
     } catch (URISyntaxException e) {
       throw new Error("Bad generated URI", e);
     }

Modified: branches/distinct_queries/src/jar/store-stringpool-memory/java/org/mulgara/store/stringpool/memory/MemoryStringPoolImpl.java
===================================================================
--- branches/distinct_queries/src/jar/store-stringpool-memory/java/org/mulgara/store/stringpool/memory/MemoryStringPoolImpl.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/store-stringpool-memory/java/org/mulgara/store/stringpool/memory/MemoryStringPoolImpl.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -198,7 +198,11 @@
       // Add to both ways of indexing objects and nodes.
       nodeToStringPool.put(gNode, spObject);
       stringToNodePool.put(spObject, gNode);
-      stringIndex.add(spObject);
+      try {
+        stringIndex.add(spObject);
+      } catch (RuntimeException e) {
+        throw new StringPoolException("Unable to add object: " + spObject + " for " + gNode, e);
+      }
     }
   }
 

Modified: branches/distinct_queries/src/jar/swrl/java/org/mulgara/swrl/SWRLLoader.java
===================================================================
--- branches/distinct_queries/src/jar/swrl/java/org/mulgara/swrl/SWRLLoader.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/swrl/java/org/mulgara/swrl/SWRLLoader.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,13 +1,17 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 Revelytix.
  *
- * 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.
+ * 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.
  */
 package org.mulgara.swrl;
 

Modified: branches/distinct_queries/src/jar/swrl/java/org/mulgara/swrl/SWRLStructureException.java
===================================================================
--- branches/distinct_queries/src/jar/swrl/java/org/mulgara/swrl/SWRLStructureException.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/swrl/java/org/mulgara/swrl/SWRLStructureException.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -1,13 +1,17 @@
 /*
- * The contents of this file are subject to the Open Software License
- * Version 3.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.opensource.org/licenses/osl-3.0.txt
+ * Copyright 2009 Revelytix.
  *
- * 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.
+ * 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.
  */
 package org.mulgara.swrl;
 

Modified: branches/distinct_queries/src/jar/tuples/java/org/mulgara/store/tuples/TuplesOperations.java
===================================================================
--- branches/distinct_queries/src/jar/tuples/java/org/mulgara/store/tuples/TuplesOperations.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/tuples/java/org/mulgara/store/tuples/TuplesOperations.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -744,7 +744,7 @@
         double term = vars.length > 0
                         ? Math.pow(tuples.getRowExpectedCount(), (double)(vars.length - (numLeftBindings - weight)) / vars.length)
                         : tuples.getRowExpectedCount();
-        weightedRowCount += term / Math.pow(10.0, weight);
+        weightedRowCount += term / Math.pow(100.0, weight);
       }
 
       if (logger.isDebugEnabled()) {

Modified: branches/distinct_queries/src/jar/tuples/java/org/mulgara/store/tuples/UnorderedProjection.java
===================================================================
--- branches/distinct_queries/src/jar/tuples/java/org/mulgara/store/tuples/UnorderedProjection.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/tuples/java/org/mulgara/store/tuples/UnorderedProjection.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -148,21 +148,20 @@
   /**
    * Gets the ColumnValue attribute of the UnorderedProjection object
    *
-   * @param column PARAMETER TO DO
-   * @return The ColumnValue value
-   * @throws TuplesException EXCEPTION TO DO
+   * @param column The 0-indexed column number to get the value from
+   * @return The value for the column binding, or {@link Tuples#UNBOUND} if the value is not bound.
+   * @throws TuplesException If there is an error accessing one of the original Tuples.
    */
   public long getColumnValue(int column) throws TuplesException {
     assert((column >= 0) && (column < getNumberOfVariables())) ||
         (column == ABSENT_COLUMN):"Invalid column " + column;
 
     if (columnMapping[column] == ABSENT_COLUMN) {
-      if (logger.isInfoEnabled()) {
-        logger.info(getVariables()[column] + " is never bound\n " + new StackTrace());
+      if (logger.isDebugEnabled()) {
+        logger.debug(getVariables()[column] + " is never bound\n " + new StackTrace());
       }
       return Tuples.UNBOUND;
-    }
-    else {
+    } else {
       return operand.getColumnValue(columnMapping[column]);
     }
   }

Modified: branches/distinct_queries/src/jar/tuples-hybrid/java/org/mulgara/store/xa/BlockCacheLine.java
===================================================================
--- branches/distinct_queries/src/jar/tuples-hybrid/java/org/mulgara/store/xa/BlockCacheLine.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/tuples-hybrid/java/org/mulgara/store/xa/BlockCacheLine.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -133,8 +133,8 @@
 
 
   public void reset(long[] prefix) throws TuplesException {
-    if (logger.isInfoEnabled()) {
-      logger.info("Entering reset with prefix: " + AbstractTuples.toString(prefix));
+    if (logger.isDebugEnabled()) {
+      logger.debug("Entering reset with prefix: " + AbstractTuples.toString(prefix));
     }
     super.reset(prefix);
 
@@ -243,7 +243,7 @@
    * @return The block containing the current prefix.
    */
   private Block findBlock(long[] prefix) throws TuplesException {
-    logger.info("Finding block matching prefix");
+    if (logger.isDebugEnabled()) logger.debug("Finding block matching prefix");
     try {
       assert prefix.length > 0 && prefix.length <= width;
 
@@ -294,8 +294,8 @@
    *      if found then lowBlock &lt; prefix == highBlock
    */
   private Block findBlock(long[] prefix, boolean found, long lowBound, Block lowBlock, long highBound, Block highBlock) throws TuplesException {
-    if (logger.isInfoEnabled()) {
-      logger.info("finding Block with prefix: " + AbstractTuples.toString(prefix) + " found: " + found +
+    if (logger.isDebugEnabled()) {
+      logger.debug("finding Block with prefix: " + AbstractTuples.toString(prefix) + " found: " + found +
           " lowBound: " + lowBound + " highBound: " + highBound);
     }
     try {

Modified: branches/distinct_queries/src/jar/util/java/org/mulgara/util/AbstractMulgaraResultSet.java
===================================================================
--- branches/distinct_queries/src/jar/util/java/org/mulgara/util/AbstractMulgaraResultSet.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/util/java/org/mulgara/util/AbstractMulgaraResultSet.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -231,7 +231,6 @@
    * @throws SQLException on failure
    * @deprecated Deprecated in {@link java.sql.ResultSet}
    */
-  @SuppressWarnings("deprecation")
   public BigDecimal getBigDecimal(int columnIndex, int scale)
     throws SQLException {
 
@@ -296,7 +295,6 @@
    * @throws SQLException on failure
    * @deprecated Deprecated in the original {@link java.sql.ResultSet}
    */
-  @SuppressWarnings("deprecation")
   public java.io.InputStream getUnicodeStream(int columnIndex)
     throws SQLException {
 
@@ -447,7 +445,6 @@
    * @throws SQLException on failure
    * @deprecated Deprecated in the original {@link java.sql.ResultSet}
    */
-  @SuppressWarnings("deprecation")
   public BigDecimal getBigDecimal(String columnName, int scale)
     throws SQLException {
 
@@ -512,7 +509,6 @@
    * @throws SQLException on failure
    * @deprecated This has been deprecated in the original {@link ResultSet#getUnicodeStream(String)}
    */
-  @SuppressWarnings("deprecation")
   public java.io.InputStream getUnicodeStream(String columnName)
     throws SQLException {
 

Modified: branches/distinct_queries/src/jar/util/java/org/mulgara/util/Bootstrap.java
===================================================================
--- branches/distinct_queries/src/jar/util/java/org/mulgara/util/Bootstrap.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/util/java/org/mulgara/util/Bootstrap.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -16,7 +16,7 @@
  * created by Plugged In Software Pty Ltd are Copyright (C) 2001,2002
  * Plugged In Software Pty Ltd. All Rights Reserved.
  *
- * Contributor(s): N/A.
+ * Contributor(s): Duraspace.
  *
  * [NOTE: The text of this Exhibit A may differ slightly from the text
  * of the notices in the Source Code files of the Original Code. You
@@ -70,13 +70,8 @@
  *
  * @modified $Date: 2005/01/05 04:59:29 $
  *
- * @maintenanceAuthor $Author: newmana $
- *
  * @company <A href="mailto:info at PIsoftware.com">Plugged In Software</A>
  *
- * @copyright &copy;2001 <a href="http://www.pisoftware.com/">Plugged In
- *      Software Pty Ltd</a>
- *
  * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
  */
 public class Bootstrap extends URLClassLoader {
@@ -100,7 +95,7 @@
   /**
    * Used by the addToSystemClasspath hack
    */
-  private static final Class[] parameters = new Class[]{URL.class};
+  private static final Class<?>[] parameters = new Class[]{URL.class};
 
   /**
    * create a 100K temp buffer to store the JAR bytes in
@@ -114,10 +109,8 @@
   // Members
   //
 
-  /**
-   * the array of JAR files to load
-   *
-   */
+  /** the array of JAR files to load */
+  @SuppressWarnings("unused")
   private URL[] jarURLs = null;
 
   //
@@ -146,7 +139,6 @@
     this.jarURLs = jarURLs;
   }
 
-  // Bootstrap
 
   /**
    * Loads a comma separated list of embedded JAR files specified by an <CODE>Embedded-Jar</CODE>
@@ -173,26 +165,18 @@
       Attributes manifestAttr = retrieveManifestAttributes();
 
       // throw and error if we couldn't get any manifest attributes
-      if (manifestAttr == null) {
+      if (manifestAttr == null) throw new Exception("No manifest attributes found for JAR");
 
-        throw new Exception("No manifest attributes found for JAR");
-      }
-
-      // end if
       // get the name of the embedded main class
       String embeddedMainClass = manifestAttr.getValue(EMBEDDED_MAIN_CLASS_KEY);
 
       // it's pointless to continue without a main class
       if (embeddedMainClass == null) {
-
         throw new Exception("No Embedded-Main-Class attribute in manifest");
       }
 
-      // end if
       // Set the path of the jar as a System property - mulgara.jar.path
-      URL bootURL =
-          Bootstrap.class.getClassLoader().getSystemResource(
-          "org/mulgara/util/Bootstrap.class");
+      URL bootURL = ClassLoader.getSystemResource("org/mulgara/util/Bootstrap.class");
 
       String bootURLString = bootURL.toString();
       String preString = "jar:file:";
@@ -207,31 +191,26 @@
       //       dodgy error message problem.
       // set the xerces system property if we're executing the Mulgara server
       if (embeddedMainClass.equals("org.mulgara.server.EmbeddedMulgaraServer")) {
-
         System.setProperty("org.mulgara.xml.ResourceDocumentBuilderFactory",
             "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
       }
 
-      // end if
       // ************************************************************************
       // get a list of URLs to the embedded JARs
-      LinkedList jarURLs = getEmbeddedJarURLs(manifestAttr);
+      LinkedList<URL> jarURLs = getEmbeddedJarURLs(manifestAttr);
 
       // create a new bootstrap classloader
-      Bootstrap loader =
-            new Bootstrap( (URL[]) jarURLs.toArray(new URL[jarURLs.size()]));
+      Bootstrap loader = new Bootstrap((URL[])jarURLs.toArray(new URL[jarURLs.size()]));
 
       // set the context class loader to the bootstrap
       Thread.currentThread().setContextClassLoader(loader);
 
       // invokes the 'real' main class
       loader.invokeClass(embeddedMainClass, args);
-    }
-    catch (Exception e) {
+    } catch (Exception e) {
 
       // print the contents of the exception
-      System.err.println("Unable to bootstrap embedded main class: " +
-          e.toString());
+      System.err.println("Unable to bootstrap embedded main class: " + e.toString());
       System.err.println(">> Stack trace:");
       e.printStackTrace();
 
@@ -240,36 +219,28 @@
       Throwable cause = e.getCause();
 
       while (cause != null) {
-
         rootCause = cause;
         cause = cause.getCause();
       }
 
-      // end while
       // print a stack trace on it
       if (rootCause != null) {
-
         System.err.println(">> Root cause stack trace:");
         System.err.flush();
         rootCause.printStackTrace();
       }
 
-      // end if
     }
 
-    // try-catch
   }
 
-  // main()
 
   /**
-   * Shutdown the current application by forcing the runtime shutdown hooks to
-   * be executed.
+   * Shutdown the current application by forcing the runtime shutdown hooks to be executed.
    *
-   * @param args PARAMETER TO DO
+   * @param args command line arguments
    */
   public static void shutdown(String[] args) {
-
     System.exit(0);
   }
 
@@ -277,13 +248,11 @@
    * Hack used to add the Embedded Jars to the system classpath.
    *
    * @param urls URLs of JARs to embed
-   * @throws IOException
+   * @throws IOException Caused by any problem updating the system class path
    */
   public static void addToSystemClasspath(URL[] urls) throws IOException {
 
-    if (urls == null) {
-      throw new IllegalArgumentException("null 'urls' parameter.");
-    }
+    if (urls == null) throw new IllegalArgumentException("null 'urls' parameter.");
 
     //add each
     for (int i = 0; i < urls.length; i++) {
@@ -294,47 +263,39 @@
   /**
    * Adds the jar (url) to the system classpath.
    *
-   * @param url URL
-   * @throws IOException
+   * @param url URL to add to the system classpath.
+   * @throws IOException Caused by any problem updating the system class path
    */
   public static void addToSystemClasspath(URL url) throws IOException {
 
-    URLClassLoader sysloader = (URLClassLoader) ClassLoader.
-        getSystemClassLoader();
-    Class sysclass = URLClassLoader.class;
+    URLClassLoader sysloader = (URLClassLoader)ClassLoader.getSystemClassLoader();
+    Class<URLClassLoader> sysclass = URLClassLoader.class;
 
     try {
       Method method = sysclass.getDeclaredMethod("addURL", parameters);
       method.setAccessible(true);
       method.invoke(sysloader, new Object[] {url});
-    }
-    catch (Throwable t) {
+    } catch (Throwable t) {
       t.printStackTrace();
       throw new IOException("Error, could not add URL to system classloader");
     }
   }
 
 
-  // retrieveManifestAttributes()
-
   /**
    * Returns a list of URLs to the embedded jar files.
    *
    * @param manifestAttr the manifest attributes of the jar to retrieve the
    *      embedded jar names from
-   * @return a list of URLs to the embedded jar files, null if no embedded jars
-   *      found
+   * @return a list of URLs to the embedded jar files, null if no embedded jars found
    */
-  private static LinkedList getEmbeddedJarURLs(Attributes manifestAttr) {
+  private static LinkedList<URL> getEmbeddedJarURLs(Attributes manifestAttr) {
 
     // check the parameters
-    if (manifestAttr == null) {
+    if (manifestAttr == null) throw new IllegalArgumentException("Null manifest attribute");
 
-      throw new IllegalArgumentException("Null manifest attribute");
-    }
-
     // create a list to hold the JAR resources
-    LinkedList jarURLs = new LinkedList();
+    LinkedList<URL> jarURLs = new LinkedList<URL>();
 
     // get the list of embedded jars
     String embeddedJarList = manifestAttr.getValue(EMBEDDED_JAR_KEY);
@@ -342,25 +303,16 @@
     if (embeddedJarList != null ) {
     
       // tokense the list of jar files
-      StringTokenizer jarTokenizer =
-          new StringTokenizer(embeddedJarList, " ,\t\f");
+      StringTokenizer jarTokenizer = new StringTokenizer(embeddedJarList, " ,\t\f");
 
       // add a URL for each embedded jar to the array
       while (jarTokenizer.hasMoreTokens()) {
-
         // write this JAR to a temp file and get its URL
         URL jarURL = writeTempJARFile(jarTokenizer.nextToken());
-
-        if (jarURL != null) {
-
-          jarURLs.add(jarURL);
-        }
-
-        // end if
+        if (jarURL != null) jarURLs.add(jarURL);
       }
     }
 
-    // end while
     // we don't want the buffer hanging around
     buf = null;
 
@@ -369,10 +321,9 @@
   }
 
   /**
-   * Retrieves the manifest attributes of the JAR from which this file is
-   * running.
+   * Retrieves the manifest attributes of the JAR from which this file is running.
    *
-       * @return the manifest attributes of the JAR from which this class is running
+   * @return the manifest attributes of the JAR from which this class is running
    * @throws Exception if unable to retrieve the JAR resource for a class
    */
   private static Attributes retrieveManifestAttributes() throws Exception {
@@ -384,27 +335,21 @@
     URL classURL = ClassLoader.getSystemResource(className + ".class");
 
     // throw an error if we could not get it
-    if (classURL == null) {
+    if (classURL == null) throw new Exception("Unable to retrieve JAR resource for " + className);
 
-      throw new Exception("Unable to retrieve JAR resource for " + className);
-    }
-
     // end if
     // open a connection to the class resource
     URLConnection urlConn = classURL.openConnection();
 
     // make sure that we're executing from within a JAR
     if ( (urlConn == null) || ! (urlConn instanceof JarURLConnection)) {
-
       throw new Exception("Bootstrap class must be executed from within a JAR");
     }
 
-    // end if
     // return its manifest attributes
-    return ( (JarURLConnection) urlConn).getMainAttributes();
+    return ((JarURLConnection)urlConn).getMainAttributes();
   }
 
-  // getEmbeddedJarURLs()
 
   /**
    * Writes an embedded JAR file to a temporary file, and returns a URL to the
@@ -412,8 +357,7 @@
    *
    * @param embeddedJARFilename the name of the embedded JAR file to retrieve
    * @return the URL of the temporary JAR file, null if we were unable to
-   *      retrieve a the embedded JAR or something went wrong writing a temp
-   *      file
+   *      retrieve a the embedded JAR or something went wrong writing a temp file
    */
   private static URL writeTempJARFile(String embeddedJARFilename) {
 
@@ -422,17 +366,13 @@
     try {
 
       // get the embedded jar as a stream
-      InputStream jarIn =
-          ClassLoader.getSystemResourceAsStream(embeddedJARFilename);
+      InputStream jarIn =ClassLoader.getSystemResourceAsStream(embeddedJARFilename);
 
       // check that the embedded filename is valid
       if (jarIn == null) {
-
-        throw new IOException("Embedded JAR: " + embeddedJARFilename +
-            " does not exist in enclosing JAR.");
+        throw new IOException("Embedded JAR: " + embeddedJARFilename + " does not exist in enclosing JAR.");
       }
 
-      // end if
       // create a temporary file to write the jar to (we may need to keep the
       // class on disk for windows weenies...)
       File tmpJarFile = File.createTempFile("mulgara", ".jar");
@@ -444,29 +384,24 @@
       // write the embedded jar to disk
       int n;
 
-      while ( (n = jarIn.read(buf)) != -1) {
-
+      while ((n = jarIn.read(buf)) != -1) {
         out.write(buf, 0, n);
       }
 
-      // end if
       // set the embedded JAR's URL
-      embeddedJarURL = tmpJarFile.toURL();
-    }
-    catch (IOException ioe) {
+      embeddedJarURL = tmpJarFile.toURI().toURL();
 
+    } catch (IOException ioe) {
       System.err.println(ioe);
     }
 
-    // try-catch
     // return the temp file's URL
     return embeddedJarURL;
   }
 
-  // writeTempJARFile()
 
   /**
-       * Invokes the <CODE>main()</CODE> or or <CODE>shutdown()</CODE> method of the
+   * Invokes the <CODE>main()</CODE> or or <CODE>shutdown()</CODE> method of the
    * class <CODE>className</CODE> with the given array of arguments. The class
    * must define a <CODE>public static void xxx()</CODE> that takes an array of
    * String.
@@ -492,38 +427,29 @@
     // check for a shutdown request
     for (int i = 0; i < args.length; i++) {
 
-      if (args[i].equalsIgnoreCase("--shutdown") ||
-          args[i].equalsIgnoreCase("-x")) {
-
+      if (args[i].equalsIgnoreCase("--shutdown") || args[i].equalsIgnoreCase("-x")) {
         // change the method to a shutdown
         methodRequest = "shutdown";
       }
     }
 
     // load the class
-    Class c = this.loadClass(className);
+    Class<?> c = this.loadClass(className);
 
     // get its main method
-    Method m = c.getMethod(methodRequest, new Class[] {
-        args.getClass()});
+    Method m = c.getMethod(methodRequest, new Class[] {args.getClass()});
     m.setAccessible(true);
 
     // retrieve its modifiers
     int mods = m.getModifiers();
 
     // make sure that it is a public static void method
-    if ( (m.getReturnType() != void.class) ||
-        !Modifier.isStatic(mods) ||
-        !Modifier.isPublic(mods)) {
-
+    if ((m.getReturnType() != void.class) || !Modifier.isStatic(mods) || !Modifier.isPublic(mods)) {
       throw new NoSuchMethodException(methodRequest);
     }
 
-    // end if
     // invoke it!
-    m.invoke(null, new Object[] {
-        args});
+    m.invoke(null, new Object[] {args});
   }
 
-  // invokeClass()
 }

Modified: branches/distinct_queries/src/jar/util/java/org/mulgara/util/ServerInfoRef.java
===================================================================
--- branches/distinct_queries/src/jar/util/java/org/mulgara/util/ServerInfoRef.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/util/java/org/mulgara/util/ServerInfoRef.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -20,6 +20,8 @@
 import java.lang.reflect.Method;
 import java.net.URI;
 import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -119,7 +121,11 @@
   public static final void setServerInfoProperty(String name, Object value) {
     try {
       Method setter = findSetter(name, value);
-      setter.invoke(null, new Object[] { value });
+      if (setter != null) {
+        setter.invoke(null, new Object[] { value });
+      } else {
+        logger.info("No setter method found in Server Info for: " + name);
+      }
     } catch (Exception e) {
       /* Not much that can be done here */
       logger.info("Unable to set '" + name + "' for Server Info", e);
@@ -169,14 +175,18 @@
    * @param value The value of the property to be set.
    * @return The method used for setting the property.
    * @throws SecurityException If the method is not allowed to be used.
-   * @throws NoSuchMethodException If the writable property does not exist.
    * @throws ClassNotFoundException If the ServerInfo class is not on the classpath.
    */
-  private static final Method findSetter(String name, Object value) throws SecurityException, NoSuchMethodException, ClassNotFoundException {
+  private static final Method findSetter(String name, Object value) throws SecurityException, ClassNotFoundException {
     String fullName = "set" + name;
     Method setter = setters.get(fullName);
     if (setter == null) {
-      setter = getServerInfoClass().getMethod(fullName, new Class[] { value.getClass() });
+      for (Class<?>cls: getSuperTypes(value.getClass())) {
+        try {
+          setter = getServerInfoClass().getMethod(fullName, new Class[] { cls });
+          break;
+        } catch (NoSuchMethodException e) { /* continue */ }
+      }
       setters.put(fullName, setter);
     }
     return setter;
@@ -184,6 +194,21 @@
 
 
   /**
+   * Get the list of all superclasses and interfaces that a class meets.
+   * @param cls The class to get all supertypes of.
+   * @return A List of classes and interfaces that this class extends.
+   */
+  private static final List<Class<?>> getSuperTypes(Class<?> cls) {
+    List<Class<?>> result = new LinkedList<Class<?>>();
+    for (Class<?> i: cls.getInterfaces()) result.add(i);
+    do {
+      result.add(cls);
+    } while ((cls = cls.getSuperclass()) != null);
+    return result;
+  }
+
+
+  /**
    * Gets a string constant from the Mulgara class.
    * @param name The name of the constant.
    * @return The string value of the constant, or null if this cannot be retrieved.

Modified: branches/distinct_queries/src/jar/util/java/org/mulgara/util/functional/C.java
===================================================================
--- branches/distinct_queries/src/jar/util/java/org/mulgara/util/functional/C.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/util/java/org/mulgara/util/functional/C.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -112,6 +112,7 @@
    * @return The first element in the list.
    * @throws NoSuchElementException If the list is empty.
    */
+  @SuppressWarnings("unchecked")
   public static final <T1> T1 head(List<T1> arg) throws NoSuchElementException {
     if (arg instanceof LinkedList) return ((LinkedList<T1>)arg).getFirst();
     if (arg.size() == 0) throw new NoSuchElementException("Empty list");
@@ -134,6 +135,7 @@
    * @param arg The list.
    * @return The first element in the list, or <code>null</code> if the list is empty.
    */
+  @SuppressWarnings("unchecked")
   public static final <T1> T1 headN(List<T1> arg) {
     return arg.isEmpty() ? null : (arg instanceof LinkedList) ? ((LinkedList<T1>)arg).getFirst() : arg.get(0);
   }
@@ -156,6 +158,7 @@
    * @return The last element in the list.
    * @throws IndexOutOfBoundsException If the list is empty.
    */
+  @SuppressWarnings("unchecked")
   public static final <T1> T1 tail(List<T1> arg) throws NoSuchElementException {
     if (arg instanceof LinkedList) return ((LinkedList<T1>)arg).getLast();
     if (arg.size() == 0) throw new NoSuchElementException("Empty list");
@@ -200,6 +203,7 @@
    * @return The first element in the collection.
    * @throws NoSuchElementException If the collection is empty.
    */
+  @SuppressWarnings("unchecked")
   public static final <T1> T1 first(Collection<T1> arg) throws NoSuchElementException {
     if (arg instanceof LinkedList) return ((LinkedList<T1>)arg).getFirst();
     if (arg.isEmpty()) throw new NoSuchElementException("Empty Collection");
@@ -229,6 +233,38 @@
   }
 
   /**
+   * Method to join the elements of a list into a string.
+   * @param <T> The type of element in the list.
+   * @param list The list to be converted to a string.
+   * @param separator The separator to use between elements of the list. May be <code>null</code>.
+   * @return The final string.
+   */
+  public static final <T> String join(List<T> list, String separator) {
+    return join(list, null, separator, null);
+  }
+
+  /**
+   * General method to join the elements of a list into a string.
+   * @param <T> The type of element in the list.
+   * @param list The list to be converted to a string.
+   * @param start The start of the string. May be <code>null</code>.
+   * @param separator The separator to use between elements of the list. May be <code>null</code>.
+   * @param end The end of the string. May be <code>null</code>.
+   * @return The final string.
+   */
+  public static final <T> String join(List<T> list, String start, String separator, String end) {
+    StringBuilder s = start == null ? new StringBuilder() : new StringBuilder(start);
+    boolean first = true;
+    for (T elt: list) {
+      if (!first && separator != null) s.append(separator);
+      else first = false;
+      s.append(elt);
+    }
+    if (end != null) s.append(end);
+    return s.toString();
+  }
+
+  /**
    * Inserts an element into an ordered list in a given order.
    * @param <T> The type of the element to be inserted. Must be comparable on itself.
    * @param list The list to insert into. This must already be ordered in the same order as this insert.

Modified: branches/distinct_queries/src/jar/util-xa/java/org/mulgara/store/xa/FreeList.java
===================================================================
--- branches/distinct_queries/src/jar/util-xa/java/org/mulgara/store/xa/FreeList.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/util-xa/java/org/mulgara/store/xa/FreeList.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -37,6 +37,7 @@
 import org.apache.log4j.Logger;
 import org.mulgara.util.IntFile;
 import org.mulgara.util.StackTrace;
+import org.mulgara.util.functional.C;
 
 /**
  * A fifo of integer items. A list of "phases" is maintained where each phase
@@ -67,9 +68,6 @@
   /** Logger. */
   private final static Logger logger = Logger.getLogger(FreeList.class);
 
-  /** Flag used to indicate that the runtime is in debug mode. */
-  private final static boolean DEBUG = false;
-
   /** The name extension of the file used for the freelist. */
   private final static String INTFILE_EXT = "_ph";
 
@@ -400,7 +398,7 @@
       throw new IllegalArgumentException("Trying to free item that was never allocated: " + item);
     }
 
-    if (DEBUG && !isValid(item)) throw new AssertionError("Attempt to free an invalid item: " + item);
+    // if (!isValid(item)) throw new AssertionError("Attempt to free an invalid item: " + item);
 
     long head = currentPhase.getHead();
     readHeadBlock(getBlockId(head));
@@ -946,8 +944,8 @@
     private Reference<Token> tokenRef = null;
 
 
-    /** Holds a stack trace of construction so we can tell where problems occurred. */
-    private StackTrace stack = null;
+    /** Holds stack traces of use so we can tell where problems occurred. */
+    private List<StackTrace> stack = null;
 
 
     /**
@@ -972,10 +970,6 @@
           init(HEADER_SIZE, HEADER_SIZE, 0, 0);
         }
       }
-      // record the stack if info is enabled
-      if (logger.isInfoEnabled()) {
-        stack = new StackTrace();
-      }
     }
 
     /**
@@ -1018,10 +1012,6 @@
         nrValidItems = p.nrValidItems;
         init();
 
-        // record the stack if info is enabled
-        if (logger.isInfoEnabled()) {
-          stack = new StackTrace();
-        }       
       }
     }
 
@@ -1134,6 +1124,11 @@
 
       ++refCount;
 
+      // record the stack if debug is enabled
+      if (logger.isDebugEnabled()) {
+        stack.add(new StackTrace());
+      }
+
       return token;
     }
 
@@ -1225,8 +1220,8 @@
       Token token = (tokenRef != null) ? tokenRef.get() : null;
 
       if ( (token == null) && (refCount > 0)) {
-        if (logger.isInfoEnabled()) {
-          logger.info("Lost phase token.\n" + stack);
+        if (logger.isDebugEnabled()) {
+          logger.info("Lost phase token. Used " + stack.size() + " times:\n" + C.join(stack, "\n\n"));
         }
         refCount = 0;
       }

Modified: branches/distinct_queries/src/jar/web/java/org/mulgara/webquery/QueryServlet.java
===================================================================
--- branches/distinct_queries/src/jar/web/java/org/mulgara/webquery/QueryServlet.java	2009-11-13 19:29:46 UTC (rev 1843)
+++ branches/distinct_queries/src/jar/web/java/org/mulgara/webquery/QueryServlet.java	2009-11-13 19:31:38 UTC (rev 1844)
@@ -291,7 +291,8 @@
       resp.sendError(SC_SERVICE_UNAVAILABLE, ise.getMessage());
       return;
     } catch (Exception e) {
-      resp.sendError(SC_BAD_REQUEST, "Error executing command. Reason: " + StackTrace.getReasonMessage(e));
+      // resp.sendError(SC_BAD_REQUEST, "Error executing command. Reason: " + StackTrace.getReasonMessage(e));
+      resp.sendError(SC_BAD_REQUEST, "Error executing command. Reason: " + StackTrace.throwableToString(e));
       return;
     }
 




More information about the Mulgara-svn mailing list