Package org.apache.commons.vfs.provider
Class UriParser
- java.lang.Object
-
- org.apache.commons.vfs.provider.UriParser
-
public final class UriParser extends java.lang.Object
Utilities for dealing with URIs. See RFC 2396 for details.- Version:
- $Revision: 480428 $ $Date: 2005-10-13 21:11:33 +0200 (Do, 13 Okt 2005) $
- Author:
- Adam Murdoch
-
-
Field Summary
Fields Modifier and Type Field Description static char
TRANS_SEPARATOR
The set of valid separators.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
appendEncoded(java.lang.StringBuffer buffer, java.lang.String unencodedValue, char[] reserved)
Encodes and appends a string to a StringBuffer.static void
canonicalizePath(java.lang.StringBuffer buffer, int offset, int length, FileNameParser fileNameParser)
static void
checkUriEncoding(java.lang.String uri)
static java.lang.String
decode(java.lang.String encodedStr)
Removes %nn encodings from a string.static void
decode(java.lang.StringBuffer 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)
static void
encode(java.lang.StringBuffer buffer, int offset, int length, char[] reserved)
Encodes a set of reserved characters in a StringBuffer, using the URI %nn encoding.static java.lang.String
encode(java.lang.String decodedStr, char[] reserved)
static java.lang.String
extractFirstElement(java.lang.StringBuffer name)
Extracts the first element of a path.static java.lang.String
extractQueryString(java.lang.StringBuffer name)
static java.lang.String
extractScheme(java.lang.String uri)
Extracts the scheme from a URI.static java.lang.String
extractScheme(java.lang.String uri, java.lang.StringBuffer buffer)
Extracts the scheme from a URI.static boolean
fixSeparators(java.lang.StringBuffer name)
Normalises the separators in a name.static FileType
normalisePath(java.lang.StringBuffer path)
Normalises a path.
-
-
-
Field Detail
-
TRANS_SEPARATOR
public static final char TRANS_SEPARATOR
The set of valid separators. These are all converted to the normalised one. Does not contain the normalised separator- See Also:
- Constant Field Values
-
-
Method Detail
-
extractFirstElement
public static java.lang.String extractFirstElement(java.lang.StringBuffer name)
Extracts the first element of a path.
-
normalisePath
public static FileType normalisePath(java.lang.StringBuffer path) throws FileSystemException
Normalises a path. Does the following:- Removes empty path elements.
- Handles '.' and '..' elements.
- Removes trailing separator.
- Throws:
FileSystemException
- See Also:
fixSeparators(java.lang.StringBuffer)
-
fixSeparators
public static boolean fixSeparators(java.lang.StringBuffer name)
Normalises the separators in a name.
-
extractScheme
public static java.lang.String extractScheme(java.lang.String uri)
Extracts the scheme from a URI.- Parameters:
uri
- The URI.- Returns:
- The scheme name. Returns null if there is no scheme.
-
extractScheme
public static java.lang.String extractScheme(java.lang.String uri, java.lang.StringBuffer buffer)
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
public static java.lang.String decode(java.lang.String encodedStr) throws FileSystemException
Removes %nn encodings from a string.- Throws:
FileSystemException
-
decode
public static void decode(java.lang.StringBuffer buffer, int offset, int length) throws FileSystemException
Removes %nn encodings from a string.- Throws:
FileSystemException
-
appendEncoded
public static void appendEncoded(java.lang.StringBuffer buffer, java.lang.String unencodedValue, char[] reserved)
Encodes and appends a string to a StringBuffer.
-
encode
public static void encode(java.lang.StringBuffer buffer, int offset, int length, char[] reserved)
Encodes a set of reserved characters in a StringBuffer, using the URI %nn encoding. Always encodes % characters.
-
encode
public static java.lang.String encode(java.lang.String decodedStr)
Removes %nn encodings from a string.
-
encode
public static java.lang.String encode(java.lang.String decodedStr, char[] reserved)
-
encode
public static java.lang.String[] encode(java.lang.String[] strings)
-
checkUriEncoding
public static void checkUriEncoding(java.lang.String uri) throws FileSystemException
- Throws:
FileSystemException
-
canonicalizePath
public static void canonicalizePath(java.lang.StringBuffer buffer, int offset, int length, FileNameParser fileNameParser) throws FileSystemException
- Throws:
FileSystemException
-
extractQueryString
public static java.lang.String extractQueryString(java.lang.StringBuffer name)
-
-