Class EmbosserBrailleConverter
- java.lang.Object
-
- org.daisy.braille.utils.impl.tools.table.EmbosserBrailleConverter
-
- All Implemented Interfaces:
BrailleConverter
public class EmbosserBrailleConverter extends Object implements BrailleConverter
Provides a simple TableConverter implementation. It provides a one-to-one mapping between braille and text and vice versa.
-
-
Constructor Summary
Constructors Constructor Description EmbosserBrailleConverter(String table, Charset charset, EightDotFallbackMethod fallback, char replacement, boolean ignoreCase)
Creates a new EmbosserBrailleConverter.EmbosserBrailleConverter(String table, Charset charset, EightDotFallbackMethod fallback, char replacement, boolean ignoreCase, Map<Character,Character> t2bSupplements)
Creates a new EmbosserBrailleConverter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Charset
getPreferredCharset()
Gets the preferred charset for this braille format when reading/writing as text from/to file.boolean
supportsEightDot()
Returns true if 8-dot braille is supported, false otherwise.String
toBraille(String text)
Transcodes the given text string as braille.String
toText(String braille)
Transcodes the given braille into text.
-
-
-
Constructor Detail
-
EmbosserBrailleConverter
public EmbosserBrailleConverter(String table, Charset charset, EightDotFallbackMethod fallback, char replacement, boolean ignoreCase)
Creates a new EmbosserBrailleConverter.- Parameters:
table
- the characters in the table, in Unicode order. Must contain 64 or 256 characters.charset
- the preferred charset as defined in the BrailleConverter interfacefallback
- the fallback method to use when encountering a character in the range 0x2840-0x28FFreplacement
- the replacement character, must be in the range 0x2800-0x283FignoreCase
- set to true to ignore character case- Throws:
IllegalArgumentException
- if the table length isn't equal to 64 or 256.
-
EmbosserBrailleConverter
public EmbosserBrailleConverter(String table, Charset charset, EightDotFallbackMethod fallback, char replacement, boolean ignoreCase, Map<Character,Character> t2bSupplements)
Creates a new EmbosserBrailleConverter.- Parameters:
table
- the characters in the table, in Unicode order. Must contain 64 or 256 characters.charset
- the preferred charset as defined in the BrailleConverter interfacefallback
- the fallback method to use when encountering a character in the range 0x2840-0x28FFreplacement
- the replacement character, must be in the range 0x2800-0x283FignoreCase
- set to true to ignore character caset2bSupplements
- additional substitutions for text to braille translation. Values MUST be braille characters.- Throws:
IllegalArgumentException
- if the table length isn't equal to 64 or 256 or if supplements values are not braille characters.
-
-
Method Detail
-
getPreferredCharset
public Charset getPreferredCharset()
Description copied from interface:BrailleConverter
Gets the preferred charset for this braille format when reading/writing as text from/to file.- Specified by:
getPreferredCharset
in interfaceBrailleConverter
- Returns:
- returns the preferred charset
-
supportsEightDot
public boolean supportsEightDot()
Description copied from interface:BrailleConverter
Returns true if 8-dot braille is supported, false otherwise.- Specified by:
supportsEightDot
in interfaceBrailleConverter
- Returns:
- returns true if 8-dot braille is supported, false otherwise
-
toBraille
public String toBraille(String text)
Description copied from interface:BrailleConverter
Transcodes the given text string as braille. This may be a one-to-one mapping or a many-to-one depending on the table implementation.- Specified by:
toBraille
in interfaceBrailleConverter
- Parameters:
text
- the text to convert- Returns:
- returns a Unicode string of braille
-
toText
public String toText(String braille)
Description copied from interface:BrailleConverter
Transcodes the given braille into text.In most cases this will reverse the effect of toBraille(String text), i.e. text.equals(toText(toBraille(text))), however an implementation cannot rely on it.
Values must be between 0x2800 and 0x28FF.
- Specified by:
toText
in interfaceBrailleConverter
- Parameters:
braille
- the braille to convert- Returns:
- returns a text string
-
-