Class LiteralBaseToken


  • public class LiteralBaseToken
    extends LeafBaseToken
    LiteralBaseToken is the BaseToken that represents literals such as String, Integer, Long, Float, and Double.
    Author:
    djl 2009.03.14
    • Field Detail

      • STRINGLITERAL

        public static final int STRINGLITERAL
        The numberic code for a string literal
        See Also:
        Constant Field Values
      • INTEGERLITERAL

        public static final int INTEGERLITERAL
        The numberic code for a integer literal
        See Also:
        Constant Field Values
      • LONGLITERAL

        public static final int LONGLITERAL
        The numberic code for a long literal
        See Also:
        Constant Field Values
      • FLOATLITERAL

        public static final int FLOATLITERAL
        The numberic code for a float literal
        See Also:
        Constant Field Values
      • DOUBLELITERAL

        public static final int DOUBLELITERAL
        The numberic code for a double literal
        See Also:
        Constant Field Values
      • BOOLEANLITERAL

        public static final int BOOLEANLITERAL
        The numberic code for a boolean literal
        See Also:
        Constant Field Values
      • NULLLITERAL

        public static final int NULLLITERAL
        The numberic code for a boolean literal
        See Also:
        Constant Field Values
      • SHORTLITERAL

        public static final int SHORTLITERAL
        The numberic code for a short literal
        See Also:
        Constant Field Values
    • Constructor Detail

      • LiteralBaseToken

        public LiteralBaseToken​(int nType,
                                String s)
        Construct a new LiteralBaseToken with the given parameters.
        Parameters:
        nType - the type code for the token
        s - the string representation for the token
    • Method Detail

      • getValue

        public String getValue()
        Return the string representation of this LeafBaseToken.
        Specified by:
        getValue in class LeafBaseToken
        Returns:
        the string that represents the reciever
      • isLiteral

        public boolean isLiteral()
        Answer whether this token represents a literal.
        Overrides:
        isLiteral in class BaseToken
        Returns:
        the answer to the question "is this token a literal?"
      • getType

        public int getType()
        Obtain the type code of this token.
        Returns:
        the type code
      • toString

        public String toString()
        Return a human-readable description for this token.
        Overrides:
        toString in class LeafBaseToken
        Returns:
        a String description of the token
      • createString

        public static LiteralBaseToken createString​(String s)
        Create new LiteralBaseToken representing a String with given value
        Parameters:
        s - the text of the literal
        Returns:
        a LiteralBaseToken for a String
      • createShort

        public static LiteralBaseToken createShort​(String s)
        Create new LiteralBaseToken representing a Integer with given value
        Parameters:
        s - the text of the literal
        Returns:
        a LiteralBaseToken for a Integer
      • createInteger

        public static LiteralBaseToken createInteger​(String s)
        Create new LiteralBaseToken representing a Integer with given value
        Parameters:
        s - the text of the literal
        Returns:
        a LiteralBaseToken for a Integer
      • createLong

        public static LiteralBaseToken createLong​(String s)
        Create new LiteralBaseToken representing a Long with given value
        Parameters:
        s - the text of the literal
        Returns:
        a LiteralBaseToken for a Long
      • createFloat

        public static LiteralBaseToken createFloat​(String s)
        Create new LiteralBaseToken representing a float with given value
        Parameters:
        s - the text of the literal
        Returns:
        a LiteralBaseToken for a Float
      • createDouble

        public static LiteralBaseToken createDouble​(String s)
        Create new LiteralBaseToken representing a Double with given value
        Parameters:
        s - the text of the literal
        Returns:
        a LiteralBaseToken for a Double
      • createBoolean

        public static LiteralBaseToken createBoolean​(String s)
        Create new LiteralBaseToken representing a Boolean with given value
        Parameters:
        s - the text of the literal
        Returns:
        a LiteralBaseToken for a Double
      • createNull

        public static LiteralBaseToken createNull​(String s)
        Create new LiteralBaseToken representing a null with given value
        Parameters:
        s - the text of the literal
        Returns:
        a LiteralBaseToken for a Double