uk.ac.umist.co.brailletrans
Class LanguageUnicode

java.lang.Object
  |
  +--uk.ac.umist.co.brailletrans.LanguageUnicode
All Implemented Interfaces:
Language, java.io.Serializable

public class LanguageUnicode
extends java.lang.Object
implements Language, java.io.Serializable

An implementation of Language that works with Unicode string and Unicode Language tables.

See Also:
Serialized Form

Field Summary
static java.lang.String DATAFILE_EXTENSION
          The filename extension for the unprocessed Language rules tables for this implementation of language.
 char ESCAPE_CHAR_1
           
 char ESCAPE_CHAR_2
           
static java.lang.String FILENAME_EXTENSION
           
 
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
LanguageUnicode()
          Constructs a LanguageUnicode object without data ready to be filled with information for the language being created in the correct order.
LanguageUnicode(java.lang.String filename)
          Loads a LanguageUnicode object from disk.
 
Method Summary
 void addCharacterInformation(java.lang.Character from, java.lang.Character to, java.lang.Integer flagValue)
           
 void addTranslationRule(java.lang.String toProcess)
           
 void addWildcardInformation(int wildcardNumber, int wildcardFlags, java.lang.Character wildcardChar)
           
 java.lang.String getDescription()
           
 java.lang.String getInputClassDescription(int inputClass)
           
 LanguageUnicode getLanguageUnicodeFromDisk(java.lang.String filename)
          Loads a LanguageUnicode object from disk
static LanguageUnicode getLanguageUnicodeFromWebsite(java.lang.String languageName)
          Downloads a language file from the web.
 java.lang.String getName()
           
 int getNumberCharacters()
           
 int getNumberInputClasses()
           
 int getNumberStates()
           
 int getNumberWildcards()
           
 int getPermittedStates()
          Returns the states permitted in this language.
 int getState()
          Returns the current state of the virtual machine.
 java.lang.String getStateDescription(int state)
           
 int getVersionNumber()
           
 void setDecisionTableEntry(int state, int inputClass, boolean value)
           
 void setDescription(java.lang.String description)
           
 void setInputClassDescription(int inputClass, java.lang.String description)
           
 void setName(java.lang.String name)
           
 void setNumberCharacters(int numberCharacters)
           
 void setNumberInputClasses(int numberInputClasses)
           
 void setNumberStates(int numberStates)
           
 void setNumberWildcards(int numberWildcards)
           
 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.
 void setStateDescription(int state, java.lang.String description)
           
 void setVersionNumber(int versionNumber)
           
 int[] translate(int[] toConvert)
          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.
 void writeLanguageUnicodeToDisk(java.lang.String filename)
          Writes the current language to disk as a serialized object.
 
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

DATAFILE_EXTENSION

public static final java.lang.String DATAFILE_EXTENSION
The filename extension for the unprocessed Language rules tables for this implementation of language.

ESCAPE_CHAR_1

public final char ESCAPE_CHAR_1

ESCAPE_CHAR_2

public final char ESCAPE_CHAR_2
Constructor Detail

LanguageUnicode

public LanguageUnicode()
Constructs a LanguageUnicode object without data ready to be filled with information for the language being created in the correct order.

LanguageUnicode

public LanguageUnicode(java.lang.String filename)
                throws java.io.IOException,
                       java.lang.ClassNotFoundException,
                       java.io.FileNotFoundException
Loads a LanguageUnicode object from disk.
Parameters:
filename - Full path and name of serialized Java object as file to load.
Method Detail

getLanguageUnicodeFromDisk

public LanguageUnicode getLanguageUnicodeFromDisk(java.lang.String filename)
                                           throws java.io.IOException,
                                                  java.io.FileNotFoundException,
                                                  java.io.StreamCorruptedException,
                                                  java.lang.ClassNotFoundException
Loads a LanguageUnicode object from disk
Parameters:
filename - Full path and name of serialized Java object as file to load.

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
Following copied from interface: uk.ac.umist.co.brailletrans.Language
Parameters:
state - An int containing the new state for the machine to take.
Returns:
okay 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.

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
Following copied from interface: uk.ac.umist.co.brailletrans.Language
Returns:
numberStates 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.

getState

public int getState()
Description copied from interface: Language
Returns the current state of the virtual machine.
Specified by:
getState in interface Language
Following copied from interface: uk.ac.umist.co.brailletrans.Language
Returns:
state The current int state of the virtual machine.

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
Following copied from interface: uk.ac.umist.co.brailletrans.Language
Parameters:
toConvert - String holding characters to translate.
Returns:
toReturn String holding characters now translated.

translate

public int[] translate(int[] 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
Following copied from interface: uk.ac.umist.co.brailletrans.Language
Parameters:
toConvert - int[] holding characters to translate.
Returns:
toReturn int[] holding characters now translated.

setNumberWildcards

public void setNumberWildcards(int numberWildcards)
                        throws LanguageDefinitionException

getNumberWildcards

public int getNumberWildcards()

getVersionNumber

public int getVersionNumber()

addCharacterInformation

public void addCharacterInformation(java.lang.Character from,
                                    java.lang.Character to,
                                    java.lang.Integer flagValue)
                             throws LanguageDefinitionException

addWildcardInformation

public void addWildcardInformation(int wildcardNumber,
                                   int wildcardFlags,
                                   java.lang.Character wildcardChar)
                            throws LanguageDefinitionException

addTranslationRule

public void addTranslationRule(java.lang.String toProcess)
                        throws LanguageDefinitionException

setName

public void setName(java.lang.String name)

getName

public java.lang.String getName()

setDescription

public void setDescription(java.lang.String description)

getDescription

public java.lang.String getDescription()

setNumberCharacters

public void setNumberCharacters(int numberCharacters)
                         throws LanguageDefinitionException

getNumberCharacters

public int getNumberCharacters()

setNumberStates

public void setNumberStates(int numberStates)
                     throws LanguageDefinitionException

setStateDescription

public void setStateDescription(int state,
                                java.lang.String description)
                         throws LanguageDefinitionException

getStateDescription

public java.lang.String getStateDescription(int state)
                                     throws LanguageDefinitionException,
                                            java.lang.ArrayIndexOutOfBoundsException

getInputClassDescription

public java.lang.String getInputClassDescription(int inputClass)
                                          throws LanguageDefinitionException,
                                                 java.lang.ArrayIndexOutOfBoundsException

setInputClassDescription

public void setInputClassDescription(int inputClass,
                                     java.lang.String description)
                              throws LanguageDefinitionException

setNumberInputClasses

public void setNumberInputClasses(int numberInputClasses)
                           throws LanguageDefinitionException

setDecisionTableEntry

public void setDecisionTableEntry(int state,
                                  int inputClass,
                                  boolean value)
                           throws LanguageDefinitionException,
                                  java.lang.ArrayIndexOutOfBoundsException

getNumberInputClasses

public int getNumberInputClasses()

getNumberStates

public int getNumberStates()

setVersionNumber

public void setVersionNumber(int versionNumber)

getLanguageUnicodeFromWebsite

public static LanguageUnicode getLanguageUnicodeFromWebsite(java.lang.String languageName)
                                                     throws java.lang.Exception
Downloads a language file from the web.
Parameters:
languageName - String name of language file to get.
Returns:
fromWeb The LanguageUnicode received.

writeLanguageUnicodeToDisk

public void writeLanguageUnicodeToDisk(java.lang.String filename)
                                throws java.io.IOException
Writes the current language to disk as a serialized object.
Parameters:
filename - String showing full path and filename for object as file.