org.pz.platypus
Class Token

java.lang.Object
  extended by org.pz.platypus.Token

public class Token
extends java.lang.Object

The token that is parsed from input lines and via TokenList is passed to the output plugin.

Author:
alb

Field Summary
private  java.lang.String content
          what would be called the lexeme in a language parser.
private  CommandParameter parameter
          possible list of parameters for a command
private  java.lang.String root
          token root, used only in commands
private  Source source
          the file number and line number of the this token.
private  TokenType type
          token type
 
Constructor Summary
Token(Source source, TokenType type, java.lang.String content)
           
Token(Source source, TokenType type, java.lang.String root, java.lang.String content, CommandParameter parameter)
           
 
Method Summary
 boolean equals(java.lang.Object tok)
          Complicated equals due to optional fields and embedded objects
(package private)  java.lang.String getCommandData(GDD gdd)
          Convert command data into dumpable strings
 java.lang.String getContent()
           
 CommandParameter getParameter()
           
 java.lang.String getRoot()
           
 Source getSource()
           
 TokenType getType()
           
 int hashCode()
           
 void setContent(java.lang.String newContent)
           
 boolean sourceEquals(Token t2)
          Determines whether another Token has the same file # and line # as this
 java.lang.String toString(GDD gdd)
          Generates a formatted string version of the contents of a token, including parameter details for a command token.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

source

private Source source
the file number and line number of the this token.


type

private TokenType type
token type


root

private java.lang.String root
token root, used only in commands


content

private java.lang.String content
what would be called the lexeme in a language parser. If type = TEXT, can be very long.


parameter

private CommandParameter parameter
possible list of parameters for a command

Constructor Detail

Token

public Token(Source source,
             TokenType type,
             java.lang.String root,
             java.lang.String content,
             CommandParameter parameter)

Token

public Token(Source source,
             TokenType type,
             java.lang.String content)
Method Detail

toString

public java.lang.String toString(GDD gdd)
Generates a formatted string version of the contents of a token, including parameter details for a command token. Used primarily for dumping token lists. See TokenList.dump(), for example.

Parameters:
gdd - the GDD
Returns:
formatted string version of token contents

getCommandData

java.lang.String getCommandData(GDD gdd)
Convert command data into dumpable strings

Parameters:
gdd - the GDD (used for Literals lookup)
Returns:
string with command data.

equals

public boolean equals(java.lang.Object tok)
Complicated equals due to optional fields and embedded objects

Overrides:
equals in class java.lang.Object
Parameters:
tok - the compared-to token
Returns:
yea or nay

hashCode

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

sourceEquals

public boolean sourceEquals(Token t2)
Determines whether another Token has the same file # and line # as this

Parameters:
t2 - the other token
Returns:
yes if they're the same, false if not

getContent

public java.lang.String getContent()

setContent

public void setContent(java.lang.String newContent)

getSource

public Source getSource()

getParameter

public CommandParameter getParameter()

getRoot

public java.lang.String getRoot()

getType

public TokenType getType()


Copyright © 2008-10 Pacific Data Works LLC