Class AdvancedBrailleConverter

  • All Implemented Interfaces:
    BrailleConverter

    public class AdvancedBrailleConverter
    extends Object
    implements BrailleConverter
    Provides an advanced Braille converter mapping each braille character to a string.
    • Constructor Detail

      • AdvancedBrailleConverter

        public AdvancedBrailleConverter​(String[] table,
                                        Charset charset,
                                        EightDotFallbackMethod fallback,
                                        char replacement,
                                        boolean ignoreCase,
                                        StringTranslator.MatchMode mode)
        Creates a new 6-dot table. Each string in the table array represents a braille character. The string at index i in the array is interpreted as the translation for the braille character with Unicode value 0x2800+i.
        Parameters:
        table - the table data, 64 entries
        charset - the preferred charset as defined in the BrailleConverter interface
        fallback - the fallback method to use when encountering a character in the range 0x2840-0x28FF
        replacement - the replacement character, must be in the range 0x2800-0x283F
        ignoreCase - set to true to ignore character case
        mode - the match mode to use
        Throws:
        IllegalArgumentException - if the table length isn't equal to 64
      • AdvancedBrailleConverter

        public AdvancedBrailleConverter​(String[] table,
                                        Charset charset,
                                        boolean ignoreCase,
                                        StringTranslator.MatchMode mode)
        Creates a new 8-dot table. Each string in the table array represents a braille character. The string at index i in the array is interpreted as the translation for the braille character with Unicode value 0x2800+i.
        Parameters:
        table - the table data, 256 entries
        charset - the preferred charset as defined in the BrailleConverter interface
        ignoreCase - set to true to ignore character case
        mode - the match mode to use
        Throws:
        IllegalArgumentException - if the table length isn't equal to 256
    • 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 interface BrailleConverter
        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 interface BrailleConverter
        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 interface BrailleConverter
        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 interface BrailleConverter
        Parameters:
        braille - the braille to convert
        Returns:
        returns a text string