All Packages Class Hierarchy This Package Previous Next Index
Interface com.jclark.xml.tok.ByteToCharConverter
- public interface ByteToCharConverter
Converts bytes to characters.
An encoding that maps sequences of characters to sequences of bytes
can be supported by this interface if:
- it is stateless; that is, the sequence of bytes that encodes
a sequence of characters is the concatenation of the sequences
of bytes that encodes each character in the sequence; and
- the lead byte in the encoding of a character determines the
number of bytes used to encode a character; that is,
whenever two sequences of bytes each encode a character, and the
first byte of each sequence is the same, then the length of the
sequences is the same.
-
convertBytes(byte[], int)
- Returns the Unicode scalar value of the character encoded
by the
n
bytes in
buf
starting at offset off
,
where n >= 2
and
n = -getLeadByteType(buf[off])
.
-
getLeadByteType(byte)
- If the byte
b
by itself
encodes a character whose Unicode scalar value is c
,
returns c
.
getLeadByteType
public abstract int getLeadByteType(byte b)
- If the byte
b
by itself
encodes a character whose Unicode scalar value is c
,
returns c
.
If the byte b
is the first byte
of a n
-byte sequence that encodes a character
where n >= 2
, returns -n
.
Otherwise return -1.
convertBytes
public abstract int convertBytes(byte buf[],
int off)
- Returns the Unicode scalar value of the character encoded
by the
n
bytes in
buf
starting at offset off
,
where n >= 2
and
n = -getLeadByteType(buf[off])
.
Returns -1 if the bytes do not encode any character.
All Packages Class Hierarchy This Package Previous Next Index