/** Check a triple - assumes individual nodes are legal */ public boolean check(Triple triple, long line, long col) { return checkTriple(triple.getSubject(), triple.getPredicate(), triple.getObject(), line, col) ; }
@Override public Triple economize(Triple that) { return new Triple( e(that.getSubject()), e(that.getPredicate()), e(that.getObject()) ); }
private Triple rename(Triple t) { Node S = t.getSubject(), P = t.getPredicate(), O = t.getObject(); Node newS = rename(S), newP = rename(P), newO = rename(O); if (newS == S && newP == P && newO == O) return t; return Triple.create(newS, newP, newO); }
/** Answer true iff this triple can be compared for sameValueAs by .equals(), ie, it is a concrete triple with a non-literal object. */ protected final boolean isSafeForEquality( Triple t ) { return t.isConcrete() && !t.getObject().isLiteral(); } }
@Override public boolean accept(Triple t) { if (t.getSubject().isLiteral()) return true; if (t.getPredicate().isBlank() || t.getPredicate().isLiteral()) return true; return false; } } ) );
private Node getObject(Node subj, Node pred) { for( final Iterator<Triple> i = triples.iterator(); i.hasNext(); ) { Triple t = i.next(); if( subj.equals( t.getSubject() ) && pred.equals( t.getPredicate() ) ) { i.remove(); return t.getObject(); } } return null; }
/** * Defacto config and example data loading. */ @PostConstruct protected void init() { for (final FactBenchExample example : FactBenchExamplesLoader.loadExamples()) { examples.put(new JSONObject().put("fact", example.getFact()) .put("s", example.getTriple().getSubject().getURI()) .put("p", example.getTriple().getPredicate().getURI()) .put("o", example.getTriple().getObject().getURI())); } }
protected Set<String> getAllVariables(Triple t) { Set<String> ret = new HashSet<String>(); Node s = t.getSubject(); Node o = t.getObject(); if (s.isVariable()) { ret.add(s.getName()); } if (o.isVariable()) { ret.add(o.getName()); } return ret; }
public static long hashTriple(Triple t) { long result = 0; Node S = t.getSubject(), P = t.getPredicate(), O = t.getObject(); if (!S.isBlank()) result = (long) S.hashCode() << 32; if (!P.isBlank()) result ^= (long) P.hashCode() << 16; if (!O.isBlank()) result ^= (long) O.hashCode(); return result; }
@Override protected void check(Triple t) { if ( Var.isVar(getGraph()) ) throw new QueryParseException("Variables not permitted in data quad", -1, -1) ; if ( Var.isVar(t.getSubject()) || Var.isVar(t.getPredicate()) || Var.isVar(t.getObject())) throw new QueryParseException("Variables not permitted in data quad", -1, -1) ; if ( t.getSubject().isLiteral() ) throw new QueryParseException("Literals not allowed as subjects in data", -1, -1) ; }
@Override public boolean accept( Triple t) { if (t.getSubject().isLiteral()) return true; Node n = t.getObject(); return n.isLiteral() && n.getLiteralDatatype() == FunctorDatatype.theFunctorDatatype; } };
private static boolean isMagicProperty(PropertyFunctionRegistry registry, Triple pfTriple) { if ( ! pfTriple.getPredicate().isURI() ) return false ; if ( registry.manages(pfTriple.getPredicate().getURI()) ) return true ; return false ; }
/** * Validate a triple add to see if it should reinvoke the hook. If so * then the inference will be restarted at next prepare time. Incremental * re-processing is not yet supported but in this case would be useful. */ @Override public boolean needsRerun(FBRuleInfGraph infGraph, Triple t) { return (t.getPredicate().getURI().startsWith(memberPrefix)); }
@Override public boolean accept(Triple triple) { return triple.getPredicate().equals(subject) || triple.getPredicate().equals(predicate) || triple.getPredicate().equals(object) || ( triple.getPredicate().equals(rdfType) && triple.getObject().equals(statement) ) ; }} ;
/** * Return the triple pattern as a triple */ public Triple asTriple() { return new Triple(subject,predicate, object); }
private boolean hasObject(Node subj, Node pred) { for( final Iterator<Triple> i = triples.iterator(); i.hasNext(); ) { Triple t = i.next(); if( subj.equals( t.getSubject() ) && pred.equals( t.getPredicate() ) ) return true; } return false; }
protected static boolean equalsObjectOK( Triple t ) { Node o = t.getObject(); return o.isLiteral() ? o.getLiteralDatatype() == null : true; }
/** * Validate a triple add to see if it should reinvoke the hook. If so * then the inference will be restarted at next prepare time. Incremental * re-processing is not yet supported. */ @Override public boolean needsRerun(FBRuleInfGraph infGraph, Triple t) { return (t.getPredicate().equals(OWL.intersectionOf.asNode())); }