xdi2.core.Graph.containsStatement()方法的使用及代码示例

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

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

Graph.containsStatement介绍

[英]Check if a statement exists in this graph.
[中]检查此图中是否存在语句。

代码示例

代码示例来源:origin: projectdanube/xdi2

public void testMultipleReplacements() throws Exception {
  Graph graph1 = MemoryGraphFactory.getInstance().openGraph();
  Graph graph2 = MemoryGraphFactory.getInstance().openGraph();
  graph1.setStatement(XDIStatement.create("=a=b=c/+e/=f"));
  XDIArc from1 = XDIArc.create("=b");
  List<XDIAddress> to1 = new ArrayList<XDIAddress> ();
  to1.add(XDIAddress.create("=x"));
  to1.add(XDIAddress.create("=y"));
  XDIArc from2 = XDIArc.create("=f");
  List<XDIAddress> to2 = new ArrayList<XDIAddress> ();
  to2.add(XDIAddress.create("=m"));
  to2.add(XDIAddress.create("=n"));
  Map<XDIArc, Object> replacements = new HashMap<XDIArc, Object> ();
  replacements.put(from1, to1);
  replacements.put(from2, to2);
  CopyUtil.copyGraph(graph1, graph2, new ReplaceXDIAddressCopyStrategy(replacements));
  assertTrue(graph2.containsStatement(XDIStatement.create("=a=x=c/+e/=m")));
  assertTrue(graph2.containsStatement(XDIStatement.create("=a=x=c/+e/=n")));
  assertTrue(graph2.containsStatement(XDIStatement.create("=a=y=c/+e/=m")));
  assertTrue(graph2.containsStatement(XDIStatement.create("=a=y=c/+e/=n")));
  assertEquals(graph2.getAllStatementCount(), 11);
  graph1.close();
  graph2.close();
}

代码示例来源:origin: projectdanube/xdi2

if (operationResultGraph.containsStatement(refRepRelation.getStatement().getXDIStatement())) {

代码示例来源:origin: projectdanube/xdi2

public void testDelRelationDelInnerRoot() throws Exception {
  Graph graph33 = this.getGraphFactory().openGraph(this.getClass().getName() + "-graph-33");
  graph33.getRootContextNode().setContextNode(XDIArc.create("(=a/#b)"));
  assertEquals(graph33.getAllStatementCount(), 3);
  graph33.getRootContextNode().getContextNode(XDIArc.create("=a")).delRelations(XDIAddress.create("#b"));
  assertEquals(graph33.getAllStatementCount(), 1);
  assertFalse(graph33.containsStatement(XDIStatement.create("//(=a/#b)")));
  assertTrue(graph33.containsStatement(XDIStatement.create("//=a")));
  assertFalse(graph33.containsStatement(XDIStatement.create("=a/#b/(=a/#b)")));
  graph33.clear();
  graph33.getRootContextNode().setContextNode(XDIArc.create("(/#b)"));
  assertEquals(graph33.getAllStatementCount(), 2);
  graph33.getRootContextNode().delRelations(XDIAddress.create("#b"));
  assertEquals(graph33.getAllStatementCount(), 0);
  assertFalse(graph33.containsStatement(XDIStatement.create("//(/#b)")));
  assertFalse(graph33.containsStatement(XDIStatement.create("/#b/(/#b)")));
  graph33.clear();
  graph33.close();
}

代码示例来源:origin: projectdanube/xdi2

private static void assertEqualsGraphs(Graph graph1, Graph graph2) throws Exception {
  assertEquals(graph1.getRootContextNode().getAllStatementCount(), graph2.getRootContextNode().getAllStatementCount());
  assertEquals(graph1.getRootContextNode().getAllContextNodeCount(), graph2.getRootContextNode().getAllContextNodeCount());
  assertEquals(graph1.getRootContextNode().getAllRelationCount(), graph2.getRootContextNode().getAllRelationCount());
  assertEquals(graph1.getRootContextNode().getAllLiteralCount(), graph2.getRootContextNode().getAllLiteralCount());
  Iterator<Statement> s1 = graph1.getRootContextNode().getAllStatements();
  Iterator<Statement> s2 = graph2.getRootContextNode().getAllStatements();
  while (s1.hasNext()) { XDIStatement s = s1.next().getXDIStatement(); assertTrue(s.toString(), graph2.containsStatement(s)); }
  while (s2.hasNext()) { XDIStatement s = s2.next().getXDIStatement(); assertTrue(s.toString(), graph1.containsStatement(s)); }
  assertEquals(graph1, graph2);
}

代码示例来源:origin: projectdanube/xdi2

assertTrue(graph32.containsStatement(XDIStatement.create("//(=a/#b)")));
assertTrue(graph32.containsStatement(XDIStatement.create("//=a")));
assertTrue(graph32.containsStatement(XDIStatement.create("=a/#b/(=a/#b)")));
graph32.clear();
assertTrue(graph32.containsStatement(XDIStatement.create("//(=a/)")));
assertTrue(graph32.containsStatement(XDIStatement.create("//=a")));
graph32.clear();
assertTrue(graph32.containsStatement(XDIStatement.create("//(/#b)")));
assertTrue(graph32.containsStatement(XDIStatement.create("/#b/(/#b)")));
graph32.clear();
assertTrue(graph32.containsStatement(XDIStatement.create("//(/)")));
graph32.clear();
assertTrue(graph32.containsStatement(XDIStatement.create("//(=a)")));
graph32.clear();
assertTrue(graph32.containsStatement(XDIStatement.create("//()")));
graph32.clear();

代码示例来源:origin: projectdanube/xdi2

assertNotNull(graph22.getDeepContextNode(XDIAddress.create("=markus<#email>")).getLiteralNode("markus@projectdanube.org"));
assertTrue(graph22.containsStatement(XDIStatement.create("=neustar//=les")));
assertTrue(graph22.containsStatement(XDIStatement.create("=markus/#friend/=neustar=les")));
assertTrue(graph22.containsStatement(XDIStatement.create("=markus<#email>/&/\"markus@projectdanube.org\"")));
assertEquals(graph22.getStatement(XDIStatement.create("=neustar//=les")).getXDIStatement(), XDIStatement.create("=neustar//=les"));
assertEquals(graph22.getStatement(XDIStatement.create("=markus/#friend/=neustar=les")).getXDIStatement(), "=markus/#friend/=neustar=les");
assertNotNull(graph23.getDeepContextNode(XDIAddress.create("=markus<#email>")).getLiteralNode("markus@projectdanube.org"));
assertTrue(graph23.containsStatement(XDIStatement.create("=neustar//=les")));
assertTrue(graph23.containsStatement(XDIStatement.create("=markus/#friend/=neustar=les")));
assertTrue(graph23.containsStatement(XDIStatement.create("=markus<#email>/&/\"markus@projectdanube.org\"")));
assertEquals(graph23.getStatement(XDIStatement.create("=neustar//=les")).getXDIStatement(), XDIStatement.create("=neustar//=les"));
assertEquals(graph23.getStatement(XDIStatement.create("=markus/#friend/=neustar=les")).getXDIStatement(), "=markus/#friend/=neustar=les");

相关文章