Class Encoding

  • Direct Known Subclasses:
    MacRomanEncoding

    public abstract class Encoding
    extends java.lang.Object
    This is an interface to a text encoder.
    Version:
    $Revision: 1.1 $
    Author:
    Ben Litchfield
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Map<java.lang.Integer,​java.lang.String> codeToName
      This is a mapping from a character code to a character name.
      static java.lang.String[] MAC_GLYPH_NAMES
      The 258 standard mac glyph names a used in 'post' format 1 and 2.
      static java.util.Map<java.lang.String,​java.lang.Integer> MAC_GLYPH_NAMES_INDICES
      The indices of the standard mac glyph names.
      protected java.util.Map<java.lang.String,​java.lang.Integer> nameToCode
      This is a mapping from a character name to a character code.
      static int NUMBER_OF_MAC_GLYPHS
      The number of standard mac glyph names.
    • Constructor Summary

      Constructors 
      Constructor Description
      Encoding()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addCharacterEncoding​(int code, java.lang.String name)
      This will add a character encoding.
      java.lang.String getCharacter​(int code)
      This will get the character from the code.
      static java.lang.String getCharacter​(java.lang.String name)
      This will get the character from the name.
      int getCode​(java.lang.String name)
      This will get the character code for the name.
      java.lang.String getName​(int code)
      This will take a character code and get the name from the code.
      java.lang.String getNameFromCharacter​(char c)
      This will take a character code and get the name from the code.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • NUMBER_OF_MAC_GLYPHS

        public static final int NUMBER_OF_MAC_GLYPHS
        The number of standard mac glyph names.
        See Also:
        Constant Field Values
      • MAC_GLYPH_NAMES

        public static final java.lang.String[] MAC_GLYPH_NAMES
        The 258 standard mac glyph names a used in 'post' format 1 and 2.
      • MAC_GLYPH_NAMES_INDICES

        public static java.util.Map<java.lang.String,​java.lang.Integer> MAC_GLYPH_NAMES_INDICES
        The indices of the standard mac glyph names.
      • codeToName

        protected java.util.Map<java.lang.Integer,​java.lang.String> codeToName
        This is a mapping from a character code to a character name.
      • nameToCode

        protected java.util.Map<java.lang.String,​java.lang.Integer> nameToCode
        This is a mapping from a character name to a character code.
    • Constructor Detail

      • Encoding

        public Encoding()
    • Method Detail

      • addCharacterEncoding

        protected void addCharacterEncoding​(int code,
                                            java.lang.String name)
        This will add a character encoding.
        Parameters:
        code - The character code that matches the character.
        name - The name of the character.
      • getCode

        public int getCode​(java.lang.String name)
                    throws java.io.IOException
        This will get the character code for the name.
        Parameters:
        name - The name of the character.
        Returns:
        The code for the character.
        Throws:
        java.io.IOException - If there is no character code for the name.
      • getName

        public java.lang.String getName​(int code)
                                 throws java.io.IOException
        This will take a character code and get the name from the code.
        Parameters:
        code - The character code.
        Returns:
        The name of the character.
        Throws:
        java.io.IOException - If there is no name for the code.
      • getNameFromCharacter

        public java.lang.String getNameFromCharacter​(char c)
                                              throws java.io.IOException
        This will take a character code and get the name from the code.
        Parameters:
        c - The character.
        Returns:
        The name of the character.
        Throws:
        java.io.IOException - If there is no name for the character.
      • getCharacter

        public java.lang.String getCharacter​(int code)
                                      throws java.io.IOException
        This will get the character from the code.
        Parameters:
        code - The character code.
        Returns:
        The printable character for the code.
        Throws:
        java.io.IOException - If there is not name for the character.
      • getCharacter

        public static java.lang.String getCharacter​(java.lang.String name)
        This will get the character from the name.
        Parameters:
        name - The name of the character.
        Returns:
        The printable character for the code.