Ejemplo n.º 1
0
  /**
   * Return as a single string all the documentation associated with the specified object. Each
   * attribute of type of class Documentation that the object contains contributes to the
   * documentation. The text contributed by each such attribute starts on a new line. If there are
   * no such attributes, then null is returned.
   *
   * @param object The object to document.
   * @return The documentation for the object.
   */
  public static String consolidate(NamedObj object) {
    List docList = object.attributeList(Documentation.class);

    if (docList.size() > 0) {
      StringBuffer doc = new StringBuffer();
      Iterator segments = docList.iterator();

      while (segments.hasNext()) {
        Documentation segment = (Documentation) segments.next();
        doc.append(segment.getValueAsString());

        if (segments.hasNext()) {
          doc.append("\n");
        }
      }

      return doc.toString();
    } else {
      return null;
    }
  }