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

pag at mulgara.org pag at mulgara.org
Tue Mar 18 21:51:55 UTC 2008


Author: pag
Date: 2008-03-18 14:51:55 -0700 (Tue, 18 Mar 2008)
New Revision: 694

Added:
   branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/value/LangFn.java
Log:
The lang() function got missed in the last update

Added: branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/value/LangFn.java
===================================================================
--- branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/value/LangFn.java	                        (rev 0)
+++ branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/value/LangFn.java	2008-03-18 21:51:55 UTC (rev 694)
@@ -0,0 +1,60 @@
+/**
+ * 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.filter.value;
+
+import org.mulgara.query.QueryException;
+
+/**
+ * Represents a Lang() function that accesses the language on a literal.
+ * This operation is made to look like a SimpleLiteral.
+ *
+ * @created Mar 17, 2008
+ * @author Paul Gearon
+ * @copyright &copy; 2008 <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 LangFn extends AbstractAccessorFn {
+
+  /**
+   * Create a new language extractor function.
+   * @param operand The operand for the function.
+   */
+  public LangFn(RDFTerm operand) {
+    super(operand);
+  }
+
+  /**
+   * @see org.mulgara.query.filter.value.ValueLiteral#getLang()
+   * @return Always empty, as the result of this operation is a simple literal, which has no type.
+   */
+  public SimpleLiteral getLang() throws QueryException {
+    return SimpleLiteral.EMPTY;
+  }
+
+  /**
+   * @see org.mulgara.query.filter.value.RDFTerm#isLiteral()
+   * May be overridden.
+   */
+  public boolean isLiteral() throws QueryException {
+    return resolve().isLiteral();
+  }
+
+  /**
+   * 
+   * @return
+   * @throws QueryException
+   */
+  RDFTerm resolve() throws QueryException {
+    if (!operand.isLiteral()) throw new QueryException("Disallowed type in LANG function. Expected a Literal. Got a : " + operand.getClass().getSimpleName());
+    return ((ValueLiteral)operand).getLang();
+  }
+}




More information about the Mulgara-svn mailing list