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