org.apache.fop.fonts

## Class SimpleSingleByteEncoding

- java.lang.Object
- - org.apache.fop.fonts.SimpleSingleByteEncoding

- All Implemented Interfaces:
    SingleByteEncoding

      public class SimpleSingleByteEncoding
      extends Object
      implements SingleByteEncoding

  A simple implementation of the OneByteEncoding mostly used for encodings that are constructed on-the-fly.

- - ### Field Summary

    - ### Fields inherited from interface org.apache.fop.fonts.SingleByteEncoding

      `NOT_FOUND_CODE_POINT`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SimpleSingleByteEncoding(String name)` Main constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `char` | `addCharacter(NamedCharacter ch)` Adds a new character to the encoding.
    `NamedCharacter` | `getCharacterForIndex(int codePoint)` Returns the named character at a given code point in the encoding.
    `String[]` | `getCharNameMap()` Returns the array of character names for this encoding.
    `int` | `getFirstChar()` Returns the index of the first defined character.
    `int` | `getLastChar()` Returns the index of the last defined character.
    `String` | `getName()` Returns the encoding's name.
    `int` | `getSize()` Returns the number of characters defined by this encoding.
    `char[]` | `getUnicodeCharMap()` Returns a character array with Unicode scalar values which can be used to map encoding code points to Unicode values.
    `boolean` | `isFull()` Indicates whether the encoding is full (with 256 code points).
    `char` | `mapChar(char c)` Maps a Unicode character to a code point in the encoding.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### SimpleSingleByteEncoding

          public SimpleSingleByteEncoding(String name)

      Main constructor.
      Parameters:
        `name` - the encoding's name

  - ### Method Detail

    - #### getName

          public String getName()

      Returns the encoding's name.
      Specified by:
        `getName` in interface `SingleByteEncoding`
      Returns:
        the name of the encoding

    - #### mapChar

          public char mapChar(char c)

      Maps a Unicode character to a code point in the encoding.
      Specified by:
        `mapChar` in interface `SingleByteEncoding`
      Parameters:
        `c` - the Unicode character to map
      Returns:
        the code point in the encoding or 0 (=.notdef) if not found

    - #### getCharNameMap

          public String[] getCharNameMap()

      Returns the array of character names for this encoding.
      Specified by:
        `getCharNameMap` in interface `SingleByteEncoding`
      Returns:
        the array of character names (unmapped code points are represented by a ".notdef" value)

    - #### getFirstChar

          public int getFirstChar()

      Returns the index of the first defined character.
      Returns:
        the index of the first defined character (always 1 for this class)

    - #### getLastChar

          public int getLastChar()

      Returns the index of the last defined character.
      Returns:
        the index of the last defined character

    - #### getSize

          public int getSize()

      Returns the number of characters defined by this encoding.
      Returns:
        the number of characters

    - #### isFull

          public boolean isFull()

      Indicates whether the encoding is full (with 256 code points).
      Returns:
        true if the encoding is full

    - #### addCharacter

          public char addCharacter(NamedCharacter ch)

      Adds a new character to the encoding.
      Parameters:
        `ch` - the named character
      Returns:
        the code point assigned to the character

    - #### getCharacterForIndex

          public NamedCharacter getCharacterForIndex(int codePoint)

      Returns the named character at a given code point in the encoding.
      Parameters:
        `codePoint` - the code point of the character
      Returns:
        the NamedCharacter (or null if no character is at this position)

    - #### getUnicodeCharMap

          public char[] getUnicodeCharMap()

      Returns a character array with Unicode scalar values which can be used to map encoding code points to Unicode values. Note that this does not return all possible Unicode values that the encoding maps.
      Specified by:
        `getUnicodeCharMap` in interface `SingleByteEncoding`
      Returns:
        a character array with Unicode scalar values

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2023 Apache Software Foundation. All rights reserved.