|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jscience.linguistics.braille.BrailleLanguageUnicode
public class BrailleLanguageUnicode
An implementation of BrailleLanguage that works with Unicode strings and
Unicode language tables.
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
The filename extension for the unprocessed BrailleLanguage rules tables for this implementation of language. |
char |
ESCAPE_CHAR_1
The first character forming part of the escape sequence for unicode characters to be depicted in ASCII. |
char |
ESCAPE_CHAR_2
The second character forming part of the escape sequence for unicode characters to be depicted in ASCII. |
static java.lang.String |
FILENAME_EXTENSION
Filename extension for serialized BrailleLanguageUnicode objects
that can be loaded into memory by calling the constructor with their path
and name and used for translation. |
| Fields inherited from interface org.jscience.linguistics.braille.BrailleLanguage |
|---|
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 | |
|---|---|
BrailleLanguageUnicode()
Constructs a BrailleLanguageUnicode object without data ready to be filled with information for the language being created in the correct order. |
|
BrailleLanguageUnicode(java.lang.String filename)
Loads a BrailleLanguageUnicode object with all the language rules table information required for translation from disk. |
|
| Method Summary | |
|---|---|
void |
addCharacterInformation(java.lang.Character from,
java.lang.Character to,
java.lang.Integer flagValue)
Adds the information for one Unicode character to the language. |
void |
addTranslationRule(java.lang.String toProcess)
Adds a new translation rule to the language. |
void |
addWildcardInformation(int wildcardNumber,
int wildcardFlags,
java.lang.Character wildcardChar)
Adds one wildcard's information to the language |
BrailleLanguageUnicode |
getBrailleLanguageUnicodeFromDisk(java.lang.String filename)
Loads a BrailleLanguageUnicode object from disk |
static BrailleLanguageUnicode |
getBrailleLanguageUnicodeFromWebsite(java.lang.String languageName)
Downloads a language file from the web. |
java.lang.String |
getDescription()
Returns the free text description of the language. |
java.lang.String |
getInputClassDescription(int inputClass)
Returns the language description for an input class. |
java.lang.String |
getName()
Returns the name of the language. |
int |
getNumberCharacters()
Returns the number of Unicode characters supported by this language. |
int |
getNumberInputClasses()
Returns the number of input classes available in the language. |
int |
getNumberStates()
Returns the number of states available in this language. |
int |
getNumberWildcards()
Returns the number of wildcards defined in the language |
int |
getPermittedStates()
DOCUMENT ME! |
int |
getState()
DOCUMENT ME! |
java.lang.String |
getStateDescription(int state)
Returns the language description for a state. |
int |
getVersionNumber()
Returns the version of the language |
void |
setDecisionTableEntry(int state,
int inputClass,
boolean value)
Sets a state table entry for the language. |
void |
setDescription(java.lang.String description)
Allows the free text description of the language to be set. |
void |
setInputClassDescription(int inputClass,
java.lang.String description)
Applies a description to one of the input classes of the language. |
void |
setName(java.lang.String name)
Allows the name of the language to be set. |
void |
setNumberCharacters(int numberCharacters)
Sets the number of Unicode characters supported by this new language. |
void |
setNumberInputClasses(int numberInputClasses)
Sets the number of input classes for the language. |
void |
setNumberStates(int numberStates)
Sets the number of states possible for the finite state machine of the language. |
void |
setNumberWildcards(int numberWildcards)
Defines the number of wildcards for this language. |
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)
Applies a description to one of the finite state machine states. |
void |
setVersionNumber(int versionNumber)
Sets the version number of a BrailleLanguageUnicode object. |
int[] |
translate(int[] toConvert)
DOCUMENT ME! |
java.lang.String |
translate(java.lang.String toConvert)
DOCUMENT ME! |
void |
writeBrailleLanguageUnicodeToDisk(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 |
|---|
public static final java.lang.String FILENAME_EXTENSION
BrailleLanguageUnicode objects
that can be loaded into memory by calling the constructor with their path
and name and used for translation.
public static final java.lang.String DATAFILE_EXTENSION
public final char ESCAPE_CHAR_1
public final char ESCAPE_CHAR_2
| Constructor Detail |
|---|
public BrailleLanguageUnicode()
public BrailleLanguageUnicode(java.lang.String filename)
throws java.io.IOException,
java.lang.ClassNotFoundException,
java.io.FileNotFoundException
set methods, then serialized to disk with
writeBrailleLanguageUnicodeToDisk, before it can be loaded in by this
constructor. If a supplied BrailleLanguageUnicode object is provided, this can be
interrogated for its translation abilities with the get methods.
filename - Full path and name of serialized Java object as file to load,
excluding the filename extension. For example, language file "english.dat" in
"\languages" should be instantiated with BrailleLanguageUnicode myBrailleLanguage =
new BrailleLanguageUnicode("\languages\english");
java.io.IOException
java.lang.ClassNotFoundException
java.io.FileNotFoundException| Method Detail |
|---|
public BrailleLanguageUnicode getBrailleLanguageUnicodeFromDisk(java.lang.String filename)
throws java.io.IOException,
java.io.FileNotFoundException,
java.io.StreamCorruptedException,
java.lang.ClassNotFoundException
filename - Full path and name of serialized Java object as file to load.
java.io.IOException
java.io.FileNotFoundException
java.io.StreamCorruptedException
java.lang.ClassNotFoundExceptionpublic boolean setState(int newState)
BrailleLanguage
setState in interface BrailleLanguagenewState - An int containing the new state for the
machine to take.
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.public int getPermittedStates()
getPermittedStates in interface BrailleLanguagepublic int getState()
getState in interface BrailleLanguagepublic java.lang.String translate(java.lang.String toConvert)
translate in interface BrailleLanguagetoConvert - DOCUMENT ME!
public int[] translate(int[] toConvert)
translate in interface BrailleLanguagetoConvert - DOCUMENT ME!
public void setNumberWildcards(int numberWildcards)
throws BrailleLanguageDefinitionException
numberWildcards - int number of wildcards.
BrailleLanguageDefinitionExceptionpublic int getNumberWildcards()
public int getVersionNumber()
public void addCharacterInformation(java.lang.Character from,
java.lang.Character to,
java.lang.Integer flagValue)
throws BrailleLanguageDefinitionException
from - Character object wrapping the character that will be mapped
from in normalising the input text.to - Character object wrapping the character that is produced
when mapping the input text.flagValue - The distinctive flags for the character in to.
BrailleLanguageDefinitionException
public void addWildcardInformation(int wildcardNumber,
int wildcardFlags,
java.lang.Character wildcardChar)
throws BrailleLanguageDefinitionException
wildcardNumber - The value indicating whether the wildcard matches
zero or more characters (WILDCARD_NONE), one character
(WILDCARD_ONE), or one or more characters
(WILDCARD_SEVERAL).wildcardFlags - The distinctive flags that the wildcard matches.wildcardChar - Character object wrapping the character used for the
wildcard.
BrailleLanguageDefinitionException
public void addTranslationRule(java.lang.String toProcess)
throws BrailleLanguageDefinitionException
String argument
must be in the format "inputclass [TAB] leftContext LEFT_FOCUS_DELIMITER
focus RIGHT_FOCUS_DELIMITER rightContext RULE_OUTPUT_DELIMITER output
RULE_CONTENT_DELIMITER [TAB] newState". The CONSTANTS are inherited
from BrailleLanguage.
toProcess - String containing whole translation rule content, input
class to new state.
BrailleLanguageDefinitionExceptionpublic void setName(java.lang.String name)
name - String that will become the name of the language.public java.lang.String getName()
getName in interface Namedpublic void setDescription(java.lang.String description)
description - String containing the description for the language.public java.lang.String getDescription()
public void setNumberCharacters(int numberCharacters)
throws BrailleLanguageDefinitionException
numberCharacters - int number of characters for language.
BrailleLanguageDefinitionExceptionpublic int getNumberCharacters()
public void setNumberStates(int numberStates)
throws BrailleLanguageDefinitionException
numberStates - The number of possible states.
BrailleLanguageDefinitionException
public void setStateDescription(int state,
java.lang.String description)
throws BrailleLanguageDefinitionException
state - The state to have a description applied to it.description - A String containing the description to be applied.
BrailleLanguageDefinitionException
public java.lang.String getStateDescription(int state)
throws BrailleLanguageDefinitionException,
java.lang.ArrayIndexOutOfBoundsException
state - The state for which the description is required.
BrailleLanguageDefinitionException
java.lang.ArrayIndexOutOfBoundsException
public java.lang.String getInputClassDescription(int inputClass)
throws BrailleLanguageDefinitionException,
java.lang.ArrayIndexOutOfBoundsException
inputClass - The input class for which the description is required.
BrailleLanguageDefinitionException
java.lang.ArrayIndexOutOfBoundsException
public void setInputClassDescription(int inputClass,
java.lang.String description)
throws BrailleLanguageDefinitionException
inputClass - The input class for which a description is being provided.description - The description as a String for the input class.
BrailleLanguageDefinitionException
public void setNumberInputClasses(int numberInputClasses)
throws BrailleLanguageDefinitionException
numberInputClasses - Number of input classes for the language.
BrailleLanguageDefinitionException
public void setDecisionTableEntry(int state,
int inputClass,
boolean value)
throws BrailleLanguageDefinitionException,
java.lang.ArrayIndexOutOfBoundsException
state - State of table.inputClass - Input class of table.value - Results to be entered.
BrailleLanguageDefinitionException
java.lang.ArrayIndexOutOfBoundsExceptionpublic int getNumberInputClasses()
public int getNumberStates()
setState. States affect the translation performed.
public void setVersionNumber(int versionNumber)
BrailleLanguageUnicode object. Version
is not used anywhere yet, so this can be used to differentiate languages but
should not be relied upon to do this.
public static BrailleLanguageUnicode getBrailleLanguageUnicodeFromWebsite(java.lang.String languageName)
throws java.lang.Exception
BrailleLanguageUnicode. Instead, the language file name
can be passed to this method, and the language file will be obtained by HTTP.
As with other BrailleLanguage implementations, the filename extension
should not be added. To get language "english", simply call
getBrailleLanguageUnicodeFromDisk("english");
- Parameters:
languageName - String name of language file to get.
- Returns:
- The
BrailleLanguageUnicode received.
- Throws:
java.lang.Exception
public void writeBrailleLanguageUnicodeToDisk(java.lang.String filename)
throws java.io.IOException
BrailleLanguage
filename - String showing full path and filename for object as file.
java.io.IOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||