org.apache.commons.text

## Class StrMatcher

- java.lang.Object
- - org.apache.commons.text.StrMatcher

- Deprecated.
  Deprecated as of 1.3, use `StringMatcherFactory` instead. This class will be removed in 2.0.

      @Deprecated
      public abstract class StrMatcher
      extends Object

  A matcher class that can be queried to determine if a character array portion matches.

  This class comes complete with various factory methods. If these do not suffice, you can subclass and implement your own matcher.

  Since:
    1.0

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `StrMatcher()` Deprecated. Constructor.

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `static StrMatcher` | `charMatcher(char ch)` Deprecated. Creates a matcher from a character.
    `static StrMatcher` | `charSetMatcher(char... chars)` Deprecated. Creates a matcher from a set of characters.
    `static StrMatcher` | `charSetMatcher(String chars)` Deprecated. Creates a matcher from a string representing a set of characters.
    `static StrMatcher` | `commaMatcher()` Deprecated. Returns a matcher which matches the comma character.
    `static StrMatcher` | `doubleQuoteMatcher()` Deprecated. Returns a matcher which matches the double quote character.
    `int` | `isMatch(char[] buffer, int pos)` Deprecated. Returns the number of matching characters, or zero if there is no match.
    `abstract int` | `isMatch(char[] buffer, int pos, int bufferStart, int bufferEnd)` Deprecated. Returns the number of matching characters, or zero if there is no match.
    `static StrMatcher` | `noneMatcher()` Deprecated. Matches no characters.
    `static StrMatcher` | `quoteMatcher()` Deprecated. Returns a matcher which matches the single or double quote character.
    `static StrMatcher` | `singleQuoteMatcher()` Deprecated. Returns a matcher which matches the single quote character.
    `static StrMatcher` | `spaceMatcher()` Deprecated. Returns a matcher which matches the space character.
    `static StrMatcher` | `splitMatcher()` Deprecated. Matches the same characters as StringTokenizer, namely space, tab, newline and form feed.
    `static StrMatcher` | `stringMatcher(String str)` Deprecated. Creates a matcher from a string.
    `static StrMatcher` | `tabMatcher()` Deprecated. Returns a matcher which matches the tab character.
    `static StrMatcher` | `trimMatcher()` Deprecated. Matches the String trim() whitespace characters.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### StrMatcher

          protected StrMatcher()

      Deprecated.
      Constructor.

  - ### Method Detail

    - #### commaMatcher

          public static StrMatcher commaMatcher()

      Deprecated.
      Returns a matcher which matches the comma character.
      Returns:
        a matcher for a comma

    - #### tabMatcher

          public static StrMatcher tabMatcher()

      Deprecated.
      Returns a matcher which matches the tab character.
      Returns:
        a matcher for a tab

    - #### spaceMatcher

          public static StrMatcher spaceMatcher()

      Deprecated.
      Returns a matcher which matches the space character.
      Returns:
        a matcher for a space

    - #### splitMatcher

          public static StrMatcher splitMatcher()

      Deprecated.
      Matches the same characters as StringTokenizer, namely space, tab, newline and form feed.
      Returns:
        the split matcher

    - #### trimMatcher

          public static StrMatcher trimMatcher()

      Deprecated.
      Matches the String trim() whitespace characters.
      Returns:
        the trim matcher

    - #### singleQuoteMatcher

          public static StrMatcher singleQuoteMatcher()

      Deprecated.
      Returns a matcher which matches the single quote character.
      Returns:
        a matcher for a single quote

    - #### doubleQuoteMatcher

          public static StrMatcher doubleQuoteMatcher()

      Deprecated.
      Returns a matcher which matches the double quote character.
      Returns:
        a matcher for a double quote

    - #### quoteMatcher

          public static StrMatcher quoteMatcher()

      Deprecated.
      Returns a matcher which matches the single or double quote character.
      Returns:
        a matcher for a single or double quote

    - #### noneMatcher

          public static StrMatcher noneMatcher()

      Deprecated.
      Matches no characters.
      Returns:
        a matcher that matches nothing

    - #### charMatcher

          public static StrMatcher charMatcher(char ch)

      Deprecated.
      Creates a matcher from a character.
      Parameters:
        `ch` - the character to match, must not be null
      Returns:
        a new Matcher for the given char

    - #### charSetMatcher

          public static StrMatcher charSetMatcher(char... chars)

      Deprecated.
      Creates a matcher from a set of characters.
      Parameters:
        `chars` - the characters to match, null or empty matches nothing
      Returns:
        a new matcher for the given char[]

    - #### charSetMatcher

          public static StrMatcher charSetMatcher(String chars)

      Deprecated.
      Creates a matcher from a string representing a set of characters.
      Parameters:
        `chars` - the characters to match, null or empty matches nothing
      Returns:
        a new Matcher for the given characters

    - #### stringMatcher

          public static StrMatcher stringMatcher(String str)

      Deprecated.
      Creates a matcher from a string.
      Parameters:
        `str` - the string to match, null or empty matches nothing
      Returns:
        a new Matcher for the given String

    - #### isMatch

          public abstract int isMatch(char[] buffer,
                                      int pos,
                                      int bufferStart,
                                      int bufferEnd)

      Deprecated.
      Returns the number of matching characters, or zero if there is no match.

      This method is called to check for a match. The parameter `pos` represents the current position to be checked in the string `buffer` (a character array which must not be changed). The API guarantees that `pos` is a valid index for `buffer`.

      The character array may be larger than the active area to be matched. Only values in the buffer between the specified indices may be accessed.

      The matching code may check one character or many. It may check characters preceding `pos` as well as those after, so long as no checks exceed the bounds specified.

      It must return zero for no match, or a positive number if a match was found. The number indicates the number of characters that matched.

      Parameters:
        `buffer` - the text content to match against, do not change
        `pos` - the starting position for the match, valid for buffer
        `bufferStart` - the first active index in the buffer, valid for buffer
        `bufferEnd` - the end index (exclusive) of the active buffer, valid for buffer
      Returns:
        the number of matching characters, or zero if there is no match

    - #### isMatch

          public int isMatch(char[] buffer,
                             int pos)

      Deprecated.
      Returns the number of matching characters, or zero if there is no match.

      This method is called to check for a match. The parameter `pos` represents the current position to be checked in the string `buffer` (a character array which must not be changed). The API guarantees that `pos` is a valid index for `buffer`.

      The matching code may check one character or many. It may check characters preceding `pos` as well as those after.

      It must return zero for no match, or a positive number if a match was found. The number indicates the number of characters that matched.

      Parameters:
        `buffer` - the text content to match against, do not change
        `pos` - the starting position for the match, valid for buffer
      Returns:
        the number of matching characters, or zero if there is no match

Copyright © 2014–2018 The Apache Software Foundation. All rights reserved.