uk.ac.umist.co.brailletrans
Class Language256
java.lang.Object
|
+--uk.ac.umist.co.brailletrans.Language256
- All Implemented Interfaces:
- Language, java.io.Serializable
- public class Language256
- extends java.lang.Object
- implements Language, java.io.Serializable
A Java implementation of the UMIST, Manchester text to Braille and Braille
to text system, designed to work with 256-character extended-ASCII ANSI sets.
- See Also:
- Serialized Form
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 |
Language256(java.lang.String filename)
Loads a Language256 object from disk. |
Method Summary |
java.lang.String |
displayRule(int ruleToDisplay)
|
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[] 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. |
java.lang.String |
viewTranslationRule(int ruleNumber)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MAX_COMPRESS
public static final double MAX_COMPRESS
- The maximum ratio of input to output arrays after translation - 1:MAX_COMPRESS. Any greater will
cause the language to throw an ArrayIndexOutOfBoundsException. The input text may be padded with
spaces if this occurs.
FILENAME_EXTENSION
public static final java.lang.String FILENAME_EXTENSION
DATAFILE_EXTENSION
public static final java.lang.String DATAFILE_EXTENSION
Language256
public Language256(java.lang.String filename)
throws java.io.IOException,
java.io.FileNotFoundException
- Loads a Language256 object from disk.
- Parameters:
filename
- Full path and name of serialized Java object as file to load.
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.
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.
displayRule
public java.lang.String displayRule(int ruleToDisplay)
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.
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.
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.
viewTranslationRule
public java.lang.String viewTranslationRule(int ruleNumber)