- private class DocletOptionTaglet
- extends DocletOption
- {
- DocletOptionTaglet(String optionName)
- {
- super(optionName);
- }
-
- public int getLength()
- {
- return 2;
- }
-
- public boolean set(String[] optionArr)
- {
-
- boolean tagletLoaded = false;
-
- String useTagletPath = AbstractDoclet.this.tagletPath;
- if (null == useTagletPath) {
- useTagletPath = System.getProperty("java.class.path");
- }
-
- try {
- Class tagletClass;
- try {
- tagletClass
- = new FileSystemClassLoader(useTagletPath).loadClass(optionArr[1]);
- }
- catch (ClassNotFoundException e) {
- // If not found on specified tagletpath, try default classloader
- tagletClass
- = Class.forName(optionArr[1]);
- }
- Method registerTagletMethod
- = tagletClass.getDeclaredMethod("register", new Class[] { java.util.Map.class });
-
- if (!registerTagletMethod.getReturnType().equals(Void.TYPE)) {
- printError("Taglet class '" + optionArr[1] + "' found, but register method doesn't return void.");
- }
- else if (registerTagletMethod.getExceptionTypes().length > 0) {
- printError("Taglet class '" + optionArr[1] + "' found, but register method contains throws clause.");
- }
- else if ((registerTagletMethod.getModifiers() & (Modifier.STATIC | Modifier.PUBLIC | Modifier.ABSTRACT)) != (Modifier.STATIC | Modifier.PUBLIC)) {
- printError("Taglet class '" + optionArr[1] + "' found, but register method isn't public static, or is abstract..");
- }
- else {
- Map tempMap = new HashMap();
- registerTagletMethod.invoke(null, new Object[] { tempMap });
- tagletLoaded = true;
- String name = (String)tempMap.keySet().iterator().next();
- Taglet taglet = (Taglet)tempMap.get(name);
- tagletMap.put(name, taglet);
- mentionedTags.add(taglet);
- }
- }
- catch (NoSuchMethodException e) {
- printError("Taglet class '" + optionArr[1] + "' found, but doesn't contain the register method.");
- }
- catch (SecurityException e) {
- printError("Taglet class '" + optionArr[1] + "' cannot be loaded: " + e.getMessage());
- }
- catch (InvocationTargetException e) {
- printError("Taglet class '" + optionArr[1] + "' found, but register method throws exception: " + e.toString());
- }
- catch (IllegalAccessException e) {
- printError("Taglet class '" + optionArr[1] + "' found, but there was a problem when accessing the register method: " + e.toString());
- }
- catch (IllegalArgumentException e) {
- printError("Taglet class '" + optionArr[1] + "' found, but there was a problem when accessing the register method: " + e.toString());
- }
- catch (ClassNotFoundException e) {
- printError("Taglet class '" + optionArr[1] + "' cannot be found.");
- }
- return tagletLoaded;
- }
- }
-