class XMLEncoder extends Encoder
Modifier and Type | Class and Description |
---|---|
(package private) static class |
XMLEncoder.Mode
An enum of supported "modes" of operation for the XMLEncoder.
|
Modifier and Type | Field and Description |
---|---|
private XMLEncoder.Mode |
_mode
The mode of operation--only really stored to provide a relevant toString
implementation.
|
private long |
_validMask
The mask of valid characters extracted from the mode for efficiency.
|
(package private) static int |
AMP_LENGTH
The encoded length of an ampersand.
|
(package private) static int |
APOS_LENGTH
The encoded length of an apostrophe.
|
private static long |
BASE_VALID_MASK
A bit-mask of valid characters with code-points in the range 0--63.
|
(package private) static int |
GT_LENGTH
The encoded length of a greater-than sign.
|
(package private) static char |
INVALID_CHARACTER_REPLACEMENT
Character to use as a replacement for invalid characters (Not to be
confused with characters that require encoding).
|
(package private) static int |
LT_LENGTH
The encoded length of a less-than sign.
|
(package private) static int |
MAX_ENCODED_CHAR_LENGTH
Maximum number of encoded characters per input character.
|
(package private) static int |
QUOT_LENGTH
The encoded length of a double-quotation character.
|
Constructor and Description |
---|
XMLEncoder()
Default constructor--equivalent to XMLEncoder(Mode.ALL).
|
XMLEncoder(XMLEncoder.Mode mode)
Creates an XMLEncoder for the specified mode constant.
|
Modifier and Type | Method and Description |
---|---|
protected java.nio.charset.CoderResult |
encodeArrays(java.nio.CharBuffer input,
java.nio.CharBuffer output,
boolean endOfInput)
The core encoding loop used when both the input and output buffers
are array backed.
|
int |
firstEncodedOffset(java.lang.String input,
int off,
int len)
Scans the input string for the first character index that requires
encoding.
|
int |
maxEncodedLength(int n)
Returns the maximum encoded length (in chars) of an input sequence of
n characters. |
java.lang.String |
toString() |
encode, encodeBuffers, overflow, underflow
private static final long BASE_VALID_MASK
static final int MAX_ENCODED_CHAR_LENGTH
static final int AMP_LENGTH
static final int LT_LENGTH
static final int GT_LENGTH
static final int APOS_LENGTH
static final int QUOT_LENGTH
static final char INVALID_CHARACTER_REPLACEMENT
private final long _validMask
private final XMLEncoder.Mode _mode
XMLEncoder()
XMLEncoder(XMLEncoder.Mode mode)
mode
- the mode of the encoder.public int maxEncodedLength(int n)
Encoder
n
characters.maxEncodedLength
in class Encoder
n
- the number of characters of inputpublic int firstEncodedOffset(java.lang.String input, int off, int len)
Encoder
firstEncodedOffset
in class Encoder
input
- the input to check for encodingoff
- the offset of the first character to checklen
- the number of characters to checkoff+len
if no characters in the input require encoding.protected java.nio.charset.CoderResult encodeArrays(java.nio.CharBuffer input, java.nio.CharBuffer output, boolean endOfInput)
encodeArrays
in class Encoder
input
- the input buffer.output
- the output buffer.endOfInput
- when true, this is the last input to encodepublic java.lang.String toString()
toString
in class java.lang.Object