Example #1
0
  public String toLinkFormatItem(Resource resource) {
    StringBuilder linkFormat = new StringBuilder();

    // TODO return absolute link
    linkFormat.append("<" + getContext());
    linkFormat.append(resource.getPath().substring(this.getPath().length()));
    linkFormat.append(">");

    return linkFormat
        .append(LinkFormat.serializeResource(resource).toString().replaceFirst("<.+>", ""))
        .toString();
  }
Example #2
0
  private void buildLinkFormat(Resource resource, StringBuilder builder, List<String> query) {
    if (resource.getChildren().size() > 0) {

      // Loop over all sub-resources
      for (Resource res : resource.getChildren()) {
        // System.out.println(resource.getSubResources().size());
        // System.out.println(res.getName());
        if (LinkFormat.matches(res, query) && res.getAttributes().getCount() > 0) {

          // Convert Resource to string representation and add
          // delimiter
          builder.append(toLinkFormatItem(res));
          builder.append(',');
        }
        // Recurse
        buildLinkFormat(res, builder, query);
      }
    }
  }