1 /* 2 * Redistribution and use of this software and associated documentation ("Software"), with or 3 * without modification, are permitted provided that the following conditions are met: 4 * 5 * 1. Redistributions of source code must retain copyright statements and notices. Redistributions 6 * must also contain a copy of this document. 7 * 8 * 2. Redistributions in binary form must reproduce the above copyright notice, this list of 9 * conditions and the following disclaimer in the documentation and/or other materials provided with 10 * the distribution. 11 * 12 * 3. The name "Exolab" must not be used to endorse or promote products derived from this Software 13 * without prior written permission of Intalio, Inc. For written permission, please contact 14 * info@exolab.org. 15 * 16 * 4. Products derived from this Software may not be called "Exolab" nor may "Exolab" appear in 17 * their names without prior written permission of Intalio, Inc. Exolab is a registered trademark of 18 * Intalio, Inc. 19 * 20 * 5. Due credit should be given to the Exolab Project (http://www.exolab.org/). 21 * 22 * THIS SOFTWARE IS PROVIDED BY INTALIO, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR 23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 24 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTALIO, INC. OR ITS 25 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY 29 * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * 31 * Copyright 2004 (C) Intalio, Inc. All Rights Reserved. 32 * 33 * $Id: CastorSourceGenTask.java 6410 2006-11-17 12:06:24Z wguttmn $ 34 */ 35 package org.exolab.castor.tools.ant.taskdefs; 36 37 import java.io.File; 38 39 import org.apache.tools.ant.taskdefs.MatchingTask; 40 import org.apache.tools.ant.types.FileSet; 41 import org.castor.anttask.CastorCodeGenTask; 42 43 /** 44 * An <a href="http://ant.apache.org/">Ant</a> task to call the Castor Source Generator. It can be 45 * passed a file, a directory, a Fileset or all three. 46 * 47 * @author <a href="mailto:joel DOT farquhar AT montage-dmc DOT com">Joel Farquhar</a> 48 * @author <a href="mailto:ferret AT frii DOT com">Bruce Snyder</a> 49 * @version $Revision: 6543 $ $Date: 2005-03-05 06:42:06 -0700 (Sat, 05 Mar 2005) $ 50 * @deprecated Please use {@link org.castor.anttask.CastorCodeGenTask} instead. 51 */ 52 public final class CastorSourceGenTask extends MatchingTask { 53 54 /** CastorCodeGenTask to delegate all work to. */ 55 private final CastorCodeGenTask _codeGen = new CastorCodeGenTask(); 56 57 /** 58 * No-arg constructor. 59 */ 60 public CastorSourceGenTask() {} 61 62 /** 63 * Sets the individual schema that will have code generated for it. 64 * 65 * @param file One schema file. 66 */ 67 public void setFile(final File file) { 68 _codeGen.setFile(file); 69 } 70 71 /** 72 * Sets the directory such that all schemas in this directory will have code generated for them. 73 * 74 * @param dir The directory containing schemas to process. 75 */ 76 public void setDir(final File dir) { 77 _codeGen.setDir(dir); 78 } 79 80 /** 81 * Adds a fileset to process that contains schemas to process. 82 * 83 * @param set An individual file set containing schemas. 84 */ 85 public void addFileset(final FileSet set) { 86 _codeGen.addFileset(set); 87 } 88 89 /** 90 * Sets the package that generated code will belong to. 91 * 92 * @param pack The package that generated code will belong to. 93 */ 94 public void setPackage(final String pack) { 95 _codeGen.setPackage(pack); 96 } 97 98 /** 99 * Sets the directory into which code will be generated. 100 * 101 * @param dest The directory into which code will be generated. 102 */ 103 public void setTodir(final String dest) { 104 _codeGen.setTodir(dest); 105 } 106 107 /** 108 * Sets the binding file to be used for code generation. 109 * 110 * @param bindingfile The binding file to be used for code generation. 111 */ 112 public void setBindingfile(final String bindingfile) { 113 _codeGen.setBindingfile(bindingfile); 114 } 115 116 /** 117 * Sets the line seperator to use for code generation. 118 * 119 * @param ls The line seperator to use for code generation. 120 */ 121 public void setLineseparator(final String ls) { 122 _codeGen.setLineseparator(ls); 123 } 124 125 /** 126 * Sets the type factory for code generation. 127 * 128 * @param tf The type factory to use for code generation. 129 */ 130 public void setTypes(final String tf) { 131 _codeGen.setTypes(tf); 132 } 133 134 /** 135 * Sets whether or not code generation gives extra information about its work. 136 * 137 * @param b If true, the code generator will be verbose. 138 */ 139 public void setVerbose(final boolean b) { 140 _codeGen.setVerbose(b); 141 } 142 143 /** 144 * Sets whether or not non-fatal warnings should be suppressed. 145 * 146 * @param b If true, non-fatal warnings will be suppressed. This additionally means that existing 147 * source files will be silently overwritten. 148 */ 149 public void setWarnings(final boolean b) { 150 _codeGen.setWarnings(b); 151 } 152 153 /** 154 * Sets whether or not class descriptors are generated. 155 * 156 * @param b If true, class descriptors are generated. 157 */ 158 public void setNodesc(final boolean b) { 159 _codeGen.setNodesc(b); 160 } 161 162 /** 163 * Sets whether or not marshaling methods are generated. 164 * 165 * @param b If true, marshaling methods are generated. 166 * @deprecated For the correct spelling, see {@link #setNomarshal(boolean)}. 167 */ 168 public void setNomarshall(final boolean b) { 169 _codeGen.setNomarshal(b); 170 } 171 172 /** 173 * Sets whether or not marshaling methods are generated. 174 * 175 * @param b If true, marshaling methods are generated. 176 */ 177 public void setNomarshal(final boolean b) { 178 _codeGen.setNomarshal(b); 179 } 180 181 /** 182 * Sets whether CTF framework code is generated. 183 * 184 * @param b If true, the generated code will be instrumented for the CTF. 185 */ 186 public void setTestable(final boolean b) { 187 _codeGen.setTestable(b); 188 } 189 190 /** 191 * Controls whether to generate code for imported schemas as well. 192 * 193 * @param generateImportedSchemas True if code should be generated for imported schemas. 194 */ 195 public void setGenerateImportedSchemas(final boolean generateImportedSchemas) { 196 _codeGen.setGenerateImportedSchemas(generateImportedSchemas); 197 } 198 199 /** 200 * Controls whether to generate SAX-1 compliant code. 201 * 202 * @param sax1 True if SAX-1 compliant code should be generated. 203 */ 204 public void setSAX1(final boolean sax1) { 205 _codeGen.setSAX1(sax1); 206 } 207 208 /** 209 * Controls whether enumerated type lookup should be performed in a case insensitive manner. 210 * 211 * @param caseInsensitive True if enumerated type lookup should be performed in a case insensitive 212 * manner 213 */ 214 public void setCaseInsensitive(final boolean caseInsensitive) { 215 _codeGen.setCaseInsensitive(caseInsensitive); 216 } 217 218 /** 219 * Sets the file to use for castor builder properties. 220 * 221 * @param properties The properties to use. 222 */ 223 public void setProperties(final String properties) { 224 _codeGen.setProperties(properties); 225 } 226 227 /** 228 * Public execute method -- entry point for the Ant task. Loops over all schema that need code 229 * generated and creates needed code generators, then executes them. If anything goes wrong during 230 * execution of the Ant task a BuildException will be thrown. 231 * 232 * @see org.apache.tools.ant.Task#execute() 233 */ 234 public void execute() { 235 System.out.println("The class org.exolab.castor.tools.ant.taskdefs.CastorSourceGenTask " 236 + "has been deprecated. Please use org.castor.anttask.CastorCodeGenTask instead."); 237 System.out.println(); 238 239 _codeGen.execute(); 240 } 241 242 243 }