本文整理了Java中org.openrdf.model.Graph.match()
方法的一些代码示例,展示了Graph.match()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graph.match()
方法的具体详情如下:
包路径:org.openrdf.model.Graph
类名称:Graph
方法名:match
[英]Gets the statements with the specified subject, predicate, object and (optionally) context. The subject, predicate and object parameters can be null to indicate wildcards. The contexts parameter is a wildcard and accepts zero or more values. 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. Note: to match statements without an associated context, specify the value null and explicitly cast it to type Resource.
Examples: graph.match(s1, null, null) matches all statements that have subject s1,
graph.match(null, null, null, c1) matches all statements that have context c1,
graph.match(null, null, null, (Resource)null) matches all statements that have no associated context,
graph.match(null, null, null, c1, c2, c3) matches all statements that have context c1, c2 or c3.
[中]获取具有指定主语、谓语、宾语和(可选)上下文的语句。主语、谓语和宾语参数可以为null以表示通配符。contexts参数是一个通配符,接受零个或多个值。如果未指定上下文,则语句将不考虑上下文而匹配。如果指定了一个或多个上下文,则上下文与其中一个匹配的语句将匹配。注意:要匹配没有关联上下文的语句,请指定null值并显式将其强制转换为Resource类型。
例子:图表。match(s1,null,null)匹配所有主题为s1的语句,
图表match(null,null,null,c1)匹配具有上下文c1的所有语句,
图表match(null,null,null,(Resource)null)匹配没有关联上下文的所有语句,
图表match(null,null,null,c1,c2,c3)匹配具有上下文c1,c2或c3的所有语句。
代码示例来源:origin: it.tidalwave.bluebill/it-tidalwave-android-org-openrdf-sesame-model
/**
* 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, URI, Value, Resource[])} for a
* description of the parameter values.
*/
public static Iterator<Resource> getSubjectIterator(Graph graph, URI 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();
}
};
}
代码示例来源:origin: it.tidalwave.bluebill/it-tidalwave-android-org-openrdf-sesame-model
/**
* 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, URI, Value, Resource[])} for a
* description of the parameter values.
*/
public static Iterator<Value> getObjectIterator(Graph graph, Resource subj, URI 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();
}
};
}
代码示例来源:origin: blazegraph/database
/**
* Count matches of the triple pattern.
*/
static protected int countMatches(final Graph g, final Resource s,
final URI p, final Value o) {
int n = 0;
final Iterator<Statement> itr = g.match(s, p, o);
while (itr.hasNext()) {
itr.next();
n++;
}
return n;
}
代码示例来源:origin: org.openrdf.sesame/sesame-model
/**
* 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();
}
};
}
代码示例来源:origin: blazegraph/database
/**
* Return the statements matching the triple pattern.
*/
static protected Statement[] getMatches(final Graph g, final Resource s,
final URI p, final Value o) {
final List<Statement> out = new LinkedList<Statement>();
final Iterator<Statement> itr = g.match(s, p, o);
while (itr.hasNext()) {
out.add(itr.next());
}
return out.toArray(new Statement[out.size()]);
}
代码示例来源:origin: org.openrdf.sesame/sesame-model
/**
* 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();
}
};
}
代码示例来源:origin: it.tidalwave.bluebill/it-tidalwave-android-org-openrdf-sesame-model
/**
* 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.
*/
public static void setUniqueObject(Graph graph, Resource subj, URI 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);
}
代码示例来源:origin: org.apache.marmotta/sesame-tools-rio-jsonld
public void importGraph(Graph model, Resource... contexts) {
Iterator<Statement> statements = model.match(null, null, null, contexts);
while (statements.hasNext()) {
handleStatement(statements.next());
}
}
代码示例来源:origin: it.tidalwave.bluebill/it-tidalwave-android-org-openrdf-sesame-model
Iterator<Statement> statements = graph.match(subj, pred, obj, contexts);
while (statements.hasNext()) {
statements.next();
代码示例来源:origin: org.openrdf.sesame/sesame-model
/**
* 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);
}
代码示例来源:origin: org.openrdf.sesame/sesame-model
Iterator<Statement> statements = graph.match(subj, pred, obj, contexts);
while (statements.hasNext()) {
statements.next();
代码示例来源:origin: blazegraph/database
/**
* Count matches of the triple pattern.
*/
static protected int countMatches(final Graph g, final Resource s,
final URI p, final Value o) {
int n = 0;
final Iterator<Statement> itr = g.match(s, p, o);
while (itr.hasNext()) {
itr.next();
n++;
}
return n;
}
代码示例来源:origin: org.openrdf.mulgara/mulgara-resolver-core
Iterator<Statement> typeIter = graph.match(subject, rdfType, null);
代码示例来源:origin: blazegraph/database
/**
* Return the statements matching the triple pattern.
*/
static protected Statement[] getMatches(final Graph g, final Resource s,
final URI p, final Value o) {
final List<Statement> out = new LinkedList<Statement>();
final Iterator<Statement> itr = g.match(s, p, o);
while (itr.hasNext()) {
out.add(itr.next());
}
return out.toArray(new Statement[out.size()]);
}
代码示例来源:origin: org.openrdf.mulgara/mulgara-resolver-core
Iterator<Statement> subjectIter = graph.match(null, null, null);
代码示例来源:origin: org.openrdf.sesame/sesame-rio-api
Iterator<Statement> typeStatements = bufferedStatements.match(subject, RDF.TYPE, null, context);
while (typeStatements.hasNext()) {
Statement typeStatement = typeStatements.next();
Iterator<Statement> subjectStatements = bufferedStatements.match(subject, null, null, context);
while (subjectStatements.hasNext()) {
Statement subjectStatement = subjectStatements.next();
IRI predicate = subjectStatement.getPredicate();
if (!processedPredicates.contains(predicate)) {
Iterator<Statement> toWrite = bufferedStatements.match(subject, predicate, null, context);
while (toWrite.hasNext()) {
Statement toWriteSt = toWrite.next();
代码示例来源:origin: org.openrdf.mulgara/mulgara-resolver-core
Iterator<Statement> graphIter = graph.match(null, null, null);
代码示例来源:origin: org.openrdf.mulgara/mulgara-resolver-core
Iterator<Statement> tripleIter = graph.match(null, null, null);
代码示例来源:origin: blazegraph/database
assertTrue(g2.match(s, p, o).hasNext());
代码示例来源:origin: blazegraph/database
assertTrue(g2.match(s, p, o).hasNext());
内容来源于网络,如有侵权,请联系作者删除!