[Mulgara-svn] r379 - in branches/nw-interface: . src/jar src/jar/client-jrdf/java/org/mulgara/client/jrdf/util src/jar/connection/java/org/mulgara/connection src/jar/itql/java/org/mulgara/itql src/jar/parser src/jar/parser/java src/jar/parser/java/org src/jar/query/java/org/mulgara/query/ast src/jar/query/java/org/mulgara/server src/jar/resolver/java/org/mulgara/resolver src/jar/resolver-distributed/java/org/mulgara/resolver/distributed src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/remote src/jar/resolver-spi/java/org/mulgara/resolver/spi

pag at mulgara.org pag at mulgara.org
Mon Aug 27 21:10:02 UTC 2007


Author: pag
Date: 2007-08-27 16:10:01 -0500 (Mon, 27 Aug 2007)
New Revision: 379

Added:
   branches/nw-interface/src/jar/parser/
   branches/nw-interface/src/jar/parser/java/
   branches/nw-interface/src/jar/parser/java/org/
   branches/nw-interface/src/jar/parser/java/org/mulgara/
Removed:
   branches/nw-interface/src/jar/itql/java/org/mulgara/itql/Interpreter.java
Modified:
   branches/nw-interface/.classpath
   branches/nw-interface/src/jar/client-jrdf/java/org/mulgara/client/jrdf/util/ItqlQueryUtil.java
   branches/nw-interface/src/jar/connection/java/org/mulgara/connection/Connection.java
   branches/nw-interface/src/jar/itql/java/org/mulgara/itql/CompoundPredListBuilder.java
   branches/nw-interface/src/jar/itql/java/org/mulgara/itql/CompoundPredicate.java
   branches/nw-interface/src/jar/itql/java/org/mulgara/itql/ConstraintExpressionBuilder.java
   branches/nw-interface/src/jar/itql/java/org/mulgara/itql/ItqlInterpreter.java
   branches/nw-interface/src/jar/itql/java/org/mulgara/itql/ItqlInterpreterBean.java
   branches/nw-interface/src/jar/itql/java/org/mulgara/itql/ItqlInterpreterUnitTest.java
   branches/nw-interface/src/jar/itql/java/org/mulgara/itql/TqlInterpreter.java
   branches/nw-interface/src/jar/itql/java/org/mulgara/itql/VariableBuilder.java
   branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/ApplyRules.java
   branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/Backup.java
   branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/Command.java
   branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/Commit.java
   branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/DataTx.java
   branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/Deletion.java
   branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/Insertion.java
   branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/LocalCommand.java
   branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/Rollback.java
   branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/ServerCommand.java
   branches/nw-interface/src/jar/query/java/org/mulgara/server/Session.java
   branches/nw-interface/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/NetworkDelegator.java
   branches/nw-interface/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/remote/StatementSetFactory.java
   branches/nw-interface/src/jar/resolver-spi/java/org/mulgara/resolver/spi/TripleSetWrapperStatements.java
   branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/AdvDatabaseSessionUnitTest.java
   branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/CacheResolver.java
   branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/CacheResolverFactory.java
   branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/Database.java
   branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java
   branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java
   branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/DatabaseSessionListQueryUnitTest.java
   branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/LocalJRDFDatabaseSession.java
   branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/ModifyModelOperation.java
   branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/OperationContext.java
   branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/QueryOperation.java
Log:
This is a checkpoint to allow moving from one development machine to another.  Changes include:
Significant refactoring to add in generics, and typed for loops. Some restructuring of itql to create a base package called lang. This still needs ant integration. Starting to implement Commands. 

Modified: branches/nw-interface/.classpath
===================================================================
--- branches/nw-interface/.classpath	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/.classpath	2007-08-27 21:10:01 UTC (rev 379)
@@ -59,6 +59,7 @@
 	<classpathentry kind="src" path="src/jar/tuples-hybrid/java"/>
 	<classpathentry kind="src" path="src/jar/util/java"/>
 	<classpathentry kind="src" path="src/jar/util-xa/java"/>
+	<classpathentry kind="src" path="src/jar/parser/java"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="lib" path="lib/xom-1.0d21.jar"/>
 	<classpathentry kind="lib" path="lib/xmlParserAPIs.jar"/>

Modified: branches/nw-interface/src/jar/client-jrdf/java/org/mulgara/client/jrdf/util/ItqlQueryUtil.java
===================================================================
--- branches/nw-interface/src/jar/client-jrdf/java/org/mulgara/client/jrdf/util/ItqlQueryUtil.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/client-jrdf/java/org/mulgara/client/jrdf/util/ItqlQueryUtil.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -65,13 +65,11 @@
 
 //JRDF packages
 import org.jrdf.graph.*;
-import org.jrdf.util.ClosableIterator;
 
 //Mulgara packages
-import org.mulgara.itql.lexer.*;
-import org.mulgara.itql.parser.*;
-import org.mulgara.client.jrdf.*;
 import org.mulgara.itql.*;
+import org.mulgara.parser.MulgaraLexerException;
+import org.mulgara.parser.MulgaraParserException;
 import org.mulgara.query.*;
 import org.mulgara.query.rdf.*;
 import org.mulgara.server.Session;
@@ -127,12 +125,12 @@
       throw new GraphException("Could not execute query: " + query,
                                queryException);
     }
-    catch (LexerException lexerException) {
+    catch (MulgaraLexerException lexerException) {
 
       throw new GraphException("Could not parse query: " + query,
                                lexerException);
     }
-    catch (ParserException parserException) {
+    catch (MulgaraParserException parserException) {
 
       throw new GraphException("Could not parse query: " + query,
                                parserException);
@@ -232,15 +230,13 @@
    * @param modelURI String
    * @throws GraphException
    */
-  public static String getDeleteQuery(Iterator triples, String modelURI) throws
-      GraphException {
+  public static String getDeleteQuery(Iterator<Triple> triples, String modelURI) throws GraphException {
 
     //value to be returned
     StringBuffer query = new StringBuffer("");
 
     //there must be triples to insert
-    if ( (triples != null)
-        && (triples.hasNext())) {
+    if ((triples != null) && (triples.hasNext())) {
 
       query.append("delete ");
 
@@ -269,15 +265,14 @@
    * @param modelURI String
    * @throws GraphException
    */
-  public static String getInsertQuery(Iterator triples, String modelURI) throws
+  public static String getInsertQuery(Iterator<Triple> triples, String modelURI) throws
       GraphException {
 
     //value to be returned
     StringBuffer query = new StringBuffer("");
 
     //there must be triples to insert
-    if ( (triples != null)
-        && (triples.hasNext())) {
+    if ((triples != null) && (triples.hasNext())) {
 
       query.append("insert ");
 
@@ -306,8 +301,7 @@
    * @throws GraphException
    * @return String
    */
-  private static String getTripleSetQuery(Iterator triples) throws
-      GraphException {
+  private static String getTripleSetQuery(Iterator<Triple> triples) throws GraphException {
 
     //value to be returned
     StringBuffer tripleSet = new StringBuffer();
@@ -317,7 +311,7 @@
       //append each
       while (triples.hasNext()) {
 
-        tripleSet.append(getTripleString( (Triple) triples.next()));
+        tripleSet.append(getTripleString(triples.next()));
       }
     }
 

Modified: branches/nw-interface/src/jar/connection/java/org/mulgara/connection/Connection.java
===================================================================
--- branches/nw-interface/src/jar/connection/java/org/mulgara/connection/Connection.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/connection/java/org/mulgara/connection/Connection.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -101,6 +101,14 @@
   }
 
 
+  /**
+   * @return the session
+   */
+  public Session getSession() {
+    return session;
+  }
+
+
   // Private methods //
 
   /**
@@ -120,14 +128,6 @@
 
 
   /**
-   * @return the session
-   */
-  Session getSession() {
-    return session;
-  }
-
-
-  /**
    * Sets the session information for this connection
    * @param session The session to set to.
    * @param securityDomainURI The security domain to use for the session.

Modified: branches/nw-interface/src/jar/itql/java/org/mulgara/itql/CompoundPredListBuilder.java
===================================================================
--- branches/nw-interface/src/jar/itql/java/org/mulgara/itql/CompoundPredListBuilder.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/itql/java/org/mulgara/itql/CompoundPredListBuilder.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -60,12 +60,6 @@
  *
  * @author Andrae Muys
  *
- * @version $Revision: 1.1.1.1 $
- *
- * @modified $Date: $ by $Author: $
- *
- * @maintenanceAuthor $Author: $
- *
  * @company <a href="mailto:mail at netymon.com">Netymon Pty Ltd</a>
  *
  * @copyright &copy;2006 Australian Commonwealth Government.
@@ -77,15 +71,16 @@
 
   private final static Logger logger = Logger.getLogger(CompoundPredListBuilder.class.getName());
 
-  private List predLists;
+  private List<CompoundPredicate> predLists;
+
   /**
    * Constructor.
    */
   public CompoundPredListBuilder() {
-    predLists = new ArrayList();
+    predLists = new ArrayList<CompoundPredicate>();
   }
 
-  public List getPredLists() {
+  public List<CompoundPredicate> getPredLists() {
     return predLists;
   }
 
@@ -97,24 +92,18 @@
   }
 
   public void caseAColonExistsExpression(AColonExistsExpression expr) {
-    if (logger.isDebugEnabled()) {
-      logger.debug("Found a colon exists expression: " + expr);
-    }
+    if (logger.isDebugEnabled()) logger.debug("Found a colon exists expression: " + expr);
     expr.getExistsExpression().apply(this);
     expr.getExistsPterm().apply(this);
   }
 
   public void caseAEtermExistsExpression(AEtermExistsExpression expr) {
-    if (logger.isDebugEnabled()) {
-      logger.debug("Found a colon exists expression: " + expr);
-    }
+    if (logger.isDebugEnabled()) logger.debug("Found a colon exists expression: " + expr);
     expr.getExistsPterm().apply(this);
   }
 
   public void caseAPtermExistsPterm(APtermExistsPterm rawTerm) {
-    if (logger.isDebugEnabled()) {
-      logger.debug("Found an Existential Predicate Term: " + rawTerm);
-    }
+    if (logger.isDebugEnabled()) logger.debug("Found an Existential Predicate Term: " + rawTerm);
 
     ObjectListBuilder builder = new ObjectListBuilder();
     rawTerm.getExistsOterm().apply(builder);
@@ -123,9 +112,7 @@
   }
 
   public void defaultCase(Node node) {
-    if (logger.isDebugEnabled()) {
-      logger.debug("Found node in pred builder: " + node + "::" + node.getClass());
-    }
+    if (logger.isDebugEnabled()) logger.debug("Found node in pred builder: " + node + "::" + node.getClass());
   }
 }
 

Modified: branches/nw-interface/src/jar/itql/java/org/mulgara/itql/CompoundPredicate.java
===================================================================
--- branches/nw-interface/src/jar/itql/java/org/mulgara/itql/CompoundPredicate.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/itql/java/org/mulgara/itql/CompoundPredicate.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -43,14 +43,12 @@
 package org.mulgara.itql;
 
 // Java 2 standard packages
-import java.util.ArrayList;
 import java.util.List;
 
 // Third party packages
-import org.apache.log4j.Logger; 
+// import org.apache.log4j.Logger; 
 
 // Generated packages
-import org.mulgara.itql.analysis.*;
 import org.mulgara.itql.node.*;
 
 /**
@@ -61,12 +59,6 @@
  *
  * @author Andrae Muys
  *
- * @version $Revision: 1.1.1.1 $
- *
- * @modified $Date: 2005/10/30 19:21:08 $ by $Author: prototypo $
- *
- * @maintenanceAuthor $Author: prototypo $
- *
  * @company <a href="mailto:mail at netymon.com">Netymon Pty Ltd</a>
  *
  * @copyright &copy;2006 Australian Commonwealth Government.
@@ -76,25 +68,21 @@
  */
 public class CompoundPredicate {
 
-  private final static Logger logger = Logger.getLogger(CompoundPredicate.class.getName());
+  // private final static Logger logger = Logger.getLogger(CompoundPredicate.class.getName());
 
   private PElement predicate;
-  private List objList;
+  private List<PElement> objList;
 
   /** Constructor */
-  public CompoundPredicate(PElement predicate, List objList) {
-    if (predicate == null) {
-      throw new IllegalArgumentException("predicate may not be null");
-    }
-    if (objList == null) {
-      throw new IllegalArgumentException("object list may not be null");
-    }
+  public CompoundPredicate(PElement predicate, List<PElement> objList) {
+    if (predicate == null) throw new IllegalArgumentException("predicate may not be null");
+    if (objList == null) throw new IllegalArgumentException("object list may not be null");
 
     this.predicate = predicate;
     this.objList = objList;
   }
 
-  public List getObjectList() {
+  public List<PElement> getObjectList() {
     return objList;
   }
 

Modified: branches/nw-interface/src/jar/itql/java/org/mulgara/itql/ConstraintExpressionBuilder.java
===================================================================
--- branches/nw-interface/src/jar/itql/java/org/mulgara/itql/ConstraintExpressionBuilder.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/itql/java/org/mulgara/itql/ConstraintExpressionBuilder.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -38,7 +38,6 @@
 // Java 2 standard packages
 import java.net.*;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
 // Third party packages
@@ -61,12 +60,6 @@
  *
  * @author Andrew Newman
  *
- * @version $Revision: 1.9 $
- *
- * @modified $Date: 2005/04/10 00:00:06 $ by $Author: pgearon $
- *
- * @maintenanceAuthor $Author: pgearon $
- *
  * @company <a href="mailto:info at PIsoftware.com">Plugged In Software</a>
  *
  * @copyright &copy;2004 <a href="http://www.pisoftware.com/">Plugged In
@@ -76,31 +69,20 @@
  */
 public class ConstraintExpressionBuilder extends AnalysisAdapter {
 
-  /**
-   * The logger
-   */
-  private final static Logger logger =
-      Logger.getLogger(ConstraintExpressionBuilder.class.getName());
+  /** The logger */
+  private final static Logger logger = Logger.getLogger(ConstraintExpressionBuilder.class.getName());
 
-  /**
-   * The internal result of parsing a constraint expression.
-   */
+  /** The internal result of parsing a constraint expression. */
   private ConstraintExpression constraintExpression = null;
 
-  /**
-   * URI Syntax Exception - not null if exception occurred since last get.
-   */
+  /** URI Syntax Exception - not null if exception occurred since last get. */
   private URISyntaxException uriException = null;
 
-  /**
-   * Query Exception - not null if exception occurred since last get.
-   */
+  /** Query Exception - not null if exception occurred since last get. */
   private QueryException queryException = null;
 
-  /**
-   * The iTQL interpreter
-   */
-  private Interpreter interpreter;
+  /** The iTQL interpreter */
+  private SableCCInterpreter interpreter;
 
   /**
    * Create a new builder.  Requires methods on the interpreter in order to
@@ -108,7 +90,7 @@
    *
    * @param newInterpreter the interpreter to use.
    */
-  public ConstraintExpressionBuilder(Interpreter newInterpreter) {
+  public ConstraintExpressionBuilder(SableCCInterpreter newInterpreter) {
     interpreter = newInterpreter;
   }
 
@@ -121,68 +103,53 @@
    * @throws URISyntaxException if the constraint contains a resource whose
    *     text violates <a href="http://www.isi.edu/in-notes/rfc2396.txt">RFC?2396</a>
    */
-  public ConstraintExpression getConstraintExpression() throws QueryException,
-      URISyntaxException {
+  public ConstraintExpression getConstraintExpression() throws QueryException, URISyntaxException {
     try {
       ConstraintExpression tmpExpression = constraintExpression;
 
       if (uriException != null) {
         throw uriException;
-      }
-      else if (queryException != null) {
+      } else if (queryException != null) {
         throw queryException;
-      }
-      else {
+      } else {
         return tmpExpression;
       }
-    }
-    finally {
+    } finally {
       uriException = null;
       queryException = null;
       constraintExpression = null;
     }
   }
 
+
   /**
    * Sets constraint expression.  Will set URIException or QueryException if
    * an exception occurs.
    *
    * @param newConstraintExpression the new expression.
    */
-  private void setConstraintExpression(ConstraintExpression
-      newConstraintExpression) {
+  private void setConstraintExpression(ConstraintExpression newConstraintExpression) {
     constraintExpression = newConstraintExpression;
   }
 
-  public void caseAConstraintConstraintFactor(
-      AConstraintConstraintFactor rawConstraintFactor) {
 
-    // log that we've got a constraint constraint factor
-    if (logger.isDebugEnabled()) {
-      logger.debug("Found constraint constraint factor " + rawConstraintFactor);
-    }
+  public void caseAConstraintConstraintFactor(AConstraintConstraintFactor rawConstraintFactor) {
 
+    if (logger.isDebugEnabled()) logger.debug("Found constraint constraint factor " + rawConstraintFactor);
+
     // get the constraint
-    PConstraint constraint =
-        ((AConstraintConstraintFactor) rawConstraintFactor).getConstraint();
+    PConstraint constraint = ((AConstraintConstraintFactor)rawConstraintFactor).getConstraint();
 
-    // log that we've found a constraint
-    if (logger.isDebugEnabled()) {
-      logger.debug("Found constraint " + constraint + ", resolving components");
-    }
+    if (logger.isDebugEnabled()) logger.debug("Found constraint " + constraint + ", resolving components");
 
     // get the constraint's components
     try {
       Constraint tmpConstraint;
 
-      ConstraintElement subject =
-          toConstraintElement(((AConstraint) constraint).getSubject());
-      ConstraintElement predicate =
-          toConstraintElement(((AConstraint) constraint).getPredicate());
-      ConstraintElement object =
-          toConstraintElement(((AConstraint) constraint).getObject());
+      ConstraintElement subject = toConstraintElement(((AConstraint)constraint).getSubject());
+      ConstraintElement predicate = toConstraintElement(((AConstraint)constraint).getPredicate());
+      ConstraintElement object = toConstraintElement(((AConstraint)constraint).getObject());
 
-      // log the components we've found
       if (logger.isDebugEnabled()) {
         logger.debug("Found subject " + subject);
         logger.debug("Found predicate " + predicate);
@@ -190,20 +157,15 @@
       }
 
       // check for an IN clause
-      AInClause inClause = (AInClause) ((AConstraint) constraint).getInClause();
+      AInClause inClause = (AInClause)((AConstraint)constraint).getInClause();
 
       // bundle them into a constraint (order is probably important here...?)
       if (inClause != null) {
-        if (logger.isDebugEnabled()) {
-          logger.debug("Found model " + inClause.getElement());
-        }
+        if (logger.isDebugEnabled()) logger.debug("Found model " + inClause.getElement());
 
-        ConstraintElement model =
-            toConstraintElement(inClause.getElement());
-        tmpConstraint =
-            ConstraintFactory.newConstraint(subject, predicate, object, model);
-      }
-      else {
+        ConstraintElement model = toConstraintElement(inClause.getElement());
+        tmpConstraint = ConstraintFactory.newConstraint(subject, predicate, object, model);
+      } else {
         tmpConstraint = ConstraintFactory.newConstraint(subject, predicate, object);
       }
 
@@ -213,95 +175,72 @@
       }
 
       // Set new value.
-      if (logger.isDebugEnabled()) {
-        logger.debug("Setting constraint: " + tmpConstraint);
-      }
+      if (logger.isDebugEnabled()) logger.debug("Setting constraint: " + tmpConstraint);
 
       setConstraintExpression(tmpConstraint);
-    }
-    catch (URISyntaxException use) {
+    } catch (URISyntaxException use) {
       uriException = use;
-    }
-    catch (QueryException qe) {
+    } catch (QueryException qe) {
       queryException = qe;
     }
   }
 
+
   /**
    * Handle a constraint expression.  Will set URIException or QueryException if
    * an exception occurs.
    *
-   * @param rawConstraintFactor the expression to create a constraint expression
-   *   from.
+   * @param rawConstraintFactor the expression to create a constraint expression from.
    */
-  public void caseAExpressionConstraintFactor(
-      AExpressionConstraintFactor rawConstraintFactor) {
+  public void caseAExpressionConstraintFactor(AExpressionConstraintFactor rawConstraintFactor) {
 
     try {
       ConstraintExpression tmpConstraintExpression;
 
-      // log that we've got an expression constraint factor
-      if (logger.isDebugEnabled()) {
-        logger.debug("Found factor expression constraint factor " +
-            rawConstraintFactor);
-      }
+      if (logger.isDebugEnabled()) logger.debug("Found factor expression constraint factor " + rawConstraintFactor);
 
       // get the constraint expression
       PConstraintExpression embeddedConstraintExpression =
-          ((AExpressionConstraintFactor) rawConstraintFactor).
-          getConstraintExpression();
+          ((AExpressionConstraintFactor)rawConstraintFactor).getConstraintExpression();
 
-      // log that we're recursing with a constraint expression
-      if (logger.isDebugEnabled()) {
-        logger.debug("Recursing with constraint factor " +
-            embeddedConstraintExpression);
-      }
+      if (logger.isDebugEnabled()) logger.debug("Recursing with constraint factor " + embeddedConstraintExpression);
 
       // build the constraint expression
-      ConstraintExpressionBuilder builder =
-          new ConstraintExpressionBuilder(interpreter);
+      ConstraintExpressionBuilder builder = new ConstraintExpressionBuilder(interpreter);
       embeddedConstraintExpression.apply((Switch) builder);
 
       tmpConstraintExpression = builder.getConstraintExpression();
 
       // handle negated expressions
       if (((AExpressionConstraintFactor) rawConstraintFactor).getExclude() != null) {
-        tmpConstraintExpression = new ConstraintNegation(
-            (Constraint) tmpConstraintExpression);
+        tmpConstraintExpression = new ConstraintNegation((Constraint)tmpConstraintExpression);
       }
 
       setConstraintExpression(tmpConstraintExpression);
-    }
-    catch (URISyntaxException use) {
+    } catch (URISyntaxException use) {
       uriException = use;
-    }
-    catch (QueryException qe) {
+    } catch (QueryException qe) {
       queryException = qe;
     }
   }
 
+
   /**
    * Handle a transitive constraint.  Will set URIException or QueryException if
    * an exception occurs.
    *
    * @param rawConstraintFactor a transitive constraint.
    */
-  public void caseATransitiveConstraintFactor(
-      ATransitiveConstraintFactor rawConstraintFactor) {
+  public void caseATransitiveConstraintFactor(ATransitiveConstraintFactor rawConstraintFactor) {
 
     try {
       ConstraintExpression tmpConstraintExpression = null;
 
-      // log that we've found a transitive predicate expression
-      if (logger.isDebugEnabled()) {
-        logger.debug("Found factor of transitive expression" +
-            rawConstraintFactor);
-      }
+      if (logger.isDebugEnabled()) logger.debug("Found factor of transitive expression" + rawConstraintFactor);
 
       // get the constraint transitive
       PTransitiveClause embeddedTransitiveConstraint =
-          ((ATransitiveConstraintFactor) rawConstraintFactor).
-          getTransitiveClause();
+          ((ATransitiveConstraintFactor) rawConstraintFactor).getTransitiveClause();
 
       if (embeddedTransitiveConstraint instanceof ATransitive1TransitiveClause) {
 
@@ -309,39 +248,32 @@
         tmpConstraintExpression = new SingleTransitiveConstraint(
             buildConstraint(((ATransitive1TransitiveClause)
             embeddedTransitiveConstraint).getConstraint()));
-      }
-      else if (embeddedTransitiveConstraint instanceof ATransitive2TransitiveClause) {
+      } else if (embeddedTransitiveConstraint instanceof ATransitive2TransitiveClause) {
 
         // build the transitive constraint expression
-        ATransitive2TransitiveClause tmpClause = (ATransitive2TransitiveClause)
-            embeddedTransitiveConstraint;
+        ATransitive2TransitiveClause tmpClause = (ATransitive2TransitiveClause)embeddedTransitiveConstraint;
         Constraint constraint1 = buildConstraint(tmpClause.getConstraint1());
         Constraint constraint2 = buildConstraint(tmpClause.getConstraint2());
-        tmpConstraintExpression = new TransitiveConstraint(constraint1,
-            constraint2);
+        tmpConstraintExpression = new TransitiveConstraint(constraint1, constraint2);
       }
 
       setConstraintExpression(tmpConstraintExpression);
-    }
-    catch (URISyntaxException use) {
+    } catch (URISyntaxException use) {
       uriException = use;
-    }
-    catch (QueryException qe) {
+    } catch (QueryException qe) {
       queryException = qe;
     }
   }
 
-   /*
+
+  /**
     * Handle a existential compound constraint.
     */
-   public void caseAExistentialConstraintFactor(
-       AExistentialConstraintFactor rawFactor) {
-    if (logger.isDebugEnabled()) {
-       logger.debug("Found existential - constraint factor " + rawFactor);
-     }
+   public void caseAExistentialConstraintFactor(AExistentialConstraintFactor rawFactor) {
+     if (logger.isDebugEnabled()) logger.debug("Found existential - constraint factor " + rawFactor);
      try {
        setConstraintExpression(
-         buildExistential(
+           buildExistential(
            interpreter.nextAnonVariable(),
            rawFactor.getExistsExpression(),
            (AInClause)rawFactor.getInClause()));
@@ -352,17 +284,15 @@
      }
    }
 
-   /*
+
+   /**
     * Handle a concrete compound constraint.
     */
-   public void caseACompoundConstraintFactor(
-       ACompoundConstraintFactor rawFactor) {
-     if (logger.isDebugEnabled()) {
-       logger.debug("Found compound - constraint factor " + rawFactor);
-     }
+   public void caseACompoundConstraintFactor(ACompoundConstraintFactor rawFactor) {
+     if (logger.isDebugEnabled()) logger.debug("Found compound - constraint factor " + rawFactor);
      try {
        setConstraintExpression(
-         buildExistential(
+           buildExistential(
            toConstraintElement(rawFactor.getSubject()),
            rawFactor.getExistsExpression(),
            (AInClause)rawFactor.getInClause()));
@@ -374,35 +304,25 @@
    }
            
    public ConstraintExpression buildExistential(ConstraintElement subject, PExistsExpression rawTerm, AInClause in)
-       throws URISyntaxException, QueryException
-   {
-     if (logger.isDebugEnabled()) {
-       logger.debug("building existential subject: " + subject + " term.class: " + rawTerm.getClass());
-     }
+       throws URISyntaxException, QueryException {
+
+     if (logger.isDebugEnabled()) logger.debug("building existential subject: " + subject + " term.class: " + rawTerm.getClass());
  
      CompoundPredListBuilder builder = new CompoundPredListBuilder();
      rawTerm.apply(builder);
  
-     if (logger.isDebugEnabled()) {
-       logger.debug("CompoundPredListBuilder built: " + builder.getPredLists());
-     }
+     if (logger.isDebugEnabled()) logger.debug("CompoundPredListBuilder built: " + builder.getPredLists());
  
-     ConstraintElement model = in == null ? null : toConstraintElement(in.getElement());
+     ConstraintElement model = (in == null) ? null : toConstraintElement(in.getElement());
  
      // forall predicates in list forall objects in pred's obj-list
      //    add new constraint(s,p,o) to argList.
-     List argList = new ArrayList();
+     List<ConstraintExpression> argList = new ArrayList<ConstraintExpression>();
  
-     Iterator p = builder.getPredLists().iterator();
-     while (p.hasNext()) {
-       CompoundPredicate plist = (CompoundPredicate)p.next();
- 
+     for (CompoundPredicate plist: builder.getPredLists()) {
        ConstraintElement predicate = toConstraintElement(plist.getPredicate());
  
-       Iterator o = plist.getObjectList().iterator();
-       while (o.hasNext()) {
-         PElement oelem = (PElement)o.next();
- 
+       for (PElement oelem: plist.getObjectList()) {
          ConstraintElement object = toConstraintElement(oelem);
  
          if (model == null) {
@@ -413,85 +333,68 @@
        }
      }
  
-     if (logger.isDebugEnabled()) {
-       logger.debug("Existential term = and(" + argList + ")");
-     }
+     if (logger.isDebugEnabled()) logger.debug("Existential term = and(" + argList + ")");
  
      return new ConstraintConjunction(argList);
    }
-                
-  /**
+
+
+   /**
    * Handle a walk constraint.
    *
    * @param rawConstraintFactor a walk constraint.
    */
-  public void caseAWalkConstraintFactor(AWalkConstraintFactor
-      rawConstraintFactor) {
+  public void caseAWalkConstraintFactor(AWalkConstraintFactor rawConstraintFactor) {
 
     try {
-
       // Build the walk constraint
-      AWalk1WalkClause embeddedWalkConstraint = (AWalk1WalkClause)
-          ((AWalkConstraintFactor) rawConstraintFactor).getWalkClause();
+      AWalk1WalkClause embeddedWalkConstraint =
+          (AWalk1WalkClause)((AWalkConstraintFactor)rawConstraintFactor).getWalkClause();
 
       ConstraintExpression tmpConstraintExpression = new WalkConstraint(
           buildConstraint(embeddedWalkConstraint.getConstraint1()),
           buildConstraint(embeddedWalkConstraint.getConstraint2()));
 
       setConstraintExpression(tmpConstraintExpression);
-    }
-    catch (URISyntaxException use) {
+    } catch (URISyntaxException use) {
       uriException = use;
-    }
-    catch (QueryException qe) {
+    } catch (QueryException qe) {
       queryException = qe;
     }
   }
 
+
   /**
    * Handle an OR constraint.  Will set URIException or QueryException if
    * an exception occurs.
    *
    * @param rawConstraintExpression an OR constraint.
    */
-  public void caseAOrConstraintExpression(
-      AOrConstraintExpression rawConstraintExpression) {
+  public void caseAOrConstraintExpression(AOrConstraintExpression rawConstraintExpression) {
 
     try {
+      if (logger.isDebugEnabled()) logger.debug("Found OR constraint expression " +rawConstraintExpression);
 
-      // log that we've found a OR constraint expression
-      if (logger.isDebugEnabled()) {
-        logger.debug("Found OR constraint expression " +
-            rawConstraintExpression);
-      }
-
       // get the OR constraint expression
       PConstraintExpression orConstraintExpression =
-          ((AOrConstraintExpression) rawConstraintExpression).
-          getConstraintExpression();
+          ((AOrConstraintExpression)rawConstraintExpression).getConstraintExpression();
 
       // get the constraint term
       PConstraintTerm constraintTerm =
-          ((AOrConstraintExpression) rawConstraintExpression).getConstraintTerm();
+          ((AOrConstraintExpression)rawConstraintExpression).getConstraintTerm();
 
-      // log that we've found the operands of the disjunction
-      if (logger.isDebugEnabled()) {
-        logger.debug("Recursing with constraint expression " +
-            orConstraintExpression + " & constraint term " +
-            constraintTerm);
-      }
+      if (logger.isDebugEnabled()) logger.debug("Recursing with constraint expression " +
+            orConstraintExpression + " & constraint term " + constraintTerm);
 
       // Construct a builder to process the constraints.
-      ConstraintExpressionBuilder builder =
-          new ConstraintExpressionBuilder(interpreter);
+      ConstraintExpressionBuilder builder = new ConstraintExpressionBuilder(interpreter);
 
       // get the LHS and RHS operands of the disjunction
-      orConstraintExpression.apply((Switch) builder);
+      orConstraintExpression.apply((Switch)builder);
       ConstraintExpression lhs = builder.getConstraintExpression();
-      constraintTerm.apply((Switch) builder);
+      constraintTerm.apply((Switch)builder);
       ConstraintExpression rhs = builder.getConstraintExpression();
 
-      // log that we've resolved the operands
       if (logger.isDebugEnabled()) {
         logger.debug("Resolved LHS disjunction operand " + lhs);
         logger.debug("Resolved RHS disjunction operand " + rhs);
@@ -499,11 +402,9 @@
 
       // apply the disjunction
       setConstraintExpression(new ConstraintDisjunction(lhs, rhs));
-    }
-    catch (URISyntaxException use) {
+    } catch (URISyntaxException use) {
       uriException = use;
-    }
-    catch (QueryException qe) {
+    } catch (QueryException qe) {
       queryException = qe;
     }
   }
@@ -514,86 +415,66 @@
    *
    * @param rawConstraintExpression a term constraint.
    */
-  public void caseATermConstraintExpression(
-      ATermConstraintExpression rawConstraintExpression) {
+  public void caseATermConstraintExpression(ATermConstraintExpression rawConstraintExpression) {
 
     try {
+      if (logger.isDebugEnabled()) logger.debug("Found term constraint expression " + rawConstraintExpression);
 
-      // log that we've got a term constraint expression
-      if (logger.isDebugEnabled()) {
-        logger.debug("Found term constraint expression " +
-            rawConstraintExpression);
-      }
-
       // get the constraint term
       PConstraintTerm constraintTerm =
-          ((ATermConstraintExpression) rawConstraintExpression).
-          getConstraintTerm();
+          ((ATermConstraintExpression) rawConstraintExpression).getConstraintTerm();
 
-      // log that we're about to resolve the term into an expression
-      if (logger.isDebugEnabled()) {
-        logger.debug("Recursing with constraint term " + constraintTerm);
-      }
+      if (logger.isDebugEnabled()) logger.debug("Recursing with constraint term " + constraintTerm);
 
       // Create a new builder.
-      ConstraintExpressionBuilder builder =
-          new ConstraintExpressionBuilder(interpreter);
-      constraintTerm.apply((Switch) builder);
+      ConstraintExpressionBuilder builder = new ConstraintExpressionBuilder(interpreter);
+      constraintTerm.apply((Switch)builder);
 
       // drill down into the constraint term
       setConstraintExpression(builder.getConstraintExpression());
-    }
-    catch (URISyntaxException use) {
+    } catch (URISyntaxException use) {
       uriException = use;
-    }
-    catch (QueryException qe) {
+    } catch (QueryException qe) {
       queryException = qe;
     }
   }
 
+
   /**
    * Handle a dterm constraint term.  Will set URIException or QueryException
    * if an exception occurs.
    *
    * @param rawConstraintTerm a dterm constraint term.
    */
-  public void caseADtermConstraintTerm(
-      ADtermConstraintTerm rawConstraintTerm) {
+  public void caseADtermConstraintTerm(ADtermConstraintTerm rawConstraintTerm) {
 
     try {
+      if (logger.isDebugEnabled()) logger.debug("Found dterm contraint term " + rawConstraintTerm);
 
-      // log that we've got a dterm constraint term
-      if (logger.isDebugEnabled()) {
-        logger.debug("Found dterm contraint term " + rawConstraintTerm);
-      }
-
       // get the constraint factor
       PConstraintDterm constraintDterm =
-          ((ADtermConstraintTerm) rawConstraintTerm).getConstraintDterm();
+          ((ADtermConstraintTerm)rawConstraintTerm).getConstraintDterm();
 
       ConstraintExpression tmpConstraintExpression = null;
 
       // drill down into the constraint factor
-      ConstraintExpressionBuilder builder =
-          new ConstraintExpressionBuilder(interpreter);
-      constraintDterm.apply((Switch) builder);
+      ConstraintExpressionBuilder builder = new ConstraintExpressionBuilder(interpreter);
+      constraintDterm.apply((Switch)builder);
       tmpConstraintExpression = builder.getConstraintExpression();
       setConstraintExpression(tmpConstraintExpression);
 
-      // log that we're recursing with a constraint factor
       if (logger.isDebugEnabled()) {
         logger.debug("Recursing with constraint factor " + constraintDterm);
         logger.debug("Got: " + tmpConstraintExpression);
       }
-    }
-    catch (URISyntaxException use) {
+    } catch (URISyntaxException use) {
       uriException = use;
-    }
-    catch (QueryException qe) {
+    } catch (QueryException qe) {
       queryException = qe;
     }
   }
 
+
   /**
    * Handle a AND constraint term.  Will set URIException or QueryException if
    * an exception occurs.
@@ -604,10 +485,7 @@
 
     try {
 
-      // log that we've got a AND constraint term
-      if (logger.isDebugEnabled()) {
-        logger.debug("Found AND contraint term " + rawConstraintTerm);
-      }
+      if (logger.isDebugEnabled()) logger.debug("Found AND contraint term " + rawConstraintTerm);
 
       // get the constraint term
       PConstraintTerm constraintTerm =
@@ -617,24 +495,19 @@
       PConstraintDterm constraintDterm =
           ((AAndConstraintTerm) rawConstraintTerm).getConstraintDterm();
 
-      // log that we've found the operands of the disjunction
-      if (logger.isDebugEnabled()) {
-        logger.debug("Recursing with constraint term " + constraintTerm +
+      if (logger.isDebugEnabled()) logger.debug("Recursing with constraint term " + constraintTerm +
             " & constraint factor " + constraintDterm);
-      }
 
-      ConstraintExpressionBuilder builder =
-          new ConstraintExpressionBuilder(interpreter);
+      ConstraintExpressionBuilder builder = new ConstraintExpressionBuilder(interpreter);
 
       // get the LHS and RHS operands of the conjunction
-      constraintTerm.apply((Switch) builder);
+      constraintTerm.apply((Switch)builder);
       ConstraintExpression lhs = builder.getConstraintExpression();
 
       // Create another constraint builder and assign to RHS.
       constraintDterm.apply((Switch) builder);
       ConstraintExpression rhs = builder.getConstraintExpression();
 
-      // log that we've resolved the operands
       if (logger.isDebugEnabled()) {
         logger.debug("Resolved LHS conjunction operand " + lhs);
         logger.debug("Resolved RHS conjunction operand " + rhs);
@@ -642,27 +515,24 @@
 
       // apply the conjunction
       setConstraintExpression(new ConstraintConjunction(lhs, rhs));
-    }
-    catch (URISyntaxException use) {
+
+    } catch (URISyntaxException use) {
       uriException = use;
-    }
-    catch (QueryException qe) {
+    } catch (QueryException qe) {
       queryException = qe;
     }
   }
 
+
   /**
    * Handle a factor constraint dterm.  Will set URIException or QueryException
    * if an exception occurs.
    *
    * @param rawConstraintTerm a factor constraint dterm.
    */
-  public void caseAFactorConstraintDterm(
-      AFactorConstraintDterm rawConstraintTerm) {
+  public void caseAFactorConstraintDterm(AFactorConstraintDterm rawConstraintTerm) {
 
     try {
-
-      // log that we've got a factor constraint term
       logger.debug("Found factor contraint term " + rawConstraintTerm);
 
       // get the constraint factor
@@ -678,16 +548,13 @@
       tmpConstraintExpression = builder.getConstraintExpression();
       setConstraintExpression(tmpConstraintExpression);
 
-      // log that we're recursing with a constraint factor
       if (logger.isDebugEnabled()) {
         logger.debug("Recursing with constraint factor " + constraintFactor);
         logger.debug("Got: " + tmpConstraintExpression);
       }
-    }
-    catch (URISyntaxException use) {
+    } catch (URISyntaxException use) {
       uriException = use;
-    }
-    catch (QueryException qe) {
+    } catch (QueryException qe) {
       queryException = qe;
     }
   }
@@ -699,14 +566,10 @@
    * @param rawConstraintTerm a MINUS constraint dterm.
    */
   public void caseAMinusConstraintDterm(AMinusConstraintDterm rawConstraintTerm) {
-    // TODO
 
     try {
 
-      // log that we've got a MINUS constraint dterm
-      if (logger.isDebugEnabled()) {
-        logger.debug("Found MINUS contraint dterm " + rawConstraintTerm);
-      }
+      if (logger.isDebugEnabled()) logger.debug("Found MINUS contraint dterm " + rawConstraintTerm);
 
       // get the minuend expression
       PConstraintDterm minuendExpr =
@@ -716,24 +579,20 @@
       PConstraintFactor subtrahendExpr =
           ((AMinusConstraintDterm) rawConstraintTerm).getSubtrahend();
 
-      // log that we've found the operands of the subtraction
       if (logger.isDebugEnabled()) {
-        logger.debug("Recursing with minuend " + minuendExpr +
-            " & subtrahend " + subtrahendExpr);
+        logger.debug("Recursing with minuend " + minuendExpr + " & subtrahend " + subtrahendExpr);
       }
 
-      ConstraintExpressionBuilder builder =
-          new ConstraintExpressionBuilder(interpreter);
+      ConstraintExpressionBuilder builder = new ConstraintExpressionBuilder(interpreter);
 
       // get the LHS and RHS operands of the conjunction
-      minuendExpr.apply((Switch) builder);
+      minuendExpr.apply((Switch)builder);
       ConstraintExpression minuend = builder.getConstraintExpression();
 
       // Create another constraint builder and assign to RHS.
-      subtrahendExpr.apply((Switch) builder);
+      subtrahendExpr.apply((Switch)builder);
       ConstraintExpression subtrahend = builder.getConstraintExpression();
 
-      // log that we've resolved the operands
       if (logger.isDebugEnabled()) {
         logger.debug("Resolved minuend operand " + minuend);
         logger.debug("Resolved subtrahend operand " + subtrahend);
@@ -741,15 +600,14 @@
 
       // apply the conjunction
       setConstraintExpression(new ConstraintDifference(minuend, subtrahend));
-    }
-    catch (URISyntaxException use) {
+    } catch (URISyntaxException use) {
       uriException = use;
-    }
-    catch (QueryException qe) {
+    } catch (QueryException qe) {
       queryException = qe;
     }
   }
 
+
   /**
    * Helper method used to build up a Constraint object from a SableCC
    * PConstraint object.
@@ -761,10 +619,7 @@
   Constraint buildConstraint(PConstraint pconstraint) throws QueryException,
       URISyntaxException {
 
-    // log that we've found a constraint
-    if (logger.isDebugEnabled()) {
-      logger.debug("Found constraint " + pconstraint + ", resolving components");
-    }
+    if (logger.isDebugEnabled()) logger.debug("Found constraint " + pconstraint + ", resolving components");
 
     // get the constraint's components
     ConstraintElement subject =
@@ -774,7 +629,6 @@
     ConstraintElement object =
         toConstraintElement(((AConstraint) pconstraint).getObject());
 
-    // log the components we've found
     if (logger.isDebugEnabled()) {
       logger.debug("Found subject " + subject);
       logger.debug("Found predicate " + predicate);
@@ -782,7 +636,7 @@
     }
 
     // check for an IN - this is illegal
-    if (((AConstraint) pconstraint).getInClause() != null) {
+    if (((AConstraint)pconstraint).getInClause() != null) {
       throw new QueryException("Illegal in clause on transitive constraint.");
     }
 
@@ -790,6 +644,7 @@
     return ConstraintFactory.newConstraint(subject, predicate, object);
   }
 
+
   /**
    * Constructs a {@link org.mulgara.query.ConstraintElement} from a
    * {@link org.mulgara.itql.node.PElement}.
@@ -805,18 +660,12 @@
    *      conform to
    *      <a href="http://www.isi.edu/in-notes/rfc2396.txt">RFC 2396</a>
    */
-  private ConstraintElement toConstraintElement(PElement element) throws
-      QueryException, URISyntaxException {
+  private ConstraintElement toConstraintElement(PElement element) throws QueryException, URISyntaxException {
 
     // validate the element parameter
-    if (element == null) {
-      throw new IllegalArgumentException("Null \"element\" parameter");
-    }
+    if (element == null) throw new IllegalArgumentException("Null \"element\" parameter");
 
-    // log what we're doing
-    if (logger.isDebugEnabled()) {
-      logger.debug("Resolving " + element + "to a constraint element");
-    }
+    if (logger.isDebugEnabled()) logger.debug("Resolving " + element + "to a constraint element");
 
     // create a constraint element to return
     ConstraintElement constraintElement = null;
@@ -828,22 +677,19 @@
       PVariable rawVariable = ((AVariableElement) element).getVariable();
       String variableName = ((AVariable) rawVariable).getIdentifier().getText();
 
-      // log what we're doing
-      if (logger.isDebugEnabled()) {
-        logger.debug("Resolved " + element + " to variable " + variableName);
-      }
+      if (logger.isDebugEnabled()) logger.debug("Resolved " + element + " to variable " + variableName);
 
       // create a new variable
       constraintElement = new Variable(variableName);
-    }
-    else if (element instanceof AResourceElement) {
 
+    } else if (element instanceof AResourceElement) {
+
       // create a new resource
       constraintElement = new URIReferenceImpl(interpreter.toURI(
           ((AResourceElement) element).getResource()));
-    }
-    else if (element instanceof ALiteralElement) {
 
+    } else if (element instanceof ALiteralElement) {
+
       // create a new literal
       constraintElement = interpreter.toLiteralImpl(((ALiteralElement) element).
           getLiteral());

Deleted: branches/nw-interface/src/jar/itql/java/org/mulgara/itql/Interpreter.java
===================================================================
--- branches/nw-interface/src/jar/itql/java/org/mulgara/itql/Interpreter.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/itql/java/org/mulgara/itql/Interpreter.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -1,110 +0,0 @@
-package org.mulgara.itql;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import org.mulgara.itql.node.PLiteral;
-import org.mulgara.itql.node.TResource;
-import org.mulgara.itql.node.Token;
-import org.mulgara.query.Query;
-import org.mulgara.query.QueryException;
-import org.mulgara.query.Variable;
-import org.mulgara.query.rdf.LiteralImpl;
-
-
-/**
- * This interface defines the namespaces used while interpreting RDF code.
- * @author pag
- *
- */
-public interface Interpreter {
-
-  //
-  // Constants
-  //
-  /** The rdf namespace prefix. */
-  public static final String RDF = "rdf";
-
-  /** The rdfs namespace prefix. */
-  public static final String RDFS = "rdfs";
-
-  /** The owl namespace prefix. */
-  public static final String OWL = "owl";
-
-  /** The mulgara namespace prefix. */
-  public static final String MULGARA = "mulgara";
-
-  /** The krule namespace prefix. */
-  public static final String KRULE = "krule";
-
-  /** The Dublin Core namespace prefix. */
-  public static final String DC = "dc";
-
-  /** The URI of the rdf namespace. */
-  public static final String RDF_NS = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
-
-  /** The URI of the rdfs namespace. */
-  public static final String RDFS_NS = "http://www.w3.org/2000/01/rdf-schema#";
-
-  /** The URI of the owl namespace. */
-  public static final String OWL_NS = "http://www.w3.org/2002/07/owl#";
-
-  /** The URI of the mulgara namespace. */
-  public static final String MULGARA_NS = "http://mulgara.org/mulgara#";
-
-  /** The URI of the krule namespace. */
-  public static final String KRULE_NS = "http://mulgara.org/owl/krule/#";
-
-  /** The URI of the dc namespace. */
-  public static final String DC_NS = "http://purl.org/dc/elements/1.1/";
-
-  /**
-   * Construct a {@link LiteralImpl} from a {@link PLiteral}.
-   *
-   * @param p  the instance to convert
-   */
-  public LiteralImpl toLiteralImpl(PLiteral p);
-
-  /**
-   * Returns an anonymous variable unique for this interpreter.
-   * Note: We really should introduce a new subclass of Variable
-   * that is explicitly anonymous, but for now this will do.
-   */
-  public Variable nextAnonVariable();
-
-  /**
-   * Executes a query and returns its results.
-   *
-   * @param rawQuery a select query, represented as either a {@link
-   *      org.mulgara.itql.node.ASelectCommand} or a {@link
-   *      org.mulgara.itql.node.ASelectSetOfTriples}
-   * @return the answer to the query
-   * @throws QueryException if the query cannot be executed
-   * @throws URISyntaxException if the <code>query</code> contains a resource
-   *      whose text violates <a href="http://www.isi.edu/in-notes/rfc2396.txt">
-   *      RFC\uFFFD2396</a>
-   */
-  public Query buildQuery(org.mulgara.itql.node.Node rawQuery) throws QueryException,
-      URISyntaxException;
-
-  /**
-   * Convert SableCC-generated {@link TResource} tokens into {@link URI}s.
-   *
-   * Resolution will treat the token as an XML
-   * <a href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">qualified
-   * names</a> if the {@link #aliasMap} <code>aliasMap</code> contains a key
-   * for the URI scheme part that can be treated as an XML namespace prefix.
-   * For example, <kbd>dc:title</kbd> is treated as a qname and mapped to the
-   * to the URI <kbd>http://purl.org/dc/elements/1.1/title</kbd>, assuming the
-   * {@link #aliasMap} had an entry mapping <code>"dc"</code> to the Dublin
-   * Core namespace.
-   *
-   * @param token  the token to be converted, which should actually be a
-   *   {@link TResource}
-   * @throws Error if the <var>token</var> text isn't syntactically
-   *   a {@link URI}; this shouldn't ever occur, assuming the <var>token</var>
-   *   is a {@link TResource}
-   */
-  URI toURI(Token token);
-
-}
\ No newline at end of file

Modified: branches/nw-interface/src/jar/itql/java/org/mulgara/itql/ItqlInterpreter.java
===================================================================
--- branches/nw-interface/src/jar/itql/java/org/mulgara/itql/ItqlInterpreter.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/itql/java/org/mulgara/itql/ItqlInterpreter.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -54,7 +54,10 @@
 import org.mulgara.itql.lexer.*;
 import org.mulgara.itql.node.*;
 import org.mulgara.itql.parser.*;
+import org.mulgara.parser.MulgaraLexerException;
+import org.mulgara.parser.MulgaraParserException;
 import org.mulgara.query.*;
+import org.mulgara.query.ast.Command;
 import org.mulgara.query.rdf.*;
 import org.mulgara.rules.*;
 import org.mulgara.server.NonRemoteSessionException;
@@ -82,49 +85,13 @@
  * @author Simon Raboczi
  * @author Tom Adams
  * @author Paul Gearon
- * @version $Revision: 1.12 $
- * @modified $Date: 2005/07/03 12:52:07 $ by $Author: pgearon $
- * @maintenanceAuthor $Author: pgearon $
  * @company <a href="mailto:info at PIsoftware.com">Plugged In Software</a>
  * @copyright &copy;2001-2004 <a href="http://www.tucanatech.com/">Tucana Technologies, Inc.</a>
  * @copyright &copy;2005 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
  * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
  */
-public class ItqlInterpreter extends DepthFirstAdapter implements Interpreter {
+public class ItqlInterpreter extends DepthFirstAdapter implements SableCCInterpreter {
 
-  //
-  // Constants
-  //
-  /** The rdf namespace prefix. */
-  public static final String RDF = "rdf";
-    
-  /** The rdfs namespace prefix. */
-  public static final String RDFS = "rdfs";
-    
-  /** The owl namespace prefix. */
-  public static final String OWL = "owl";
-    
-  /** The mulgara namespace prefix. */
-  public static final String MULGARA = "mulgara";
-    
-  /** The krule namespace prefix. */
-  public static final String KRULE = "krule";
-    
-  /** The URI of the rdf namespace. */
-  public static final String RDF_NS = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
-    
-  /** The URI of the rdfs namespace. */
-  public static final String RDFS_NS = "http://www.w3.org/2000/01/rdf-schema#";
-    
-  /** The URI of the owl namespace. */
-  public static final String OWL_NS = "http://www.w3.org/2002/07/owl#";
-    
-  /** The URI of the mulgara namespace. */
-  public static final String MULGARA_NS = "http://mulgara.org/mulgara#";
-    
-  /** The URI of the krule namespace. */
-  public static final String KRULE_NS = "http://mulgara.org/owl/krule/#";
-
   /**
    * Get line separator.
    */
@@ -506,13 +473,13 @@
    * Executes the given ITQL command.
    *
    * @param command the command to execute in ITQL syntax
-   * @throws ParserException if the syntax of the command is incorrect
+   * @throws MulgaraParserException if the syntax of the command is incorrect
    * @throws LexerException if the syntax of the command is incorrect
    * @throws IOException if the <var>command</var> cannot be paersed
    * @throws IllegalArgumentException if the <var>command</var> is
    *   <code>null</code>
    */
-  public void executeCommand(String command) throws ParserException,
+  public void executeCommand(String command) throws MulgaraParserException,
       LexerException, Exception {
 
     this.setLastError(null);
@@ -547,17 +514,15 @@
       try {
         Parser parser = new Parser(lexer);
         commandTree = parser.parse();
-      }
-      catch (ParserException pe) {
+      } catch (ParserException pe) {
 
         // let the user know the problem
         this.setLastError(pe);
         this.setLastAnswer(null);
         this.setLastMessage("Syntax error " + EOL + this.getCause(pe, 2));
         flush();
-        throw pe;
-      }
-      catch (LexerException le) {
+        throw new MulgaraParserException(pe);
+      } catch (LexerException le) {
 
         // let the user know the problem
         this.setLastError(le);
@@ -570,12 +535,10 @@
       // execute the command
       try {
         commandTree.apply(this);
-      }
-      catch (Exception e) {
+      } catch (Exception e) {
         flush();
         throw e;
-      }
-      catch (Error e) {
+      } catch (Error e) {
 
         flush();
         throw e;
@@ -599,16 +562,46 @@
   // isQuitRequested()
 
   /**
+   * Parses the given TQL command.  This implementation only understands Query commands.
+   *
+   * @param command the command to parse in TQL syntax
+   * @return An AST for the command
+   * @throws MulgaraParserException if the syntax of the command is incorrect
+   * @throws MulgaraLexerException if the syntax of the command is incorrect
+   * @throws IOException if the <var>command</var> cannot be paersed
+   * @throws IllegalArgumentException if the <var>command</var> is <code>null</code>
+   */
+  public Command parseCommand(String command) throws MulgaraParserException, MulgaraLexerException, Exception {
+    return parseQuery(command);
+  }
+
+
+  /**
+   * Parses the given TQL command.
+   *
+   * @param command the command to parse in TQL syntax
+   * @return A {@link List} of ASTs, one for each command
+   * @throws MulgaraParserException if the syntax of the command is incorrect
+   * @throws MulgaraLexerException if the syntax of the command is incorrect
+   * @throws IOException if the <var>command</var> cannot be paersed
+   * @throws IllegalArgumentException if the <var>command</var> is <code>null</code>
+   */
+  public List<Command> parseCommands(String command) throws MulgaraParserException, MulgaraLexerException, Exception {
+    throw new UnsupportedOperationException("Commands are not supported in this interface");
+  }
+
+
+  /**
    * Parse a string into a {@link Query}.
    *
    * @param queryString a string containing an ITQL query
    * @return the corresponding {@link Query} instance
    * @throws IOException if <var>queryString</var> can't be buffered.
    * @throws LexerException if <var>queryString</var> can't be tokenized.
-   * @throws ParserException if <var>queryString</var> is not syntactic.
+   * @throws MulgaraParserException if <var>queryString</var> is not syntactic.
    */
   public Query parseQuery(String queryString) throws IOException,
-      LexerException, ParserException {
+      MulgaraLexerException, MulgaraParserException {
 
     if (queryString == null) {
       throw new IllegalArgumentException("Null \"queryString\" parameter");
@@ -631,13 +624,16 @@
     try {
       executeQuery = false;
       parser.parse().apply(this);
-    }
-    finally {
+    } catch (LexerException le) {
+      throw new MulgaraLexerException(le);
+    } catch (ParserException le) {
+      throw new MulgaraParserException(le);
+    } finally {
       executeQuery = true;
     }
 
     if (lastQuery == null) {
-      throw new ParserException(null, "Parameter was not a query");
+      throw new MulgaraParserException("Parameter was not a query");
     }
 
     // return the results of the command
@@ -1927,7 +1923,7 @@
       resultsMsg.append("Completed execution of script " + resource);
       this.setLastMessage(resultsMsg.toString());
     }
-    catch (ParserException pe) {
+    catch (MulgaraParserException pe) {
 
       // let the user know the problem
       this.setLastError(pe);

Modified: branches/nw-interface/src/jar/itql/java/org/mulgara/itql/ItqlInterpreterBean.java
===================================================================
--- branches/nw-interface/src/jar/itql/java/org/mulgara/itql/ItqlInterpreterBean.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/itql/java/org/mulgara/itql/ItqlInterpreterBean.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -45,6 +45,8 @@
 // Mulgara packages
 import org.mulgara.itql.lexer.LexerException;
 import org.mulgara.itql.parser.ParserException;
+import org.mulgara.parser.MulgaraLexerException;
+import org.mulgara.parser.MulgaraParserException;
 import org.mulgara.query.Answer;
 import org.mulgara.query.Query;
 import org.mulgara.query.QueryException;
@@ -611,8 +613,7 @@
    * @throws ParserException if the <var>query</var> is not syntactically
    *      correct
    */
-  public Query buildQuery(String query) throws IOException, LexerException,
-      ParserException {
+  public Query buildQuery(String query) throws IOException, MulgaraLexerException, MulgaraParserException {
 
     // defer to the interpreter
     return this.interpreter.parseQuery(query);

Modified: branches/nw-interface/src/jar/itql/java/org/mulgara/itql/ItqlInterpreterUnitTest.java
===================================================================
--- branches/nw-interface/src/jar/itql/java/org/mulgara/itql/ItqlInterpreterUnitTest.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/itql/java/org/mulgara/itql/ItqlInterpreterUnitTest.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -44,6 +44,7 @@
 
 // automagically generated classes
 import org.mulgara.itql.parser.ParserException;
+import org.mulgara.parser.MulgaraParserException;
 import org.mulgara.query.Answer;
 import org.mulgara.query.AnswerImpl;
 import org.mulgara.query.Constraint;
@@ -1057,7 +1058,7 @@
    * Test the interpreter using a delete statement. Executes the following query:
    * <pre>
    *   delete $s $p $o from &lt;rmi://localhost/database#model&gt; ;
-   * </pre> Expects results: ParserException
+   * </pre> Expects results: MulgaraParserException
    *
    * @throws Exception if the test fails
    */
@@ -1097,7 +1098,7 @@
    * Test the interpreter using a delete statement. Executes the following query:
    * <pre>
    *   delete $s <urn:foo:bar> $o from &lt;rmi://localhost/database#model&gt; ;
-   * </pre> Expects results: ParserException
+   * </pre> Expects results: MulgaraParserException
    *
    * @throws Exception if the test fails
    */
@@ -1137,7 +1138,7 @@
    * Test the interpreter using a directory statement. Executes the following
    * query: <pre>
    *   directory &lt;beep://rns.site1.net:7000/models&gt; ;
-   * </pre> Expects results: ParserException
+   * </pre> Expects results: MulgaraParserException
    *
    * @throws Exception if the test fails
    */
@@ -1171,7 +1172,7 @@
    * Test the interpreter using a create statement. Executes the following
    * query: <pre>
    *   create &lt;mulgara://localhost/database&gt; ;
-   * </pre> Expects results: ParserException
+   * </pre> Expects results: MulgaraParserException
    *
    * @throws Exception if the test fails
    */
@@ -1205,7 +1206,7 @@
    * Test the interpreter using a create statement. Executes the following
    * query: <pre>
    *   create &lt;mulgara://localhost/database#model&gt; ;
-   * </pre> Expects results: ParserException
+   * </pre> Expects results: MulgaraParserException
    *
    * @throws Exception if the test fails
    */
@@ -1239,7 +1240,7 @@
    * Test the interpreter using a drop statement. Executes the following query:
    * <pre>
    *   drop &lt;mulgara://localhost/database#model&gt; ;
-   * </pre> Expects results: ParserException
+   * </pre> Expects results: MulgaraParserException
    *
    * @throws Exception if the test fails
    */
@@ -1273,7 +1274,7 @@
    * Test the interpreter using a drop statement. Executes the following query:
    * <pre>
    *   drop &lt;mulgara://localhost/database#model&gt; ;
-   * </pre> Expects results: ParserException
+   * </pre> Expects results: MulgaraParserException
    *
    * @throws Exception if the test fails
    */
@@ -1365,7 +1366,7 @@
    * <pre>
    *   load &lt;http://purl.org/dc/elements/1.1&gt; into
    *       &lt;mulgara://localhost/database#model&gt; ;
-   * </pre> Expects results: ParserException
+   * </pre> Expects results: MulgaraParserException
    *
    * @throws Exception if the test fails
    */
@@ -1401,7 +1402,7 @@
    * <pre>
    *   load &lt;file:<it>mulgarahome</it> /data/dc.rdfs&gt; into
    * &lt;mulgara://localhost/database&gt; ; </pre> Expects results:
-   * ParserException
+   * MulgaraParserException
    *
    * @throws Exception if the test fails
    */
@@ -1437,7 +1438,7 @@
    * <pre>
    *   load &lt;file:<it>mulgarahome</it> /data/dc.rdfs&gt; into
    * &lt;mulgara://localhost/database#model&gt; ; </pre> Expects results:
-   * ParserException
+   * MulgaraParserException
    *
    * @throws Exception if the test fails
    */
@@ -1472,7 +1473,7 @@
    * <pre>
    *   load as rdf &lt;http://<it>dchost</it> /<it>path</it> /dc.rdfs&gt; into
    * &lt;mulgara://localhost/database#model&gt; ; </pre> Expects results:
-   * ParserException
+   * MulgaraParserException
    *
    * @throws Exception if the test fails
    */
@@ -1508,7 +1509,7 @@
    * <pre>
    *   load as rdf &lt;file:<it>mulgarahome</it> /data/dc.rdfs&gt; into
    * &lt;mulgara://localhost/database&gt; ; </pre> Expects results:
-   * ParserException
+   * MulgaraParserException
    *
    * @throws Exception if the test fails
    */
@@ -1544,7 +1545,7 @@
    * <pre>
    *   load as rdf &lt;file:<it>mulgarahome</it> /data/dc.rdfs&gt; into
    * &lt;mulgara://localhost/database#model&gt; ; </pre> Expects results:
-   * ParserException
+   * MulgaraParserException
    *
    * @throws Exception if the test fails
    */
@@ -1580,7 +1581,7 @@
    * <pre>
    *   load as serial &lt;http://<it>dchost</it> /<it>path</it> /<it>database
    * </it>&gt; into &lt;mulgara://localhost/database#model&gt; ; </pre> Expects
-   * results: ParserException
+   * results: MulgaraParserException
    *
    * @throws Exception if the test fails
    */
@@ -1617,7 +1618,7 @@
    * <pre>
    *   load as serial &lt;file:<it>mulgarahome</it> /data/<it>database</it> &gt;
    * into &lt;mulgara://localhost/database&gt; ; </pre> Expects results:
-   * ParserException
+   * MulgaraParserException
    *
    * @throws Exception if the test fails
    */
@@ -1653,7 +1654,7 @@
    * <pre>
    *   load as serial &lt;file:<it>mulgarahome</it> /<it>database</it> &gt; into
    * &lt;mulgara://localhost/database#model&gt; ; </pre> Expects results:
-   * ParserException
+   * MulgaraParserException
    *
    * @throws Exception if the test fails
    */
@@ -1986,7 +1987,7 @@
 
   /**
    * Test #2 for {@link ItqlInterpreter#parseQuery}. Non-queries should return a
-   * {@link ParserException}.
+   * {@link MulgaraParserException}.
    *
    * @throws Exception EXCEPTION TO DO
    */
@@ -1999,8 +2000,7 @@
       String notAQuery = "quit";
       Query query = interpreter.parseQuery(notAQuery);
       fail("\"" + notAQuery + "\" erroneously parsed as \"" + query + "\"");
-    }
-    catch (ParserException e) {
+    } catch (MulgaraParserException e) {
 
       // this is the correct response
     }
@@ -2128,7 +2128,7 @@
    * Test the interpreter using a create statement. Executes the following
    * query: <pre>
    *   create &lt;mulgara://localhost/database&gt; ;
-   * </pre> Expects results: ParserException
+   * </pre> Expects results: MulgaraParserException
    *
    * @throws Exception if the test fails
    */

Modified: branches/nw-interface/src/jar/itql/java/org/mulgara/itql/TqlInterpreter.java
===================================================================
--- branches/nw-interface/src/jar/itql/java/org/mulgara/itql/TqlInterpreter.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/itql/java/org/mulgara/itql/TqlInterpreter.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -1,36 +1,13 @@
-/*
- * 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
+/**
+ * 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.mozilla.org/MPL/
+ * http://www.opensource.org/licenses/osl-3.0.txt
  *
  * Software distributed under the License is distributed on an "AS IS"
  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
  * the License for the specific language governing rights and limitations
  * under the License.
- *
- * The Original Code is the Kowari Metadata Store.
- *
- * 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):
- *  Copywrite in the anon-variable support:
- *  The Australian Commonwealth Government
- *  Department of Defense
- *  Developed by Netymon Pty Ltd
- *  under contract 4500507038
- *  contributed to the Mulgara Project under the 
- *    Mozilla Public License version 1.1
- *  per clause 4.1.3 and 4.1.4 of the above contract.
- *
- * [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.]
- *
  */
 
 package org.mulgara.itql;
@@ -51,6 +28,9 @@
 import org.mulgara.itql.lexer.*;
 import org.mulgara.itql.node.*;
 import org.mulgara.itql.parser.*;
+import org.mulgara.parser.Interpreter;
+import org.mulgara.parser.MulgaraLexerException;
+import org.mulgara.parser.MulgaraParserException;
 import org.mulgara.query.*;
 import org.mulgara.query.ast.ApplyRules;
 import org.mulgara.query.ast.Backup;
@@ -87,7 +67,7 @@
  * @copyright &copy;2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
  * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
  */
-public class TqlInterpreter extends DepthFirstAdapter implements Interpreter {
+public class TqlInterpreter extends DepthFirstAdapter implements SableCCInterpreter {
 
   /** The logger */
   static final Logger logger = Logger.getLogger(TqlInterpreter.class.getName());
@@ -183,12 +163,12 @@
    *
    * @param command the command to parse in TQL syntax
    * @return An AST for the command
-   * @throws ParserException if the syntax of the command is incorrect
+   * @throws MulgaraParserException if the syntax of the command is incorrect
    * @throws LexerException if the syntax of the command is incorrect
-   * @throws IOException if the <var>command</var> cannot be paersed
+   * @throws IOException if the <var>command</var> cannot be parsed
    * @throws IllegalArgumentException if the <var>command</var> is <code>null</code>
    */
-  public Command parseCommand(String command) throws ParserException, LexerException, Exception {
+  public Command parseCommand(String command) throws MulgaraParserException, LexerException, Exception {
 
     // validate command parameter
     if ((command == null) || command.equals("")) {
@@ -207,9 +187,7 @@
     this.logItql(command);
     lexer.add(command);
     // test that this is a single command
-    if (lexer.getCommandCount() > 1) {
-      logger.warn("Multiple commands given to parser");
-    }
+    if (lexer.getCommandCount() > 1) logger.warn("Multiple commands given to parser");
 
     try {
       // if the lexer saw terminators, parse the associated commands
@@ -240,12 +218,12 @@
    *
    * @param command the command to parse in TQL syntax
    * @return A {@link List} of ASTs, one for each command
-   * @throws ParserException if the syntax of the command is incorrect
+   * @throws MulgaraParserException if the syntax of the command is incorrect
    * @throws LexerException if the syntax of the command is incorrect
    * @throws IOException if the <var>command</var> cannot be paersed
    * @throws IllegalArgumentException if the <var>command</var> is <code>null</code>
    */
-  public List<Command> parseCommands(String command) throws ParserException, LexerException, Exception {
+  public List<Command> parseCommands(String command) throws MulgaraParserException, LexerException, Exception {
 
     // validate command parameter
     if ((command == null) || command.equals("")) {
@@ -306,10 +284,10 @@
    * @return the corresponding {@link Query} instance
    * @throws IOException if <var>queryString</var> can't be buffered.
    * @throws LexerException if <var>queryString</var> can't be tokenized.
-   * @throws ParserException if <var>queryString</var> is not syntactic.
+   * @throws MulgaraParserException if <var>queryString</var> is not syntactic.
    */
   public Query parseQuery(String queryString) throws IOException,
-      LexerException, ParserException {
+      MulgaraLexerException, MulgaraParserException {
 
     if (queryString == null) throw new IllegalArgumentException("Null \"queryString\" parameter");
 
@@ -325,11 +303,17 @@
     // parse the command via double dispatch
     Parser parser = new Parser(new Lexer(new PushbackReader(new StringReader(queryString), 256)));
     resetInterpreter();
-    parser.parse().apply(this);
+    try {
+      parser.parse().apply(this);
+    } catch (LexerException le) {
+      throw new MulgaraLexerException(le);
+    } catch (ParserException pe) {
+      throw new MulgaraParserException(pe);
+    }
 
     // should now have the command parsed into lastCommand.
     // check the the command worked as expected
-    if (lastCommand == null) throw new ParserException(null, "Parameter was not a query");
+    if (lastCommand == null) throw new MulgaraParserException("Parameter was not a query");
     if (!(lastCommand instanceof Query)) throw new IllegalArgumentException("Command was not a query: " + queryString);
 
     // return the results of the command
@@ -754,7 +738,7 @@
     if (rawQuery == null) throw new IllegalArgumentException("Null \"rawQuery\" parameter");
   
     // create the variables.  May contain a PElement; Count; URI literal; or a sub query
-    LinkedList<Object> variables = null;
+    LinkedList<PElement> variables = null;
     AFromClause fromClause;
     AWhereClause whereClause;
     AOrderClause orderClause;
@@ -769,7 +753,7 @@
       AQuery query = (AQuery) rawQuery;
       PSelectClause selectClause = query.getSelectClause();
       if (selectClause instanceof ANormalSelectSelectClause) {
-        variables = (LinkedList<Object>)((ANormalSelectSelectClause)selectClause).getElement();
+        variables = (LinkedList<PElement>)((ANormalSelectSelectClause)selectClause).getElement();
       }
       fromClause = ((AFromClause)query.getFromClause());
       whereClause = ((AWhereClause)query.getWhereClause());
@@ -780,7 +764,7 @@
     } else if (rawQuery instanceof ASelectSetOfTriples) {
   
       ASelectSetOfTriples query = (ASelectSetOfTriples) rawQuery;
-      variables = new LinkedList<Object>();
+      variables = new LinkedList<PElement>();
       variables.add(query.getSubject());
       variables.add(query.getPredicate());
       variables.add(query.getObject());
@@ -799,7 +783,7 @@
     if (fromClause == null) throw new QueryException("FROM clause missing.");
     if (whereClause == null) throw new QueryException("WHERE clause missing.");
 
-    // build the variable list
+    // build the variable list: collection of Variable, ConstantValue, Count, Subquery
     if (logger.isDebugEnabled()) logger.debug("Building query variable list from " + variables);
     List<Object> variableList = this.buildVariableList(variables);
     if (logger.isDebugEnabled()) logger.debug("Built variable list " + variableList);
@@ -936,10 +920,8 @@
     List<PStrand> strands = (List<PStrand>)literal.getStrand();
   
     // add each strand together to make the literal text
-    for (Iterator<PStrand> i = strands.iterator(); i.hasNext(); ) {
-  
-      PStrand strand = i.next();
-  
+    for (PStrand strand: strands) {
+      
       // add the strand to the literal text
       if (strand instanceof AUnescapedStrand) {
         literalText.append(((AUnescapedStrand)strand).getText().getText());
@@ -986,7 +968,7 @@
    *      into a list of {@link org.mulgara.query.Variable}s
    */
   @SuppressWarnings("unchecked")
-  List<Object> buildVariableList(LinkedList<Object> rawVariableList) throws
+  List<Object> buildVariableList(LinkedList<PElement> rawVariableList) throws
       QueryException, URISyntaxException {
   
     // Empty variable list.
@@ -996,18 +978,14 @@
     if (rawVariableList.size() == 0) throw new IllegalArgumentException("Empty \"rawVariableList\" parameter");
   
     // Construct the required builder
-    VariableBuilder variableBuilder = new VariableBuilder(this,
-        variableFactory);
+    VariableBuilder variableBuilder = new VariableBuilder(this, variableFactory);
   
     // end if
     // log that we're building the variable list
     if (logger.isDebugEnabled()) logger.debug("Building variable list from " + rawVariableList);
   
     // copy each variable from the query into the list
-    for (Iterator<Object> i = rawVariableList.iterator(); i.hasNext(); ) {
-      PElement element = (PElement) i.next();
-      element.apply( (Switch) variableBuilder);
-    }
+    for (PElement element: rawVariableList) element.apply((Switch)variableBuilder);
   
     // Get the variable list
     List<Object> variableList = variableBuilder.getVariableList();
@@ -1056,10 +1034,8 @@
     List<Order> orderList = new ArrayList<Order>(rawOrderList.size());
   
     // copy each variable from the query into the list
-    for (Iterator<AOrderElement> i = rawOrderList.iterator(); i.hasNext(); ) {
-  
-      AOrderElement order = i.next();
-  
+    for (AOrderElement order: rawOrderList) {
+
       // get the name of this variable
       String variableName = ((AVariable)order.getVariable()).getIdentifier().getText();
   
@@ -1079,17 +1055,14 @@
         throw new Error("Unknown direction field in order");
       }
   
-      // add a new variable to the list
+      // add a new ordered variable to the list
       orderList.add(new Order(new Variable(variableName), ascending));
     }
   
     // make sure that we return a list with something in it
     if (orderList.size() == 0) throw new QueryException("No variables parseable from query");
   
-    // log that we've successfully built the order list
     if (logger.isDebugEnabled()) logger.debug("Built order list " + orderList);
-  
-    // return the list
     return orderList;
   }
 

Modified: branches/nw-interface/src/jar/itql/java/org/mulgara/itql/VariableBuilder.java
===================================================================
--- branches/nw-interface/src/jar/itql/java/org/mulgara/itql/VariableBuilder.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/itql/java/org/mulgara/itql/VariableBuilder.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -81,7 +81,7 @@
   private List<Object> variableList;
 
   /** The TQL interpreter */
-  private Interpreter interpreter;
+  private SableCCInterpreter interpreter;
 
 
   /**
@@ -89,7 +89,7 @@
    * function correctly.
    * @param newInterpreter the interpreter to use.
    */
-  public VariableBuilder(Interpreter newInterpreter, VariableFactory newVariableFactory) {
+  public VariableBuilder(SableCCInterpreter newInterpreter, VariableFactory newVariableFactory) {
     variableList = new ArrayList<Object>();
     interpreter = newInterpreter;
     variableFactory = newVariableFactory;

Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/ApplyRules.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/ApplyRules.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/ApplyRules.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -12,8 +12,13 @@
 package org.mulgara.query.ast;
 
 import java.net.URI;
+import java.rmi.RemoteException;
 
 import org.mulgara.connection.Connection;
+import org.mulgara.query.QueryException;
+import org.mulgara.rules.InitializerException;
+import org.mulgara.rules.RulesException;
+import org.mulgara.rules.RulesRef;
 
 /**
  * Represents a command to apply rules to a set of data.
@@ -68,9 +73,37 @@
     return destGraph;
   }
 
-  public Object execute(Connection conn) throws Exception {
-    // TODO Auto-generated method stub
-    return null;
+  /**
+   * Apply rules using the given connection.
+   * @param conn The connection to make the rule application on.
+   * @return A string containing the result message.
+   * @throws InitializerException The rules were not structured correctly.
+   * @throws QueryException Unable to read the rules.
+   * @throws RemoteException There was a connectivity problem with the server.
+   * @throws RulesException There was an error with the application of the rules.
+   */
+  public Object execute(Connection conn) throws RemoteException, RulesException, QueryException, InitializerException {
+    return execute(conn, conn);
   }
 
+  /**
+   * Apply rules using separate connections for getting rules and applying them.
+   * @param conn The connection to apply the rules with.
+   * @param ruleConn The connection to retrieve rules over.
+   * @return A string containing the result message.
+   * @throws InitializerException The rules were not structured correctly.
+   * @throws QueryException Unable to read the rules.
+   * @throws RemoteException There was a connectivity problem with the server.
+   * @throws RulesException There was an error with the application of the rules.
+   */
+  public Object execute(Connection conn, Connection ruleConn) throws RemoteException, RulesException, QueryException, InitializerException {
+    if (conn == null) throw new IllegalArgumentException("Connection may not be null");
+    // get the structure from the rule model
+    RulesRef rules = ruleConn.getSession().buildRules(ruleGraph, baseGraph, destGraph);
+    // create apply the rules to the model
+    conn.getSession().applyRules(rules);
+    resultMessage = "Successfully applied " + ruleGraph + " to " + baseGraph + (destGraph == baseGraph ? "" : " => " + destGraph);
+    return resultMessage;
+  }
+
 }

Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/Backup.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/Backup.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/Backup.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -12,8 +12,11 @@
 package org.mulgara.query.ast;
 
 import java.net.URI;
+import java.net.URISyntaxException;
 
+import org.apache.log4j.Logger;
 import org.mulgara.connection.Connection;
+import org.mulgara.itql.TqlInterpreter;
 
 /**
  * Represents a command to back data up from a model.
@@ -25,13 +28,54 @@
  */
 public class Backup extends DataTx {
 
+  /** The logger */
+  static final Logger logger = Logger.getLogger(Backup.class.getName());
+
+  /** The URI for the server. */
+  private URI serverUri;
+
+  /**
+   * Creates a new Backup command.
+   * @param source The data to back up.  May be a server or just a single graph.
+   * @param destination The location where to back the data up.
+   *        Only file URLs supported at the moment.
+   */
   public Backup(URI source, URI destination) {
     super(source, destination);
+    calcServerUri(source);
   }
 
+  /**
+   * @return The URI of the destination graph.
+   */
+  public URI getServerURI() throws UnsupportedOperationException {
+    return serverUri;
+  }
+
   public Object execute(Connection conn) throws Exception {
     // TODO Auto-generated method stub
     return null;
   }
 
+  
+  /**
+   * Sets the server URI for this server operation.
+   * @param uri The URI to determine the server URI from.
+   */
+  private void calcServerUri(URI uri) {
+    assert serverUri != null;
+    // check if backing up a graph or a server
+    String fragment = uri.getFragment();
+    if (fragment == null) {
+      if (logger.isDebugEnabled()) logger.debug("Backup for server: " + uri);
+      serverUri = uri;
+    } else {
+      String serverUriString = uri.toString().replaceAll("#" + fragment, "");
+      try {
+        serverUri = new URI(serverUriString);
+      } catch (URISyntaxException e) {
+        throw new Error("Unable to truncate a fragment from a valid URI");
+      }
+    }
+  }
 }

Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/Command.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/Command.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/Command.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -52,4 +52,11 @@
    * @throws Exception specific to the operation.
    */
   Object execute(Connection conn) throws Exception;
+
+  /**
+   * Gets a message text relevant to the operation.  Useful for the UI.
+   * @return A text message associated with the result of this
+   * operation.
+   */
+  String getResultMessage();
 }

Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/Commit.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/Commit.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/Commit.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -12,9 +12,9 @@
 
 package org.mulgara.query.ast;
 
-import java.net.URI;
 
 import org.mulgara.connection.Connection;
+import org.mulgara.query.QueryException;
 
 
 /**
@@ -25,39 +25,17 @@
  * @copyright &copy; 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
  * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
  */
-public class Commit implements Command {
-
+public class Commit extends TransactionCommand implements Command {
+  
   /**
-   * Indicates that this operation may require network access.
-   * @return <code>false</code> as network access may be needed.
+   * Commits the transaction on a connection.
+   * @param conn Contains the session to commit. 
+   * @throws QueryException There was a server error commiting the transaction.
    */
-  public boolean isLocalOperation() {
-    return false;
+  public Object execute(Connection conn) throws QueryException {
+    conn.getSession().commit();
+    resultMessage = "Successfully committed transaction";
+    return resultMessage;
   }
 
-
-  /**
-   * Indicates that this operation is not specific to a UI.
-   * @return <code>false</code> as operation is not specific to UIs.
-   */
-  public boolean isUICommand() {
-    return false;
-  }
-
-
-  /**
-   * Requests a server URI for this operation.  None available, as it
-   * operates on the local connection.
-   * @return <code>null</code>
-   */
-  public URI getServerURI() {
-    return null;
-  }
-
-
-  public Object execute(Connection conn) throws Exception {
-    // TODO Auto-generated method stub
-    return null;
-  }
-
 }

Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/DataTx.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/DataTx.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/DataTx.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -36,10 +36,12 @@
    */
   public DataTx(URI source, URI destination) {
     super(destination);
+    if (source == null) throw new IllegalArgumentException("Need a valid source of data");
+    if (destination == null) throw new IllegalArgumentException("Need a valid destination for data");
     this.source = source;
     this.destination = destination;
   }
-  
+
   /**
    * @return The URI of the destination graph.
    */

Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/Deletion.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/Deletion.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/Deletion.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -46,7 +46,8 @@
   }
 
   public Object execute(Connection conn) throws Exception {
-    // TODO Auto-generated method stub
+    if (isSelectBased()) conn.getSession().delete(graph, getSelectQuery());
+    else conn.getSession().delete(graph, getStatements());
     return null;
   }
 

Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/Insertion.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/Insertion.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/Insertion.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -46,7 +46,8 @@
   }
 
   public Object execute(Connection conn) throws Exception {
-    // TODO Auto-generated method stub
+    if (isSelectBased()) conn.getSession().insert(graph, getSelectQuery());
+    else conn.getSession().insert(graph, getStatements());
     return null;
   }
 

Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/LocalCommand.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/LocalCommand.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/LocalCommand.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -24,6 +24,9 @@
  */
 public abstract class LocalCommand implements Command {
 
+  /** The message set by the result of this command. */
+  protected String resultMessage = "";
+  
   /**
    * Indicates that this operation is local.
    * @return Always <code>true</code> to indicate this command is local.
@@ -48,4 +51,14 @@
   public Object execute() throws Exception {
     return execute(null);
   }
+  
+  /**
+   * Gets a message text relevant to the operation.  Useful for the UI.
+   * @return A text message associated with the result of this
+   * operation.
+   */
+  public String getResultMessage() {
+    return resultMessage;
+  }
+
 }

Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/Rollback.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/Rollback.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/Rollback.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -12,9 +12,9 @@
 
 package org.mulgara.query.ast;
 
-import java.net.URI;
 
 import org.mulgara.connection.Connection;
+import org.mulgara.query.QueryException;
 
 
 /**
@@ -25,36 +25,17 @@
  * @copyright &copy; 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
  * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
  */
-public class Rollback implements Command {
+public class Rollback extends TransactionCommand implements Command {
 
   /**
-   * Indicates that this operation may require network access.
-   * @return <code>false</code> as network access may be needed.
+   * Commits the transaction on a connection.
+   * @param conn Contains the session to commit. 
+   * @throws QueryException There was a server error commiting the transaction.
    */
-  public boolean isLocalOperation() {
-    return false;
+  public Object execute(Connection conn) throws QueryException {
+    conn.getSession().rollback();
+    resultMessage = "Successfully committed transaction";
+    return resultMessage;
   }
 
-  /**
-   * Indicates that this operation is not specific to a UI.
-   * @return <code>false</code> as operation is not specific to UIs.
-   */
-  public boolean isUICommand() {
-    return false;
-  }
-
-  /**
-   * Requests a server URI for this operation.  None available, as it
-   * operates on the local connection.
-   * @return <code>null</code>
-   */
-  public URI getServerURI() {
-    return null;
-  }
-
-  public Object execute(Connection conn) throws Exception {
-    // TODO Auto-generated method stub
-    return null;
-  }
-
 }

Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/ServerCommand.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/ServerCommand.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/ast/ServerCommand.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -29,12 +29,16 @@
   /** The graph being referred to on the server. */
   private ModelResource serverGraph;
   
+  /** The message set by the result of this command. */
+  protected String resultMessage;
+  
   /**
    * Creates a new command, with a principle graph URI.
    * @param serverGraphUri The URI of the graph.
    */
   public ServerCommand(URI serverGraphUri) {
     serverGraph = new ModelResource(serverGraphUri);
+    resultMessage = "";
   }
   
   
@@ -67,4 +71,13 @@
     return false;
   }
 
+
+  /**
+   * Gets a message text relevant to the operation.  Useful for the UI.
+   * @return A text message associated with the result of this
+   * operation.
+   */
+  public String getResultMessage() {
+    return resultMessage;
+  }
 }

Modified: branches/nw-interface/src/jar/query/java/org/mulgara/server/Session.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/server/Session.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/server/Session.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -34,6 +34,7 @@
 import java.io.*;
 
 // Locally written packages
+import org.jrdf.graph.Triple;
 import org.mulgara.query.Answer;
 import org.mulgara.query.ModelExpression;
 import org.mulgara.query.Query;
@@ -78,7 +79,7 @@
    * @param statements The Set of statements to insert into the model.
    * @throws QueryException if the insert cannot be completed.
    */
-  public void insert(URI modelURI, Set statements) throws QueryException;
+  public void insert(URI modelURI, Set<Triple> statements) throws QueryException;
 
   /**
    * Insert statements from the results of a query into another model.
@@ -96,7 +97,7 @@
    * @param statements The Set of statements to delete from the model.
    * @throws QueryException if the deletion cannot be completed.
    */
-  public void delete(URI modelURI, Set statements) throws QueryException;
+  public void delete(URI modelURI, Set<Triple> statements) throws QueryException;
 
   /**
    * Delete statements from a model using the results of query.
@@ -173,7 +174,7 @@
    * @return a list of non-<code>null</code> answers to the <var>queries</var>
    * @throws QueryException if <var>query</var> can't be answered
    */
-  public List query(List queries) throws QueryException;
+  public List<Answer> query(List<Query> queries) throws QueryException;
 
   /**
    * Creates a new model of a given type.  The standard model type is

Modified: branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/AdvDatabaseSessionUnitTest.java
===================================================================
--- branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/AdvDatabaseSessionUnitTest.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/AdvDatabaseSessionUnitTest.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -39,10 +39,10 @@
 // Third party packages
 import junit.framework.*;        // JUnit
 import org.apache.log4j.Logger;  // Log4J
-import org.jrdf.vocabulary.RDF;  // JRDF
 import org.jrdf.graph.SubjectNode;  // JRDF
 import org.jrdf.graph.PredicateNode;  // JRDF
 import org.jrdf.graph.ObjectNode;  // JRDF
+import org.jrdf.graph.Triple;
 
 // Locally written packages
 import org.mulgara.query.*;
@@ -50,9 +50,6 @@
 import org.mulgara.query.rdf.URIReferenceImpl;
 import org.mulgara.query.rdf.TripleImpl;
 import org.mulgara.server.Session;
-import org.mulgara.store.StoreException;
-import org.mulgara.store.nodepool.NodePool;
-import org.mulgara.store.stringpool.StringPool;
 import org.mulgara.util.FileUtil;
 
 /**
@@ -73,8 +70,6 @@
 
   private static final URI databaseURI;
 
-  private static final URI systemModelURI;
-
   private static final URI modelURI;
   private static final URI model2URI;
   private static final URI model3URI;
@@ -86,7 +81,6 @@
   static {
     try {
       databaseURI    = new URI("local:database");
-      systemModelURI = new URI("local:database#");
       modelURI       = new URI("local:database#model");
       model2URI      = new URI("local:database#model2");
       model3URI      = new URI("local:database#model3");
@@ -171,9 +165,6 @@
       String tempResolverFactoryClassName =
         "org.mulgara.resolver.memory.MemoryResolverFactory";
 
-      String ruleLoaderFactoryClassName =
-        "org.mulgara.rules.RuleLoaderFactory";
-
       // Create a database which keeps its system models on the Java heap
       database = new Database(
                    databaseURI,
@@ -247,7 +238,7 @@
         Variable predicateVariable = new Variable("predicate");
         Variable objectVariable    = new Variable("object");
 
-        List selectList = new ArrayList(3);
+        List<Object> selectList = new ArrayList<Object>(3);
         selectList.add(subjectVariable);
         selectList.add(predicateVariable);
         selectList.add(objectVariable);
@@ -305,7 +296,7 @@
         Variable predicateVariable = new Variable("predicate");
         Variable objectVariable    = new Variable("object");
 
-        List selectList = new ArrayList(3);
+        List<Object> selectList = new ArrayList<Object>(3);
         selectList.add(subjectVariable);
         selectList.add(predicateVariable);
         selectList.add(objectVariable);
@@ -365,10 +356,10 @@
         Variable predicateVariable = new Variable("predicate");
         Variable objectVariable    = new Variable("object");
 
-        List selectList = new ArrayList(3);
+        List<Object> selectList = new ArrayList<Object>(3);
         selectList.add(subjectVariable);
         selectList.add(new Subquery(new Variable("k0"), new Query(
-          Collections.singletonList(objectVariable),
+          Collections.singletonList((Object)objectVariable),
           new ModelResource(modelURI),                      // FROM
           new ConstraintImpl(subjectVariable,               // WHERE
                          predicateVariable,
@@ -440,10 +431,10 @@
         Variable predicateVariable = new Variable("predicate");
         Variable objectVariable    = new Variable("object");
 
-        List selectList = new ArrayList(3);
+        List<Object> selectList = new ArrayList<Object>(3);
         selectList.add(subjectVariable);
         selectList.add(new Subquery(new Variable("k0"), new Query(
-          Collections.singletonList(objectVariable),
+          Collections.singletonList((Object)objectVariable),
           new ModelResource(modelURI),                      // FROM
           new ConstraintImpl(subjectVariable,               // WHERE
                          predicateVariable,
@@ -529,7 +520,7 @@
         Variable predicateVariable = new Variable("predicate");
         Variable objectVariable    = new Variable("object");
 
-        List selectList = new ArrayList(3);
+        List<Object> selectList = new ArrayList<Object>(3);
         selectList.add(subjectVariable);
         selectList.add(predicateVariable);
         selectList.add(objectVariable);
@@ -554,7 +545,7 @@
 
         answer.beforeFirst();
         while (answer.next()) {
-          session.insert(model2URI, Collections.singleton(new TripleImpl(
+          session.insert(model2URI, Collections.singleton((Triple)new TripleImpl(
               (SubjectNode)answer.getObject(0),
               (PredicateNode)answer.getObject(1),
               (ObjectNode)answer.getObject(2))));
@@ -616,7 +607,7 @@
         Variable predicateVariable = new Variable("predicate");
         Variable objectVariable    = new Variable("object");
 
-        List selectList = new ArrayList(3);
+        List<Object> selectList = new ArrayList<Object>(3);
         selectList.add(subjectVariable);
         selectList.add(predicateVariable);
         selectList.add(objectVariable);
@@ -693,7 +684,7 @@
           Variable predicateVariable = new Variable("predicate");
           Variable objectVariable    = new Variable("object");
 
-          List selectList = new ArrayList(3);
+          List<Object> selectList = new ArrayList<Object>(3);
           selectList.add(subjectVariable);
           selectList.add(predicateVariable);
           selectList.add(objectVariable);
@@ -721,7 +712,7 @@
 
           session1.setAutoCommit(true);
 
-          selectList = new ArrayList(3);
+          selectList = new ArrayList<Object>(3);
           selectList.add(subjectVariable);
           selectList.add(predicateVariable);
           selectList.add(objectVariable);
@@ -791,7 +782,7 @@
           Variable predicateVariable = new Variable("predicate");
           Variable objectVariable    = new Variable("object");
 
-          List selectList = new ArrayList(3);
+          List<Object> selectList = new ArrayList<Object>(3);
           selectList.add(subjectVariable);
           selectList.add(predicateVariable);
           selectList.add(objectVariable);
@@ -820,7 +811,7 @@
           session1.rollback();
           session1.setAutoCommit(true);
 
-          selectList = new ArrayList(3);
+          selectList = new ArrayList<Object>(3);
           selectList.add(subjectVariable);
           selectList.add(predicateVariable);
           selectList.add(objectVariable);
@@ -876,7 +867,7 @@
           Variable predicateVariable = new Variable("predicate");
           Variable objectVariable    = new Variable("object");
 
-          List selectList = new ArrayList(3);
+          List<Object> selectList = new ArrayList<Object>(3);
           selectList.add(subjectVariable);
           selectList.add(predicateVariable);
           selectList.add(objectVariable);
@@ -904,7 +895,7 @@
 
           session1.commit();
 
-          selectList = new ArrayList(3);
+          selectList = new ArrayList<Object>(3);
           selectList.add(subjectVariable);
           selectList.add(predicateVariable);
           selectList.add(objectVariable);
@@ -947,7 +938,7 @@
           session1.removeModel(model3URI);
           session1.createModel(model3URI, null);
 
-          selectList = new ArrayList(3);
+          selectList = new ArrayList<Object>(3);
           selectList.add(subjectVariable);
           selectList.add(predicateVariable);
           selectList.add(objectVariable);
@@ -989,7 +980,7 @@
 
           session1.setAutoCommit(true);
 
-          selectList = new ArrayList(3);
+          selectList = new ArrayList<Object>(3);
           selectList.add(subjectVariable);
           selectList.add(predicateVariable);
           selectList.add(objectVariable);
@@ -1043,7 +1034,7 @@
           Variable predicateVariable = new Variable("predicate");
           Variable objectVariable    = new Variable("object");
 
-          List selectList = new ArrayList(3);
+          List<Object> selectList = new ArrayList<Object>(3);
           selectList.add(subjectVariable);
           selectList.add(predicateVariable);
           selectList.add(objectVariable);
@@ -1091,7 +1082,7 @@
                            predicateVariable,
                            objectVariable),
             null,                                             // HAVING
-            new ArrayList(),                                  // ORDER BY
+            new ArrayList<Order>(),                           // ORDER BY
             null,                                             // LIMIT
             0,                                                // OFFSET
             new UnconstrainedAnswer()                         // GIVEN
@@ -1107,7 +1098,7 @@
                            predicateVariable,
                            objectVariable),
             null,                                             // HAVING
-            new ArrayList(),                                  // ORDER BY
+            new ArrayList<Order>(),                           // ORDER BY
             null,                                             // LIMIT
             0,                                                // OFFSET
             new UnconstrainedAnswer()                         // GIVEN
@@ -1163,7 +1154,7 @@
                 Variable predicateVariable = new Variable("predicate");
                 Variable objectVariable    = new Variable("object");
 
-                List selectList = new ArrayList(3);
+                List<Object> selectList = new ArrayList<Object>(3);
                 selectList.add(subjectVariable);
                 selectList.add(predicateVariable);
                 selectList.add(objectVariable);
@@ -1286,7 +1277,7 @@
                 Variable predicateVariable = new Variable("predicate");
                 Variable objectVariable    = new Variable("object");
 
-                List selectList = new ArrayList(3);
+                List<Object> selectList = new ArrayList<Object>(3);
                 selectList.add(subjectVariable);
                 selectList.add(predicateVariable);
                 selectList.add(objectVariable);
@@ -1342,7 +1333,7 @@
                 Variable predicateVariable = new Variable("predicate");
                 Variable objectVariable    = new Variable("object");
 
-                List selectList = new ArrayList(3);
+                List<Object> selectList = new ArrayList<Object>(3);
                 selectList.add(subjectVariable);
                 selectList.add(predicateVariable);
                 selectList.add(objectVariable);
@@ -1427,7 +1418,7 @@
         Variable varB   = new Variable("b");
         Variable varT = new Variable("t");
 
-        List selectList = new ArrayList(2);
+        List<Object> selectList = new ArrayList<Object>(2);
         selectList.add(varA);
         selectList.add(varT);
 

Modified: branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/CacheResolver.java
===================================================================
--- branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/CacheResolver.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/CacheResolver.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -37,7 +37,6 @@
 // Local packages
 import org.mulgara.query.*;
 import org.mulgara.resolver.spi.*;
-import org.mulgara.store.tuples.Tuples;
 
 /**
  * Cached access to models managed by some other {@link ResolverFactory}.
@@ -46,12 +45,6 @@
  *
  * @author <a href="http://www.pisoftware.com/raboczi">Simon Raboczi</a>
  *
- * @version $Revision: 1.10 $
- *
- * @modified $Date: 2005/05/02 20:07:55 $
- *
- * @maintenanceAuthor $Author: raboczi $
- *
  * @company <a href="mailto:info at PIsoftware.com">Plugged In Software</a>
  *
  * @copyright &copy;2004 <a href="http://www.pisoftware.com/">Plugged In
@@ -61,9 +54,9 @@
  */
 
 class CacheResolver implements Resolver {
-  private final Set cachedModelSet;
+  private final Set<LocalNode> cachedModelSet;
   private final boolean canWrite;
-  private final Set changedCachedModelSet;
+  private final Set<LocalNode> changedCachedModelSet;
   private final ResolverFactory externalResolverFactory;
   private final ResolverSession resolverSession;
   private final Resolver systemResolver;
@@ -83,8 +76,8 @@
       ResolverFactory externalResolverFactory,
       ResolverFactory temporaryResolverFactory,
       URI temporaryModelTypeURI,
-      Set cachedModelSet,
-      Set changedCachedModelSet) {
+      Set<LocalNode> cachedModelSet,
+      Set<LocalNode> changedCachedModelSet) {
     // Initialize fields
     this.cachedModelSet = cachedModelSet;
     this.canWrite = canWrite;
@@ -115,16 +108,14 @@
     return new DummyXAResource(3600 /* one hour timeout */);
   }
 
-  public void modifyModel(long model, Statements statements,
-      boolean occurs) throws ResolverException {
+  public void modifyModel(long model, Statements statements, boolean occurs) throws ResolverException {
     LocalNode modelLocalNode = new LocalNode(model);
 
     // Obtain the resolver against the cached version
     Resolver temporaryResolver;
     try {
       temporaryResolver = getTemporaryResolver(modelLocalNode);
-    }
-    catch (Exception e) {
+    } catch (Exception e) {
       throw new ResolverException("Unable to cache model " + modelLocalNode, e);
     }
     assert temporaryResolver != null;
@@ -156,14 +147,13 @@
     }
     assert constraint.getModel() instanceof LocalNode;
 
-    LocalNode modelLocalNode = (LocalNode) constraint.getModel();
+    LocalNode modelLocalNode = (LocalNode)constraint.getModel();
 
     // Obtain the resolver against the cached version
     Resolver temporaryResolver;
     try {
       temporaryResolver = getTemporaryResolver(modelLocalNode);
-    }
-    catch (Exception e) {
+    } catch (Exception e) {
       throw new QueryException("Unable to cache model " + modelLocalNode, e);
     }
     assert temporaryResolver != null;

Modified: branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/CacheResolverFactory.java
===================================================================
--- branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/CacheResolverFactory.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/CacheResolverFactory.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -44,9 +44,6 @@
  *
  * @created 2004-11-10
  * @author <a href="http://www.pisoftware.com/raboczi">Simon Raboczi</a>
- * @version $Revision: 1.10 $
- * @modified $Date: 2005/05/02 20:07:55 $
- * @maintenanceAuthor $Author: raboczi $
  * @company <a href="mailto:info at PIsoftware.com">Plugged In Software</a>
  * @copyright &copy;2004 <a href="http://www.pisoftware.com/">Plugged In
  *      Software Pty Ltd</a>
@@ -76,7 +73,7 @@
    * This is basically the counterpart of the system model (<code>#</code>)
    * for temporary models instead of persistent ones.
    */
-  private final Set cachedModelSet;
+  private final Set<LocalNode> cachedModelSet;
 
   /**
    * The set of cached models which have been modified.
@@ -85,7 +82,7 @@
    * When the cache is cleared, these models will need to have their changes
    * written back.
    */
-  private final Set changedCachedModelSet;
+  private final Set<LocalNode> changedCachedModelSet;
 
   //
   // Constructor
@@ -100,8 +97,8 @@
   CacheResolverFactory(ResolverFactory externalResolverFactory,
                        ResolverFactory temporaryResolverFactory,
                        URI             temporaryModelTypeURI,
-                       Set             cachedModelSet,
-                       Set             changedCachedModelSet)
+                       Set<LocalNode>  cachedModelSet,
+                       Set<LocalNode>  changedCachedModelSet)
   {
     assert externalResolverFactory  != null;
     assert temporaryResolverFactory != null;

Modified: branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/Database.java
===================================================================
--- branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/Database.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/Database.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -117,6 +117,7 @@
    * This is a stopgap measure to deal with the lack of a defined negative
    * return value from {@link StringPool#findGNode}.
    */
+  @SuppressWarnings("unused")
   private final long NONE = NodePool.NONE;
 
   /** The directory where persistence files are stored.  */
@@ -140,12 +141,12 @@
    * The set of resolver factories that should have access to their models
    * cached.
    */
-  private final Set cachedResolverFactorySet = new HashSet();
+  private final Set<ResolverFactory> cachedResolverFactorySet = new HashSet<ResolverFactory>();
 
   /**
    * Read-only view of {@link #cachedResolverFactorySet}.
    */
-  private final Set unmodifiableCachedResolverFactorySet =
+  private final Set<ResolverFactory> unmodifiableCachedResolverFactorySet =
     Collections.unmodifiableSet(cachedResolverFactorySet);
 
   /**
@@ -156,13 +157,13 @@
   /**
    * The set of all registered {@link ResolverFactory} instances.
    */
-  private final List resolverFactoryList = new ArrayList();
+  private final List<ResolverFactory> resolverFactoryList = new ArrayList<ResolverFactory>();
 
   /**
    * Read-only view of {@link #resolverFactoryList}, safe to be handed out to
    * the resolver sessions.
    */
-  private final List unmodifiableResolverFactoryList =
+  private final List<ResolverFactory> unmodifiableResolverFactoryList =
     Collections.unmodifiableList(resolverFactoryList);
 
   /**
@@ -170,13 +171,13 @@
    * {@link ResolverFactory} instance that manages external models via that
    * protocol.
    */
-  private final Map externalResolverFactoryMap = new HashMap();
+  private final Map<String,ResolverFactory> externalResolverFactoryMap = new HashMap<String,ResolverFactory>();
 
   /**
    * Read-only view of {@link #externalResolverFactoryMap}, safe to be handed
    * out to the resolver sessions.
    */
-  private final Map unmodifiableExternalResolverFactoryMap =
+  private final Map<String,ResolverFactory> unmodifiableExternalResolverFactoryMap =
     Collections.unmodifiableMap(externalResolverFactoryMap);
 
   /**
@@ -184,13 +185,13 @@
    * {@link InternalResolverFactory} instance that wraps the actual
    * {@link ResolverFactory} instance which manages that model type.
    */
-  private final Map internalResolverFactoryMap = new HashMap();
+  private final Map<URI,InternalResolverFactory> internalResolverFactoryMap = new HashMap<URI,InternalResolverFactory>();
 
   /**
    * Read-only view of {@link #internalResolverFactoryMap}, safe to be handed
    * out to the resolver sessions.
    */
-  private final Map unmodifiableInternalResolverFactoryMap =
+  private final Map<URI,InternalResolverFactory> unmodifiableInternalResolverFactoryMap =
     Collections.unmodifiableMap(internalResolverFactoryMap);
 
   private DatabaseMetadata metadata;
@@ -215,13 +216,13 @@
    * contain any additional adapters registered via the
    * {@link #addSecurityAdapter} method.
    */
-  private final List securityAdapterList = new ArrayList(1);
+  private final List<SecurityAdapter> securityAdapterList = new ArrayList<SecurityAdapter>(1);
 
   /**
    * Read-only view of {@link #securityAdapterList}, safe to be handed out to
    * the {@link DatabaseSession}s.
    */
-  private final List unmodifiableSecurityAdapterList =
+  private final List<SecurityAdapter> unmodifiableSecurityAdapterList =
     Collections.unmodifiableList(securityAdapterList);
 
   /** The {@link URI} of the security domain this database is within.  */
@@ -230,13 +231,13 @@
   /**
    * The list of {@link SymbolicTransformation} instances.
    */
-  private final List symbolicTransformationList = new ArrayList();
+  private final List<SymbolicTransformation> symbolicTransformationList = new ArrayList<SymbolicTransformation>();
 
   /**
    * Read-only view of {@link #symbolicTransformationList}, safe to be handed
    * out to the {@link DatabaseSession}s.
    */
-  private final List unmodifiableSymbolicTransformationList =
+  private final List<SymbolicTransformation> unmodifiableSymbolicTransformationList =
     Collections.unmodifiableList(symbolicTransformationList);
 
   /**
@@ -260,11 +261,12 @@
    */
   private final MulgaraTransactionManager transactionManager;
 
-  /** The unique {@link URI} naming this database.  */
+  /** The unique {@link URI} naming this database.  Not read in this implementation. */
+  @SuppressWarnings("unused")
   private final URI uri;
 
   /** The set of alternative hostnames for the current host. */
-  private final Set hostnameAliases;
+  private final Set<String> hostnameAliases;
 
   /**
    * A {@link SessionFactory} that produces {@link Session}s which aren't
@@ -313,8 +315,8 @@
              NamingException, NodePoolException, QueryException,
              ResolverException, ResolverFactoryException,
              SecurityAdapterFactoryException, StringPoolException,
-             SystemException, URISyntaxException
-  {
+             SystemException, URISyntaxException {
+
     // Construct this resolver backed by in-memory components
     this(uri,        // database name
          directory,  // persistence directory
@@ -431,8 +433,8 @@
     throws ConfigurationException, InitializerException, LocalizeException,
            NamingException, NodePoolException, QueryException,
            ResolverException, ResolverFactoryException, StringPoolException,
-           SystemException, URISyntaxException
-  {
+           SystemException, URISyntaxException {
+
     if (logger.isDebugEnabled()) {
       logger.debug("Constructing database");
       logger.debug("Persistent node pool factory: class=" +
@@ -501,10 +503,8 @@
         defaultContentHandler = (ContentHandler)
           Beans.instantiate(this.getClass().getClassLoader(), defaultContentHandlerClassName);
       }
-      this.contentHandlers =
-        new ContentHandlerManagerImpl(defaultContentHandler);
-    }
-    catch (Exception e) {
+      this.contentHandlers = new ContentHandlerManagerImpl(defaultContentHandler);
+    } catch (Exception e) {
       throw new ConfigurationException(
         "Couldn't instantiate default content handler", e
       );
@@ -522,27 +522,25 @@
     }
 
     // Create the set of alternative names for the current host.
-    Set hostNames = new HashSet();
+    Set<String> hostNames = new HashSet<String>();
     hostNames.addAll(Arrays.asList(new String[] {"localhost", "127.0.0.1"}));
 
     // Attempt to obtain the IP address
     try {
     	hostNames.add(InetAddress.getLocalHost().getHostAddress());
     } catch(UnknownHostException ex) {
-      logger.info("Unable to obtain local host address "+
-          "aliases", ex);
+      logger.info("Unable to obtain local host address aliases", ex);
     }
     // Attempt to obtain the localhost name
     try {
     	hostNames.add(InetAddress.getLocalHost().getHostName());
     } catch(UnknownHostException ex) {
-      logger.info("Unable to obtain local host name for  "+
-          "aliases", ex);
+      logger.info("Unable to obtain local host name for aliases", ex);
     }
     if (startupLogger.isInfoEnabled()) {
       StringBuffer aliases =
         new StringBuffer("Host name aliases for this server are: [");
-      for (Iterator it = hostNames.iterator(); it.hasNext(); ) {
+      for (Iterator<String> it = hostNames.iterator(); it.hasNext(); ) {
         aliases.append(it.next().toString());
         if (it.hasNext()) {
           aliases.append(", ");
@@ -604,8 +602,7 @@
     DatabaseFactoryInitializer initializer =
         new DatabaseFactoryInitializer(uri, hostnameAliases, directory);
 
-    jrdfSessionFactory =
-        new JRDFResolverSessionFactory(initializer, spSessionFactory);
+    jrdfSessionFactory = new JRDFResolverSessionFactory(initializer, spSessionFactory);
 
     // Ensure that no further initialization is provided
     initializer.close();
@@ -672,8 +669,7 @@
 
 
     URI systemModelURI = new URI(uri.getScheme(), uri.getSchemeSpecificPart(), "");
-    metadata =
-      new DatabaseMetadataImpl(uri,
+    metadata = new DatabaseMetadataImpl(uri,
                                hostnameAliases,
                                securityDomainURI,
                                systemModelURI,
@@ -732,8 +728,7 @@
    * @throws IllegalArgumentException if <var>className</var> is
    *   <code>null</code> or isn't a valid {@link ContentHandler}
    */
-  public void addContentHandler(String className)
-  {
+  public void addContentHandler(String className) {
     if (logger.isDebugEnabled()) {
       logger.debug("Adding content handler " + className);
     }
@@ -765,9 +760,7 @@
    * @throws InitializerException  if the {@link ResolverFactory}
    *   generated from the <var>className</var> can't be initialized
    */
-  public void addResolverFactory(String className, File dir)
-    throws InitializerException
-  {
+  public void addResolverFactory(String className, File dir) throws InitializerException {
     if (logger.isDebugEnabled()) {
       logger.debug("Adding resolver factory " + className);
     }
@@ -791,6 +784,7 @@
     }
   }
 
+
   /**
    * Add a {@link SecurityAdapter} to this {@link Database}.
    *
@@ -803,8 +797,7 @@
    *   <code>null</code>
    */
   public void addSecurityAdapter(SecurityAdapterFactory securityAdapterFactory)
-    throws SecurityAdapterFactoryException
-  {
+        throws SecurityAdapterFactoryException {
     // Create the security adapter even if in admin mode, because we need the
     // side effects like model creation to be trigger
     DatabaseSecurityAdapterInitializer initializer =
@@ -828,8 +821,7 @@
       if (logger.isDebugEnabled()) {
         logger.debug("Added security adapter");
       }
-    }
-    else {
+    } else {
       // Skip the addition of security adapters if we're started in admin mode
       logger.warn("Skipping addition of security adapter " +
                   securityAdapterFactory.getClass().getName() +
@@ -837,22 +829,20 @@
     }
   }
 
+
   /**
    * Flush all resources associated with the database into a recoverable state.
    */
-  public void close()
-  {
+  public void close() {
 
     // Transaction management
     transactionManagerFactory.close();
 
     // Resolver factories
-    for (Iterator i = resolverFactoryList.iterator(); i.hasNext();) {
-      ResolverFactory resolverFactory = (ResolverFactory) i.next();
+    for (ResolverFactory resolverFactory: resolverFactoryList) {
       try {
         resolverFactory.close();
-      }
-      catch (ResolverFactoryException e) {
+      } catch (ResolverFactoryException e) {
         logger.warn("Unable to close " + resolverFactory, e);
       }
     }
@@ -861,17 +851,16 @@
     jrdfSessionFactory.close();
   }
 
+
   /**
    * Remove all persistent resources associated with the database.
    *
    * In other words, erase all the data.  This is generally only useful for
    * testing.
    */
-  public void delete()
-  {
+  public void delete() {
     // Resolver factories
-    for (Iterator i = resolverFactoryList.iterator(); i.hasNext();) {
-      ResolverFactory resolverFactory = (ResolverFactory) i.next();
+    for (ResolverFactory resolverFactory: resolverFactoryList) {
       try {
         resolverFactory.delete();
       } catch (ResolverFactoryException e) {
@@ -887,14 +876,12 @@
   // Methods implementing SessionFactory
   //
 
-  public URI getSecurityDomain()
-  {
+  public URI getSecurityDomain() {
     assert securityDomainURI != null;
     return securityDomainURI;
   }
 
-  public Session newSession() throws QueryException
-  {
+  public Session newSession() throws QueryException {
     try {
       return new DatabaseSession(
         transactionManager,
@@ -938,8 +925,7 @@
           contentHandlers,
           cachedResolverFactorySet,
           temporaryModelTypeURI);
-    }
-    catch (ResolverFactoryException e) {
+    } catch (ResolverFactoryException e) {
       throw new QueryException("Couldn't create JRDF session", e);
     }
   }
@@ -949,8 +935,8 @@
   //
 
   void addModelType(URI modelTypeURI, ResolverFactory resolverFactory)
-    throws InitializerException
-  {
+      throws InitializerException {
+
     if (logger.isDebugEnabled()) {
       logger.debug("Registering model type " + modelTypeURI + " for " +  resolverFactory);
     }
@@ -982,9 +968,8 @@
   }
 
 
-  void addProtocol(String protocol, ResolverFactory resolverFactory)
-    throws InitializerException
-  {
+  void addProtocol(String protocol, ResolverFactory resolverFactory) throws InitializerException {
+
     if (logger.isDebugEnabled()) {
       logger.debug("Registering protocol " + protocol + " for " +  resolverFactory);
     }
@@ -1011,9 +996,8 @@
   }
 
 
-  void addSymbolicTransformation(SymbolicTransformation symbolicTransformation)
-    throws InitializerException
-  {
+  void addSymbolicTransformation(SymbolicTransformation symbolicTransformation) throws InitializerException {
+
     if (logger.isDebugEnabled()) {
       logger.debug("Registering symbolic transformation " +
                    symbolicTransformation.getClass());
@@ -1029,15 +1013,12 @@
   }
 
 
-  File getRootDirectory()
-  {
+  File getRootDirectory() {
     return directory;
   }
 
 
-  private void recoverDatabase(SimpleXARecoveryHandler[] handlers)
-      throws SimpleXAResourceException
-  {
+  private void recoverDatabase(SimpleXARecoveryHandler[] handlers) throws SimpleXAResourceException {
     assert handlers != null;
 
     TIntHashSet[] phaseSets = recoverRecoveryHandlers(handlers);
@@ -1056,8 +1037,7 @@
 
 
   private TIntHashSet[] recoverRecoveryHandlers(SimpleXARecoveryHandler[] handlers)
-      throws SimpleXAResourceException
-  {
+      throws SimpleXAResourceException {
     TIntHashSet[] phaseSets = new TIntHashSet[handlers.length];
     boolean allEmpty = true;
     for (int i = 0; i < handlers.length; i++) {
@@ -1073,34 +1053,27 @@
   }
 
 
-  private TIntHashSet intersectPhaseSets(TIntHashSet[] phaseSets)
-  {
+  private TIntHashSet intersectPhaseSets(TIntHashSet[] phaseSets) {
     TIntHashSet phaseSet = phaseSets[0];
-    for (int i = 1; i < phaseSets.length; i++) {
-      phaseSet.retainAll(phaseSets[i].toArray());
-    }
-
+    for (TIntHashSet ps: phaseSets) phaseSet.retainAll(ps.toArray());
     return phaseSet;
   }
 
 
   private void clearDatabase(SimpleXARecoveryHandler[] handlers)
-      throws SimpleXAResourceException
-  {
+      throws SimpleXAResourceException {
     try {
-      for (int i = 0; i < handlers.length; i++) {
-        handlers[i].clear();
-      }
+      for (SimpleXARecoveryHandler handler: handlers) handler.clear();
     } catch (IOException ei) {
       throw new SimpleXAResourceException("IO failure clearing database", ei);
     }
   }
 
 
-  private int highestCommonPhaseNumber(TIntHashSet phaseSet)
-  {
+  private int highestCommonPhaseNumber(TIntHashSet phaseSet) {
     int hcpn = -1;
 
+    // Trove iterators cannot use for() constructs
     TIntIterator i = phaseSet.iterator();
     while (i.hasNext()) {
       int phase = i.next();
@@ -1110,13 +1083,12 @@
     return hcpn;
   }
 
+
   private void selectCommonPhase(int phaseNumber, SimpleXARecoveryHandler[] handlers)
-      throws SimpleXAResourceException
-  {
+      throws SimpleXAResourceException {
+
     try {
-      for (int i = 0; i < handlers.length; i++) {
-        handlers[i].selectPhase(phaseNumber);
-      }
+      for (SimpleXARecoveryHandler handler: handlers) handler.selectPhase(phaseNumber);
     } catch (IOException ei) {
       throw new SimpleXAResourceException("IO failure selecting phase on database", ei);
     }
@@ -1140,8 +1112,7 @@
    *   Technology, Inc</a>
    * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
    */
-  private class UnsecuredSessionFactory implements SessionFactory
-  {
+  private class UnsecuredSessionFactory implements SessionFactory {
     //
     // Methods implementing SessionFactory
     //
@@ -1150,21 +1121,19 @@
      * @return {@inheritDoc}; this is the same value as the outer
      *   {@link Database} returns
      */
-    public URI getSecurityDomain() throws QueryException
-    {
+    public URI getSecurityDomain() throws QueryException {
       return Database.this.getSecurityDomain();
     }
 
     /**
      * @return an unsecured {@link Session} to the outer {@link Database}
      */
-    public Session newSession() throws QueryException
-    {
+    public Session newSession() throws QueryException {
       try {
         return new DatabaseSession(
           transactionManager,
           Collections.singletonList(
-            new SystemModelSecurityAdapter(metadata.getSystemModelNode())
+            (SecurityAdapter)new SystemModelSecurityAdapter(metadata.getSystemModelNode())
           ),
           unmodifiableSymbolicTransformationList,
           spSessionFactory,
@@ -1187,8 +1156,7 @@
     /**
      * @return an unsecured {@link Session} to the outer {@link Database}
      */
-    public Session newJRDFSession() throws QueryException
-    {
+    public Session newJRDFSession() throws QueryException {
       try {
         return new LocalJRDFDatabaseSession(
           transactionManager,
@@ -1215,16 +1183,14 @@
     /**
      * {@inheritDoc}  This method is a no-op in this implementation.
      */
-    public void close() throws QueryException
-    {
+    public void close() throws QueryException {
       // null implementation
     }
 
     /**
      * {@inheritDoc}  This method is a no-op in this implementation.
      */
-    public void delete() throws QueryException
-    {
+    public void delete() throws QueryException {
       // null implementation
     }
   }
@@ -1235,9 +1201,9 @@
    *
    * @param names The set of hostnames to set on ServerInfo
    */
-  private void setHostnameAliases(Set names) {
+  private void setHostnameAliases(Set<String> names) {
     try {
-      Class si = Class.forName("org.mulgara.server.ServerInfo");
+      Class<?> si = Class.forName("org.mulgara.server.ServerInfo");
       java.lang.reflect.Method setter = si.getMethod("setHostnameAliases", new Class[] { Set.class });
       setter.invoke(null, new Object[] { names });
     } catch (Exception e) {

Modified: branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java
===================================================================
--- branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/DatabaseOperationContext.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -41,12 +41,7 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.WeakHashMap;
-import javax.transaction.xa.XAResource;
 
-// Java 2 enterprise packages
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-
 // Third party packages
 import org.apache.log4j.Logger;
 import org.jrdf.graph.Node;
@@ -62,7 +57,6 @@
 import org.mulgara.resolver.spi.Resolver;
 import org.mulgara.resolver.spi.ResolverFactory;
 import org.mulgara.resolver.spi.ResolverFactoryException;
-import org.mulgara.resolver.spi.ResolverSession;
 import org.mulgara.resolver.spi.SecurityAdapter;
 import org.mulgara.resolver.spi.Statements;
 import org.mulgara.resolver.spi.SymbolicTransformation;
@@ -89,15 +83,10 @@
  *   Technology, Inc</a>
  * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
  */
-class DatabaseOperationContext implements OperationContext, SessionView, SymbolicTransformationContext
-{
-  /**
-   * Logger.
-   *
-   * This is named after the class.
-   */
-  private static final Logger logger =
-    Logger.getLogger(DatabaseOperationContext.class.getName());
+class DatabaseOperationContext implements OperationContext, SessionView, SymbolicTransformationContext {
+ 
+  /** Logger. */
+  private static final Logger logger = Logger.getLogger(DatabaseOperationContext.class.getName());
 
   /** Logger for {@link SymbolicTransformation} plugins. */
   private static final Logger symbolicLogger =
@@ -110,7 +99,7 @@
    * Every model in this set can be manipulated by resolvers from the
    * {@link #temporaryResolverFactory}.
    */
-  private final Set cachedModelSet;
+  private final Set<LocalNode> cachedModelSet;
 
   /**
    * The models from external resolvers which have been cached as temporary
@@ -119,7 +108,7 @@
    * Every model in this set can be manipulated by resolvers from the
    * {@link #temporaryResolverFactory}.
    */
-  private final Set changedCachedModelSet;
+  private final Set<LocalNode> changedCachedModelSet;
 
   /**
    * A map from {@link URI}s of models to {@link LocalNode}s representing the
@@ -128,7 +117,7 @@
    * This is populated by {@link #findModelTypeURI} and cleared by
    * clear()
    */
-  private final Map systemModelCacheMap = new WeakHashMap();
+  private final Map<LocalNode,URI> systemModelCacheMap = new WeakHashMap<LocalNode,URI>();
 
   /** Resolver used for accessing the system model (<code>#</code>).  */
   protected SystemResolverFactory systemResolverFactory;
@@ -138,29 +127,30 @@
   private MulgaraTransaction transaction;
 
   // Immutable properties of the containing DatabaseSession
-  private final Set                cachedResolverFactorySet;
-  private final Map                enlistedResolverMap;
-  private final Map                externalResolverFactoryMap;
-  private final Map                internalResolverFactoryMap;
+  private final Set<ResolverFactory> cachedResolverFactorySet;  // NOTE: Currently unused
+  private final Map<ResolverFactory,Resolver> enlistedResolverMap;
+  private final Map<String,ResolverFactory> externalResolverFactoryMap;
+    // Hold a specific type of ResolverFactory to restrict what should be in there
+  private final Map<URI,InternalResolverFactory> internalResolverFactoryMap;
   private final DatabaseMetadata   metadata;
-  private final List               securityAdapterList;
+  private final List<SecurityAdapter> securityAdapterList;
   private final URI                temporaryModelTypeURI;
   private final ResolverFactory    temporaryResolverFactory;
   /** Symbolic transformations this instance should apply. */
-  private final List               symbolicTransformationList;
+  private final List<SymbolicTransformation> symbolicTransformationList;
   private final boolean            isWriting;
 
   // Used as a set, all values are null.  Java doesn't provide a WeakHashSet.
   private WeakHashMap<TransactionalAnswer,Object> answers;
 
-  DatabaseOperationContext(Set                   cachedResolverFactorySet,
-                           Map                   externalResolverFactoryMap,
-                           Map                   internalResolverFactoryMap,
+  DatabaseOperationContext(Set<ResolverFactory> cachedResolverFactorySet,
+                           Map<String,ResolverFactory> externalResolverFactoryMap,
+                           Map<URI,InternalResolverFactory> internalResolverFactoryMap,
                            DatabaseMetadata      metadata,
-                           List                  securityAdapterList,
+                           List<SecurityAdapter> securityAdapterList,
                            URI                   temporaryModelTypeURI,
                            ResolverFactory       temporaryResolverFactory,
-                           List                  symbolicTransformationList,
+                           List<SymbolicTransformation> symbolicTransformationList,
                            SystemResolverFactory systemResolverFactory,
                            boolean               isWriting)
   {
@@ -185,9 +175,9 @@
     this.isWriting                  = isWriting;
     this.systemResolverFactory      = systemResolverFactory;
 
-    this.cachedModelSet             = new HashSet();
-    this.changedCachedModelSet      = new HashSet();
-    this.enlistedResolverMap        = new HashMap();
+    this.cachedModelSet             = new HashSet<LocalNode>();
+    this.changedCachedModelSet      = new HashSet<LocalNode>();
+    this.enlistedResolverMap        = new HashMap<ResolverFactory,Resolver>();
     this.answers                    = new WeakHashMap<TransactionalAnswer,Object>();
   }
 
@@ -195,13 +185,10 @@
   // Methods implementing OperationContext
   //
 
-  public ResolverFactory findModelResolverFactory(long model)
-    throws QueryException
-  {
-    if (logger.isDebugEnabled()) {
-      logger.debug("Finding resolver factory for model " + model);
-    }
+  public ResolverFactory findModelResolverFactory(long model) throws QueryException {
 
+    if (logger.isDebugEnabled()) logger.debug("Finding resolver factory for model " + model);
+
     // See if the model is an internal one, with a model type
     try {
       URI modelTypeURI = findModelTypeURI(model);
@@ -210,8 +197,7 @@
         if (logger.isDebugEnabled()) {
           logger.debug("Model " + model + " type is " + modelTypeURI);
         }
-        InternalResolverFactory internalResolverFactory =
-          (InternalResolverFactory) internalResolverFactoryMap.get(modelTypeURI);
+        InternalResolverFactory internalResolverFactory = internalResolverFactoryMap.get(modelTypeURI);
 
         if (internalResolverFactory == null) {
           throw new QueryException("Unsupported model type for model " + model);        }
@@ -275,8 +261,7 @@
         }
 
         // find the factory for this protocol
-        ResolverFactory resolverFactory =
-            (ResolverFactory) externalResolverFactoryMap.get(modelProtocol);
+        ResolverFactory resolverFactory = externalResolverFactoryMap.get(modelProtocol);
         if (resolverFactory == null) {
           throw new QueryException(
               "Unsupported protocol for destination model (" +
@@ -309,12 +294,10 @@
    * @return a completely unwrapped resolver factory
    */
   // TODO: Common code with findModelResolverFactory should be consolidated.
-  private ResolverFactory findResolverFactory(long model) throws QueryException
-  {
-    if (logger.isDebugEnabled()) {
-      logger.debug("Finding raw resolver factory for model " + model);
-    }
+  private ResolverFactory findResolverFactory(long model) throws QueryException {
 
+    if (logger.isDebugEnabled()) logger.debug("Finding raw resolver factory for model " + model);
+
     try {
       // get the model URI
       Node modelNode = systemResolver.globalize(model);
@@ -345,8 +328,7 @@
       }
 
       // find the factory for this protocol
-      ResolverFactory resolverFactory =
-          (ResolverFactory) externalResolverFactoryMap.get(modelProtocol);
+      ResolverFactory resolverFactory = externalResolverFactoryMap.get(modelProtocol);
       if (resolverFactory == null) {
         throw new QueryException(
             "Unsupported protocol for destination model (" +
@@ -359,24 +341,18 @@
     }
   }
 
-  public ResolverFactory findModelTypeResolverFactory(URI modelTypeURI)
-    throws QueryException
-  {
-    return (InternalResolverFactory) internalResolverFactoryMap.get(modelTypeURI);
+  public ResolverFactory findModelTypeResolverFactory(URI modelTypeURI) throws QueryException {
+    return internalResolverFactoryMap.get(modelTypeURI);
   }
 
-  public List getSecurityAdapterList()
-  {
+  public List<SecurityAdapter> getSecurityAdapterList() {
     return securityAdapterList;
   }
 
-  public Resolver obtainResolver(ResolverFactory resolverFactory)
-    throws QueryException
-  {
-    ResolverSession session;
+  public Resolver obtainResolver(ResolverFactory resolverFactory) throws QueryException {
 
     // Obtain a resolver
-    Resolver resolver = (Resolver) enlistedResolverMap.get(resolverFactory);
+    Resolver resolver = enlistedResolverMap.get(resolverFactory);
     if (resolver != null) {
       return resolver;
     }
@@ -446,9 +422,7 @@
 
   public URI mapToModelTypeURI(URI modelURI) throws QueryException {
     try {
-      if (logger.isDebugEnabled()) {
-        logger.debug("Finding modelTypeURI for " + modelURI);
-      }
+      if (logger.isDebugEnabled()) logger.debug("Finding modelTypeURI for " + modelURI);
       long rawModel = systemResolver.localize(new URIReferenceImpl(modelURI));
       long canModel = getCanonicalModel(rawModel);
 
@@ -479,17 +453,13 @@
    *   system
    * @throws QueryException if the model type can't be determined
    */
-  private URI findModelTypeURI(long model)
-    throws QueryException, GlobalizeException
-  {
+  private URI findModelTypeURI(long model) throws QueryException, GlobalizeException {
     // If model is a query-node, model cannot exist in the system model so return null.
-    if (model < 0) {
-      return null;
-    }
+    if (model < 0) return null;
 
     // Check our cached version of the system model
     LocalNode modelLocalNode = new LocalNode(model);
-    URI modelTypeURI = (URI) systemModelCacheMap.get(modelLocalNode);
+    URI modelTypeURI = systemModelCacheMap.get(modelLocalNode);
     if (modelTypeURI != null) {
       return modelTypeURI;
     }
@@ -543,8 +513,7 @@
    * @throws QueryException if the <var>node</var> can't be globalized or
    *   isn't a URI reference
    */
-  private String findProtocol(long n) throws QueryException
-  {
+  private String findProtocol(long n) throws QueryException {
     try {
       // Globalize the node
       Node node = (Node) systemResolver.globalize(n);
@@ -658,14 +627,12 @@
       long realModel = getCanonicalModel(model);
 
       // Make sure security adapters are satisfied
-      for (Iterator i = securityAdapterList.iterator(); i.hasNext();) {
-        SecurityAdapter securityAdapter = (SecurityAdapter) i.next();
+      for (SecurityAdapter securityAdapter: securityAdapterList) {
 
         // Lie to the user
         if (!securityAdapter.canSeeModel(realModel, systemResolver)) {
           try {
-            throw new QueryException(
-              "No such model " + systemResolver.globalize(realModel));
+            throw new QueryException("No such model " + systemResolver.globalize(realModel));
           } catch (GlobalizeException e) {
             logger.warn("Unable to globalize model " + realModel);
             throw new QueryException("No such model");
@@ -673,8 +640,7 @@
         }
       }
 
-      for (Iterator i = securityAdapterList.iterator(); i.hasNext();) {
-        SecurityAdapter securityAdapter = (SecurityAdapter) i.next();
+      for (SecurityAdapter securityAdapter: securityAdapterList) {
 
         // Tell a different lie to the user
         if (!securityAdapter.canResolve(realModel, systemResolver)) {
@@ -725,9 +691,7 @@
     //
     //Iterator i = resolverFactoryList.iterator();
 
-    Iterator i = internalResolverFactoryMap.values().iterator();
-    while (i.hasNext()) {
-      ResolverFactory resolverFactory = (ResolverFactory) i.next();
+    for (ResolverFactory resolverFactory: internalResolverFactoryMap.values()) {
       assert resolverFactory != null;
 
       // Resolve the constraint
@@ -797,8 +761,7 @@
     model = getCanonicalModel(model);
 
     // Make sure security adapters are satisfied
-    for (Iterator i = securityAdapterList.iterator(); i.hasNext(); ) {
-      SecurityAdapter securityAdapter = (SecurityAdapter) i.next();
+    for (SecurityAdapter securityAdapter: securityAdapterList) {
 
       // Lie to the user
       if (!securityAdapter.canSeeModel(model, systemResolver)) {
@@ -826,8 +789,7 @@
     }
   }
 
-  public Answer doQuery(Query query) throws Exception
-  {
+  public Answer doQuery(Query query) throws Exception {
     TransactionalAnswer result;
 
     LocalQuery localQuery = new LocalQuery(query, systemResolver, this);
@@ -856,10 +818,9 @@
     if (symbolicLogger.isDebugEnabled()) {
       symbolicLogger.debug("Before transformation: " + mutableLocalQueryImpl);
     }
-    Iterator i = symbolicTransformationList.iterator();
+    Iterator<SymbolicTransformation> i = symbolicTransformationList.iterator();
     while (i.hasNext()) {
-      SymbolicTransformation symbolicTransformation =
-        (SymbolicTransformation) i.next();
+      SymbolicTransformation symbolicTransformation = i.next();
       assert symbolicTransformation != null;
       symbolicTransformation.transform(this, mutableLocalQueryImpl);
       if (mutableLocalQueryImpl.isModified()) {
@@ -871,6 +832,7 @@
         }
         mutableLocalQueryImpl.close();
         mutableLocalQueryImpl = localQuery.new MutableLocalQueryImpl();
+        // start again
         i = symbolicTransformationList.iterator();
       }
     }
@@ -918,8 +880,8 @@
       try {
         Resolver temporaryResolver =
           temporaryResolverFactory.newResolver(true, systemResolver, systemResolver);
-        for (Iterator i = cachedModelSet.iterator(); i.hasNext();) {
-          LocalNode modelLocalNode = (LocalNode) i.next();
+        for (Iterator<LocalNode> i = cachedModelSet.iterator(); i.hasNext();) {
+          LocalNode modelLocalNode = i.next();
           long model = modelLocalNode.getValue();
 
           if (changedCachedModelSet.contains(modelLocalNode)) {

Modified: branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java
===================================================================
--- branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/DatabaseSession.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -31,15 +31,9 @@
 
 // Java 2 standard packages
 import java.io.*;
-import java.lang.reflect.*;
 import java.net.URI;
-import java.net.URISyntaxException;
 import java.util.*;
 
-// Java 2 enterprise packages
-import javax.transaction.RollbackException;
-import javax.transaction.Status;
-
 // Third party packages
 import org.apache.log4j.Logger;
 import org.jrdf.graph.*;
@@ -48,14 +42,10 @@
 import org.mulgara.content.ContentHandler;
 import org.mulgara.content.ContentHandlerManager;
 import org.mulgara.query.*;
-import org.mulgara.query.rdf.*;
 import org.mulgara.resolver.spi.*;
-import org.mulgara.resolver.spi.ResolverFactoryException;
 import org.mulgara.rules.*;
 import org.mulgara.server.Session;
 import org.mulgara.store.nodepool.NodePool;
-import org.mulgara.store.tuples.Tuples;
-import org.mulgara.store.tuples.TuplesOperations;
 
 /**
  * A database session.
@@ -64,12 +54,6 @@
  *
  * @author <a href="http://staff.pisoftware.com/raboczi">Simon Raboczi</a>
  *
- * @version $Revision: 1.17 $
- *
- * @modified $Date: 2005/07/03 13:00:26 $ by $Author: pgearon $
- *
- * @maintenanceAuthor $Author: pgearon $
- *
  * @copyright &copy;2004 <a href="http://www.tucanatech.com/">Tucana
  *   Technology, Inc</a>
  *
@@ -88,30 +72,34 @@
    *
    * This field is read-only.
    */
-  private final Set cachedResolverFactorySet;
+  private final Set<ResolverFactory> cachedResolverFactorySet;
 
-  /** The list of all registered {@link ResolverFactory} instances.  */
-  private final List resolverFactoryList;
+  /**
+   * The list of all registered {@link ResolverFactory} instances.
+   * Not used in this implementation.
+   */
+  @SuppressWarnings("unused")
+  private final List<ResolverFactory> resolverFactoryList;
 
   /**
    * Map from URL protocol {@link String}s to the {@link ResolverFactory} which
    * handles external models using that protocol.
    */
-  private final Map externalResolverFactoryMap;
+  private final Map<String,ResolverFactory> externalResolverFactoryMap;
 
   /**
    * Map from modelType {@link LocalNode}s to the {@link ResolverFactory} which
    * handles that model type.
    */
-  private final Map internalResolverFactoryMap;
+  private final Map<URI,InternalResolverFactory> internalResolverFactoryMap;
 
   private final DatabaseMetadata metadata;
 
   /** Security adapters this instance should enforce. */
-  private final List securityAdapterList;
+  private final List<SecurityAdapter> securityAdapterList;
 
   /** Symbolic transformations this instance should apply. */
-  private final List symbolicTransformationList;
+  private final List<SymbolicTransformation> symbolicTransformationList;
 
   /** Persistent string pool. */
   private final ResolverSessionFactory resolverSessionFactory;
@@ -171,17 +159,17 @@
    * @throws IllegalArgumentException if any argument is <code>null</code>
    */
   DatabaseSession(MulgaraTransactionManager transactionManager,
-      List securityAdapterList,
-      List symbolicTransformationList,
+      List<SecurityAdapter> securityAdapterList,
+      List<SymbolicTransformation> symbolicTransformationList,
       ResolverSessionFactory resolverSessionFactory,
       SystemResolverFactory systemResolverFactory,
       ResolverFactory temporaryResolverFactory,
-      List resolverFactoryList,
-      Map externalResolverFactoryMap,
-      Map internalResolverFactoryMap,
+      List<ResolverFactory> resolverFactoryList,
+      Map<String,ResolverFactory> externalResolverFactoryMap,
+      Map<URI,InternalResolverFactory> internalResolverFactoryMap,
       DatabaseMetadata metadata,
       ContentHandlerManager contentHandlers,
-      Set cachedResolverFactorySet,
+      Set<ResolverFactory> cachedResolverFactorySet,
       URI temporaryModelTypeURI,
       String ruleLoaderClassName) throws ResolverFactoryException {
 
@@ -251,17 +239,17 @@
    * Non-rule version of the constructor.  Accepts all parameters except ruleLoaderClassName.
    */
   DatabaseSession(MulgaraTransactionManager transactionManager,
-      List securityAdapterList,
-      List symbolicTransformationList,
+      List<SecurityAdapter> securityAdapterList,
+      List<SymbolicTransformation> symbolicTransformationList,
       ResolverSessionFactory resolverSessionFactory,
       SystemResolverFactory systemResolverFactory,
       ResolverFactory temporaryResolverFactory,
-      List resolverFactoryList,
-      Map externalResolverFactoryMap,
-      Map internalResolverFactoryMap,
+      List<ResolverFactory> resolverFactoryList,
+      Map<String,ResolverFactory> externalResolverFactoryMap,
+      Map<URI,InternalResolverFactory> internalResolverFactoryMap,
       DatabaseMetadata metadata,
       ContentHandlerManager contentHandlers,
-      Set cachedResolverFactorySet,
+      Set<ResolverFactory> cachedResolverFactorySet,
       URI temporaryModelTypeURI) throws ResolverFactoryException {
     this(transactionManager, securityAdapterList, symbolicTransformationList, resolverSessionFactory,
         systemResolverFactory, temporaryResolverFactory, resolverFactoryList, externalResolverFactoryMap,
@@ -309,7 +297,7 @@
   // Methods implementing Session
   //
 
-  public void insert(URI modelURI, Set statements) throws QueryException {
+  public void insert(URI modelURI, Set<Triple> statements) throws QueryException {
     modify(modelURI, statements, ASSERT_STATEMENTS);
   }
 
@@ -317,7 +305,7 @@
     modify(modelURI, query, ASSERT_STATEMENTS);
   }
 
-  public void delete(URI modelURI, Set statements) throws QueryException {
+  public void delete(URI modelURI, Set<Triple> statements) throws QueryException {
     modify(modelURI, statements, DENY_STATEMENTS);
   }
 
@@ -389,7 +377,7 @@
     return queryOperation.getAnswer();
   }
 
-  public List query(List queryList) throws QueryException {
+  public List<Answer> query(List<Query> queryList) throws QueryException {
     if (logger.isInfoEnabled()) {
       StringBuffer log = new StringBuffer("QUERYING LIST: ");
       for (int i = 0; i < queryList.size(); i++) {
@@ -567,8 +555,8 @@
 
     if (securityDomain.equals(metadata.getSecurityDomainURI())) {
       // Propagate the login event to the security adapters
-      for (Iterator i = securityAdapterList.iterator(); i.hasNext();) {
-        ((SecurityAdapter) i.next()).login(user, password);
+      for (SecurityAdapter adapter: securityAdapterList) {
+        adapter.login(user, password);
       }
     }
   }
@@ -594,7 +582,7 @@
   //
   // Internal utility methods.
   //
-  protected void modify(URI modelURI, Set statements, boolean insert) throws QueryException
+  protected void modify(URI modelURI, Set<Triple> statements, boolean insert) throws QueryException
   {
     if (logger.isInfoEnabled()) {
       logger.info("Inserting statements into " + modelURI);

Modified: branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/DatabaseSessionListQueryUnitTest.java
===================================================================
--- branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/DatabaseSessionListQueryUnitTest.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/DatabaseSessionListQueryUnitTest.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -29,8 +29,6 @@
 
 // Java 2 standard packages
 import java.io.File;
-import java.io.PrintWriter;
-import java.io.StringWriter;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.*;
@@ -42,17 +40,14 @@
 import org.jrdf.vocabulary.RDFS; // JRDF
 
 // Locally written packages
+import org.jrdf.graph.Triple;
 import org.jrdf.graph.URIReference;
 import org.mulgara.query.*;
 import org.mulgara.query.rdf.TripleImpl;
 import org.mulgara.query.rdf.Mulgara;
 import org.mulgara.query.rdf.URIReferenceImpl;
 import org.mulgara.server.Session;
-import org.mulgara.server.SessionFactoryFactory;
-import org.mulgara.store.StoreException;
-import org.mulgara.store.nodepool.NodePool;
 import org.mulgara.store.statement.StatementStore;
-import org.mulgara.store.stringpool.StringPool;
 import org.mulgara.util.FileUtil;
 
 /**
@@ -71,19 +66,13 @@
   /** The URI of the {@link #database}: <code>local:database</code>.  */
   private static final URI databaseURI;
 
-  /**
-   * The URI of the {@link #database}'s system model:
-   * <code>local:database#</code>.
-   */
-  private static final URI systemModelURI;
-
   /** The URI of the {@link #database}'s system model type.  */
   private static final URI memoryModelURI;
 
   /** A list of model URIs that can be queried.
    * local:database#model0 -> local:database#modelNUM_MODELS
    */
-  private static final List modelURIs;
+  private static final List<URI> modelURIs;
 
   /** Number of models to be queried */
   private static final int NUM_MODELS = 10;
@@ -94,11 +83,10 @@
   static {
     try {
       databaseURI = new URI("local:database");
-      systemModelURI = new URI("local:database#");
       memoryModelURI = new URI(Mulgara.NAMESPACE + "MemoryModel");
 
       //generate a number of models to be 'batch' queried
-      modelURIs = new ArrayList();
+      modelURIs = new ArrayList<URI>();
       for (int i = 0; i < NUM_MODELS; i++) {
         modelURIs.add(new URI("local:database#model" + i));
       }
@@ -244,8 +232,8 @@
     try {
 
       session = database.newSession();
-      List queryList = generateQueries();
-      List answerList = session.query(queryList);
+      List<Query> queryList = generateQueries();
+      List<Answer> answerList = session.query(queryList);
 
       //perform operations on the answers
       assertNotNull("Session.query(List) returned null.", answerList);
@@ -280,14 +268,14 @@
    * @throws Exception
    * @return List
    */
-  private List generateQueries() throws Exception {
+  private List<Query> generateQueries() throws Exception {
 
-    List list = new ArrayList();
+    List<Query> list = new ArrayList<Query>();
 
     //create a selectAll query for each modelURI
     for (int i = 0; i < modelURIs.size(); i++) {
 
-      list.add(selectAll((URI) modelURIs.get(i)));
+      list.add(selectAll(modelURIs.get(i)));
     }
 
     return list;
@@ -300,6 +288,7 @@
    * @throws Exception
    * @return Query
    */
+  @SuppressWarnings("unchecked")
   private Query selectAll(URI modelURI) throws Exception {
 
     //select $s $p $o
@@ -316,11 +305,11 @@
     ConstraintImpl varConstraint = new ConstraintImpl(vars[0], vars[1], vars[2]);
 
     return new Query(
-        Arrays.asList(vars), // variable list
+        Arrays.asList((Object[])vars), // variable list
         model, // model expression
         varConstraint, // constraint expr
         null, // no having
-        Collections.EMPTY_LIST, // no ordering
+        (List<Order>)Collections.EMPTY_LIST, // no ordering
         null, // no limit
         0, // zero offset
         new UnconstrainedAnswer() // nothing given
@@ -336,7 +325,7 @@
    */
   private void populateModel(URI modelURI, Session session) throws Exception {
 
-    Set statements = new HashSet();
+    Set<Triple> statements = new HashSet<Triple>();
 
     //add some statements
     URIReference subject = null;

Modified: branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/LocalJRDFDatabaseSession.java
===================================================================
--- branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/LocalJRDFDatabaseSession.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/LocalJRDFDatabaseSession.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -168,6 +168,7 @@
     }
   }
 
+  @SuppressWarnings("unchecked")
   public Answer find(URI modelURI, SubjectNode subject, PredicateNode predicate,
       ObjectNode object) throws GraphException {
 
@@ -190,11 +191,11 @@
       constraint = appendMulgaraIsConstraint(vars[2], toValue(object), constraint);
 
       Query query = new Query(
-          Arrays.asList(vars),             // variable list
+          Arrays.asList((Object[])vars),   // variable list
           new ModelResource(modelURI),     // model expression
           constraint,                      // constraint expr
           null,                            // no having
-          Collections.EMPTY_LIST,          // no ordering
+          (List<Order>)Collections.EMPTY_LIST,          // no ordering
           null,                            // no limit
           0,                               // zero offset
           new UnconstrainedAnswer()        // nothing given

Modified: branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/ModifyModelOperation.java
===================================================================
--- branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/ModifyModelOperation.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/ModifyModelOperation.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -28,7 +28,6 @@
 package org.mulgara.resolver;
 
 // Java 2 standard packages
-import java.io.*;
 import java.net.URI;
 import java.util.*;
 
@@ -86,7 +85,7 @@
    * If this field is not <code>null</code>, {@link #query} will be
    * <code>null</code>
    */
-  private final Set tripleSet;
+  private final Set<Triple> tripleSet;
 
   /**
    * The query generating the statements whose occurence is to be modified.
@@ -98,8 +97,6 @@
    */
   private final boolean insert;
 
-  private final DatabaseSession databaseSession;
-
   //
   // Constructor
   //
@@ -115,7 +112,7 @@
    * @throws IllegalArgumentException if <var>modelURI</var> or
    *   <var>tripleSet</var> are <code>null</code>
    */
-  ModifyModelOperation(URI modelURI, Set tripleSet, boolean insert)
+  ModifyModelOperation(URI modelURI, Set<Triple> tripleSet, boolean insert)
   {
     // Validate "modelURI" parameter
     if (modelURI == null) {
@@ -132,7 +129,6 @@
     this.tripleSet = tripleSet;
     this.query     = null;
     this.insert    = insert;
-    this.databaseSession = null;
   }
 
   /**
@@ -176,7 +172,6 @@
     this.tripleSet = null;
     this.query     = query;
     this.insert    = insert;
-    this.databaseSession = databaseSession;
   }
 
   //
@@ -229,10 +224,7 @@
     model = operationContext.getCanonicalModel(model);
 
     // Make sure security adapters are satisfied
-    for (Iterator i = operationContext.getSecurityAdapterList().iterator();
-         i.hasNext(); )
-    {
-      SecurityAdapter securityAdapter = (SecurityAdapter) i.next();
+    for (SecurityAdapter securityAdapter: (List<SecurityAdapter>)operationContext.getSecurityAdapterList()) {
 
       // Lie to the user
       if (!securityAdapter.canSeeModel(model, systemResolver)) {

Modified: branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/OperationContext.java
===================================================================
--- branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/OperationContext.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/OperationContext.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -35,7 +35,6 @@
 import org.mulgara.query.Answer;
 import org.mulgara.query.Query;
 import org.mulgara.query.QueryException;
-import org.mulgara.resolver.spi.GlobalizeException;
 import org.mulgara.resolver.spi.Resolver;
 import org.mulgara.resolver.spi.ResolverFactory;
 import org.mulgara.resolver.spi.SecurityAdapter;
@@ -88,7 +87,7 @@
    *
    * @return an unmodifiable list of {@link SecurityAdapter}s
    */
-  public List getSecurityAdapterList();
+  public List<SecurityAdapter> getSecurityAdapterList();
 
   /**
    * This method should be used to obtain a {@link Resolver} instance, rather

Modified: branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/QueryOperation.java
===================================================================
--- branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/QueryOperation.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/resolver/java/org/mulgara/resolver/QueryOperation.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -29,11 +29,10 @@
 
 // Java 2 standard packages
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
 // Third party packages
-import org.apache.log4j.Logger;
+// import org.apache.log4j.Logger;
 
 // Local packages
 import org.mulgara.query.*;
@@ -47,12 +46,6 @@
  *
  * @author <a href="http://staff.pisoftware.com/raboczi">Simon Raboczi</a>
  *
- * @version $Revision: 1.8 $
- *
- * @modified $Date: 2005/01/05 04:58:24 $ by $Author: newmana $
- *
- * @maintenanceAuthor $Author: newmana $
- *
  * @copyright &copy;2004 <a href="http://www.tucanatech.com/">Tucana
  *   Technology, Inc</a>
  *
@@ -60,17 +53,11 @@
  */
 class QueryOperation implements Operation
 {
-  /**
-   * Logger.
-   *
-   * This is named after the class.
-   */
-  private static final Logger logger =
-    Logger.getLogger(QueryOperation.class.getName());
+  /** Logger. */
+  // private static final Logger logger = Logger.getLogger(QueryOperation.class.getName());
 
   private final Query query;
-  private final List queryList;
-  private final DatabaseSession databaseSession;
+  private final List<Query> queryList;
 
   /**
    * Answer to the query, or <code>null</code> if the {@link #execute} method
@@ -82,7 +69,7 @@
    * List of {@link Answer}s to a list of queries, or <code>null</code> if the
    * {@link #execute} method hasn't yet been invoked.
    */
-  private List answerList = null;
+  private List<Answer> answerList = null;
 
   //
   // Constructor
@@ -111,7 +98,6 @@
     // Initialize fields
     this.query           = query;
     this.queryList       = null;
-    this.databaseSession = databaseSession;
   }
 
   /**
@@ -123,7 +109,7 @@
    * @throws IllegalArgumentException if <var>queryList</var> or
    *   <var>databaseSession</var> are <code>null</code>
    */
-  QueryOperation(List queryList, DatabaseSession databaseSession)
+  QueryOperation(List<Query> queryList, DatabaseSession databaseSession)
   {
     // Validate "query" parameter
     if (queryList == null) {
@@ -138,7 +124,6 @@
     // Initialize fields
     this.query           = null;
     this.queryList       = queryList;
-    this.databaseSession = databaseSession;
   }
 
   //
@@ -158,9 +143,9 @@
     else {
       assert queryList != null;
 
-      answerList = new ArrayList(queryList.size());
-      for (Iterator i = queryList.iterator(); i.hasNext();) {
-        answerList.add(operationContext.doQuery((Query) i.next()));
+      answerList = new ArrayList<Answer>(queryList.size());
+      for (Query query: queryList) {
+        answerList.add(operationContext.doQuery(query));
       }
     }
   }
@@ -181,8 +166,7 @@
    * @return the answer to the query, never <code>null</code>
    * @throws IllegalStateException  if {@link #execute} hasn't yet been called
    */
-  Answer getAnswer()
-  {
+  Answer getAnswer() {
     if (answer == null) {
       throw new IllegalStateException("Answer not available before execution.");
     }
@@ -195,8 +179,7 @@
    *   <code>null</code>
    * @throws IllegalStateException  if {@link #execute} hasn't yet been called
    */
-  List getAnswerList()
-  {
+  List<Answer> getAnswerList() {
     if (answerList == null) {
       throw new IllegalStateException("Answers not available before execution.");
     }

Modified: branches/nw-interface/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/NetworkDelegator.java
===================================================================
--- branches/nw-interface/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/NetworkDelegator.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/NetworkDelegator.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -40,6 +40,7 @@
 
 import org.apache.log4j.Logger;
 import org.jrdf.graph.Node;
+import org.jrdf.graph.Triple;
 import org.jrdf.graph.URIReference;
 
 import java.net.URI;
@@ -119,7 +120,7 @@
     logger.debug("Adding data to model: " + modelRef + " on server: " + serverUri);
     // convert the data to something shippable
     try {
-      Set statementSet = StatementSetFactory.newStatementSet(statements, session);
+      Set<Triple> statementSet = StatementSetFactory.newStatementSet(statements, session);
       getServerSession(serverUri).insert(modelRef.getURI(), statementSet);
     } catch (GlobalizeException ge) {
       throw new ResolverException("Insertion data can't be sent over a network", ge);
@@ -144,7 +145,7 @@
     logger.debug("Removing data from model: " + modelRef + " on server: " + serverUri);
     // convert the data to something shippable
     try {
-      Set statementSet = StatementSetFactory.newStatementSet(statements, session);
+      Set<Triple> statementSet = StatementSetFactory.newStatementSet(statements, session);
       getServerSession(serverUri).delete(modelRef.getURI(), statementSet);
     } catch (GlobalizeException ge) {
       throw new ResolverException("Deletion data can't be sent over a network", ge);
@@ -197,7 +198,7 @@
     );
 
     // convert the variable set to a variable list - add types via unchecked casts
-    List<Variable> variables = new ArrayList<Variable>((Set<Variable>)globalConstraint.getVariables());
+    List<Object> variables = new ArrayList<Object>((Set<Variable>)globalConstraint.getVariables());
     // build the new query
     return new Query(variables, new ModelResource(model.getURI()), globalConstraint, null, Collections.EMPTY_LIST, null, 0, new UnconstrainedAnswer());
   }

Modified: branches/nw-interface/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/remote/StatementSetFactory.java
===================================================================
--- branches/nw-interface/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/remote/StatementSetFactory.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/resolver-distributed/java/org/mulgara/resolver/distributed/remote/StatementSetFactory.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -35,7 +35,7 @@
   /** The size for transitioning between a serializable set and a remote set. */
   static final long WATER_MARK = 2048L;
 
-  public static Set newStatementSet(Statements statements, ResolverSession session) throws TuplesException, GlobalizeException {
+  public static Set<Triple> newStatementSet(Statements statements, ResolverSession session) throws TuplesException, GlobalizeException {
     // make sure the WATER_MARK refers to a set that is indexable by integer
     assert (long)(int)WATER_MARK == WATER_MARK;
     if (statements.getRowUpperBound() < WATER_MARK) return new ShortGlobalStatementSet(statements, session);

Modified: branches/nw-interface/src/jar/resolver-spi/java/org/mulgara/resolver/spi/TripleSetWrapperStatements.java
===================================================================
--- branches/nw-interface/src/jar/resolver-spi/java/org/mulgara/resolver/spi/TripleSetWrapperStatements.java	2007-08-24 17:23:21 UTC (rev 378)
+++ branches/nw-interface/src/jar/resolver-spi/java/org/mulgara/resolver/spi/TripleSetWrapperStatements.java	2007-08-27 21:10:01 UTC (rev 379)
@@ -31,7 +31,7 @@
 import java.util.Iterator;
 
 // Third party packages
-import org.apache.log4j.Logger;
+// import org.apache.log4j.Logger;
 import org.jrdf.graph.Node;
 import org.jrdf.graph.Triple;
 import gnu.trove.TObjectLongHashMap;
@@ -57,9 +57,8 @@
 
 public class TripleSetWrapperStatements implements Statements
 {
-  /** Logger.  */
-  private final Logger logger =
-    Logger.getLogger(TripleSetWrapperStatements.class.getName());
+  // /** Logger.  */
+  // private final Logger logger = Logger.getLogger(TripleSetWrapperStatements.class.getName());
 
   public static final int PERSIST = 0;
   public static final int TEMP = 1;
@@ -72,8 +71,8 @@
   
   TObjectLongHashMap nodeMap;
 
-  Set triples;
-  Iterator iter;
+  Set<Triple> triples;
+  Iterator<Triple> iter;
   Triple currentTriple;
   boolean persistent;
 
@@ -81,7 +80,7 @@
   // Constructors
   //
 
-  public TripleSetWrapperStatements(Set triples, ResolverSession resolverSession, int persistent)
+  public TripleSetWrapperStatements(Set<Triple> triples, ResolverSession resolverSession, int persistent)
       throws TuplesException {
     this.triples = triples;
     this.resolverSession = resolverSession;
@@ -148,7 +147,7 @@
       currentTriple = null;
       return false;
     } else {
-      currentTriple = (Triple)iter.next();
+      currentTriple = iter.next();
       return true;
     }
   }




More information about the Mulgara-svn mailing list