name.angoca.db2sa.core.syntax.graph
Class GraphToken

Package class diagram package GraphToken
java.lang.Object
  extended by name.angoca.db2sa.core.syntax.graph.GraphToken
Direct Known Subclasses:
EndingToken, HelpToken, LicenseToken, StartingToken

public class GraphToken
extends Object

This is the representation of a word in the grammar graph. A token can be a reserved word, a parenthesis, a comma, or a variable word, like a name or a number.
The grammar is represented by a graph, and this graph has the possibles ways that a command can have.
A token has the following elements:

The name attribute represents the internal identification of the token, and its content can be the reserved word that it represents, or the name of the variable. Then, the reservedWord attribute indicates if the id is a reservedWord or not. This is used when scanning the graph.
Two nodes are the same if the data that they have is the same, and the ways that they have are the same.
Control Version

Version:
1.0.0 2009-07-19
Author:
Andres Gomez Casanova (AngocA)

Constructor Summary
GraphToken(String name, boolean reservedWord)
          Constructor that defines a token object.
GraphToken(String tokenId, String name, boolean reservedWord)
          Constructor that defines a token object.
 
Method Summary
 void addWay(GraphToken token)
          Adds a possible way to the current token.
 boolean equals(Object object)
           
 String getId()
          Returns the identifier of this token.
 String getName()
          Returns the name of the token.
 List<GraphToken> getWays()
          This method retrieves all the possibles ways that can be taken from this node.
 int hashCode()
           
 boolean isReservedWord()
          Returns true if the token represents a reserved word in the grammar.
 boolean represent(String token)
          Analyzes the given token, and returns true if the current graph token represents that token.
 String toString()
          Returns a string representation of a graph token.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GraphToken

public GraphToken(String name,
                  boolean reservedWord)
Constructor that defines a token object. The name is the name of the token that this token object represents, and reservedWord says if the node is a reserved word or a variable name.
PRE: The token does not have any delimiter, it just have the token.

Parameters:
name - Name of the token.
reservedWord - Indicates if the token is a reserved word in the grammar.

GraphToken

public GraphToken(String tokenId,
                  String name,
                  boolean reservedWord)
Constructor that defines a token object. The id is the unique identifier of this token. The name is the name of the token that this token object represents, and reservedWord says if the node is a reserved word or a variable name.
PRE: The token does not have any delimiter, it just have the token.

Parameters:
tokenId - Unique id of the token.
name - Name of the token.
reservedWord - Indicates if the token is a reserved word in the grammar.
Method Detail

addWay

public final void addWay(GraphToken token)
Adds a possible way to the current token.

Parameters:
token - to connect with the current token.

represent

public final boolean represent(String token)
Analyzes the given token, and returns true if the current graph token represents that token.

Parameters:
token - token to analyze.
Returns:
true if the graph node represents that token.

getId

public final String getId()
Returns the identifier of this token.

Returns:
the unique identifier of this token.

getName

public final String getName()
Returns the name of the token.

Returns:
the name of the token.

isReservedWord

public final boolean isReservedWord()
Returns true if the token represents a reserved word in the grammar. False if not.

Returns:
if the token represents a reserved word

getWays

public final List<GraphToken> getWays()
This method retrieves all the possibles ways that can be taken from this node. This is useful to analyze the graph.

Returns:
set of possibles ways.

equals

public boolean equals(Object object)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Returns a string representation of a graph token. The representation is:

Overrides:
toString in class Object
Returns:
String representation of a graph token.
See Also:
Object.toString()


Andres Gomez Casanova (AngocA) Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License.