Source Code Cross Referenced for AntTextReplaceInvocationDefinition.java in  » UML » MetaBoss » com » metaboss » sdlctools » applications » anttasks » builder » tools » 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 » UML » MetaBoss » com.metaboss.sdlctools.applications.anttasks.builder.tools 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002:        // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003:        // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004:        // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005:        // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006:        // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007:        // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008:        // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009:        // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010:        // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011:        // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012:        // POSSIBILITY OF SUCH DAMAGE.
013:        //
014:        // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
015:        package com.metaboss.sdlctools.applications.anttasks.builder.tools;
016:
017:        import java.io.File;
018:        import java.util.Arrays;
019:        import java.util.HashSet;
020:        import java.util.Iterator;
021:        import java.util.Set;
022:
023:        import org.apache.tools.ant.BuildException;
024:        import org.apache.tools.ant.Project;
025:        import org.apache.tools.ant.taskdefs.Replace;
026:        import org.apache.tools.ant.types.PatternSet;
027:
028:        import com.metaboss.sdlctools.applications.anttasks.builder.MetaBossBuilderTask;
029:        import com.metaboss.sdlctools.applications.anttasks.builder.ToolInvocationDefinition;
030:
031:        /** This definition is responsible for invocation of Mkdir standard ant target */
032:        public class AntTextReplaceInvocationDefinition extends
033:                ToolInvocationDefinition {
034:            private String mOldValue = null;
035:            private String mNewValue = null;
036:            public File mFile = null;
037:            public File mDirectory = null;
038:            public Set mDirectoryIncludes = new HashSet();
039:            public Set mDirectoryExcludes = new HashSet();
040:
041:            /** Public constructor for the invocation */
042:            public AntTextReplaceInvocationDefinition(
043:                    MetaBossBuilderTask pOwnerTask, String pTaskName) {
044:                super (pOwnerTask, pTaskName);
045:            }
046:
047:            /** Setter for the old token */
048:            public void setOldValue(String pOldValue) {
049:                mOldValue = pOldValue;
050:            }
051:
052:            /** Gets the old value to replace */
053:            public String getOldValue() {
054:                if (mOldValue == null)
055:                    throw new BuildException(
056:                            "Missing OldValue, which is mandatory for ant task invocation.");
057:                return mOldValue;
058:            }
059:
060:            /** Setter for the new token */
061:            public void setNewValue(String pNewValue) {
062:                mNewValue = pNewValue;
063:            }
064:
065:            /** Gets the new value to replace */
066:            public String getNewValue() {
067:                if (mNewValue == null)
068:                    throw new BuildException(
069:                            "Missing NewValue, which is mandatory for ant task invocation.");
070:                return mNewValue;
071:            }
072:
073:            /** Setter for the file to replace text in */
074:            public void setFile(String pFilePath) {
075:                if (mDirectory != null)
076:                    throw new BuildException(
077:                            "Either File or Directory must be specified, not both.");
078:                mFile = new File(pFilePath).getAbsoluteFile();
079:            }
080:
081:            /** Gets the path of the file to work on */
082:            public File getFile() {
083:                return mFile;
084:            }
085:
086:            /** Adds directory to replace the text in */
087:            public void setDirectory(String pDirectoryPath) {
088:                if (mFile != null)
089:                    throw new BuildException(
090:                            "Either File or Directory must be specified, not both.");
091:                mDirectory = new File(pDirectoryPath).getAbsoluteFile();
092:            }
093:
094:            /** Gets the path of the directory to work on */
095:            public File getDirectory() {
096:                return mDirectory;
097:            }
098:
099:            /** Adds list of includes to the set of includes */
100:            public void addDirectoryIncludes(String[] pIncludes) {
101:                mDirectoryIncludes.addAll(Arrays.asList(pIncludes));
102:            }
103:
104:            /** Adds single include to the set of includes  */
105:            public void addDirectoryInclude(String pInclude) {
106:                mDirectoryIncludes.add(pInclude);
107:            }
108:
109:            /** Adds list of excludes to the set of excludes */
110:            public void addDirectoryExcludes(String[] pExcludes) {
111:                mDirectoryExcludes.addAll(Arrays.asList(pExcludes));
112:            }
113:
114:            /** Adds single exclude to the set of excludes from generated source path */
115:            public void addDirectoryExclude(String pExclude) {
116:                mDirectoryExcludes.add(pExclude);
117:            }
118:
119:            /** Overridden to make it always not equal unless this is exactly the same object */
120:            public boolean equals(Object pOther) {
121:                if (this  == pOther)
122:                    return true;
123:                return false;
124:            }
125:
126:            /** This method will have to invoke the generator */
127:            public void invoke() throws BuildException {
128:                MetaBossBuilderTask lOwnerTask = getOwnerTask();
129:                Project lThisProject = getOwnerTask().getProject();
130:                // Now create and execute the task
131:                Replace lReplaceTask = (Replace) lThisProject
132:                        .createTask("replace");
133:                if (getFile() != null) {
134:                    lReplaceTask.setFile(getFile());
135:                } else if (getDirectory() != null) {
136:                    lReplaceTask.setDir(getDirectory());
137:                    // Work on includes
138:                    for (Iterator lIncludesIterator = mDirectoryIncludes
139:                            .iterator(); lIncludesIterator.hasNext();) {
140:                        PatternSet.NameEntry lIncludeNameEntry = lReplaceTask
141:                                .createInclude();
142:                        lIncludeNameEntry.setName((String) lIncludesIterator
143:                                .next());
144:                    }
145:                    // Work on excludes
146:                    for (Iterator lExcludesIterator = mDirectoryIncludes
147:                            .iterator(); lExcludesIterator.hasNext();) {
148:                        PatternSet.NameEntry lExcludeNameEntry = lReplaceTask
149:                                .createExclude();
150:                        lExcludeNameEntry.setName((String) lExcludesIterator
151:                                .next());
152:                    }
153:                }
154:                lReplaceTask.setToken(getOldValue());
155:                lReplaceTask.setValue(getNewValue());
156:                lReplaceTask.execute();
157:            }
158:        }
w_ww_.___java___2___s___.co__m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.