class HTMLEncoder extends Encoder
HTMLEncoder -- an encoder for HTML contexts. Currently most HTML-based
contexts are properly handled by XMLEncoder. The remaining
HTML-specific context of "unquoted attributes" could not be added to the
XMLEncoder without slowing it down. This class implements that remaining
context: unquoted attribute values.
Note: because this context is likely small strings, and hopefully rarely used, no effort was put into optimizing this encoder.
| Modifier and Type | Field and Description |
|---|---|
private static char[] |
AMP
Encoding for '&'.
|
private static int |
ENCODE_AFFIX_CHAR_COUNT
Number of characters in the encoding prefix and suffix when using decimal
numeric encodings of the form "...;".
|
private static char[] |
GT
Encoding for '>'.
|
private static char[] |
LT
Encoding for '<'.
|
private static char[] |
TAB
Encoding for '\t'.
|
| Constructor and Description |
|---|
HTMLEncoder() |
| Modifier and Type | Method and Description |
|---|---|
(package private) static int |
append(char[] src,
char[] out,
int j)
Appends a source array verbatim to the output array.
|
(package private) static int |
encode(int codePoint,
char[] out,
int j)
Appends the numerically encoded version of
codePoint to the
output buffer. |
(package private) 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.
|
(package private) int |
firstEncodedOffset(java.lang.String input,
int off,
int len)
Scans the input string for the first character index that requires
encoding.
|
(package private) int |
maxEncodedLength(int n)
Returns the maximum encoded length (in chars) of an input sequence of
n characters. |
encode, encodeBuffers, overflow, underflowprivate static final int ENCODE_AFFIX_CHAR_COUNT
private static final char[] TAB
private static final char[] AMP
private static final char[] LT
private static final char[] GT
int maxEncodedLength(int n)
Encodern characters.maxEncodedLength in class Encodern - the number of characters of inputint firstEncodedOffset(java.lang.String input,
int off,
int len)
EncoderfirstEncodedOffset in class Encoderinput - 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.static int append(char[] src,
char[] out,
int j)
src - the characters to copyout - the output bufferj - the offset where to write in the output bufferj + src.lengthstatic int encode(int codePoint,
char[] out,
int j)
codePoint to the
output buffer. Caller must insure there is enough space for the output.codePoint - the character to encodeout - the output bufferj - the offset where to write in the output bufferj + the encoded length.java.nio.charset.CoderResult encodeArrays(java.nio.CharBuffer input,
java.nio.CharBuffer output,
boolean endOfInput)
EncoderencodeArrays in class Encoderinput - the input buffer.output - the output buffer.endOfInput - when true, this is the last input to encode