KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > types > FileSet


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */

18
19 package org.apache.tools.ant.types;
20
21 import java.util.Iterator JavaDoc;
22
23 import org.apache.tools.ant.types.resources.FileResourceIterator;
24
25 /**
26  * Moved out of MatchingTask to make it a standalone object that could
27  * be referenced (by scripts for example).
28  *
29  */

30 public class FileSet extends AbstractFileSet implements ResourceCollection {
31
32     /**
33      * Constructor for FileSet.
34      */

35     public FileSet() {
36         super();
37     }
38
39     /**
40      * Constructor for FileSet, with FileSet to shallowly clone.
41      * @param fileset the fileset to clone
42      */

43     protected FileSet(FileSet fileset) {
44         super(fileset);
45     }
46
47     /**
48      * Return a FileSet that has the same basedir and same patternsets
49      * as this one.
50      * @return the cloned fileset
51      */

52     public Object JavaDoc clone() {
53         if (isReference()) {
54             return ((FileSet) getRef(getProject())).clone();
55         } else {
56             return super.clone();
57         }
58     }
59
60     /**
61      * Fulfill the ResourceCollection contract.
62      * @return an Iterator of Resources.
63      * @since Ant 1.7
64      */

65     public Iterator JavaDoc iterator() {
66         if (isReference()) {
67             return ((FileSet) getRef(getProject())).iterator();
68         }
69         return new FileResourceIterator(getDir(getProject()),
70             getDirectoryScanner(getProject()).getIncludedFiles());
71     }
72
73     /**
74      * Fulfill the ResourceCollection contract.
75      * @return number of elements as int.
76      * @since Ant 1.7
77      */

78     public int size() {
79         if (isReference()) {
80             return ((FileSet) getRef(getProject())).size();
81         }
82         return getDirectoryScanner(getProject()).getIncludedFilesCount();
83     }
84
85     /**
86      * Always returns true.
87      * @return true indicating that all elements will be FileResources.
88      * @since Ant 1.7
89      */

90     public boolean isFilesystemOnly() {
91         return true;
92     }
93
94 }
95
Popular Tags