1 5 package xdoclet.modules.jdo; 6 7 import java.util.ArrayList ; 8 9 import java.util.Collection ; 10 import java.util.Iterator ; 11 import java.util.Properties ; 12 13 import xjavadoc.*; 14 15 import xdoclet.SubTask; 16 import xdoclet.XDocletException; 17 import xdoclet.XDocletTagSupport; 18 19 26 public class JdoTagsHandler extends XDocletTagSupport 27 { 28 29 private Collection _extensions; 30 private VendorExtension _currentExtension; 31 32 43 public void forAllPackages(String template, Properties attributes) throws XDocletException 44 { 45 if (getCurrentPackage() == null) { 46 Collection packages = getXJavaDoc().getSourcePackages(); 47 48 for (Iterator i = packages.iterator(); i.hasNext(); ) { 49 XPackage pakkage = (XPackage) i.next(); 50 51 setCurrentPackage(pakkage); 52 53 Collection classes = getCurrentPackage().getClasses(); 54 55 for (Iterator j = classes.iterator(); j.hasNext(); ) { 56 XDoc doc = ((XClass) j.next()).getDoc(); 57 58 if (doc.hasTag("jdo.persistence-capable")) { 59 generate(template); 60 break; 61 } 62 } 63 setCurrentPackage(null); 64 } 65 } 66 else { 67 Collection classes = getCurrentPackage().getClasses(); 68 69 for (Iterator j = classes.iterator(); j.hasNext(); ) { 70 XDoc doc = ((XClass) j.next()).getDoc(); 71 72 if (doc.hasTag("jdo.persistence-capable")) { 73 generate(template); 74 break; 75 } 76 } 77 } 78 } 79 80 88 public void forAllClassesInPackage(String template, Properties attributes) throws XDocletException 89 { 90 if (getCurrentClass() == null) { 91 92 Collection classes = getCurrentPackage().getClasses(); 93 94 for (Iterator i = classes.iterator(); i.hasNext(); ) { 95 setCurrentClass((XClass) i.next()); 96 generate(template); 97 } 98 } 99 else { 100 generate(template); 101 } 102 103 } 104 105 115 public void forAllVendorExtensions(String template, Properties attributes) throws XDocletException 116 { 117 String level = attributes.getProperty("level"); 118 SubTask[] subtasks = getDocletContext().getSubTasks(); 119 120 _extensions = new ArrayList (); 121 for (int i = 0; i < subtasks.length; i++) { 122 if (subtasks[i] instanceof VendorExtensionsSubTask) { 123 VendorExtensionsSubTask vendorExtensionsTask = (VendorExtensionsSubTask) subtasks[i]; 124 125 _extensions.addAll(vendorExtensionsTask.getExtensions(level)); 126 } 127 } 128 129 for (Iterator i = _extensions.iterator(); i.hasNext(); ) { 130 setCurrentVendorExtension((VendorExtension) i.next()); 131 generate(template); 132 } 133 } 134 135 142 public String vendorExtension(Properties attributes) 143 { 144 StringBuffer tags = new StringBuffer (); 145 146 tags.append("<extension vendor-name=\""); 147 tags.append(_currentExtension.getVendor()); 148 tags.append("\" key=\""); 149 tags.append(_currentExtension.getKey()); 150 tags.append("\" value=\""); 151 tags.append(_currentExtension.getValue()); 152 tags.append("\""); 153 if (_currentExtension.hasNestedExtensions()) { 154 tags.append(">"); 155 for (Iterator i = _currentExtension.nestedExtensionsIterator(); i.hasNext(); ) { 156 VendorExtension popVendorExtension = _currentExtension; 157 158 setCurrentVendorExtension((VendorExtension) i.next()); 159 tags.append(vendorExtension(attributes)); 160 setCurrentVendorExtension(popVendorExtension); 161 } 162 tags.append("</extension>"); 163 } 164 else { 165 tags.append("/>"); 166 } 167 return tags.toString(); 168 } 169 170 protected void setCurrentVendorExtension(VendorExtension vendorExtension) 171 { 172 _currentExtension = vendorExtension; 173 } 174 175 } 176 | Popular Tags |