xdi2.core.util.XDIAddressUtil.startsWithXDIAddress()方法的使用及代码示例

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

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

XDIAddressUtil.startsWithXDIAddress介绍

[英]Checks if an address starts with a certain other address.
[中]检查地址是否以某个其他地址开头。

代码示例

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

/**
 * Checks if an address starts with a certain other address.
 */
public static XDIAddress[] startsWithXDIAddress(XDIAddress XDIaddress, XDIAddress startXDIAddress) {
  return startsWithXDIAddress(XDIaddress, startXDIAddress, false, false);
}

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

private void checkReadOnly(Operation operation, XDIAddress contextNodeXDIAddress, ExecutionContext executionContext) throws Xdi2MessagingException {
  if (operation instanceof GetOperation) return;
  for (XDIAddress readOnlyAddress : this.readOnlyAddresses) {
    if (readOnlyAddress == null || XDIAddressUtil.startsWithXDIAddress(contextNodeXDIAddress, readOnlyAddress) != null) {
      throw new Xdi2MessagingException("This address is read-only: " + contextNodeXDIAddress, null, executionContext);
    }
  }
}

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

/**
 * Returns an XSD data type for an XDI address.
 */
public static String xsdTypeFromDataTypeXDIAddress(XDIAddress dataTypeXDIAddress) {
  if (XDIAddressUtil.startsWithXDIAddress(dataTypeXDIAddress, XDI_ADD_DATATYPE_XSD) == null) throw new Xdi2RuntimeException("Invalid XSD data type address: " + dataTypeXDIAddress);
  XDIAddress xsdTypeXDIAddress = dataTypeXDIAddress;
  return xsdTypeXDIAddress.toString().substring(1).replace(XDIConstants.CS_CLASS_RESERVED.toString(), ":");
}

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

if (XDIAddressUtil.startsWithXDIAddress(targetXDIAddress, writeListenerXDIAddress) != null) {
  if (XDIAddressUtil.startsWithXDIAddress(targetXDIStatement.getContextNodeXDIAddress(), writeListenerXDIAddress) != null) {

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

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 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

if (XDIAddressUtil.startsWithXDIAddress(targetXDIaddress, permissionTargetXDIAddress, false, true) != null) {
if (XDIAddressUtil.startsWithXDIAddress(targetXDIaddress, permissionTargetXDIAddress, false, true) != null) {

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

/**
 * Checks if an relation is a valid XDI $do operation.
 * @param relation The relation to check.
 * @return True if the relation is a valid XDI $do operation.
 */
public static boolean isValid(Relation relation) {
  if (XDIAddressUtil.startsWithXDIAddress(relation.getXDIAddress(), XDIMessagingConstants.XDI_ADD_DO) == null) return false;
  if (! XDIMessagingConstants.XDI_ARC_DO.equals(relation.getContextNode().getXDIArc())) return false;
  return true;
}

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

/**
 * Checks if an relation is a valid XDI $send operation.
 * @param relation The relation to check.
 * @return True if the relation is a valid XDI $send operation.
 */
public static boolean isValid(Relation relation) {
  if (XDIAddressUtil.startsWithXDIAddress(relation.getXDIAddress(), XDIMessagingConstants.XDI_ADD_SEND) == null) return false;
  if (! XDIMessagingConstants.XDI_ARC_DO.equals(relation.getContextNode().getXDIArc())) return false;
  return true;
}

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

/**
 * Checks if an relation is a valid XDI $connect operation.
 * @param relation The relation to check.
 * @return True if the relation is a valid XDI $connect operation.
 */
public static boolean isValid(Relation relation) {
  if (XDIAddressUtil.startsWithXDIAddress(relation.getXDIAddress(), XDIMessagingConstants.XDI_ADD_CONNECT) == null) return false;
  if (! XDIMessagingConstants.XDI_ARC_DO.equals(relation.getContextNode().getXDIArc())) return false;
  return true;
}

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

/**
 * Checks if an relation is a valid XDI $get operation.
 * @param relation The relation to check.
 * @return True if the relation is a valid XDI $get operation.
 */
public static boolean isValid(Relation relation) {
  if (XDIAddressUtil.startsWithXDIAddress(relation.getXDIAddress(), XDIMessagingConstants.XDI_ADD_GET) == null) return false;
  if (! XDIMessagingConstants.XDI_ARC_DO.equals(relation.getContextNode().getXDIArc())) return false;
  return true;
}

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

/**
 * Checks if an relation is a valid XDI $push operation.
 * @param relation The relation to check.
 * @return True if the relation is a valid XDI $push operation.
 */
public static boolean isValid(Relation relation) {
  if (XDIAddressUtil.startsWithXDIAddress(relation.getXDIAddress(), XDIMessagingConstants.XDI_ADD_PUSH) == null) return false;
  if (! XDIMessagingConstants.XDI_ARC_DO.equals(relation.getContextNode().getXDIArc())) return false;
  return true;
}

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

/**
 * Checks if an relation is a valid XDI $del operation.
 * @param relation The relation to check.
 * @return True if the relation is a valid XDI $del operation.
 */
public static boolean isValid(Relation relation) {
  if (XDIAddressUtil.startsWithXDIAddress(relation.getXDIAddress(), XDIMessagingConstants.XDI_ADD_DEL) == null) return false;
  if (! XDIMessagingConstants.XDI_ARC_DO.equals(relation.getContextNode().getXDIArc())) return false;
  return true;
}

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

/**
 * Checks if an relation is a valid XDI $set operation.
 * @param relation The relation to check.
 * @return True if the relation is a valid XDI $set operation.
 */
public static boolean isValid(Relation relation) {
  if (XDIAddressUtil.startsWithXDIAddress(relation.getXDIAddress(), XDIMessagingConstants.XDI_ADD_SET) == null) return false;
  if (! XDIMessagingConstants.XDI_ARC_DO.equals(relation.getContextNode().getXDIArc())) return false;
  return true;
}

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

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

assertEquals(XDIAddressUtil.startsWithXDIAddress(XDIaddress1, XDIAddress.create("=a")), XDIAddress.create("=a"));
assertEquals(XDIAddressUtil.startsWithXDIAddress(XDIaddress1, XDIAddress.create("=a*b")), XDIAddress.create("=a*b"));
assertEquals(XDIAddressUtil.startsWithXDIAddress(XDIaddress1, XDIAddress.create("=a*b*c")), XDIAddress.create("=a*b*c"));
assertEquals(XDIAddressUtil.startsWithXDIAddress(XDIaddress1, XDIAddress.create("=a*b*c*d")), XDIAddress.create("=a*b*c*d"));
assertNull(XDIAddressUtil.startsWithXDIAddress(XDIaddress1, XDIAddress.create("=x*b")));
assertNull(XDIAddressUtil.startsWithXDIAddress(XDIaddress1, XDIAddress.create("=a*x*c")));
assertEquals(XDIAddressUtil.startsWithXDIAddress(XDIaddress1, XDIAddress.create("{}"), false, true), XDIAddress.create("=a"));
assertEquals(XDIAddressUtil.startsWithXDIAddress(XDIaddress1, XDIAddress.create("=a{}"), false, true), XDIAddress.create("=a*b"));
assertEquals(XDIAddressUtil.startsWithXDIAddress(XDIaddress1, XDIAddress.create("{}{}*c"), false, true), XDIAddress.create("=a*b*c"));
assertEquals(XDIAddressUtil.startsWithXDIAddress(XDIaddress1, XDIAddress.create("{}*b*c*d"), false, true), XDIAddress.create("=a*b*c*d"));
assertNull(XDIAddressUtil.startsWithXDIAddress(XDIaddress1, XDIAddress.create("=x*b"), false, true));
assertNull(XDIAddressUtil.startsWithXDIAddress(XDIaddress1, XDIAddress.create("=a*x*c"), false, true));
assertNull(XDIAddressUtil.startsWithXDIAddress(XDIaddress1, XDIAddress.create("{}"), false, false));
assertNull(XDIAddressUtil.startsWithXDIAddress(XDIaddress1, XDIAddress.create("=a{}"), false, false));
assertNull(XDIAddressUtil.startsWithXDIAddress(XDIaddress1, XDIAddress.create("{}{}*c"), false, false));
assertNull(XDIAddressUtil.startsWithXDIAddress(XDIaddress1, XDIAddress.create("{}*b*c*d"), false, false));
assertNull(XDIAddressUtil.startsWithXDIAddress(XDIaddress1, XDIAddress.create("=x*b"), false, false));
assertNull(XDIAddressUtil.startsWithXDIAddress(XDIaddress1, XDIAddress.create("=a*x*c"), false, false));
assertEquals(XDIAddressUtil.startsWithXDIAddress(XDIaddress2, XDIAddress.create("=a"), true, false), XDIAddress.create("{}"));
assertEquals(XDIAddressUtil.startsWithXDIAddress(XDIaddress2, XDIAddress.create("=a*b"), true, false), XDIAddress.create("{}*b"));
assertEquals(XDIAddressUtil.startsWithXDIAddress(XDIaddress2, XDIAddress.create("=a*b*c"), true, false), XDIAddress.create("{}*b{}"));
assertEquals(XDIAddressUtil.startsWithXDIAddress(XDIaddress2, XDIAddress.create("=a*b*c*d"), true, false), XDIAddress.create("{}*b{}*d"));
assertEquals(XDIAddressUtil.startsWithXDIAddress(XDIaddress2, XDIAddress.create("=x*b"), true, false), XDIAddress.create("{}*b"));
assertNull(XDIAddressUtil.startsWithXDIAddress(XDIaddress2, XDIAddress.create("=a*x*c"), true, false));
assertEquals(XDIAddressUtil.startsWithXDIAddress(XDIaddress1, XDIAddress.create("{{=*}}*b*c*d"), false, true), XDIaddress1);

相关文章