uk.ac.umist.co.brailletrans
Class LanguageInteger

java.lang.Object
  extended byuk.ac.umist.co.brailletrans.LanguageInteger
All Implemented Interfaces:
Language

public class LanguageInteger
extends java.lang.Object
implements Language

Language class based on the C implementation BrailleTrans by Paul Blenkhorn, UMIST, Manchester, UK. This runs the fastest of all the Language implementations developed by Alasdair King.

Copyright 1999, 2004 Alasdair King. This program is free software under the terms of the GNU General Public License.


Field Summary
static java.lang.String DATAFILE_EXTENSION
          Indicates the text-only human-editable language rules tables format on disk.
static java.lang.String FILENAME_EXTENSION
          Indicates language rules tables (data files) on disk, suitable for loading into the LanguageInteger class and performing translation.
 
Fields inherited from interface uk.ac.umist.co.brailletrans.Language
FILE_EXTENSION_DELIMITER, LEFT_FOCUS_DELIMITER, RIGHT_FOCUS_DELIMITER, RULE_BUFFER, RULE_CONTENT_DELIMITER, RULE_OUTPUT_DELIMITER, SPACE_FLAG, TABLE_DELIMITER, WILDCARD_FLAG, WILDCARD_NONE, WILDCARD_ONE, WILDCARD_SEVERAL
 
Constructor Summary
LanguageInteger(java.lang.String filename)
          Loads a LanguageInteger object from disk.
 
Method Summary
 int getPermittedStates()
          Returns the states permitted in this language.
 int getState()
          Returns the current state of the virtual machine.
 boolean setState(int newState)
          Sets the state of the finite state machine performing the translation, and therefore controls the type of translation performed, depending on the translation language selected.
 int[] translate(int[] input_txt)
          Performs translation from text to Braille or from Braille to text, depending on language and state.
 java.lang.String translate(java.lang.String toConvert)
          Performs translation from text to Braille or from Braille to text, depending on language and state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILENAME_EXTENSION

public static final java.lang.String FILENAME_EXTENSION
Indicates language rules tables (data files) on disk, suitable for loading into the LanguageInteger class and performing translation.

See Also:
Constant Field Values

DATAFILE_EXTENSION

public static final java.lang.String DATAFILE_EXTENSION
Indicates the text-only human-editable language rules tables format on disk. These must be converted into the machine format by MakeLegacy

See Also:
Constant Field Values
Constructor Detail

LanguageInteger

public LanguageInteger(java.lang.String filename)
                throws java.io.IOException,
                       java.io.FileNotFoundException,
                       LanguageLegacyDatafileFormatException
Loads a LanguageInteger object from disk.

Parameters:
filename - Full path and name of language rules table as file to load, according to local filesystem. Do not append the filename extension, for example ".DAT", just use the full path except this, for example "C:\trans\english" for the english.dat language rules table.
Method Detail

translate

public int[] translate(int[] input_txt)
Description copied from interface: Language
Performs translation from text to Braille or from Braille to text, depending on language and state.

Specified by:
translate in interface Language
Parameters:
input_txt - int[] holding characters to translate.
Returns:
int[] holding the output text, characters now translated.

translate

public java.lang.String translate(java.lang.String toConvert)
Description copied from interface: Language
Performs translation from text to Braille or from Braille to text, depending on language and state.

Specified by:
translate in interface Language
Parameters:
toConvert - String holding characters to translate.
Returns:
A String holding the output text, characters now translated.

getState

public int getState()
Description copied from interface: Language
Returns the current state of the virtual machine.

Specified by:
getState in interface Language
Returns:
The current int state of the virtual machine, in the range 1 to numberStates.

getPermittedStates

public int getPermittedStates()
Description copied from interface: Language
Returns the states permitted in this language. This will vary from one language to the next.

Specified by:
getPermittedStates in interface Language
Returns:
An int, the number of states defined for the language and hence the number of permitted states. The state can be any integer from 1 to numberStates.

setState

public boolean setState(int newState)
Description copied from interface: Language
Sets the state of the finite state machine performing the translation, and therefore controls the type of translation performed, depending on the translation language selected.

Specified by:
setState in interface Language
Parameters:
newState - An int containing the new state for the machine to take.
Returns:
A boolean indicating whether setting the state was successful. It will fail if the new state requested is outside the limits of states for the language being used.