1 19 20 package org.netbeans.modules.s2banttask; 21 22 import java.io.File ; 23 import java.util.StringTokenizer ; 24 25 import org.apache.tools.ant.BuildException; 26 import org.apache.tools.ant.Task; 27 28 import org.netbeans.modules.schema2beansdev.GenBeans; 29 30 37 public class Schema2BeansAntTask extends S2bConfigDelegator { 38 public Schema2BeansAntTask() { 39 super(new GenBeans.Config()); 40 } 41 42 48 public void init() { 49 setAuto(true); 50 setCheckUpToDate(true); 51 setGenerateTimeStamp(false); 52 } 53 54 public void execute() throws BuildException { 55 if (_S2bConfig == null) { 56 throw new BuildException("Invoked for the second time!"); 57 } 58 try { 59 GenBeans.doIt(getConfig()); 60 } catch (java.io.IOException e) { 61 throw new BuildException(e); 62 } catch (org.netbeans.modules.schema2beans.Schema2BeansException e) { 63 throw new BuildException(e); 64 } 65 _S2bConfig = null; 66 } 67 68 protected GenBeans.Config getConfig() { 69 return (GenBeans.Config) _S2bConfig; 70 } 71 72 public void setOutputType(String type) { 73 if ("basebean".equalsIgnoreCase(type)) 74 getConfig().setOutputType(GenBeans.Config.OUTPUT_TRADITIONAL_BASEBEAN); 75 else if ("javabeans".equalsIgnoreCase(type)) 76 getConfig().setOutputType(GenBeans.Config.OUTPUT_JAVABEANS); 77 else 78 throw new RuntimeException ("Incorrect argument to outputType. It must be 'javabeans' or 'basebean'."); 79 } 80 81 public void setSchema(File type) { 82 setFilename(type); 83 } 84 85 public void setPackage(String value) { 86 setPackagePath(value); 87 } 88 89 public void setWriteBeanGraph(File bg) { 90 setWriteBeanGraphFile(bg); 91 } 92 93 public void setReadBeanGraph(File f) { 94 addReadBeanGraphFiles(f); 95 } 96 97 public void setValidate(boolean v) { 98 setGenerateValidate(v); 99 } 100 101 public void setComments(boolean value) { 102 setProcessComments(value); 103 } 104 105 public void setDocType(boolean value) { 106 setProcessDocType(value); 107 } 108 109 public void setDelegator(boolean value) { 110 setGenerateDelegator(value); 111 } 112 113 public void setAttrProp(boolean value) { 114 setAttributesAsProperties(value); 115 } 116 117 public void setCommonInterface(String commonBeanName) { 118 setGenerateCommonInterface(commonBeanName); 119 } 120 121 public void setPropertyEvents(boolean value) { 122 setGeneratePropertyEvents(value); 123 } 124 125 public void setMin(boolean value) { 126 setMinFeatures(value); 127 } 128 129 public void setPremium(boolean value) { 130 if (value) { 131 getConfig().buyPremium(); 132 } 133 } 134 135 public void setStrict(boolean value) { 136 if (value) { 137 getConfig().useStrict(); 138 } 139 } 140 141 145 public void setFinder(String exprList) { 146 StringTokenizer st = new StringTokenizer (exprList, ","); 147 while (st.hasMoreTokens()) { 148 String expr = st.nextToken().trim(); 149 if (expr.equals("")) 150 continue; 151 addFinder(expr); 152 } 153 } 154 } 155 | Popular Tags |