[Mulgara-svn] r363 - branches/nw-interface/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd

pag at mulgara.org pag at mulgara.org
Tue Aug 21 05:43:37 UTC 2007


Author: pag
Date: 2007-08-21 00:43:36 -0500 (Tue, 21 Aug 2007)
New Revision: 363

Modified:
   branches/nw-interface/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalConstraint.java
   branches/nw-interface/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalTransformationUnitTest.java
Log:
Changed most untyped code over to using generics

Modified: branches/nw-interface/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalConstraint.java
===================================================================
--- branches/nw-interface/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalConstraint.java	2007-08-21 05:42:01 UTC (rev 362)
+++ branches/nw-interface/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalConstraint.java	2007-08-21 05:43:36 UTC (rev 363)
@@ -43,13 +43,11 @@
 import java.util.Set;
 
 // Third party packages
-import org.apache.log4j.Logger; // Apache Log4J
+// import org.apache.log4j.Logger; // Apache Log4J
 
 // Local classes
 import org.mulgara.query.Constraint;
 import org.mulgara.query.ConstraintElement;
-import org.mulgara.query.Query;
-import org.mulgara.query.QueryException;
 import org.mulgara.query.Variable;
 import org.mulgara.query.rdf.URIReferenceImpl;
 import org.jrdf.graph.URIReference;
@@ -75,11 +73,18 @@
  */
 public class IntervalConstraint implements Constraint {
 
-  /** Logger */
-  private static Logger logger =
-    Logger.getLogger(IntervalConstraint.class.getName());
+  // /** Logger */
+  // private static Logger logger = Logger.getLogger(IntervalConstraint.class.getName());
 
   /**
+   * 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 static final long serialVersionUID = 7653707287858079768L;
+
+  /**
    * The variable under constraint.
    *
    * This is never <code>null</code>.
@@ -116,8 +121,7 @@
    * @throws IllegalArgumentException if <var>variable</var> is
    *   <code>null</code>
    */
-  IntervalConstraint(Variable variable, Bound lowerBound, Bound upperBound, URIReference model)
-  {
+  IntervalConstraint(Variable variable, Bound lowerBound, Bound upperBound, URIReference model) {
     if (variable == null) { throw new IllegalArgumentException("Null \"variable\" parameter"); }
     if (model == null) { throw new IllegalArgumentException("Null 'model' parameter"); }
 
@@ -134,8 +138,7 @@
    * @throws IllegalArgumentException if the <var>intervalConstraint</var> does
    *   not constrain the same variable as this instance or is <code>null</code>
    */
-  IntervalConstraint conjoin(IntervalConstraint intervalConstraint)
-  {
+  IntervalConstraint conjoin(IntervalConstraint intervalConstraint) {
     // Validate "intervalConstraint" parameter
     if (intervalConstraint == null) {
       throw new IllegalArgumentException(
@@ -178,22 +181,15 @@
    * @return the largest of <var>lhs</var> and <var>rhs</var>, or
    *   <code>null</code> if both are <code>null</code>
    */
-  private static Bound maximumBound(Bound lhs, Bound rhs)
-  {
+  private static Bound maximumBound(Bound lhs, Bound rhs) {
     if (lhs == null) {
       return (rhs == null) ? null : rhs;
-    }
-    else {
+    } else {
       if (rhs == null) {
         return lhs;
-      }
-      else {
-        if (lhs.getValue() < rhs.getValue()) {
-          return rhs;
-        }
-        if (lhs.getValue() > rhs.getValue()) {
-          return lhs;
-        }
+      } else {
+        if (lhs.getValue() < rhs.getValue()) return rhs;
+        if (lhs.getValue() > rhs.getValue()) return lhs;
         assert lhs.getValue() == rhs.getValue();
         return lhs.isClosed() ? lhs : rhs;
       }
@@ -208,22 +204,15 @@
    * @return the smallest of <var>lhs</var> and <var>rhs</var>, or
    *   <code>null</code> if both are <code>null</code>
    */
-  private static Bound minimumBound(Bound lhs, Bound rhs)
-  {
+  private static Bound minimumBound(Bound lhs, Bound rhs) {
     if (lhs == null) {
       return (rhs == null) ? null : rhs;
-    }
-    else {
+    } else {
       if (rhs == null) {
         return lhs;
-      }
-      else {
-        if (lhs.getValue() < rhs.getValue()) {
-          return lhs;
-        }
-        if (lhs.getValue() > rhs.getValue()) {
-          return rhs;
-        }
+      } else {
+        if (lhs.getValue() < rhs.getValue()) return lhs;
+        if (lhs.getValue() > rhs.getValue()) return rhs;
         assert lhs.getValue() == rhs.getValue();
         return lhs.isClosed() ? rhs : lhs;
       }
@@ -234,8 +223,7 @@
    * @return the lower {@link Bound} of the constraint, or <code>null</code>
    *   if it has no lower {@link Bound}
    */
-  Bound getLowerBound()
-  {
+  Bound getLowerBound() {
     return lowerBound;
   }
 
@@ -243,16 +231,14 @@
    * @return the upper {@link Bound} of the constraint, or <code>null</code>
    *   if it has no upper {@link Bound}
    */
-  Bound getUpperBound()
-  {
+  Bound getUpperBound() {
     return upperBound;
   }
 
   /**
    * @return the constrained variable
    */
-  Variable getVariable()
-  {
+  Variable getVariable() {
     return variable;
   }
 
@@ -260,23 +246,15 @@
    * @return <code>true</code> if the constraint can never be satisfied (i.e.
    *   the lower bound is above the upper bound)
    */
-  boolean isEmpty()
-  {
-    if (lowerBound == null) {
-      return false;
-    }
+  boolean isEmpty() {
+    
+    if (lowerBound == null) return false;
 
-    if (upperBound == null) {
-      return false;
-    }
+    if (upperBound == null) return false;
 
-    if (lowerBound.getValue() < upperBound.getValue()) {
-      return false;
-    }
+    if (lowerBound.getValue() < upperBound.getValue()) return false;
 
-    if (lowerBound.getValue() > upperBound.getValue()) {
-      return true;
-    }
+    if (lowerBound.getValue() > upperBound.getValue()) return true;
 
     assert lowerBound.getValue() == upperBound.getValue();
     return !(lowerBound.isClosed() && upperBound.isClosed());
@@ -285,8 +263,7 @@
   /**
    * @return whether the interval admits only a single value
    */
-  boolean isSingleton()
-  {
+  boolean isSingleton() {
     return lowerBound != null &&
            lowerBound.isClosed() &&
            lowerBound.equals(upperBound);
@@ -296,8 +273,7 @@
    * @return whether the interval has neither a lower nor an upper bound, and
    *   is thus not really a constraint at all
    */
-  boolean isUnconstrained()
-  {
+  boolean isUnconstrained() {
     return (lowerBound == null) && (upperBound == null);
   }
 
@@ -305,8 +281,7 @@
   // Methods implementing ConstraintExpression
   //
 
-  public Set getVariables()
-  {
+  public Set<Variable> getVariables() {
     return Collections.singleton(variable);
   }
 
@@ -317,26 +292,17 @@
   /**
    * Equality is by value rather than by reference.
    */
-  public boolean equals(Object object)
-  {
-    if (object == null) {
-      return false;
-    }
+  public boolean equals(Object object) {
+    if (object == null) return false;
 
-    if (!object.getClass().equals(IntervalConstraint.class)) {
-      return false;
-    }
+    if (!object.getClass().equals(IntervalConstraint.class)) return false;
 
     assert object instanceof IntervalConstraint;
     IntervalConstraint intervalConstraint = (IntervalConstraint) object;
     
-    if (isEmpty() && intervalConstraint.isEmpty()) {
-      return true;
-    }
+    if (isEmpty() && intervalConstraint.isEmpty()) return true;
 
-    if (isUnconstrained() && intervalConstraint.isUnconstrained()) {
-      return true;
-    }
+    if (isUnconstrained() && intervalConstraint.isUnconstrained()) return true;
 
     return variable.equals(intervalConstraint.variable) &&
            Bound.equals(lowerBound, intervalConstraint.lowerBound) &&
@@ -347,8 +313,7 @@
    * @return a legible representation of the constraint, for instance
    *   <pre>[1.5 < $x <= 2.5]</pre>
    */
-  public String toString()
-  {
+  public String toString() {
     StringBuffer buffer = new StringBuffer("[");
     if (lowerBound != null) {
       buffer.append(lowerBound.getValue());

Modified: branches/nw-interface/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalTransformationUnitTest.java
===================================================================
--- branches/nw-interface/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalTransformationUnitTest.java	2007-08-21 05:42:01 UTC (rev 362)
+++ branches/nw-interface/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/IntervalTransformationUnitTest.java	2007-08-21 05:43:36 UTC (rev 363)
@@ -301,7 +301,7 @@
     Variable x = new Variable("x");
 
     assertEquals(
-      new ConstraintConjunction(Arrays.asList(new Object[] {
+      new ConstraintConjunction(Arrays.asList(new ConstraintExpression[] {
           new ConstraintImpl(x, greaterThan, new LiteralImpl(3), nonXSDModel),
           new ConstraintImpl(x, lessThan, new LiteralImpl(4), nonXSDModel),
           new IntervalConstraint(
@@ -311,7 +311,7 @@
             xsdModel)
       })),
       intervalTransformation.transformExpression(context,
-        new ConstraintConjunction(Arrays.asList(new Object[] {
+        new ConstraintConjunction(Arrays.asList(new ConstraintExpression[] {
           new ConstraintImpl(x, greaterThan, new LiteralImpl(3), nonXSDModel),
           new ConstraintImpl(x, lessThan, new LiteralImpl(4), nonXSDModel),
           new ConstraintImpl(x, greaterThan, new LiteralImpl(2), xsdModel),




More information about the Mulgara-svn mailing list