public static TriplePatternImpl createObjectPattern(Resource resource, URI propertyURI) { return new TriplePatternImpl(resource, propertyURI, Variable.ANY, SPO.OBJECT); }
@Override public boolean matches(Statement statement) { boolean matchesSubject = statement.getSubject().equals(this.getSubject()) || this.getSubject() instanceof Variable; boolean matchesPredicate = statement.getPredicate().equals(this.getPredicate()) || this.getPredicate() instanceof Variable; boolean matchesObject = statement.getObject().equals(this.getObject()) || this.getObject() instanceof Variable; return matchesSubject && matchesPredicate && matchesObject; }
@Override public int hashCode() { return this.context.hashCode() + super.hashCode(); }
@Override public boolean matches(Statement statement) { boolean matchesContext = statement.getContext().equals(this.getContext()) || this.getContext() instanceof Variable; return matchesContext && super.matches(statement); }
/** * Get all instances of the class in the model. * * @param model - * the underlying RDF2Go class * @param javaClass - * the requested Java class * @return Array of the given javaClass type instances in the model */ @Patrolled public static Object[] getAllInstances(Model model, java.lang.Class<?> javaClass) { URI rdfsClass; try { rdfsClass = (URI) javaClass.getDeclaredField("RDFS_CLASS") .get(null); return triplepattern2reactor(model, TriplePatternImpl .createObjectPattern(RDF.type, rdfsClass), javaClass); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (SecurityException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (NoSuchFieldException e) { throw new RuntimeException(e); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public boolean matches(Statement statement) { boolean matchesContext = statement.getContext().equals(this.getContext()) || this.getContext() instanceof Variable; return matchesContext && super.matches(statement); }
/** * Get all values for the given resource and property. * * @param model - * the underlying RDF2Go model * @param resource - * URI or BlankNode of the resource * @param propertyURI - * URI of the property * @param returnType - * return the values typed as returnType * @return array of type 'returnType' with 0..n values. Never null. * @throws Exception */ @Patrolled public static Object[] getAllValues(Model model, Resource resource, URI propertyURI, java.lang.Class<?> returnType) { return triplepattern2reactor(model, TriplePatternImpl .createObjectPattern(resource, propertyURI), returnType); }
public boolean matches(Statement statement) { boolean matchesSubject = statement.getSubject().equals( this.getSubject()) || this.getSubject() instanceof Variable; boolean matchesPredicate = statement.getPredicate().equals( this.getPredicate()) || this.getPredicate() instanceof Variable; boolean matchesObject = statement.getObject().equals(this.getObject()) || this.getObject() instanceof Variable; return matchesSubject && matchesPredicate && matchesObject; }
@Override public TriplePattern createTriplePattern(ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object) { return new TriplePatternImpl(subject, predicate, object); }
@Override public int hashCode() { return this.context.hashCode() + super.hashCode(); }
@Override public boolean equals(Object o) { return ((o instanceof Statement) && (this.getSubject().equals(((Statement) o).getSubject())) && (this.getPredicate().equals(((Statement) o).getPredicate())) && (this .getObject().equals(((Statement) o).getObject()))); }
public static TriplePatternImpl createSubjectPattern(URI propertyURI, Node objectNode) { return new TriplePatternImpl(Variable.ANY, propertyURI, objectNode, SPO.SUBJECT); }
@Override public boolean equals(Object o) { return ((o instanceof Statement) && (this.getSubject().equals(((Statement)o).getSubject())) && (this.getPredicate().equals(((Statement)o).getPredicate())) && (this.getObject() .equals(((Statement)o).getObject()))); }
public static TriplePatternImpl createSubjectPattern(URI propertyURI, Node objectNode) { return new TriplePatternImpl(Variable.ANY, propertyURI, objectNode, SPO.SUBJECT); }
public ClosableIterator<T> asClosableIterator() { ClosableIterator<Statement> it = this.model.findStatements(this.triplePattern.getSubject(), this.triplePattern.getPredicate(), this.triplePattern.getObject() ); ProjectingIterator.projection proj = null; switch (this.triplePattern.extract) { case SUBJECT: proj = ProjectingIterator.projection.Subject; break; case PREDICATE: proj = ProjectingIterator.projection.Predicate; break; case OBJECT: proj = ProjectingIterator.projection.Object; break; } return new ConvertingClosableIterator<T>( new ProjectingIterator<Node>(it, proj), this.model, this.returnType); }
public TriplePattern createTriplePattern(ResourceOrVariable subject, UriOrVariable predicate, NodeOrVariable object) { return new TriplePatternImpl(subject, predicate, object); }
public static TriplePatternImpl createObjectPattern(Resource resource, URI propertyURI) { return new TriplePatternImpl(resource, propertyURI, Variable.ANY, SPO.OBJECT); }
public static <T> ReactorResult<T> getAllInstances_as(Model model, URI classURI, Class<T> returnType) { if(model == null) throw new IllegalArgumentException("model may not be null"); if(classURI == null) throw new IllegalArgumentException("classURI may not be null"); if(returnType == null) throw new IllegalArgumentException("returnType may not be null"); assertOpen(model); return new ReactorResult<T>(model, new TriplePatternImpl(Variable.ANY, RDF.type, classURI, TriplePatternImpl.SPO.SUBJECT), returnType); }
public static <T> ReactorResult<T> getAll_Inverse_as(Model model, URI propertyURI, Object value, Class<T> returnType) { if(model == null) throw new IllegalArgumentException("model may not be null"); if(value == null) throw new IllegalArgumentException("value may not be null"); if(propertyURI == null) throw new IllegalArgumentException("propertyURI may not be null"); if(returnType == null) throw new IllegalArgumentException("returnType may not be null"); assertOpen(model); Node node = RDFReactorRuntime.java2node(model, value); return new ReactorResult<T>(model, new TriplePatternImpl(Variable.ANY, propertyURI, node, TriplePatternImpl.SPO.SUBJECT), returnType); }
public static <T> ReactorResult<T> getAll_as(Model model, Resource resourceSubject, URI propertyURI, Class<T> returnType) { if(model == null) throw new IllegalArgumentException("model may not be null"); if(resourceSubject == null) throw new IllegalArgumentException("resourceSubject may not be null"); if(propertyURI == null) throw new IllegalArgumentException("propertyURI may not be null"); if(returnType == null) throw new IllegalArgumentException("returnType may not be null"); assertOpen(model); Resource rdfResource = RDFReactorRuntime.genericResource2RDF2Goresource(model, resourceSubject); return new ReactorResult<T>(model, new TriplePatternImpl(rdfResource, propertyURI, Variable.ANY, TriplePatternImpl.SPO.OBJECT), returnType); }