jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cla...@apache.org
Subject [03/11] jena git commit: Changes to JENA-946 to rely on ExprUtils.parse for expression parsing.
Date Tue, 19 May 2015 19:14:48 GMT
Changes to JENA-946 to rely on ExprUtils.parse for expression parsing.


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/b739e4d5
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/b739e4d5
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/b739e4d5

Branch: refs/heads/add-contract-tests
Commit: b739e4d59e9b2fbbf313858da5f5e82a2db7b1d2
Parents: b03ce37
Author: Claude Warren <claude@apache.org>
Authored: Sun May 17 18:23:32 2015 +0100
Committer: Claude Warren <claude@apache.org>
Committed: Sun May 17 18:23:32 2015 +0100

----------------------------------------------------------------------
 .../jena/arq/querybuilder/handlers/Handler.java | 22 +++++++++++---------
 .../querybuilder/handlers/SelectHandler.java    |  7 +++----
 .../arq/querybuilder/handlers/WhereHandler.java | 13 +++---------
 3 files changed, 18 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/b739e4d5/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/Handler.java
----------------------------------------------------------------------
diff --git a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/Handler.java
b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/Handler.java
index 2070225..3061a25 100644
--- a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/Handler.java
+++ b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/Handler.java
@@ -27,6 +27,7 @@ import org.apache.jena.sparql.core.Var ;
 import org.apache.jena.sparql.expr.Expr;
 import org.apache.jena.sparql.lang.sparql_11.ParseException;
 import org.apache.jena.sparql.lang.sparql_11.SPARQLParser11;
+import org.apache.jena.sparql.util.ExprUtils;
 
 /**
  * The base interface for handlers.
@@ -46,14 +47,15 @@ public interface Handler {
 	 */
 	public void build();
 	
-	public static class Utils {
-		public static Expr parseExpression( Query query, String expression ) throws ParseException
-		{
-			SPARQLParser11 parser = new SPARQLParser11(new ByteArrayInputStream(
-					expression.getBytes()));
-			Prologue prologue = new Prologue( query.getPrefixMapping() );
-			parser.setPrologue(prologue);
-			return parser.Expression();
-		}
-	}
+//	public static class Utils {
+//		public static Expr parseExpression( Query query, String expression ) throws ParseException
+//		{
+//			ExprUtils.parse(s)
+//			SPARQLParser11 parser = new SPARQLParser11(new ByteArrayInputStream(
+//					expression.getBytes()));
+//			Prologue prologue = new Prologue( query.getPrefixMapping() );
+//			parser.setPrologue(prologue);
+//			return parser.Expression();
+//		}
+//	}
 }

http://git-wip-us.apache.org/repos/asf/jena/blob/b739e4d5/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/SelectHandler.java
----------------------------------------------------------------------
diff --git a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/SelectHandler.java
b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/SelectHandler.java
index df3261b..3edd842 100644
--- a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/SelectHandler.java
+++ b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/SelectHandler.java
@@ -26,7 +26,7 @@ import org.apache.jena.query.Query ;
 import org.apache.jena.sparql.core.Var ;
 import org.apache.jena.sparql.core.VarExprList ;
 import org.apache.jena.sparql.expr.Expr;
-import org.apache.jena.sparql.lang.sparql_11.ParseException;
+import org.apache.jena.sparql.util.ExprUtils;
 
 /**
  * A Select clause handler.
@@ -91,10 +91,9 @@ public class SelectHandler implements Handler {
 	 * If the variable is the variables are set to star.
 	 * @param expression The expression as a string.
 	 * @param var The variable to add.
-	 * @throws ParseException 
 	 */
-	public void addVar(String expression, Var var) throws ParseException {
-		addVar( Utils.parseExpression(query, expression), var );
+	public void addVar(String expression, Var var)  {
+		addVar( ExprUtils.parse( query, expression, true ), var );
 	}
 	
 	/**

http://git-wip-us.apache.org/repos/asf/jena/blob/b739e4d5/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 754e7a3..c6dab1a 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
@@ -17,7 +17,6 @@
  */
 package org.apache.jena.arq.querybuilder.handlers;
 
-import java.io.ByteArrayInputStream;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -31,12 +30,11 @@ import org.apache.jena.arq.querybuilder.rewriters.ElementRewriter;
 import org.apache.jena.graph.Node ;
 import org.apache.jena.graph.Triple ;
 import org.apache.jena.query.Query ;
-import org.apache.jena.sparql.core.Prologue;
 import org.apache.jena.sparql.core.Var ;
 import org.apache.jena.sparql.expr.Expr ;
 import org.apache.jena.sparql.lang.sparql_11.ParseException ;
-import org.apache.jena.sparql.lang.sparql_11.SPARQLParser11 ;
 import org.apache.jena.sparql.syntax.* ;
+import org.apache.jena.sparql.util.ExprUtils;
 
 /**
  * The where handler
@@ -192,12 +190,7 @@ public class WhereHandler implements Handler {
 	 * @throws ParseException If the expression can not be parsed.
 	 */
 	public void addFilter(String expression) throws ParseException {
-		String filterClause = "FILTER( " + expression + ")";
-		SPARQLParser11 parser = new SPARQLParser11(new ByteArrayInputStream(
-				filterClause.getBytes()));
-		Prologue prologue = new Prologue( query.getPrefixMapping() );
-		parser.setPrologue(prologue);
-		getClause().addElement(parser.Filter());
+		getClause().addElement( new ElementFilter( ExprUtils.parse( query, expression, true ) )
);
 	}
 
 	/**
@@ -307,7 +300,7 @@ public class WhereHandler implements Handler {
 	public void addBind( String expression, Var var ) throws ParseException
 	{
 		getClause().addElement(
-				new ElementBind(var, Utils.parseExpression(query, expression))
+				new ElementBind(var, ExprUtils.parse( query, expression, true ))
 				);
 	}
 	


Mime
View raw message