本文整理了Java中xdi2.core.util.XDIAddressUtil.localXDIAddress()
方法的一些代码示例,展示了XDIAddressUtil.localXDIAddress()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XDIAddressUtil.localXDIAddress()
方法的具体详情如下:
包路径:xdi2.core.util.XDIAddressUtil
类名称:XDIAddressUtil
方法名:localXDIAddress
[英]Extracts an address's local arc(s). For =abcd and 1, this returns d For =abcd and -1, this returns bcd
[中]提取地址的局部弧。对于=abcd和1,返回d对于=abcd和-1,返回bcd
代码示例来源: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
/**
* 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
/**
* Returns an XSD data type for a JSON data type.
*/
public static String jsonTypeFromDataTypeXDIAddress(XDIAddress dataTypeXDIAddress) {
if (XDIAddressUtil.startsWithXDIAddress(dataTypeXDIAddress, XDI_ADD_DATATYPE_JSON) == null) throw new Xdi2RuntimeException("Invalid JSON data type address: " + dataTypeXDIAddress);
XDIAddress jsonTypeXDIAddress = XDIAddressUtil.localXDIAddress(dataTypeXDIAddress, - XDI_ADD_DATATYPE_JSON.getNumXDIArcs());
return jsonTypeXDIAddress.toString().substring(1);
}
代码示例来源: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
/**
* 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, final boolean variablesinXDIAddress, final boolean variablesInStart) {
if (XDIaddress == null) throw new NullPointerException();
if (startXDIAddress == null) throw new NullPointerException();
XDIAddress result = null;
try {
if (startXDIAddress.equals(XDIConstants.XDI_ADD_ROOT)) { result = XDIaddress; return result; }
if (XDIaddress.equals(XDIConstants.XDI_ADD_ROOT)) { result = null; return result; }
XDIAddress[] foundXDIAddress = XDIAddressUtil.startsWithXDIAddress(XDIaddress, startXDIAddress, variablesinXDIAddress, variablesInStart);
if (foundXDIAddress == null) { result = null; return result; }
if (XDIaddress.equals(foundXDIAddress[0])) { result = XDIConstants.XDI_ADD_ROOT; return result; }
{ result = XDIAddressUtil.localXDIAddress(XDIaddress, - foundXDIAddress[0].getNumXDIArcs()); return result; }
} finally {
if (log.isTraceEnabled()) log.trace("removeStartXDIAddress(" + XDIaddress + "," + startXDIAddress + "," + variablesinXDIAddress + "," + variablesInStart + ") --> " + Arrays.asList(result));
}
}
代码示例来源:origin: projectdanube/xdi2
XDIAddress[] matched = XDIAddressUtil.startsWithXDIAddress(XDIAddressUtil.concatXDIAddresses(contributorsXDIAddress, nextContributorXDIAddress), XDIAddressUtil.concatXDIAddresses(contributorsXDIAddress, relativeNodeXDIAddress), true, false);
if (matched == null) continue;
XDIAddress matchedRelativeNodeXDIAddress = XDIAddressUtil.localXDIAddress(matched[1], - contributorsXDIAddress.getNumXDIArcs());
XDIAddress matchedNextContributorXDIAddress = XDIAddressUtil.localXDIAddress(matched[0], - contributorsXDIAddress.getNumXDIArcs());
XDIAddress contributorLocalXDIAddress = XDIAddressUtil.localXDIAddress(nextContributorXDIAddress, nextContributorXDIAddress.getNumXDIArcs() - matchedNextContributorXDIAddress.getNumXDIArcs());
XDIAddress contributorXDIAddress = XDIAddressUtil.concatXDIAddresses(matchedRelativeNodeXDIAddress, contributorLocalXDIAddress);
代码示例来源:origin: projectdanube/xdi2
public void testLocalXDIAddress() throws Exception {
XDIAddress XDIaddress = XDIAddress.create("=a*b*c*d");
assertEquals(XDIAddressUtil.localXDIAddress(XDIaddress, 0), XDIAddress.create("=a*b*c*d"));
assertEquals(XDIAddressUtil.localXDIAddress(XDIaddress, 1), XDIAddress.create("*d"));
assertEquals(XDIAddressUtil.localXDIAddress(XDIaddress, -1), XDIAddress.create("*b*c*d"));
assertEquals(XDIAddressUtil.localXDIAddress(XDIaddress, 2), XDIAddress.create("*c*d"));
assertEquals(XDIAddressUtil.localXDIAddress(XDIaddress, -2), XDIAddress.create("*c*d"));
assertEquals(XDIAddressUtil.localXDIAddress(XDIaddress, 3), XDIAddress.create("*b*c*d"));
assertEquals(XDIAddressUtil.localXDIAddress(XDIaddress, -3), XDIAddress.create("*d"));
assertEquals(XDIAddressUtil.localXDIAddress(XDIaddress, 4), XDIAddress.create("=a*b*c*d"));
assertEquals(XDIAddressUtil.localXDIAddress(XDIaddress, -4), XDIConstants.XDI_ADD_ROOT);
assertNull(XDIAddressUtil.localXDIAddress(XDIaddress, -5));
assertEquals(XDIAddressUtil.localXDIAddress(XDIaddress, -1), XDIAddress.create("*b*c*d"));
assertEquals(XDIAddressUtil.localXDIAddress(XDIAddressUtil.localXDIAddress(XDIaddress, -1), -1), XDIAddress.create("*c*d"));
assertEquals(XDIAddressUtil.localXDIAddress(XDIAddressUtil.localXDIAddress(XDIAddressUtil.localXDIAddress(XDIaddress, -1), -1), -1), XDIAddress.create("*d"));
assertEquals(XDIAddressUtil.localXDIAddress(XDIAddressUtil.localXDIAddress(XDIAddressUtil.localXDIAddress(XDIAddressUtil.localXDIAddress(XDIaddress, -1), -1), -1), -1), XDIConstants.XDI_ADD_ROOT);
assertNull(XDIAddressUtil.localXDIAddress(XDIAddressUtil.localXDIAddress(XDIAddressUtil.localXDIAddress(XDIAddressUtil.localXDIAddress(XDIAddressUtil.localXDIAddress(XDIaddress, -1), -1), -1), -1), -1));
}
代码示例来源: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
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
private void putAttributeIntoEntityJsonObject(ContextNode attributeContextNode, JsonObject entityJsonObject, XDIAddress parentXDIAddress) throws IOException {
XDIAddress XDIaddress = attributeContextNode.getXDIAddress();
XDIAddress localXDIAddress = XDIAddressUtil.localXDIAddress(XDIaddress, - parentXDIAddress.getNumXDIArcs());
// set up attribute
JsonObject attributeJsonObject = new JsonObject();
entityJsonObject.add(localXDIAddress.toString(), attributeJsonObject);
// context nodes
for (ContextNode contextNode : attributeContextNode.getContextNodes()) {
if (XdiAbstractAttribute.isValid(contextNode) || XdiAttributeCollection.isValid(contextNode)) {
this.putAttributeIntoEntityJsonObject(contextNode, entityJsonObject, parentXDIAddress);
continue;
}
throw new Xdi2RuntimeException("Unexpected context node: " + contextNode + " on attribute context node: " + attributeContextNode);
}
// relations
for (Relation relation : attributeContextNode.getRelations()) {
this.putRelationIntoJsonObject(relation, attributeJsonObject);
}
// literal node
if (attributeContextNode.containsLiteralNode()) {
LiteralNode literalNode = attributeContextNode.getLiteralNode();
this.putLiteralNodeIntoAttributeJsonObject(literalNode, attributeJsonObject, XDIaddress);
}
// finish attribute
if (attributeJsonObject.entrySet().isEmpty() && ! attributeContextNode.isEmpty()) {
if (! this.isWriteImplied()) entityJsonObject.remove(localXDIAddress.toString());
}
}
代码示例来源:origin: projectdanube/xdi2
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;
代码示例来源:origin: projectdanube/xdi2
private void putEntityIntoRootJsonObject(ContextNode entityContextNode, JsonObject rootJsonObject, XDIAddress parentXDIAddress) throws IOException {
XDIAddress localXDIAddress = XDIAddressUtil.localXDIAddress(XDIaddress, - parentXDIAddress.getNumXDIArcs());
代码示例来源:origin: projectdanube/xdi2
private void putAttributeIntoJsonObject(ContextNode attributeContextNode, JsonObject jsonObject, XDIAddress parentXDIAddress) throws IOException {
XDIAddress localXDIAddress = XDIAddressUtil.localXDIAddress(XDIaddress, - parentXDIAddress.getNumXDIArcs());
代码示例来源:origin: projectdanube/xdi2
XDIAddress localXDIAddress = XDIAddressUtil.localXDIAddress(collapsedContextNode.getXDIAddress(), collapsedContextNode.getXDIAddress().getNumXDIArcs() - contextNode.getXDIAddress().getNumXDIArcs() + 1);
contextNode = collapsedContextNode;
代码示例来源:origin: projectdanube/xdi2
private void putEntityIntoJsonObject(ContextNode entityContextNode, JsonObject jsonObject, XDIAddress parentXDIAddress) throws IOException {
XDIAddress localXDIAddress = XDIAddressUtil.localXDIAddress(XDIaddress, - parentXDIAddress.getNumXDIArcs());
代码示例来源:origin: projectdanube/xdi2
localAddress = XDIAddressUtil.concatXDIAddresses(XDIAddressUtil.localXDIAddress(contextNodeXDIAddress, 1), localAddress);
contextNodeXDIAddress = XDIAddressUtil.parentXDIAddress(contextNodeXDIAddress, -1);
if (contextNodeXDIAddress == null) contextNodeXDIAddress = XDIConstants.XDI_ADD_ROOT;
内容来源于网络,如有侵权,请联系作者删除!