protected final void raiseException(RiotParseException ex) { throw new QueryException("Error passing SPARQL JSON results", ex); }
throw new TerminationException(2) ; } catch (QueryException qEx) { System.err.println(qEx.getMessage()) ; throw new TerminationException(2) ; } catch (JenaException ex) {
System.err.println(qEx.getMessage()) ; throw new TerminationException(2) ;
/** Location of the source for the data. If the model is not set, * then the QueryEngine will attempt to load the data from these URIs * as named graphs in the dataset. */ public void addNamedGraphURI(String uri) { if ( namedGraphURIs == null ) namedGraphURIs = new ArrayList<String>() ; if ( namedGraphURIs.contains(uri) ) throw new QueryException("URI already in named graph set: "+uri) ; else namedGraphURIs.add(uri) ; }
@Override public QueryIterator execEvaluated(Binding binding, PropFuncArg argSubject, Node predicate, PropFuncArg argObject, ExecutionContext execCxt) { try { // Subject bound to something other a URI. if ( argSubject.getArg().isLiteral() || argSubject.getArg().isBlank() ) // Only split IRIs return IterLib.noResults(execCxt) ; if ( argSubject.getArg().isURI() ) // Case 1 : subject is a fixed URI or a variable bount to a URI. return subjectIsIRI(argSubject.getArg(), argObject, binding, execCxt) ; else // Case 2 : subject is an unbound variable. return subjectIsVariable(argSubject.getArg(), argObject, execCxt) ; } catch (QueryException ex) { Log.warn(this, "Unexpected problems in splitIRI: "+ex.getMessage()) ; return null ; } }
/** Location of the source for the data. If the model is not set, * then the QueryEngine will attempt to load the data from these URIs * as named graphs in the dataset. */ public void addNamedGraphURI(String uri) { if ( namedGraphURIs == null ) namedGraphURIs = new ArrayList<String>() ; if ( namedGraphURIs.contains(uri) ) throw new QueryException("URI already in named graph set: "+uri) ; else namedGraphURIs.add(uri) ; }
@Override public QueryIterator execEvaluated(Binding binding, PropFuncArg argSubject, Node predicate, PropFuncArg argObject, ExecutionContext execCxt) { try { // Subject bound to something other a URI. if ( argSubject.getArg().isLiteral() || argSubject.getArg().isBlank() ) // Only split IRIs return IterLib.noResults(execCxt) ; if ( argSubject.getArg().isURI() ) // Case 1 : subject is a fixed URI or a variable bount to a URI. return subjectIsIRI(argSubject.getArg(), argObject, binding, execCxt) ; else // Case 2 : subject is an unbound variable. return subjectIsVariable(argSubject.getArg(), argObject, execCxt) ; } catch (QueryException ex) { Log.warn(this, "Unexpected problems in splitIRI: "+ex.getMessage()) ; return null ; } }
@Override public void jjtClose() { int n = jjtGetNumChildren() ; if ( n != 2 ) throw new QueryException("Q_StringNotEqual: Wrong number of children: "+n) ; super.jjtClose() ; } }
@Override public void jjtClose() { int n = jjtGetNumChildren() ; if ( n != 1 ) throw new QueryException("Q_UnaryPlus: Wrong number of children: "+n) ; expr = (ExprRDQL)jjtGetChild(0) ; }
@Override public void jjtClose() { int n = jjtGetNumChildren() ; if ( n != 1 ) throw new QueryException("Q_UnaryMinus: Wrong number of children: "+n) ; expr = (ExprRDQL)jjtGetChild(0) ; }
/** Add a collection of projection variables to a SELECT query */ public void addProjectVars(Collection<?> vars) { for ( Iterator<?> iter = vars.iterator() ; iter.hasNext() ; ) { Object obj = iter.next(); if ( obj instanceof String ) { this.addResultVar((String)obj) ; continue ; } if ( obj instanceof Var ) { this.addResultVar((Var)obj) ; continue ; } throw new QueryException("Not a variable or variable name: "+obj) ; } resultVarsSet = true ; }
/** Add a collection of projection variables to a SELECT query */ public void addProjectVars(Collection<?> vars) { for ( Iterator<?> iter = vars.iterator() ; iter.hasNext() ; ) { Object obj = iter.next(); if ( obj instanceof String ) { this.addResultVar((String)obj) ; continue ; } if ( obj instanceof Var ) { this.addResultVar((Var)obj) ; continue ; } throw new QueryException("Not a variable or variable name: "+obj) ; } resultVarsSet = true ; }
@Override public void jjtClose() { int n = jjtGetNumChildren(); if (n != 1) throw new QueryException("Q_UnaryNot: Wrong number of children: " + n); expr = (ExprRDQL) jjtGetChild(0); }
private boolean parseNextBinding() { String line; try { line = this.reader.readLine(); //Once EOF has been reached we'll see null for this call so we can return false because there are no further bindings if (line == null) return false; this.lineNum++; } catch (IOException e) { throw new QueryException("Error parsing CSV results - " + e.getMessage()); } if ( line.isEmpty() ) { // Empty input line - no bindings. // Only valid when we expect zero/one values as otherwise we should get a sequence of tab characters // which means a non-empty string which we handle normally if (expectedItems > 1) throw new QueryException(String.format("Error Parsing CSV results at Line %d - The result row had 0/1 values when %d were expected", this.lineNum, expectedItems)); binding = BindingFactory.create() ; if ( expectedItems == 1 ) binding.add(vars.get(0), NodeConst.emptyString) ; return true ; } binding = parseLine(vars, line) ; return true ; }
public void addDescribeNode(Node node) { if ( node.isVariable() ) { addResultVar(node) ; return ; } if ( node.isURI() || node.isBlank() ) { if ( !resultNodes.contains(node) ) resultNodes.add(node); return ; } if ( node.isLiteral() ) throw new QueryException("Result node is a literal: "+FmtUtils.stringForNode(node)) ; throw new QueryException("Result node not recognized: "+node) ; }
public void addDescribeNode(Node node) { if ( node.isVariable() ) { addResultVar(node) ; return ; } if ( node.isURI() || node.isBlank() ) { if ( !resultNodes.contains(node) ) resultNodes.add(node); return ; } if ( node.isLiteral() ) throw new QueryException("Result node is a literal: "+FmtUtils.stringForNode(node)) ; throw new QueryException("Result node not recognized: "+node) ; }
throw new QueryException(String.format("Error Parsing CSV results at Line %d - Unterminated quoted string", this.lineNum)); if ( idx < line.length() ) throw new QueryException(String.format("Error Parsing CSV results at Line %d - Expected comma after quote", this.lineNum)) ; throw new QueryException(String.format("Error Parsing CSV results at Line %d - The result row '%s' has %d items when %d was expected", this.lineNum, line, terms.size(), vars.size())) ; for ( int i = 0 ; i < vars.size() ; i++ ) binding.add(vars.get(i), NodeFactory.createLiteral(terms.get(i))) ;
@Override public void jjtClose() { int n = jjtGetNumChildren() ; if ( n != 2 ) throw new QueryException("Q_RightSignedShift: Wrong number of children: "+n) ; left = (ExprRDQL)jjtGetChild(0) ; right = (ExprRDQL)jjtGetChild(1) ; }
@Override public void jjtClose() { int n = jjtGetNumChildren() ; if ( n != 2 ) throw new QueryException("Q_LogicalOr: Wrong number of children: "+n) ; left = (ExprRDQL)jjtGetChild(0) ; right = (ExprRDQL)jjtGetChild(1) ; }
@Override public void jjtClose() { int n = jjtGetNumChildren() ; if ( n != 2 ) throw new QueryException("Q_StringEqual: Wrong number of children: "+n) ; left = (ExprRDQL)jjtGetChild(0) ; right = (ExprRDQL)jjtGetChild(1) ; }