Package org.apache.fop.afp.fonts
Class CharactersetEncoder
- java.lang.Object
-
- org.apache.fop.afp.fonts.CharactersetEncoder
-
- Direct Known Subclasses:
CharactersetEncoder.DefaultEncoder
,CharactersetEncoder.EbcdicDoubleByteLineDataEncoder
public abstract class CharactersetEncoder extends java.lang.Object
An abstraction that wraps the encoding mechanism for encoding a Unicode character sequence into a specified format.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
CharactersetEncoder.DefaultEncoder
The default encoder is used for encoding IBM format SBCS (single byte character sets), this the primary format for most Latin character sets.(package private) static class
CharactersetEncoder.EbcdicDoubleByteLineDataEncoder
The EBCDIC double byte encoder is used for encoding IBM format DBCS (double byte character sets) with an EBCDIC code-page.static class
CharactersetEncoder.EncodedChars
A container for encoded character bytes
-
Field Summary
Fields Modifier and Type Field Description private java.nio.charset.CharsetEncoder
encoder
-
Constructor Summary
Constructors Modifier Constructor Description private
CharactersetEncoder(java.lang.String encoding)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) boolean
canEncode(char c)
Tells whether or not this encoder can encode the given character.(package private) CharactersetEncoder.EncodedChars
encode(java.lang.CharSequence chars)
Encodes a character sequence to a byte array.static CharactersetEncoder.EncodedChars
encodeSBCS(java.lang.CharSequence chars, java.lang.String encoding)
Encodeschars
into a format specified byencoding
.(package private) abstract CharactersetEncoder.EncodedChars
getEncodedChars(byte[] byteArray, int length)
-
-
-
Method Detail
-
canEncode
final boolean canEncode(char c)
Tells whether or not this encoder can encode the given character.- Parameters:
c
- the character- Returns:
- true if, and only if, this encoder can encode the given character
- Throws:
java.lang.IllegalStateException
- - If an encoding operation is already in progress
-
encode
final CharactersetEncoder.EncodedChars encode(java.lang.CharSequence chars) throws java.nio.charset.CharacterCodingException
Encodes a character sequence to a byte array.- Parameters:
chars
- the character sequence- Returns:
- the encoded character sequence
- Throws:
java.nio.charset.CharacterCodingException
- if the encoding operation fails
-
getEncodedChars
abstract CharactersetEncoder.EncodedChars getEncodedChars(byte[] byteArray, int length)
-
encodeSBCS
public static CharactersetEncoder.EncodedChars encodeSBCS(java.lang.CharSequence chars, java.lang.String encoding) throws java.nio.charset.CharacterCodingException
Encodeschars
into a format specified byencoding
.- Parameters:
chars
- the character sequenceencoding
- the encoding type- Returns:
- encoded data
- Throws:
java.nio.charset.CharacterCodingException
- if encoding fails
-
-