本文整理了Java中org.openrdf.model.Graph
类的一些代码示例,展示了Graph
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graph
类的具体详情如下:
包路径:org.openrdf.model.Graph
类名称:Graph
[英]An RDF graph, represented as a collection of Statements.
[中]一种RDF图,表示为一组语句。
代码示例来源:origin: com.blazegraph/bigdata-core
/**
* Describe the service end point(s).
*
* @see #endpoint
*/
protected void describeServiceEndpoints() {
for (String uri : serviceURI) {
g.add(aService, SD.endpoint, g.getValueFactory().createURI(uri));
}
}
代码示例来源: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.openrdf.sesame/sesame-rio-api
@Override
public void handleStatement(Statement st)
throws RDFHandlerException
{
synchronized (bufferLock) {
bufferedStatements.add(st);
contexts.add(st.getContext());
if (bufferedStatements.size() >= this.bufferSize) {
processBuffer();
}
}
}
代码示例来源:origin: blazegraph/database
/**
* Describe the supported Query Languages
*/
protected void describeLanguages() {
g.add(aService, SD.supportedLanguage, SD.SPARQL10Query);
g.add(aService, SD.supportedLanguage, SD.SPARQL11Query);
g.add(aService, SD.supportedLanguage, SD.SPARQL11Update);
}
代码示例来源:origin: blazegraph/database
final Literal o = getVeryLargeLiteral();
final Statement stmt = new StatementImpl(s, p, o);
g.add(stmt);
assertEquals(1, g2.size());
assertTrue(g2.match(s, p, o).hasNext());
代码示例来源:origin: apache/attic-polygene-java
public SerializerContext( Graph graph )
{
this.valueFactory = graph.getValueFactory();
this.graph = graph;
}
代码示例来源: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: org.openrdf/sesame
ValueFactory factory = graph.getValueFactory();
StatementIterator sti = graph.getStatements(null,resRdfType,resUser);
while ( sti.hasNext() ) {
Resource resCUser = sti.next().getSubject();
int id = Integer.parseInt(
graph.getStatements(resCUser,proId,null).next().getObject().toString());
User user = new UserImpl(id,"","","");
StatementIterator rui = graph.getStatements(resCUser,proHasRule,null);
Set rulzSet = new HashSet();
while (rui.hasNext()){
if ( null == rule ) {
rule = new RuleImpl(
Integer.parseInt(graph.getStatements(rul,proId,null)
.next().getObject().toString())
,"","");
= graph.getStatements(resCUser,proHasRole,null);
Set rolzSet = new HashSet();
while (roi.hasNext()){
if ( null == role ) {
role = new RoleImpl(
Integer.parseInt(graph.getStatements(rol,proId,null).next().
getObject().toString())
,"","");
代码示例来源: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();
bufferedStatements.clear();
contexts.clear();
代码示例来源:origin: blazegraph/database
/**
* Compare two graphs for equality.
* <p>
* Note: This is not very efficient if the {@link Graph} implementations are
* not indexed.
* <p>
* Note: This does not handle equality testing with blank nodes (it does not
* test for isomorphic graphs).
*
* @param expected
* @param actual
*/
static protected void assertSameGraph(final Graph expected, final Graph actual) {
for (Statement s : expected) {
if (!actual.contains(s))
fail("Expecting: " + s);
}
assertEquals("size", expected.size(), actual.size());
}
代码示例来源:origin: it.unibz.inf.ontop/ontop-obdalib-r2rml
/**
* call this method if you need the RDF Graph
* that represents the R2RML mappings
* @return an RDF Graph
*/
@Deprecated
public Graph getGraph() {
OBDAMappingTransformer transformer = new OBDAMappingTransformer();
transformer.setOntology(ontology);
List<Statement> statements = new ArrayList<Statement>();
for (OBDAMappingAxiom axiom: this.mappings) {
List<Statement> statements2 = transformer.getStatements(axiom,prefixmng);
statements.addAll(statements2);
}
@SuppressWarnings("deprecation")
Graph g = new GraphImpl();
g.addAll(statements);
return g;
}
代码示例来源:origin: com.blazegraph/bigdata-core
case DESCRIBE:
case CONSTRUCT:
nresults = buildGraph(conn).size();
break;
case ASK: // I think that there are some alternative mime types for ask...
代码示例来源:origin: org.openrdf.sesame/sesame-query
@Override
public void handleStatement(Statement st)
throws RDFHandlerException
{
graph.add(st);
}
代码示例来源:origin: blazegraph/database
final Literal o = getVeryLargeLiteral();
final Statement stmt = new StatementImpl(s, p, o);
g.add(stmt);
assertEquals(1, g2.size());
assertTrue(g2.match(s, p, o).hasNext());
代码示例来源:origin: org.qi4j.library/org.qi4j.library.rdf
public SerializerContext( Graph graph )
{
this.valueFactory = graph.getValueFactory();
this.graph = graph;
}
代码示例来源: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
/**
* Compare two graphs for equality.
* <p>
* Note: This is not very efficient if the {@link Graph} implementations are
* not indexed.
* <p>
* Note: This does not handle equality testing with blank nodes (it does not
* test for isomorphic graphs).
*
* @param expected
* @param actual
*/
static protected void assertSameGraph(final Graph expected, final Graph actual) {
for (Statement s : expected) {
if (!actual.contains(s))
fail("Expecting: " + s);
}
assertEquals("size", expected.size(), actual.size());
}
代码示例来源:origin: blazegraph/database
g.addAll(rdfHandler.getStatements());
代码示例来源:origin: blazegraph/database
case DESCRIBE:
case CONSTRUCT:
nresults = buildGraph(conn).size();
break;
case ASK: // I think that there are some alternative mime types for ask...
代码示例来源:origin: blazegraph/database
/**
* Describe the service end point(s).
*
* @see #endpoint
*/
protected void describeServiceEndpoints() {
for (String uri : serviceURI) {
g.add(aService, SD.endpoint, g.getValueFactory().createURI(uri));
}
}
内容来源于网络,如有侵权,请联系作者删除!