[Mulgara-svn] r360 - branches/nw-interface/src/jar/query/java/org/mulgara/query
pag at mulgara.org
pag at mulgara.org
Tue Aug 21 05:39:12 UTC 2007
Author: pag
Date: 2007-08-21 00:39:11 -0500 (Tue, 21 Aug 2007)
New Revision: 360
Added:
branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintFilteredOperation.java
Modified:
branches/nw-interface/src/jar/query/java/org/mulgara/query/AbstractConstraintExpression.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/Constraint.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintConjunction.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintDifference.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintDisjunction.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintExpression.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintFalse.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintHaving.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintImpl.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintIs.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintNegation.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintNotOccurs.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintOccurs.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintOccursLessThan.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintOccursMoreThan.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintOperation.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintTrue.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/SingleTransitiveConstraint.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/TransitiveConstraint.java
branches/nw-interface/src/jar/query/java/org/mulgara/query/WalkConstraint.java
Log:
Changed most untyped code over to using generics
Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/AbstractConstraintExpression.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/AbstractConstraintExpression.java 2007-08-21 05:37:58 UTC (rev 359)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/AbstractConstraintExpression.java 2007-08-21 05:39:11 UTC (rev 360)
@@ -62,24 +62,19 @@
/**
* A set of all variables the compose the constraint.
*/
- protected Set variables = null;
+ protected Set<Variable> variables = null;
/**
* The operands.
*/
- protected ArrayList elements;
+ protected ArrayList<ConstraintExpression> elements;
public boolean equals(Object o) {
- if (o == null) {
- return false;
- }
- if (o == this) {
- return true;
- }
+ if (o == null) return false;
+ if (o == this) return true;
if (o instanceof ConstraintExpression) {
- ConstraintExpression ce = (ConstraintExpression) o;
- return (getVariables().equals(((ConstraintExpression) o).getVariables()));
+ return (getVariables().equals(((ConstraintExpression)o).getVariables()));
} else {
return false;
}
Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/Constraint.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/Constraint.java 2007-08-21 05:37:58 UTC (rev 359)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/Constraint.java 2007-08-21 05:39:11 UTC (rev 360)
@@ -29,7 +29,6 @@
package org.mulgara.query;
-import java.util.Set;
/**
* A variable and its ordering, for composing <code>ORDER BY</code> clauses.
Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintConjunction.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintConjunction.java 2007-08-21 05:37:58 UTC (rev 359)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintConjunction.java 2007-08-21 05:39:11 UTC (rev 360)
@@ -51,7 +51,7 @@
*
* @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
*/
-public class ConstraintConjunction extends ConstraintOperation {
+public class ConstraintConjunction extends ConstraintFilteredOperation {
/**
* Allow newer compiled version of the stub to operate when changes
@@ -71,27 +71,24 @@
* @param lhs a non-<code>null</code> constraint expression
* @param rhs another non-<code>null</code> constraint expression
*/
- public ConstraintConjunction(ConstraintExpression lhs,
- ConstraintExpression rhs) {
+ public ConstraintConjunction(ConstraintExpression lhs, ConstraintExpression rhs) {
super(lhs, rhs);
}
/**
- * CONSTRUCTOR ConstraintConjunction TO DO
- *
- * @param elements PARAMETER TO DO
+ * Build a conjunction with a {@link List} of several children constraint expressions
+ * @param elements a {@link List} of constraint expressions.
*/
- public ConstraintConjunction(List elements) {
+ public ConstraintConjunction(List<ConstraintExpression> elements) {
super(elements);
}
/**
- * CONSTRUCTOR ConstraintConjunction TO DO
- *
- * @param elements PARAMETER TO DO
+ * Build a conjunction with a {@link Collection} of several children constraint expressions
+ * @param elements a {@link Collection} of {@link ConstraintExpression}s.
*/
- public ConstraintConjunction(Collection elements) {
- super(new ArrayList(elements));
+ public ConstraintConjunction(Collection<ConstraintExpression> elements) {
+ super(new ArrayList<ConstraintExpression>(elements));
}
@@ -102,7 +99,7 @@
*/
public ConstraintConjunction getFiltered() {
- List elements = new ArrayList(this.getElements());
+ List<ConstraintExpression> elements = new ArrayList<ConstraintExpression>(this.getElements());
filter(elements);
return new ConstraintConjunction(elements);
@@ -115,45 +112,6 @@
* @return The Name value
*/
String getName() {
-
return " and ";
}
-
-
- /**
- * METHOD TO DO
- *
- * @param product PARAMETER TO DO
- */
- private void filter(List product) {
-
- Set o1 = new HashSet();
-
- // Variables which occur at least once.
- Set o2 = new HashSet();
-
- // Variables which occur two or more times.
- // Get a set of variables which occur two or more times.
- for (Iterator pIt = product.iterator(); pIt.hasNext(); ) {
-
- ConstraintExpression oc = (ConstraintExpression) pIt.next();
- Set ocVars = oc.getVariables();
- Set vars = new HashSet(ocVars);
- vars.retainAll(o1);
- o2.addAll(vars);
- o1.addAll(ocVars);
- }
-
- for (Iterator pIt = product.iterator(); pIt.hasNext(); ) {
-
- ConstraintExpression oc = (ConstraintExpression) pIt.next();
- Set vars = new HashSet(oc.getVariables());
- vars.retainAll(o2);
-
- if (vars.isEmpty()) {
-
- pIt.remove();
- }
- }
- }
}
Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintDifference.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintDifference.java 2007-08-21 05:37:58 UTC (rev 359)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintDifference.java 2007-08-21 05:39:11 UTC (rev 360)
@@ -48,7 +48,7 @@
*
* @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
*/
-public class ConstraintDifference extends ConstraintOperation {
+public class ConstraintDifference extends ConstraintFilteredOperation {
/**
* Allow newer compiled version of the stub to operate when changes
@@ -80,11 +80,11 @@
*/
public ConstraintDifference getFiltered() {
- List elements = new ArrayList(this.getElements());
+ List<ConstraintExpression> elements = new ArrayList<ConstraintExpression>(this.getElements());
filter(elements);
assert elements.size() == 2;
- return new ConstraintDifference((ConstraintExpression)elements.get(0), (ConstraintExpression)elements.get(1));
+ return new ConstraintDifference(elements.get(0), elements.get(1));
}
@@ -94,45 +94,7 @@
* @return The Name value
*/
String getName() {
-
return " minus ";
}
-
- /**
- * METHOD TO DO
- *
- * @param product PARAMETER TO DO
- */
- private void filter(List product) {
-
- Set o1 = new HashSet();
-
- // Variables which occur at least once.
- Set o2 = new HashSet();
-
- // Variables which occur two or more times.
- // Get a set of variables which occur two or more times.
- for (Iterator pIt = product.iterator(); pIt.hasNext(); ) {
-
- ConstraintExpression oc = (ConstraintExpression) pIt.next();
- Set ocVars = oc.getVariables();
- Set vars = new HashSet(ocVars);
- vars.retainAll(o1);
- o2.addAll(vars);
- o1.addAll(ocVars);
- }
-
- for (Iterator pIt = product.iterator(); pIt.hasNext(); ) {
-
- ConstraintExpression oc = (ConstraintExpression) pIt.next();
- Set vars = new HashSet(oc.getVariables());
- vars.retainAll(o2);
-
- if (vars.isEmpty()) {
-
- pIt.remove();
- }
- }
- }
}
Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintDisjunction.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintDisjunction.java 2007-08-21 05:37:58 UTC (rev 359)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintDisjunction.java 2007-08-21 05:39:11 UTC (rev 360)
@@ -63,27 +63,21 @@
static final long serialVersionUID = -6389569358524360795L;
/**
- * A set of all variables the compose the constraint.
- */
- private Set variables = null;
-
- /**
* Construct a constraint disjunction.
*
* @param lhs a non-<code>null</code> constraint expression
* @param rhs another non-<code>null</code> constraint expression
*/
- public ConstraintDisjunction(ConstraintExpression lhs,
- ConstraintExpression rhs) {
+ public ConstraintDisjunction(ConstraintExpression lhs, ConstraintExpression rhs) {
super(lhs, rhs);
}
/**
- * CONSTRUCTOR ConstraintDisjunction TO DO
+ * Create a Disjunction (OR expression) between several constraint expressions.
*
- * @param elements PARAMETER TO DO
+ * @param elements The expressions to perform a disjunction on.
*/
- public ConstraintDisjunction(List elements) {
+ public ConstraintDisjunction(List<ConstraintExpression> elements) {
super(elements);
}
Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintExpression.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintExpression.java 2007-08-21 05:37:58 UTC (rev 359)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintExpression.java 2007-08-21 05:39:11 UTC (rev 360)
@@ -61,10 +61,9 @@
static final long serialVersionUID = 3476137906321174349L;
/**
- * Get all constraints which are variables. For back-compatibility, this
- * method currently ignores the fourth element of the triple.
+ * Get all variables from component constraints.
*
* @return A set containing all variable constraints.
*/
- public Set getVariables();
+ public Set<Variable> getVariables();
}
Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintFalse.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintFalse.java 2007-08-21 05:37:58 UTC (rev 359)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintFalse.java 2007-08-21 05:39:11 UTC (rev 360)
@@ -101,8 +101,8 @@
*
* @return A set containing all variable constraints.
*/
- public Set getVariables() {
- return new HashSet();
+ public Set<Variable> getVariables() {
+ return new HashSet<Variable>();
}
//
Added: branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintFilteredOperation.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintFilteredOperation.java 2007-08-21 05:37:58 UTC (rev 359)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintFilteredOperation.java 2007-08-21 05:39:11 UTC (rev 360)
@@ -0,0 +1,81 @@
+/**
+ * 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.query;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * A constraint operation where the result uses an intersection of variables from the parameters.
+ *
+ * @created Aug 20, 2007
+ * @author Paul Gearon
+ * @copyright © 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 abstract class ConstraintFilteredOperation extends ConstraintOperation {
+
+ /**
+ * Create a binary operation for requiring intersecting variables.
+ * @param lhs The first constraint operations.
+ * @param rhs The second constraint operations.
+ */
+ public ConstraintFilteredOperation(ConstraintExpression lhs, ConstraintExpression rhs) {
+ super(lhs, rhs);
+ }
+
+
+ /**
+ * Create an operation for requiring intersecting variables.
+ * @param elements The list of expressions to use as parameters.
+ */
+ public ConstraintFilteredOperation(List<ConstraintExpression> elements) {
+ super(elements);
+ }
+
+ /**
+ * Remove the constraint expressions from the product that have non-intersecting variables.
+ *
+ * @param product The list of constraints to test and modify.
+ */
+ protected void filter(List<ConstraintExpression> product) {
+
+ Set<Variable> o1 = new HashSet<Variable>();
+
+ // Variables which occur at least once.
+ Set<Variable> o2 = new HashSet<Variable>();
+
+ // Variables which occur two or more times.
+ // Get a set of variables which occur two or more times.
+ for (ConstraintExpression oc: product) {
+
+ Set<Variable> ocVars = oc.getVariables();
+ Set<Variable> vars = new HashSet<Variable>(ocVars);
+ vars.retainAll(o1);
+ o2.addAll(vars);
+ o1.addAll(ocVars);
+ }
+
+ // remove the expressions which have non-intersecting variables
+ for (Iterator<ConstraintExpression> pIt = product.iterator(); pIt.hasNext(); ) {
+
+ ConstraintExpression oc = pIt.next();
+ Set<Variable> vars = new HashSet<Variable>(oc.getVariables());
+ vars.retainAll(o2);
+
+ if (vars.isEmpty()) pIt.remove();
+ }
+ }
+
+}
\ No newline at end of file
Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintHaving.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintHaving.java 2007-08-21 05:37:58 UTC (rev 359)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintHaving.java 2007-08-21 05:39:11 UTC (rev 360)
@@ -33,11 +33,9 @@
import java.util.*;
// Third party packages
-import org.apache.log4j.Category;
+// import org.apache.log4j.Category;
import org.jrdf.graph.*;
-// Local packages
-import org.mulgara.query.rdf.URIReferenceImpl;
/**
* An equality constraint. The elements within the constraint can be either variables or
@@ -62,11 +60,8 @@
*/
public abstract class ConstraintHaving extends AbstractConstraintExpression implements Constraint {
- /**
- * Logger.
- */
- private final static Category logger =
- Category.getInstance(ConstraintHaving.class.getName());
+ // /** Logger. */
+ // private final static Category logger = Category.getInstance(ConstraintHaving.class.getName());
/**
* The 4-tuple of elements (either nodes or variables)
@@ -151,15 +146,13 @@
*
* @return A set containing all variable constraints.
*/
- public Set getVariables() {
+ public Set<Variable> getVariables() {
if (variables == null) {
- Set v = new HashSet();
+ Set<Variable> v = new HashSet<Variable>();
Variable e = getVariable();
- if (!e.getName().startsWith("_")) {
- v.add(e);
- }
+ if (!e.getName().startsWith("_")) v.add(e);
if (element[3] instanceof Variable && !((Variable)element[3]).getName().startsWith("_")) {
- v.add(element[3]);
+ v.add((Variable)element[3]);
}
variables = Collections.unmodifiableSet(v);
}
@@ -174,18 +167,12 @@
* @return <code>true</code> if object is the same as this.
*/
public boolean equals(Object object) {
- if (object == null) {
- return false;
- }
+ if (object == null) return false;
- if (object == this) {
- return true;
- }
+ if (object == this) return true;
// Check that the given object is the correct class
- if (!object.getClass().equals(this.getClass())) {
- return false;
- }
+ if (!object.getClass().equals(this.getClass())) return false;
// Check each element.
ConstraintHaving tmpConstraint = (ConstraintHaving) object;
Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintImpl.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintImpl.java 2007-08-21 05:37:58 UTC (rev 359)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintImpl.java 2007-08-21 05:39:11 UTC (rev 360)
@@ -33,7 +33,7 @@
import java.util.*;
// Third party packages
-import org.apache.log4j.Category;
+// import org.apache.log4j.Category;
/**
* A constraint. The elements within the constraint can be either variables or
@@ -56,8 +56,7 @@
*
* @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
*/
-public class ConstraintImpl extends AbstractConstraintExpression implements
- Constraint {
+public class ConstraintImpl extends AbstractConstraintExpression implements Constraint {
/**
* Allow newer compiled version of the stub to operate when changes
@@ -67,11 +66,8 @@
*/
static final long serialVersionUID = -3127160729187334757L;
- /**
- * Logger.
- */
- private final static Category logger =
- Category.getInstance(ConstraintImpl.class.getName());
+ // /** Logger. */
+ // private final static Category logger = Category.getInstance(ConstraintImpl.class.getName());
/**
* The 4-tuple of elements (either nodes or variables)
@@ -172,18 +168,17 @@
}
/**
- * Get all constraints which are variables. For back-compatibility, this
- * method currently ignores the fourth element of the triple.
+ * Get all constraints which are variables. This
+ * method uses the fourth element of the triple.
*
* @return A set containing all variable constraints.
*/
- public Set getVariables() {
+ public Set<Variable> getVariables() {
if (variables == null) {
- Set v = new HashSet();
+ Set<Variable> v = new HashSet<Variable>();
for (int i = 0; i < 4; i++) {
- if (element[i] instanceof Variable &&
- ! ( (Variable) element[i]).getName().startsWith("_")) {
- v.add(element[i]);
+ if (element[i] instanceof Variable && !((Variable)element[i]).getName().startsWith("_")) {
+ v.add((Variable)element[i]);
}
}
variables = Collections.unmodifiableSet(v);
@@ -194,25 +189,17 @@
/**
* Equality is by value.
*
- * @param object PARAMETER TO DO
- * @return RETURNED VALUE TO DO
+ * @param object The instance to compare to
+ * @return <code>true</code> iff objects are compatible and contain the same data.
*/
public boolean equals(Object object) {
// FIXME: Refactor to exploit equals() method on ConstraintExpression.
- if (object == null) {
+ if (object == null) return false;
+ if (object == this) return true;
- return false;
- }
-
- if (object == this) {
-
- return true;
- }
-
boolean returnValue = false;
- // Check that the given object is the correct class if so check each
- // element.
+ // Check that the given object is the correct class if so check each element.
if (object.getClass().equals(this.getClass())) {
Constraint tmpConstraint = (Constraint) object;
@@ -227,10 +214,10 @@
return returnValue;
}
+
/**
- * METHOD TO DO
- *
- * @return RETURNED VALUE TO DO
+ * Generate a relatively unique number for the given data
+ * @return A reproducible number that changes with the data
*/
public int hashCode() {
@@ -238,6 +225,7 @@
element[2].hashCode() + element[3].hashCode();
}
+
/**
* Creates a string representation of these constraints. A typical result
* might be <code>[$x <urn:foo> 'bar' $0]</code>.
Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintIs.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintIs.java 2007-08-21 05:37:58 UTC (rev 359)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintIs.java 2007-08-21 05:39:11 UTC (rev 360)
@@ -33,7 +33,7 @@
import java.util.*;
// Third party packages
-import org.apache.log4j.Category;
+// import org.apache.log4j.Category;
// Local packages
import org.mulgara.query.rdf.URIReferenceImpl;
@@ -61,12 +61,12 @@
*/
public class ConstraintIs extends AbstractConstraintExpression implements Constraint {
- /**
- * Logger.
- */
- private final static Category logger =
- Category.getInstance(ConstraintIs.class.getName());
+ /** Serialization ID for marshalling */
+ private static final long serialVersionUID = 7952821738407976852L;
+ // /** Logger. */
+ // private final static Category logger = Category.getInstance(ConstraintIs.class.getName());
+
/** Create the predicate to be used to indicate equality. */
public static final URIReferenceImpl MULGARA_IS = new URIReferenceImpl(SpecialPredicates.MULGARA_IS);
@@ -168,20 +168,19 @@
/**
- * Get all constraints which are variables. For back-compatibility, this
- * method currently ignores the fourth element of the triple.
+ * Get all constraints which are variables. This
+ * method now uses the fourth element of the triple.
*
* @return A set containing all variable constraints.
*/
- public Set getVariables() {
+ public Set<Variable> getVariables() {
if (variables == null) {
- Set v = new HashSet();
+ Set<Variable> v = new HashSet<Variable>();
Variable e = getVariable();
- if (!e.getName().startsWith("_")) {
- v.add(e);
- }
+ if (!e.getName().startsWith("_")) v.add(e);
+ // now check the graph
if (element[3] instanceof Variable && !((Variable)element[3]).getName().startsWith("_")) {
- v.add(element[3]);
+ v.add((Variable)element[3]);
}
variables = Collections.unmodifiableSet(v);
}
@@ -196,18 +195,12 @@
* @return <code>true</code> if object is the same as this.
*/
public boolean equals(Object object) {
- if (object == null) {
- return false;
- }
+ if (object == null) return false;
- if (object == this) {
- return true;
- }
+ if (object == this) return true;
// Check that the given object is the correct class
- if (!object.getClass().equals(this.getClass())) {
- return false;
- }
+ if (!object.getClass().equals(this.getClass())) return false;
// Check each element.
ConstraintIs tmpConstraint = (ConstraintIs) object;
Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintNegation.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintNegation.java 2007-08-21 05:37:58 UTC (rev 359)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintNegation.java 2007-08-21 05:39:11 UTC (rev 360)
@@ -32,7 +32,7 @@
import java.util.*;
// Third party packages
-import org.apache.log4j.Logger;
+// import org.apache.log4j.Logger;
/**
* A constraint expression composed of the negation (logical NOT) of one
@@ -57,11 +57,8 @@
*/
public class ConstraintNegation implements Constraint {
- /**
- * The logger
- */
- private final static Logger logger =
- Logger.getLogger(ConstraintNegation.class.getName());
+ // /** The logger */
+ // private final static Logger logger = Logger.getLogger(ConstraintNegation.class.getName());
/**
* Allow newer compiled version of the stub to operate when changes
@@ -125,7 +122,7 @@
*
* @return A set containing all variable constraints.
*/
- public Set getVariables() {
+ public Set<Variable> getVariables() {
return constraint.getVariables();
}
Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintNotOccurs.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintNotOccurs.java 2007-08-21 05:37:58 UTC (rev 359)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintNotOccurs.java 2007-08-21 05:39:11 UTC (rev 360)
@@ -27,11 +27,8 @@
package org.mulgara.query;
-// Java 2 standard packages
-import java.util.*;
-
// Third party packages
-import org.apache.log4j.Category;
+// import org.apache.log4j.Category;
// Local packages
import org.mulgara.query.rdf.URIReferenceImpl;
@@ -59,11 +56,16 @@
*/
public class ConstraintNotOccurs extends ConstraintHaving {
+ // /** Logger. */
+ // private final static Category logger = Category.getInstance(ConstraintOccurs.class.getName());
+
/**
- * Logger.
+ * Allow newer compiled version of the stub to operate when changes
+ * have not occurred with the class.
+ * NOTE : update this serialVersionUID when a method or a public member is
+ * deleted.
*/
- private final static Category logger =
- Category.getInstance(ConstraintOccurs.class.getName());
+ private static final long serialVersionUID = 1125962088193740608L;
/**
* Create the predicate to be used to indicate equality.
Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintOccurs.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintOccurs.java 2007-08-21 05:37:58 UTC (rev 359)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintOccurs.java 2007-08-21 05:39:11 UTC (rev 360)
@@ -27,11 +27,8 @@
package org.mulgara.query;
-// Java 2 standard packages
-import java.util.*;
-
// Third party packages
-import org.apache.log4j.Category;
+// import org.apache.log4j.Category;
// Local packages
import org.mulgara.query.rdf.URIReferenceImpl;
@@ -59,11 +56,16 @@
*/
public class ConstraintOccurs extends ConstraintHaving {
+ // /** Logger. */
+ // private final static Category logger = Category.getInstance(ConstraintOccurs.class.getName());
+
/**
- * Logger.
+ * Allow newer compiled version of the stub to operate when changes
+ * have not occurred with the class.
+ * NOTE : update this serialVersionUID when a method or a public member is
+ * deleted.
*/
- private final static Category logger =
- Category.getInstance(ConstraintOccurs.class.getName());
+ private static final long serialVersionUID = -5881219717825517770L;
/**
* Create the predicate to be used to indicate equality.
Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintOccursLessThan.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintOccursLessThan.java 2007-08-21 05:37:58 UTC (rev 359)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintOccursLessThan.java 2007-08-21 05:39:11 UTC (rev 360)
@@ -27,11 +27,8 @@
package org.mulgara.query;
-// Java 2 standard packages
-import java.util.*;
-
// Third party packages
-import org.apache.log4j.Category;
+// import org.apache.log4j.Category;
// Local packages
import org.mulgara.query.rdf.URIReferenceImpl;
@@ -59,11 +56,16 @@
*/
public class ConstraintOccursLessThan extends ConstraintHaving {
+ // /** Logger. */
+ // private final static Category logger = Category.getInstance(ConstraintOccursLessThan.class.getName());
+
/**
- * Logger.
+ * Allow newer compiled version of the stub to operate when changes
+ * have not occurred with the class.
+ * NOTE : update this serialVersionUID when a method or a public member is
+ * deleted.
*/
- private final static Category logger =
- Category.getInstance(ConstraintOccursLessThan.class.getName());
+ private static final long serialVersionUID = -4589400796204186895L;
/**
* Create the predicate to be used to indicate equality.
Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintOccursMoreThan.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintOccursMoreThan.java 2007-08-21 05:37:58 UTC (rev 359)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintOccursMoreThan.java 2007-08-21 05:39:11 UTC (rev 360)
@@ -27,11 +27,8 @@
package org.mulgara.query;
-// Java 2 standard packages
-import java.util.*;
-
// Third party packages
-import org.apache.log4j.Category;
+// import org.apache.log4j.Category;
// Local packages
import org.mulgara.query.rdf.URIReferenceImpl;
@@ -42,7 +39,7 @@
*
* @created 2004-08-12
*
- * @author <a href="mailto:pag at tucanatech.com">Paul Gearon</a>
+ * @author <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
*
* @version $Revision: 1.9 $
*
@@ -59,11 +56,16 @@
*/
public class ConstraintOccursMoreThan extends ConstraintHaving {
+ // /** Logger. */
+ // private final static Category logger = Category.getInstance(ConstraintOccursMoreThan.class.getName());
+
/**
- * Logger.
+ * Allow newer compiled version of the stub to operate when changes
+ * have not occurred with the class.
+ * NOTE : update this serialVersionUID when a method or a public member is
+ * deleted.
*/
- private final static Category logger =
- Category.getInstance(ConstraintOccursMoreThan.class.getName());
+ private static final long serialVersionUID = 8077840346515987908L;
/**
* Create the predicate to be used to indicate equality.
Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintOperation.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintOperation.java 2007-08-21 05:37:58 UTC (rev 359)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintOperation.java 2007-08-21 05:39:11 UTC (rev 360)
@@ -31,7 +31,7 @@
import java.util.*;
// Third party packages
-import org.apache.log4j.Category;
+// import org.apache.log4j.Category;
/**
* A constraint expression composed of two subexpressions and a dyadic operator.
@@ -64,11 +64,8 @@
*/
static final long serialVersionUID = -236847137057853871L;
- /**
- * Logger.
- */
- private static Category logger =
- Category.getInstance(ConstraintOperation.class.getName());
+ // /** Logger. */
+ // private static Category logger = Category.getInstance(ConstraintOperation.class.getName());
//
// Constructor
@@ -84,21 +81,17 @@
*/
protected ConstraintOperation(ConstraintExpression lhs, ConstraintExpression rhs) {
// Validate "lhs" parameter
- if (lhs == null) {
- throw new IllegalArgumentException("Null \"lhs\" parameter");
- }
+ if (lhs == null) throw new IllegalArgumentException("Null \"lhs\" parameter");
// Validate "rhs" parameter
- if (rhs == null) {
- throw new IllegalArgumentException("Null \"rhs\" parameter");
- }
+ if (rhs == null) throw new IllegalArgumentException("Null \"rhs\" parameter");
// Initialize fields
- elements = new ArrayList(2);
+ elements = new ArrayList<ConstraintExpression>(2);
// Add the LHS
if (lhs.getClass().equals(getClass())) {
- elements.addAll( ( (ConstraintOperation) lhs).getElements());
+ elements.addAll(((ConstraintOperation)lhs).getElements());
} else {
elements.add(lhs);
}
@@ -112,33 +105,17 @@
}
/**
- * CONSTRUCTOR ConstraintOperation TO DO
+ * Creates a new ConstraintOperation build on a list of ConstraintExpression
*
- * @param elements PARAMETER TO DO
+ * @param elements A list of ConstraintExpression to be the parameters of this expression
*/
- protected ConstraintOperation(List elements) {
+ protected ConstraintOperation(List<ConstraintExpression> elements) {
// Validate "elements" parameter
- if (elements == null) {
- throw new IllegalArgumentException("Null \"elements\" parameter");
- }
+ if (elements == null) throw new IllegalArgumentException("Null \"elements\" parameter");
+ assert elements.size() > 1;
// Initialize fields
- this.elements = new ArrayList(elements);
-
- ListIterator i = this.elements.listIterator();
-
- while (i.hasNext()) {
- Object o = i.next();
-
- assert o != null;
- if (o instanceof ConstraintExpression ||
- o instanceof Constraint) {
- i.set(o);
- } else {
- logger.error("Bad element: "+o.getClass()+" in "+getClass());
- throw new Error("Bad element: " + o.getClass());
- }
- }
+ this.elements = new ArrayList<ConstraintExpression>(elements);
}
@@ -147,7 +124,7 @@
*
* @return a list of {@link ConstraintExpression}s
*/
- public List getElements() {
+ public List<ConstraintExpression> getElements() {
return Collections.unmodifiableList(elements);
}
@@ -168,21 +145,15 @@
* @return equality.
*/
public boolean equals(Object o) {
- if (!super.equals(o)) {
- return false;
- }
+ if (!super.equals(o)) return false;
ConstraintOperation co = (ConstraintOperation) o;
- if (elements.size() != co.elements.size()) {
- return false;
- }
+ if (elements.size() != co.elements.size()) return false;
- Iterator lhs = elements.iterator();
- Iterator rhs = co.elements.iterator();
+ Iterator<ConstraintExpression> lhs = elements.iterator();
+ Iterator<ConstraintExpression> rhs = co.elements.iterator();
while (lhs.hasNext()) {
- if (!(lhs.next().equals(rhs.next()))) {
- return false;
- }
+ if (!(lhs.next().equals(rhs.next()))) return false;
}
return true;
@@ -194,18 +165,12 @@
*
* @return A set containing all variable constraints.
*/
- public Set getVariables() {
+ public Set<Variable> getVariables() {
// Check to see if there variables have been retrieved.
if (variables == null) {
- Set v = new HashSet();
+ Set<Variable> v = new HashSet<Variable>();
- for (Iterator it = getElements().iterator(); it.hasNext(); ) {
- // Get the operands and check to see if they are a valid constraint.
- Object e = it.next();
- if (e instanceof ConstraintExpression) {
- v.addAll(((ConstraintExpression)e).getVariables());
- }
- }
+ for (ConstraintExpression expr: getElements()) v.addAll(expr.getVariables());
variables = Collections.unmodifiableSet(v);
}
@@ -221,10 +186,8 @@
*/
public int hashCode() {
int hashCode = 0;
- Iterator i = elements.iterator();
- while (i.hasNext()) {
- hashCode ^= i.next().hashCode();
- }
+ Iterator<ConstraintExpression> i = elements.iterator();
+ while (i.hasNext()) hashCode ^= i.next().hashCode();
return hashCode;
}
@@ -235,13 +198,11 @@
*/
public String toString() {
StringBuffer buffer = new StringBuffer("(" + getName());
- Iterator i = getElements().iterator();
+ Iterator<ConstraintExpression> i = getElements().iterator();
while (i.hasNext()) {
buffer.append(i.next().toString());
- if (i.hasNext()) {
- buffer.append(" ");
- }
+ if (i.hasNext()) buffer.append(" ");
}
buffer.append(")");
Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintTrue.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintTrue.java 2007-08-21 05:37:58 UTC (rev 359)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/ConstraintTrue.java 2007-08-21 05:39:11 UTC (rev 360)
@@ -99,8 +99,8 @@
*
* @return A set containing all variable constraints.
*/
- public Set getVariables() {
- return new HashSet();
+ public Set<Variable> getVariables() {
+ return new HashSet<Variable>();
}
//
@@ -108,14 +108,14 @@
//
/**
- * METHOD TO DO
+ * Converts an expression to be made against a new source. In this case, nothing need change.
*
- * @param modelExpression PARAMETER TO DO
- * @param transformation PARAMETER TO DO
- * @param modelProperty PARAMETER TO DO
- * @param systemModel PARAMETER TO DO
- * @param variableFactory PARAMETER TO DO
- * @return RETURNED VALUE TO DO
+ * @param modelExpression ignored
+ * @param transformation ignored
+ * @param modelProperty ignored
+ * @param systemModel ignored
+ * @param variableFactory ignored
+ * @return The current constraint.
*/
public ConstraintExpression from(ModelExpression modelExpression,
Transformation transformation, Value modelProperty, Value systemModel,
Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/SingleTransitiveConstraint.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/SingleTransitiveConstraint.java 2007-08-21 05:37:58 UTC (rev 359)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/SingleTransitiveConstraint.java 2007-08-21 05:39:11 UTC (rev 360)
@@ -33,7 +33,7 @@
import java.util.*;
// Third party packages
-import org.apache.log4j.Category;
+// import org.apache.log4j.Category;
/**
* A transitive constraint. The elements within the constraint must be variable
@@ -68,11 +68,8 @@
*/
static final long serialVersionUID = -3828723182891026790L;
- /**
- * Logger.
- */
- private final static Category logger =
- Category.getInstance(Constraint.class.getName());
+ // /** Logger. */
+ // private final static Category logger = Category.getInstance(Constraint.class.getName());
/**
* The constraint containing the transitive predicate.
@@ -140,7 +137,7 @@
*
* @return A set containing all variable constraints.
*/
- public Set getVariables() {
+ public Set<Variable> getVariables() {
return transConstraint.getVariables();
}
Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/TransitiveConstraint.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/TransitiveConstraint.java 2007-08-21 05:37:58 UTC (rev 359)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/TransitiveConstraint.java 2007-08-21 05:39:11 UTC (rev 360)
@@ -33,7 +33,7 @@
import java.util.*;
// Third party packages
-import org.apache.log4j.Category;
+// import org.apache.log4j.Category;
/**
* A transitive constraint. The constraint must take the form of an anchored
@@ -68,11 +68,8 @@
*/
static final long serialVersionUID = -3828723182891026790L;
- /**
- * Logger.
- */
- private final static Category logger =
- Category.getInstance(Constraint.class.getName());
+ // /** Logger. */
+ // private final static Category logger = Category.getInstance(Constraint.class.getName());
/**
* The constraint containing the anchored transitive predicate.
@@ -174,8 +171,8 @@
*
* @return A set containing all variable constraints.
*/
- public Set getVariables() {
- Set vars = new HashSet();
+ public Set<Variable> getVariables() {
+ Set<Variable> vars = new HashSet<Variable>();
vars.addAll(unanchoredConstraint.getVariables());
vars.addAll(anchoredConstraint.getVariables());
return vars;
Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/WalkConstraint.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/WalkConstraint.java 2007-08-21 05:37:58 UTC (rev 359)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/WalkConstraint.java 2007-08-21 05:39:11 UTC (rev 360)
@@ -33,7 +33,7 @@
import java.util.*;
// Third party packages
-import org.apache.log4j.Category;
+// import org.apache.log4j.Category;
/**
* A walk constraint. The constraint must take the form of an anchored
@@ -67,11 +67,8 @@
*/
static final long serialVersionUID = 1054509776341736706L;
- /**
- * Logger.
- */
- private final static Category logger =
- Category.getInstance(Constraint.class.getName());
+ // /** Logger. */
+ // private final static Category logger = Category.getInstance(Constraint.class.getName());
/**
* The constraint containing the anchored constraint.
@@ -147,8 +144,8 @@
*
* @return A set containing all variable constraints.
*/
- public Set getVariables() {
- Set vars = new HashSet();
+ public Set<Variable> getVariables() {
+ Set<Variable> vars = new HashSet<Variable>();
vars.addAll(unanchoredConstraint.getVariables());
vars.addAll(anchoredConstraint.getVariables());
return vars;
More information about the Mulgara-svn
mailing list