Source Code Cross Referenced for FileList.java in  » Build » ANT » org » apache » tools » ant » types » 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.types 
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.types;
020:
021:        import java.io.File;
022:        import java.util.StringTokenizer;
023:        import java.util.Vector;
024:        import java.util.Iterator;
025:
026:        import org.apache.tools.ant.Project;
027:        import org.apache.tools.ant.BuildException;
028:        import org.apache.tools.ant.types.resources.FileResourceIterator;
029:
030:        /**
031:         * FileList represents an explicitly named list of files.  FileLists
032:         * are useful when you want to capture a list of files regardless of
033:         * whether they currently exist.  By contrast, FileSet operates as a
034:         * filter, only returning the name of a matched file if it currently
035:         * exists in the file system.
036:         */
037:        public class FileList extends DataType implements  ResourceCollection {
038:
039:            private Vector filenames = new Vector();
040:            private File dir;
041:
042:            /**
043:             * The default constructor.
044:             *
045:             */
046:            public FileList() {
047:                super ();
048:            }
049:
050:            /**
051:             * A copy constructor.
052:             *
053:             * @param filelist a <code>FileList</code> value
054:             */
055:            protected FileList(FileList filelist) {
056:                this .dir = filelist.dir;
057:                this .filenames = filelist.filenames;
058:                setProject(filelist.getProject());
059:            }
060:
061:            /**
062:             * Makes this instance in effect a reference to another FileList
063:             * instance.
064:             *
065:             * <p>You must not set another attribute or nest elements inside
066:             * this element if you make it a reference.</p>
067:             * @param r the reference to another filelist.
068:             * @exception BuildException if an error occurs.
069:             */
070:            public void setRefid(Reference r) throws BuildException {
071:                if ((dir != null) || (filenames.size() != 0)) {
072:                    throw tooManyAttributes();
073:                }
074:                super .setRefid(r);
075:            }
076:
077:            /**
078:             * Set the dir attribute.
079:             *
080:             * @param dir the directory this filelist is relative to.
081:             * @exception BuildException if an error occurs
082:             */
083:            public void setDir(File dir) throws BuildException {
084:                checkAttributesAllowed();
085:                this .dir = dir;
086:            }
087:
088:            /**
089:             * @param p the current project
090:             * @return the directory attribute
091:             */
092:            public File getDir(Project p) {
093:                if (isReference()) {
094:                    return getRef(p).getDir(p);
095:                }
096:                return dir;
097:            }
098:
099:            /**
100:             * Set the filenames attribute.
101:             *
102:             * @param filenames a string contains filenames, separated by , or
103:             *        by whitespace.
104:             */
105:            public void setFiles(String filenames) {
106:                checkAttributesAllowed();
107:                if (filenames != null && filenames.length() > 0) {
108:                    StringTokenizer tok = new StringTokenizer(filenames,
109:                            ", \t\n\r\f", false);
110:                    while (tok.hasMoreTokens()) {
111:                        this .filenames.addElement(tok.nextToken());
112:                    }
113:                }
114:            }
115:
116:            /**
117:             * Returns the list of files represented by this FileList.
118:             * @param p the current project
119:             * @return the list of files represented by this FileList.
120:             */
121:            public String[] getFiles(Project p) {
122:                if (isReference()) {
123:                    return getRef(p).getFiles(p);
124:                }
125:
126:                if (dir == null) {
127:                    throw new BuildException(
128:                            "No directory specified for filelist.");
129:                }
130:
131:                if (filenames.size() == 0) {
132:                    throw new BuildException("No files specified for filelist.");
133:                }
134:
135:                String[] result = new String[filenames.size()];
136:                filenames.copyInto(result);
137:                return result;
138:            }
139:
140:            /**
141:             * Performs the check for circular references and returns the
142:             * referenced FileList.
143:             * @param p the current project
144:             * @return the FileList represented by a referenced filelist.
145:             */
146:            protected FileList getRef(Project p) {
147:                return (FileList) getCheckedRef(p);
148:            }
149:
150:            /**
151:             * Inner class corresponding to the &lt;file&gt; nested element.
152:             */
153:            public static class FileName {
154:                private String name;
155:
156:                /**
157:                 * The name attribute of the file element.
158:                 *
159:                 * @param name the name of a file to add to the file list.
160:                 */
161:                public void setName(String name) {
162:                    this .name = name;
163:                }
164:
165:                /**
166:                 * @return the name of the file for this element.
167:                 */
168:                public String getName() {
169:                    return name;
170:                }
171:            }
172:
173:            /**
174:             * Add a nested &lt;file&gt; nested element.
175:             *
176:             * @param name a configured file element with a name.
177:             * @since Ant 1.6.2
178:             */
179:            public void addConfiguredFile(FileName name) {
180:                if (name.getName() == null) {
181:                    throw new BuildException(
182:                            "No name specified in nested file element");
183:                }
184:                filenames.addElement(name.getName());
185:            }
186:
187:            /**
188:             * Fulfill the ResourceCollection contract.
189:             * @return an Iterator of Resources.
190:             * @since Ant 1.7
191:             */
192:            public Iterator iterator() {
193:                if (isReference()) {
194:                    return ((FileList) getRef(getProject())).iterator();
195:                }
196:                return new FileResourceIterator(dir, (String[]) (filenames
197:                        .toArray(new String[filenames.size()])));
198:            }
199:
200:            /**
201:             * Fulfill the ResourceCollection contract.
202:             * @return number of elements as int.
203:             * @since Ant 1.7
204:             */
205:            public int size() {
206:                if (isReference()) {
207:                    return ((FileList) getRef(getProject())).size();
208:                }
209:                return filenames.size();
210:            }
211:
212:            /**
213:             * Always returns true.
214:             * @return true indicating that all elements will be FileResources.
215:             * @since Ant 1.7
216:             */
217:            public boolean isFilesystemOnly() {
218:                return true;
219:            }
220:
221:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.