class URIEncoder extends Encoder
Modifier and Type | Class and Description |
---|---|
static class |
URIEncoder.Mode
Encoding mode of operation for URI encodes.
|
Modifier and Type | Field and Description |
---|---|
private long |
_highMask
The bit-mask of characters that do not need to be escaped, for character with code-points in the range 64 to 127.
|
private long |
_lowMask
The bit-mask of characters that do not need to be escaped, for characters with code-points in the range 0 to 63.
|
private URIEncoder.Mode |
_mode
The encoding mode for this encoder--used primarily for toString().
|
(package private) static int |
CHARS_0_TO_9
Number of characters in the range '0' to '9'.
|
(package private) static int |
CHARS_A_TO_Z
Number of characters in the range 'a' to 'z'.
|
(package private) static char |
INVALID_REPLACEMENT_CHARACTER
The character to use when replacing an invalid character.
|
(package private) static int |
LONG_BITS
Number of bits in a long.
|
(package private) static int |
MAX_ENCODED_CHAR_LENGTH
Maximum number of characters quired to encode a single input character.
|
(package private) static int |
MAX_UTF8_2_BYTE
Maximum code-point value that can be encoded with 2 utf-8 bytes.
|
(package private) static int |
PERCENT_ENCODED_LENGTH
Number of characters used to '%' encode a single hex-value.
|
(package private) static long |
RESERVED_MASK_HIGH
The second 64 RFC 3986 Reserved characters.
|
(package private) static long |
RESERVED_MASK_LOW
RFC 3986 Reserved Characters.
|
(package private) static char[] |
UHEX
RFC 3986 -- "The uppercase hexadecimal digits 'A' through 'F' are equivalent to the lowercase digits 'a' through 'f',
respectively.
|
(package private) static long |
UNRESERVED_MASK_HIGH
RFC 3986 Unreserved Characters.
|
(package private) static long |
UNRESERVED_MASK_LOW
RFC 3986 Unreserved Characters.
|
(package private) static int |
UTF8_2_BYTE_FIRST_MSB
When the encoded output requires 2 bytes, this is the high bits of the first byte.
|
(package private) static int |
UTF8_3_BYTE_FIRST_MSB
When the encoded output requires 3 bytes, this is the high bits of the first byte.
|
(package private) static int |
UTF8_4_BYTE_FIRST_MSB
When the encoded output requires 4 bytes, this is the high bits of the first byte.
|
(package private) static int |
UTF8_BYTE_MSB
For all characters in a 2-4 byte encoded sequence after the first this is the high bits of the input bytes.
|
(package private) static int |
UTF8_MASK
This is the mask containing 6-ones in the lower 6-bits.
|
(package private) static int |
UTF8_SHIFT
UTF-8 encodes 6-bits of the code-point in each output UTF-8 byte.
|
Constructor and Description |
---|
URIEncoder()
Constructor equivalent to @{code URIEncoder(Mode.FULL_URI)}.
|
URIEncoder(URIEncoder.Mode mode)
Constructor for the URIEncoder the specifies the encoding mode the URIEncoder will use.
|
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.
|
protected int |
firstEncodedOffset(java.lang.String input,
int off,
int len)
Scans the input string for the first character index that requires
encoding.
|
protected 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
static final int CHARS_0_TO_9
static final int CHARS_A_TO_Z
static final int LONG_BITS
static final int MAX_ENCODED_CHAR_LENGTH
static final int PERCENT_ENCODED_LENGTH
static final int MAX_UTF8_2_BYTE
static final int UTF8_2_BYTE_FIRST_MSB
static final int UTF8_3_BYTE_FIRST_MSB
static final int UTF8_4_BYTE_FIRST_MSB
static final int UTF8_BYTE_MSB
static final int UTF8_SHIFT
static final int UTF8_MASK
static final char INVALID_REPLACEMENT_CHARACTER
static final char[] UHEX
static final long UNRESERVED_MASK_LOW
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
static final long UNRESERVED_MASK_HIGH
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
static final long RESERVED_MASK_LOW
reserved = gen-delims / sub-delims gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@" sub-delims = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
static final long RESERVED_MASK_HIGH
private final long _lowMask
private final long _highMask
private final URIEncoder.Mode _mode
URIEncoder()
URIEncoder(URIEncoder.Mode mode)
mode
- the encoding mode for this encoder.protected int maxEncodedLength(int n)
Encoder
n
characters.maxEncodedLength
in class Encoder
n
- the number of characters of inputprotected 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)
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