class UriComponent extends Object
| Modifier and Type | Class and Description |
|---|---|
private static class |
UriComponent.PathSegment |
(package private) static class |
UriComponent.Type
The URI component type.
|
| Modifier and Type | Field and Description |
|---|---|
private static boolean[][] |
ENCODING_TABLES |
private static char[] |
HEX_DIGITS |
private static int[] |
HEX_TABLE |
private static String[] |
SCHEME |
private static String[] |
SUB_DELIMS |
private static String[] |
UNRESERVED |
private static Charset |
UTF_8_CHARSET |
| Modifier | Constructor and Description |
|---|---|
private |
UriComponent() |
| Modifier and Type | Method and Description |
|---|---|
private static String |
_encode(String s,
UriComponent.Type t,
boolean template,
boolean contextualEncode) |
private static int |
_valid(String s,
UriComponent.Type t,
boolean template) |
private static void |
appendPercentEncodedOctet(StringBuilder sb,
int b) |
private static void |
appendUTF8EncodedCharacter(StringBuilder sb,
char c) |
(package private) static String |
contextualEncode(String s,
UriComponent.Type t)
Contextually encodes the characters of string that are either non-ASCII characters or are ASCII characters that
must be percent-encoded using the UTF-8 encoding.
|
(package private) static String |
contextualEncode(String s,
UriComponent.Type t,
boolean template)
Contextually encodes the characters of string that are either non-ASCII characters or are ASCII characters that
must be percent-encoded using the UTF-8 encoding.
|
private static String |
decode(String s,
int n) |
(package private) static String |
decode(String s,
UriComponent.Type t)
Decodes characters of a string that are percent-encoded octets using UTF-8 decoding (if needed).
|
private static int |
decodeHex(char c) |
private static int |
decodeHex(String s,
int i) |
private static String |
decodeHost(String s,
int n) |
(package private) static MultivaluedMap<String,String> |
decodeMatrix(String pathSegment,
boolean decode)
Decode the matrix component of a URI path segment.
|
private static void |
decodeMatrixParam(MultivaluedMap<String,String> params,
String param,
boolean decode) |
private static int |
decodeOctets(int i,
ByteBuffer bb,
StringBuilder sb)
Decodes octets to characters using the UTF-8 decoding and appends the characters to a StringBuffer.
|
(package private) static List<UriComponent.PathSegment> |
decodePath(String path,
boolean decode)
Decode the path component of a URI as path segments.
|
(package private) static List<UriComponent.PathSegment> |
decodePath(URI u,
boolean decode)
Decode the path component of a URI as path segments.
|
(package private) static void |
decodePathSegment(List<UriComponent.PathSegment> segments,
String segment,
boolean decode)
Decode the path segment and add it to the list of path segments.
|
private static ByteBuffer |
decodePercentEncodedOctets(String s,
int i,
ByteBuffer bb)
Decode a continuous sequence of percent encoded octets.
|
(package private) static MultivaluedMap<String,String> |
decodeQuery(String q,
boolean decode)
Decode the query component of a URI.
|
(package private) static MultivaluedMap<String,String> |
decodeQuery(String q,
boolean decodeNames,
boolean decodeValues)
Decode the query component of a URI.
|
(package private) static MultivaluedMap<String,String> |
decodeQuery(URI u,
boolean decode)
Decode the query component of a URI.
|
private static void |
decodeQueryParam(MultivaluedMap<String,String> params,
String param,
boolean decodeNames,
boolean decodeValues) |
private static String |
decodeQueryParam(String s,
int n) |
(package private) static String |
encode(String s,
UriComponent.Type t)
Encodes the characters of string that are either non-ASCII characters or are ASCII characters that must be
percent-encoded using the UTF-8 encoding.
|
(package private) static String |
encode(String s,
UriComponent.Type t,
boolean template)
Encodes the characters of string that are either non-ASCII characters or are ASCII characters that must be
percent-encoded using the UTF-8 encoding.
|
(package private) static String |
encodeTemplateNames(String s)
Encodes a string with template parameters names present, specifically the characters '{' and '}' will be
percent-encoded.
|
private static boolean[] |
initEncodingTable(List<String> allowed) |
private static boolean[][] |
initEncodingTables() |
private static int[] |
initHexTable() |
(package private) static boolean |
isHexCharacter(char c)
Checks whether the character
c is hexadecimal character. |
(package private) static boolean |
valid(String s,
UriComponent.Type t)
Validates the legal characters of a percent-encoded string that represents a URI component type.
|
(package private) static boolean |
valid(String s,
UriComponent.Type t,
boolean template)
Validates the legal characters of a percent-encoded string that represents a URI component type.
|
(package private) static void |
validate(String s,
UriComponent.Type t)
Validates the legal characters of a percent-encoded string that represents a URI component type.
|
(package private) static void |
validate(String s,
UriComponent.Type t,
boolean template)
Validates the legal characters of a percent-encoded string that represents a URI component type.
|
private static final char[] HEX_DIGITS
private static final String[] SCHEME
private static final String[] UNRESERVED
private static final String[] SUB_DELIMS
private static final boolean[][] ENCODING_TABLES
private static final Charset UTF_8_CHARSET
private static final int[] HEX_TABLE
static void validate(String s, UriComponent.Type t)
s - the encoded string.t - the URI component type identifying the legal characters.IllegalArgumentException - if the encoded string contains illegal characters.static void validate(String s, UriComponent.Type t, boolean template)
s - the encoded string.t - the URI component type identifying the legal characters.template - true if the encoded string contains URI template variablesIllegalArgumentException - if the encoded string contains illegal characters.static boolean valid(String s, UriComponent.Type t)
s - the encoded string.t - the URI component type identifying the legal characters.static boolean valid(String s, UriComponent.Type t, boolean template)
s - the encoded string.t - the URI component type identifying the legal characters.template - true if the encoded string contains URI template variablesprivate static int _valid(String s, UriComponent.Type t, boolean template)
static String contextualEncode(String s, UriComponent.Type t)
s - the string to be encoded.t - the URI component type identifying the ASCII characters that must be percent-encoded.static String contextualEncode(String s, UriComponent.Type t, boolean template)
s - the string to be encoded.t - the URI component type identifying the ASCII characters that must be percent-encoded.template - true if the encoded string contains URI template variablesstatic String encode(String s, UriComponent.Type t)
s - the string to be encoded.t - the URI component type identifying the ASCII characters that must be percent-encoded.static String encode(String s, UriComponent.Type t, boolean template)
s - the string to be encoded.t - the URI component type identifying the ASCII characters that must be percent-encoded.template - true if the encoded string contains URI template variablesstatic String encodeTemplateNames(String s)
s - the string with zero or more template parameters namesprivate static String _encode(String s, UriComponent.Type t, boolean template, boolean contextualEncode)
private static void appendPercentEncodedOctet(StringBuilder sb, int b)
private static void appendUTF8EncodedCharacter(StringBuilder sb, char c)
private static boolean[][] initEncodingTables()
static String decode(String s, UriComponent.Type t)
It is assumed that the string is valid according to an (unspecified) URI component type. If a sequence of contiguous percent-encoded octets is not a valid UTF-8 character then the octets are replaced with '�'.
If the URI component is of type HOST then any "%" found between "[]" is left alone. It is an IPv6 literal with a scope_id.
If the URI component is of type QUERY_PARAM then any "+" is decoded as as ' '.
s - the string to be decoded.t - the URI component type, may be null.IllegalArgumentException - if a malformed percent-encoded octet is detectedstatic MultivaluedMap<String,String> decodeQuery(URI u, boolean decode)
Query parameter names in the returned map are always decoded. Decoding of query parameter values can be
controlled using the decode parameter flag.
u - the URI.decode - true if the returned query parameter values of the query component should be in decoded
form.static MultivaluedMap<String,String> decodeQuery(String q, boolean decode)
Query parameter names in the returned map are always decoded. Decoding of query parameter values can be
controlled using the decode parameter flag.
q - the query component in encoded form.decode - true if the returned query parameter values of the query component should be in decoded
form.static MultivaluedMap<String,String> decodeQuery(String q, boolean decodeNames, boolean decodeValues)
Decoding of query parameter names and values can be controlled using the decodeNames and
decodeValues parameter flags.
q - the query component in encoded form.decodeNames - true if the returned query parameter names of the query component should be in decoded
form.decodeValues - true if the returned query parameter values of the query component should be in
decoded form.private static void decodeQueryParam(MultivaluedMap<String,String> params, String param, boolean decodeNames, boolean decodeValues)
static List<UriComponent.PathSegment> decodePath(URI u, boolean decode)
u - the URI. If the path component is an absolute path component then the leading '/' is ignored and is not
considered a delimiator of a path segment.decode - true if the path segments of the path component should be in decoded form.static List<UriComponent.PathSegment> decodePath(String path, boolean decode)
Any '/' character in the path is considered to be a deliminator between two path segments. Thus if the path is '/' then the path segment list will contain two empty path segments. If the path is "//" then the path segment list will contain three empty path segments. If the path is "/a/" the path segment list will consist of the following path segments in order: "", "a" and "".
path - the path component in encoded form.decode - true if the path segments of the path component should be in decoded form.static void decodePathSegment(List<UriComponent.PathSegment> segments, String segment, boolean decode)
segments - mutable list of path segments.segment - path segment to be decoded.decode - true if the path segment should be in a decoded form.static MultivaluedMap<String,String> decodeMatrix(String pathSegment, boolean decode)
pathSegment - the path segment component in encoded form.decode - true if the matrix parameters of the path segment component should be in decoded form.private static void decodeMatrixParam(MultivaluedMap<String,String> params, String param, boolean decode)
private static ByteBuffer decodePercentEncodedOctets(String s, int i, ByteBuffer bb)
Assumes the index, i, starts that the first hex digit of the first percent-encoded octet.
s - TODOi - TODObb - TODOprivate static int decodeOctets(int i,
ByteBuffer bb,
StringBuilder sb)
i - TODObb - TODOsb - TODOprivate static int decodeHex(String s, int i)
private static int[] initHexTable()
private static int decodeHex(char c)
static boolean isHexCharacter(char c)
c is hexadecimal character.c - Any characterc is a hexadecimal character (e.g. 0, 5, a, A, f, ...)Copyright © 2014 Sven Strittmatter. All Rights Reserved.