An object of this type has two useful methods
isInEncoding(char ch);which can be called if the character is not the high one in a surrogate pair and:
isInEncoding(char high, char low);which can be called if the two characters from a high/low surrogate pair.
An EncodingInfo object is a node in a binary search tree. Such a node
will answer if a character is in the encoding, and do so for a given
range of unicode values (m_first to
m_last). It will handle a certain range of values
explicitly (m_explFirst to m_explLast).
If the unicode point is before that explicit range, that is it
is in the range m_first <= value < m_explFirst, then it will delegate to another EncodingInfo object for The root
of such a tree, m_before. Likewise for values in the range
m_explLast < value <= m_last, but delgating to m_after
Actually figuring out if a code point is in the encoding is expensive. So the purpose of this tree is to cache such determinations, and not to build the entire tree of information at the start, but only build up as much of the tree as is used during the transformation.
This Class is not a public API, and should only be used internally within the serializer.
| Modifier and Type | Class and Description |
|---|---|
| private class | EncodingInfo.
This class implements the |
| private static interface | EncodingInfo.
A simple interface to isolate the implementation. |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final String | javaName
The name used by the Java convertor. |
| private EncodingInfo. | m_encoding
A helper object that we can ask if a single char, or a surrogate UTF-16 pair of chars that form a single character, is in this encoding. |
| pack-priv final String | name
The ISO encoding name. |
| Access | Constructor and Description |
|---|---|
| public | EncodingInfo(String
reference to the ISO name. name, String reference to the Java encoding name. javaName)Create an EncodingInfo object based on the ISO name and Java name. |
| Modifier and Type | Method and Description |
|---|---|
| private static boolean | inEncoding(char
the char in question, that is not a high char of
a high/low surrogate pair. ch, String the Java name of the enocding. encoding)This is heart of the code that determines if a given character is in the given encoding. |
| private static boolean | inEncoding(char
the high char of
a high/low surrogate pair. high, char the low char of a high/low surrogate pair. low, String the Java name of the encoding. encoding)This is heart of the code that determines if a given high/low surrogate pair forms a character that is in the given encoding. |
| private static boolean | Returns: true if the character is in the encoding.the char that was converted using getBytes, or
the first char of a high/low pair that was converted. ch, byte[] the bytes written out by the call to s.getBytes(encoding); data)This method is the core of determining if character is in the encoding. |
| public boolean | |
| public boolean | isInEncoding(char
a char that the a high char of a high/low surrogate pair. high, char a char that is the low char of a high/low surrogate pair. low)This is not a public API. |
| javaName | back to summary |
|---|---|
| pack-priv final String javaName The name used by the Java convertor. | |
| m_encoding | back to summary |
|---|---|
| private EncodingInfo. A helper object that we can ask if a single char, or a surrogate UTF-16 pair of chars that form a single character, is in this encoding. | |
| name | back to summary |
|---|---|
| pack-priv final String name The ISO encoding name. | |
| EncodingInfo | back to summary |
|---|---|
| public EncodingInfo(String name, String javaName) Create an EncodingInfo object based on the ISO name and Java name. If both parameters are null any character will be considered to be in the encoding. This is useful for when the serializer is in temporary output state, and has no assciated encoding. | |
| inEncoding | back to summary |
|---|---|
| private static boolean inEncoding(char ch, String encoding) This is heart of the code that determines if a given character is in the given encoding. This method is probably expensive, and the answer should be cached. This method is not a public API, and should only be used internally within the serializer.
| |
| inEncoding | back to summary |
|---|---|
| private static boolean inEncoding(char high, char low, String encoding) This is heart of the code that determines if a given high/low surrogate pair forms a character that is in the given encoding. This method is probably expensive, and the answer should be cached. This method is not a public API, and should only be used internally within the serializer.
| |
| inEncoding | back to summary |
|---|---|
| private static boolean inEncoding(char ch, byte[] data) This method is the core of determining if character is in the encoding. The method is not foolproof, because s.getBytes(encoding) has specified behavior only if the characters are in the specified encoding. However this method tries it's best.
| |
| isInEncoding | back to summary |
|---|---|
| public boolean isInEncoding(char ch) This is not a public API. It returns true if the char in question is in the encoding.
| |
| isInEncoding | back to summary |
|---|---|
| public boolean isInEncoding(char high, char low) This is not a public API. It returns true if the character formed by the high/low pair is in the encoding.
| |
| Modifier and Type | Field and Description |
|---|---|
| private EncodingInfo. | m_after
The object, of the same type as this one, that handles unicode values in a range after the range explictly handled by this object, and to which this object may delegate. |
| private final boolean[] | m_alreadyKnown
A flag to record if we already know the answer for the given unicode value. |
| private EncodingInfo. | m_before
The object, of the same type as this one, that handles unicode values in a range before the range explictly handled by this object, and to which this object may delegate. |
| private final String | m_encoding
The encoding. |
| private final int | m_explFirst
m_explFirst through m_explLast is the range of unicode value that this object handles explicitly and does not delegate to a similar object. |
| private final int | |
| private final int | m_first
m_first through m_last is the range of unicode values that this object will return an answer on. |
| private final boolean[] | m_isInEncoding
A table holding the answer on whether the given unicode value is in the encoding. |
| private final int | |
| private static final int | RANGE
The number of unicode values explicitly handled by a single EncodingInfo object. |
| Access | Constructor and Description |
|---|---|
| private | |
| private |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | isInEncoding(char ch1)
Implements com. Returns true if the char is in the encoding |
| public boolean | isInEncoding(char high, char low)
Implements com. Returns true if the high/low surrogate pair forms a character that is in the encoding. |
| m_after | back to summary |
|---|---|
| private EncodingInfo. The object, of the same type as this one, that handles unicode values in a range after the range explictly handled by this object, and to which this object may delegate. | |
| m_alreadyKnown | back to summary |
|---|---|
| private final boolean[] m_alreadyKnown A flag to record if we already know the answer for the given unicode value. | |
| m_before | back to summary |
|---|---|
| private EncodingInfo. The object, of the same type as this one, that handles unicode values in a range before the range explictly handled by this object, and to which this object may delegate. | |
| m_encoding | back to summary |
|---|---|
| private final String m_encoding The encoding. | |
| m_explFirst | back to summary |
|---|---|
| private final int m_explFirst m_explFirst through m_explLast is the range of unicode value that this object handles explicitly and does not delegate to a similar object. | |
| m_explLast | back to summary |
|---|---|
| private final int m_explLast | |
| m_first | back to summary |
|---|---|
| private final int m_first m_first through m_last is the range of unicode values that this object will return an answer on. It may delegate to a similar object with a different range | |
| m_isInEncoding | back to summary |
|---|---|
| private final boolean[] m_isInEncoding A table holding the answer on whether the given unicode value is in the encoding. | |
| m_last | back to summary |
|---|---|
| private final int m_last | |
| RANGE | back to summary |
|---|---|
| private static final int RANGE The number of unicode values explicitly handled by a single EncodingInfo object. This value is tuneable, but is set to 128 because that covers the entire low range of ASCII type chars within a single object. | |
| EncodingImpl | back to summary |
|---|---|
| private EncodingImpl() | |
| EncodingImpl | back to summary |
|---|---|
| private EncodingImpl(String encoding, int first, int last, int codePoint) | |
| isInEncoding | back to summary |
|---|---|
| public boolean isInEncoding(char ch1) Implements com. Doc from com. Returns true if the char is in the encoding | |
| isInEncoding | back to summary |
|---|---|
| public boolean isInEncoding(char high, char low) Implements com. Doc from com. Returns true if the high/low surrogate pair forms a character that is in the encoding. | |
This interface is not a public API, and should only be used internally within the serializer.
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public boolean | isInEncoding(char high, char low)
Returns true if the high/low surrogate pair forms a character that is in the encoding. |
| isInEncoding | back to summary |
|---|---|
| public boolean isInEncoding(char ch) Returns true if the char is in the encoding | |
| isInEncoding | back to summary |
|---|---|
| public boolean isInEncoding(char high, char low) Returns true if the high/low surrogate pair forms a character that is in the encoding. | |