langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java
changeset 1789 7ac8c0815000
parent 1264 076a3cde30d5
child 1864 c17be9084212
equal deleted inserted replaced
1788:ced0a1a7ec80 1789:7ac8c0815000
    86     }
    86     }
    87 
    87 
    88     /**
    88     /**
    89      * Return the list of ProgramElementDoc objects as Array.
    89      * Return the list of ProgramElementDoc objects as Array.
    90      */
    90      */
    91     public static ProgramElementDoc[] toProgramElementDocArray(List list) {
    91     public static ProgramElementDoc[] toProgramElementDocArray(List<ProgramElementDoc> list) {
    92         ProgramElementDoc[] pgmarr = new ProgramElementDoc[list.size()];
    92         ProgramElementDoc[] pgmarr = new ProgramElementDoc[list.size()];
    93         for (int i = 0; i < list.size(); i++) {
    93         for (int i = 0; i < list.size(); i++) {
    94             pgmarr[i] = (ProgramElementDoc)(list.get(i));
    94             pgmarr[i] = list.get(i);
    95         }
    95         }
    96         return pgmarr;
    96         return pgmarr;
    97     }
    97     }
    98 
    98 
    99     /**
    99     /**
   414                 (configuration == null ||
   414                 (configuration == null ||
   415                 isLinkable(interfaceClassDoc, configuration)))) {
   415                 isLinkable(interfaceClassDoc, configuration)))) {
   416                 continue;
   416                 continue;
   417             }
   417             }
   418             results.put(interfaceClassDoc, interfaceType);
   418             results.put(interfaceClassDoc, interfaceType);
   419             List superInterfaces = getAllInterfaces(interfaceType, configuration, sort);
   419             List<Type> superInterfaces = getAllInterfaces(interfaceType, configuration, sort);
   420             for (Iterator iter = superInterfaces.iterator(); iter.hasNext(); ) {
   420             for (Iterator<Type> iter = superInterfaces.iterator(); iter.hasNext(); ) {
   421                 Type t = (Type) iter.next();
   421                 Type t = iter.next();
   422                 results.put(t.asClassDoc(), t);
   422                 results.put(t.asClassDoc(), t);
   423             }
   423             }
   424         }
   424         }
   425         if (superType == null)
   425         if (superType == null)
   426             return new ArrayList<Type>(results.values());
   426             return new ArrayList<Type>(results.values());
   436                 Collections.sort(resultsList, new TypeComparator());
   436                 Collections.sort(resultsList, new TypeComparator());
   437         }
   437         }
   438         return resultsList;
   438         return resultsList;
   439     }
   439     }
   440 
   440 
   441     public static List getAllInterfaces(Type type, Configuration configuration) {
   441     public static List<Type> getAllInterfaces(Type type, Configuration configuration) {
   442         return getAllInterfaces(type, configuration, true);
   442         return getAllInterfaces(type, configuration, true);
   443     }
   443     }
   444 
   444 
   445     private static void findAllInterfaceTypes(Map<ClassDoc,Type> results, ClassDoc c, boolean raw,
   445     private static void findAllInterfaceTypes(Map<ClassDoc,Type> results, ClassDoc c, boolean raw,
   446             Configuration configuration) {
   446             Configuration configuration) {
   478                 continue;
   478                 continue;
   479             }
   479             }
   480             if (raw)
   480             if (raw)
   481                 interfaceType = interfaceType.asClassDoc();
   481                 interfaceType = interfaceType.asClassDoc();
   482             results.put(interfaceClassDoc, interfaceType);
   482             results.put(interfaceClassDoc, interfaceType);
   483             List superInterfaces = getAllInterfaces(interfaceType, configuration);
   483             List<Type> superInterfaces = getAllInterfaces(interfaceType, configuration);
   484             for (Iterator iter = superInterfaces.iterator(); iter.hasNext(); ) {
   484             for (Iterator<Type> iter = superInterfaces.iterator(); iter.hasNext(); ) {
   485                 Type superInterface = (Type) iter.next();
   485                 Type superInterface = iter.next();
   486                 results.put(superInterface.asClassDoc(), superInterface);
   486                 results.put(superInterface.asClassDoc(), superInterface);
   487             }
   487             }
   488         }
   488         }
   489         if (type instanceof ParameterizedType)
   489         if (type instanceof ParameterizedType)
   490             findAllInterfaceTypes(results, (ParameterizedType) type, configuration);
   490             findAllInterfaceTypes(results, (ParameterizedType) type, configuration);
   493         else
   493         else
   494             findAllInterfaceTypes(results, (ClassDoc) type, true, configuration);
   494             findAllInterfaceTypes(results, (ClassDoc) type, true, configuration);
   495     }
   495     }
   496 
   496 
   497 
   497 
   498     public static List<ProgramElementDoc> asList(ProgramElementDoc[] members) {
   498     public static <T extends ProgramElementDoc> List<T> asList(T[] members) {
   499         List<ProgramElementDoc> list = new ArrayList<ProgramElementDoc>();
   499         List<T> list = new ArrayList<T>();
   500         for (int i = 0; i < members.length; i++) {
   500         for (int i = 0; i < members.length; i++) {
   501             list.add(members[i]);
   501             list.add(members[i]);
   502         }
   502         }
   503         return list;
   503         return list;
   504     }
   504     }