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. */
  17. package org.apache.tools.ant.types;
  18. // java io classes
  19. // java util classes
  20. import java.util.Enumeration;
  21. import java.util.Vector;
  22. // ant classes
  23. /**
  24. * A FilterSetCollection is a collection of filtersets each of which may have
  25. * a different start/end token settings.
  26. *
  27. */
  28. public class FilterSetCollection {
  29. private Vector filterSets = new Vector();
  30. public FilterSetCollection() {
  31. }
  32. public FilterSetCollection(FilterSet filterSet) {
  33. addFilterSet(filterSet);
  34. }
  35. public void addFilterSet(FilterSet filterSet) {
  36. filterSets.addElement(filterSet);
  37. }
  38. /**
  39. * Does replacement on the given string with token matching.
  40. * This uses the defined begintoken and endtoken values which default to @ for both.
  41. *
  42. * @param line The line to process the tokens in.
  43. * @return The string with the tokens replaced.
  44. */
  45. public String replaceTokens(String line) {
  46. String replacedLine = line;
  47. for (Enumeration e = filterSets.elements(); e.hasMoreElements();) {
  48. FilterSet filterSet = (FilterSet) e.nextElement();
  49. replacedLine = filterSet.replaceTokens(replacedLine);
  50. }
  51. return replacedLine;
  52. }
  53. /**
  54. * Test to see if this filter set it empty.
  55. *
  56. * @return Return true if there are filter in this set otherwise false.
  57. */
  58. public boolean hasFilters() {
  59. for (Enumeration e = filterSets.elements(); e.hasMoreElements();) {
  60. FilterSet filterSet = (FilterSet) e.nextElement();
  61. if (filterSet.hasFilters()) {
  62. return true;
  63. }
  64. }
  65. return false;
  66. }
  67. }