diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphCopyAdd.java b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphCopyAdd.java deleted file mode 100644 index 296b555fb91..00000000000 --- a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphCopyAdd.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * 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. - */ - -package org.apache.jena.sparql.core; - -import org.apache.jena.graph.Graph ; -import org.apache.jena.graph.Node ; - -/** Override {@link DatasetGraph#addGraph} so that it always copies - * content from the added graph data. - */ - -/*package*/ class DatasetGraphCopyAdd extends DatasetGraphWrapper -{ - public DatasetGraphCopyAdd(boolean x , DatasetGraph dsg) { - super(dsg); - } - - @Override - public void addGraph(Node graphName, Graph graph) { - graph.find(null,null,null).forEachRemaining(t-> { - Quad q = Quad.create(graphName, t) ; - super.add(q) ; - }) ; - } -} \ No newline at end of file diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/expr/ExprSystem.java b/jena-arq/src/main/java/org/apache/jena/sparql/expr/ExprSystem.java index dc312921808..62cd25e3858 100644 --- a/jena-arq/src/main/java/org/apache/jena/sparql/expr/ExprSystem.java +++ b/jena-arq/src/main/java/org/apache/jena/sparql/expr/ExprSystem.java @@ -25,7 +25,7 @@ public abstract class ExprSystem extends ExprFunction0 { - private final Symbol systemSymbol ; + protected final Symbol systemSymbol ; protected ExprSystem(String fName, Symbol systemSymbol) { @@ -41,12 +41,11 @@ public NodeValue eval(FunctionEnv env) if ( obj == null ) throw new ExprEvalException("null for system symbol: "+systemSymbol) ; if ( ! ( obj instanceof Node ) ) - throw new ExprEvalException("Not a Node: "+Lib.className(obj)) ; + throw new ExprEvalException("ExprSystem: Not a Node: "+Lib.className(obj)) ; Node n = (Node)obj ; -// if ( n == null ) -// throw new ExprEvalException("No value for system variable: "+systemSymbol) ; - // NodeValue.makeNode could have a cache. + if ( n == null ) + throw new ExprEvalException("No value for system variable: "+systemSymbol) ; NodeValue nv = NodeValue.makeNode(n) ; return nv ; } diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/sse/builders/BuilderLib.java b/jena-arq/src/main/java/org/apache/jena/sparql/sse/builders/BuilderLib.java index a154ac27761..ed7b3e8dbd8 100644 --- a/jena-arq/src/main/java/org/apache/jena/sparql/sse/builders/BuilderLib.java +++ b/jena-arq/src/main/java/org/apache/jena/sparql/sse/builders/BuilderLib.java @@ -18,168 +18,135 @@ package org.apache.jena.sparql.sse.builders; -import org.apache.jena.sparql.sse.Item ; -import org.apache.jena.sparql.sse.ItemList ; -import org.apache.jena.sparql.sse.ItemLocation ; - -public class BuilderLib -{ - - public static void checkNode(Item item) - { - if ( item.isNode() ) - return ; - broken(item, "Not a node: "+item.shortString()) ; - } - - public static void checkSymbol(Item item) - { - if ( item.isSymbol() ) - return ; - broken(item, "Not a symbol: "+item.shortString()) ; - } - - public static void checkTagged(Item item, String tag, String msg) - { - if ( item.isTagged(tag) ) return ; - broken(item, msg, item) ; - } - - public static void checkTagged(Item item, int len, String tag, String msg) - { - if ( item.isTagged(tag) && item.getList().size() == len ) - return ; - broken(item, msg, item) ; - } - - - public static void checkTag(ItemList list, String tag) - { +import org.apache.jena.sparql.sse.Item; +import org.apache.jena.sparql.sse.ItemList; +import org.apache.jena.sparql.sse.ItemLocation; + +public class BuilderLib { + + public static void checkNode(Item item) { + if ( item.isNode() ) + return; + broken(item, "Not a node: " + item.shortString()); + } + + public static void checkSymbol(Item item) { + if ( item.isSymbol() ) + return; + broken(item, "Not a symbol: " + item.shortString()); + } + + public static void checkTagged(Item item, String tag, String msg) { + if ( item.isTagged(tag) ) + return; + broken(item, msg, item); + } + + public static void checkTagged(Item item, int len, String tag, String msg) { + if ( item.isTagged(tag) && item.getList().size() == len ) + return; + broken(item, msg, item); + } + + public static void checkTag(ItemList list, String tag) { if ( list.size() == 0 ) - broken(list, "Empty list") ; - if ( ! list.get(0).isSymbolIgnoreCase(tag) ) - broken(list, "List does not start ("+tag+ "...) : "+list.shortString()) ; + broken(list, "Empty list"); + if ( !list.get(0).isSymbolIgnoreCase(tag) ) + broken(list, "List does not start (" + tag + "...) : " + list.shortString()); } - public static void checkList(Item item) - { - if ( item.isList() ) - return ; - broken(item, "Not a list: "+item.shortString()) ; + public static void checkList(Item item) { + if ( item.isList() ) + return; + broken(item, "Not a list: " + item.shortString()); } - public static void checkList(Item item, String msg) - { + public static void checkList(Item item, String msg) { if ( item.isList() ) - return ; - if ( msg == null && item.isSymbol()) - msg = "Attempt to use a symbol where list expected: "+item.shortString() ; - if ( msg == null && item.isNode()) - msg = "Attempt to use a node where list expected: "+item.shortString() ; + return; + if ( msg == null && item.isSymbol() ) + msg = "Attempt to use a symbol where list expected: " + item.shortString(); + if ( msg == null && item.isNode() ) + msg = "Attempt to use a node where list expected: " + item.shortString(); if ( msg == null ) - msg = "Not a list" ; - broken(item, msg) ; - } - - public static void warning(ItemLocation location, String msg) - { - msg = msg(location, msg) ; - System.err.println(msg) ; + msg = "Not a list"; + broken(item, msg); } - public static void checkLength(int len1, int len2, ItemList list, String msg) - { + public static void checkLength(int len1, int len2, ItemList list, String msg) { if ( list.size() >= len1 && list.size() <= len2 ) - return ; + return; if ( msg == null ) - msg = "Wrong number of arguments: ("+len1+"-"+len2+")/"+list.size()+" : "+list.shortString() ; + msg = "Wrong number of arguments: (" + len1 + "-" + len2 + ")/" + list.size() + " : " + list.shortString(); else - msg = msg+" : "+list.shortString() ; - broken(list, msg) ; - } - - - - public static void checkLength(int len, ItemList list, String msg) - { + msg = msg + " : " + list.shortString(); + broken(list, msg); + } + + public static void checkLength(int len, ItemList list, String msg) { if ( list.size() == len ) - return ; - + return; + if ( msg == null ) - msg = "Wrong number of arguments: "+len+"/"+list.size()+" : "+list.shortString() ; + msg = "Wrong number of arguments: " + len + "/" + list.size() + " : " + list.shortString(); else - msg = msg+" : "+list.shortString() ; - broken(list, msg) ; + msg = msg + " : " + list.shortString(); + broken(list, msg); } - public static void checkLengthAtLeast(int len, ItemList list, String msg) - { - if ( list.size()>= len ) - return ; - + public static void checkLengthAtLeast(int len, ItemList list, String msg) { + if ( list.size() >= len ) + return; + if ( msg == null ) - msg = "Too few arguments: want > "+len+" :got : "+list.size()+" : "+list.shortString() ; + msg = "Too few arguments: want > " + len + " :got : " + list.size() + " : " + list.shortString(); else - msg = msg+" : "+list.shortString() ; - broken(list, msg) ; - } - - public static void broken(Item item, String msg) - { - broken(item, msg, item) ; - } - - public static void broken(String msg) - { - System.err.println(msg) ; - exception(msg) ; - } - - public static void exception(String msg) - { - throw new ExprBuildException(msg) ; - } - - public static void broken(ItemLocation location, String msg, Item item) - { - msg = msg(location, msg) ; - System.err.println(msg+": "+item.shortString()) ; - exception(msg) ; - } - - public static void broken(ItemList list, String msg) - { - broken(list, msg, list) ; - } - - public static void broken(ItemLocation location, String msg, ItemList list) - { - msg = msg(location, msg) ; - System.err.println(msg+": "+list.shortString()) ; - exception(msg) ; - } - - public static void broken(ItemLocation location, String msg) - { - msg = msg(location, msg) ; - System.err.println(msg) ; - exception(msg) ; - } - - public static String msg(ItemLocation location, String msg) - { + msg = msg + " : " + list.shortString(); + broken(list, msg); + } + + public static void broken(Item item, String msg) { + broken(item, msg, item); + } + + public static void broken(String msg) { + exception(msg); + } + + public static void exception(String msg) { + throw new ExprBuildException(msg); + } + + public static void broken(ItemLocation location, String msg, Item item) { + msg = msg(location, msg); + exception(msg); + } + + public static void broken(ItemList list, String msg) { + broken(list, msg, list); + } + + public static void broken(ItemLocation location, String msg, ItemList list) { + msg = msg(location, msg); + exception(msg); + } + + public static void broken(ItemLocation location, String msg) { + msg = msg(location, msg); + exception(msg); + } + + public static String msg(ItemLocation location, String msg) { if ( location != null ) - msg = location.location()+": "+msg ; - return msg ; + msg = location.location() + ": " + msg; + return msg; } - public static ItemList skipTag(ItemList list, String tag) - { - if ( list.size() > 0 ) - { + public static ItemList skipTag(ItemList list, String tag) { + if ( list.size() > 0 ) { if ( list.get(0).isSymbol(tag) ) - list = list.cdr() ; + list = list.cdr(); } - return list ; + return list; } } diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/util/FmtUtils.java b/jena-arq/src/main/java/org/apache/jena/sparql/util/FmtUtils.java index 8452fbeeab4..e9a3adaa9c2 100644 --- a/jena-arq/src/main/java/org/apache/jena/sparql/util/FmtUtils.java +++ b/jena-arq/src/main/java/org/apache/jena/sparql/util/FmtUtils.java @@ -49,7 +49,7 @@ public class FmtUtils { // OLD CODE - being replaced by riot.NodeFmtLib - // Consider withdrawing non-serialzation context forms of this. + // Consider withdrawing non-serialization context forms of this. // Or a temporary SerialzationContext does not abbreviate bNodes. static final String indentPrefix = " " ; public static boolean multiLineExpr = false ;