KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > junit > output > antutils > FileSet


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.junit.output.antutils;
21
22 import java.io.File JavaDoc;
23 import java.util.Collection JavaDoc;
24 import org.apache.tools.ant.module.spi.TaskStructure;
25
26 /**
27  *
28  * @author Marian Petras
29  */

30 final class FileSet {
31
32     /** */
33     private final AntProject project;
34     
35     /** */
36     private PatternSet implicitPatternSet;
37     /** */
38     private File JavaDoc baseDir;
39     /** */
40     private File JavaDoc file;
41     /** */
42     private boolean defaultExcludes = true;
43     /** */
44     private boolean caseSensitive = true;
45     /** */
46     private boolean followSymlinks;
47
48     /**
49      */

50     FileSet(AntProject project) {
51         this.project = project;
52     }
53
54     /**
55      *
56      */

57     void handleChildrenAndAttrs(TaskStructure struct) {
58         /*
59          * Only FileSet-specific attributes are handled by setAttrs(struct).
60          * Attributes of the implicit pattern set are handled by the call of
61          * implicitPatternSet.handleChildrenAndAttrs(struct) below.
62          */

63         setAttrs(struct);
64         
65         /* Handles PatternSet-like children and attributes: */
66         implicitPatternSet = new PatternSet(project);
67         implicitPatternSet.handleChildrenAndAttrs(struct);
68     }
69     
70     /**
71      * Handles this {@code FileSet}'s attributes.
72      *
73      * @param struct XML element corresponding to this {@code FileSet}
74      */

75     private void setAttrs(TaskStructure struct) {
76         String JavaDoc dirName = struct.getAttribute("dir"); //NOI18N
77
String JavaDoc fileName = struct.getAttribute("file"); //NOI18N
78
String JavaDoc defaultExcludes = struct.getAttribute("defaultexcludes");//NOI18N
79
String JavaDoc caseSensitive = struct.getAttribute("casesensitive"); //NOI18N
80
String JavaDoc followSymlinks = struct.getAttribute("followsymlinks"); //NOI18N
81

82         if (dirName != null) {
83             dirName = project.replaceProperties(dirName);
84             setBaseDir(project.resolveFile(dirName));
85         }
86         if (fileName != null) {
87             fileName = project.replaceProperties(fileName);
88             setFile(project.resolveFile(fileName));
89         }
90         if (defaultExcludes != null) {
91             defaultExcludes = project.replaceProperties(defaultExcludes);
92             setDefaultExcludes(AntProject.toBoolean(defaultExcludes));
93         }
94         if (caseSensitive != null) {
95             caseSensitive = project.replaceProperties(caseSensitive);
96             setCaseSensitive(AntProject.toBoolean(caseSensitive));
97         }
98         if (followSymlinks != null) {
99             followSymlinks = project.replaceProperties(followSymlinks);
100             setFollowSymlinks(AntProject.toBoolean(followSymlinks));
101         }
102     }
103     
104     /**
105      */

106     private void setBaseDir(File JavaDoc baseDir) {
107         this.baseDir = baseDir;
108     }
109     
110     /**
111      */

112     private void setFile(File JavaDoc file) {
113         this.file = file;
114     }
115     
116     /**
117      */

118     private void setDefaultExcludes(boolean defaultExcludes) {
119         this.defaultExcludes = defaultExcludes;
120     }
121     
122     /**
123      */

124     private void setCaseSensitive(boolean caseSensitive) {
125         this.caseSensitive = caseSensitive;
126     }
127     
128     /**
129      */

130     private void setFollowSymlinks(boolean followSymlinks) {
131         this.followSymlinks = followSymlinks;
132     }
133     
134     
135     /**
136      */

137     File JavaDoc getBaseDir() {
138         return baseDir;
139     }
140     
141     /**
142      */

143     File JavaDoc getFile() {
144         return file;
145     }
146     
147     /**
148      */

149     boolean isDefaultExcludes() {
150         return defaultExcludes;
151     }
152     
153     /**
154      */

155     boolean isCaseSensitive() {
156         return caseSensitive;
157     }
158     
159     /**
160      */

161     boolean isFollowSymlinks() {
162         return followSymlinks;
163     }
164     
165     /**
166      */

167     Collection JavaDoc<String JavaDoc> getIncludePatterns() {
168         return implicitPatternSet.getIncludePatterns();
169     }
170     
171     /**
172      */

173     Collection JavaDoc<String JavaDoc> getExcludesPatterns() {
174         return implicitPatternSet.getExcludePatterns();
175     }
176     
177 }
178
Popular Tags