Ejemplo n.º 1
0
  private static void toXml(XmlWriter w, Resource resource) throws IOException {
    w.element(RepositoryParser.RESOURCE)
        .attribute(Resource.ID, resource.getId())
        .attribute(Resource.SYMBOLIC_NAME, resource.getSymbolicName())
        .attribute(Resource.PRESENTATION_NAME, resource.getPresentationName())
        .attribute(Resource.URI, getRelativeUri(resource, Resource.URI))
        .attribute(Resource.VERSION, resource.getVersion().toString());

    w.textElement(Resource.DESCRIPTION, resource.getProperties().get(Resource.DESCRIPTION))
        .textElement(Resource.SIZE, resource.getProperties().get(Resource.SIZE))
        .textElement(
            Resource.DOCUMENTATION_URI, getRelativeUri(resource, Resource.DOCUMENTATION_URI))
        .textElement(Resource.SOURCE_URI, getRelativeUri(resource, Resource.SOURCE_URI))
        .textElement(Resource.JAVADOC_URI, getRelativeUri(resource, Resource.JAVADOC_URI))
        .textElement(Resource.LICENSE_URI, getRelativeUri(resource, Resource.LICENSE_URI));

    String[] categories = resource.getCategories();
    for (int i = 0; categories != null && i < categories.length; i++) {
      w.element(RepositoryParser.CATEGORY).attribute(RepositoryParser.ID, categories[i]).end();
    }
    Capability[] capabilities = resource.getCapabilities();
    for (int i = 0; capabilities != null && i < capabilities.length; i++) {
      toXml(w, capabilities[i]);
    }
    Requirement[] requirements = resource.getRequirements();
    for (int i = 0; requirements != null && i < requirements.length; i++) {
      toXml(w, requirements[i]);
    }
    w.end();
  }
Ejemplo n.º 2
0
 private static void toXml(XmlWriter w, Property property) throws IOException {
   w.element(RepositoryParser.P)
       .attribute(RepositoryParser.N, property.getName())
       .attribute(RepositoryParser.T, property.getType())
       .attribute(RepositoryParser.V, property.getValue())
       .end();
 }
Ejemplo n.º 3
0
 private static void toXml(XmlWriter w, Capability capability) throws IOException {
   w.element(RepositoryParser.CAPABILITY).attribute(RepositoryParser.NAME, capability.getName());
   Property[] props = capability.getProperties();
   for (int j = 0; props != null && j < props.length; j++) {
     toXml(w, props[j]);
   }
   w.end();
 }
Ejemplo n.º 4
0
 private static void toXml(XmlWriter w, Requirement requirement) throws IOException {
   w.element(RepositoryParser.REQUIRE)
       .attribute(RepositoryParser.NAME, requirement.getName())
       .attribute(RepositoryParser.FILTER, requirement.getFilter())
       .attribute(RepositoryParser.EXTEND, Boolean.toString(requirement.isExtend()))
       .attribute(RepositoryParser.MULTIPLE, Boolean.toString(requirement.isMultiple()))
       .attribute(RepositoryParser.OPTIONAL, Boolean.toString(requirement.isOptional()))
       .text(requirement.getComment().trim())
       .end();
 }
Ejemplo n.º 5
0
  private static void toXml(XmlWriter w, Repository repository) throws IOException {
    SimpleDateFormat format = new SimpleDateFormat("yyyyMMddhhmmss.SSS");
    w.element(RepositoryParser.REPOSITORY)
        .attribute(RepositoryParser.NAME, repository.getName())
        .attribute(
            RepositoryParser.LASTMODIFIED, format.format(new Date(repository.getLastModified())));

    if (repository instanceof RepositoryImpl) {
      Referral[] referrals = ((RepositoryImpl) repository).getReferrals();
      for (int i = 0; referrals != null && i < referrals.length; i++) {
        w.element(RepositoryParser.REFERRAL)
            .attribute(RepositoryParser.DEPTH, new Integer(referrals[i].getDepth()))
            .attribute(RepositoryParser.URL, referrals[i].getUrl())
            .end();
      }
    }

    Resource[] resources = repository.getResources();
    for (int i = 0; resources != null && i < resources.length; i++) {
      toXml(w, resources[i]);
    }

    w.end();
  }