You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by cl...@apache.org on 2017/05/27 20:45:58 UTC
[1/2] jena git commit: initial implementation for JENA-1343
Repository: jena
Updated Branches:
refs/heads/master b642b1670 -> cd4fde067
http://git-wip-us.apache.org/repos/asf/jena/blob/cd4fde06/jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/ExprFactoryTest.java
----------------------------------------------------------------------
diff --git a/jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/ExprFactoryTest.java b/jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/ExprFactoryTest.java
new file mode 100644
index 0000000..305881d
--- /dev/null
+++ b/jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/ExprFactoryTest.java
@@ -0,0 +1,696 @@
+package org.apache.jena.arq.querybuilder;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+import org.apache.jena.arq.querybuilder.clauses.WhereClause;
+import org.apache.jena.arq.querybuilder.handlers.WhereHandler;
+import org.apache.jena.graph.NodeFactory;
+import org.apache.jena.query.Query;
+import org.apache.jena.sparql.core.Var;
+import org.apache.jena.sparql.expr.*;
+import org.apache.jena.sparql.expr.nodevalue.NodeValueInteger;
+import org.apache.jena.sparql.expr.nodevalue.NodeValueNode;
+import org.apache.jena.sparql.expr.nodevalue.NodeValueString;
+import org.junit.Test;
+
+public class ExprFactoryTest {
+
+ private ExprFactory factory = new ExprFactory();
+
+ @Test
+ public void randTest() {
+ Expr e = factory.rand();
+ assertTrue(e instanceof E_Random);
+ }
+
+ @Test
+ public void struuidTest() {
+ Expr e = factory.struuid();
+ assertTrue(e instanceof E_StrUUID);
+ }
+
+ @Test
+ public void uuidTest() {
+ Expr e = factory.uuid();
+ assertTrue(e instanceof E_UUID);
+ }
+
+ @Test
+ public void versionTest() {
+ Expr e = factory.version();
+ assertTrue(e instanceof E_Version);
+ }
+
+ @Test
+ public void nowTest() {
+ Expr e = factory.now();
+ assertTrue(e instanceof E_Now);
+ }
+
+ // expr 1 functions
+ @Test
+ public void boundTest_Var() {
+ Expr e = factory.bound(Var.alloc("hello"));
+ assertTrue(e instanceof E_Bound);
+ assertEquals("?hello", ((E_Bound) e).getArg().toString());
+ }
+
+ public void boundTest_Object() {
+ Expr e = factory.bound("hello");
+ assertTrue(e instanceof E_Bound);
+ assertEquals("?hello", e.getVarName());
+ }
+
+ public void boundTest_ExprVar() {
+ ExprVar ev = new ExprVar("hello");
+ Expr e = factory.bound(ev);
+ assertTrue(e instanceof E_Bound);
+ assertEquals("?hello", e.getVarName());
+ }
+
+ @Test
+ public void datatypeTest() {
+ Expr e = factory.datatype(factory.none());
+ assertTrue(e instanceof E_Datatype);
+ }
+
+ @Test
+ public void dayTest() {
+ Expr e = factory.day(factory.none());
+ assertTrue(e instanceof E_DateTimeDay);
+ }
+
+ @Test
+ public void hoursTest() {
+ Expr e = factory.hours(factory.none());
+ assertTrue(e instanceof E_DateTimeHours);
+ }
+
+ @Test
+ public void minutesTest() {
+ Expr e = factory.minutes(factory.none());
+ assertTrue(e instanceof E_DateTimeMinutes);
+ }
+
+ @Test
+ public void monthTest() {
+ Expr e = factory.month(factory.none());
+ assertTrue(e instanceof E_DateTimeMonth);
+ }
+
+ @Test
+ public void secondsTest() {
+ Expr e = factory.seconds(factory.none());
+ assertTrue(e instanceof E_DateTimeSeconds);
+ }
+
+ @Test
+ public void timezoneTest() {
+ Expr e = factory.timezone(factory.none());
+ assertTrue(e instanceof E_DateTimeTimezone);
+ }
+
+ @Test
+ public void tzTest() {
+ Expr e = factory.tz(factory.none());
+ assertTrue(e instanceof E_DateTimeTZ);
+ }
+
+ @Test
+ public void yearTest() {
+ Expr e = factory.year(factory.none());
+ assertTrue(e instanceof E_DateTimeYear);
+ }
+
+ @Test
+ public void iriTest() {
+ Expr e = factory.iri(factory.none());
+ assertTrue(e instanceof E_IRI);
+ }
+
+ @Test
+ public void isBlankTest() {
+ Expr e = factory.isBlank(factory.none());
+ assertTrue(e instanceof E_IsBlank);
+ }
+
+ @Test
+ public void isIRITest() {
+ Expr e = factory.isIRI(factory.none());
+ assertTrue(e instanceof E_IsIRI);
+ }
+
+ @Test
+ public void isLiteralTest() {
+ Expr e = factory.isLiteral(factory.none());
+ assertTrue(e instanceof E_IsLiteral);
+ }
+
+ @Test
+ public void isNumericTest() {
+ Expr e = factory.isNumeric(factory.none());
+ assertTrue(e instanceof E_IsNumeric);
+ }
+
+ @Test
+ public void langTest() {
+ Expr e = factory.lang(factory.none());
+ assertTrue(e instanceof E_Lang);
+ }
+
+ @Test
+ public void notTest() {
+ Expr e = factory.not(factory.none());
+ assertTrue(e instanceof E_LogicalNot);
+ }
+
+ @Test
+ public void absTest() {
+ Expr e = factory.abs(factory.none());
+ assertTrue(e instanceof E_NumAbs);
+ }
+
+ @Test
+ public void ceilTest() {
+ Expr e = factory.ceil(factory.none());
+
+ assertTrue(e instanceof E_NumCeiling);
+ }
+
+ @Test
+ public void floorTest() {
+ Expr e = factory.floor(factory.none());
+ assertTrue(e instanceof E_NumFloor);
+ }
+
+ @Test
+ public void roundTest() {
+ Expr e = factory.round(factory.none());
+ assertTrue(e instanceof E_NumRound);
+ }
+
+ @Test
+ public void strTest() {
+ Expr e = factory.str(factory.none());
+ assertTrue(e instanceof E_Str);
+ }
+
+ @Test
+ public void encode_for_uriTest() {
+ Expr e = factory.encode(factory.none());
+ assertTrue(e instanceof E_StrEncodeForURI);
+ }
+
+ @Test
+ public void strlenTest() {
+ Expr e = factory.strlen(factory.none());
+ assertTrue(e instanceof E_StrLength);
+ }
+
+ @Test
+ public void lcaseTest() {
+ Expr e = factory.lcase(factory.none());
+ assertTrue(e instanceof E_StrLowerCase);
+ }
+
+ @Test
+ public void ucaseTest() {
+ Expr e = factory.ucase(factory.none());
+ assertTrue(e instanceof E_StrUpperCase);
+ }
+
+ @Test
+ public void minusTest() {
+ Expr e = factory.minus(factory.none());
+ assertTrue(e instanceof E_UnaryMinus);
+ }
+
+ @Test
+ public void plusTest() {
+ Expr e = factory.plus(factory.none());
+ assertTrue(e instanceof E_UnaryPlus);
+ }
+
+ @Test
+ public void md5Test() {
+ Expr e = factory.md5(factory.none());
+ assertTrue(e instanceof E_MD5);
+ }
+
+ @Test
+ public void sha1Test() {
+ Expr e = factory.sha1(factory.none());
+ assertTrue(e instanceof E_SHA1);
+ }
+
+ @Test
+ public void sha224Test() {
+ Expr e = factory.sha224(factory.none());
+ assertTrue(e instanceof E_SHA224);
+ }
+
+ @Test
+ public void sha256Test() {
+ Expr e = factory.sha256(factory.none());
+ assertTrue(e instanceof E_SHA256);
+ }
+
+ @Test
+ public void sha384Test() {
+ Expr e = factory.sha384(factory.none());
+ assertTrue(e instanceof E_SHA384);
+ }
+
+ @Test
+ public void sha512Test() {
+ Expr e = factory.sha512(factory.none());
+ assertTrue(e instanceof E_SHA512);
+ }
+
+ // expr2 functions
+ @Test
+ public void addTest() {
+ Expr e = factory.add(factory.none(), factory.none());
+ assertTrue(e instanceof E_Add);
+ }
+ // E_Cast has a private constructor and seems not to be used.
+ // public void castTest( Expr expr1, Expr expr2 )
+ // {
+ // assertTrue( e instanceof E_Cast);
+ // }@Test
+
+ public void divideTest() {
+ Expr e = factory.divide(factory.none(), factory.none());
+ assertTrue(e instanceof E_Divide);
+ }
+
+ @Test
+ public void eqTest() {
+ Expr e = factory.eq(factory.none(), factory.none());
+ assertTrue(e instanceof E_Equals);
+ }
+
+ @Test
+ public void gtTest() {
+ Expr e = factory.gt(factory.none(), factory.none());
+ assertTrue(e instanceof E_GreaterThan);
+ }
+
+ @Test
+ public void geTest() {
+ Expr e = factory.ge(factory.none(), factory.none());
+ assertTrue(e instanceof E_GreaterThanOrEqual);
+ }
+
+ @Test
+ public void langMatchesTest() {
+ Expr e = factory.langMatches(factory.none(), factory.none());
+ assertTrue(e instanceof E_LangMatches);
+ }
+
+ @Test
+ public void ltTest() {
+ Expr e = factory.lt(factory.none(), factory.none());
+ assertTrue(e instanceof E_LessThan);
+ }
+
+ @Test
+ public void leTest() {
+ Expr e = factory.le(factory.none(), factory.none());
+ assertTrue(e instanceof E_LessThanOrEqual);
+ }
+
+ @Test
+ public void andTest() {
+ Expr e = factory.and(factory.none(), factory.none());
+ assertTrue(e instanceof E_LogicalAnd);
+ }
+
+ @Test
+ public void orTest() {
+ Expr e = factory.or(factory.none(), factory.none());
+ assertTrue(e instanceof E_LogicalOr);
+ }
+
+ @Test
+ public void multiplyTest() {
+ Expr e = factory.multiply(factory.none(), factory.none());
+ assertTrue(e instanceof E_Multiply);
+ }
+
+ @Test
+ public void neTest() {
+ Expr e = factory.ne(factory.none(), factory.none());
+ assertTrue(e instanceof E_NotEquals);
+ }
+
+ @Test
+ public void sameTermTest() {
+ Expr e = factory.sameTerm(factory.none(), factory.none());
+ assertTrue(e instanceof E_SameTerm);
+ }
+
+ @Test
+ public void strafterTest() {
+ Expr e = factory.strafter(factory.none(), factory.none());
+ assertTrue(e instanceof E_StrAfter);
+ }
+
+ @Test
+ public void strbeforeTest() {
+ Expr e = factory.strbefore(factory.none(), factory.none());
+ assertTrue(e instanceof E_StrBefore);
+ }
+
+ @Test
+ public void containsTest() {
+ Expr e = factory.contains(factory.none(), factory.none());
+ assertTrue(e instanceof E_StrContains);
+ }
+
+ @Test
+ public void strdtTest() {
+ Expr e = factory.strdt(factory.none(), factory.none());
+ assertTrue(e instanceof E_StrDatatype);
+ }
+
+ @Test
+ public void strendsTest() {
+ Expr e = factory.strends(factory.none(), factory.none());
+ assertTrue(e instanceof E_StrEndsWith);
+ }
+
+ @Test
+ public void strlangTest() {
+ Expr e = factory.strlang(factory.none(), factory.none());
+ assertTrue(e instanceof E_StrLang);
+ }
+
+ @Test
+ public void strtartsTest() {
+ Expr e = factory.strstarts(factory.none(), factory.none());
+ assertTrue(e instanceof E_StrStartsWith);
+ }
+
+ @Test
+ public void subtractTest() {
+ Expr e = factory.subtract(factory.none(), factory.none());
+ assertTrue(e instanceof E_Subtract);
+ }
+
+ // expr3 functions@Test
+ public void condTest(Expr condition, Expr thenExpr, Expr elseExpr) {
+ Expr e = factory.cond(factory.none(), factory.none(), factory.none());
+ assertTrue(e instanceof E_Conditional);
+ }
+
+ // exprN functions@Test
+ public void bnodeTest(Expr expr1) {
+ Expr e = factory.bnode(factory.none());
+ assertTrue(e instanceof E_BNode);
+ }
+
+ @Test
+ public void bnodeTest() {
+ Expr e = factory.bnode();
+ assertTrue(e instanceof E_BNode);
+ }
+
+ @Test
+ public void exprListTest() {
+ ExprList e = factory.list();
+ assertTrue(e instanceof ExprList);
+
+ }
+
+ @Test
+ public void exprListTest_OneArg() {
+ ExprList e = factory.asList(factory.none());
+ assertTrue(e instanceof ExprList);
+
+ }
+
+ @Test
+ public void exprListTest_MultipleArg() {
+ ExprList e = factory.asList(factory.none(), factory.none());
+ assertTrue(e instanceof ExprList);
+
+ }
+
+ @Test
+ public void callTest_dynamic() {
+ Expr e = factory.call(factory.none(), factory.list());
+ assertTrue(e instanceof E_FunctionDynamic);
+ }
+
+ @Test
+ public void callTest() {
+ Expr e = factory.call(factory.list());
+ assertTrue(e instanceof E_Call);
+ }
+
+ @Test
+ public void coalesceTest() {
+ Expr e = factory.coalesce(factory.list());
+ assertTrue(e instanceof E_Coalesce);
+ }
+
+ @Test
+ public void functionTest() {
+ Expr e = factory.function("name", factory.list());
+ assertTrue(e instanceof E_Function);
+ }
+
+ @Test
+ public void notinTest() {
+ Expr e = factory.notin(factory.none(), factory.list());
+ assertTrue(e instanceof E_NotOneOf);
+ }
+
+ @Test
+ public void inTest() {
+ Expr e = factory.in(factory.none(), factory.list());
+ assertTrue(e instanceof E_OneOf);
+ }
+
+ @Test
+ public void regexTest_expr() {
+ Expr e = factory.regex(factory.none(), factory.none(), factory.none());
+ assertTrue(e instanceof E_Regex);
+ }
+
+ @Test
+ public void regexTest_strings() {
+ /*
+ * case 'i' : // Need both (Java 1.4) newMask |= Pattern.UNICODE_CASE ;
+ * newMask |= Pattern.CASE_INSENSITIVE; break ; case 'm' : newMask |=
+ * Pattern.MULTILINE ; break ; case 's' : newMask |= Pattern.DOTALL ;
+ * break ;
+ */
+ Expr e = factory.regex(factory.none(), "pattern", "ims");
+ assertTrue(e instanceof E_Regex);
+ }
+
+ @Test
+ public void concatTest() {
+ Expr e = factory.concat(factory.list());
+ assertTrue(e instanceof E_StrConcat);
+ }
+
+ @Test
+ public void replaceTest() {
+ Expr e = factory.replace(factory.none(), factory.none(), factory.none(), factory.none());
+ assertTrue(e instanceof E_StrReplace);
+ }
+
+ @Test
+ public void substrTest() {
+ Expr e = factory.substr(factory.none(), factory.none(), factory.none());
+ assertTrue(e instanceof E_StrSubstring);
+ }
+
+ // expr op@Test
+
+ @Test
+ public void existsTest() {
+ WhereHandler handler = new WhereHandler(new Query());
+ WhereClause<?> whereClause = mock(WhereClause.class);
+ when(whereClause.getWhereHandler()).thenReturn(handler);
+ Expr e = factory.exists(whereClause);
+ assertTrue(e instanceof E_Exists);
+ }
+
+ @Test
+ public void notexistsTest() {
+ WhereHandler handler = new WhereHandler(new Query());
+ WhereClause<?> whereClause = mock(WhereClause.class);
+ when(whereClause.getWhereHandler()).thenReturn(handler);
+ Expr e = factory.notexists(whereClause);
+ assertTrue(e instanceof E_NotExists);
+ }
+
+ // exprnone
+ @Test
+ public void noneTest() {
+ Expr e = factory.none();
+ assertTrue(e instanceof ExprNone);
+ }
+
+ @Test
+ public void asVarTest() {
+ Expr e = factory.asVar("hello");
+ assertTrue(e instanceof ExprVar);
+ }
+
+ @Test
+ public void asVarTest_null() {
+ Expr e = factory.asVar(null);
+ assertTrue(e instanceof ExprVar);
+ ExprVar v = (ExprVar) e;
+ assertEquals("?_", v.asVar().getName());
+ }
+
+ @Test
+ public void asVarTest_var() {
+ Expr e = factory.asVar(Var.alloc("hello"));
+ assertTrue(e instanceof ExprVar);
+ ExprVar v = (ExprVar) e;
+ assertEquals("hello", v.asVar().getName());
+ }
+
+ @Test
+ public void asVarTest_node() {
+ Expr e = factory.asVar(NodeFactory.createVariable("hello"));
+ assertTrue(e instanceof ExprVar);
+ ExprVar v = (ExprVar) e;
+ assertEquals("hello", v.asVar().getName());
+ }
+
+ @Test
+ public void asVarTest_asterisk() {
+ assertNull(factory.asVar("*"));
+ }
+
+ @Test
+ public void asVarTest_string() {
+ Expr e = factory.asVar("foo");
+ assertTrue(e instanceof ExprVar);
+ ExprVar v = (ExprVar) e;
+ assertEquals("foo", v.asVar().getName());
+ }
+
+ @Test
+ public void asVarTest_varString() {
+ Expr e = factory.asVar("?foo");
+ assertTrue(e instanceof ExprVar);
+ ExprVar v = (ExprVar) e;
+ assertEquals("foo", v.asVar().getName());
+ }
+
+ @Test
+ public void asExprTest() {
+ assertNotNull( factory.asExpr("hello") );
+ }
+
+ @Test
+ public void asExprTest_number() {
+ Expr e = factory.asExpr( 3 );
+ assertTrue(e instanceof NodeValueInteger);
+ NodeValueInteger i = (NodeValueInteger)e;
+ assertEquals( 3, i.asNode().getLiteralValue());
+ }
+
+ @Test
+ public void asExprTest_null() {
+ Expr e = factory.asExpr(null);
+ assertTrue(e instanceof ExprNone);
+ }
+
+ @Test
+ public void asExprTest_var() {
+ Expr e = factory.asExpr(Var.alloc("hello"));
+ assertTrue(e instanceof ExprVar);
+ ExprVar v = (ExprVar) e;
+ assertEquals("hello", v.asVar().getName());
+ }
+
+ @Test
+ public void asExprTest_URInode() {
+ Expr e = factory.asExpr(NodeFactory.createURI("http://example.com/foo"));
+ assertTrue(e instanceof NodeValueNode);
+ NodeValueNode n = (NodeValueNode) e;
+ assertEquals("http://example.com/foo", n.asNode().getURI());
+ }
+
+ @Test
+ public void asExprTest_URIstring() {
+ Expr e = factory.asExpr("http://example.com/foo");
+ assertTrue(e instanceof NodeValueString);
+ NodeValueString n = (NodeValueString) e;
+ assertEquals("\"http://example.com/foo\"", n.asNode().toString());
+ }
+
+ public void asExprTest_Varnode() {
+ Expr e = factory.asExpr(NodeFactory.createVariable("hello"));
+ assertTrue(e instanceof ExprVar);
+ ExprVar v = (ExprVar) e;
+ assertEquals("hello", v.asVar().getName());
+ }
+ @Test
+ public void asExprTest_asterisk() {
+ Expr e = factory.asExpr("*");
+ assertTrue( e instanceof NodeValueString);
+ NodeValueString n = (NodeValueString) e;
+ assertEquals("*", n.asString());
+ }
+
+ @Test
+ public void asExprTest_string() {
+ Expr e = factory.asExpr("foo");
+ assertTrue(e instanceof NodeValueString);
+ NodeValueString n = (NodeValueString) e;
+ assertEquals("foo", n.asString());
+ }
+
+ @Test
+ public void asExprTest_varString() {
+ Expr e = factory.asExpr("?foo");
+ assertTrue(e instanceof ExprVar);
+ ExprVar v = (ExprVar) e;
+ assertEquals("foo", v.asVar().getName());
+ }
+
+ @Test
+ public void asListTest() {
+ ExprList lst = factory.asList("?foo", "http://example.com", factory.quote("hello"), 1, 5L, 3.14f, 6.28d, Var.alloc( "bar" ), null, factory.rand() );
+ assertEquals( 10, lst.size() );
+ assertEquals( new ExprVar( "foo" ), lst.get(0));
+ //assertEquals( new ExprVar( "foo" ), lst.get(0));
+ assertEquals( new NodeValueString( "hello" ), lst.get(2));
+ assertEquals( 1 , lst.get(3).getConstant().asNode().getLiteralValue());
+ assertEquals( 5 , lst.get(4).getConstant().asNode().getLiteralValue());
+ assertEquals( 3.14f, lst.get(5).getConstant().asNode().getLiteralValue());
+ assertEquals( 6.28, lst.get(6).getConstant().asNode().getLiteralValue());
+ assertEquals( new ExprVar( "bar" ), lst.get(7));
+ assertEquals( Expr.NONE, lst.get(8));
+ assertEquals( new E_Random(), lst.get(9));
+ }
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/cd4fde06/jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/handlers/WhereHandlerTest.java
----------------------------------------------------------------------
diff --git a/jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/handlers/WhereHandlerTest.java b/jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/handlers/WhereHandlerTest.java
index c7df825..7a717b2 100644
--- a/jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/handlers/WhereHandlerTest.java
+++ b/jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/handlers/WhereHandlerTest.java
@@ -438,4 +438,5 @@ public class WhereHandlerTest extends AbstractHandlerTest {
assertContainsRegex(MINUS + OPEN_CURLY + uri("one") + SPACE + uri("two") + SPACE + quote("three") + CLOSE_CURLY,
query.toString());
}
+
}
[2/2] jena git commit: initial implementation for JENA-1343
Posted by cl...@apache.org.
initial implementation for JENA-1343
This is an implementation of ExprFactory, which is retrieved from a
PrologHandler and will create Expr instances for use in Filter, Order
and Having expressions.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/cd4fde06
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/cd4fde06
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/cd4fde06
Branch: refs/heads/master
Commit: cd4fde067c53122d401e09745d72b2f47978e943
Parents: b642b16
Author: Claude Warren <cl...@apache.org>
Authored: Sat May 27 21:44:49 2017 +0100
Committer: Claude Warren <cl...@apache.org>
Committed: Sat May 27 21:44:49 2017 +0100
----------------------------------------------------------------------
jena-extras/jena-querybuilder/pom.xml | 4 +
.../arq/querybuilder/AbstractQueryBuilder.java | 7 +-
.../jena/arq/querybuilder/AskBuilder.java | 7 +-
.../jena/arq/querybuilder/ConstructBuilder.java | 6 +
.../jena/arq/querybuilder/ExprFactory.java | 1783 ++++++++++++++++++
.../jena/arq/querybuilder/SelectBuilder.java | 7 +-
.../arq/querybuilder/clauses/PrologClause.java | 8 +
.../clauses/SolutionModifierClause.java | 14 +
.../arq/querybuilder/clauses/WhereClause.java | 83 +-
.../querybuilder/handlers/PrologHandler.java | 5 +
.../arq/querybuilder/handlers/WhereHandler.java | 7 +-
.../querybuilder/AbstractQueryBuilderTest.java | 18 +-
.../jena/arq/querybuilder/ExprFactoryTest.java | 696 +++++++
.../querybuilder/handlers/WhereHandlerTest.java | 1 +
14 files changed, 2603 insertions(+), 43 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/cd4fde06/jena-extras/jena-querybuilder/pom.xml
----------------------------------------------------------------------
diff --git a/jena-extras/jena-querybuilder/pom.xml b/jena-extras/jena-querybuilder/pom.xml
index 2314a64..963c7bd 100644
--- a/jena-extras/jena-querybuilder/pom.xml
+++ b/jena-extras/jena-querybuilder/pom.xml
@@ -39,6 +39,10 @@
<groupId>org.xenei</groupId>
<artifactId>junit-contracts</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jena/blob/cd4fde06/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/AbstractQueryBuilder.java
----------------------------------------------------------------------
diff --git a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/AbstractQueryBuilder.java b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/AbstractQueryBuilder.java
index 447d5ff..ed18272 100644
--- a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/AbstractQueryBuilder.java
+++ b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/AbstractQueryBuilder.java
@@ -192,7 +192,7 @@ public abstract class AbstractQueryBuilder<T extends AbstractQueryBuilder<T>>
*
* @return the quoted string.
*/
- public String quote(String q) {
+ public static String quote(String q) {
int qt = q.indexOf('"');
int sqt = q.indexOf("'");
@@ -263,7 +263,7 @@ public abstract class AbstractQueryBuilder<T extends AbstractQueryBuilder<T>>
* @return the Var value.
* @throws ARQInternalErrorException
*/
- public Var makeVar(Object o) throws ARQInternalErrorException {
+ public static Var makeVar(Object o) throws ARQInternalErrorException {
if (o == null) {
return Var.ANON;
}
@@ -314,6 +314,9 @@ public abstract class AbstractQueryBuilder<T extends AbstractQueryBuilder<T>>
return getHandlerBlock().getWhereHandler();
}
+ public final ExprFactory getExprFactory() {
+ return getHandlerBlock().getPrologHandler().getExprFactory();
+ }
/**
* Set a variable replacement. During build all instances of var in the
* query will be replaced with value. If value is null the replacement is
http://git-wip-us.apache.org/repos/asf/jena/blob/cd4fde06/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/AskBuilder.java
----------------------------------------------------------------------
diff --git a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/AskBuilder.java b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/AskBuilder.java
index 42e76ef..34b8887 100644
--- a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/AskBuilder.java
+++ b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/AskBuilder.java
@@ -25,7 +25,6 @@ import org.apache.jena.arq.querybuilder.clauses.WhereClause;
import org.apache.jena.arq.querybuilder.handlers.DatasetHandler;
import org.apache.jena.arq.querybuilder.handlers.HandlerBlock;
import org.apache.jena.arq.querybuilder.handlers.SolutionModifierHandler;
-import org.apache.jena.arq.querybuilder.handlers.WhereHandler;
import org.apache.jena.graph.FrontsTriple;
import org.apache.jena.graph.Node;
import org.apache.jena.graph.Triple;
@@ -150,6 +149,12 @@ public class AskBuilder extends AbstractQueryBuilder<AskBuilder>
}
@Override
+ public AskBuilder addFilter(Expr expr) {
+ getWhereHandler().addFilter(expr);
+ return this;
+ }
+
+ @Override
public AskBuilder addFilter(String s) throws ParseException {
getWhereHandler().addFilter(s);
return this;
http://git-wip-us.apache.org/repos/asf/jena/blob/cd4fde06/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/ConstructBuilder.java
----------------------------------------------------------------------
diff --git a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/ConstructBuilder.java b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/ConstructBuilder.java
index 5040712..0ce8808 100644
--- a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/ConstructBuilder.java
+++ b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/ConstructBuilder.java
@@ -240,6 +240,12 @@ public class ConstructBuilder extends AbstractQueryBuilder<ConstructBuilder> imp
}
@Override
+ public ConstructBuilder addFilter(Expr expr) {
+ getWhereHandler().addFilter(expr);
+ return this;
+ }
+
+ @Override
public ConstructBuilder addFilter(String s) throws ParseException {
getWhereHandler().addFilter(s);
return this;
http://git-wip-us.apache.org/repos/asf/jena/blob/cd4fde06/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/ExprFactory.java
----------------------------------------------------------------------
diff --git a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/ExprFactory.java b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/ExprFactory.java
new file mode 100644
index 0000000..ec96f65
--- /dev/null
+++ b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/ExprFactory.java
@@ -0,0 +1,1783 @@
+package org.apache.jena.arq.querybuilder;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.apache.jena.arq.querybuilder.clauses.WhereClause;
+import org.apache.jena.graph.Node;
+import org.apache.jena.shared.PrefixMapping;
+import org.apache.jena.sparql.core.Var;
+import org.apache.jena.sparql.expr.E_Add;
+import org.apache.jena.sparql.expr.E_BNode;
+import org.apache.jena.sparql.expr.E_Bound;
+import org.apache.jena.sparql.expr.E_Call;
+import org.apache.jena.sparql.expr.E_Coalesce;
+import org.apache.jena.sparql.expr.E_Conditional;
+import org.apache.jena.sparql.expr.E_Datatype;
+import org.apache.jena.sparql.expr.E_DateTimeDay;
+import org.apache.jena.sparql.expr.E_DateTimeHours;
+import org.apache.jena.sparql.expr.E_DateTimeMinutes;
+import org.apache.jena.sparql.expr.E_DateTimeMonth;
+import org.apache.jena.sparql.expr.E_DateTimeSeconds;
+import org.apache.jena.sparql.expr.E_DateTimeTZ;
+import org.apache.jena.sparql.expr.E_DateTimeTimezone;
+import org.apache.jena.sparql.expr.E_DateTimeYear;
+import org.apache.jena.sparql.expr.E_Divide;
+import org.apache.jena.sparql.expr.E_Equals;
+import org.apache.jena.sparql.expr.E_Exists;
+import org.apache.jena.sparql.expr.E_Function;
+import org.apache.jena.sparql.expr.E_FunctionDynamic;
+import org.apache.jena.sparql.expr.E_GreaterThan;
+import org.apache.jena.sparql.expr.E_GreaterThanOrEqual;
+import org.apache.jena.sparql.expr.E_IRI;
+import org.apache.jena.sparql.expr.E_IsBlank;
+import org.apache.jena.sparql.expr.E_IsIRI;
+import org.apache.jena.sparql.expr.E_IsLiteral;
+import org.apache.jena.sparql.expr.E_IsNumeric;
+import org.apache.jena.sparql.expr.E_Lang;
+import org.apache.jena.sparql.expr.E_LangMatches;
+import org.apache.jena.sparql.expr.E_LessThan;
+import org.apache.jena.sparql.expr.E_LessThanOrEqual;
+import org.apache.jena.sparql.expr.E_LogicalAnd;
+import org.apache.jena.sparql.expr.E_LogicalNot;
+import org.apache.jena.sparql.expr.E_LogicalOr;
+import org.apache.jena.sparql.expr.E_MD5;
+import org.apache.jena.sparql.expr.E_Multiply;
+import org.apache.jena.sparql.expr.E_NotEquals;
+import org.apache.jena.sparql.expr.E_NotExists;
+import org.apache.jena.sparql.expr.E_NotOneOf;
+import org.apache.jena.sparql.expr.E_Now;
+import org.apache.jena.sparql.expr.E_NumAbs;
+import org.apache.jena.sparql.expr.E_NumCeiling;
+import org.apache.jena.sparql.expr.E_NumFloor;
+import org.apache.jena.sparql.expr.E_NumRound;
+import org.apache.jena.sparql.expr.E_OneOf;
+import org.apache.jena.sparql.expr.E_Random;
+import org.apache.jena.sparql.expr.E_Regex;
+import org.apache.jena.sparql.expr.E_SHA1;
+import org.apache.jena.sparql.expr.E_SHA224;
+import org.apache.jena.sparql.expr.E_SHA256;
+import org.apache.jena.sparql.expr.E_SHA384;
+import org.apache.jena.sparql.expr.E_SHA512;
+import org.apache.jena.sparql.expr.E_SameTerm;
+import org.apache.jena.sparql.expr.E_Str;
+import org.apache.jena.sparql.expr.E_StrAfter;
+import org.apache.jena.sparql.expr.E_StrBefore;
+import org.apache.jena.sparql.expr.E_StrConcat;
+import org.apache.jena.sparql.expr.E_StrContains;
+import org.apache.jena.sparql.expr.E_StrDatatype;
+import org.apache.jena.sparql.expr.E_StrEncodeForURI;
+import org.apache.jena.sparql.expr.E_StrEndsWith;
+import org.apache.jena.sparql.expr.E_StrLang;
+import org.apache.jena.sparql.expr.E_StrLength;
+import org.apache.jena.sparql.expr.E_StrLowerCase;
+import org.apache.jena.sparql.expr.E_StrReplace;
+import org.apache.jena.sparql.expr.E_StrStartsWith;
+import org.apache.jena.sparql.expr.E_StrSubstring;
+import org.apache.jena.sparql.expr.E_StrUUID;
+import org.apache.jena.sparql.expr.E_StrUpperCase;
+import org.apache.jena.sparql.expr.E_Subtract;
+import org.apache.jena.sparql.expr.E_UUID;
+import org.apache.jena.sparql.expr.E_UnaryMinus;
+import org.apache.jena.sparql.expr.E_UnaryPlus;
+import org.apache.jena.sparql.expr.E_Version;
+import org.apache.jena.sparql.expr.Expr;
+import org.apache.jena.sparql.expr.ExprList;
+import org.apache.jena.sparql.expr.ExprNone;
+import org.apache.jena.sparql.expr.ExprVar;
+import org.apache.jena.sparql.expr.NodeValue;
+
+/**
+ * Create expressions.
+ *
+ * NodeValue contains a number of static functions to make a number of node
+ * functions.
+ *
+ * @see org.apache.jena.sparql.expr.NodeValue
+ *
+ * Function names here map as closely as possible to the tag names for the
+ * generated expression.
+ *
+ */
+public class ExprFactory {
+
+ private final PrefixMapping pMap;
+
+ public ExprFactory(PrefixMapping pMap) {
+ this.pMap = pMap;
+ }
+
+ public ExprFactory() {
+ this(PrefixMapping.Extended);
+ }
+
+ // expr 0 functions
+
+ /**
+ * implements rand() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-rand
+ *
+ * @see org.apache.jena.sparql.expr.E_Random
+ * @return E_Random instance
+ */
+ public final E_Random rand() {
+ return new E_Random();
+ }
+
+ /**
+ * implements struuid() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-struuid
+ *
+ * @see org.apache.jena.sparql.expr.E_StrUUID
+ * @return E_StrUUID instance
+ */
+ public final E_StrUUID struuid() {
+ return new E_StrUUID();
+ }
+
+ /**
+ * implements uuid() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-uuid
+ *
+ * @see org.apache.jena.sparql.expr.E_UUID
+ * @return E_UUID instance
+ */
+ public final E_UUID uuid() {
+ return new E_UUID();
+ }
+
+ /**
+ * Returns the current ARQ name and version number as a string.
+ *
+ * @see org.apache.jena.sparql.expr.E_Version
+ * @return E_Version instance
+ */
+ public final E_Version version() {
+ return new E_Version();
+ }
+
+ /**
+ * implements now() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-now
+ *
+ * @see org.apache.jena.sparql.expr.E_Now
+ * @return E_Now instance
+ */
+ public final E_Now now() {
+ return new E_Now();
+ }
+
+ // expr 1 functions
+
+ /**
+ * implements bound() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-bound
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_Bound
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_Bound instance
+ */
+ public final E_Bound bound(Object expr) {
+ return new E_Bound(asExpr(expr));
+ }
+
+ /**
+ * implements datatype() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-datatype
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_Datatype
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_Datatype instance
+ */
+ public final E_Datatype datatype(Object expr) {
+ return new E_Datatype(asExpr(expr));
+ }
+
+ /**
+ * implements day() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-day
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_Datatype instance
+ */
+ public final E_DateTimeDay day(Object expr) {
+ return new E_DateTimeDay(asExpr(expr));
+ }
+
+ /**
+ * implements hours() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-hours
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_DateTimeHours
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_DateTimeHours instance
+ */
+ public final E_DateTimeHours hours(Object expr) {
+ return new E_DateTimeHours(asExpr(expr));
+ }
+
+ /**
+ * implements minutes() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-minutes
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_DateTimeMinutes
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_DateTimeMinutes instance
+ */
+ public final E_DateTimeMinutes minutes(Object expr) {
+ return new E_DateTimeMinutes(asExpr(expr));
+ }
+
+ /**
+ * implements month() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-month
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_DateTimeMonth
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_DateTimeMonth instance
+ */
+ public final E_DateTimeMonth month(Object expr) {
+ return new E_DateTimeMonth(asExpr(expr));
+ }
+
+ /**
+ * implements seconds() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-seconds
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_DateTimeSeconds
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_DateTimeSeconds instance
+ */
+ public final E_DateTimeSeconds seconds(Object expr) {
+ return new E_DateTimeSeconds(asExpr(expr));
+ }
+
+ /**
+ * implements timezone() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-timezone
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_DateTimeTimezone
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_DateTypeTimezone instance
+ */
+ public final E_DateTimeTimezone timezone(Object expr) {
+ return new E_DateTimeTimezone(asExpr(expr));
+ }
+
+ /**
+ * implements tz() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-tz
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_DateTimeTZ
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_DateTimeTZ instance
+ */
+ public final E_DateTimeTZ tz(Object expr) {
+ return new E_DateTimeTZ(asExpr(expr));
+ }
+
+ /**
+ * implements year() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-year
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_DateTimeYear
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_DateTimeYear instance
+ */
+ public final E_DateTimeYear year(Object expr) {
+ return new E_DateTimeYear(asExpr(expr));
+ }
+
+ /**
+ * implements iri() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-iri
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_IRI
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_IRI instance
+ */
+ public final E_IRI iri(Object expr) {
+ return new E_IRI(asExpr(expr));
+ }
+
+ /**
+ * implements isBlank() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-isBlank
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_IsBlank
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_isBlank instance
+ */
+ public final E_IsBlank isBlank(Object expr) {
+ return new E_IsBlank(asExpr(expr));
+ }
+
+ /**
+ * implements isIRI() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-isIRI
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_IsIRI
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_IsIRI instance
+ */
+ public final E_IsIRI isIRI(Object expr) {
+ return new E_IsIRI(asExpr(expr));
+ }
+
+ /**
+ * implements isLiteral() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-isLiteral
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_IsLiteral
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_IsLiteral instance
+ */
+ public final E_IsLiteral isLiteral(Object expr) {
+ return new E_IsLiteral(asExpr(expr));
+ }
+
+ /**
+ * implements isNumeric() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-isNumeric
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_IsNumeric
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_IsNumeric instance
+ */
+ public final E_IsNumeric isNumeric(Object expr) {
+ return new E_IsNumeric(asExpr(expr));
+ }
+
+ /**
+ * implements lang() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-lang
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_Lang
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_Lang instance
+ */
+ public final E_Lang lang(Object expr) {
+ return new E_Lang(asExpr(expr));
+ }
+
+ /**
+ * implements not() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-not
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_LogicalNot
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_LogicalNot instance
+ */
+ public final E_LogicalNot not(Object expr) {
+ return new E_LogicalNot(asExpr(expr));
+ }
+
+ /**
+ * implements abs() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-abs
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_NumAbs
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_NumAbs instance
+ */
+ public final E_NumAbs abs(Object expr) {
+ return new E_NumAbs(asExpr(expr));
+ }
+
+ /**
+ * implements ceil() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-ceil
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_NumCeiling
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_NumCeiling instance
+ */
+ public final E_NumCeiling ceil(Object expr) {
+ return new E_NumCeiling(asExpr(expr));
+ }
+
+ /**
+ * implements floor() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-floor
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_NumFloor
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_NumFloor instance
+ */
+ public final E_NumFloor floor(Object expr) {
+ return new E_NumFloor(asExpr(expr));
+ }
+
+ /**
+ * implements round() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-round
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_Round
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_Round instance
+ */
+ public final E_NumRound round(Object expr) {
+ return new E_NumRound(asExpr(expr));
+ }
+
+ /**
+ * implements str() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-str
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_Str
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_Str instance
+ */
+ public final E_Str str(Object expr) {
+ return new E_Str(asExpr(expr));
+ }
+
+ /**
+ * implements encode() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-encode
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_StrEncodedForURI
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_StrEncodedForURI instance
+ */
+ public final E_StrEncodeForURI encode(Object expr) {
+ return new E_StrEncodeForURI(asExpr(expr));
+ }
+
+ /**
+ * implements strlen() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-strlen
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_StrLength
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_StrLength instance
+ */
+ public final E_StrLength strlen(Object expr) {
+ return new E_StrLength(asExpr(expr));
+ }
+
+ /**
+ * implements lcase() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-lcase
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_StrLowerCase
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_StrLowerCase instance
+ */
+ public final E_StrLowerCase lcase(Object expr) {
+ return new E_StrLowerCase(asExpr(expr));
+ }
+
+ /**
+ * implements ucase() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-ucase
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_StrUpperCase
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_StrUpperCase instance
+ */
+ public final E_StrUpperCase ucase(Object expr) {
+ return new E_StrUpperCase(asExpr(expr));
+ }
+
+ /**
+ * implements unary minus as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#OperatorMapping
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_UnaryMinus
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_UnaryMinus instance
+ */
+ public final E_UnaryMinus minus(Object expr) {
+ return new E_UnaryMinus(asExpr(expr));
+ }
+
+ /**
+ * implements unary plus as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#OperatorMapping
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_UnaryPlus
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_UnaryPlus instance
+ */
+ public final E_UnaryPlus plus(Object expr) {
+ return new E_UnaryPlus(asExpr(expr));
+ }
+
+ /**
+ * implements md5() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-md5
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_MD5
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_MD5 instance
+ */
+ public final E_MD5 md5(Object expr) {
+ return new E_MD5(asExpr(expr));
+ }
+
+ /**
+ * implements sha1() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-sha1
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_SHA1
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_SHA1 instance
+ */
+ public final E_SHA1 sha1(Object expr) {
+ return new E_SHA1(asExpr(expr));
+ }
+
+ /**
+ * implements sha224() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-sha224
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_SHA224
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_SHA224 instance
+ */
+ public final E_SHA224 sha224(Object expr) {
+ return new E_SHA224(asExpr(expr));
+ }
+
+ /**
+ * implements sha256() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-sha256
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_SHA256
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_SHA256 instance
+ */
+ public final E_SHA256 sha256(Object expr) {
+ return new E_SHA256(asExpr(expr));
+ }
+
+ /**
+ * implements sha384() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-sha384
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_SHA384
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_SHA384 instance
+ */
+ public final E_SHA384 sha384(Object expr) {
+ return new E_SHA384(asExpr(expr));
+ }
+
+ /**
+ * implements sha512() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-sha512
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_SHA512
+ *
+ * @param expr
+ * the expression to check.
+ * @return E_SHA512 instance
+ */
+ public final E_SHA512 sha512(Object expr) {
+ return new E_SHA512(asExpr(expr));
+ }
+
+ // expr2 functions
+
+ /**
+ * implements addition as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#OperatorMapping
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_Add
+ *
+ * @param expr1
+ * the first expression.
+ * @param expr2
+ * the second expression.
+ * @return E_Add instance
+ */
+ public final E_Add add(Object expr1, Object expr2) {
+ return new E_Add(asExpr(expr1), asExpr(expr2));
+ }
+
+ // E_Cast has a private constructor and seems not to be used.
+ // public final E_Cast cast( Expr expr1, Expr expr2 )
+ // {
+ // return new E_Cast( expr1, expr2 );
+ // }
+ /**
+ * implements division as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#OperatorMapping
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_Divide
+ *
+ * @param expr1
+ * the first expression.
+ * @param expr2
+ * the second expression.
+ * @return E_Devide instance
+ */
+ public final E_Divide divide(Object expr1, Object expr2) {
+ return new E_Divide(asExpr(expr1), asExpr(expr2));
+ }
+
+ /**
+ * implements equality as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#OperatorMapping
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_Equals
+ *
+ * @param expr1
+ * the first expression.
+ * @param expr2
+ * the second expression.
+ * @return E_Equals instance
+ */
+ public final E_Equals eq(Object expr1, Object expr2) {
+ return new E_Equals(asExpr(expr1), asExpr(expr2));
+ }
+
+ /**
+ * implements greater than as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#OperatorMapping
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_GreaterThan
+ *
+ * @param expr1
+ * the first expression.
+ * @param expr2
+ * the second expression.
+ * @return E_GreaterThan instance
+ */
+ public final E_GreaterThan gt(Object expr1, Object expr2) {
+ return new E_GreaterThan(asExpr(expr1), asExpr(expr2));
+ }
+
+ /**
+ * implements greater than or equal as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#OperatorMapping
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_GreaterThanOrEqual
+ *
+ * @param expr1
+ * the first expression.
+ * @param expr2
+ * the second expression.
+ * @return E_GreaterThanOrEqual instance
+ */
+ public final E_GreaterThanOrEqual ge(Object expr1, Object expr2) {
+ return new E_GreaterThanOrEqual(asExpr(expr1), asExpr(expr2));
+ }
+
+ /**
+ * implements langMatches() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-langMatches
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_LangMatches
+ *
+ * @param expr1
+ * the first expression.
+ * @param expr2
+ * the second expression.
+ * @return E_LangMatches instance
+ */
+ public final E_LangMatches langMatches(Object expr1, Object expr2) {
+ return new E_LangMatches(asExpr(expr1), asExpr(expr2));
+ }
+
+ /**
+ * implements less than as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#OperatorMapping
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_LessThan
+ *
+ * @param expr1
+ * the first expression.
+ * @param expr2
+ * the second expression.
+ * @return E_LessThan instance
+ */
+ public final E_LessThan lt(Object expr1, Object expr2) {
+ return new E_LessThan(asExpr(expr1), asExpr(expr2));
+ }
+
+ /**
+ * implements less than or equal as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#OperatorMapping
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_LessThanOrEqual
+ *
+ * @param expr1
+ * the first expression.
+ * @param expr2
+ * the second expression.
+ * @return E_LessThanOrEqual instance
+ */
+ public final E_LessThanOrEqual le(Object expr1, Object expr2) {
+ return new E_LessThanOrEqual(asExpr(expr1), asExpr(expr2));
+ }
+
+ /**
+ * implements logical and as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#OperatorMapping
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_LogicalAnd
+ *
+ * @param expr1
+ * the first expression.
+ * @param expr2
+ * the second expression.
+ * @return E_LogicalAnd instance
+ */
+ public final E_LogicalAnd and(Object expr1, Object expr2) {
+ return new E_LogicalAnd(asExpr(expr1), asExpr(expr2));
+ }
+
+ /**
+ * implements logical or as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#OperatorMapping
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_LogicalOr
+ *
+ * @param expr1
+ * the first expression.
+ * @param expr2
+ * the second expression.
+ * @return E_LogicalOr instance
+ */
+ public final E_LogicalOr or(Object expr1, Object expr2) {
+ return new E_LogicalOr(asExpr(expr1), asExpr(expr2));
+ }
+
+ /**
+ * implements multiplication s per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#OperatorMapping
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_Multiply
+ *
+ * @param expr1
+ * the first expression.
+ * @param expr2
+ * the second expression.
+ * @return E_Multiply instance
+ */
+ public final E_Multiply multiply(Object expr1, Object expr2) {
+ return new E_Multiply(asExpr(expr1), asExpr(expr2));
+ }
+
+ /**
+ * implements not equals as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#OperatorMapping
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_NotEquals
+ *
+ * @param expr1
+ * the first expression.
+ * @param expr2
+ * the second expression.
+ * @return E_NotEquals instance
+ */
+ public final E_NotEquals ne(Object expr1, Object expr2) {
+ return new E_NotEquals(asExpr(expr1), asExpr(expr2));
+ }
+
+ /**
+ * implements sameTerm() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-sameTerm
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_SameTerm
+ *
+ * @param expr1
+ * the first expression.
+ * @param expr2
+ * the second expression.
+ * @return E_SameTerm instance
+ */
+ public final E_SameTerm sameTerm(Object expr1, Object expr2) {
+ return new E_SameTerm(asExpr(expr1), asExpr(expr2));
+ }
+
+ /**
+ * implements strafter() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-strafter
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_StrAfter
+ *
+ * @param expr1
+ * the first expression.
+ * @param expr2
+ * the second expression.
+ * @return E_StrAfter instance
+ */
+ public final E_StrAfter strafter(Object expr1, Object expr2) {
+ return new E_StrAfter(asExpr(expr1), asExpr(expr2));
+ }
+
+ /**
+ * implements strbefore() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-strbefore
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_StrBefore
+ *
+ * @param expr1
+ * the first expression.
+ * @param expr2
+ * the second expression.
+ * @return E_StrBefore instance
+ */
+ public final E_StrBefore strbefore(Object expr1, Object expr2) {
+ return new E_StrBefore(asExpr(expr1), asExpr(expr2));
+ }
+
+ /**
+ * implements contains() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-contains
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_StrContains
+ *
+ * @param expr1
+ * the first expression.
+ * @param expr2
+ * the second expression.
+ * @return E_StrContains instance
+ */
+ public final E_StrContains contains(Object expr1, Object expr2) {
+ return new E_StrContains(asExpr(expr1), asExpr(expr2));
+ }
+
+ /**
+ * implements strdt() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-strdt
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_StrDatatype
+ *
+ * @param expr1
+ * the first expression.
+ * @param expr2
+ * the second expression.
+ * @return E_StrDatatype instance
+ */
+ public final E_StrDatatype strdt(Object expr1, Object expr2) {
+ return new E_StrDatatype(asExpr(expr1), asExpr(expr2));
+ }
+
+ /**
+ * implements strends() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-strends
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_StrEndsWith
+ *
+ * @param expr1
+ * the first expression.
+ * @param expr2
+ * the second expression.
+ * @return E_StrEndsWith instance
+ */
+ public final E_StrEndsWith strends(Object expr1, Object expr2) {
+ return new E_StrEndsWith(asExpr(expr1), asExpr(expr2));
+ }
+
+ /**
+ * implements strlang() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-strlang
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_StrLang
+ *
+ * @param expr1
+ * the first expression.
+ * @param expr2
+ * the second expression.
+ * @return E_StrLang instance
+ */
+ public final E_StrLang strlang(Object expr1, Object expr2) {
+ return new E_StrLang(asExpr(expr1), asExpr(expr2));
+ }
+
+ /**
+ * implements strstarts() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-strstarts
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_StrStartsWith
+ *
+ * @param expr1
+ * the first expression.
+ * @param expr2
+ * the second expression.
+ * @return E_StrStartsWith instance
+ */
+ public final E_StrStartsWith strstarts(Object expr1, Object expr2) {
+ return new E_StrStartsWith(asExpr(expr1), asExpr(expr2));
+ }
+
+ /**
+ * implements subtraction as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#OperatorMapping
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_Subtract
+ *
+ * @param expr1
+ * the first expression.
+ * @param expr2
+ * the second expression.
+ * @return E_Subtract instance
+ */
+
+ public final E_Subtract subtract(Object expr1, Object expr2) {
+ return new E_Subtract(asExpr(expr1), asExpr(expr2));
+ }
+
+ // expr3 functions
+
+ /**
+ * implements if() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-if
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_Conditional
+ *
+ * @param condition
+ * the condition to check.
+ * @param thenExpr
+ * the expression to execute if condition is true.
+ * @param elseExpr
+ * the expression to execute if condition is false.
+ * @return an E_Conditional instance.
+ */
+ public final E_Conditional cond(Expr condition, Expr thenExpr, Expr elseExpr) {
+ return new E_Conditional(condition, thenExpr, elseExpr);
+ }
+
+ // exprN functions
+ /**
+ * implements bnode() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-bnode
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_BNode
+ *
+ * @param expr1
+ * the blank node id.
+ * @return an E_BNode instance
+ */
+ public final E_BNode bnode(Object expr1) {
+ return new E_BNode(asExpr(expr1));
+ }
+
+ /**
+ * implements bnode() as per SPARQL 1.1 spec
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-bnode
+ *
+ * @see org.apache.jena.sparql.expr.E_Random
+ *
+ * @return an E_BNode instance.
+ */
+ public final E_BNode bnode() {
+ return new E_BNode();
+ }
+
+ /**
+ * Creates a dynamic function call.
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#rFunctionCall
+ *
+ * Converts function to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_FunctionDynamic
+ *
+ * @param function
+ * The function to execute
+ * @param args
+ * the arguments to the function.
+ * @return an E_FunctionDynamic instance.
+ */
+ public final E_FunctionDynamic call(Object function, ExprList args) {
+ return new E_FunctionDynamic(asExpr(function), args);
+ }
+
+ /**
+ * Creates a dynamic function call.
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#rFunctionCall
+ *
+ * Converts function to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_FunctionDynamic
+ *
+ * @param function
+ * The function to execute
+ * @param args
+ * the arguments to the function.
+ * @return an E_FunctionDynamic instance.
+ */
+ public final E_FunctionDynamic call(Object function, Object... args) {
+ return call(asExpr(function), asList(args));
+ }
+
+ /**
+ * Creates a function call as per the SPARQL 11 query definition.
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#rFunctionCall
+ *
+ * @see org.apache.jena.sparql.expr.E_Call
+ *
+ * The first argument is the function to call
+ *
+ * @param args
+ * the arguments to the function.
+ * @return an E_Call instance.
+ */
+ public final E_Call call(ExprList args) {
+ return new E_Call(args);
+ }
+
+ /**
+ * implements coalesce() as per the SPARQL 11 query definition.
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-coalesce
+ *
+ * @see org.apache.jena.sparql.expr.E_Coalesce
+ *
+ * @param args
+ * the arguments to the function.
+ * @return an E_Coalesce instance.
+ */
+ public final E_Coalesce coalesce(ExprList args) {
+ return new E_Coalesce(args);
+ }
+
+ /**
+ * implements coalesce() as per the SPARQL 11 query definition.
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-coalesce
+ *
+ * @see org.apache.jena.sparql.expr.E_Coalesce
+ *
+ * @param args
+ * the arguments to the function.
+ * @return an E_Coalesce instance.
+ */
+ public final E_Coalesce coalesce(Object... args) {
+ return new E_Coalesce(asList(args));
+ }
+
+ /**
+ * Creates a function call as per the SPARQL 11 query definition.
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#rFunctionCall
+ *
+ * @see org.apache.jena.sparql.expr.E_Function
+ *
+ * @param name
+ * the name of the function.
+ * @param args
+ * the arguments to the function.
+ * @return an E_Function instance.
+ */
+ public final E_Function function(String name, ExprList args) {
+ return new E_Function(name, args);
+ }
+
+ /**
+ * implements "not in" as per the SPARQL 11 query definition.
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-not-in
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_NotOneOf
+ *
+ * @param expr
+ * the expression that is not in the list
+ * @param list
+ * the list of expressions.
+ * @return an E_NotOneOf instance.
+ */
+ public final E_NotOneOf notin(Object expr, ExprList list) {
+ return new E_NotOneOf(asExpr(expr), list);
+ }
+
+ /**
+ * implements "not in" as per the SPARQL 11 query definition.
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-not-in
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_NotOneOf
+ *
+ * @param expr
+ * the expression that is not in the list
+ * @param list
+ * the list of expressions.
+ * @return an E_NotOneOf instance.
+ */
+ public final E_NotOneOf notin(Object expr, Object... list) {
+ return new E_NotOneOf(asExpr(expr), asList(list));
+ }
+
+ /**
+ * implements "in" as per the SPARQL 11 query definition.
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-in
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_OneOf
+ *
+ * @param expr
+ * the expression that is not in the list
+ * @param list
+ * the list of expressions.
+ * @return an E_OneOf instance.
+ */
+ public final E_OneOf in(Object expr, ExprList list) {
+ return new E_OneOf(asExpr(expr), list);
+ }
+
+ /**
+ * implements "in" as per the SPARQL 11 query definition.
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-in
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_OneOf
+ *
+ * @param expr
+ * the expression that is not in the list
+ * @param list
+ * the list of expressions.
+ * @return an E_OneOf instance.
+ */
+ public final E_OneOf in(Object expr, Object... list) {
+ return new E_OneOf(asExpr(expr), asList(list));
+ }
+
+ /**
+ * implements regex() as per the SPARQL 11 query definition.
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-regex
+ *
+ * Converts objects to an Expr objects via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_Regex
+ *
+ * @param expr
+ * string to match.
+ * @param pattern
+ * the pattern to match
+ * @param flags
+ * the regex flags
+ * @return an E_Regex instance.
+ */
+ public final E_Regex regex(Object expr, Object pattern, Object flags) {
+ return new E_Regex(asExpr(expr), asExpr(pattern), asExpr(flags));
+ }
+
+ /**
+ * implements regex() as per the SPARQL 11 query definition.
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-regex
+ *
+ * Converts expr to an Expr object via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_Regex
+ *
+ * @param expr
+ * string to match.
+ * @param pattern
+ * the pattern to match
+ * @param flags
+ * the regex flags
+ * @return an E_Regex instance.
+ */
+ public final E_Regex regex(Object expr, String pattern, String flags) {
+ return new E_Regex(asExpr(expr), pattern, flags);
+ }
+
+ /**
+ * implements concat() as per the SPARQL 11 query definition.
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-concat
+ *
+ * @see org.apache.jena.sparql.expr.E_StrConcat
+ *
+ * @param list
+ * the list of arguments to concatenate
+ * @return an E_StrConcat instance
+ */
+ public final E_StrConcat concat(ExprList list) {
+ return new E_StrConcat(list);
+ }
+
+ /**
+ * implements concat() as per the SPARQL 11 query definition.
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-concat
+ *
+ * @see org.apache.jena.sparql.expr.E_StrConcat
+ *
+ * @param list
+ * the list of arguments to concatenate
+ * @return an E_StrConcat instance
+ */
+ public final E_StrConcat concat(Object... list) {
+ return new E_StrConcat(asList(list));
+ }
+
+ /**
+ * implements replace() as per the SPARQL 11 query definition.
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-replace
+ *
+ * Converts Objects to an Expr objects via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_StrReplace
+ *
+ * @param arg
+ * the string literal to replace
+ * @param pattern
+ * the pattern to replace in the string literal.
+ * @param replacement
+ * the string literal to replace the pattern with.
+ * @flags flags the flags that control replacement options.
+ * @return an E_StrReplace instance
+ */
+ public final E_StrReplace replace(Object arg, Object pattern, Object replacement, Object flags) {
+ return new E_StrReplace(asExpr(arg), asExpr(pattern), asExpr(replacement), asExpr(flags));
+ }
+
+ /**
+ * implements replace() as per the SPARQL 11 query definition.
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-replace
+ *
+ * Converts Objects to an Expr objects via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_StrReplace
+ *
+ * @param arg
+ * the string literal to replace
+ * @param pattern
+ * the pattern to replace in the string literal.
+ * @param replacement
+ * the string literal to replace the pattern with.
+ * @return an E_StrReplace instance
+ */
+ public final E_StrReplace replace(Object arg, Object pattern, Object replacement) {
+ return new E_StrReplace(asExpr(arg), asExpr(pattern), asExpr(replacement), null);
+ }
+
+ /**
+ * implements substr() as per the SPARQL 11 query definition.
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-substr
+ *
+ * Converts Objects to an Expr objects via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_StrSubstring
+ *
+ * @param src
+ * the expression to extract the substring from.
+ * @param loc
+ * the location within the expression string to start
+ * @param len
+ * the length of the string to extract.
+ *
+ * @return an E_Substring instance.
+ */
+ public final E_StrSubstring substr(Object src, Object loc, Object len) {
+ return new E_StrSubstring(asExpr(src), asExpr(loc), asExpr(len));
+ }
+
+ /**
+ * implements substr() as per the SPARQL 11 query definition.
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-substr
+ *
+ * Converts Objects to an Expr objects via expr()
+ *
+ * @see #asExpr(Object)
+ * @see org.apache.jena.sparql.expr.E_StrSubstring
+ *
+ * @param src
+ * the expression to extract the substring from.
+ * @param loc
+ * the location within the expression string to start
+ *
+ * @return an E_Substring instance.
+ */
+ public final E_StrSubstring substr(Object src, Object loc) {
+ return new E_StrSubstring(asExpr(src), asExpr(loc), null);
+ }
+ // expr op
+
+ /**
+ * implements exists() as per the SPARQL 11 query definition.
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-filter-exists
+ *
+ * @see org.apache.jena.sparql.expr.E_Exists
+ *
+ * @param whereClause
+ * A WhereClause to check existence of.
+ * @return an E_Exists instance,
+ */
+ public final E_Exists exists(WhereClause<?> whereClause) {
+ return new E_Exists(whereClause.getWhereHandler().getClause());
+ }
+
+ /**
+ * implements not exists() as per the SPARQL 11 query definition.
+ *
+ * https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#func-filter-exists
+ *
+ * @see org.apache.jena.sparql.expr.E_NotExists
+ *
+ * @param args
+ * the arguments to the function.
+ * @return an E_NotExists instance.
+ */
+ public final E_NotExists notexists(WhereClause<?> whereClause) {
+ return new E_NotExists(whereClause.getWhereHandler().getClause());
+ }
+
+ // exprnone
+ /**
+ * Should probably be called "null" but that is a reserved work. An
+ * expression that can be used in place of null.
+ *
+ * @see org.apache.jena.sparql.expr.ExprNone
+ *
+ * @return an ExprNone instance
+ */
+ public final ExprNone none() {
+ return (ExprNone) Expr.NONE;
+ }
+
+ /**
+ * Converts the object to a ExprVar.
+ * <ul>
+ * <li>If the object is an ExprVar return it</li>
+ * <li>Will return null if the object is "*" or Node_RuleVariable.WILD</li>
+ * <li>otherwise create an ExprVar from {AbstractQuerybuilder.makeVar}
+ * </ul>
+ *
+ * @see {@link AbstractQueryBuilder#makeVar(Object)}
+ *
+ * @param o
+ * the object to convert.
+ * @return an ExprVar
+ */
+ public final ExprVar asVar(Object o) {
+ if (o instanceof ExprVar) {
+ return (ExprVar) o;
+ }
+ Var v = AbstractQueryBuilder.makeVar(o);
+ return v == null ? null : new ExprVar(v);
+ }
+
+ /**
+ * Not really an Expr but a container of exprs.
+ *
+ * @param args
+ * the list of expressons.
+ * @return the expression list.
+ */
+ public final ExprList asList(Object... args) {
+ // make sure the list is modifyable
+ List<Expr> lst = Arrays.asList(args).stream().map(arg -> asExpr(arg)).collect(Collectors.toList());
+ return new ExprList(lst);
+ }
+
+ /**
+ * Not really an Expr but a container of exprs. creates an empty list.
+ *
+ * @return the empty expression list.
+ */
+ public final ExprList list() {
+ return new ExprList();
+ }
+
+ /**
+ * Convert the object into an expression using the query's PrefixMapping
+ *
+ * @param o
+ * the object to convert.
+ * @return the Expr.
+ */
+ public final Expr asExpr(Object o) {
+ return asExpr(o, pMap);
+ }
+
+ /**
+ * Convenience method to call AbstractQueryBuilder.quote
+ *
+ * @see AbstractQueryBuilder#quote(String)
+ * @param s
+ * the string to quote
+ * @return the quotes string.
+ */
+ public final String quote(String s) {
+ return AbstractQueryBuilder.quote(s);
+ }
+
+ /**
+ * Create an expression from an object.
+ *
+ * <b>this method does not parse strings to expressions.</b> to parse
+ * strings to expressions see {AbstractQueryBuilder.makeExpr}
+ *
+ * <ul>
+ * <li>If the object is null returns none()</li>
+ * <li>If the object is an expression return it</li>
+ * <li>If the object fronts a node and is not a var make a NodeVar</li>
+ * <li>otherwise calls var()</li>
+ * </ul>
+ *
+ * @see {@link #asVar(Object)}
+ * @see {@link AbstractQueryBuilder#makeVar(Object)}
+ *
+ * @param o
+ * the object to create the expression from
+ * @return
+ */
+ public static final Expr asExpr(Object o, PrefixMapping pMap) {
+ if (o == null) {
+ return Expr.NONE;
+ }
+ if (o instanceof Expr) {
+ return (Expr) o;
+ }
+ Node n = AbstractQueryBuilder.makeNode(o, pMap);
+
+ if (n.isVariable()) {
+ return new ExprVar(Var.alloc(n));
+ }
+ return NodeValue.makeNode(n);
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/cd4fde06/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/SelectBuilder.java
----------------------------------------------------------------------
diff --git a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/SelectBuilder.java b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/SelectBuilder.java
index bcd2f30..0978c8e 100644
--- a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/SelectBuilder.java
+++ b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/SelectBuilder.java
@@ -28,7 +28,6 @@ import org.apache.jena.arq.querybuilder.handlers.DatasetHandler;
import org.apache.jena.arq.querybuilder.handlers.HandlerBlock;
import org.apache.jena.arq.querybuilder.handlers.SelectHandler;
import org.apache.jena.arq.querybuilder.handlers.SolutionModifierHandler;
-import org.apache.jena.arq.querybuilder.handlers.WhereHandler;
import org.apache.jena.graph.FrontsNode;
import org.apache.jena.graph.FrontsTriple;
import org.apache.jena.graph.Node;
@@ -335,6 +334,12 @@ public class SelectBuilder extends AbstractQueryBuilder<SelectBuilder> implement
}
@Override
+ public SelectBuilder addFilter(Expr expr) {
+ getWhereHandler().addFilter(expr);
+ return this;
+ }
+
+ @Override
public SelectBuilder addFilter(String s) throws ParseException {
getWhereHandler().addFilter(s);
return this;
http://git-wip-us.apache.org/repos/asf/jena/blob/cd4fde06/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/clauses/PrologClause.java
----------------------------------------------------------------------
diff --git a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/clauses/PrologClause.java b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/clauses/PrologClause.java
index ba35c46..3770bc0 100644
--- a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/clauses/PrologClause.java
+++ b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/clauses/PrologClause.java
@@ -20,6 +20,7 @@ package org.apache.jena.arq.querybuilder.clauses;
import java.util.Map;
import org.apache.jena.arq.querybuilder.AbstractQueryBuilder;
+import org.apache.jena.arq.querybuilder.ExprFactory;
import org.apache.jena.arq.querybuilder.handlers.PrologHandler;
import org.apache.jena.graph.Node ;
import org.apache.jena.rdf.model.Resource ;
@@ -37,6 +38,13 @@ public interface PrologClause<T extends AbstractQueryBuilder<T>> {
* @return The PrologHandler this clause is using.
*/
public PrologHandler getPrologHandler();
+
+ /**
+ * Get the expression factory that works with the prefixes for this builder.
+ * @return an ExprFactory for this builder.
+ */
+ public ExprFactory getExprFactory();
+
/**
* Add a prefix.
http://git-wip-us.apache.org/repos/asf/jena/blob/cd4fde06/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/clauses/SolutionModifierClause.java
----------------------------------------------------------------------
diff --git a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/clauses/SolutionModifierClause.java b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/clauses/SolutionModifierClause.java
index 608c966..0f1c3b3 100644
--- a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/clauses/SolutionModifierClause.java
+++ b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/clauses/SolutionModifierClause.java
@@ -36,6 +36,13 @@ public interface SolutionModifierClause<T extends AbstractQueryBuilder<T>> {
/**
* Add an ascending order by.
*
+ * Use ExprFactory or NodeValue static or the AbstractQueryBuilder.makeExpr
+ * methods to create the expression.
+ *
+ * @see ExprFactory
+ * @see org.apache.jena.sparql.expr.NodeValue
+ * @see AbstractQueryBuilder#makeExpr(String)
+ *
* @param orderBy
* The expression to order by.
* @return The builder for chaining.
@@ -132,6 +139,13 @@ public interface SolutionModifierClause<T extends AbstractQueryBuilder<T>> {
/**
* Add a having expression.
*
+ * Use ExprFactory or NodeValue static or the AbstractQueryBuilder.makeExpr
+ * methods to create the expression.
+ *
+ * @see ExprFactory
+ * @see org.apache.jena.sparql.expr.NodeValue
+ * @see AbstractQueryBuilder#makeExpr(String)
+ *
* @param expression
* Expression to evaluate for the having.
* @return The builder for chaining.
http://git-wip-us.apache.org/repos/asf/jena/blob/cd4fde06/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/clauses/WhereClause.java
----------------------------------------------------------------------
diff --git a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/clauses/WhereClause.java b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/clauses/WhereClause.java
index a947354..cd78e76 100644
--- a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/clauses/WhereClause.java
+++ b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/clauses/WhereClause.java
@@ -19,12 +19,12 @@ package org.apache.jena.arq.querybuilder.clauses;
import org.apache.jena.arq.querybuilder.AbstractQueryBuilder;
import org.apache.jena.arq.querybuilder.handlers.WhereHandler;
-import org.apache.jena.graph.FrontsTriple ;
+import org.apache.jena.graph.FrontsTriple;
import org.apache.jena.graph.Node;
-import org.apache.jena.graph.Triple ;
+import org.apache.jena.graph.Triple;
import org.apache.jena.sparql.core.TriplePath;
import org.apache.jena.sparql.expr.Expr;
-import org.apache.jena.sparql.lang.sparql_11.ParseException ;
+import org.apache.jena.sparql.lang.sparql_11.ParseException;
/**
* Interface that defines the WhereClause as per
@@ -43,7 +43,7 @@ public interface WhereClause<T extends AbstractQueryBuilder<T>> {
* @return The Builder for chaining.
*/
public T addWhere(Triple t);
-
+
/**
* Adds a triple path to the where clause.
*
@@ -65,7 +65,8 @@ public interface WhereClause<T extends AbstractQueryBuilder<T>> {
/**
* Adds a triple or triple path to the where clause.
*
- * See {@link AbstractQueryBuilder#makeTriplePath} for conversion of the param values.
+ * See {@link AbstractQueryBuilder#makeTriplePath} for conversion of the
+ * param values.
*
* @param s
* The subject.
@@ -94,6 +95,7 @@ public interface WhereClause<T extends AbstractQueryBuilder<T>> {
* @return The Builder for chaining.
*/
public T addOptional(TriplePath t);
+
/**
* Adds an optional triple as to the where clause.
*
@@ -106,7 +108,8 @@ public interface WhereClause<T extends AbstractQueryBuilder<T>> {
/**
* Adds an optional triple or triple path to the where clause.
*
- * See {@link AbstractQueryBuilder#makeTriplePath} for conversion of the param values.
+ * See {@link AbstractQueryBuilder#makeTriplePath} for conversion of the
+ * param values.
*
* @param s
* The subject.
@@ -117,7 +120,7 @@ public interface WhereClause<T extends AbstractQueryBuilder<T>> {
* @return The Builder for chaining.
*/
public T addOptional(Object s, Object p, Object o);
-
+
/**
* Adds an optional group pattern to the where clause.
*
@@ -139,6 +142,22 @@ public interface WhereClause<T extends AbstractQueryBuilder<T>> {
public T addFilter(String expression) throws ParseException;
/**
+ * Adds a filter to the where clause
+ *
+ * Use ExprFactory or NodeValue static or the AbstractQueryBuilder.makeExpr
+ * methods to create the expression.
+ *
+ * @see ExprFactory
+ * @see org.apache.jena.sparql.expr.NodeValue
+ * @see AbstractQueryBuilder#makeExpr(String)
+ *
+ * @param expression
+ * the expression to evaluate for the filter.
+ * @return @return The Builder for chaining.
+ */
+ public T addFilter(Expr expression);
+
+ /**
* Add a sub query.
*
* @param subQuery
@@ -161,7 +180,8 @@ public interface WhereClause<T extends AbstractQueryBuilder<T>> {
* http://www.w3.org/TR/2013/REC-sparql11
* -query-20130321/#rGraphGraphPattern.
*
- * See {@link AbstractQueryBuilder#makeNode} for conversion of the graph param.
+ * See {@link AbstractQueryBuilder#makeNode} for conversion of the graph
+ * param.
*
* @param graph
* The iri or variable identifying the graph.
@@ -170,38 +190,46 @@ public interface WhereClause<T extends AbstractQueryBuilder<T>> {
* @return This builder for chaining.
*/
public T addGraph(Object graph, AbstractQueryBuilder<?> subQuery);
-
+
/**
- * Add a bind statement to the query
- * * http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#rGraphGraphPattern.
- * @param expression The expression to bind to the var.
- * @param var The variable to bind to.
+ * Add a bind statement to the query *
+ * http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#rGraphGraphPattern.
+ *
+ * @param expression
+ * The expression to bind to the var.
+ * @param var
+ * The variable to bind to.
* @return This builder for chaining.
*/
- public T addBind( Expr expression, Object var);
+ public T addBind(Expr expression, Object var);
/**
* Add a bind statement to the query
* http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#rGraphGraphPattern.
- * @param expression The expression to bind to the var.
- * @param var The variable to bind to.
+ *
+ * @param expression
+ * The expression to bind to the var.
+ * @param var
+ * The variable to bind to.
* @return This builder for chaining.
- * @throws ParseException
+ * @throws ParseException
*/
- public T addBind( String expression, Object var) throws ParseException;
-
+ public T addBind(String expression, Object var) throws ParseException;
+
/**
* Get the Where handler for this clause.
+ *
* @return The WhereHandler used by this clause.
*/
public WhereHandler getWhereHandler();
-
+
/**
* Create a list node from a list of objects as per RDF Collections.
*
- * http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#collections
+ * http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#collections
*
- * See {@link AbstractQueryBuilder#makeNode} for conversion of the param values.
+ * See {@link AbstractQueryBuilder#makeNode} for conversion of the param
+ * values.
* <p>
* usage:
* <ul>
@@ -211,20 +239,21 @@ public interface WhereClause<T extends AbstractQueryBuilder<T>> {
* </ul>
* </p>
*
- * @param objs the list of objects for the list.
+ * @param objs
+ * the list of objects for the list.
* @return the first blank node in the list.
*/
- public Node list( Object ... objs );
-
+ public Node list(Object... objs);
+
/**
* Add a minus clause to the query.
*
* https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#rMinusGraphPattern
*
- * @param t
+ * @param t
* The select builder to add as a minus pattern
* @return this builder for chaining
*/
- public T addMinus( AbstractQueryBuilder<?> t );
+ public T addMinus(AbstractQueryBuilder<?> t);
}
http://git-wip-us.apache.org/repos/asf/jena/blob/cd4fde06/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/PrologHandler.java
----------------------------------------------------------------------
diff --git a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/PrologHandler.java b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/PrologHandler.java
index fe3dcfc..9741a7c 100644
--- a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/PrologHandler.java
+++ b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/PrologHandler.java
@@ -20,6 +20,7 @@ package org.apache.jena.arq.querybuilder.handlers;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
+import org.apache.jena.arq.querybuilder.ExprFactory;
import org.apache.jena.graph.Node ;
import org.apache.jena.query.Query ;
import org.apache.jena.riot.system.IRIResolver;
@@ -104,6 +105,10 @@ public class PrologHandler implements Handler {
public PrefixMapping getPrefixes() {
return query.getPrefixMapping();
}
+
+ public ExprFactory getExprFactory() {
+ return new ExprFactory( query.getPrefixMapping() );
+ }
/**
* Add prefixes from a prefix mapping.
http://git-wip-us.apache.org/repos/asf/jena/blob/cd4fde06/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/WhereHandler.java
----------------------------------------------------------------------
diff --git a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/WhereHandler.java b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/WhereHandler.java
index ee6f0e0..b5f04ac 100644
--- a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/WhereHandler.java
+++ b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/WhereHandler.java
@@ -97,7 +97,7 @@ public class WhereHandler implements Handler {
/**
* Get the base element from the where clause. If the clause does not
* contain an element return the element group, otherwise return the
- * enclosed elelment.
+ * enclosed element.
*
* @return the base element.
*/
@@ -113,9 +113,11 @@ public class WhereHandler implements Handler {
* Get the element group for the clause. if The element group is not set,
* create and set it.
*
+ * Public for ExprFactory use.
+ *
* @return The element group.
*/
- private ElementGroup getClause() {
+ public ElementGroup getClause() {
Element e = query.getQueryPattern();
if (e == null) {
e = new ElementGroup();
@@ -127,7 +129,6 @@ public class WhereHandler implements Handler {
ElementGroup eg = new ElementGroup();
eg.addElement(e);
- ;
query.setQueryPattern(eg);
return eg;
}
http://git-wip-us.apache.org/repos/asf/jena/blob/cd4fde06/jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/AbstractQueryBuilderTest.java
----------------------------------------------------------------------
diff --git a/jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/AbstractQueryBuilderTest.java b/jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/AbstractQueryBuilderTest.java
index 6e07419..90eb6ea 100644
--- a/jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/AbstractQueryBuilderTest.java
+++ b/jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/AbstractQueryBuilderTest.java
@@ -103,36 +103,36 @@ public class AbstractQueryBuilderTest {
@Test
public void testMakeVar() {
- Var v = builder.makeVar(null);
+ Var v = AbstractQueryBuilder.makeVar(null);
assertEquals(Var.ANON, v);
- v = builder.makeVar("a");
+ v = AbstractQueryBuilder.makeVar("a");
assertEquals(Var.alloc("a"), v);
- v = builder.makeVar("?a");
+ v = AbstractQueryBuilder.makeVar("?a");
assertEquals(Var.alloc("a"), v);
Node n = NodeFactory.createVariable("foo");
- v = builder.makeVar(n);
+ v = AbstractQueryBuilder.makeVar(n);
assertEquals(Var.alloc("foo"), v);
NodeFront nf = new NodeFront(n);
- v = builder.makeVar(nf);
+ v = AbstractQueryBuilder.makeVar(nf);
assertEquals(Var.alloc("foo"), v);
- v = builder.makeVar(Node_RuleVariable.WILD);
+ v = AbstractQueryBuilder.makeVar(Node_RuleVariable.WILD);
assertNull(v);
ExprVar ev = new ExprVar("bar");
- v = builder.makeVar(ev);
+ v = AbstractQueryBuilder.makeVar(ev);
assertEquals(Var.alloc("bar"), v);
ev = new ExprVar(n);
- v = builder.makeVar(ev);
+ v = AbstractQueryBuilder.makeVar(ev);
assertEquals(Var.alloc("foo"), v);
ev = new ExprVar(Var.ANON);
- v = builder.makeVar(ev);
+ v = AbstractQueryBuilder.makeVar(ev);
assertEquals(Var.ANON, v);
}