openjava.ptree
Class Literal

java.lang.Object
  |
  +--openjava.ptree.ParseTreeObject
        |
        +--openjava.ptree.Leaf
              |
              +--openjava.ptree.Literal
All Implemented Interfaces:
Cloneable, Expression, ParseTree, VariableInitializer
Direct Known Subclasses:
SubqueryFinder.RexExpression

public class Literal
extends Leaf
implements Expression

The Literal class represents a literal.

See Also:
Leaf, Expression

Field Summary
static int BOOLEAN
           
static int CHARACTER
           
private static Literal constantEmptyString_
           
private static Literal constantFalse_
           
private static Literal constantNull_
           
private static Literal constantOne_
           
private static Literal constantTrue_
           
private static Literal constantZero_
           
static int DOUBLE
           
static int FLOAT
           
protected  int id
           
static int INTEGER
           
static int LONG
           
static int NULL
           
static int STRING
           
 
Fields inherited from class openjava.ptree.Leaf
charBegin, line
 
Fields inherited from class openjava.ptree.ParseTreeObject
debugFlag, debugLevel, LN, out, writerStack
 
Constructor Summary
Literal(int id, String str)
          Allocates a new object.
 
Method Summary
 void accept(ParseTreeVisitor v)
          Accepts a ParseTreeVisitor object as the role of a Visitor in the Visitor pattern, as the role of an Element in the Visitor pattern.
static Literal constantEmptyString()
           
static Literal constantFalse()
           
static Literal constantNull()
           
static Literal constantOne()
           
static Literal constantTrue()
           
static Literal constantZero()
           
private static String doubleQuoteString(String s)
           
 int getLiteralType()
           
 OJClass getType(Environment env)
           
static Literal makeLiteral(boolean b)
          Makes a new object of Literal class from the boolean.
static Literal makeLiteral(Boolean b)
           
static Literal makeLiteral(char c)
          Makes a new object of Literal class from the character.
static Literal makeLiteral(Character c)
           
static Literal makeLiteral(double num)
          Makes a new object of Literal class from the number.
static Literal makeLiteral(Double d)
           
static Literal makeLiteral(float num)
          Makes a new object of Literal class from the number.
static Literal makeLiteral(Float f)
           
static Literal makeLiteral(int num)
          Makes a new object of Literal class from the number.
static Literal makeLiteral(Integer n)
           
static Literal makeLiteral(long num)
          Makes a new object of Literal class from the number.
static Literal makeLiteral(Long n)
           
static Literal makeLiteral(String str)
          Makes a new object of Literal class from the string.
private static String singleQuoteChar(char c)
           
static String stripString(String s)
          Given a double-quoted string, returns the string without double-quotes.
 
Methods inherited from class openjava.ptree.Leaf
childrenAccept, equals, equals, getRowType, getTokenID, makeCopy, makeRecursiveCopy, replaceChildWith, toString, writeCode
 
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
 
Methods inherited from interface openjava.ptree.Expression
getRowType
 
Methods inherited from interface openjava.ptree.ParseTree
childrenAccept, eq, equals, getObjectID, makeCopy, makeRecursiveCopy, replace, toFlattenString, toString, writeCode
 

Field Detail

BOOLEAN

public static final int BOOLEAN
See Also:
getLiteralType(), Constant Field Values

INTEGER

public static final int INTEGER
See Also:
Constant Field Values

LONG

public static final int LONG
See Also:
Constant Field Values

FLOAT

public static final int FLOAT
See Also:
Constant Field Values

DOUBLE

public static final int DOUBLE
See Also:
Constant Field Values

CHARACTER

public static final int CHARACTER
See Also:
Constant Field Values

STRING

public static final int STRING
See Also:
Constant Field Values

NULL

public static final int NULL
See Also:
Constant Field Values

id

protected int id

constantTrue_

private static Literal constantTrue_

constantFalse_

private static Literal constantFalse_

constantNull_

private static Literal constantNull_

constantEmptyString_

private static Literal constantEmptyString_

constantZero_

private static Literal constantZero_

constantOne_

private static Literal constantOne_
Constructor Detail

Literal

public Literal(int id,
               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)
Method Detail

makeLiteral

public static Literal makeLiteral(String str)
Makes a new object of Literal class from the string.

Parameters:
str - the string.

doubleQuoteString

private static String doubleQuoteString(String s)

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(Boolean b)

makeLiteral

public static Literal makeLiteral(char c)
Makes a new object of Literal class from the character.

Parameters:
c - the character.

singleQuoteChar

private static String singleQuoteChar(char c)

makeLiteral

public static Literal makeLiteral(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(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(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(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(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 Exception
Specified by:
getType in interface Expression
Exception

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
Parameters:
v - a visitor
ParseTreeException

stripString

public static String stripString(String s)
Given a double-quoted string, returns the string without double-quotes.


SourceForge.net_Logo