Module openj9.dtfj

Class 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:
    Serialized Form
    • Nested Class Summary

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

      Constructors 
      Constructor Description
      PatternString​(String pattern)
      Constructor for creating a PatternString class which can contain wildcard expressions and other characters to represent many strings at once.
    • Constructor Detail

      • 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 Detail

      • 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