Search in sources :

Example 61 with Item

use of org.apache.jena.sparql.sse.Item in project jena by apache.

the class StatsMatcher method onePattern.

private void onePattern(Item elt) {
    Item pat = elt.getList().get(0);
    if (pat.isNode()) {
        // (<uri> weight)
        Node n = pat.getNode();
        if (!n.isURI()) {
            log.warn("Not a preicate URI: " + pat.toString());
            return;
        }
        addAbbreviation(elt);
    } else if (pat.isSymbol()) {
        if (pat.equals(OTHER)) {
            double d = elt.getList().get(1).getDouble();
            DefaultMatch = d;
            return;
        }
        if (pat.equals(BNODE) || pat.equals(LITERAL)) {
            log.warn("Not a match for a predicate URI: " + pat.toString());
            return;
        }
        if (pat.equals(TERM) || pat.equals(VAR) || pat.equals(ANY))
            addAbbreviation(elt);
        else {
            log.warn("Not understood: " + pat);
            return;
        }
    } else if (pat.isList() && pat.getList().size() == 3) {
        // It's of the form ((S P O) weight)
        Item w = elt.getList().get(1);
        Pattern pattern = new Pattern(((Number) (w.getNode().getLiteralValue())).doubleValue(), intern(pat.getList().get(0)), intern(pat.getList().get(1)), intern(pat.getList().get(2)));
        addPattern(pattern);
    } else {
        log.warn("Unrecognized pattern: " + pat);
    }
}
Also used : Item(org.apache.jena.sparql.sse.Item) Node(org.apache.jena.graph.Node)

Example 62 with Item

use of org.apache.jena.sparql.sse.Item in project jena by apache.

the class StatsMatcher method addAbbreviation.

private void addAbbreviation(Item elt) {
    Item predicateTerm = elt.getList().get(0);
    // Single node - it's a predicate abbreviate.
    double numProp = elt.getList().get(1).getDouble();
    if (count < 100)
        addPatternsSmall(predicateTerm, numProp);
    else
        addPatterns(predicateTerm, numProp);
}
Also used : Item(org.apache.jena.sparql.sse.Item)

Example 63 with Item

use of org.apache.jena.sparql.sse.Item in project jena by apache.

the class ParseHandlerResolver method emitPName.

@Override
public void emitPName(int line, int column, String pname) {
    if (inFormDecl()) {
        // Record a faked PName.  Works with BuilderPrefixMapping
        Item item = Item.createSymbol(pname, line, column);
        listAdd(item);
        return;
    }
    String iriStr = resolvePrefixedName(pname, line, column);
    super.emitIRI(line, column, iriStr);
}
Also used : Item(org.apache.jena.sparql.sse.Item)

Example 64 with Item

use of org.apache.jena.sparql.sse.Item in project jena by apache.

the class BuilderPath method build.

private Path build(ItemList list) {
    Item head = list.get(0);
    if (!head.isSymbol())
        return build(head);
    String tag = head.getSymbol();
    Build bob = findBuild(tag);
    if (bob != null)
        return bob.make(list);
    else
        BuilderLib.broken(head, "Unrecognized path operation: " + tag);
    return null;
}
Also used : Item(org.apache.jena.sparql.sse.Item)

Example 65 with Item

use of org.apache.jena.sparql.sse.Item in project jena by apache.

the class BuilderExpr method buildExprListUntagged.

private static ExprList buildExprListUntagged(ItemList list, int idx) {
    ExprList exprList = new ExprList();
    for (int i = idx; i < list.size(); i++) {
        Item item = list.get(i);
        exprList.add(buildExpr(item));
    }
    return exprList;
}
Also used : Item(org.apache.jena.sparql.sse.Item) VarExprList(org.apache.jena.sparql.core.VarExprList)

Aggregations

Item (org.apache.jena.sparql.sse.Item)78 Test (org.junit.Test)31 Node (org.apache.jena.graph.Node)11 ItemList (org.apache.jena.sparql.sse.ItemList)10 Var (org.apache.jena.sparql.core.Var)6 ArrayList (java.util.ArrayList)5 Binding (org.apache.jena.sparql.engine.binding.Binding)3 Graph (org.apache.jena.graph.Graph)2 Triple (org.apache.jena.graph.Triple)2 ARQException (org.apache.jena.sparql.ARQException)2 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)2 VarExprList (org.apache.jena.sparql.core.VarExprList)2 ItemException (org.apache.jena.sparql.sse.ItemException)2 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)1 RDFDatatype (org.apache.jena.datatypes.RDFDatatype)1 QueryParseException (org.apache.jena.query.QueryParseException)1 ResultSetRewindable (org.apache.jena.query.ResultSetRewindable)1 Model (org.apache.jena.rdf.model.Model)1 ARQInternalErrorException (org.apache.jena.sparql.ARQInternalErrorException)1 Table (org.apache.jena.sparql.algebra.Table)1