langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java
changeset 22163 3651128c74eb
parent 22159 682da512ec17
equal deleted inserted replaced
22162:3b3e23e67329 22163:3651128c74eb
   171      * @param message the message retriever to print warnings.
   171      * @param message the message retriever to print warnings.
   172      */
   172      */
   173     public TagletManager(boolean nosince, boolean showversion,
   173     public TagletManager(boolean nosince, boolean showversion,
   174                          boolean showauthor, boolean javafx,
   174                          boolean showauthor, boolean javafx,
   175                          MessageRetriever message) {
   175                          MessageRetriever message) {
   176         overridenStandardTags = new HashSet<String>();
   176         overridenStandardTags = new HashSet<>();
   177         potentiallyConflictingTags = new HashSet<String>();
   177         potentiallyConflictingTags = new HashSet<>();
   178         standardTags = new HashSet<String>();
   178         standardTags = new HashSet<>();
   179         standardTagsLowercase = new HashSet<String>();
   179         standardTagsLowercase = new HashSet<>();
   180         unseenCustomTags = new HashSet<String>();
   180         unseenCustomTags = new HashSet<>();
   181         customTags = new LinkedHashMap<String,Taglet>();
   181         customTags = new LinkedHashMap<>();
   182         this.nosince = nosince;
   182         this.nosince = nosince;
   183         this.showversion = showversion;
   183         this.showversion = showversion;
   184         this.showauthor = showauthor;
   184         this.showauthor = showauthor;
   185         this.javafx = javafx;
   185         this.javafx = javafx;
   186         this.message = message;
   186         this.message = message;
   233                 tagClassLoader = new URLClassLoader(pathToURLs(cpString));
   233                 tagClassLoader = new URLClassLoader(pathToURLs(cpString));
   234             }
   234             }
   235 
   235 
   236             customTagClass = tagClassLoader.loadClass(classname);
   236             customTagClass = tagClassLoader.loadClass(classname);
   237             Method meth = customTagClass.getMethod("register",
   237             Method meth = customTagClass.getMethod("register",
   238                                                    new Class<?>[] {java.util.Map.class});
   238                                                    Map.class);
   239             Object[] list = customTags.values().toArray();
   239             Object[] list = customTags.values().toArray();
   240             Taglet lastTag = (list != null && list.length > 0)
   240             Taglet lastTag = (list != null && list.length > 0)
   241                 ? (Taglet) list[list.length-1] : null;
   241                 ? (Taglet) list[list.length-1] : null;
   242             meth.invoke(null, new Object[] {customTags});
   242             meth.invoke(null, customTags);
   243             list = customTags.values().toArray();
   243             list = customTags.values().toArray();
   244             Object newLastTag = (list != null&& list.length > 0)
   244             Object newLastTag = (list != null&& list.length > 0)
   245                 ? list[list.length-1] : null;
   245                 ? list[list.length-1] : null;
   246             if (lastTag != newLastTag) {
   246             if (lastTag != newLastTag) {
   247                 //New taglets must always be added to the end of the LinkedHashMap.
   247                 //New taglets must always be added to the end of the LinkedHashMap.
   274      *
   274      *
   275      * @param path the search path string
   275      * @param path the search path string
   276      * @return the resulting array of directory and JAR file URLs
   276      * @return the resulting array of directory and JAR file URLs
   277      */
   277      */
   278     private URL[] pathToURLs(String path) {
   278     private URL[] pathToURLs(String path) {
   279         Set<URL> urls = new LinkedHashSet<URL>();
   279         Set<URL> urls = new LinkedHashSet<>();
   280         for (String s: path.split(File.pathSeparator)) {
   280         for (String s: path.split(File.pathSeparator)) {
   281             if (s.isEmpty()) continue;
   281             if (s.isEmpty()) continue;
   282             try {
   282             try {
   283                 urls.add(new File(s).getAbsoluteFile().toURI().toURL());
   283                 urls.add(new File(s).getAbsoluteFile().toURI().toURL());
   284             } catch (MalformedURLException e) {
   284             } catch (MalformedURLException e) {
   412      * @param taglet the taglet representing the misused tag.
   412      * @param taglet the taglet representing the misused tag.
   413      * @param tag the misused tag.
   413      * @param tag the misused tag.
   414      * @param holderType the type of documentation that the misused tag was found in.
   414      * @param holderType the type of documentation that the misused tag was found in.
   415      */
   415      */
   416     private void printTagMisuseWarn(Taglet taglet, Tag tag, String holderType) {
   416     private void printTagMisuseWarn(Taglet taglet, Tag tag, String holderType) {
   417         Set<String> locationsSet = new LinkedHashSet<String>();
   417         Set<String> locationsSet = new LinkedHashSet<>();
   418         if (taglet.inOverview()) {
   418         if (taglet.inOverview()) {
   419             locationsSet.add("overview");
   419             locationsSet.add("overview");
   420         }
   420         }
   421         if (taglet.inPackage()) {
   421         if (taglet.inPackage()) {
   422             locationsSet.add("package");
   422             locationsSet.add("package");
   580     /**
   580     /**
   581      * Initialize the custom tag arrays.
   581      * Initialize the custom tag arrays.
   582      */
   582      */
   583     private void initCustomTagletArrays() {
   583     private void initCustomTagletArrays() {
   584         Iterator<Taglet> it = customTags.values().iterator();
   584         Iterator<Taglet> it = customTags.values().iterator();
   585         ArrayList<Taglet> pTags = new ArrayList<Taglet>(customTags.size());
   585         ArrayList<Taglet> pTags = new ArrayList<>(customTags.size());
   586         ArrayList<Taglet> tTags = new ArrayList<Taglet>(customTags.size());
   586         ArrayList<Taglet> tTags = new ArrayList<>(customTags.size());
   587         ArrayList<Taglet> fTags = new ArrayList<Taglet>(customTags.size());
   587         ArrayList<Taglet> fTags = new ArrayList<>(customTags.size());
   588         ArrayList<Taglet> cTags = new ArrayList<Taglet>(customTags.size());
   588         ArrayList<Taglet> cTags = new ArrayList<>(customTags.size());
   589         ArrayList<Taglet> mTags = new ArrayList<Taglet>(customTags.size());
   589         ArrayList<Taglet> mTags = new ArrayList<>(customTags.size());
   590         ArrayList<Taglet> iTags = new ArrayList<Taglet>(customTags.size());
   590         ArrayList<Taglet> iTags = new ArrayList<>(customTags.size());
   591         ArrayList<Taglet> oTags = new ArrayList<Taglet>(customTags.size());
   591         ArrayList<Taglet> oTags = new ArrayList<>(customTags.size());
   592         ArrayList<Taglet> sTags = new ArrayList<Taglet>();
   592         ArrayList<Taglet> sTags = new ArrayList<>();
   593         Taglet current;
   593         Taglet current;
   594         while (it.hasNext()) {
   594         while (it.hasNext()) {
   595             current = it.next();
   595             current = it.next();
   596             if (current.inPackage() && !current.isInlineTag()) {
   596             if (current.inPackage() && !current.isInlineTag()) {
   597                 pTags.add(current);
   597                 pTags.add(current);