コード例 #1
0
  /**
   * This method compresses the list of URIs to identify common patterns.
   *
   * @param uris The URIs
   * @return The compressed list of URIs
   */
  protected static List<URIInfo> compressURIInfo(List<URIInfo> uris) {
    List<URIInfo> others = new ArrayList<URIInfo>();

    URIPart rootPart = new URIPart();

    for (int i = 0; i < uris.size(); i++) {
      URIInfo uri = uris.get(i);

      if (uri.getUri() != null && uri.getUri().length() > 0 && uri.getUri().charAt(0) == '/') {
        String[] parts = uri.getUri().split("/");

        buildTree(rootPart, parts, 1, uri.getEndpointType());

      } else {
        others.add(uri);
      }
    }

    if (others.size() == uris.size()) {
      return uris;
    }

    // Construct new list
    rootPart.collapse();

    List<URIInfo> info = extractURIInfo(rootPart);

    // Initialise the URI info
    initURIInfo(info);

    return info;
  }