private Set<ModelStatement> choose(Resource subj, IRI pred, Value obj, Resource... contexts) { contexts = notNull(contexts); Set<ModelStatement> s = null; Set<ModelStatement> p = null; Set<ModelStatement> o = null; if (subj != null) { if (!values.containsKey(subj)) return Collections.emptySet(); s = values.get(subj).subjects; } if (pred != null) { if (!values.containsKey(pred)) return Collections.emptySet(); p = values.get(pred).predicates; } if (obj != null) { if (!values.containsKey(obj)) return Collections.emptySet(); o = values.get(obj).objects; } if (contexts.length == 1) { if (!values.containsKey(contexts[0])) return Collections.emptySet(); Set<ModelStatement> c = values.get(contexts[0]).contexts; return smallest(statements, s, p, o, c); } else { return smallest(statements, s, p, o); } }
private Set<ModelStatement> choose(Value subj, Value pred, Value obj, Value... contexts) { contexts = notNull(contexts); Set<ModelStatement> s = null; Set<ModelStatement> p = null; Set<ModelStatement> o = null; if (subj != null) { if (!values.containsKey(subj)) return Collections.emptySet(); s = values.get(subj).subjects; } if (pred != null) { if (!values.containsKey(pred)) return Collections.emptySet(); p = values.get(pred).predicates; } if (obj != null) { if (!values.containsKey(obj)) return Collections.emptySet(); o = values.get(obj).objects; } if (contexts.length == 1) { if (!values.containsKey(contexts[0])) return Collections.emptySet(); Set<ModelStatement> c = values.get(contexts[0]).contexts; return smallest(statements, s, p, o, c); } else { return smallest(statements, s, p, o); } }
public boolean add(Resource subj, URI pred, Value obj, Resource... contexts) { if (subj == null || pred == null || obj == null) throw new UnsupportedOperationException("Incomplete statement"); Value[] ctxs = notNull(contexts); if (ctxs.length == 0) { ctxs = NULL_CTX; } boolean changed = false; for (Value ctx : ctxs) { ModelNode<Resource> s = asNode(subj); ModelNode<URI> p = asNode(pred); ModelNode<Value> o = asNode(obj); ModelNode<Resource> c = asNode((Resource) ctx); ModelStatement st = new ModelStatement(s, p, o, c); changed |= addModelStatement(st); } return changed; }
@Override public boolean add(Resource subj, IRI pred, Value obj, Resource... contexts) { if (subj == null || pred == null || obj == null) throw new UnsupportedOperationException("Incomplete statement"); Value[] ctxs = notNull(contexts); if (ctxs.length == 0) { ctxs = NULL_CTX; } boolean changed = false; for (Value ctx : ctxs) { ModelNode<Resource> s = asNode(subj); ModelNode<IRI> p = asNode(pred); ModelNode<Value> o = asNode(obj); ModelNode<Resource> c = asNode((Resource)ctx); ModelStatement st = new ModelStatement(s, p, o, c); changed |= addModelStatement(st); } return changed; }