KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > types > FilterSetCollection


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */

18 package org.apache.tools.ant.types;
19
20 // java io classes
21

22
23
24
25 // java util classes
26
import java.util.Enumeration JavaDoc;
27 import java.util.Vector JavaDoc;
28
29 // ant classes
30

31
32
33
34 /**
35  * A FilterSetCollection is a collection of filtersets each of which may have
36  * a different start/end token settings.
37  *
38  */

39 public class FilterSetCollection {
40
41     private Vector JavaDoc filterSets = new Vector JavaDoc();
42
43     /**
44      * Constructor for a FilterSetCollection.
45      */

46     public FilterSetCollection() {
47     }
48
49     /**
50      * Constructor for a FilterSetCollection.
51      * @param filterSet a filterset to start the collection with
52      */

53     public FilterSetCollection(FilterSet filterSet) {
54         addFilterSet(filterSet);
55     }
56
57
58     /**
59      * Add a filterset to the collection.
60      *
61      * @param filterSet a <code>FilterSet</code> value
62      */

63     public void addFilterSet(FilterSet filterSet) {
64         filterSets.addElement(filterSet);
65     }
66
67     /**
68      * Does replacement on the given string with token matching.
69      * This uses the defined begintoken and endtoken values which default to @ for both.
70      *
71      * @param line The line to process the tokens in.
72      * @return The string with the tokens replaced.
73      */

74     public String JavaDoc replaceTokens(String JavaDoc line) {
75         String JavaDoc replacedLine = line;
76         for (Enumeration JavaDoc e = filterSets.elements(); e.hasMoreElements();) {
77             FilterSet filterSet = (FilterSet) e.nextElement();
78             replacedLine = filterSet.replaceTokens(replacedLine);
79         }
80         return replacedLine;
81     }
82
83     /**
84     * Test to see if this filter set it empty.
85     *
86     * @return Return true if there are filter in this set otherwise false.
87     */

88     public boolean hasFilters() {
89         for (Enumeration JavaDoc e = filterSets.elements(); e.hasMoreElements();) {
90             FilterSet filterSet = (FilterSet) e.nextElement();
91             if (filterSet.hasFilters()) {
92                 return true;
93             }
94         }
95         return false;
96     }
97 }
98
99
100
101
Popular Tags