Class TokenString


  • public class TokenString
    extends Token
    A string Token.
    • Method Detail

      • get

        public static TokenString get​(java.lang.String value)
        Create a token for the specified string.
        Parameters:
        value - the string
        Returns:
        the token
      • get

        public static TokenString get​(java.lang.String value,
                                      ParserAttribute attribute)
        Create a token for the specified string (with an attribute)
        Parameters:
        value - the string
        attribute - the attribute
        Returns:
        the token
      • get

        public static TokenString get​(java.lang.String value,
                                      java.util.Collection<ParserAttribute> attributes)
        Create a token for the specified string (with attributes)
        Parameters:
        value - the string
        attributes - the attributes
        Returns:
        the token
      • getValue

        public java.lang.String getValue()
        Get the string.
        Specified by:
        getValue in class Token
        Returns:
        The string value of this token.
      • matches

        public boolean matches​(Token input)
        Does this token match the input?

        This token matches other token strings that have the same underlying string. If this is a single character string, it will also match TokenCharacters that are defined with the same character.

        Specified by:
        matches in class Token
        Parameters:
        input - The input.
        Returns:
        true if they match.
      • matches

        public boolean matches​(char input)
        Does this toke match this character?
        Parameters:
        input - the character.
        Returns:
        true if this token matches.
      • matches

        public boolean matches​(java.lang.String input)
        Does this token match this string?
        Parameters:
        input - the string.
        Returns:
        true if the token matches.
      • equals

        public boolean equals​(java.lang.Object obj)
        Test tokens for equality.

        Two tokens are equal if they represent the same string.

        Overrides:
        equals in class java.lang.Object
        Parameters:
        obj - An object.
        Returns:
        true if obj is equal to this terminal character.
      • hashCode

        public int hashCode()
        Assure that equal tokens return the same hash code.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hash code.
      • toString

        public java.lang.String toString()
        Pretty print a token.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string representation of the object.