Package org.apache.commons.vfs2.provider
Class UriParser
java.lang.Object
org.apache.commons.vfs2.provider.UriParser
Utilities for dealing with URIs. See RFC 2396 for details.
2005) $
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic void
appendEncoded
(StringBuilder buffer, String unencodedValue, char[] reserved) Encodes and appends a string to a StringBuilder.static void
canonicalizePath
(StringBuilder buffer, int offset, int length, FileNameParser fileNameParser) static void
checkUriEncoding
(String uri) Decodes the String.static String
Removes %nn encodings from a string.static void
decode
(StringBuilder buffer, int offset, int length) Removes %nn encodings from a string.static String
Removes %nn encodings from a string.static String[]
Encode an array of Strings.static void
encode
(StringBuilder buffer, int offset, int length, char[] reserved) Encodes a set of reserved characters in a StringBuilder, using the URI %nn encoding.static String
Converts "special" characters to their %nn value.static String
Extracts the first element of a path.static String
Extract the query String from the URI.static String
extractScheme
(String uri) Extracts the scheme from a URI.static String
extractScheme
(String uri, StringBuilder buffer) Extracts the scheme from a URI.static boolean
fixSeparators
(StringBuilder name) Normalises the separators in a name.static FileType
normalisePath
(StringBuilder path) Normalises a path.
-
Field Details
-
TRANS_SEPARATOR
The set of valid separators. These are all converted to the normalized one. Does not contain the normalized separator- See Also:
-
-
Method Details
-
extractFirstElement
Extracts the first element of a path.- Parameters:
name
- StringBuilder containing the path.- Returns:
- The first element of the path.
-
normalisePath
Normalises a path. Does the following:- Removes empty path elements.
- Handles '.' and '..' elements.
- Removes trailing separator.
- Parameters:
path
- The path to normalize.- Returns:
- The FileType.
- Throws:
FileSystemException
- if an error occurs.- See Also:
-
fixSeparators
Normalises the separators in a name.- Parameters:
name
- The StringBuilder containing the name- Returns:
- true if the StringBuilder was modified.
-
extractScheme
Extracts the scheme from a URI.- Parameters:
uri
- The URI.- Returns:
- The scheme name. Returns null if there is no scheme.
-
extractScheme
Extracts the scheme from a URI. Removes the scheme and ':' delimiter from the front of the URI.- Parameters:
uri
- The URI.buffer
- Returns the remainder of the URI.- Returns:
- The scheme name. Returns null if there is no scheme.
-
decode
Removes %nn encodings from a string.- Parameters:
encodedStr
- The encoded String.- Returns:
- The decoded String.
- Throws:
FileSystemException
- if an error occurs.
-
decode
Removes %nn encodings from a string.- Parameters:
buffer
- StringBuilder containing the string to decode.offset
- The position in the string to start decoding.length
- The number of characters to decode.- Throws:
FileSystemException
- if an error occurs.
-
appendEncoded
Encodes and appends a string to a StringBuilder.- Parameters:
buffer
- The StringBuilder to append to.unencodedValue
- The String to encode and append.reserved
- characters to encode.
-
encode
Encodes a set of reserved characters in a StringBuilder, using the URI %nn encoding. Always encodes % characters.- Parameters:
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.
-
encode
Removes %nn encodings from a string.- Parameters:
decodedStr
- The decoded String.- Returns:
- The encoded String.
-
encode
Converts "special" characters to their %nn value.- Parameters:
decodedStr
- The decoded String.reserved
- Characters to encode.- Returns:
- The encoded String
-
encode
Encode an array of Strings.- Parameters:
strings
- The array of Strings to encode.- Returns:
- An array of encoded Strings.
-
checkUriEncoding
Decodes the String.- Parameters:
uri
- The String to decode.- Throws:
FileSystemException
- if an error occurs.
-
canonicalizePath
public static void canonicalizePath(StringBuilder buffer, int offset, int length, FileNameParser fileNameParser) throws FileSystemException - Throws:
FileSystemException
-
extractQueryString
Extract the query String from the URI.- Parameters:
name
- StringBuilder containing the URI.- Returns:
- The query string, if any. null otherwise.
-