1 5 package xdoclet.modules.doc; 6 7 import java.util.*; 8 9 import xdoclet.XDocletException; 10 import xdoclet.XDocletTagSupport; 11 import xdoclet.template.TemplateEngine; 12 import xdoclet.template.TemplateException; 13 import xdoclet.template.TemplateTagHandler; 14 15 21 public class DocumentationTagsHandler extends XDocletTagSupport 22 { 23 private String currentNamespace; 24 25 33 public void forAllNamespaces(String template) throws XDocletException 34 { 35 for (Iterator iterator = getSortedNameSpaces().iterator(); iterator.hasNext(); ) { 36 currentNamespace = (String ) iterator.next(); 37 38 try { 39 TemplateTagHandler th = TemplateEngine.getEngineInstance().getTagHandlerFor(currentNamespace); 40 41 setCurrentClass(getXJavaDoc().getXClass(th.getClass().getName())); 42 43 generate(template); 44 } 45 catch (TemplateException e) { 46 throw new XDocletException(e, "Error getting tag handler"); 47 } 48 } 49 } 50 51 58 public String namespace() throws XDocletException 59 { 60 return currentNamespace; 61 } 62 63 70 public String namespaceTagsHandlerClassName() throws XDocletException 71 { 72 try { 73 return TemplateEngine.getEngineInstance().getTagHandlerFor(currentNamespace).getClass().getName(); 74 } 75 catch (TemplateException e) { 76 throw new XDocletException(e, "Error getting tag handler for " + currentNamespace); 77 } 78 } 79 80 87 public String namespaceFromClassName() throws XDocletException 88 { 89 for (Iterator iterator = getSortedNameSpaces().iterator(); iterator.hasNext(); ) { 90 String tempNamespace = (String ) iterator.next(); 91 92 try { 93 if (TemplateEngine.getEngineInstance().getTagHandlerFor(tempNamespace).getClass().getName().equals(getCurrentClass().getQualifiedName())) { 94 return tempNamespace; 95 } 96 } 97 catch (TemplateException e) { 98 throw new XDocletException(e, "Error getting tag handler for" + tempNamespace); 99 } 100 } 101 102 return null; 103 } 104 105 112 public String currentNamespace() throws XDocletException 113 { 114 return getActiveDocumentTagsSubTask().getCurrentNamespace(); 115 } 116 117 126 public String currentNamespaceTagsHandlerClassName() throws XDocletException 127 { 128 try { 129 return TemplateEngine.getEngineInstance().getTagHandlerFor(getActiveDocumentTagsSubTask().getCurrentNamespace()).getClass().getName(); 130 } 131 catch (TemplateException e) { 132 throw new XDocletException(e, "Error getting tag handler for " + getActiveDocumentTagsSubTask().getCurrentNamespace()); 133 } 134 } 135 136 145 public String currentNamespaceTagsHandlerClassNameAsDirStructure() throws XDocletException 146 { 147 return currentNamespaceTagsHandlerClassName().replace('.', '/'); 148 } 149 150 private final List getSortedNameSpaces() 151 { 152 ArrayList result = new ArrayList(TemplateEngine.getEngineInstance().getNamespaces()); 153 154 Collections.sort(result); 155 return result; 156 } 157 158 163 private DocumentTagsSubTask getActiveDocumentTagsSubTask() 164 { 165 return (DocumentTagsSubTask) getDocletContext().getActiveSubTask(); 166 } 167 } 168 | Popular Tags |