AdventNet CLI 2.0 API Specification

com.adventnet.cli.terminal
Class TranslationHandlerImpl

java.lang.Object
  |
  +--com.adventnet.cli.terminal.TranslationHandlerImpl

public class TranslationHandlerImpl
extends java.lang.Object
implements TranslationHandler

This class is the default implementation for the TranslationHandler interface. It performs the Translation based on a key code mapping in a byte array. The index in the array refers to the code to be translated and the value contains the translated code. Many such arrays will be read from an XML file and stored in a Hashtable based on the table name.


Constructor Summary
TranslationHandlerImpl()
          Default Constructor.
 
Method Summary
 java.lang.String[] getTranslationTableNames()
          This method returns the table names that are present in the Translation table list.
 byte inverseTranslate(byte code)
          This method is called to perform the opposite of translation.
 void readTranslationTables(java.lang.String filename)
          This method reads the translation tables (e.g in a XML file or a simple Text file).
 byte translate(byte code)
          This method is called to perform the actual translation.
 void useTranslationTable(java.lang.String tableName)
          This method sets the Translation Table to use among the different tables read.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TranslationHandlerImpl

public TranslationHandlerImpl()
Default Constructor. The API user need not instantiate this class. The TerminalIOHandler will load this class during its initialization.
Method Detail

readTranslationTables

public void readTranslationTables(java.lang.String filename)
                           throws TerminalException
This method reads the translation tables (e.g in a XML file or a simple Text file). The format in which the tables are stored and read are left to user implementation of this method.
Specified by:
readTranslationTables in interface TranslationHandler
Parameters:
fileName - the file in which the Table entries are present
Throws:
TerminalException - thrown when an error occurs during reading of the file.

useTranslationTable

public void useTranslationTable(java.lang.String tableName)
                         throws TerminalException
This method sets the Translation Table to use among the different tables read. The translation table is identified by the table name.
Specified by:
useTranslationTable in interface TranslationHandler
Parameters:
tableName - the table name indicates the table which should be used for the translation.
Throws:
TerminalException - thrown when an error occurs during setting the Translation table

translate

public byte translate(byte code)
               throws TerminalException
This method is called to perform the actual translation. It takes the untranslated terminal code in a byte and returns the translated code after performing look up operations in the table.
Specified by:
translate in interface TranslationHandler
Parameters:
code - the terminal code to be translated
Returns:
the translated code
Throws:
TerminalException - thrown when an error occurs during the translation operation

inverseTranslate

public byte inverseTranslate(byte code)
                      throws TerminalException
This method is called to perform the opposite of translation. It takes the code in a byte and returns a code after performing a reverse lookup operation in the translation table.
Specified by:
inverseTranslate in interface TranslationHandler
Parameters:
code - the terminal code to be inverse translated
Returns:
the inverse translated code
Throws:
TerminalException - thrown when an error occurs during the inverse translation operation

getTranslationTableNames

public java.lang.String[] getTranslationTableNames()
                                            throws TerminalException
This method returns the table names that are present in the Translation table list. Typical implementation of this method should return the list of names of all the various tables defined.
Specified by:
getTranslationTableNames in interface TranslationHandler
Returns:
the list of table names defined.
Throws:
TerminalExcption - thrown when an error occurs while retreiving the table names.

AdventNet CLI 2.0 API Specification