本文整理了Java中xdi2.core.util.XDIAddressUtil.parentXDIAddress()
方法的一些代码示例,展示了XDIAddressUtil.parentXDIAddress()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XDIAddressUtil.parentXDIAddress()
方法的具体详情如下:
包路径:xdi2.core.util.XDIAddressUtil
类名称:XDIAddressUtil
方法名:parentXDIAddress
[英]Extracts an address's parent arc(s), counting either from the start or the end. For =abcd and 1, this returns =a For =abcd and -1, this returns =abc
[中]提取地址的父弧,从开始或结束计数。对于=abcd和1,返回=a对于=abcd和-1,返回=abc
代码示例来源:origin: projectdanube/xdi2
@Override
public String toString() {
if (this.positionXDIAddress == null) this.positionXDIAddress = XDIAddressUtil.parentXDIAddress(this.XDIaddress, this.position + 1);
return this.positionXDIAddress.toString();
}
}
代码示例来源:origin: projectdanube/xdi2
public XDIAddress getContextNodeXDIAddress() {
if (this.isLiteralNodeXDIAddress()) {
return XDIAddressUtil.parentXDIAddress(this, -1);
} else {
return this;
}
}
代码示例来源:origin: projectdanube/xdi2
private XdiContext<?> toContext() {
if (this.positionXDIAddress == null) this.positionXDIAddress = XDIAddressUtil.parentXDIAddress(this.XDIaddress, this.position + 1);
if (this.positionXdiContext == null) this.positionXdiContext = XdiAbstractContext.fromXDIAddress(this.positionXDIAddress);
return this.positionXdiContext;
}
代码示例来源:origin: projectdanube/xdi2
/**
* Extracts an partial address from an address.
*/
public static XDIAddress subXDIAddress(final XDIAddress XDIaddress, final int startIndex, final int endIndex) {
if (XDIaddress == null) throw new NullPointerException();
return XDIAddressUtil.localXDIAddress(XDIAddressUtil.parentXDIAddress(XDIaddress, endIndex), - startIndex);
}
代码示例来源:origin: projectdanube/xdi2
private XDIAddress result() {
return this.forward ?
XDIAddressUtil.parentXDIAddress(this.XDIaddress, this.position):
XDIAddressUtil.localXDIAddress(this.XDIaddress, - this.position - 1);
}
代码示例来源:origin: projectdanube/xdi2
private XdiVariable<?> toVariable() {
if (this.positionXDIAddress == null) this.positionXDIAddress = XDIAddressUtil.parentXDIAddress(this.XDIaddress, this.position + 1);
if (this.positionXdiVariable == null) this.positionXdiVariable = XdiAbstractVariable.fromXDIAddress(this.positionXDIAddress);
return this.positionXdiVariable;
}
代码示例来源:origin: projectdanube/xdi2
/**
* Removes an end address from an address.
* E.g. for =a*b*c*d and *c*d, this returns =a*b
* E.g. for =a*b*c*d and (empty address), this returns =a*b*c*d
* E.g. for =a*b*c*d and =a*b*c*d, this returns (empty address)
* E.g. for =a*b*c*d and *y, this returns null
*/
public static XDIAddress removeEndXDIAddress(final XDIAddress XDIaddress, final XDIAddress endXDIAddress, final boolean variablesinXDIAddress, final boolean variablesInEnd) {
if (XDIaddress == null) throw new NullPointerException();
if (endXDIAddress == null) throw new NullPointerException();
XDIAddress result = null;
try {
if (endXDIAddress.equals(XDIConstants.XDI_ADD_ROOT)) { result = XDIaddress; return result; }
if (XDIaddress.equals(XDIConstants.XDI_ADD_ROOT)) { result = null; return result; }
XDIAddress[] foundXDIAddress = XDIAddressUtil.endsWithXDIAddress(XDIaddress, endXDIAddress, variablesinXDIAddress, variablesInEnd);
if (foundXDIAddress == null) { result = null; return result; }
if (XDIaddress.equals(foundXDIAddress[0])) { result = XDIConstants.XDI_ADD_ROOT; return result; }
{ result = XDIAddressUtil.parentXDIAddress(XDIaddress, - foundXDIAddress[0].getNumXDIArcs()); return result; }
} finally {
if (log.isTraceEnabled()) log.trace("removeEndXDIAddress(" + XDIaddress + "," + endXDIAddress + "," + variablesinXDIAddress + "," + variablesInEnd + ") --> " + result);
}
}
代码示例来源:origin: projectdanube/xdi2
private static List<RelationshipLinkContract> findPushLinkContracts(Graph pushLinkContractsGraph, XDIAddress XDIaddress) {
List<RelationshipLinkContract> pushLinkContracts = new ArrayList<RelationshipLinkContract> ();
while (true) {
ContextNode contextNode = pushLinkContractsGraph.getDeepContextNode(XDIaddress);
if (contextNode != null) {
if (log.isDebugEnabled()) log.debug("Trying to find push link contracts for context node " + contextNode);
for (Relation pushLinkContractRelation : contextNode.getRelations(XDILinkContractConstants.XDI_ADD_IS_PUSH)) {
if (log.isDebugEnabled()) log.debug("Trying to find push link contract for relation " + pushLinkContractRelation);
ContextNode pushLinkContractContextNode = pushLinkContractRelation.followContextNode();
if (pushLinkContractContextNode == null) continue;
XdiEntity pushLinkContractXdiEntity = XdiAbstractEntity.fromContextNode(pushLinkContractContextNode);
if (pushLinkContractXdiEntity == null) continue;
RelationshipLinkContract pushLinkContract = RelationshipLinkContract.fromXdiEntity(pushLinkContractXdiEntity);
if (pushLinkContract == null) continue;
for (XDIAddress pushTargetXDIAddress : pushLinkContract.getPermissionTargetXDIAddresses(XDILinkContractConstants.XDI_ADD_PUSH)) {
if (log.isDebugEnabled()) log.debug("Found push link contract to address " + pushTargetXDIAddress + " for address " + XDIaddress);
if (XDIAddressUtil.startsWithXDIAddress(XDIaddress, pushTargetXDIAddress) != null) {
pushLinkContracts.add(pushLinkContract);
break;
}
}
}
}
if (XDIaddress.getNumXDIArcs() == 0) break;
XDIaddress = XDIAddressUtil.parentXDIAddress(XDIaddress, -1);
}
// done
if (log.isDebugEnabled()) log.debug("Found " + pushLinkContracts.size() + " push link contracts: " + pushLinkContracts);
return pushLinkContracts;
}
代码示例来源:origin: projectdanube/xdi2
public void testParentXDIAddress() throws Exception {
XDIAddress XDIaddress = XDIAddress.create("=a*b*c*d");
assertEquals(XDIAddressUtil.parentXDIAddress(XDIaddress, 0), XDIAddress.create("=a*b*c*d"));
assertEquals(XDIAddressUtil.parentXDIAddress(XDIaddress, 1), XDIAddress.create("=a"));
assertEquals(XDIAddressUtil.parentXDIAddress(XDIaddress, -1), XDIAddress.create("=a*b*c"));
assertEquals(XDIAddressUtil.parentXDIAddress(XDIaddress, 2), XDIAddress.create("=a*b"));
assertEquals(XDIAddressUtil.parentXDIAddress(XDIaddress, -2), XDIAddress.create("=a*b"));
assertEquals(XDIAddressUtil.parentXDIAddress(XDIaddress, 3), XDIAddress.create("=a*b*c"));
assertEquals(XDIAddressUtil.parentXDIAddress(XDIaddress, -3), XDIAddress.create("=a"));
assertEquals(XDIAddressUtil.parentXDIAddress(XDIaddress, 4), XDIAddress.create("=a*b*c*d"));
assertEquals(XDIAddressUtil.parentXDIAddress(XDIaddress, -4), XDIConstants.XDI_ADD_ROOT);
assertNull(XDIAddressUtil.parentXDIAddress(XDIaddress, -5));
assertEquals(XDIAddressUtil.parentXDIAddress(XDIaddress, -1), XDIAddress.create("=a*b*c"));
assertEquals(XDIAddressUtil.parentXDIAddress(XDIAddressUtil.parentXDIAddress(XDIaddress, -1), -1), XDIAddress.create("=a*b"));
assertEquals(XDIAddressUtil.parentXDIAddress(XDIAddressUtil.parentXDIAddress(XDIAddressUtil.parentXDIAddress(XDIaddress, -1), -1), -1), XDIAddress.create("=a"));
assertEquals(XDIAddressUtil.parentXDIAddress(XDIAddressUtil.parentXDIAddress(XDIAddressUtil.parentXDIAddress(XDIAddressUtil.parentXDIAddress(XDIaddress, -1), -1), -1), -1), XDIConstants.XDI_ADD_ROOT);
assertNull(XDIAddressUtil.parentXDIAddress(XDIAddressUtil.parentXDIAddress(XDIAddressUtil.parentXDIAddress(XDIAddressUtil.parentXDIAddress(XDIAddressUtil.parentXDIAddress(XDIaddress, -1), -1), -1), -1), -1));
}
代码示例来源:origin: projectdanube/xdi2
replacedContextNodeXDIAddress = XDIAddressUtil.concatXDIAddresses(XDIAddressUtil.parentXDIAddress(contextNodeXDIAddress, -1), replacedContextNodeXDIAddress);
代码示例来源:origin: projectdanube/xdi2
@Override
public ContextNode getDeepContextNode(XDIAddress relativeContextNodeXDIAddress, boolean subgraph) {
if (XDIConstants.XDI_ADD_ROOT.equals(relativeContextNodeXDIAddress)) return this;
XDIAddress contextNodeXDIAddress = XDIAddressUtil.concatXDIAddresses(this.getXDIAddress(), relativeContextNodeXDIAddress);
XDIAddress parentcontextNodeXDIAddress = XDIAddressUtil.concatXDIAddresses(this.getXDIAddress(), XDIAddressUtil.parentXDIAddress(relativeContextNodeXDIAddress, -1));
XDIArc XDIarc = relativeContextNodeXDIAddress.getLastXDIArc();
// load the JSON object for the parent context node
JsonObject jsonObject = ((JSONGraph) this.getGraph()).jsonLoad(parentcontextNodeXDIAddress.toString());
final JsonArray jsonArrayContexts = jsonObject.getAsJsonArray(XDIConstants.STRING_CONTEXT);
if (jsonArrayContexts == null) return null;
if (jsonArrayContexts.size() < 1) return null;
if (! new IteratorContains<JsonElement> (jsonArrayContexts.iterator(), new JsonPrimitive(XDIarc.toString())).contains()) return null;
JSONContextNode contextNode = this;
for (XDIArc temparc : relativeContextNodeXDIAddress.getXDIArcs()) {
XDIAddress tempAddress = XDIAddressUtil.concatXDIAddresses(contextNode.getXDIAddress(), temparc);
contextNode = new JSONContextNode((JSONGraph) this.getGraph(), contextNode, temparc, tempAddress);
}
// retrieve subgraph?
if (subgraph) {
((JSONGraph) this.getGraph()).jsonLoadWithPrefix(contextNodeXDIAddress.toString());
}
// done
return contextNode;
}
代码示例来源:origin: projectdanube/xdi2
subjectXDIAddress = XDIAddressUtil.parentXDIAddress(subjectXDIAddress, - predicateXDIAddress.getNumXDIArcs());
代码示例来源: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
contextNodeXDIAddress = XDIAddressUtil.parentXDIAddress(contextNodeXDIAddress, -1);
if (contextNodeXDIAddress == null) contextNodeXDIAddress = XDIConstants.XDI_ADD_ROOT;
内容来源于网络,如有侵权,请联系作者删除!