1 5 package xdoclet.modules.maven; 6 7 import java.util.Iterator ; 8 import java.util.List ; 9 import xjavadoc.XClass; 10 import xjavadoc.XParameter; 11 12 import xdoclet.XDocletException; 13 import xdoclet.modules.doc.AntdocSubTask; 14 import xdoclet.modules.doc.AntdocTagsHandler; 15 import xdoclet.tagshandler.TypeTagsHandler; 16 17 25 public class MavenpluginTagsHandler extends AntdocTagsHandler 26 { 27 private List tasks; 28 29 private static boolean isNestedElementParameter(XParameter parameter) 30 { 31 return TypeTagsHandler.isPrimitiveType(parameter.getType().getQualifiedName()) == false && 32 parameter.getType().getQualifiedName().startsWith("xjavadoc") == false && 33 parameter.getType().getQualifiedName().startsWith("java") == false; 34 } 35 36 public List getTasks() 37 { 38 return tasks; 39 } 40 41 public void setTasks(List tasks) 42 { 43 this.tasks = tasks; 44 } 45 46 public void forAllTasks(String template) throws XDocletException 47 { 48 XClass old_cur_class = getCurrentClass(); 49 50 for (Iterator i = getTasks().iterator(); i.hasNext(); ) { 51 docElement = (AntdocSubTask.Element) i.next(); 52 53 setCurrentClass(docElement.getXClass()); 54 55 generate(template); 56 } 57 58 setCurrentClass(old_cur_class); 59 } 60 61 public void ifIsASubTask(String template) throws XDocletException 62 { 63 ifIsASubTask_Impl(template, true); 64 } 65 66 public void ifIsNotASubTask(String template) throws XDocletException 67 { 68 ifIsASubTask_Impl(template, false); 69 } 70 71 public void ifIsAFileSet(String template) throws XDocletException 72 { 73 ifIsAFileSet_Impl(template, true); 74 } 75 76 public void ifIsNotAFileSet(String template) throws XDocletException 77 { 78 ifIsAFileSet_Impl(template, false); 79 } 80 81 public void ifIsAConfigParam(String template) throws XDocletException 82 { 83 if (subElement.getXClass().isA("xdoclet.ConfigParameter")) 84 generate(template); 85 } 86 87 public void ifIsANestedElement(String template) throws XDocletException 88 { 89 ifIsANestedElement_Impl(template, true); 90 } 91 92 public String nestedElementName() throws XDocletException 93 { 94 return getCurrentMethod().getName().substring(3); 95 } 96 97 public String nestedElementType() throws XDocletException 98 { 99 for (Iterator i = getCurrentMethod().getParameters().iterator(); i.hasNext(); ) { 100 XParameter parameter = (XParameter) i.next(); 101 102 return parameter.getType().getQualifiedName(); 103 } 104 105 return ""; 106 } 107 108 public String moduleName() throws XDocletException 109 { 110 String elementName = elementName(); 111 112 return elementName.substring(0, elementName.indexOf("doclet")); 113 } 114 115 public void ifIsNotANestedElement(String template) throws XDocletException 116 { 117 ifIsANestedElement_Impl(template, false); 118 } 119 120 private void ifIsASubTask_Impl(String template, boolean condition) throws XDocletException 121 { 122 if (subElement.isDynamicSubElement() == condition) 123 generate(template); 124 } 125 126 private void ifIsAFileSet_Impl(String template, boolean condition) throws XDocletException 127 { 128 if (subElement.getXClass().isA("org.apache.tools.ant.types.FileSet") == condition) 129 generate(template); 130 } 131 132 private void ifIsANestedElement_Impl(String template, boolean condition) throws XDocletException 133 { 134 if ((getCurrentMethod().getName().startsWith("set") || getCurrentMethod().getName().startsWith("add")) && getCurrentMethod().getParameters().size() == 1) { 135 136 for (Iterator i = getCurrentMethod().getParameters().iterator(); i.hasNext(); ) { 137 XParameter parameter = (XParameter) i.next(); 138 139 if (isNestedElementParameter(parameter) == condition) { 140 generate(template); 141 } 142 } 143 } 144 } 145 } 146 | Popular Tags |