Exemplo n.º 1
1
 /**
  * Given a string, return an array of tokens. The separator can be escaped with the '\' character.
  * The '\' character may also be escaped by the '\' character.
  *
  * @param s the string to tokenize.
  * @param separator the separator char.
  * @param maxTokens the maxmimum number of tokens returned. If the max is reached, the remaining
  *     part of s is appended to the end of the last token.
  * @return an array of tokens.
  */
 public static String[] tokenize(String s, char separator, int maxTokens) {
   List tokens = new ArrayList();
   StringBuilder token = new StringBuilder();
   boolean prevIsEscapeChar = false;
   for (int i = 0; i < s.length(); i += Character.charCount(i)) {
     int currentChar = s.codePointAt(i);
     if (prevIsEscapeChar) {
       // Case 1:  escaped character
       token.appendCodePoint(currentChar);
       prevIsEscapeChar = false;
     } else if (currentChar == separator && tokens.size() < maxTokens - 1) {
       // Case 2:  separator
       tokens.add(token.toString());
       token = new StringBuilder();
     } else if (currentChar == '\\') {
       // Case 3:  escape character
       prevIsEscapeChar = true;
     } else {
       // Case 4:  regular character
       token.appendCodePoint(currentChar);
     }
   }
   if (token.length() > 0) {
     tokens.add(token.toString());
   }
   return (String[]) tokens.toArray(new String[] {});
 }
Exemplo n.º 2
0
 public static List asList(ProgramElementDoc[] members) {
   List list = new ArrayList();
   for (int i = 0; i < members.length; i++) {
     list.add(members[i]);
   }
   return list;
 }
Exemplo n.º 3
0
 /**
  * Return array of class members whose documentation is to be generated. If the member is
  * deprecated do not include such a member in the returned array.
  *
  * @param members Array of members to choose from.
  * @return List List of eligible members for whom documentation is getting generated.
  */
 public static List excludeDeprecatedMembersAsList(ProgramElementDoc[] members) {
   List list = new ArrayList();
   for (int i = 0; i < members.length; i++) {
     if (members[i].tags("deprecated").length == 0) {
       list.add(members[i]);
     }
   }
   Collections.sort(list);
   return list;
 }
Exemplo n.º 4
0
 /**
  * Adjust the Class Tree. Add the class interface in to it's super-class' or super-interface's
  * sub-interface list.
  *
  * @param map the entire map.
  * @param superclass java.lang.Object or the super-interface.
  * @param cd sub-interface to be mapped.
  * @returns boolean true if class added, false if class already processed.
  */
 private boolean add(Map map, ClassDoc superclass, ClassDoc cd) {
   List list = (List) map.get(superclass);
   if (list == null) {
     list = new ArrayList();
     map.put(superclass, list);
   }
   if (list.contains(cd)) {
     return false;
   } else {
     list.add(cd);
   }
   return true;
 }
Exemplo n.º 5
0
 /**
  * Return a list of all direct or indirect, sub-classes and subinterfaces of the ClassDoc
  * argument.
  *
  * @param cd ClassDoc whose sub-classes or sub-interfaces are requested.
  * @param isEnum true if the subclasses should be forced to come from the enum tree.
  */
 public List allSubs(ClassDoc cd, boolean isEnum) {
   List list = subs(cd, isEnum);
   for (int i = 0; i < list.size(); i++) {
     cd = (ClassDoc) list.get(i);
     List tlist = subs(cd, isEnum);
     for (int j = 0; j < tlist.size(); j++) {
       ClassDoc tcd = (ClassDoc) tlist.get(j);
       if (!list.contains(tcd)) {
         list.add(tcd);
       }
     }
   }
   Collections.sort(list);
   return list;
 }
Exemplo n.º 6
0
 /**
  * For the interface passed get the interfaces which it extends, and then put this interface in
  * the sub-interface list of those interfaces. Do it recursively. If a interface doesn't have
  * super-interface just attach that interface in the list of all the baseinterfaces.
  *
  * @param cd Interface under consideration.
  */
 private void processInterface(ClassDoc cd) {
   ClassDoc[] intfacs = cd.interfaces();
   if (intfacs.length > 0) {
     for (int i = 0; i < intfacs.length; i++) {
       if (!add(subinterfaces, intfacs[i], cd)) {
         return;
       } else {
         processInterface(intfacs[i]); // Recurse
       }
     }
   } else {
     // we need to add all the interfaces who do not have
     // super-interfaces to baseinterfaces list to traverse them
     if (!baseinterfaces.contains(cd)) {
       baseinterfaces.add(cd);
     }
   }
 }
Exemplo n.º 7
0
 /**
  * For the class passed map it to it's own sub-class listing. For the Class passed, get the super
  * class, if superclass is non null, (it is not "java.lang.Object") get the "value" from the
  * hashmap for this key Class if entry not found create one and get that. add this Class as a sub
  * class in the list Recurse till hits java.lang.Object Null SuperClass.
  *
  * @param cd class for which sub-class mapping to be generated.
  * @param configuration the current configurtation of the doclet.
  */
 private void processType(ClassDoc cd, Configuration configuration, List bases, Map subs) {
   ClassDoc superclass = Util.getFirstVisibleSuperClassCD(cd, configuration);
   if (superclass != null) {
     if (!add(subs, superclass, cd)) {
       return;
     } else {
       processType(superclass, configuration, bases, subs);
     }
   } else { // cd is java.lang.Object, add it once to the list
     if (!bases.contains(cd)) {
       bases.add(cd);
     }
   }
   List intfacs = Util.getAllInterfaces(cd, configuration);
   for (Iterator iter = intfacs.iterator(); iter.hasNext(); ) {
     add(implementingclasses, ((Type) iter.next()).asClassDoc(), cd);
   }
 }
 /**
  * Add the member summary for the given class.
  *
  * @param classDoc the class that is being documented
  * @param member the member being documented
  * @param firstSentenceTags the first sentence tags to be added to the summary
  * @param tableContents the list of contents to which the documentation will be added
  * @param counter the counter for determining id and style for the table row
  */
 public void addMemberSummary(
     ClassDoc classDoc,
     ProgramElementDoc member,
     Tag[] firstSentenceTags,
     List<Content> tableContents,
     int counter) {
   HtmlTree tdSummaryType = new HtmlTree(HtmlTag.TD);
   tdSummaryType.addStyle(HtmlStyle.colFirst);
   writer.addSummaryType(this, member, tdSummaryType);
   HtmlTree tdSummary = new HtmlTree(HtmlTag.TD);
   setSummaryColumnStyle(tdSummary);
   addSummaryLink(classDoc, member, tdSummary);
   writer.addSummaryLinkComment(this, member, firstSentenceTags, tdSummary);
   HtmlTree tr = HtmlTree.TR(tdSummaryType);
   tr.addContent(tdSummary);
   if (member instanceof MethodDoc && !member.isAnnotationTypeElement()) {
     int methodType =
         (member.isStatic()) ? MethodTypes.STATIC.value() : MethodTypes.INSTANCE.value();
     if (member.containingClass().isInterface()) {
       methodType =
           (((MethodDoc) member).isAbstract())
               ? methodType | MethodTypes.ABSTRACT.value()
               : methodType | MethodTypes.DEFAULT.value();
     } else {
       methodType =
           (((MethodDoc) member).isAbstract())
               ? methodType | MethodTypes.ABSTRACT.value()
               : methodType | MethodTypes.CONCRETE.value();
     }
     if (utils.isDeprecated(member) || utils.isDeprecated(classdoc)) {
       methodType = methodType | MethodTypes.DEPRECATED.value();
     }
     methodTypesOr = methodTypesOr | methodType;
     String tableId = "i" + counter;
     typeMap.put(tableId, methodType);
     tr.addAttr(HtmlAttr.ID, tableId);
   }
   if (counter % 2 == 0) tr.addStyle(HtmlStyle.altColor);
   else tr.addStyle(HtmlStyle.rowColor);
   tableContents.add(tr);
 }
Exemplo n.º 9
0
  /**
   * Return the list of classes which implement the interface passed.
   *
   * @param cd interface whose implementing-classes list is required.
   */
  public List implementingclasses(ClassDoc cd) {
    List result = get(implementingclasses, cd);
    List subinterfaces = allSubs(cd, false);

    // If class x implements a subinterface of cd, then it follows
    // that class x implements cd.
    Iterator implementingClassesIter, subInterfacesIter = subinterfaces.listIterator();
    ClassDoc c;
    while (subInterfacesIter.hasNext()) {
      implementingClassesIter =
          implementingclasses((ClassDoc) subInterfacesIter.next()).listIterator();
      while (implementingClassesIter.hasNext()) {
        c = (ClassDoc) implementingClassesIter.next();
        if (!result.contains(c)) {
          result.add(c);
        }
      }
    }
    Collections.sort(result);
    return result;
  }