Source Code Cross Referenced for MatchingTask.java in  » XML-UI » XUI » net » xoetrope » builder » editor » 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 » XML UI » XUI » net.xoetrope.builder.editor.ant.taskdefs 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The Apache Software License, Version 1.1
003:         *
004:         * Copyright (c) 1999 The Apache Software Foundation.  All rights
005:         * reserved.
006:         *
007:         * Redistribution and use in source and binary forms, with or without
008:         * modification, are permitted provided that the following conditions
009:         * are met:
010:         *
011:         * 1. Redistributions of source code must retain the above copyright
012:         *    notice, this list of conditions and the following disclaimer.
013:         *
014:         * 2. Redistributions in binary form must reproduce the above copyright
015:         *    notice, this list of conditions and the following disclaimer in
016:         *    the documentation and/or other materials provided with the
017:         *    distribution.
018:         *
019:         * 3. The end-user documentation included with the redistribution, if
020:         *    any, must include the following acknowlegement:
021:         *       "This product includes software developed by the
022:         *        Apache Software Foundation (http://www.apache.org/)."
023:         *    Alternately, this acknowlegement may appear in the software itself,
024:         *    if and wherever such third-party acknowlegements normally appear.
025:         *
026:         * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
027:         *    Foundation" must not be used to endorse or promote products derived
028:         *    from this software without prior written permission. For written
029:         *    permission, please contact apache@apache.org.
030:         *
031:         * 5. Products derived from this software may not be called "Apache"
032:         *    nor may "Apache" appear in their names without prior written
033:         *    permission of the Apache Group.
034:         *
035:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
036:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
037:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
038:         * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
039:         * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
040:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
041:         * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
042:         * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
043:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
044:         * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
045:         * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
046:         * SUCH DAMAGE.
047:         * ====================================================================
048:         *
049:         * This software consists of voluntary contributions made by many
050:         * individuals on behalf of the Apache Software Foundation.  For more
051:         * information on the Apache Software Foundation, please see
052:         * <http://www.apache.org/>.
053:         *
054:         * Modified for us in XuiEditor
055:         */
056:
057:        package net.xoetrope.builder.editor.ant.taskdefs;
058:
059:        import java.io.File;
060:        import java.util.Enumeration;
061:        import java.util.Hashtable;
062:        import java.util.StringTokenizer;
063:        import java.util.Vector;
064:
065:        import net.xoetrope.builder.editor.ant.DirectoryScanner;
066:        import net.xoetrope.debug.DebugLogger;
067:
068:        /**
069:         * This is an abstract task that should be used by all those tasks that
070:         * require to include or exclude files based on pattern matching.
071:         *
072:         * @author Arnout J. Kuiper <a href="mailto:ajkuiper@wxs.nl">ajkuiper@wxs.nl</a>
073:         * @author Stefano Mazzocchi <a href="mailto:stefano@apache.org">stefano@apache.org</a>
074:         * @author Sam Ruby <a href="mailto:rubys@us.ibm.com">rubys@us.ibm.com</a>
075:         * @author Jon S. Stevens <a href="mailto:jon@clearink.com">jon@clearink.com</a>
076:         */
077:
078:        public abstract class MatchingTask /*extends Task*/
079:        {
080:
081:            protected Vector includeList = new Vector();
082:            protected Vector excludeList = new Vector();
083:            protected boolean useDefaultExcludes = true;
084:            private Hashtable properties = new Hashtable();
085:
086:            /**
087:             * provide access to properties from within the inner class
088:             */
089:            public String getProperty(String name) {
090:                if (name == null)
091:                    return null;
092:                String property = (String) properties.get(name);
093:                return property;
094:            }
095:
096:            /**
097:             * inner class to hold a name on list.  "If" and "Unless" attributes
098:             * may be used to invalidate the entry based on the existence of a
099:             * property (typically set thru the use of the Available task).
100:             */
101:            public class NameEntry {
102:                private boolean valid = true;
103:                private String name;
104:
105:                public String getName() {
106:                    return valid ? name : null;
107:                }
108:
109:                public void setName(String name) {
110:                    this .name = name;
111:                }
112:
113:                public void setIf(String name) {
114:                    if (getProperty(name) == null)
115:                        valid = false;
116:                }
117:
118:                public void setUnless(String name) {
119:                    if (getProperty(name) != null)
120:                        valid = false;
121:                }
122:            }
123:
124:            /**
125:             * add a name entry on the include list
126:             */
127:            public NameEntry createInclude() {
128:                NameEntry result = new NameEntry();
129:                includeList.addElement(result);
130:                return result;
131:            }
132:
133:            /**
134:             * add a name entry on the exclude list
135:             */
136:            public NameEntry createExclude() {
137:                NameEntry result = new NameEntry();
138:                excludeList.addElement(result);
139:                return result;
140:            }
141:
142:            /**
143:             * Sets the set of include patterns. Patterns may be separated by a comma
144:             * or a space.
145:             *
146:             * @param includes the string containing the include patterns
147:             */
148:            public void setIncludes(String includes) {
149:                if (includes != null && includes.length() > 0) {
150:                    createInclude().setName(includes);
151:                }
152:            }
153:
154:            /**
155:             * Set this to be the items in the base directory that you want to be
156:             * included. You can also specify "*" for the items (ie: items="*")
157:             * and it will include all the items in the base directory.
158:             *
159:             * @param itemString the string containing the files to include.
160:             */
161:            public void setItems(String itemString) {
162:                DebugLogger.trace("The items attribute is deprecated. "
163:                        + "Please use the includes attribute.");
164:                if (itemString == null || itemString.equals("*")
165:                        || itemString.equals(".")) {
166:                    createInclude().setName("**");
167:                } else {
168:                    StringTokenizer tok = new StringTokenizer(itemString, ", ");
169:                    while (tok.hasMoreTokens()) {
170:                        String pattern = tok.nextToken().trim();
171:                        if (pattern.length() > 0) {
172:                            createInclude().setName(pattern + "/**");
173:                        }
174:                    }
175:                }
176:            }
177:
178:            /**
179:             * Sets the set of exclude patterns. Patterns may be separated by a comma
180:             * or a space.
181:             *
182:             * @param excludes the string containing the exclude patterns
183:             */
184:            public void setExcludes(String excludes) {
185:                if (excludes != null && excludes.length() > 0) {
186:                    createExclude().setName(excludes);
187:                }
188:            }
189:
190:            /**
191:             * List of filenames and directory names to not include. They should be
192:             * either , or " " (space) separated. The ignored files will be logged.
193:             *
194:             * @param ignoreString the string containing the files to ignore.
195:             */
196:            public void setIgnore(String ignoreString) {
197:                DebugLogger.trace("The ignore attribute is deprecated."
198:                        + "Please use the excludes attribute.");
199:                if (ignoreString != null && ignoreString.length() > 0) {
200:                    Vector tmpExcludes = new Vector();
201:                    StringTokenizer tok = new StringTokenizer(ignoreString,
202:                            ", ", false);
203:                    while (tok.hasMoreTokens()) {
204:                        createExclude().setName(
205:                                "**/" + tok.nextToken().trim() + "/**");
206:                    }
207:                }
208:            }
209:
210:            /**
211:             * Sets whether default exclusions should be used or not.
212:             *
213:             * @param useDefaultExcludes "true"|"on"|"yes" when default exclusions
214:             *                           should be used, "false"|"off"|"no" when they
215:             *                           shouldn't be used.
216:             */
217:            public void setDefaultexcludes(boolean useDefaultExcludes) {
218:                this .useDefaultExcludes = useDefaultExcludes;
219:            }
220:
221:            /**
222:             * Convert a vector of NameEntry elements into an array of Strings.
223:             */
224:            private String[] makeArray(Vector list) {
225:                if (list.size() == 0)
226:                    return null;
227:
228:                Vector tmpNames = new Vector();
229:                for (Enumeration e = list.elements(); e.hasMoreElements();) {
230:                    String includes = ((NameEntry) e.nextElement()).getName();
231:                    if (includes == null)
232:                        continue;
233:                    StringTokenizer tok = new StringTokenizer(includes, ", ",
234:                            false);
235:                    while (tok.hasMoreTokens()) {
236:                        String pattern = tok.nextToken().trim();
237:                        if (pattern.length() > 0) {
238:                            tmpNames.addElement(pattern);
239:                        }
240:                    }
241:                }
242:
243:                String result[] = new String[tmpNames.size()];
244:                for (int i = 0; i < tmpNames.size(); i++) {
245:                    result[i] = (String) tmpNames.elementAt(i);
246:                }
247:
248:                return result;
249:            }
250:
251:            /**
252:             * Returns the directory scanner needed to access the files to process.
253:             */
254:            protected DirectoryScanner getDirectoryScanner(File baseDir) {
255:                DirectoryScanner ds = new DirectoryScanner();
256:                ds.setBasedir(baseDir);
257:                ds.setIncludes(makeArray(includeList));
258:                ds.setExcludes(makeArray(excludeList));
259:                if (useDefaultExcludes)
260:                    ds.addDefaultExcludes();
261:                ds.scan();
262:                return ds;
263:            }
264:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.