~ubuntu-branches/ubuntu/lucid/libstruts1.2-java/lucid

« back to all changes in this revision

Viewing changes to contrib/tag-doc/src/java/org/apache/struts/taskdefs/EnhMatchingTask.java

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Vandyck
  • Date: 2006-04-24 12:14:23 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060424121423-naev53qigqgks0sa
Tags: 1.2.9-1
New upstream  release Fixes  three security  problems: CVE-2006-1546,
CVE-2006-1547,  CVE-2006-1548  (closes:  #360551),  thanks  to  Moritz
Muehlenhoff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * $Header: /home/cvs/jakarta-struts/contrib/tag-doc/src/java/org/apache/struts/taskdefs/EnhMatchingTask.java,v 1.4 2004/03/14 07:15:06 sraeburn Exp $
3
 
 * $Revision: 1.4 $
4
 
 * $Date: 2004/03/14 07:15:06 $
5
 
 *
6
 
 * Copyright 1999-2004 The Apache Software Foundation.
7
 
 * 
8
 
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 
 * you may not use this file except in compliance with the License.
10
 
 * You may obtain a copy of the License at
11
 
 * 
12
 
 *      http://www.apache.org/licenses/LICENSE-2.0
13
 
 * 
14
 
 * Unless required by applicable law or agreed to in writing, software
15
 
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 
 * See the License for the specific language governing permissions and
18
 
 * limitations under the License.
19
 
 */
20
 
 
21
 
package org.apache.struts.taskdefs;
22
 
 
23
 
import java.io.File;
24
 
import java.util.ArrayList;
25
 
import java.util.Iterator;
26
 
import java.util.List;
27
 
 
28
 
import org.apache.tools.ant.DirectoryScanner;
29
 
import org.apache.tools.ant.taskdefs.MatchingTask;
30
 
import org.apache.tools.ant.types.FileSet;
31
 
 
32
 
/**
33
0
* ENHanced-MatchingTask - enhances the MatchingTask by allowing
34
1
* the subclasses to act as a FileSet container as well as allowing
35
2
* the implicit FileSet.
36
3
*
37
4
* @version $Revision: 1.4 $ $Date: 2004/03/14 07:15:06 $
38
 
 */
39
 
 
40
 
public abstract class EnhMatchingTask extends MatchingTask {
41
 
        /** Base directory for implicit FileSet */
42
 
        protected File dir;
43
 
        /** List of embeded filesets */
44
 
        protected List filesets = new ArrayList();
45
 
 
46
 
        /**
47
 
         * Set the base directory for the implicit FileSet
48
 
         * @param base directory for implicit FileSet
49
 
         */
50
 
        public void setDir(File dir) {
51
 
                this.dir = dir;
52
 
        }
53
 
        /**
54
 
         * Adds an embeded FileSet for this task.
55
 
         * @param the FileSet to add
56
 
         */
57
 
        public void addFileset(FileSet fileset) {
58
 
                filesets.add(fileset);
59
 
        }
60
 
 
61
 
        /**
62
 
         * Returns the combined list of Files, from both the
63
 
         * implicit and embeded FileSets.
64
 
         * @return list of File objects
65
 
         */
66
 
        protected List getFiles() {
67
 
                List files = new ArrayList();
68
 
                if (dir != null) {
69
 
                        fileset.setDir(dir);
70
 
                        files.addAll(getFiles(fileset));
71
 
                }
72
 
                Iterator iter = filesets.iterator();
73
 
                while (iter.hasNext()) {
74
 
                        files.addAll(getFiles((FileSet) iter.next()));
75
 
                }
76
 
                return files;
77
 
        }
78
 
        private List getFiles(FileSet fs) {
79
 
                List files = new ArrayList();
80
 
                DirectoryScanner ds = fs.getDirectoryScanner(fs.getProject());
81
 
                File dir = ds.getBasedir();
82
 
                String[] filenames = ds.getIncludedFiles();
83
 
                for (int i = 0; i < filenames.length; i++) {
84
 
                        File file = new File(dir, filenames[i]);
85
 
                        files.add(file);
86
 
                }
87
 
                return files;
88
 
        }
89
 
}
 
 
b'\\ No newline at end of file'