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

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

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

Graph.clear介绍

[英]Clears all data from the graph. This is equivalent to calling getRootContextNode().clear();
[中]清除图形中的所有数据。这相当于调用getRootContextNode()。清除();

代码示例

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

private synchronized void read(Graph graph, byte[] byteArray) throws Xdi2ParseException {
  for (XDIReader xdiReader : readers) {
    if (xdiReader instanceof AutoReader) continue;
    try {
      graph.clear();
      xdiReader.read(graph, new ByteArrayInputStream(byteArray));
      this.lastSuccessfulReader = xdiReader;
      return;
    } catch(Exception ex) {
      continue;
    }
  }
  this.lastSuccessfulReader = null;
  throw new Xdi2ParseException("Unknown serialization format.");
}

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

private synchronized void read(Graph graph, String string) throws Xdi2ParseException {
  for (XDIReader xdiReader : readers) {
    if (xdiReader instanceof AutoReader) continue;
    try {
      graph.clear();
      xdiReader.read(graph, new StringReader(string));
      this.lastSuccessfulReader = xdiReader;
      return;
    } catch(Exception ex) {
      continue;
    }
  }
  this.lastSuccessfulReader = null;
  throw new Xdi2ParseException("Unknown serialization format.");
}

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

private void readGraph(ExecutionContext executionContext) throws Xdi2MessagingException {
  XDIReader xdiReader = XDIReaderRegistry.forFormat(this.mimeType, null);
  if (xdiReader == null) throw new Xdi2MessagingException("Cannot read this format: " + this.mimeType, null, executionContext);
  Graph graph = this.getGraph();
  graph.clear();
  FileReader reader = null;
  try {
    File file = new File(this.path);
    reader = new FileReader(file);
    xdiReader.read(graph, reader);
    reader.close();
  } catch (FileNotFoundException ex) {
  } catch (Exception ex) {
    throw new Xdi2MessagingException("Cannot read file: " + ex.getMessage(), ex, executionContext);
  } finally {
    if (reader != null) {
      try {
        reader.close();
      } catch (Exception ex) { }
    }
  }
  if (xdiReader instanceof AutoReader) this.mimeType = ((AutoReader) xdiReader).getLastSuccessfulReader().getFormat();
  if (this.mimeType == null) this.mimeType = XDIWriterRegistry.getDefault().getFormat();
}

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

graph.clear();
  xdiReader.read(graph, new StringReader(graphstring));
} catch (Xdi2ParseException ex) {

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

XDIWriterRegistry.forFormat("XDI/JSON", null).write(graph10, buffer1);
XDIWriterRegistry.forFormat("XDI DISPLAY", null).write(graph11, buffer2);
graph10.clear();
graph11.clear();
XDIReaderRegistry.forFormat("XDI/JSON", null).read(graph10, new StringReader(buffer1.toString()));
XDIReaderRegistry.forFormat("XDI DISPLAY", null).read(graph11, new StringReader(buffer2.toString()));

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

@Override
public void executeDelOnAddress(XDIAddress targetXDIAddress, DelOperation operation, Graph operationResultGraph, ExecutionContext executionContext) throws Xdi2MessagingException {
  if (XDIConstants.XDI_ADD_ROOT.equals(targetXDIAddress)) {
    this.getGraph().clear();
  } else if (targetXDIAddress.getNumXDIArcs() == 1) {
    this.getGraph().getRootContextNode(false).delContextNode(targetXDIAddress.getFirstXDIArc());
  } else {
    XDIAddress parentContextNodeXDIAddress = XDIAddressUtil.parentXDIAddress(targetXDIAddress, -1);
    XDIArc XDIarc = targetXDIAddress.getLastXDIArc();
    ContextNode parentContextNode = this.getGraph().getDeepContextNode(parentContextNodeXDIAddress, false);
    if (parentContextNode == null) return;
    if (XDIConstants.XDI_ARC_LITERAL.equals(XDIarc)) {
      parentContextNode.delLiteralNode();
    } else {
      parentContextNode.delContextNode(XDIarc);
    }
  }
}

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

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();
graph32.clear();
graph32.clear();
graph32.clear();

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

graph18.clear();
graph18.rollbackTransaction();
graph18.clear();
graph18.commitTransaction();

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

graph30.clear();
assertEquals(graph30.getRootContextNode().getAllStatementCount(), 5);
graph30.clear();
assertEquals(graph30.getRootContextNode().getAllStatementCount(), 5);
graph30.clear();
graph30.clear();
graph30.clear();

相关文章