[Mulgara-svn] r1043 - trunk/src/jar/sparql-interpreter/java/org/mulgara/sparql

pag at mulgara.org pag at mulgara.org
Wed Jul 2 21:37:43 UTC 2008


Author: pag
Date: 2008-07-02 14:37:42 -0700 (Wed, 02 Jul 2008)
New Revision: 1043

Added:
   trunk/src/jar/sparql-interpreter/java/org/mulgara/sparql/ConstantVarFactory.java
Log:
New class to handle creation of unique variables in a context

Added: trunk/src/jar/sparql-interpreter/java/org/mulgara/sparql/ConstantVarFactory.java
===================================================================
--- trunk/src/jar/sparql-interpreter/java/org/mulgara/sparql/ConstantVarFactory.java	                        (rev 0)
+++ trunk/src/jar/sparql-interpreter/java/org/mulgara/sparql/ConstantVarFactory.java	2008-07-02 21:37:42 UTC (rev 1043)
@@ -0,0 +1,45 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.opensource.org/licenses/osl-3.0.txt
+ *
+ * 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.
+ */
+
+package org.mulgara.sparql;
+
+import org.mulgara.query.Variable;
+
+/**
+ * Creates variables to use for constants.
+ *
+ * @created Jun 30, 2008
+ * @author Paul Gearon
+ * @copyright &copy; 2008 <a href="http://www.topazproject.org/">The Topaz Project</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class ConstantVarFactory {
+
+  /** A label to use for all "constant" variables. */
+  private static final String PREFIX = "c";
+
+  /** The internal incrementing counter for identifying variables. */
+  private int id;
+
+  /** Creates a new factory, with a fresh counter. */
+  ConstantVarFactory() {
+    id = 0;
+  }
+
+  /**
+   * Allocate a new variable.
+   * @return The new variable.
+   */
+  public Variable newVar() {
+    return new Variable(PREFIX + id++);
+  }
+}




More information about the Mulgara-svn mailing list