class JavaScriptEncoder extends Encoder
Modifier and Type | Class and Description |
---|---|
(package private) static class |
JavaScriptEncoder.Mode
Mode of operation constants for the JavaScriptEncoder.
|
Modifier and Type | Field and Description |
---|---|
private boolean |
_asciiOnly
True if the output should only include ASCII characters.
|
private boolean |
_hexEncodeQuotes
True if quotation characters should be hex encoded.
|
private JavaScriptEncoder.Mode |
_mode
The mode of operations--used for toString implementation.
|
private int[] |
_validMasks
An array of 4 32-bit integers used as bitmasks to check if a character
needs encoding or not.
|
Constructor and Description |
---|
JavaScriptEncoder(JavaScriptEncoder.Mode mode,
boolean asciiOnly)
Constructs a new JavaScriptEncoder for the specified contextual mode.
|
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.
|
(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. |
java.lang.String |
toString() |
encode, encodeBuffers, overflow, underflow
private final JavaScriptEncoder.Mode _mode
private final boolean _hexEncodeQuotes
private final int[] _validMasks
private final boolean _asciiOnly
JavaScriptEncoder(JavaScriptEncoder.Mode mode, boolean asciiOnly)
mode
- the mode of operationasciiOnly
- true if only ASCII characters should be included in the
output (all code-points outside the ASCII range will be encoded).int maxEncodedLength(int n)
Encoder
n
characters.maxEncodedLength
in class Encoder
n
- the number of characters of inputint 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)
Encoder
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