Class NumberToken


  • public class NumberToken
    extends Token
    A token denoting a number.
    • Constructor Summary

      Constructors 
      Constructor Description
      NumberToken​(java.lang.String lexeme, int position, double precision)
      Create a token.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object actual)
      Compares the numeric value of two numbers based upon the precision value recorded for the first number.
      int hashCode()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • NumberToken

        public NumberToken​(java.lang.String lexeme,
                           int position,
                           double precision)
        Create a token.
        Parameters:
        lexeme - the string denoting the number.
        position - position of the token within the string.
        precision - How close this must be to another number to be judged equal.
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object actual)
        Compares the numeric value of two numbers based upon the precision value recorded for the first number.
        Specified by:
        equals in class Token
        Parameters:
        actual - another token
        Returns:
        true iff actual is a NumberToken and their values are within the specified precision.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        hash code.