net.sf.imageCave.database
Class DataAST

java.lang.Object
  |
  +--antlr.BaseAST
        |
        +--net.sf.imageCave.database.DataAST
All Implemented Interfaces:
antlr.collections.AST, java.io.Serializable

public class DataAST
extends antlr.BaseAST

AST node implementation which stores tokens explicitly. This is handy if you'd rather derive information from tokens on an as-needed basis instead of snarfing data from a token as an AST is being built. This implementation is borrowed from TokenAST Dan Bornstein, danfuzz@milk.com

The current implementation doesn't really do anything different than TokenAST (or just CommonAST, for that matter), but I wanted to have my own class for the specific type of AST generated from Image Cave *.cfg files.

Since:
13 March, 2004
Version:
%I%, %G%
Author:
Stuart T. Tett, disc0stu@sf.net
See Also:
BaseAST, Serialized Form

Field Summary
 
Fields inherited from class antlr.BaseAST
down, right
 
Constructor Summary
DataAST()
          Construct an instance which (at least initially) is not associated with a token.
DataAST(antlr.Token tok)
          Construct an instance which is associated with the given token.
 
Method Summary
 java.lang.String getText()
          Get the token text for this instance.
 antlr.Token getToken()
          Get the token associated with this instance.
 int getType()
          Get the token type for this instance.
 void initialize(antlr.collections.AST ast)
          Initialize this instance based on the given AST.
 void initialize(int type, java.lang.String text)
          Initialize this instance with the given token type and text.
 void initialize(antlr.Token tok)
          Initialize this instance with the given token.
 void setText(java.lang.String text)
          Set the token text for this node.
 void setToken(antlr.Token tok)
          Set the token associated with this instance.
 void setType(int type)
          Set the token type for this node.
 
Methods inherited from class antlr.BaseAST
addChild, decode, encode, equals, equalsList, equalsListPartial, equalsTree, equalsTreePartial, findAll, findAllPartial, getColumn, getFirstChild, getLine, getNextSibling, getNumberOfChildren, getTokenNames, removeChildren, setFirstChild, setNextSibling, setVerboseStringConversion, toString, toStringList, toStringTree, xmlSerialize, xmlSerializeNode, xmlSerializeRootClose, xmlSerializeRootOpen
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataAST

public DataAST()
Construct an instance which (at least initially) is not associated with a token.


DataAST

public DataAST(antlr.Token tok)
Construct an instance which is associated with the given token.

Parameters:
tok - null-ok; the token to associate this instance with
Method Detail

getText

public java.lang.String getText()
Get the token text for this instance. If there is no token associated with this instance, then this returns the empty string (""), not null.

Specified by:
getText in interface antlr.collections.AST
Overrides:
getText in class antlr.BaseAST
Returns:
non-null; the token text

getType

public int getType()
Get the token type for this instance. If there is no token associated with this instance, then this returns Token.INVALID_TYPE.

Specified by:
getType in interface antlr.collections.AST
Overrides:
getType in class antlr.BaseAST
Returns:
the token type

getToken

public antlr.Token getToken()
Get the token associated with this instance. If there is no token associated with this instance, then this returns null.

Returns:
null-ok; the token associated with this instance or mull if there is no associated token

setToken

public void setToken(antlr.Token tok)
Set the token associated with this instance.

Parameters:
tok - null-ok; the new token to associate with this instance

initialize

public void initialize(antlr.Token tok)
Initialize this instance with the given token.

Specified by:
initialize in interface antlr.collections.AST
Specified by:
initialize in class antlr.BaseAST
Parameters:
tok - null-ok; the token to associate with this instance

initialize

public void initialize(int type,
                       java.lang.String text)
Initialize this instance with the given token type and text. This will construct a new CommonToken with the given parameters and associate this instance with it.

Specified by:
initialize in interface antlr.collections.AST
Specified by:
initialize in class antlr.BaseAST
Parameters:
type - the token type
text - null-ok; the token text

initialize

public void initialize(antlr.collections.AST ast)
Initialize this instance based on the given AST. If the given AST is in fact an instance of TokenAST, then this instance will be initialized to point at the same token as the given one. If not, then this instance will be initialized with the same token type and text as the given one.

Specified by:
initialize in interface antlr.collections.AST
Specified by:
initialize in class antlr.BaseAST
Parameters:
ast - non-null; the AST to base this instance on

setText

public void setText(java.lang.String text)
Set the token text for this node. If this instance is already associated with a token, then that token is destructively modified by this operation. If not, then a new token is constructed with the type Token.INVALID_TYPE and the given text.

Specified by:
setText in interface antlr.collections.AST
Overrides:
setText in class antlr.BaseAST
Parameters:
text - the new token text

setType

public void setType(int type)
Set the token type for this node. If this instance is already associated with a token, then that token is destructively modified by this operation. If not, then a new token is constructed with the given type and an empty ("", not null) text string.

Specified by:
setType in interface antlr.collections.AST
Overrides:
setType in class antlr.BaseAST
Parameters:
type - the new token type


Copyright 2004 Brian Lund, Justin Rasmussen, & Stuart Tett. All Rights Reserved.