FileDocCategorySizeDatePackage
IndexBuilder.javaAPI DocExample5631Wed Apr 19 11:17:18 BST 2000com.sun.tools.doclets

IndexBuilder

public class IndexBuilder extends Object
Build the mapping of each Unicode character with it's member lists containing members names starting with it. Also build a list for all the Unicode characters which start a member name. Member name is classkind or field or method or constructor name.
since
JDK1.2
see
java.lang.Character
author
Atul M Dambalkar

Fields Summary
private Map
indexmap
Mapping of each Unicode Character with the member list containing members with names starting with it.
private boolean
noDeprecated
Don't generate deprecated information if true.
private boolean
classesOnly
Build this Index only for classes?
protected final Object[]
elements
Constructors Summary
public IndexBuilder(RootDoc root, boolean noDeprecated)
Constructor. Build the index map.

param
root Root of the Tree.
param
noDeprecated true if -nodeprecated option is used, false otherwise.

  

                              
         
        this(root, noDeprecated, false);
    
public IndexBuilder(RootDoc root, boolean noDeprecated, boolean classesOnly)
Constructor. Build the index map.

param
root Root of the Tree.
param
noDeprecated true if -nodeprecated option is used, false otherwise.
param
classesOnly Include only classes in index.

        if (classesOnly) {
            Configuration.message.
                              notice("doclet.Building_Index_For_All_Classes");
        } else {
            Configuration.message.notice("doclet.Building_Index");
        }
        this.noDeprecated = noDeprecated;
        this.classesOnly = classesOnly;
        buildIndexMap(root);
        Set set = indexmap.keySet();
        elements =  set.toArray();
        Arrays.sort(elements);
    
Methods Summary
protected voidadjustIndexMap(com.sun.javadoc.Doc[] elements)
Adjust list of members according to their names. Check the first character in a member name, and then add the member to a list of members for that particular unicode character.

param
elements Array of members.

        for (int i = 0; i < elements.length; i++) {
            if (shouldAddToIndexMap(elements[i])) {
                String name = elements[i].name();
                char ch = (name.length()==0)? 
                    '*" : 
                    Character.toUpperCase(name.charAt(0));
                Character unicode = new Character(ch);
                List list = (List)indexmap.get(unicode); 
                if (list == null) {
                    list = new ArrayList();
                    indexmap.put(unicode, list); 
                }     
                list.add(elements[i]);
            }
        }
    
protected voidbuildIndexMap(com.sun.javadoc.RootDoc root)
Get all the members in all the Packages and all the Classes given on the command line. Form separate list of those members depending upon their names.

param
root Root of the documemt.

        PackageDoc[] packages = root.specifiedPackages();
        ClassDoc[] classes = root.classes();
        List list = new ArrayList();
        if (!classesOnly) {
            adjustIndexMap(packages);
        }
        adjustIndexMap(classes);
        if (!classesOnly) {
            for (int i = 0; i < classes.length; i++) {
                if (shouldAddToIndexMap(classes[i])) {
                    putMembersInIndexMap(classes[i]);
                }
            }
        }
        sortIndexMap();
    
public java.lang.Object[]elements()
Array of IndexMap keys, Unicode characters.

        return elements;
    
public java.util.MapgetIndexMap()
Return a map of all the individual member lists with Unicode character.

return
Map index map.

        return indexmap;
    
public java.util.ListgetMemberList(java.lang.Character index)
Return the sorted list of members, for passed Unicode Character.

param
index index Unicode character.
return
List member list for specific Unicode character.

        return (List)indexmap.get(index);
    
protected voidputMembersInIndexMap(com.sun.javadoc.ClassDoc classdoc)
Put all the members(fields, methods and constructors) in the classdoc to the indexmap.

param
classdoc ClassDoc whose members will be added to the indexmap.

        adjustIndexMap(classdoc.fields());
        adjustIndexMap(classdoc.methods());
        adjustIndexMap(classdoc.constructors());
    
protected booleanshouldAddToIndexMap(com.sun.javadoc.Doc element)
Should this doc element be added to the index map?

        return !(noDeprecated && element.tags("deprecated").length > 0);
    
protected voidsortIndexMap()
Sort the index map. Traverse the index map for all it's elements and sort each element which is a list.

        for (Iterator it = indexmap.values().iterator(); it.hasNext(); ) {
            Collections.sort((List)it.next());
        }