org.openrdf.model.Graph.contains()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(109)

本文整理了Java中org.openrdf.model.Graph.contains()方法的一些代码示例,展示了Graph.contains()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graph.contains()方法的具体详情如下:
包路径:org.openrdf.model.Graph
类名称:Graph
方法名:contains

Graph.contains介绍

[英]Checks if a statement matching the (subject, predicate, object) pattern is present in the graph.
[中]检查图中是否存在与(主语、谓语、宾语)模式匹配的语句。

代码示例

代码示例来源:origin: org.openrdf.sesame/sesame-repository-compliance-base

public void testGraphSerialization()
  throws Exception
{
  testCon.add(bob, name, nameBob);
  testCon.add(alice, name, nameAlice);
  Graph graph;
  RepositoryResult<Statement> statements = testCon.getStatements(null, null, null, true);
  try {
    graph = new GraphImpl(vf, statements.asList());
  }
  finally {
    statements.close();
  }
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  ObjectOutputStream out = new ObjectOutputStream(baos);
  out.writeObject(graph);
  out.close();
  ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
  ObjectInputStream in = new ObjectInputStream(bais);
  Graph deserializedGraph = (Graph)in.readObject();
  in.close();
  assertFalse(deserializedGraph.isEmpty());
  for (Statement st : deserializedGraph) {
    assertTrue(graph.contains(st));
    assertTrue(testCon.hasStatement(st, true));
  }
}

代码示例来源: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

/**
 * 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());
 }

相关文章