use of org.apache.jena.sparql.expr.ExprEvalException in project jena by apache.
the class AccStatLib method calcVariance$.
// Engine.
private static double calcVariance$(double sumSquared, double sum, long N, long N1) {
// System.out.printf("sum = %f, sumSq = %f, N=%d\n", sum, sumSquared, N) ;
if (N <= 0)
throw new ExprEvalException("N= " + N);
if (N1 == 0)
throw new ExprEvalException("Sample size one");
double x = sumSquared - (sum * sum) / N;
x = x / N1;
return x;
}
use of org.apache.jena.sparql.expr.ExprEvalException in project jena by apache.
the class NodeFunctions method strLang.
public static NodeValue strLang(NodeValue v1, NodeValue v2) {
if (!v1.isString())
throw new ExprEvalException("Not a string (arg 1): " + v1);
if (!v2.isString())
throw new ExprEvalException("Not a string (arg 2): " + v2);
String lex = v1.asString();
String lang = v2.asString();
if (lang.isEmpty())
throw new ExprEvalException("Empty lang tag");
return NodeValue.makeLangString(lex, lang);
}
use of org.apache.jena.sparql.expr.ExprEvalException in project jena by apache.
the class NodeFunctions method rdfTermEquals.
// Exact as defined by SPARQL spec.
public static boolean rdfTermEquals(Node n1, Node n2) {
if (n1.equals(n2))
return true;
if (n1.isLiteral() && n2.isLiteral()) {
// Two literals, may be sameTerm by language tag case insensitivity.
String lang1 = n1.getLiteralLanguage();
String lang2 = n2.getLiteralLanguage();
if (!lang1.equals("") && lang1.equalsIgnoreCase(lang2)) {
// Two language tags, equal by case insensitivity.
boolean b = n1.getLiteralLexicalForm().equals(n2.getLiteralLexicalForm());
if (b)
return true;
}
// Two literals, different terms, different language tags.
NodeValue.raise(new ExprEvalException("Mismatch in RDFterm-equals: " + n1 + ", " + n2));
}
// One or both not a literal.
return false;
}
use of org.apache.jena.sparql.expr.ExprEvalException in project jena by apache.
the class NodeFunctions method strDatatype.
public static NodeValue strDatatype(NodeValue v1, NodeValue v2) {
if (!v1.isString())
throw new ExprEvalException("Not a string (arg 1): " + v1);
if (!v2.isIRI())
throw new ExprEvalException("Not an IRI (arg 2): " + v2);
String lex = v1.asString();
Node dt = v2.asNode();
// Check?
Node n = NodeFactory.createLiteral(lex, NodeFactory.getType(dt.getURI()));
return NodeValue.makeNode(n);
}
use of org.apache.jena.sparql.expr.ExprEvalException in project jena by apache.
the class listIndex method execObjectList.
@Override
protected QueryIterator execObjectList(Binding binding, Var listVar, Node predicate, List<Node> objectArgs, ExecutionContext execCxt) {
if (objectArgs.size() != 2)
throw new ExprEvalException("ListIndex : object not a list of length 2");
Node indexNode = objectArgs.get(0);
Node memberNode = objectArgs.get(1);
final Collection<Node> x;
if (!Var.isVar(memberNode))
// If memberNode is defined, find lists containing it.
x = GraphList.listFromMember(new GNode(execCxt.getActiveGraph(), memberNode));
else
// Hard. Subject unbound, no fixed member. Find every list and use BFI.
x = GraphList.findAllLists(execCxt.getActiveGraph());
return super.allLists(binding, x, listVar, predicate, new PropFuncArg(objectArgs, null), execCxt);
}
Aggregations