@Override protected final void removeIteration(Iterator<Statement> iter, Resource s, URI p, Value o, Resource... c) { if (s == null) { s = (Resource) subj; } if (p == null) { p = (URI) pred; } if (o == null) { o = obj; } if (c != null && c.length == 0) { c = cast(contexts); } if (!accept(s, p, o, c)) { throw new IllegalStateException(); } removeFilteredIteration(iter, s, p, o, c); }
@Override public int size() { Iterator<Statement> iter = iterator(); try { int size = 0; while (iter.hasNext()) { size++; iter.next(); } return size; } finally { closeIterator(iter); } }
private boolean accept(Value s, Value p, Value o, Value... c) { if (subj != null && !subj.equals(s)) { return false; } if (pred != null && !pred.equals(p)) { return false; } if (obj != null && !obj.equals(o)) { return false; } if (!matches(notNull(c), contexts)) { return false; } return (s == null || s instanceof Resource) && (p == null || p instanceof URI); }
@Override public final void removeTermIteration(Iterator<Statement> iter, Resource s, IRI p, Value o, Resource... c) { if (s == null) { s = subj; } if (p == null) { p = pred; } if (o == null) { o = obj; } if (c != null && c.length == 0) { c = contexts; } if (!accept(s, p, o, c)) { throw new IllegalStateException(); } removeFilteredTermIteration(iter, s, p, o, c); }
public boolean remove(Value s, Value p, Value o, Value... c) { if (s == null) { s = subj; } if (p == null) { p = pred; } if (o == null) { o = obj; } if (c != null && c.length == 0) { c = contexts; } if (!accept(s, p, o, c)) { return false; } return model.remove(s, p, o, c); }
public boolean add(Resource s, URI p, Value o, Resource... c) { if (s == null) { s = (Resource) subj; } if (p == null) { p = (URI) pred; } if (o == null) { o = obj; } if (c != null && c.length == 0) { c = cast(contexts); } if (!accept(s, p, o, c)) { throw new IllegalArgumentException( "Statement is filtered out of view"); } return model.add(s, p, o, c); }
private boolean matches(Value[] stContext, Value... contexts) { if (stContext != null && stContext.length > 0) { for (Value c : stContext) { if (!matches(c, contexts)) { return false; } } } return true; }
public FilteredModel(AbstractModel model, Value subj, Value pred, Value obj, Value... contexts) { this.model = model; this.subj = subj; this.pred = pred; this.obj = obj; this.contexts = notNull(contexts); }
@Override public int size() { if (subj == null && pred == null && obj == null) { try { return (int) con.size(cast(contexts)); } catch (RepositoryException e) { throw new ModelException(e); } } return super.size(); }
@Override public boolean remove(Resource s, IRI p, Value o, Resource... c) { if (s == null) { s = subj; } if (p == null) { p = pred; } if (o == null) { o = obj; } if (c != null && c.length == 0) { c = contexts; } if (!accept(s, p, o, c)) { return false; } return model.remove(s, p, o, c); }
private boolean matches(Resource[] stContext, Resource... contexts) { OpenRDFUtil.verifyContextNotNull(stContext); if (stContext != null && stContext.length > 0) { for (Resource c : stContext) { if (!matches(c, contexts)) { return false; } } } return true; }
private boolean matches(Value stContext, Value... contexts) { if (contexts != null && contexts.length == 0) { // Any context matches return stContext == null || stContext instanceof Resource; } else { // Accept if one of the contexts from the pattern matches for (Value context : notNull(contexts)) { if (context == null && stContext == null) { return true; } if (context != null && context.equals(stContext)) { return true; } } return false; } }
@Override public int size() { Iterator<Statement> iter = iterator(); try { int size = 0; while (iter.hasNext()) { size++; iter.next(); } return size; } finally { closeIterator(iter); } }
public boolean contains(Value s, Value p, Value o, Value... c) { if (s == null) { s = subj; } if (p == null) { p = pred; } if (o == null) { o = obj; } if (c != null && c.length == 0) { c = contexts; } if (!accept(s, p, o, c)) { return false; } return model.contains(s, p, o, c); }
private boolean accept(Resource s, IRI p, Value o, Resource... c) { if (subj != null && !subj.equals(s)) { return false; } if (pred != null && !pred.equals(p)) { return false; } if (obj != null && !obj.equals(o)) { return false; } if (!matches(c, contexts)) { return false; } return (s == null || s instanceof Resource) && (p == null || p instanceof IRI); }
@Override public boolean contains(Resource s, IRI p, Value o, Resource... c) { if (s == null) { s = subj; } if (p == null) { p = pred; } if (o == null) { o = obj; } if (c != null && c.length == 0) { c = contexts; } if (!accept(s, p, o, c)) { return false; } return model.contains(s, p, o, c); }
@Override public boolean add(Resource s, IRI p, Value o, Resource... c) { if (s == null) { s = subj; } if (p == null) { p = pred; } if (o == null) { o = obj; } if (c != null && c.length == 0) { c = contexts; } if (!accept(s, p, o, c)) { throw new IllegalArgumentException("Statement is filtered out of view"); } return model.add(s, p, o, c); }
public Model filter(Value s, Value p, Value o, Value... c) { if (s == null) { s = subj; } if (p == null) { p = pred; } if (o == null) { o = obj; } if (c != null && c.length == 0) { c = contexts; } if (!accept(s, p, o, c)) { return new EmptyModel(model); } return model.filter(s, p, o, c); }
@Override public Model filter(Resource s, IRI p, Value o, Resource... c) { if (s == null) { s = subj; } if (p == null) { p = pred; } if (o == null) { o = obj; } if (c != null && c.length == 0) { c = contexts; } if (!accept(s, p, o, c)) { return new EmptyModel(model); } return model.filter(s, p, o, c); }