KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > build > ant > FileSet


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM - Initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.build.ant;
12
13 import java.util.StringTokenizer JavaDoc;
14
15 /**
16  * Represents an Ant fileset.
17  */

18 public class FileSet {
19
20     protected String JavaDoc dir; // true
21
protected String JavaDoc defaultexcludes;
22     protected String JavaDoc includes;
23     protected String JavaDoc includesfile;
24     protected String JavaDoc excludes;
25     protected String JavaDoc excludesfile;
26     protected String JavaDoc casesensitive;
27
28     /**
29      * Constructor for the file set.
30      *
31      * @param dir
32      * @param defaultexcludes
33      * @param includes
34      * @param includesfile
35      * @param excludes
36      * @param excludesfile
37      * @param casesensitive
38      */

39     public FileSet(String JavaDoc dir, String JavaDoc defaultexcludes, String JavaDoc includes, String JavaDoc includesfile, String JavaDoc excludes, String JavaDoc excludesfile, String JavaDoc casesensitive) {
40         this.dir = dir;
41         this.defaultexcludes = defaultexcludes;
42         this.includes = includes;
43         this.includesfile = includesfile;
44         this.excludes = excludes;
45         this.excludesfile = excludesfile;
46         this.casesensitive = casesensitive;
47     }
48
49     /**
50      * Print this fileset to the given Ant script.
51      *
52      * @param script the script to output to
53      */

54     protected void print(AntScript script) {
55         script.printTab();
56         script.print("<fileset"); //$NON-NLS-1$
57
script.printAttribute("dir", dir, true); //$NON-NLS-1$
58
script.printAttribute("defaultexcludes", defaultexcludes, false); //$NON-NLS-1$
59
script.printAttribute("includesfile", includesfile, false); //$NON-NLS-1$
60
script.printAttribute("excludesfile", excludesfile, false); //$NON-NLS-1$
61
script.printAttribute("casesensitive", casesensitive, false); //$NON-NLS-1$
62
script.print(">"); //$NON-NLS-1$
63
script.println();
64
65         if (includes != null)
66             printNames(script, "include", includes); //$NON-NLS-1$
67
if (excludes != null)
68             printNames(script, "exclude", excludes); //$NON-NLS-1$
69
script.println("</fileset>"); //$NON-NLS-1$
70
}
71
72     private void printNames(AntScript script, String JavaDoc tag, String JavaDoc names) {
73         script.indent++;
74         for (StringTokenizer JavaDoc tokenizer = new StringTokenizer JavaDoc(names, ","); tokenizer.hasMoreTokens();) { //$NON-NLS-1$
75
script.printTabs();
76             script.print("<"); //$NON-NLS-1$
77
script.print(tag);
78             script.printAttribute("name", tokenizer.nextToken().trim(), true); //$NON-NLS-1$
79
script.print("/>"); //$NON-NLS-1$
80
script.println();
81         }
82         script.indent--;
83     }
84 }
85
Popular Tags