Search in sources :

Example 1 with ARQInternalErrorException

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);
}
Also used : ARQInternalErrorException(org.apache.jena.sparql.ARQInternalErrorException)

Example 2 with ARQInternalErrorException

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;
}
Also used : ARQInternalErrorException(org.apache.jena.sparql.ARQInternalErrorException)

Example 3 with ARQInternalErrorException

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;
}
Also used : ARQInternalErrorException(org.apache.jena.sparql.ARQInternalErrorException)

Example 4 with ARQInternalErrorException

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;
}
Also used : Context(org.apache.jena.sparql.util.Context) Binding(org.apache.jena.sparql.engine.binding.Binding) ARQInternalErrorException(org.apache.jena.sparql.ARQInternalErrorException) BasicPattern(org.apache.jena.sparql.core.BasicPattern) QueryIterConcat(org.apache.jena.sparql.engine.iterator.QueryIterConcat) TriplePath(org.apache.jena.sparql.core.TriplePath) OpPath(org.apache.jena.sparql.algebra.op.OpPath) OpSequence(org.apache.jena.sparql.algebra.op.OpSequence) Graph(org.apache.jena.graph.Graph) ArrayList(java.util.ArrayList) QueryIterator(org.apache.jena.sparql.engine.QueryIterator) QueryIterYieldN(org.apache.jena.sparql.engine.iterator.QueryIterYieldN) Op(org.apache.jena.sparql.algebra.Op) GraphUtils(org.apache.jena.sparql.util.graph.GraphUtils) Iter(org.apache.jena.atlas.iterator.Iter) ExecutionContext(org.apache.jena.sparql.engine.ExecutionContext) BindingFactory(org.apache.jena.sparql.engine.binding.BindingFactory) PathEval(org.apache.jena.sparql.path.eval.PathEval) Iterator(java.util.Iterator) Predicate(java.util.function.Predicate) Triple(org.apache.jena.graph.Triple) QueryIterPlainWrapper(org.apache.jena.sparql.engine.iterator.QueryIterPlainWrapper) PropertyFunctionFactory(org.apache.jena.sparql.pfunction.PropertyFunctionFactory) PathBlock(org.apache.jena.sparql.core.PathBlock) Objects(java.util.Objects) List(java.util.List) Explain(org.apache.jena.sparql.mgt.Explain) Var(org.apache.jena.sparql.core.Var) Node(org.apache.jena.graph.Node) OpBGP(org.apache.jena.sparql.algebra.op.OpBGP) PropertyFunctionRegistry(org.apache.jena.sparql.pfunction.PropertyFunctionRegistry) ARQInternalErrorException(org.apache.jena.sparql.ARQInternalErrorException) Node(org.apache.jena.graph.Node)

Example 5 with ARQInternalErrorException

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;
}
Also used : NodeValue(org.apache.jena.sparql.expr.NodeValue) Expr(org.apache.jena.sparql.expr.Expr) ARQInternalErrorException(org.apache.jena.sparql.ARQInternalErrorException) ArrayList(java.util.ArrayList)

Aggregations

ARQInternalErrorException (org.apache.jena.sparql.ARQInternalErrorException)34 Node (org.apache.jena.graph.Node)6 NodeValue (org.apache.jena.sparql.expr.NodeValue)6 ArrayList (java.util.ArrayList)5 Binding (org.apache.jena.sparql.engine.binding.Binding)5 Var (org.apache.jena.sparql.core.Var)4 BigDecimal (java.math.BigDecimal)3 BasicPattern (org.apache.jena.sparql.core.BasicPattern)3 ExprEvalException (org.apache.jena.sparql.expr.ExprEvalException)3 BigInteger (java.math.BigInteger)2 CmdException (jena.cmd.CmdException)2 TerminationException (jena.cmd.TerminationException)2 RDFDatatype (org.apache.jena.datatypes.RDFDatatype)2 Graph (org.apache.jena.graph.Graph)2 RDFNode (org.apache.jena.rdf.model.RDFNode)2 JenaException (org.apache.jena.shared.JenaException)2 TableEmpty (org.apache.jena.sparql.algebra.table.TableEmpty)2 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)2 QueryIterator (org.apache.jena.sparql.engine.QueryIterator)2 QueryIterPlainWrapper (org.apache.jena.sparql.engine.iterator.QueryIterPlainWrapper)2