[Mulgara-svn] r685 - branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter
pag at mulgara.org
pag at mulgara.org
Mon Mar 17 22:05:42 UTC 2008
Author: pag
Date: 2008-03-17 15:05:40 -0700 (Mon, 17 Mar 2008)
New Revision: 685
Added:
branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/AbstractBooleanFn.java
branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/IsBlankFn.java
branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/IsIriFn.java
branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/IsLiteralFn.java
branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/IsUriFn.java
Log:
New boolean functions
Added: branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/AbstractBooleanFn.java
===================================================================
--- branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/AbstractBooleanFn.java (rev 0)
+++ branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/AbstractBooleanFn.java 2008-03-17 22:05:40 UTC (rev 685)
@@ -0,0 +1,54 @@
+/**
+ * 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;
+
+import org.mulgara.query.QueryException;
+import org.mulgara.query.filter.value.RDFTerm;
+
+
+/**
+ * Describes a test function on an RDFTerm.
+ *
+ * @created Mar 17, 2008
+ * @author Paul Gearon
+ * @copyright © 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 abstract class AbstractBooleanFn extends AbstractContextOwner implements Filter {
+
+ /** The variable to test */
+ RDFTerm operand;
+
+ /**
+ * Create a function for testing a term
+ * @param The term to test
+ */
+ public AbstractBooleanFn(RDFTerm operand) {
+ this.operand = operand;
+ operand.setContextOwner(this);
+ }
+
+ /**
+ * @see org.mulgara.query.filter.Filter#test()
+ */
+ public boolean test(Context context) throws QueryException {
+ setCurrentContext(context);
+ return fnTest();
+ }
+
+ /**
+ * An implementation specific test
+ * @return <code>true</code> when this test passes.
+ * @throws QueryException Thrown when an error occurs while trying to resolve the value of the operand.
+ */
+ abstract boolean fnTest() throws QueryException;
+}
Added: branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/IsBlankFn.java
===================================================================
--- branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/IsBlankFn.java (rev 0)
+++ branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/IsBlankFn.java 2008-03-17 22:05:40 UTC (rev 685)
@@ -0,0 +1,41 @@
+/**
+ * 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;
+
+import org.mulgara.query.QueryException;
+import org.mulgara.query.filter.value.RDFTerm;
+
+
+/**
+ * Tests an element to see if it represents a blank node.
+ *
+ * @created Mar 17, 2008
+ * @author Paul Gearon
+ * @copyright © 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 IsBlankFn extends AbstractBooleanFn {
+
+ /**
+ * Create a function for testing a variable
+ * @param The variable to test
+ */
+ public IsBlankFn(RDFTerm operand) {
+ super(operand);
+ }
+
+ /** @see org.mulgara.query.filter.AbstractBooleanFn#fnTest() */
+ boolean fnTest() throws QueryException {
+ return operand.isBlank();
+ }
+
+}
Added: branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/IsIriFn.java
===================================================================
--- branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/IsIriFn.java (rev 0)
+++ branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/IsIriFn.java 2008-03-17 22:05:40 UTC (rev 685)
@@ -0,0 +1,41 @@
+/**
+ * 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;
+
+import org.mulgara.query.QueryException;
+import org.mulgara.query.filter.value.RDFTerm;
+
+
+/**
+ * Tests an element to see if it conforms to being an IRI.
+ *
+ * @created Mar 17, 2008
+ * @author Paul Gearon
+ * @copyright © 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 IsIriFn extends AbstractBooleanFn {
+
+ /**
+ * Create a function for testing a variable
+ * @param The variable to test
+ */
+ public IsIriFn(RDFTerm operand) {
+ super(operand);
+ }
+
+ /** @see org.mulgara.query.filter.AbstractBooleanFn#fnTest() */
+ boolean fnTest() throws QueryException {
+ return operand.isIRI();
+ }
+
+}
Added: branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/IsLiteralFn.java
===================================================================
--- branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/IsLiteralFn.java (rev 0)
+++ branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/IsLiteralFn.java 2008-03-17 22:05:40 UTC (rev 685)
@@ -0,0 +1,41 @@
+/**
+ * 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;
+
+import org.mulgara.query.QueryException;
+import org.mulgara.query.filter.value.RDFTerm;
+
+
+/**
+ * Tests an element to see if it is an RDF Literal value.
+ *
+ * @created Mar 17, 2008
+ * @author Paul Gearon
+ * @copyright © 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 IsLiteralFn extends AbstractBooleanFn {
+
+ /**
+ * Create a function for testing if a value it a Literal
+ * @param The variable to test
+ */
+ public IsLiteralFn(RDFTerm operand) {
+ super(operand);
+ }
+
+ /** @see org.mulgara.query.filter.AbstractBooleanFn#fnTest() */
+ boolean fnTest() throws QueryException {
+ return operand.isLiteral();
+ }
+
+}
Added: branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/IsUriFn.java
===================================================================
--- branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/IsUriFn.java (rev 0)
+++ branches/mgr-61-sparql/src/jar/query/java/org/mulgara/query/filter/IsUriFn.java 2008-03-17 22:05:40 UTC (rev 685)
@@ -0,0 +1,41 @@
+/**
+ * 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;
+
+import org.mulgara.query.QueryException;
+import org.mulgara.query.filter.value.RDFTerm;
+
+
+/**
+ * Tests an element to see if it conforms to being a URI.
+ *
+ * @created Mar 17, 2008
+ * @author Paul Gearon
+ * @copyright © 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 IsUriFn extends AbstractBooleanFn {
+
+ /**
+ * Create a function for testing a variable
+ * @param The variable to test
+ */
+ public IsUriFn(RDFTerm operand) {
+ super(operand);
+ }
+
+ /** @see org.mulgara.query.filter.AbstractBooleanFn#fnTest() */
+ boolean fnTest() throws QueryException {
+ return operand.isURI();
+ }
+
+}
More information about the Mulgara-svn
mailing list