/** * Gets the objects of the statements with the specified subject, predicate and (optionally) contexts from * the supplied graph. Calling this method is equivalent to calling * <tt>graph.match(subj, pred, null, contexts)</tt> and extracting the objects of the matching statements * from the returned iterator. See {@link Graph#match(Resource, IRI, Value, Resource[])} for a description * of the parameter values. * * @deprecated since 2.8.0. Use {@link Model#filter(Resource, IRI, Value, Resource...)} and * {@link Model#objects()} instead. */ @Deprecated public static Iterator<Value> getObjectIterator(Graph graph, Resource subj, IRI pred, Resource... contexts) { Iterator<Statement> iter = graph.match(subj, pred, null, contexts); return new ConvertingIterator<Statement, Value>(iter) { @Override protected Value convert(Statement st) throws RuntimeException { return st.getObject(); } }; }
/** * Gets the objects of the statements with the specified subject, predicate and (optionally) contexts from * the supplied graph. Calling this method is equivalent to calling * <tt>graph.match(subj, pred, null, contexts)</tt> and extracting the objects of the matching statements * from the returned iterator. See {@link Graph#match(Resource, IRI, Value, Resource[])} for a description * of the parameter values. * * @deprecated since 2.8.0. Use {@link Model#filter(Resource, IRI, Value, Resource...)} and * {@link Model#objects()} instead. */ @Deprecated public static Iterator<Value> getObjectIterator(Graph graph, Resource subj, IRI pred, Resource... contexts) { Iterator<Statement> iter = graph.match(subj, pred, null, contexts); return new ConvertingIterator<Statement, Value>(iter) { @Override protected Value convert(Statement st) throws RuntimeException { return st.getObject(); } }; }
/** * Gets the subject of the statements with the specified predicate, object and (optionally) contexts from * the supplied graph. Calling this method is equivalent to calling * <tt>graph.match(null, pred, obj, contexts)</tt> and extracting the subjects of the matching statements * from the returned iterator. See {@link Graph#match(Resource, IRI, Value, Resource[])} for a description * of the parameter values. * * @deprecated since 2.8.0. Use {@link Model#filter(Resource, IRI, Value, Resource...)} and * {@link Model#subjects()} instead. */ @Deprecated public static Iterator<Resource> getSubjectIterator(Graph graph, IRI pred, Value obj, Resource... contexts) { Iterator<Statement> iter = graph.match(null, pred, obj, contexts); return new ConvertingIterator<Statement, Resource>(iter) { @Override protected Resource convert(Statement st) throws RuntimeException { return st.getSubject(); } }; }
/** * Gets the subject of the statements with the specified predicate, object and (optionally) contexts from * the supplied graph. Calling this method is equivalent to calling * <tt>graph.match(null, pred, obj, contexts)</tt> and extracting the subjects of the matching statements * from the returned iterator. See {@link Graph#match(Resource, IRI, Value, Resource[])} for a description * of the parameter values. * * @deprecated since 2.8.0. Use {@link Model#filter(Resource, IRI, Value, Resource...)} and * {@link Model#subjects()} instead. */ @Deprecated public static Iterator<Resource> getSubjectIterator(Graph graph, IRI pred, Value obj, Resource... contexts) { Iterator<Statement> iter = graph.match(null, pred, obj, contexts); return new ConvertingIterator<Statement, Resource>(iter) { @Override protected Resource convert(Statement st) throws RuntimeException { return st.getSubject(); } }; }
/** * Utility method that removes all statements matching the specified criteria from a graph. * * @param graph * The graph to remove the statements from. * @param subj * The subject of the statements to match, <tt>null</tt> to match statements with any subject. * @param pred * The predicate of the statements to match, <tt>null</tt> to match statements with any predicate. * @param obj * The object of the statements to match, <tt>null</tt> to match statements with any object. * @param contexts * The contexts of the statements to match. If no contexts are specified, statements will match * disregarding their context. If one or more contexts are specified, statements with a context * matching one of these will match. * @throws IllegalArgumentException * If a <tt>null</tt>-array is specified as the value for <tt>contexts</tt>. See * {@link OpenRDFUtil#verifyContextNotNull(Resource[])} for more info. * @deprecated since 2.8.0. Use {@link Model#remove(Resource, IRI, Value, Resource...) } instead. */ @Deprecated public static void remove(Graph graph, Resource subj, IRI pred, Value obj, Resource... contexts) { Iterator<Statement> statements = graph.match(subj, pred, obj, contexts); while (statements.hasNext()) { statements.next(); statements.remove(); } } }
/** * Utility method that removes all statements matching the specified criteria from a graph. * * @param graph * The graph to remove the statements from. * @param subj * The subject of the statements to match, <tt>null</tt> to match statements with any subject. * @param pred * The predicate of the statements to match, <tt>null</tt> to match statements with any predicate. * @param obj * The object of the statements to match, <tt>null</tt> to match statements with any object. * @param contexts * The contexts of the statements to match. If no contexts are specified, statements will match * disregarding their context. If one or more contexts are specified, statements with a context * matching one of these will match. * @throws IllegalArgumentException * If a <tt>null</tt>-array is specified as the value for <tt>contexts</tt>. See * {@link OpenRDFUtil#verifyContextNotNull(Resource[])} for more info. * @deprecated since 2.8.0. Use {@link Model#remove(Resource, IRI, Value, Resource...) } instead. */ @Deprecated public static void remove(Graph graph, Resource subj, IRI pred, Value obj, Resource... contexts) { Iterator<Statement> statements = graph.match(subj, pred, obj, contexts); while (statements.hasNext()) { statements.next(); statements.remove(); } } }
/** * Adds the specified statement and makes sure that no other statements are present in the Graph with the * same subject and predicate. When contexts are specified, the (subj, pred) pair will occur exactly once * in each context, else the (subj, pred) pair will occur exactly once in the entire Graph. * * @deprecated since 2.8.0. Use {@link Models#setProperty(Model, Resource, IRI, Value, Resource...) } * instead. */ @Deprecated public static void setUniqueObject(Graph graph, Resource subj, IRI pred, Value obj, Resource... contexts) { Iterator<Statement> iter = graph.match(subj, pred, null, contexts); while (iter.hasNext()) { iter.next(); iter.remove(); } graph.add(subj, pred, obj, contexts); }
/** * Adds the specified statement and makes sure that no other statements are present in the Graph with the * same subject and predicate. When contexts are specified, the (subj, pred) pair will occur exactly once * in each context, else the (subj, pred) pair will occur exactly once in the entire Graph. * * @deprecated since 2.8.0. Use {@link Models#setProperty(Model, Resource, IRI, Value, Resource...) } * instead. */ @Deprecated public static void setUniqueObject(Graph graph, Resource subj, IRI pred, Value obj, Resource... contexts) { Iterator<Statement> iter = graph.match(subj, pred, null, contexts); while (iter.hasNext()) { iter.next(); iter.remove(); } graph.add(subj, pred, obj, contexts); }
Iterator<Statement> typeStatements = bufferedStatements.match(subject, RDF.TYPE, null, context); while (typeStatements.hasNext()) { Iterator<Statement> subjectStatements = bufferedStatements.match(subject, null, null, context); while (subjectStatements.hasNext()) { IRI predicate = subjectStatement.getPredicate(); if (!processedPredicates.contains(predicate)) { Iterator<Statement> toWrite = bufferedStatements.match(subject, predicate, null, context); while (toWrite.hasNext()) {
Iterator<Statement> typeStatements = bufferedStatements.match(subject, RDF.TYPE, null, context); while (typeStatements.hasNext()) { Iterator<Statement> subjectStatements = bufferedStatements.match(subject, null, null, context); while (subjectStatements.hasNext()) { IRI predicate = subjectStatement.getPredicate(); if (!processedPredicates.contains(predicate)) { Iterator<Statement> toWrite = bufferedStatements.match(subject, predicate, null, context); while (toWrite.hasNext()) {
Iterator<Statement> typeStatements = bufferedStatements.match(subject, RDF.TYPE, null, context); while (typeStatements.hasNext()) { Iterator<Statement> subjectStatements = bufferedStatements.match(subject, null, null, context); while (subjectStatements.hasNext()) { IRI predicate = subjectStatement.getPredicate(); if (!processedPredicates.contains(predicate)) { Iterator<Statement> toWrite = bufferedStatements.match(subject, predicate, null, context); while (toWrite.hasNext()) {