71 * |
71 * |
72 * @param members Array of members to choose from. |
72 * @param members Array of members to choose from. |
73 * @return List List of eligible members for whom |
73 * @return List List of eligible members for whom |
74 * documentation is getting generated. |
74 * documentation is getting generated. |
75 */ |
75 */ |
76 public static List excludeDeprecatedMembersAsList( |
76 public static List<ProgramElementDoc> excludeDeprecatedMembersAsList( |
77 ProgramElementDoc[] members) { |
77 ProgramElementDoc[] members) { |
78 List list = new ArrayList(); |
78 List<ProgramElementDoc> list = new ArrayList<ProgramElementDoc>(); |
79 for (int i = 0; i < members.length; i++) { |
79 for (int i = 0; i < members.length; i++) { |
80 if (members[i].tags("deprecated").length == 0) { |
80 if (members[i].tags("deprecated").length == 0) { |
81 list.add(members[i]); |
81 list.add(members[i]); |
82 } |
82 } |
83 } |
83 } |
370 |
370 |
371 /** |
371 /** |
372 * We want the list of types in alphabetical order. However, types are not |
372 * We want the list of types in alphabetical order. However, types are not |
373 * comparable. We need a comparator for now. |
373 * comparable. We need a comparator for now. |
374 */ |
374 */ |
375 private static class TypeComparator implements Comparator { |
375 private static class TypeComparator implements Comparator<Type> { |
376 public int compare(Object type1, Object type2) { |
376 public int compare(Type type1, Type type2) { |
377 return ((Type) type1).qualifiedTypeName().toLowerCase().compareTo( |
377 return type1.qualifiedTypeName().toLowerCase().compareTo( |
378 ((Type) type2).qualifiedTypeName().toLowerCase()); |
378 type2.qualifiedTypeName().toLowerCase()); |
379 } |
379 } |
380 } |
380 } |
381 |
381 |
382 /** |
382 /** |
383 * For the class return all implemented interfaces including the |
383 * For the class return all implemented interfaces including the |
389 * super interfaces are sought. |
389 * super interfaces are sought. |
390 * @param configuration the current configuration of the doclet. |
390 * @param configuration the current configuration of the doclet. |
391 * @param sort if true, return list of interfaces sorted alphabetically. |
391 * @param sort if true, return list of interfaces sorted alphabetically. |
392 * @return List of all the required interfaces. |
392 * @return List of all the required interfaces. |
393 */ |
393 */ |
394 public static List getAllInterfaces(Type type, |
394 public static List<Type> getAllInterfaces(Type type, |
395 Configuration configuration, boolean sort) { |
395 Configuration configuration, boolean sort) { |
396 Map results = sort ? new TreeMap() : new LinkedHashMap(); |
396 Map<ClassDoc,Type> results = sort ? new TreeMap<ClassDoc,Type>() : new LinkedHashMap<ClassDoc,Type>(); |
397 Type[] interfaceTypes = null; |
397 Type[] interfaceTypes = null; |
398 Type superType = null; |
398 Type superType = null; |
399 if (type instanceof ParameterizedType) { |
399 if (type instanceof ParameterizedType) { |
400 interfaceTypes = ((ParameterizedType) type).interfaceTypes(); |
400 interfaceTypes = ((ParameterizedType) type).interfaceTypes(); |
401 superType = ((ParameterizedType) type).superclassType(); |
401 superType = ((ParameterizedType) type).superclassType(); |
421 Type t = (Type) iter.next(); |
421 Type t = (Type) 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(results.values()); |
426 return new ArrayList<Type>(results.values()); |
427 //Try walking the tree. |
427 //Try walking the tree. |
428 addAllInterfaceTypes(results, |
428 addAllInterfaceTypes(results, |
429 superType, |
429 superType, |
430 superType instanceof ClassDoc ? |
430 superType instanceof ClassDoc ? |
431 ((ClassDoc) superType).interfaceTypes() : |
431 ((ClassDoc) superType).interfaceTypes() : |
432 ((ParameterizedType) superType).interfaceTypes(), |
432 ((ParameterizedType) superType).interfaceTypes(), |
433 false, configuration); |
433 false, configuration); |
434 List resultsList = new ArrayList(results.values()); |
434 List<Type> resultsList = new ArrayList<Type>(results.values()); |
435 if (sort) { |
435 if (sort) { |
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 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 results, ClassDoc c, boolean raw, |
445 private static void findAllInterfaceTypes(Map<ClassDoc,Type> results, ClassDoc c, boolean raw, |
446 Configuration configuration) { |
446 Configuration configuration) { |
447 Type superType = c.superclassType(); |
447 Type superType = c.superclassType(); |
448 if (superType == null) |
448 if (superType == null) |
449 return; |
449 return; |
450 addAllInterfaceTypes(results, superType, |
450 addAllInterfaceTypes(results, superType, |
452 ((ClassDoc) superType).interfaceTypes() : |
452 ((ClassDoc) superType).interfaceTypes() : |
453 ((ParameterizedType) superType).interfaceTypes(), |
453 ((ParameterizedType) superType).interfaceTypes(), |
454 raw, configuration); |
454 raw, configuration); |
455 } |
455 } |
456 |
456 |
457 private static void findAllInterfaceTypes(Map results, ParameterizedType p, |
457 private static void findAllInterfaceTypes(Map<ClassDoc,Type> results, ParameterizedType p, |
458 Configuration configuration) { |
458 Configuration configuration) { |
459 Type superType = p.superclassType(); |
459 Type superType = p.superclassType(); |
460 if (superType == null) |
460 if (superType == null) |
461 return; |
461 return; |
462 addAllInterfaceTypes(results, superType, |
462 addAllInterfaceTypes(results, superType, |
464 ((ClassDoc) superType).interfaceTypes() : |
464 ((ClassDoc) superType).interfaceTypes() : |
465 ((ParameterizedType) superType).interfaceTypes(), |
465 ((ParameterizedType) superType).interfaceTypes(), |
466 false, configuration); |
466 false, configuration); |
467 } |
467 } |
468 |
468 |
469 private static void addAllInterfaceTypes(Map results, Type type, |
469 private static void addAllInterfaceTypes(Map<ClassDoc,Type> results, Type type, |
470 Type[] interfaceTypes, boolean raw, |
470 Type[] interfaceTypes, boolean raw, |
471 Configuration configuration) { |
471 Configuration configuration) { |
472 for (int i = 0; i < interfaceTypes.length; i++) { |
472 for (int i = 0; i < interfaceTypes.length; i++) { |
473 Type interfaceType = interfaceTypes[i]; |
473 Type interfaceType = interfaceTypes[i]; |
474 ClassDoc interfaceClassDoc = interfaceType.asClassDoc(); |
474 ClassDoc interfaceClassDoc = interfaceType.asClassDoc(); |
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 asList(ProgramElementDoc[] members) { |
498 public static List<ProgramElementDoc> asList(ProgramElementDoc[] members) { |
499 List list = new ArrayList(); |
499 List<ProgramElementDoc> list = new ArrayList<ProgramElementDoc>(); |
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 } |
637 * to the end of the last token. |
637 * to the end of the last token. |
638 * |
638 * |
639 * @return an array of tokens. |
639 * @return an array of tokens. |
640 */ |
640 */ |
641 public static String[] tokenize(String s, char separator, int maxTokens) { |
641 public static String[] tokenize(String s, char separator, int maxTokens) { |
642 List tokens = new ArrayList(); |
642 List<String> tokens = new ArrayList<String>(); |
643 StringBuilder token = new StringBuilder (); |
643 StringBuilder token = new StringBuilder (); |
644 boolean prevIsEscapeChar = false; |
644 boolean prevIsEscapeChar = false; |
645 for (int i = 0; i < s.length(); i += Character.charCount(i)) { |
645 for (int i = 0; i < s.length(); i += Character.charCount(i)) { |
646 int currentChar = s.codePointAt(i); |
646 int currentChar = s.codePointAt(i); |
647 if (prevIsEscapeChar) { |
647 if (prevIsEscapeChar) { |