public String getServiceDescription()

in SimpleServer/src/main/java/org/apache/uima/simpleserver/Service.java [315:365]


  public String getServiceDescription() {
    if (!this.initialized) {
      logInitializationError();
      return null;
    }
    try {
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      DocumentBuilder builder = factory.newDocumentBuilder();
      DOMImplementation impl = builder.getDOMImplementation();

      Document document = impl.createDocument(null, null, null);
      Element root = document.createElement("uimaService");
      root.setAttribute("shortDescription", this.serviceSpec.getShortDescription());
      document.appendChild(root);
      for (TypeMap tspec : this.serviceSpec.getTypeSpecs()) {
        Element typeDescription = document.createElement("element");
        root.appendChild(typeDescription);
        typeDescription.setAttribute("name", tspec.getOutputTag());
        typeDescription.setAttribute("shortDescription", tspec.getShortDescription());
        for (Output output : tspec.getOutputs()) {
          Element outputSpec = document.createElement("attribute");
          typeDescription.appendChild(outputSpec);
          outputSpec.setAttribute("name", output.getAttribute());
          outputSpec.setAttribute("shortDescription", output.getShortDescription());
        }
        if (tspec.isOutputCoveredText()) {
          Element outputSpec = document.createElement("attribute");
          typeDescription.appendChild(outputSpec);
          outputSpec.setAttribute("name", "coveredText");
          outputSpec.setAttribute("shortDescription", "Text covered by annotation");
        }
      }

      DOMSource source = new DOMSource(document);
      TransformerFactory tFactory = TransformerFactory.newInstance();
      Transformer transformer = tFactory.newTransformer();
      transformer.setOutputProperty(OutputKeys.METHOD, "xml");
      transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
      transformer.setOutputProperty(OutputKeys.INDENT, "yes");

      StringWriter stringWriter = new StringWriter();
      StreamResult streamResult = new StreamResult(stringWriter);
      transformer.transform(source, streamResult);

      return stringWriter.toString();
    } catch (Exception e) {
      e.printStackTrace();
    }

    return "";
  }