org.naturalcli
Class Token

java.lang.Object
  extended by org.naturalcli.Token

public class Token
extends java.lang.Object

The Token class implements a token for the command grammar.

Author:
Ferran Busquets

Constructor Summary
Token(java.lang.String text)
          Constructor for the token
 
Method Summary
 java.lang.String getParameterName()
          Gets the parameter name for the token
 java.lang.String getParameterTypeName()
          Gets the parameter type name for the token
 java.lang.String getText()
          Get the token text
 java.lang.String getWord()
          Obtains the word that represents the token, it means the token text without optional or parameter chars
 boolean isIdentifier()
          Determines if it's an identifier
 boolean isMandatoryParameter()
          Checks if it's a mandatory parameter token
 boolean isOptional()
          Checks if it's an optional token
 boolean isOptionalParameter()
          Checks if it's an optional parameter token
 boolean isParameter()
          Checks if it's a parameter token
 boolean isVarArgs()
          Determines if it's a variable arguments token
 boolean matches(java.lang.String t, ParameterValidator pv)
          Checks the text given to see if it's like the token
 void setText(java.lang.String text)
          Set the token text and validate it
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Token

public Token(java.lang.String text)
      throws InvalidTokenException
Constructor for the token

Parameters:
text - the token text
Throws:
InvalidTokenException
InvalidTokenException
Method Detail

getText

public java.lang.String getText()
Get the token text

Returns:
the token text

setText

public void setText(java.lang.String text)
             throws InvalidTokenException
Set the token text and validate it

Parameters:
text - the token text to set
Throws:
InvalidTokenException
InvalidTokenException

isOptional

public boolean isOptional()
Checks if it's an optional token

Returns:
true if its optional, false otherwise

isParameter

public boolean isParameter()
Checks if it's a parameter token

Returns:
true if it's a parameter, false otherwise

isOptionalParameter

public boolean isOptionalParameter()
Checks if it's an optional parameter token

Returns:
true if its optional parameter, false otherwise

isMandatoryParameter

public boolean isMandatoryParameter()
Checks if it's a mandatory parameter token

Returns:
true if it's mandatory parameter, false otherwise

getParameterName

public java.lang.String getParameterName()
Gets the parameter name for the token

Returns:
the parameter name, or null if it's not a parameter.

getParameterTypeName

public java.lang.String getParameterTypeName()
Gets the parameter type name for the token

Returns:
the parameter type name, or null if it's not a parameter.

isIdentifier

public boolean isIdentifier()
Determines if it's an identifier

Returns:
true if it's an identifier, false otherwise

isVarArgs

public boolean isVarArgs()
Determines if it's a variable arguments token

Returns:
true if it's a variable arguments token, false otherwise

getWord

public java.lang.String getWord()
Obtains the word that represents the token, it means the token text without optional or parameter chars

Returns:
the word that represents the token

matches

public boolean matches(java.lang.String t,
                       ParameterValidator pv)
                throws UnknownParameterType
Checks the text given to see if it's like the token

Parameters:
text - the text to match
pv - the parameter validator
Returns:
true if matches, false if not
Throws:
UnknownParameterType
UnknownParameterType