Class StringToken


  • public class StringToken
    extends Token
    Represents a token for a string (e.g., an expression loaded from a file). Using equals, a StringToken object compares as true only to another StringToken object with the same string value. A StringToken is immutable, once created it doesn't change.
    • Constructor Detail

      • StringToken

        public StringToken​(String value)
        Constructs a token representing the given string.
        Parameters:
        value - the value of this string token
    • Method Detail

      • equals

        public boolean equals​(Object o)
        Overrides:
        equals in class Object
        Returns:
        true iff o is a StringToken with the same value
      • value

        public String value()
        Returns:
        the value of this token
      • toString

        public String toString()
        Description copied from class: Token
        Represents the token by its description
        Overrides:
        toString in class Token
        Returns:
        the token's description
      • isConstant

        public boolean isConstant()
        Description copied from class: Token
        Returns true if this token represents a constant, false otherwise
        Specified by:
        isConstant in class Token
        Returns:
        true iff this Token represents a constant
      • isFunction

        public boolean isFunction()
        Description copied from class: Token
        Returns true if this token represents a function, false otherwise
        Specified by:
        isFunction in class Token
        Returns:
        true iff this Token represents a function