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, 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.º 3
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();
  }
Ejemplo n.º 4
0
 public void writeProperty(Property property, Writer writer) throws IOException {
   XmlWriter w = new XmlWriter(writer);
   toXml(w, property);
 }
Ejemplo n.º 5
0
 public void writeRequirement(Requirement requirement, Writer writer) throws IOException {
   XmlWriter w = new XmlWriter(writer);
   toXml(w, requirement);
 }
Ejemplo n.º 6
0
 public void writeCapability(Capability capability, Writer writer) throws IOException {
   XmlWriter w = new XmlWriter(writer);
   toXml(w, capability);
 }
Ejemplo n.º 7
0
 public void writeResource(Resource resource, Writer writer) throws IOException {
   XmlWriter w = new XmlWriter(writer);
   toXml(w, resource);
 }
Ejemplo n.º 8
0
 public void writeRepository(Repository repository, Writer writer) throws IOException {
   XmlWriter w = new XmlWriter(writer);
   toXml(w, repository);
 }