1. /*
  2. * Copyright 2000-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.util.regexp;
  18. import java.util.Vector;
  19. import org.apache.tools.ant.BuildException;
  20. /**
  21. * Interface describing a regular expression matcher.
  22. *
  23. */
  24. public interface RegexpMatcher {
  25. /***
  26. * Default Mask (case insensitive, neither multiline nor
  27. * singleline specified).
  28. */
  29. int MATCH_DEFAULT = 0x00000000;
  30. /***
  31. * Perform a case insenstive match
  32. */
  33. int MATCH_CASE_INSENSITIVE = 0x00000100;
  34. /***
  35. * Treat the input as a multiline input
  36. */
  37. int MATCH_MULTILINE = 0x00001000;
  38. /***
  39. * Treat the input as singleline input ('.' matches newline)
  40. */
  41. int MATCH_SINGLELINE = 0x00010000;
  42. /**
  43. * Set the regexp pattern from the String description.
  44. */
  45. void setPattern(String pattern) throws BuildException;
  46. /**
  47. * Get a String representation of the regexp pattern
  48. */
  49. String getPattern() throws BuildException;
  50. /**
  51. * Does the given argument match the pattern?
  52. */
  53. boolean matches(String argument) throws BuildException;
  54. /**
  55. * Returns a Vector of matched groups found in the argument.
  56. *
  57. * <p>Group 0 will be the full match, the rest are the
  58. * parenthesized subexpressions</p>.
  59. */
  60. Vector getGroups(String argument) throws BuildException;
  61. /***
  62. * Does this regular expression match the input, given
  63. * certain options
  64. * @param input The string to check for a match
  65. * @param options The list of options for the match. See the
  66. * MATCH_ constants above.
  67. */
  68. boolean matches(String input, int options) throws BuildException;
  69. /***
  70. * Get the match groups from this regular expression. The return
  71. * type of the elements is always String.
  72. * @param input The string to check for a match
  73. * @param options The list of options for the match. See the
  74. * MATCH_ constants above.
  75. */
  76. Vector getGroups(String input, int options) throws BuildException;
  77. }