AdventNet CLI 2.0 API Specification

com.adventnet.cli.terminal
Class TerminalIOHandler

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

public class TerminalIOHandler
extends java.lang.Object

This class can be used to handle Terminal Data. It uses the Transformation and Translation Handler implementations to perform the Transformation and Translation operations. For example it could perform translation between two types of Terminals (say a vt100 & IBM terminal). For doing these operations the user has to provide the Translation mappings for the key codes (say in a file). A default implementation for the Transformation and Translation Handler implementations are provided. These will be loaded during the initialization of this class. If the user wants his implementation of the handlers to be used he has to provide them (the class names of the implementation) in the terminal.conf file.


Constructor Summary
TerminalIOHandler()
          This constructor creates an instance of the TerminalIOHandler.
 
Method Summary
 java.lang.String getTransformationHandlerClassName()
          Gets the class name for the TransformationHandler implementation.
 java.lang.String[] getTransformationTableNames()
          This method returns the table names that are present in the Transformation table list.
 java.lang.String getTranslationHandlerClassName()
          Gets the class name for the TranslationHandler implementation.
 java.lang.String[] getTranslationTableNames()
          This method returns the table names that are present in the Translation table list.
 void init(java.lang.String translationFileName, java.lang.String transformationFileName)
          This method loads the transformation & translation handlers and reads the translation/transformation tables from files.
 byte inverseTranslate(byte code)
          This method is called to perform the opposite of translation.
 void setTransformationHandlerClassName(java.lang.String className)
          Sets the class name of the TransformationHandler implementation.
 void setTranslationHandlerClassName(java.lang.String className)
          Sets the class name of the TranslationHandler implementation.
 byte[] transform(byte[] codes)
          This method is called to perform the actual transformation.
 byte translate(byte code)
          This method is called to perform the actual translation.
 void useTransformationTable(java.lang.String tableName)
          This method sets the Transformation Table to use among the different tables read.
 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

TerminalIOHandler

public TerminalIOHandler()
                  throws TerminalException
This constructor creates an instance of the TerminalIOHandler. It reads the Transformation/Translation handler class names from a config file.
Throws:
TerminalException - thrown when an error occurs during initialization of the handler.
Method Detail

setTransformationHandlerClassName

public void setTransformationHandlerClassName(java.lang.String className)
Sets the class name of the TransformationHandler implementation. When set this will be used for performing the Transformation.
Parameters:
className - the TransformationHandler Implementation class name.

getTransformationHandlerClassName

public java.lang.String getTransformationHandlerClassName()
Gets the class name for the TransformationHandler implementation.

setTranslationHandlerClassName

public void setTranslationHandlerClassName(java.lang.String className)
Sets the class name of the TranslationHandler implementation. When set this will be used for performing the Translation of terminal data.
Parameters:
className - the TranslationHandler Implementation class name.

getTranslationHandlerClassName

public java.lang.String getTranslationHandlerClassName()
Gets the class name for the TranslationHandler implementation.

transform

public byte[] transform(byte[] codes)
                 throws TerminalException
This method is called to perform the actual transformation. It takes the untransformed data in a byte array and returns the transformed data after performing look up operations in the table.
Parameters:
codes - the data to be transformed
Returns:
the byte array containing the transformed data
Throws:
TerminalException - thrown when an error occurs during the transformation operation

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.
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.
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

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.
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

useTransformationTable

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

init

public void init(java.lang.String translationFileName,
                 java.lang.String transformationFileName)
          throws java.lang.Exception
This method loads the transformation & translation handlers and reads the translation/transformation tables from files. The Transformation and translation table file names are to be specified as arguments to the method. If any of the argument is null, that particular handler is not loaded. For example if the translationFileName is null the Translation handler will not be loaded and no translation can be performed.
Parameters:
translationFileName - the file name in which the translation table is present.
transformationFileName - the file name in which the transformation table is present.
Throws:
java.lang.Exception - thrown if an error occurs during reading of the files or during the initialization of the handlers.

getTransformationTableNames

public java.lang.String[] getTransformationTableNames()
                                               throws TerminalException
This method returns the table names that are present in the Transformation table list. This method returns the list of names of all the various tables defined.
Returns:
the list of table names defined.
Throws:
TerminalExcption - thrown when an error occurs while retreiving the table names.

getTranslationTableNames

public java.lang.String[] getTranslationTableNames()
                                            throws TerminalException
This method returns the table names that are present in the Translation table list. This method returns the list of names of all the various tables defined.
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