org.restlet.data.Reference.isHierarchical()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(94)

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

Reference.isHierarchical介绍

[英]Indicates if the identifier is hierarchical.
[中]指示标识符是否具有层次结构。

代码示例

代码示例来源:origin: org.restlet/org.restlet

/**
 * Indicates if the reference is a parent of the hierarchical child
 * reference.
 * 
 * @param childRef
 *            The hierarchical reference.
 * @return True if the reference is a parent of the hierarchical child
 *         reference.
 */
public boolean isParent(Reference childRef) {
  boolean result = false;
  if ((childRef != null) && (childRef.isHierarchical())) {
    result = childRef.toString(false, false).startsWith(
        toString(false, false));
  }
  return result;
}

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Indicates if the reference is a parent of the hierarchical child
 * reference.
 * 
 * @param childRef
 *            The hierarchical reference.
 * @return True if the reference is a parent of the hierarchical child
 *         reference.
 */
public boolean isParent(Reference childRef) {
  boolean result = false;
  if ((childRef != null) && (childRef.isHierarchical())) {
    result = childRef.toString(false, false).startsWith(
        toString(false, false));
  }
  return result;
}

代码示例来源:origin: DeviceConnect/DeviceConnect-Android

/**
 * Indicates if the reference is a parent of the hierarchical child
 * reference.
 * 
 * @param childRef
 *            The hierarchical reference.
 * @return True if the reference is a parent of the hierarchical child
 *         reference.
 */
public boolean isParent(Reference childRef) {
  boolean result = false;
  if ((childRef != null) && (childRef.isHierarchical())) {
    result = childRef.toString(false, false).startsWith(
        toString(false, false));
  }
  return result;
}

代码示例来源:origin: org.restlet/org.restlet

/**
 * Returns the parent reference of a hierarchical reference. The last slash
 * of the path will be considered as the end of the parent path.
 * 
 * @return The parent reference of a hierarchical reference.
 */
public Reference getParentRef() {
  Reference result = null;
  if (isHierarchical()) {
    String parentRef = null;
    String path = getPath();
    if (!path.equals("/") && !path.equals("")) {
      if (path.endsWith("/")) {
        path = path.substring(0, path.length() - 1);
      }
      parentRef = getHostIdentifier()
          + path.substring(0, path.lastIndexOf('/') + 1);
    } else {
      parentRef = this.internalRef;
    }
    result = new Reference(parentRef);
  }
  return result;
}

代码示例来源:origin: DeviceConnect/DeviceConnect-Android

/**
 * Returns the parent reference of a hierarchical reference. The last slash
 * of the path will be considered as the end of the parent path.
 * 
 * @return The parent reference of a hierarchical reference.
 */
public Reference getParentRef() {
  Reference result = null;
  if (isHierarchical()) {
    String parentRef = null;
    String path = getPath();
    if (!path.equals("/") && !path.equals("")) {
      if (path.endsWith("/")) {
        path = path.substring(0, path.length() - 1);
      }
      if (isAbsolute()) {
        parentRef = getHostIdentifier()
            + path.substring(0, path.lastIndexOf('/') + 1);
      } else {
        parentRef = path.substring(0, path.lastIndexOf('/') + 1);
      }
    } else {
      parentRef = this.internalRef;
    }
    result = new Reference(parentRef);
  }
  return result;
}

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Returns the parent reference of a hierarchical reference. The last slash
 * of the path will be considered as the end of the parent path.
 * 
 * @return The parent reference of a hierarchical reference.
 */
public Reference getParentRef() {
  Reference result = null;
  if (isHierarchical()) {
    String parentRef = null;
    String path = getPath();
    if (!path.equals("/") && !path.equals("")) {
      if (path.endsWith("/")) {
        path = path.substring(0, path.length() - 1);
      }
      if (isAbsolute()) {
        parentRef = getHostIdentifier()
            + path.substring(0, path.lastIndexOf('/') + 1);
      } else {
        parentRef = path.substring(0, path.lastIndexOf('/') + 1);
      }
    } else {
      parentRef = this.internalRef;
    }
    result = new Reference(parentRef);
  }
  return result;
}

代码示例来源:origin: org.restlet.osgi/org.restlet

} else if (!isAbsolute() || !isHierarchical()) {
  throw new IllegalArgumentException(
      "The reference must have an absolute hierarchical path component");
} else if (!base.isAbsolute() || !base.isHierarchical()) {
  throw new IllegalArgumentException(
      "The base reference must have an absolute hierarchical path component");

代码示例来源:origin: org.restlet/org.restlet

} else if (!isAbsolute() || !isHierarchical()) {
  throw new IllegalArgumentException(
      "The reference must have an absolute hierarchical path component");
} else if (!base.isAbsolute() || !base.isHierarchical()) {
  throw new IllegalArgumentException(
      "The base reference must have an absolute hierarchical path component");

代码示例来源:origin: DeviceConnect/DeviceConnect-Android

} else if (!isAbsolute() || !isHierarchical()) {
  throw new IllegalArgumentException(
      "The reference must have an absolute hierarchical path component");
} else if (!base.isAbsolute() || !base.isHierarchical()) {
  throw new IllegalArgumentException(
      "The base reference must have an absolute hierarchical path component");

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Returns the parent resource. The parent resource is defined in the sense
 * of hierarchical URIs. If the resource URI is not hierarchical, then an
 * exception is thrown.
 * 
 * @return The parent resource.
 */
public ClientResource getParent() throws ResourceException {
  ClientResource result = null;
  if (getReference().isHierarchical()) {
    result = new ClientResource(this);
    result.setReference(getReference().getParentRef());
  } else {
    doError(Status.CLIENT_ERROR_BAD_REQUEST, "The resource URI is not hierarchical.");
  }
  return result;
}

相关文章

Reference类方法