public abstract class ByteLookupCharset
extends java.nio.charset.Charset
Modifier and Type | Class and Description |
---|---|
protected class |
ByteLookupCharset.Decoder
The Decoder inner class handles the decoding of the
charset using the inverse lookup table.
|
protected class |
ByteLookupCharset.Encoder
The Encoder inner class handles the encoding of the
charset using the lookup table.
|
Modifier | Constructor and Description |
---|---|
protected |
ByteLookupCharset(java.lang.String canonicalName,
java.lang.String[] aliases,
int[] byteToChar,
int[][] charToByte)
Initializes a new charset with the given canonical name and alias
set, and byte-to-char/char-to-byte lookup tables.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(java.nio.charset.Charset cs)
Tells whether or not this charset contains the given charset.
|
static int[][] |
createInverseLookupTable(int[] chars)
Creates an inverse lookup table for the given byte-to-char lookup table.
|
static java.lang.String |
createInverseLookupTableDefinition(int[] chars)
Returns a string containing Java definitions of the inverse lookup
table returned by getInverseLookupTable for the given byte-to-char
lookup table.
|
protected static int[] |
mutate(int[] src,
int[] ind,
int[] val)
Returns a copy of the given array in which several items
are modified.
|
java.nio.charset.CharsetDecoder |
newDecoder()
Constructs a new decoder for this charset.
|
java.nio.charset.CharsetEncoder |
newEncoder()
Constructs a new encoder for this charset.
|
static int[][] |
updateInverseLookupTable(int[][] tables,
int[] chars,
int[] bytes)
Updates an inverse lookup table with additional mappings,
replacing previous mappings of the same values if they exists.
|
static int[][] |
updateInverseLookupTable(int[][] tables,
int c,
int b)
Updates an inverse lookup table with an additional mapping,
replacing a previous mapping of the same value if it exists.
|
protected ByteLookupCharset(java.lang.String canonicalName, java.lang.String[] aliases, int[] byteToChar, int[][] charToByte)
canonicalName
- The canonical name of this charsetaliases
- An array of this charset's aliases, or null if it has no aliasesbyteToChar
- a byte-to-char conversion table for this charsetcharToByte
- a char-to-byte conversion table for this charset. It can
be generated on-the-fly by calling createInverseLookupTable(byteToChar).java.nio.charset.IllegalCharsetNameException
- If the canonical name or any of the aliases are illegalprotected static int[] mutate(int[] src, int[] ind, int[] val)
src
- the array to mutateind
- the array indices in which the values will be modifiedval
- the respective values to place in these indicespublic static int[][] createInverseLookupTable(int[] chars)
chars
- a lookup table which holds the character value
that each byte value (0-255) is converted to.public static int[][] updateInverseLookupTable(int[][] tables, int c, int b)
tables
- the inverse lookup table to update
(see createInverseLookupTable(int[])
)c
- the character to mapb
- the byte value to which c is mapped, or -1 to mark an illegal mappingpublic static int[][] updateInverseLookupTable(int[][] tables, int[] chars, int[] bytes)
tables
- the inverse lookup table to update
(see createInverseLookupTable(int[])
)chars
- the characters to mapbytes
- the respective byte values to which the chars are mapped,
or -1 to mark an illegal mappingpublic static java.lang.String createInverseLookupTableDefinition(int[] chars)
chars
- a lookup table which holds the character value
that each byte value (0-255) is converted to.public boolean contains(java.nio.charset.Charset cs)
A charset C is said to contain a charset D if, and only if, every character representable in D is also representable in C. If this relationship holds then it is guaranteed that every string that can be encoded in D can also be encoded in C without performing any replacements.
That C contains D does not imply that each character representable in C by a particular byte sequence is represented in D by the same byte sequence, although sometimes this is the case.
Every charset contains itself.
This method computes an approximation of the containment relation: If it returns true then the given charset is known to be contained by this charset; if it returns false, however, then it is not necessarily the case that the given charset is not contained in this charset.
contains
in class java.nio.charset.Charset
public java.nio.charset.CharsetDecoder newDecoder()
newDecoder
in class java.nio.charset.Charset
public java.nio.charset.CharsetEncoder newEncoder()
newEncoder
in class java.nio.charset.Charset
java.lang.UnsupportedOperationException
- If this charset does not support encoding