use of org.apache.jena.sparql.ARQInternalErrorException in project jena by apache.
the class VarExprList method add.
public void add(Var var, Expr expr) {
if (expr == null) {
add(var);
return;
}
if (var == null)
throw new ARQInternalErrorException("Attempt to add a named expression with a null variable");
if (exprs.containsKey(var))
throw new ARQInternalErrorException("Attempt to assign an expression again");
add(var);
exprs.put(var, expr);
}
use of org.apache.jena.sparql.ARQInternalErrorException in project jena by apache.
the class Loader method loadClass.
public static Class<?> loadClass(String classNameOrURI, Class<?> requiredClass) {
if (classNameOrURI == null)
throw new ARQInternalErrorException("Null classNameorIRI");
if (classNameOrURI.startsWith("http:"))
return null;
if (classNameOrURI.startsWith("urn:"))
return null;
String className = classNameOrURI;
if (classNameOrURI.startsWith(ARQConstants.javaClassURIScheme))
className = classNameOrURI.substring(ARQConstants.javaClassURIScheme.length());
Class<?> classObj = null;
try {
classObj = Class.forName(className);
} catch (ClassNotFoundException ex) {
// It is possible that when coming from a URI we might have
// characters which aren't valid as Java identifiers
// We should see if we can load the class with the escaped class
// name instead
String baseUri = className.substring(0, className.lastIndexOf('.') + 1);
String escapedClassName = escape(className.substring(className.lastIndexOf('.') + 1));
try {
classObj = Class.forName(baseUri + escapedClassName);
} catch (ClassNotFoundException innerEx) {
// Ignore, handled in the outer catch
}
if (classObj == null) {
Log.warn(Loader.class, "Class not found: " + className);
return null;
}
}
if (requiredClass != null && !requiredClass.isAssignableFrom(classObj)) {
Log.warn(Loader.class, "Class '" + className + "' found but not a " + Lib.classShortName(requiredClass));
return null;
}
return classObj;
}
use of org.apache.jena.sparql.ARQInternalErrorException in project jena by apache.
the class FmtUtils method checkValidPrefixName.
private static boolean checkValidPrefixName(String prefixedName) {
// Split it to get the parts.
int i = prefixedName.indexOf(':');
if (i < 0)
throw new ARQInternalErrorException("Broken short form -- " + prefixedName);
String p = prefixedName.substring(0, i);
String x = prefixedName.substring(i + 1);
// Check legality
if (checkValidPrefix(p) && checkValidLocalname(x))
return true;
return false;
}
use of org.apache.jena.sparql.ARQInternalErrorException in project jena by apache.
the class PathLib method existsPath.
private static int existsPath(Graph graph, Node subject, Path path, final Node object, ExecutionContext execCxt) {
if (!subject.isConcrete() || !object.isConcrete())
throw new ARQInternalErrorException("Non concrete node for existsPath evaluation");
Iterator<Node> iter = PathEval.eval(graph, subject, path, execCxt.getContext());
Predicate<Node> filter = node -> Objects.equals(node, object);
// See if we got to the node we're interested in finishing at.
iter = Iter.filter(iter, filter);
long x = Iter.count(iter);
return (int) x;
}
use of org.apache.jena.sparql.ARQInternalErrorException in project jena by apache.
the class FunctionBase method exec.
@Override
public NodeValue exec(Binding binding, ExprList args, String uri, FunctionEnv env) {
if (args == null)
// The contract on the function interface is that this should not happen.
throw new ARQInternalErrorException("FunctionBase: Null args list");
List<NodeValue> evalArgs = new ArrayList<>();
for (Expr e : args) {
NodeValue x = e.eval(binding, env);
evalArgs.add(x);
}
NodeValue nv = exec(evalArgs);
return nv;
}
Aggregations