com.go.tea.parsetree
Class NumberLiteral

java.lang.Object
  |
  +--com.go.tea.parsetree.Node
        |
        +--com.go.tea.parsetree.Expression
              |
              +--com.go.tea.parsetree.Literal
                    |
                    +--com.go.tea.parsetree.NumberLiteral
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class NumberLiteral
extends Literal

Base class for all Literals that have a numeric type.

Version:
27 , 9/07/00
Author:
Brian S O'Neill
See Also:
Serialized Form

Inner classes inherited from class com.go.tea.parsetree.Expression
Expression.Conversion
 
Constructor Summary
NumberLiteral(SourceInfo info, double value)
           
NumberLiteral(SourceInfo info, float value)
           
NumberLiteral(SourceInfo info, int value)
           
NumberLiteral(SourceInfo info, long value)
           
NumberLiteral(SourceInfo info, java.lang.Number value)
           
 
Method Summary
 java.lang.Object accept(NodeVisitor visitor)
          Every subclass of Node must override this method with the following: return visitor.visit(this).
 void convertTo(Type type, boolean preferCast)
          Applies a type conversion to this expression which is chained to all previous conversions.
 java.lang.Object getValue()
          Most expressions can't generate a value at compile-time, so this method simply returns null.
 boolean isValueKnown()
          Value is known only if type is a number or can be assigned a number.
 void setType(Type type)
          Sets the type of this expression, clearing the conversion chain.
 
Methods inherited from class com.go.tea.parsetree.Expression
clone, convertTo, getConversionChain, getInitialType, getType, isExceptionPossible, setInitialType
 
Methods inherited from class com.go.tea.parsetree.Node
getSourceInfo, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NumberLiteral

public NumberLiteral(SourceInfo info,
                     java.lang.Number value)

NumberLiteral

public NumberLiteral(SourceInfo info,
                     int value)

NumberLiteral

public NumberLiteral(SourceInfo info,
                     float value)

NumberLiteral

public NumberLiteral(SourceInfo info,
                     long value)

NumberLiteral

public NumberLiteral(SourceInfo info,
                     double value)
Method Detail

accept

public java.lang.Object accept(NodeVisitor visitor)
Description copied from class: Node
Every subclass of Node must override this method with the following: return visitor.visit(this).
Overrides:
accept in class Literal
Following copied from class: com.go.tea.parsetree.Node
Parameters:
visitor - A visitor of this Node
Returns:
Node The Node returned by the visitor
See Also:
NodeVisitor

convertTo

public void convertTo(Type type,
                      boolean preferCast)
Description copied from class: Expression
Applies a type conversion to this expression which is chained to all previous conversions.
Overrides:
convertTo in class Expression
Following copied from class: com.go.tea.parsetree.Expression
Parameters:
toType - the type to convert to.
preferCast - a hint that the conversion should be performed by a type cast operation, by default is true.
Throws:
java.lang.IllegalArgumentException - when the conversion is illegal.

setType

public void setType(Type type)
Description copied from class: Expression
Sets the type of this expression, clearing the conversion chain.
Overrides:
setType in class Expression

getValue

public java.lang.Object getValue()
Description copied from class: Expression
Most expressions can't generate a value at compile-time, so this method simply returns null. Call isValueKnown to check if the expression's value is known at compile-time.
Overrides:
getValue in class Expression

isValueKnown

public boolean isValueKnown()
Value is known only if type is a number or can be assigned a number.
Overrides:
isValueKnown in class Literal
Following copied from class: com.go.tea.parsetree.Expression
See Also:
Literal