Class PatternString

java.lang.Object
com.ibm.j9ddr.util.PatternString
All Implemented Interfaces:
Serializable

public class PatternString extends Object implements Serializable
A string containing wildcards and other characters that enable it to represent many strings at once.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    A class to represent the PatternString in two separate patterns
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final PatternString
     
    static final char
     
    static final char
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for creating a PatternString class which can contain wildcard expressions and other characters to represent many strings at once.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    endsWith(String string)
    Determine if there is a match to the pattern that ends with the given string
    int[]
    indexOf(int c)
    Finds the indices of the possible first locations of the indicated character.
    boolean
    isMatch(String string)
    Determines if the pattern matches with a given string.
    boolean
    Checks if this PatternString contains no wildcards.
    static boolean
    isWildcard(char c)
    Checks if the provided character is a wildcard
    int[]
    lastIndexOf(int c)
    Finds the indices of the possible last locations of the indicated character.
    split(int index)
    Splits the patterns into two separate patterns, the splitting being done by the character at the indicated index, so this character is not included in either string.
    boolean
    Determine if there is a match to the pattern that starts with the given string
    Gives the pattern used to create this PatternString class

    Methods declared in class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • PatternString

      public PatternString(String pattern)
      Constructor for creating a PatternString class which can contain wildcard expressions and other characters to represent many strings at once.
      Parameters:
      pattern - a String which can contain wildcards
  • Method Details

    • split

      public PatternString.PatternStringPair split(int index)
      Splits the patterns into two separate patterns, the splitting being done by the character at the indicated index, so this character is not included in either string. If such a character is a variable length wildcard then the new patterns will begin and end with wildcards as needed.
      Parameters:
      index - the index at which to split the PatternString in two parts
    • indexOf

      public int[] indexOf(int c)
      Finds the indices of the possible first locations of the indicated character. The results are returned in ascending order.
      Parameters:
      c - index of the pattern within this PatternString
      Returns:
      int[] an array indicating the possible first locations of the character indicated at the index provided.
    • lastIndexOf

      public int[] lastIndexOf(int c)
      Finds the indices of the possible last locations of the indicated character. The results are returned in descending order.
      Parameters:
      c - index of the pattern within this PatternString
      Returns:
      int[] an array indicating the possible last locations of the character indicated at the index provided.
    • isRegularString

      public boolean isRegularString()
      Checks if this PatternString contains no wildcards.
      Returns:
      boolean true if this PatternString contains no wildcards, false otherwise
    • isWildcard

      public static boolean isWildcard(char c)
      Checks if the provided character is a wildcard
      Parameters:
      c - the character to check whether it is a wildcard or not
      Returns:
      boolean true if the character given is a wildcard
    • endsWith

      public boolean endsWith(String string)
      Determine if there is a match to the pattern that ends with the given string
      Parameters:
      string - the String to match
      Returns:
      boolean returns true if there is a match, false if not
    • isMatch

      public boolean isMatch(String string)
      Determines if the pattern matches with a given string.
      Parameters:
      string - the String to match
      Returns:
      boolean returns true if there is a match, false if not
    • startsWith

      public boolean startsWith(String string)
      Determine if there is a match to the pattern that starts with the given string
      Parameters:
      string - the String to match
      Returns:
      boolean returns true if there is a match, false if not
    • toString

      public String toString()
      Gives the pattern used to create this PatternString class
      Overrides:
      toString in class Object
      Returns:
      String returns the pattern used to construct this PatternString