< prev index next >

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletManager.java

Print this page




 235      * @param classname  the name of the class representing the custom tag.
 236      * @param fileManager the filemanager to load classes and resources.
 237      * @param tagletPath  the path to the class representing the custom tag.
 238      */
 239     public void addCustomTag(String classname, JavaFileManager fileManager, String tagletPath) {
 240         try {
 241             ClassLoader tagClassLoader = null;
 242             if (!fileManager.hasLocation(TAGLET_PATH)) {
 243                 List<File> paths = new ArrayList<>();
 244                 if (tagletPath != null) {
 245                     for (String pathname : tagletPath.split(File.pathSeparator)) {
 246                         paths.add(new File(pathname));
 247                     }
 248                 }
 249                 if (fileManager instanceof StandardJavaFileManager) {
 250                     ((StandardJavaFileManager) fileManager).setLocation(TAGLET_PATH, paths);
 251                 }
 252             }
 253             tagClassLoader = fileManager.getClassLoader(TAGLET_PATH);
 254             Class<?> customTagClass = tagClassLoader.loadClass(classname);
 255             @SuppressWarnings("deprecation")
 256             Object instance = customTagClass.newInstance();
 257             Taglet newLegacy = new UserTaglet((jdk.javadoc.doclet.taglet.Taglet)instance);
 258             String tname = newLegacy.getName();
 259             Taglet t = customTags.get(tname);
 260             if (t != null) {
 261                 customTags.remove(tname);
 262             }
 263             customTags.put(tname, newLegacy);
 264             message.notice("doclet.Notice_taglet_registered", classname);
 265         } catch (Exception exc) {
 266             message.error("doclet.Error_taglet_not_registered", exc.getClass().getName(), classname);
 267         }
 268     }
 269 
 270     /**
 271      * Add a new <code>SimpleTaglet</code>.  If this tag already exists
 272      * and the header passed as an argument is null, move tag to the back of the
 273      * list. If this tag already exists and the header passed as an argument is
 274      * not null, overwrite previous tag with new one.  Otherwise, add new
 275      * SimpleTaglet to list.
 276      * @param tagName the name of this tag




 235      * @param classname  the name of the class representing the custom tag.
 236      * @param fileManager the filemanager to load classes and resources.
 237      * @param tagletPath  the path to the class representing the custom tag.
 238      */
 239     public void addCustomTag(String classname, JavaFileManager fileManager, String tagletPath) {
 240         try {
 241             ClassLoader tagClassLoader = null;
 242             if (!fileManager.hasLocation(TAGLET_PATH)) {
 243                 List<File> paths = new ArrayList<>();
 244                 if (tagletPath != null) {
 245                     for (String pathname : tagletPath.split(File.pathSeparator)) {
 246                         paths.add(new File(pathname));
 247                     }
 248                 }
 249                 if (fileManager instanceof StandardJavaFileManager) {
 250                     ((StandardJavaFileManager) fileManager).setLocation(TAGLET_PATH, paths);
 251                 }
 252             }
 253             tagClassLoader = fileManager.getClassLoader(TAGLET_PATH);
 254             Class<?> customTagClass = tagClassLoader.loadClass(classname);
 255             Object instance = customTagClass.getConstructor(new Class<?>[0]).newInstance((Object[])null);

 256             Taglet newLegacy = new UserTaglet((jdk.javadoc.doclet.taglet.Taglet)instance);
 257             String tname = newLegacy.getName();
 258             Taglet t = customTags.get(tname);
 259             if (t != null) {
 260                 customTags.remove(tname);
 261             }
 262             customTags.put(tname, newLegacy);
 263             message.notice("doclet.Notice_taglet_registered", classname);
 264         } catch (Exception exc) {
 265             message.error("doclet.Error_taglet_not_registered", exc.getClass().getName(), classname);
 266         }
 267     }
 268 
 269     /**
 270      * Add a new <code>SimpleTaglet</code>.  If this tag already exists
 271      * and the header passed as an argument is null, move tag to the back of the
 272      * list. If this tag already exists and the header passed as an argument is
 273      * not null, overwrite previous tag with new one.  Otherwise, add new
 274      * SimpleTaglet to list.
 275      * @param tagName the name of this tag


< prev index next >