01: /*******************************************************************************
02: * Copyright (c) 2000, 2004 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM - Initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.build.ant;
11:
12: import java.util.StringTokenizer;
13:
14: /**
15: * Represents an Ant fileset.
16: */
17: public class FileSet {
18:
19: protected String dir; // true
20: protected String defaultexcludes;
21: protected String includes;
22: protected String includesfile;
23: protected String excludes;
24: protected String excludesfile;
25: protected String casesensitive;
26:
27: /**
28: * Constructor for the file set.
29: *
30: * @param dir
31: * @param defaultexcludes
32: * @param includes
33: * @param includesfile
34: * @param excludes
35: * @param excludesfile
36: * @param casesensitive
37: */
38: public FileSet(String dir, String defaultexcludes, String includes,
39: String includesfile, String excludes, String excludesfile,
40: String casesensitive) {
41: this .dir = dir;
42: this .defaultexcludes = defaultexcludes;
43: this .includes = includes;
44: this .includesfile = includesfile;
45: this .excludes = excludes;
46: this .excludesfile = excludesfile;
47: this .casesensitive = casesensitive;
48: }
49:
50: /**
51: * Print this fileset to the given Ant script.
52: *
53: * @param script the script to output to
54: */
55: protected void print(AntScript script) {
56: script.printTab();
57: script.print("<fileset"); //$NON-NLS-1$
58: script.printAttribute("dir", dir, true); //$NON-NLS-1$
59: script
60: .printAttribute(
61: "defaultexcludes", defaultexcludes, false); //$NON-NLS-1$
62: script.printAttribute("includesfile", includesfile, false); //$NON-NLS-1$
63: script.printAttribute("excludesfile", excludesfile, false); //$NON-NLS-1$
64: script.printAttribute("casesensitive", casesensitive, false); //$NON-NLS-1$
65: script.print(">"); //$NON-NLS-1$
66: script.println();
67:
68: if (includes != null)
69: printNames(script, "include", includes); //$NON-NLS-1$
70: if (excludes != null)
71: printNames(script, "exclude", excludes); //$NON-NLS-1$
72: script.println("</fileset>"); //$NON-NLS-1$
73: }
74:
75: private void printNames(AntScript script, String tag, String names) {
76: script.indent++;
77: for (StringTokenizer tokenizer = new StringTokenizer(names, ","); tokenizer.hasMoreTokens();) { //$NON-NLS-1$
78: script.printTabs();
79: script.print("<"); //$NON-NLS-1$
80: script.print(tag);
81: script.printAttribute(
82: "name", tokenizer.nextToken().trim(), true); //$NON-NLS-1$
83: script.print("/>"); //$NON-NLS-1$
84: script.println();
85: }
86: script.indent--;
87: }
88: }
|