FileDocCategorySizeDatePackage
Util.javaAPI DocExample6420Wed Apr 19 11:17:18 BST 2000com.sun.tools.doclets

Util

public class Util extends Object
Utilities Class for Doclets.
author
Atul M Dambalkar

Fields Summary
Constructors Summary
Methods Summary
public static java.util.ListasList(com.sun.javadoc.ProgramElementDoc[] members)

        List list = new ArrayList();
        for (int i = 0; i < members.length; i++) {
            list.add(members[i]);
        }
        return list;
    
private static voidbuildInterfaces(java.util.Set interfaces, com.sun.javadoc.ClassDoc cd)

        ClassDoc[] iin = cd.interfaces();
        for (int i = 0; i < iin.length; i++) {
            interfaces.add(iin[i]);
            buildInterfaces(interfaces, iin[i]);
        }
    
public static voidcopyFile(java.io.File destfile, java.io.File srcfile)
Copy source file to destination file.

throws
SecurityException
throws
IOException

        byte[] bytearr = new byte[512];
        int len = 0;
        FileInputStream input = new FileInputStream(srcfile);
        FileOutputStream output = new FileOutputStream(destfile);
        try {
            while ((len = input.read(bytearr)) != -1) {
                output.write(bytearr, 0, len);
            }
        } catch (FileNotFoundException exc) {
        } catch (SecurityException exc) {
        } finally {
            input.close();
            output.close();
        }
    
public static com.sun.javadoc.ProgramElementDoc[]excludeDeprecatedMembers(com.sun.javadoc.ProgramElementDoc[] members)
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
ProgramElementDoc[] Array of eligible members for whom documentation is getting generated.

        return 
             toProgramElementDocArray(excludeDeprecatedMembersAsList(members));
    
public static java.util.ListexcludeDeprecatedMembersAsList(com.sun.javadoc.ProgramElementDoc[] members)
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.

        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;
    
public static com.sun.javadoc.MethodDocfindMethod(com.sun.javadoc.ClassDoc cd, com.sun.javadoc.MethodDoc method)
Search for the given method in the given class.

param
cd Class to search into.
param
method Method to be searched.
return
MethodDoc Method found, null otherwise.

        MethodDoc[] methods = cd.methods();
        for (int i = 0; i < methods.length; i++) {
            if (method.name().equals(methods[i].name()) &&
                   method.signature().equals(methods[i].signature())) {
                return methods[i];
            }
        }
        return null;
    
public static com.sun.javadoc.ClassDoc[]getAllInterfaces(com.sun.javadoc.ClassDoc classdoc)
For the class return all implemented interfaces including the superinterfaces of the implementing interfaces, also iterate over for all the superclasses. For interface return all the extended interfaces as well as superinterfaces for those extended interfaces.

param
cd Class or interface whose implemented or super interfaces are sought.
return
ClassDoc[] Array of all the required interfaces.

        Set interfaces = new HashSet();
        buildInterfaces(interfaces, classdoc);
        if (classdoc.isClass()) {
            ClassDoc icd = classdoc.superclass();
            while (icd != null) {
                buildInterfaces(interfaces, icd);
                icd = icd.superclass();
            }
        }
        ClassDoc[] intarr = new ClassDoc[interfaces.size()];
        interfaces.toArray(intarr);
        Arrays.sort(intarr);
        return intarr;   
    
public static booleanisCoreClass(com.sun.javadoc.ClassDoc cd)
According to the Java Language Specifications, all the outer classes and static inner classes are core classes.

        return cd.containingClass() == null || cd.isStatic();
    
public static booleanmatches(com.sun.javadoc.ProgramElementDoc doc1, com.sun.javadoc.ProgramElementDoc doc2)

        if (doc1 instanceof ExecutableMemberDoc && 
                doc2 instanceof ExecutableMemberDoc) {
            ExecutableMemberDoc ed1 = (ExecutableMemberDoc)doc1;
            ExecutableMemberDoc ed2 = (ExecutableMemberDoc)doc2;
            return ed1.name().equals(ed2.name()) && 
                       ed1.signature().equals(ed2.signature());
        } else {
            return doc1.name().equals(doc2.name());
        }
    
public static booleannonPublicMemberFound(com.sun.javadoc.ProgramElementDoc[] members)
Return true if a non-public member found in the given array.

param
members Array of members to look into.
return
boolean True if non-public member found, false otherwise.

        for (int i = 0; i < members.length; i++) {
            if (!members[i].isPublic()) {
                return true;
            }
        }
        return false;
    
public static com.sun.javadoc.ProgramElementDoc[]toProgramElementDocArray(java.util.List list)
Return the list of ProgramElementDoc objects as Array.

        ProgramElementDoc[] pgmarr = new ProgramElementDoc[list.size()];
        for (int i = 0; i < list.size(); i++) {
            pgmarr[i] = (ProgramElementDoc)(list.get(i));
        } 
        return pgmarr;