source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/src/main/org/apache/tools/ant/types/FilterSetCollection.java@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

File size: 2.3 KB
Line 
1/*
2 * Copyright 2001-2002,2004 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17package org.apache.tools.ant.types;
18
19// java io classes
20
21
22
23
24// java util classes
25import java.util.Enumeration;
26import java.util.Vector;
27
28// ant classes
29
30
31
32
33/**
34 * A FilterSetCollection is a collection of filtersets each of which may have
35 * a different start/end token settings.
36 *
37 */
38public class FilterSetCollection {
39
40 private Vector filterSets = new Vector();
41
42 public FilterSetCollection() {
43 }
44
45 public FilterSetCollection(FilterSet filterSet) {
46 addFilterSet(filterSet);
47 }
48
49
50 public void addFilterSet(FilterSet filterSet) {
51 filterSets.addElement(filterSet);
52 }
53
54 /**
55 * Does replacement on the given string with token matching.
56 * This uses the defined begintoken and endtoken values which default to @ for both.
57 *
58 * @param line The line to process the tokens in.
59 * @return The string with the tokens replaced.
60 */
61 public String replaceTokens(String line) {
62 String replacedLine = line;
63 for (Enumeration e = filterSets.elements(); e.hasMoreElements();) {
64 FilterSet filterSet = (FilterSet) e.nextElement();
65 replacedLine = filterSet.replaceTokens(replacedLine);
66 }
67 return replacedLine;
68 }
69
70 /**
71 * Test to see if this filter set it empty.
72 *
73 * @return Return true if there are filter in this set otherwise false.
74 */
75 public boolean hasFilters() {
76 for (Enumeration e = filterSets.elements(); e.hasMoreElements();) {
77 FilterSet filterSet = (FilterSet) e.nextElement();
78 if (filterSet.hasFilters()) {
79 return true;
80 }
81 }
82 return false;
83 }
84}
85
86
87
Note: See TracBrowser for help on using the repository browser.