use of org.apache.jena.sparql.ARQInternalErrorException in project jena by apache.
the class QueryIterProcessBinding method hasNextBinding.
/**
* Are there any more acceptable objects.
*
* @return true if there is another acceptable object.
*/
@Override
protected boolean hasNextBinding() {
// Needs to be idempotent.?
if (isFinished())
return false;
if (nextBinding != null)
return true;
// Null iterator.
if (getInput() == null)
throw new ARQInternalErrorException(Lib.className(this) + ": Null iterator");
while (getInput().hasNext()) {
// Skip forward until a binding to return is found.
Binding input = getInput().nextBinding();
Binding output = accept(input);
if (output != null) {
nextBinding = output;
return true;
}
}
nextBinding = null;
return false;
}
use of org.apache.jena.sparql.ARQInternalErrorException in project jena by apache.
the class QueryIterPeek method moveToNextBinding.
@Override
protected Binding moveToNextBinding() {
if (!hasNextBinding())
throw new ARQInternalErrorException("No next binding");
Binding b = binding;
binding = null;
return b;
}
use of org.apache.jena.sparql.ARQInternalErrorException in project jena by apache.
the class NodeUtils method compareLiteralsBySyntax.
/** Compare literals by kind - not by value.
* Gives a determinitics, stable, arbitrary ordering between unrelated literals.
*
* Ordering:
* <ol>
* <li>By lexical form</li>
* <li> For same lexical form:
* <ul>
* <li> RDF 1.0 : simple literal < literal by lang < literal with type
* <li> RDF 1.1 : xsd:string < rdf:langString < other dataypes.<br/>
* This is the closest to SPARQL 1.1: treat xsd:string as a simple literal</ul></li>
* <li> Lang by sorting on language tag (first case insensistive then case sensitive)
* <li> Datatypes by URI
* </ol>
*/
private static int compareLiteralsBySyntax(Node node1, Node node2) {
if (node1 == null || !node1.isLiteral() || node2 == null || !node2.isLiteral())
throw new ARQInternalErrorException("compareLiteralsBySyntax called with non-literal: (" + node1 + "," + node2 + ")");
if (node1.equals(node2))
return Expr.CMP_EQUAL;
String lex1 = node1.getLiteralLexicalForm();
String lex2 = node2.getLiteralLexicalForm();
int x = StrUtils.strCompare(lex1, lex2);
if (x != Expr.CMP_EQUAL)
return x;
// Same lexical form. Not .equals()
if (// node2 not a simple string because they
isSimpleString(node1))
// would be .equals
return Expr.CMP_LESS;
if (isSimpleString(node2))
return Expr.CMP_GREATER;
// Both language strings?
if (isLangString(node1) && isLangString(node2)) {
String lang1 = node1.getLiteralLanguage();
String lang2 = node2.getLiteralLanguage();
x = StrUtils.strCompareIgnoreCase(lang1, lang2);
if (x != Expr.CMP_EQUAL)
return x;
x = StrUtils.strCompare(lang1, lang2);
if (x != Expr.CMP_EQUAL)
return x;
throw new ARQInternalErrorException("compareLiteralsBySyntax: lexical form and languages tags identical on non.equals literals");
}
// One a language string?
if (isLangString(node1))
return Expr.CMP_LESS;
if (isLangString(node2))
return Expr.CMP_GREATER;
// Both have other datatypes. Neither simple nor language tagged.
String dt1 = node1.getLiteralDatatypeURI();
String dt2 = node2.getLiteralDatatypeURI();
// Two datatypes.
return StrUtils.strCompare(dt1, dt2);
}
use of org.apache.jena.sparql.ARQInternalErrorException in project jena by apache.
the class ModelUtils method tripleToStatement.
public static Statement tripleToStatement(Model model, Triple t) {
if (model == null)
throw new ARQInternalErrorException("Attempt to create statement with null model");
Node sNode = t.getSubject();
Node pNode = t.getPredicate();
Node oNode = t.getObject();
if (!isValidAsStatement(sNode, pNode, oNode))
return null;
return model.asStatement(t);
}
use of org.apache.jena.sparql.ARQInternalErrorException in project jena by apache.
the class qparse method exec.
@Override
protected void exec() {
try {
Query query = modQuery.getQuery();
try {
LogCtl.disable(ParserBase.ParserLoggerName);
QueryUtils.checkQuery(query, true);
} catch (QueryCheckException ex) {
System.err.println();
System.err.println("**** Check failure: " + ex.getMessage());
if (ex.getCause() != null)
ex.getCause().printStackTrace(System.err);
} finally {
LogCtl.setLevel(ParserBase.ParserLoggerName, "INFO");
}
// Print the query out in some syntax
if (printQuery) {
divider();
modOutput.output(query);
}
// Print internal forms.
if (printOp) {
divider();
modOutput.outputOp(query, false);
}
if (printQuad) {
divider();
modOutput.outputQuad(query, false);
}
if (printOpt) {
divider();
modOutput.outputOp(query, true);
}
if (printQuadOpt) {
divider();
modOutput.outputQuad(query, true);
}
if (printPlan) {
divider();
// This forces internal query initialization - must be after QueryUtils.checkQuery
QueryExecution qExec = QueryExecutionFactory.create(query, DatasetFactory.createGeneral());
QueryOutputUtils.printPlan(query, qExec);
}
} catch (ARQInternalErrorException intEx) {
System.err.println(intEx.getMessage());
if (intEx.getCause() != null) {
System.err.println("Cause:");
intEx.getCause().printStackTrace(System.err);
System.err.println();
}
intEx.printStackTrace(System.err);
} catch (ResultSetException ex) {
System.err.println(ex.getMessage());
ex.printStackTrace(System.err);
} catch (QueryException qEx) {
//System.err.println(qEx.getMessage()) ;
throw new CmdException("Query Exeception", qEx);
} catch (JenaException ex) {
ex.printStackTrace();
throw ex;
} catch (CmdException ex) {
throw ex;
} catch (Exception ex) {
throw new CmdException("Exception", ex);
}
}
Aggregations