openjava.ptree
Class Literal
java.lang.Object
|
+--openjava.ptree.ParseTreeObject
|
+--openjava.ptree.Leaf
|
+--openjava.ptree.Literal
- All Implemented Interfaces:
- java.lang.Cloneable, Expression, ParseTree, VariableInitializer
- public class Literal
- extends Leaf
- implements Expression
The Literal class
represents
a literal.
- See Also:
Leaf
,
Expression
Constructor Summary |
Literal(int id,
java.lang.String str)
Allocates a new object. |
Methods inherited from class openjava.ptree.ParseTreeObject |
clone, eq, eq, equal, flushPrintWriter, getDebugFlag, getNest, getObjectID, getParent, getPrintWriter, getTab, hashCode, lastObjectID, popNest, popPrintWriter, pushNest, pushPrintWriter, replace, setDebugFlag, setDebugLevel, setNest, setParent, setPrintStream, setTab, toFlattenString, writeDebug, writeDebugL, writeDebugLln, writeDebugln, writeDebugLR, writeDebugR, writeDebugRln, writeTab |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
BOOLEAN
public static final int BOOLEAN
- See Also:
getLiteralType()
INTEGER
public static final int INTEGER
LONG
public static final int LONG
FLOAT
public static final int FLOAT
DOUBLE
public static final int DOUBLE
CHARACTER
public static final int CHARACTER
STRING
public static final int STRING
NULL
public static final int NULL
id
protected int id
Literal
public Literal(int id,
java.lang.String str)
- Allocates a new object.
If you want to make
String
literal like
"test"
,
call this constructor in the form :
new Literal( Literal.STRING, "\"test\"" )
or use makeLiteral() static method.
- Parameters:
id
- the id number of the literal.str
- the literal as a String.- See Also:
makeLiteral(String)
makeLiteral
public static Literal makeLiteral(java.lang.String str)
- Makes a new object of
Literal
class
from the string.
- Parameters:
str
- the string.
makeLiteral
public static Literal makeLiteral(boolean b)
- Makes a new object of
Literal
class
from the boolean.
- Parameters:
b
- the boolean.
makeLiteral
public static Literal makeLiteral(java.lang.Boolean b)
makeLiteral
public static Literal makeLiteral(char c)
- Makes a new object of
Literal
class
from the character.
- Parameters:
c
- the character.
makeLiteral
public static Literal makeLiteral(java.lang.Character c)
makeLiteral
public static Literal makeLiteral(int num)
- Makes a new object of
Literal
class
from the number.
- Parameters:
num
- the number.
makeLiteral
public static Literal makeLiteral(java.lang.Integer n)
makeLiteral
public static Literal makeLiteral(long num)
- Makes a new object of
Literal
class
from the number.
- Parameters:
num
- the number.
makeLiteral
public static Literal makeLiteral(java.lang.Long n)
makeLiteral
public static Literal makeLiteral(float num)
- Makes a new object of
Literal
class
from the number.
- Parameters:
num
- the number.
makeLiteral
public static Literal makeLiteral(java.lang.Float f)
makeLiteral
public static Literal makeLiteral(double num)
- Makes a new object of
Literal
class
from the number.
- Parameters:
num
- the number.
makeLiteral
public static Literal makeLiteral(java.lang.Double d)
getLiteralType
public int getLiteralType()
constantTrue
public static Literal constantTrue()
constantFalse
public static Literal constantFalse()
constantNull
public static Literal constantNull()
constantEmptyString
public static Literal constantEmptyString()
constantZero
public static Literal constantZero()
constantOne
public static Literal constantOne()
getType
public OJClass getType(Environment env)
throws java.lang.Exception
- Specified by:
getType
in interface Expression
accept
public void accept(ParseTreeVisitor v)
throws ParseTreeException
- Description copied from interface:
ParseTree
- Accepts a
ParseTreeVisitor
object as the role of a
Visitor in the Visitor pattern, as the role of an Element in the
Visitor pattern.
This invoke an appropriate visit()
method on the
accepted visitor.
- Specified by:
accept
in interface ParseTree
- Overrides:
accept
in class Leaf
- Following copied from interface:
openjava.ptree.ParseTree
- Parameters:
visitor
- a visitor