public final class UriParser
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static int |
BITS_IN_HALF_BYTE |
private static int |
HEX_BASE |
private static char |
LOW_MASK |
private static char |
SEPARATOR_CHAR
The normalised separator to use.
|
static char |
TRANS_SEPARATOR
The set of valid separators.
|
Modifier | Constructor and Description |
---|---|
private |
UriParser() |
Modifier and Type | Method and Description |
---|---|
static void |
appendEncoded(java.lang.StringBuilder buffer,
java.lang.String unencodedValue,
char[] reserved)
Encodes and appends a string to a StringBuilder.
|
static void |
canonicalizePath(java.lang.StringBuilder buffer,
int offset,
int length,
FileNameParser fileNameParser) |
static void |
checkUriEncoding(java.lang.String uri)
Decodes the String.
|
static java.lang.String |
decode(java.lang.String encodedStr)
Removes %nn encodings from a string.
|
static void |
decode(java.lang.StringBuilder buffer,
int offset,
int length)
Removes %nn encodings from a string.
|
static java.lang.String |
encode(java.lang.String decodedStr)
Removes %nn encodings from a string.
|
static java.lang.String[] |
encode(java.lang.String[] strings)
Encode an array of Strings.
|
static void |
encode(java.lang.StringBuilder buffer,
int offset,
int length,
char[] reserved)
Encodes a set of reserved characters in a StringBuilder, using the URI %nn encoding.
|
static java.lang.String |
encode(java.lang.String decodedStr,
char[] reserved)
Converts "special" characters to their %nn value.
|
static java.lang.String |
extractFirstElement(java.lang.StringBuilder name)
Extracts the first element of a path.
|
static java.lang.String |
extractQueryString(java.lang.StringBuilder name)
Extract the query String from the URI.
|
static java.lang.String |
extractScheme(java.lang.String uri)
Deprecated.
Use instead
extractScheme(java.lang.String[], java.lang.String) . Will be removed in 3.0. |
static java.lang.String |
extractScheme(java.lang.String[] schemes,
java.lang.String uri)
Extracts the scheme from a URI.
|
static java.lang.String |
extractScheme(java.lang.String[] schemes,
java.lang.String uri,
java.lang.StringBuilder buffer)
Extracts the scheme from a URI.
|
static java.lang.String |
extractScheme(java.lang.String uri,
java.lang.StringBuilder buffer)
Deprecated.
Use instead
extractScheme(java.lang.String[], java.lang.String) . Will be removed in 3.0. |
static boolean |
fixSeparators(java.lang.StringBuilder name)
Normalises the separators in a name.
|
static FileType |
normalisePath(java.lang.StringBuilder path)
Normalises a path.
|
public static final char TRANS_SEPARATOR
private static final char SEPARATOR_CHAR
private static final int HEX_BASE
private static final int BITS_IN_HALF_BYTE
private static final char LOW_MASK
public static void appendEncoded(java.lang.StringBuilder buffer, java.lang.String unencodedValue, char[] reserved)
buffer
- The StringBuilder to append to.unencodedValue
- The String to encode and append.reserved
- characters to encode.public static void canonicalizePath(java.lang.StringBuilder buffer, int offset, int length, FileNameParser fileNameParser) throws FileSystemException
FileSystemException
public static void checkUriEncoding(java.lang.String uri) throws FileSystemException
uri
- The String to decode.FileSystemException
- if an error occurs.public static java.lang.String decode(java.lang.String encodedStr) throws FileSystemException
encodedStr
- The encoded String.FileSystemException
- if an error occurs.public static void decode(java.lang.StringBuilder buffer, int offset, int length) throws FileSystemException
buffer
- StringBuilder containing the string to decode.offset
- The position in the string to start decoding.length
- The number of characters to decode.FileSystemException
- if an error occurs.public static java.lang.String encode(java.lang.String decodedStr)
decodedStr
- The decoded String.public static java.lang.String encode(java.lang.String decodedStr, char[] reserved)
decodedStr
- The decoded String.reserved
- Characters to encode.public static java.lang.String[] encode(java.lang.String[] strings)
strings
- The array of Strings to encode.public static void encode(java.lang.StringBuilder buffer, int offset, int length, char[] reserved)
buffer
- The StringBuilder to append to.offset
- The position in the buffer to start encoding at.length
- The number of characters to encode.reserved
- characters to encode.public static java.lang.String extractFirstElement(java.lang.StringBuilder name)
name
- StringBuilder containing the path.public static java.lang.String extractQueryString(java.lang.StringBuilder name)
name
- StringBuilder containing the URI.public static java.lang.String extractScheme(java.lang.String[] schemes, java.lang.String uri)
The scheme is extracted based on the currently supported schemes in the system. That is to say the schemes supported by the registered providers.
This allows us to handle varying scheme's without making assumptions based on the ':' character. Specifically handle scheme extraction calls for URI parameters that are not actually uri's, but may be names with ':' in them.
schemes
- The schemes to check.uri
- The potential URI. May also be a name.public static java.lang.String extractScheme(java.lang.String[] schemes, java.lang.String uri, java.lang.StringBuilder buffer)
The scheme is extracted based on the given set of schemes. Normally, that is to say the schemes supported by the registered providers.
This allows us to handle varying scheme's without making assumptions based on the ':' character. Specifically handle scheme extraction calls for URI parameters that are not actually uri's, but may be names with ':' in them.
schemes
- The schemes to check.uri
- The potential URI. May also just be a name.buffer
- Returns the remainder of the URI.@Deprecated public static java.lang.String extractScheme(java.lang.String uri)
extractScheme(java.lang.String[], java.lang.String)
. Will be removed in 3.0.uri
- The URI.@Deprecated public static java.lang.String extractScheme(java.lang.String uri, java.lang.StringBuilder buffer)
extractScheme(java.lang.String[], java.lang.String)
. Will be removed in 3.0.uri
- The URI.buffer
- Returns the remainder of the URI.public static boolean fixSeparators(java.lang.StringBuilder name)
name
- The StringBuilder containing the namepublic static FileType normalisePath(java.lang.StringBuilder path) throws FileSystemException
path
- The path to normalize.FileSystemException
- if an error occurs.fixSeparators(java.lang.StringBuilder)