[Mulgara-svn] r761 - branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/arithmetic

pag at mulgara.org pag at mulgara.org
Thu Apr 10 23:13:39 UTC 2008


Author: pag
Date: 2008-04-10 16:13:38 -0700 (Thu, 10 Apr 2008)
New Revision: 761

Modified:
   branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/arithmetic/AbstractNumericOperation.java
Log:
Updated numeric operations to be literals

Modified: branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/arithmetic/AbstractNumericOperation.java
===================================================================
--- branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/arithmetic/AbstractNumericOperation.java	2008-04-10 23:12:54 UTC (rev 760)
+++ branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/arithmetic/AbstractNumericOperation.java	2008-04-10 23:13:38 UTC (rev 761)
@@ -7,9 +7,21 @@
 import org.mulgara.query.filter.Context;
 import org.mulgara.query.filter.ContextOwner;
 import org.mulgara.query.filter.value.AbstractComparable;
+import org.mulgara.query.filter.value.IRI;
+import org.mulgara.query.filter.value.NumericExpression;
+import org.mulgara.query.filter.value.NumericLiteral;
 import org.mulgara.query.filter.value.RDFTerm;
+import org.mulgara.query.filter.value.SimpleLiteral;
 
-public abstract class AbstractNumericOperation extends AbstractComparable {
+/**
+ * Implements common functionality for arithmetic operations.
+ *
+ * @created Apr 10, 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 abstract class AbstractNumericOperation extends AbstractComparable implements NumericExpression {
 
   /** The owner of the context for resolving here */
   private ContextOwner owner = null;
@@ -19,7 +31,7 @@
   }
 
   /** @see org.mulgara.query.filter.value.ComparableExpression#getValue() */
-  public Object getValue() throws QueryException { return getNumber(); }
+  public Number getValue() throws QueryException { return getNumber(); }
 
   /** @see org.mulgara.query.filter.value.RDFTerm#equals() */
   public boolean equals(RDFTerm v) throws QueryException { return compare(getNumber(), v.getValue()) == 0; }
@@ -31,7 +43,7 @@
   public boolean isIRI() throws QueryException { return false; }
 
   /** @see org.mulgara.query.filter.value.RDFTerm#isLiteral() */
-  public boolean isLiteral() throws QueryException { return false; }
+  public boolean isLiteral() throws QueryException { return true; }
 
   /** @see org.mulgara.query.filter.value.RDFTerm#isURI() */
   public boolean isURI() throws QueryException { return false; }
@@ -99,4 +111,24 @@
   }
 
 
+  /////////////////////////////////
+  // Implementation of ValueLiteral
+  /////////////////////////////////
+
+  /** @see org.mulgara.query.filter.value.ValueLiteral#getLexical() */
+  public String getLexical() throws QueryException {
+    return getValue().toString();
+  }
+
+  /** @see org.mulgara.query.filter.value.ValueLiteral#getLang() */
+  public SimpleLiteral getLang() {
+    return SimpleLiteral.EMPTY;
+  }
+
+
+  /** @see org.mulgara.query.filter.value.ValueLiteral#getType() */
+  public IRI getType() throws QueryException {
+    return NumericLiteral.getTypeFor(getValue());
+  }
+
 }
\ No newline at end of file




More information about the Mulgara-svn mailing list