1 5 package xdoclet.modules.triactive.jdo; 6 7 import java.util.ArrayList ; 8 import java.util.Collection ; 9 10 import org.apache.commons.logging.Log; 11 import org.apache.commons.logging.LogFactory; 12 import xjavadoc.XDoc; 13 import xjavadoc.XTag; 14 import xdoclet.XDocletException; 15 import xdoclet.modules.jdo.VendorExtension; 16 import xdoclet.modules.jdo.VendorExtensionsSubTask; 17 18 25 public class TJDOSubTask extends VendorExtensionsSubTask 26 { 27 28 private final static Log LOG = LogFactory.getLog(TJDOSubTask.class); 29 30 private String version = TJDOVersionTypes.VERSION_2_0; 31 32 37 public String getVersion() 38 { 39 return version; 40 } 41 42 46 public String getVendorName() 47 { 48 return "triactive"; 49 } 50 51 public String getVendorDescription() 52 { 53 return "TJDO open source JDO implementation initially developed by Triactive"; 54 } 55 56 62 public void setVersion(TJDOVersionTypes version) 63 { 64 this.version = version.getValue(); 65 } 66 67 71 protected Collection getClassExtensions() throws XDocletException 72 { 73 Collection extensions = new ArrayList (); 74 75 return extensions; 76 } 77 78 83 protected Collection getFieldExtensions() throws XDocletException 84 { 85 Collection extensions = new ArrayList (); 86 XDoc doc = getCurrentField().getDoc(); 87 88 if (doc.hasTag("tjdo.field")) { 89 XTag tag = doc.getTag("tjdo.field"); 90 91 addSizeExtensions(extensions, tag, "column-", ""); 92 93 String collectionField = tag.getAttributeValue("collection-field"); 94 String mapField = tag.getAttributeValue("map-field"); 95 96 if (collectionField != null) { 97 extensions.add(new VendorExtension(getVendorName(), "collection-field", collectionField)); 98 } 99 if (mapField != null) { 100 extensions.add(new VendorExtension(getVendorName(), "map-field", mapField)); 101 } 102 } 103 104 return extensions; 105 } 106 107 protected Collection getCollectionExtensions() throws XDocletException 108 { 109 Collection extensions = new ArrayList (); 110 XDoc doc = getCurrentField().getDoc(); 111 112 if (doc.hasTag("tjdo.field")) { 113 XTag tag = doc.getTag("tjdo.field"); 114 String ownerField = tag.getAttributeValue("owner-field"); 115 116 if (ownerField != null) { 117 extensions.add(new VendorExtension(getVendorName(), "owner-field", ownerField)); 118 } 119 addSizeExtensions(extensions, tag, "element-", ""); 120 } 121 122 return extensions; 123 } 124 125 protected Collection getArrayExtensions() throws XDocletException 126 { 127 Collection extensions = new ArrayList (); 128 129 return extensions; 130 } 131 132 136 protected Collection getMapExtensions() throws XDocletException 137 { 138 Collection extensions = new ArrayList (); 139 XDoc doc = getCurrentField().getDoc(); 140 141 if (doc.hasTag("tjdo.field")) { 142 XTag tag = doc.getTag("tjdo.field"); 143 String ownerField = tag.getAttributeValue("owner-field"); 144 String keyField = tag.getAttributeValue("key-field"); 145 146 if (ownerField != null) { 147 extensions.add(new VendorExtension(getVendorName(), "owner-field", ownerField)); 148 } 149 if (keyField != null) { 150 extensions.add(new VendorExtension(getVendorName(), "key-field", keyField)); 151 } 152 addSizeExtensions(extensions, tag, "key-", "key-"); 153 154 addSizeExtensions(extensions, tag, "value-", "value-"); 155 156 } 157 158 return extensions; 159 } 160 161 protected void addSizeExtensions(Collection extensions, XTag tag, String sourcePrefix, String targetPrefix) 162 { 163 String length = tag.getAttributeValue(sourcePrefix + "length"); 164 String precision = tag.getAttributeValue(sourcePrefix + "precision"); 165 String scale = tag.getAttributeValue(sourcePrefix + "scale"); 166 167 if (length != null) { 168 extensions.add(new VendorExtension(getVendorName(), targetPrefix + "length", length)); 169 } 170 if (precision != null) { 171 extensions.add(new VendorExtension(getVendorName(), targetPrefix + "precision", precision)); 172 } 173 if (scale != null) { 174 extensions.add(new VendorExtension(getVendorName(), targetPrefix + "scale", scale)); 175 } 176 177 } 178 179 182 public static class TJDOVersionTypes extends org.apache.tools.ant.types.EnumeratedAttribute 183 { 184 public final static String VERSION_2_0 = "2.0"; 185 186 191 public String [] getValues() 192 { 193 return new String []{VERSION_2_0}; 194 } 195 } 196 197 } 198 | Popular Tags |