xdi2.core.features.nodetypes.XdiPeerRoot类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(10.7k)|赞(0)|评价(0)|浏览(110)

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

XdiPeerRoot介绍

[英]An XDI peer root, represented as a context node.
[中]XDI对等根,表示为上下文节点。

代码示例

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

@Override
  public XDIArc map(XDIAddress XDIaddress) {
    return XdiPeerRoot.createPeerRootXDIArc(XDIaddress);
  }
}

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

@Override
  public XDIAddress map(XDIArc XDIarc) {
    return XdiPeerRoot.getXDIAddressOfPeerRootXDIArc(XDIarc);
  }
}

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

public static boolean isValidXDIArc(XDIArc XDIarc) {

    if (XDIarc == null) throw new NullPointerException();

    if (XdiPeerRoot.isValidXDIArc(XDIarc)) return true;
    if (XdiInnerRoot.isValidXDIArc(XDIarc)) return true;

    return false;
  }
}

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

@Override
public boolean select(XdiPeerRoot ownerPeerRoot) {
  if (ownerPeerRoot.isSelfPeerRoot()) return false;
  if (ownerPeerRoot.dereference() != ownerPeerRoot) return false;
  return true;
}

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

/**
 * Checks if a given arc is a peer root arc.
 * @param arc A peer root arc.
 * @return True, if the arc is a peer root arc.
 */
public static boolean isValidXDIArc(XDIArc XDIarc) {
  if (XDIarc == null) throw new NullPointerException();
  if (getXDIAddressOfPeerRootXDIArc(XDIarc) != null) return true;
  if (getIriOfPeerRootXDIArc(XDIarc) != null) return true;
  if (getLiteralOfPeerRootXDIArc(XDIarc) != null) return true;
  return false;
}

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

/**
 * Checks if this XDI peer root is the self XDI peer root of the graph.
 * @return True, if this is the self XDI peer root.
 */
public boolean isSelfPeerRoot() {
  XdiPeerRoot selfPeerRoot = this.findCommonRoot().getSelfPeerRoot();
  if (this.equals(selfPeerRoot)) return true;
  ContextNode refContextNode = Equivalence.getReferenceContextNode(this.getContextNode());
  XdiPeerRoot refPeerRoot = refContextNode == null ? null : XdiPeerRoot.fromContextNode(refContextNode);
  if (refPeerRoot != null && refPeerRoot.equals(selfPeerRoot)) return true;
  ContextNode repContextNode = Equivalence.getReplacementContextNode(this.getContextNode());
  XdiPeerRoot repPeerRoot = repContextNode == null ? null : XdiPeerRoot.fromContextNode(repContextNode);
  if (repPeerRoot != null && repPeerRoot.equals(selfPeerRoot)) return true;
  return false;
}

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

public void testPeerRootXDIArces() throws Exception {
  
  assertFalse(XdiPeerRoot.isValidXDIArc(XDIArc.create("")));
  assertTrue(XdiPeerRoot.isValidXDIArc(XDIArc.create("(=!1111)")));
  assertFalse(XdiPeerRoot.isValidXDIArc(XDIArc.create("(=a*b/+c*d)")));
  assertFalse(XdiPeerRoot.isValidXDIArc(XDIArc.create("[<+c>]")));
  assertFalse(XdiPeerRoot.isValidXDIArc(XDIArc.create("{*1}")));
  assertFalse(XdiPeerRoot.isValidXDIArc(XDIArc.create("{[<+(name)>]}")));
  assertFalse(XdiPeerRoot.isValidXDIArc(XDIArc.create("<+(name)>")));
  assertFalse(XdiPeerRoot.isValidXDIArc(XDIArc.create("[+(name)]")));
  assertFalse(XdiPeerRoot.isValidXDIArc(XDIArc.create("+(name)")));
  assertEquals(XdiPeerRoot.createPeerRootXDIArc(XDIAddress.create("=!1111")), XDIArc.create("(=!1111)"));
  assertEquals(XdiPeerRoot.getXDIAddressOfPeerRootXDIArc(XDIArc.create("(=!1111)")), XDIAddress.create("=!1111"));
}

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

Object value = entry.getValue();
if ((! XdiPeerRoot.isValidXDIArc(key)) && value instanceof XDIAddress && ((XDIAddress) value).getNumXDIArcs() == 1) {
  XDIArc peerValue = XdiPeerRoot.createPeerRootXDIArc((XDIAddress) value);

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

public XDIAddress getXDIAddressOfPeerRoot() {
  return getXDIAddressOfPeerRootXDIArc(this.getContextNode().getXDIArc());
}

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

private Graph resolveGraph(XDIAddress contextNodeXDIAddress) {
  XDIArc firstArc = contextNodeXDIAddress.getFirstXDIArc();
  if (XdiPeerRoot.isValidXDIArc(firstArc)) {
    firstArc = XdiPeerRoot.getXDIAddressOfPeerRootXDIArc(firstArc).getFirstXDIArc();
  } else if (XdiInnerRoot.isValidXDIArc(firstArc)) {
    firstArc = XdiInnerRoot.getSubjectOfInnerRootXDIArc(firstArc).getFirstXDIArc();
  }
  Graph resolvedGraph = null;
  if (XDI_ARC_MSG_VARIABLE.equals(firstArc)) {
    resolvedGraph = this.getMessage().getContextNode().getGraph();
  } else if (XDI_ARC_FROM_VARIABLE.equals(firstArc)) {
    resolvedGraph = this.getTargetGraph();
  } else if (XDI_ARC_FROM_PEER_VARIABLE.equals(firstArc)) {
    resolvedGraph = this.getTargetGraph();
  } else {
    resolvedGraph = this.getTargetGraph();
  }
  if (log.isTraceEnabled()) log.trace("getGraph(" + contextNodeXDIAddress + ") --> " + resolvedGraph);
  return resolvedGraph;
}

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

@Override
public XdiPeerRoot getPeerRoot(XDIAddress XDIaddress, boolean create) {
  if (log.isTraceEnabled()) log.trace("getPeerRoot(" + XDIaddress + "," + create + ")");
  XDIArc peerRootXDIArc = XdiPeerRoot.createPeerRootXDIArc(XDIaddress);
  ContextNode peerRootContextNode = create ? this.getContextNode().setContextNode(peerRootXDIArc) : this.getContextNode().getContextNode(peerRootXDIArc, false);
  if (peerRootContextNode == null) return null;
  return new XdiPeerRoot(peerRootContextNode);
}

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

if (xdiRoot == null) return;
if (xdiRoot instanceof XdiPeerRoot && CloudNumber.isValid(((XdiPeerRoot) xdiRoot).getXDIAddressOfPeerRoot())) {
  this.cloudNumber = CloudNumber.fromPeerRootXDIArc(((XdiPeerRoot) xdiRoot).getXDIArc());
if (xdiRoot instanceof XdiPeerRoot && CloudNumber.isValid(((XdiPeerRoot) xdiRoot).getXDIAddressOfPeerRoot())) {
  this.cloudNumber = CloudNumber.fromPeerRootXDIArc(((XdiPeerRoot) xdiRoot).getXDIArc());

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

XdiRoot dereferencedOwnerPeerRoot = ownerXdiPeerRoot.dereference();
if (dereferencedOwnerPeerRoot instanceof XdiPeerRoot) ownerXdiPeerRoot = (XdiPeerRoot) dereferencedOwnerPeerRoot;
if (ownerXdiPeerRoot.isSelfPeerRoot()) {
ownerXDIAddress = ownerXdiPeerRoot.getXDIAddressOfPeerRoot();

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

@Override
public BootstrapInterceptor instanceFor(PrototypingContext prototypingContext) {
  // create new interceptor
  BootstrapInterceptor interceptor = new BootstrapInterceptor();
  // set the owner, root link contract, public link contract, connect link contract, send link contract
  interceptor.setBootstrapOwner(prototypingContext.getOwnerXDIAddress());
  interceptor.setBootstrapRootLinkContract(this.getBootstrapRootLinkContract());
  interceptor.setBootstrapPublicLinkContract(this.getBootstrapPublicLinkContract());
  interceptor.setBootstrapConnectLinkContract(this.getBootstrapConnectLinkContract());
  interceptor.setBootstrapSendLinkContract(this.getBootstrapSendLinkContract());
  // set the owner synonyms
  XDIAddress[] bootstrapOwnerSynonyms = null;
  if (prototypingContext.getOwnerXdiPeerRoot() != null) {
    Iterator<ContextNode> ownerSynonymPeerRootContextNodes = Equivalence.getIncomingReferenceContextNodes(prototypingContext.getOwnerXdiPeerRoot().getContextNode());
    XdiPeerRoot[] ownerSynonymPeerRoots = (new IteratorArrayMaker<XdiPeerRoot> (new MappingContextNodePeerRootIterator(ownerSynonymPeerRootContextNodes))).array(XdiPeerRoot.class);
    bootstrapOwnerSynonyms = new XDIAddress[ownerSynonymPeerRoots.length];
    for (int i=0; i<bootstrapOwnerSynonyms.length; i++) bootstrapOwnerSynonyms[i] = ownerSynonymPeerRoots[i].getXDIAddressOfPeerRoot();
  }
  interceptor.setBootstrapOwnerSynonyms(bootstrapOwnerSynonyms);
  // set bootstrap statements and operations
  interceptor.setBootstrapGraph(this.getBootstrapGraph());
  interceptor.setBootstrapMessageEnvelope(this.getBootstrapMessageEnvelope());
  // done
  return interceptor;
}

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

@Override
public XdiRoot getRoot(XDIAddress XDIaddress, boolean create) {
  if (log.isTraceEnabled()) log.trace("getRoot(" + XDIaddress + "," + create + ")");
  XdiRoot root = this;
  for (int i=0; i<XDIaddress.getNumXDIArcs(); i++) {
    XDIArc XDIarc = XDIaddress.getXDIArc(i);
    XdiRoot nextRoot;
    if (XdiPeerRoot.isValidXDIArc(XDIarc)) {
      ContextNode peerRootContextNode = create ? root.getContextNode().setContextNode(XDIarc) : root.getContextNode().getContextNode(XDIarc, false);
      if (peerRootContextNode == null) return null;
      nextRoot = new XdiPeerRoot(peerRootContextNode);
    } else if (XdiInnerRoot.isValidXDIArc(XDIarc)) {
      ContextNode innerRootContextNode = create ? root.getContextNode().setContextNode(XDIarc) : root.getContextNode().getContextNode(XDIarc, false);
      if (innerRootContextNode == null) return null;
      nextRoot = new XdiInnerRoot(innerRootContextNode);
    } else {
      break;
    }
    root = nextRoot;
  }
  return root;
}

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

public XdiPeerRoot setSelfPeerRoot(XDIAddress XDIaddress) {
  XdiPeerRoot selfPeerRoot = this.getSelfPeerRoot();
  if (selfPeerRoot != null) selfPeerRoot.getContextNode().delete();
  if (XDIaddress == null) return null;
  selfPeerRoot = this.getPeerRoot(XDIaddress, true);
  ContextNode commonRootContextNode = this.getContextNode();
  ContextNode selfPeerRootContextNode = selfPeerRoot.getContextNode();
  commonRootContextNode.delRelations(XDIDictionaryConstants.XDI_ADD_IS_REF);
  commonRootContextNode.setRelation(XDIDictionaryConstants.XDI_ADD_IS_REF, selfPeerRootContextNode);
  selfPeerRootContextNode.delRelations(XDIDictionaryConstants.XDI_ADD_REF);
  selfPeerRootContextNode.setRelation(XDIDictionaryConstants.XDI_ADD_REF, commonRootContextNode);
  return selfPeerRoot;
}

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

public void testSelfPeerRoots() throws Exception {

    Graph graph = MemoryGraphFactory.getInstance().openGraph();
    XdiCommonRoot.findCommonRoot(graph).setSelfPeerRoot(XDIAddress.create("=!1111"));

    XdiPeerRoot selfPeerRoot = XdiCommonRoot.findCommonRoot(graph).getSelfPeerRoot();

    assertEquals(selfPeerRoot.getContextNode().getXDIAddress(), XDIAddress.create("(=!1111)"));
    assertEquals(XdiCommonRoot.findCommonRoot(graph).getPeerRoot(XDIAddress.create("=!1111"), false), selfPeerRoot);
    assertTrue(selfPeerRoot.isSelfPeerRoot());

    graph.close();
  }
}

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

@Override
  public XDIArc map(XdiPeerRoot ownerPeerRoot) {
    return ownerPeerRoot.getXDIArc();
  }
};

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

public void testSubGraph() throws Exception {

    Graph graph = MemoryGraphFactory.getInstance().openGraph();
    XdiCommonRoot localRoot = XdiCommonRoot.findCommonRoot(graph);
    XdiPeerRoot peerRoot = localRoot.getPeerRoot(XDIAddress.create("=!:uuid:91f28153-f600-ae24-91f2-8153f600ae24"), true);
    XdiInnerRoot innerRoot = peerRoot.getInnerRoot(XDIAddress.create("=!1111"), XDIAddress.create("$add"), true);
    
    assertTrue(XdiAbstractContext.fromContextNode(localRoot.getContextNode()) instanceof XdiCommonRoot);
    assertTrue(XdiAbstractContext.fromContextNode(peerRoot.getContextNode()) instanceof XdiPeerRoot);
    assertTrue(XdiAbstractContext.fromContextNode(innerRoot.getContextNode()) instanceof XdiInnerRoot);
    
    graph.close();
  }
}

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

public static boolean ownsPeerRootXDIArc(Graph graph, XDIArc peerRootXDIArc) {
  XdiPeerRoot xdiPeerRoot = XdiCommonRoot.findCommonRoot(graph).getPeerRoot(peerRootXDIArc, false);
  if (xdiPeerRoot == null) return false;
  XdiRoot xdiRoot = xdiPeerRoot.dereference();
  return xdiRoot instanceof XdiCommonRoot;
}

相关文章