本文整理了Java中xdi2.core.util.XDIAddressUtil
类的一些代码示例,展示了XDIAddressUtil
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XDIAddressUtil
类的具体详情如下:
包路径:xdi2.core.util.XDIAddressUtil
类名称:XDIAddressUtil
[英]Various utility methods for working with XDI addresses.
[中]使用XDI地址的各种实用方法。
代码示例来源:origin: projectdanube/xdi2
public static XDIAddress getTemplateAuthorityAndId(XDIAddress XDIaddress) {
XDIaddress = XDIAddressUtil.extractXDIAddress(XDIaddress, XdiInnerRoot.class, false, true, false, false, true);
if (XDIaddress == null) return null;
int index = XDIAddressUtil.indexOfXDIArc(XDIaddress, XDILinkContractConstants.XDI_ARC_CONTRACT);
if (index < 0) index = XDIAddressUtil.indexOfXDIArc(XDIaddress, XdiEntityCollection.createXDIArc(XDILinkContractConstants.XDI_ARC_CONTRACT));
XDIAddress templateAuthorityAndId = XDIAddressUtil.subXDIAddress(XDIaddress, 1, index);
if (XDIConstants.XDI_ADD_ROOT.equals(templateAuthorityAndId)) return null;
return templateAuthorityAndId;
}
代码示例来源:origin: projectdanube/xdi2
private XDIAddress replaceXDIAddress(XDIAddress XDIaddress) {
return XDIAddressUtil.concatXDIAddresses(this.startXDIAddress, XDIaddress);
}
}
代码示例来源:origin: projectdanube/xdi2
public static List<ContributorFound> findHigherContributors(ContributorMap contributorMap, XDIAddress contributorsXDIAddress, XDIAddress relativeNodeXDIAddress) {
if (contributorMap.isEmpty()) return new ArrayList<ContributorFound> ();
List<ContributorFound> higherContributors = new ArrayList<ContributorFound> ();
if (relativeNodeXDIAddress == null) {
} else {
for (Map.Entry<XDIAddress, List<Contributor>> contributorEntry : contributorMap.entrySet()) {
XDIAddress nextContributorXDIAddress = contributorEntry.getKey();
XDIAddress[] matched = XDIAddressUtil.startsWithXDIAddress(XDIAddressUtil.concatXDIAddresses(contributorsXDIAddress, relativeNodeXDIAddress), XDIAddressUtil.concatXDIAddresses(contributorsXDIAddress, nextContributorXDIAddress), false, true);
if (matched == null) continue;
XDIAddress matchedRelativeNodeXDIAddress = XDIAddressUtil.localXDIAddress(matched[0], - contributorsXDIAddress.getNumXDIArcs());
XDIAddress matchedNextContributorXDIAddress = XDIAddressUtil.localXDIAddress(matched[1], - contributorsXDIAddress.getNumXDIArcs());
XDIAddress contributorXDIAddress = matchedRelativeNodeXDIAddress;
List<Contributor> contributors = contributorEntry.getValue();
for (Contributor contributor : contributors) higherContributors.add(new ContributorFound(contributorXDIAddress, contributor));
}
}
if (higherContributors.isEmpty()) {
if (log.isDebugEnabled()) log.debug("Finding higher contributors for " + relativeNodeXDIAddress + ": No matches.");
} else {
if (log.isDebugEnabled()) log.debug("Finding higher contributors for " + relativeNodeXDIAddress + ": Matches at " + higherContributors);
}
return higherContributors;
}
代码示例来源:origin: projectdanube/xdi2
public static XDIAddress getTemplateAuthorityAndId(XDIAddress XDIaddress) {
int index = XDIAddressUtil.indexOfXDIArc(XDIaddress, XDILinkContractConstants.XDI_ARC_V_CONTRACT);
if (index < 0) return null;
return XDIAddressUtil.subXDIAddress(XDIaddress, 0, index);
}
代码示例来源: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
public static boolean isValidOperationXDIAddress(XDIAddress operationXDIAddress) {
return
XDIAddressUtil.startsWithXDIAddress(operationXDIAddress, XDIMessagingConstants.XDI_ADD_GET) != null ||
XDIAddressUtil.startsWithXDIAddress(operationXDIAddress, XDIMessagingConstants.XDI_ADD_SET) != null ||
XDIAddressUtil.startsWithXDIAddress(operationXDIAddress, XDIMessagingConstants.XDI_ADD_DEL) != null ||
XDIAddressUtil.startsWithXDIAddress(operationXDIAddress, XDIMessagingConstants.XDI_ADD_DO) != null ||
XDIAddressUtil.startsWithXDIAddress(operationXDIAddress, XDIMessagingConstants.XDI_ADD_CONNECT) != null ||
XDIAddressUtil.startsWithXDIAddress(operationXDIAddress, XDIMessagingConstants.XDI_ADD_SEND) != null ||
XDIAddressUtil.startsWithXDIAddress(operationXDIAddress, XDIMessagingConstants.XDI_ADD_PUSH) != null;
}
代码示例来源:origin: projectdanube/xdi2
org.openrdf.model.Resource context = null;
XDIAddress rootXDIAddress = XDIAddressUtil.extractXDIAddress(XDIstatement.getContextNodeXDIAddress(), XdiPeerRoot.class, false, false, true, false, false);
if (rootXDIAddress != null) subjectXDIAddress = XDIAddressUtil.localXDIAddress(subjectXDIAddress, - rootXDIAddress.getNumXDIArcs());
if (subjectXDIAddress == null) subjectXDIAddress = XDIConstants.XDI_ADD_ROOT;
if (rootXDIAddress != null) subjectXDIAddress = XDIAddressUtil.localXDIAddress(subjectXDIAddress, - rootXDIAddress.getNumXDIArcs());
if (subjectXDIAddress == null) subjectXDIAddress = XDIConstants.XDI_ADD_ROOT;
if (rootXDIAddress != null) subjectXDIAddress = XDIAddressUtil.localXDIAddress(subjectXDIAddress, - rootXDIAddress.getNumXDIArcs());
if (subjectXDIAddress == null) subjectXDIAddress = XDIConstants.XDI_ADD_ROOT;
XDIAddress predicateXDIAddress = XDIAddressUtil.extractXDIAddress(subjectXDIAddress, XdiAttribute.class, false, false, true, false, true);
subjectXDIAddress = XDIAddressUtil.parentXDIAddress(subjectXDIAddress, - predicateXDIAddress.getNumXDIArcs());
代码示例来源:origin: projectdanube/xdi2
/**
* Returns a MIME data type for an XDI address.
*/
public static String mimeTypeFromDataTypeXDIAddress(XDIAddress dataTypeXDIAddress) {
if (XDIAddressUtil.startsWithXDIAddress(dataTypeXDIAddress, XDI_ADD_DATATYPE_MIME) == null) throw new Xdi2RuntimeException("Invalid MIME data type address: " + dataTypeXDIAddress);
XDIAddress mimeTypeXDIAddress = XDIAddressUtil.localXDIAddress(dataTypeXDIAddress, - XDI_ADD_DATATYPE_MIME.getNumXDIArcs());
return mimeTypeXDIAddress.toString().substring(1).replace(XDIConstants.CS_CLASS_RESERVED.toString(), "/");
}
}
代码示例来源:origin: projectdanube/xdi2
pushRefRepRelationPerOperation(executionContext, refRelation);
return XDIAddressUtil.concatXDIAddresses(referenceContextNode.getXDIAddress(), localAddress);
pushRefRepRelationPerOperation(executionContext, repRelation);
return XDIAddressUtil.concatXDIAddresses(replacementContextNode.getXDIAddress(), localAddress);
localAddress = XDIAddressUtil.concatXDIAddresses(XDIAddressUtil.localXDIAddress(contextNodeXDIAddress, 1), localAddress);
contextNodeXDIAddress = XDIAddressUtil.parentXDIAddress(contextNodeXDIAddress, -1);
if (contextNodeXDIAddress == null) contextNodeXDIAddress = XDIConstants.XDI_ADD_ROOT;
代码示例来源:origin: projectdanube/xdi2
private XDIAddress replaceXDIAddress(XDIAddress XDIaddress) {
XDIAddress replacedXDIAddress = XDIAddressUtil.extractXDIAddress(XDIaddress, this.clazzes, this.keepOnlyFirstFound, this.keepOnlyLastFound, this.keepAllFound, this.keepParent, this.keepLocal);
return replacedXDIAddress != null ? replacedXDIAddress : XDIaddress;
}
}
代码示例来源:origin: projectdanube/xdi2
XDIAddress replacedContextNodeXDIAddress = XDIAddressUtil.replaceXDIAddress(
baseXDIAddress,
oldXDIArc,
replacedContextNodeXDIAddress = XDIAddressUtil.concatXDIAddresses(XDIAddressUtil.parentXDIAddress(contextNodeXDIAddress, -1), replacedContextNodeXDIAddress);
代码示例来源:origin: projectdanube/xdi2
private void putLiteralNodeIntoAttributeJsonObject(LiteralNode literalNode, JsonObject attributeJsonObject, XDIAddress parentXDIAddress) {
XDIAddress XDIaddress = literalNode.getXDIAddress();
XDIAddress localXDIAddress = XDIAddressUtil.localXDIAddress(XDIaddress, - parentXDIAddress.getNumXDIArcs());
JsonElement literalJsonElement = AbstractLiteralNode.literalDataToJsonElement(literalNode.getLiteralData());
attributeJsonObject.add(localXDIAddress.toString(), literalJsonElement);
}
代码示例来源: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
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
@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
XDIAddress nextRelativeTargetXDIAddress = relativeTargetXDIAddress == null ? null : XDIAddressUtil.removeStartXDIAddress(relativeTargetXDIAddress, contributorXDIAddress);
XDIAddress nextRelativeNodeXDIAddress = nextRelativeTargetXDIAddress;
nextContributorXDIAddresses[nextContributorXDIAddresses.length - 1] = contributorXDIAddress;
XDIAddress nextContributorsXDIAddress = XDIAddressUtil.concatXDIAddresses(nextContributorXDIAddresses);
contributorResultXDIAddress = contributorResultXDIAddress.or(contributorResult);
XDIAddress tempNodeXDIAddress = XDIAddressUtil.concatXDIAddresses(nextContributorsXDIAddress, nextRelativeNodeXDIAddress);
Node tempNode = tempResultGraph.getDeepNode(tempNodeXDIAddress, true);
代码示例来源: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
/**
* Removes a start address from an address.
* E.g. for =a*b*c*d and =a*b, this returns *c*d
* 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 =x, this returns null
*/
public static XDIAddress removeStartXDIAddress(final XDIAddress XDIaddress, final XDIAddress startXDIAddress) {
return removeStartXDIAddress(XDIaddress, startXDIAddress, false, false);
}
代码示例来源:origin: projectdanube/xdi2
public void DISABLEDtestRemoveEndXDIAddressVariables() throws Exception {
XDIAddress XDIaddress = XDIAddress.create("=a*b+c!d#e$f*g");
assertEquals(XDIAddressUtil.removeEndXDIAddress(XDIaddress, XDIAddress.create("{}"), false, true), XDIAddress.create("=a*b+c!d#e$f"));
assertEquals(XDIAddressUtil.removeEndXDIAddress(XDIaddress, XDIAddress.create("{*}"), false, true), XDIAddress.create("=a*b+c!d#e$f"));
assertEquals(XDIAddressUtil.removeEndXDIAddress(XDIaddress, XDIAddress.create("{}{}"), false, true), XDIAddress.create("=a*b+c!d#e"));
assertEquals(XDIAddressUtil.removeEndXDIAddress(XDIaddress, XDIAddress.create("{{$*}}"), false, true), XDIAddress.create("=a*b+c!d#e"));
assertEquals(XDIAddressUtil.removeEndXDIAddress(XDIaddress, XDIAddress.create("{$}{}"), false, true), XDIAddress.create("=a*b+c!d#e"));
assertEquals(XDIAddressUtil.removeEndXDIAddress(XDIaddress, XDIAddress.create("{{!#}}{{$*}}"), false, true), XDIAddress.create("=a*b+c"));
assertEquals(XDIAddressUtil.removeEndXDIAddress(XDIaddress, XDIAddress.create("{!}{}{{$*}}"), false, true), XDIAddress.create("=a*b+c"));
assertEquals(XDIAddressUtil.removeEndXDIAddress(XDIaddress, XDIAddress.create("{}{!}{}{{$*}}"), false, true), XDIAddress.create("=a*b"));
assertEquals(XDIAddressUtil.removeEndXDIAddress(XDIaddress, XDIAddress.create("{+}{{!}}{}{{$*}}"), false, true), XDIAddress.create("=a*b"));
assertEquals(XDIAddressUtil.removeEndXDIAddress(XDIaddress, XDIAddress.create("{=}{*}{+}{!}{}{{$*}}"), false, true), XDIAddress.create(""));
assertEquals(XDIAddressUtil.removeStartXDIAddress(XDIaddress, XDIAddress.create("{{=+*#$!}}"), false, true), XDIAddress.create(""));
assertNull(XDIAddressUtil.removeEndXDIAddress(XDIaddress, XDIAddress.create("{!}"), false, true));
}
}
代码示例来源:origin: projectdanube/xdi2
private static boolean isSetOnContractAddress(XDIAddress targetXDIAddress, Operation operation) {
if (! (operation instanceof SetOperation)) return false;
if (XDIAddressUtil.indexOfXDIArc(targetXDIAddress, XDILinkContractConstants.XDI_ARC_CONTRACT) != -1) return true;
return false;
}
内容来源于网络,如有侵权,请联系作者删除!