Source Code Cross Referenced for CallTarget.java in  » Build » ANT » org » apache » tools » ant » taskdefs » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Build » ANT » org.apache.tools.ant.taskdefs 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         *
017:         */
018:
019:        package org.apache.tools.ant.taskdefs;
020:
021:        import java.io.IOException;
022:
023:        import org.apache.tools.ant.Task;
024:        import org.apache.tools.ant.BuildException;
025:        import org.apache.tools.ant.types.PropertySet;
026:
027:        /**
028:         * Call another target in the same project.
029:         *
030:         *  <pre>
031:         *    &lt;target name="foo"&gt;
032:         *      &lt;antcall target="bar"&gt;
033:         *        &lt;param name="property1" value="aaaaa" /&gt;
034:         *        &lt;param name="foo" value="baz" /&gt;
035:         *       &lt;/antcall&gt;
036:         *    &lt;/target&gt;
037:         *
038:         *    &lt;target name="bar" depends="init"&gt;
039:         *      &lt;echo message="prop is ${property1} ${foo}" /&gt;
040:         *    &lt;/target&gt;
041:         * </pre>
042:         *
043:         * <p>This only works as expected if neither property1 nor foo are
044:         * defined in the project itself.
045:         *
046:         *
047:         * @since Ant 1.2
048:         *
049:         * @ant.task name="antcall" category="control"
050:         */
051:        public class CallTarget extends Task {
052:
053:            private Ant callee;
054:            // must match the default value of Ant#inheritAll
055:            private boolean inheritAll = true;
056:            // must match the default value of Ant#inheritRefs
057:            private boolean inheritRefs = false;
058:
059:            private boolean targetSet = false;
060:
061:            /**
062:             * If true, pass all properties to the new Ant project.
063:             * Defaults to true.
064:             * @param inherit <code>boolean</code> flag.
065:             */
066:            public void setInheritAll(boolean inherit) {
067:                inheritAll = inherit;
068:            }
069:
070:            /**
071:             * If true, pass all references to the new Ant project.
072:             * Defaults to false.
073:             * @param inheritRefs <code>boolean</code> flag.
074:             */
075:            public void setInheritRefs(boolean inheritRefs) {
076:                this .inheritRefs = inheritRefs;
077:            }
078:
079:            /**
080:             * Initialize this task by creating new instance of the ant task and
081:             * configuring it by calling its own init method.
082:             */
083:            public void init() {
084:                callee = new Ant(this );
085:                callee.init();
086:            }
087:
088:            /**
089:             * Delegate the work to the ant task instance, after setting it up.
090:             * @throws BuildException on validation failure or if the target didn't
091:             * execute.
092:             */
093:            public void execute() throws BuildException {
094:                if (callee == null) {
095:                    init();
096:                }
097:                if (!targetSet) {
098:                    throw new BuildException(
099:                            "Attribute target or at least one nested target is required.",
100:                            getLocation());
101:                }
102:                callee.setAntfile(getProject().getProperty("ant.file"));
103:                callee.setInheritAll(inheritAll);
104:                callee.setInheritRefs(inheritRefs);
105:                callee.execute();
106:            }
107:
108:            /**
109:             * Create a new Property to pass to the invoked target(s).
110:             * @return a <code>Property</code> object.
111:             */
112:            public Property createParam() {
113:                if (callee == null) {
114:                    init();
115:                }
116:                return callee.createProperty();
117:            }
118:
119:            /**
120:             * Reference element identifying a data type to carry
121:             * over to the invoked target.
122:             * @param r the specified <code>Ant.Reference</code>.
123:             * @since Ant 1.5
124:             */
125:            public void addReference(Ant.Reference r) {
126:                if (callee == null) {
127:                    init();
128:                }
129:                callee.addReference(r);
130:            }
131:
132:            /**
133:             * Set of properties to pass to the new project.
134:             * @param ps the <code>PropertySet</code> to pass.
135:             * @since Ant 1.6
136:             */
137:            public void addPropertyset(PropertySet ps) {
138:                if (callee == null) {
139:                    init();
140:                }
141:                callee.addPropertyset(ps);
142:            }
143:
144:            /**
145:             * Set target to execute.
146:             * @param target the name of the target to execute.
147:             */
148:            public void setTarget(String target) {
149:                if (callee == null) {
150:                    init();
151:                }
152:                callee.setTarget(target);
153:                targetSet = true;
154:            }
155:
156:            /**
157:             * Add a target to the list of targets to invoke.
158:             * @param t <code>Ant.TargetElement</code> representing the target.
159:             * @since Ant 1.6.3
160:             */
161:            public void addConfiguredTarget(Ant.TargetElement t) {
162:                if (callee == null) {
163:                    init();
164:                }
165:                callee.addConfiguredTarget(t);
166:                targetSet = true;
167:            }
168:
169:            /**
170:             * Handles output.
171:             * Send it the the new project if is present, otherwise
172:             * call the super class.
173:             * @param output The string output to output.
174:             * @see Task#handleOutput(String)
175:             * @since Ant 1.5
176:             */
177:            public void handleOutput(String output) {
178:                if (callee != null) {
179:                    callee.handleOutput(output);
180:                } else {
181:                    super .handleOutput(output);
182:                }
183:            }
184:
185:            /**
186:             * Handles input.
187:             * Deleate to the created project, if present, otherwise
188:             * call the super class.
189:             * @param buffer the buffer into which data is to be read.
190:             * @param offset the offset into the buffer at which data is stored.
191:             * @param length the amount of data to read.
192:             *
193:             * @return the number of bytes read.
194:             *
195:             * @exception IOException if the data cannot be read.
196:             * @see Task#handleInput(byte[], int, int)
197:             * @since Ant 1.6
198:             */
199:            public int handleInput(byte[] buffer, int offset, int length)
200:                    throws IOException {
201:                if (callee != null) {
202:                    return callee.handleInput(buffer, offset, length);
203:                }
204:                return super .handleInput(buffer, offset, length);
205:            }
206:
207:            /**
208:             * Handles output.
209:             * Send it the the new project if is present, otherwise
210:             * call the super class.
211:             * @param output The string to output.
212:             * @see Task#handleFlush(String)
213:             * @since Ant 1.5.2
214:             */
215:            public void handleFlush(String output) {
216:                if (callee != null) {
217:                    callee.handleFlush(output);
218:                } else {
219:                    super .handleFlush(output);
220:                }
221:            }
222:
223:            /**
224:             * Handle error output.
225:             * Send it the the new project if is present, otherwise
226:             * call the super class.
227:             * @param output The string to output.
228:             *
229:             * @see Task#handleErrorOutput(String)
230:             * @since Ant 1.5
231:             */
232:            public void handleErrorOutput(String output) {
233:                if (callee != null) {
234:                    callee.handleErrorOutput(output);
235:                } else {
236:                    super .handleErrorOutput(output);
237:                }
238:            }
239:
240:            /**
241:             * Handle error output.
242:             * Send it the the new project if is present, otherwise
243:             * call the super class.
244:             * @param output The string to output.
245:             * @see Task#handleErrorFlush(String)
246:             * @since Ant 1.5.2
247:             */
248:            public void handleErrorFlush(String output) {
249:                if (callee != null) {
250:                    callee.handleErrorFlush(output);
251:                } else {
252:                    super.handleErrorFlush(output);
253:                }
254:            }
255:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.