name.angoca.db2sa.core.lexical
Class ImplLexicalAnalyzer

Package class diagram package ImplLexicalAnalyzer
java.lang.Object
  extended by name.angoca.db2sa.core.lexical.AbstractLexicalAnalyzer
      extended by name.angoca.db2sa.core.lexical.ImplLexicalAnalyzer

public final class ImplLexicalAnalyzer
extends AbstractLexicalAnalyzer

This is the implementation of the lexical analyzer.
Control Version

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

Method Summary
static void destroyInstance()
          Destroys the instance.
static ImplLexicalAnalyzer getInstance()
          Creates the only possible instance of this object.
 ReturnOptions processPhrase(String phrase)
          Process a given phrase that represents a command and sends the options in the screen printer.
protected  String replaceLastToken(String phrase, List<Token> tokens, GraphAnswer answer)
          Retrieves a phrase with the last token modified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ImplLexicalAnalyzer getInstance()
                                       throws InvalidGraphException
Creates the only possible instance of this object. This method can be called after defining the delimiters for this object.

Returns:
This object instanced.
Throws:
InvalidGraphException - When there is a problem creating the graph.

destroyInstance

public static void destroyInstance()
Destroys the instance. It is useful for testings purposes.


processPhrase

public ReturnOptions processPhrase(String phrase)
                            throws InvalidGraphException
Description copied from class: AbstractLexicalAnalyzer
Process a given phrase that represents a command and sends the options in the screen printer.

Specified by:
processPhrase in class AbstractLexicalAnalyzer
Parameters:
phrase - Phrase to process.
Returns:
Set of options for the current phrase and the phrase to print.
Throws:
InvalidGraphException - When the graph that represents the grammar is invalid.

replaceLastToken

protected String replaceLastToken(String phrase,
                                  List<Token> tokens,
                                  GraphAnswer answer)
Retrieves a phrase with the last token modified. The modification depends on the answer of the grammatical analyzer.

Parameters:
phrase - Original phrase.
tokens - Set of token that represents the original phrase.
answer - New phrase returned by the grammatical analyzer.
Returns:
a phrase with the last token modified according to the answer.


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