|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.excalibur.source.SourceUtil
Utility class for source resolving.
Field Summary | |
static int |
AUTHORITY
|
static int |
FRAGMENT
|
static int |
PATH
|
static int |
QUERY
|
static int |
SCHEME
|
Constructor Summary | |
SourceUtil()
|
Method Summary | |
static java.lang.String |
absolutize(java.lang.String url1,
java.lang.String url2)
Calls absolutize(url1, url2, false). |
static java.lang.String |
absolutize(java.lang.String url1,
java.lang.String url2,
boolean treatAuthorityAsBelongingToPath)
Calls absolutize(url1, url2, false, true). |
static java.lang.String |
absolutize(java.lang.String url1,
java.lang.String url2,
boolean treatAuthorityAsBelongingToPath,
boolean normalizePath)
Applies a location to a baseURI. |
static java.lang.String |
appendParameters(java.lang.String uri,
Parameters parameters)
Append parameters to the uri. |
static java.lang.String |
appendParameters(java.lang.String uri,
SourceParameters parameters)
Append parameters to the uri Each parameter is appended to the uri with "parameter=value", the parameters are separated by "&". |
static void |
copy(java.io.InputStream in,
java.io.OutputStream out)
Copy the contents of an InputStream to an OutputStream . |
static void |
copy(Source source,
Source destination)
Copy the source to a specified destination. |
static java.lang.String |
decodePath(java.lang.String path)
Decode a path. |
static java.lang.String |
encode(java.lang.String s)
Translates a string into x-www-form-urlencoded format. |
static java.lang.String |
encode(java.lang.String s,
java.lang.String enc)
Translates a string into x-www-form-urlencoded format
with specified encoding |
static java.lang.String |
encodeBASE64(byte[] octetString)
BASE 64 encoding. |
static java.lang.String |
encodeBASE64(java.lang.String s)
BASE 64 encoding. |
static java.io.File |
getFile(Source source)
Return a File object associated with the Source object. |
static java.lang.String |
getScheme(java.lang.String uri)
Get the scheme of an absolute URI. |
static java.lang.String |
getSpecificPart(java.lang.String uri)
Get the scheme-specific part of an absolute URI. |
static int |
indexOfSchemeColon(java.lang.String uri)
Get the position of the scheme-delimiting colon in an absolute URI, as specified by RFC 2396, appendix A. |
static void |
move(Source source,
Source destination)
Move the source to a specified destination. |
static java.lang.String[] |
parseUrl(java.lang.String url)
Parses an URL into the following parts: scheme, authority, path, query and fragment identifier. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int SCHEME
public static final int AUTHORITY
public static final int PATH
public static final int QUERY
public static final int FRAGMENT
Constructor Detail |
public SourceUtil()
Method Detail |
public static java.lang.String appendParameters(java.lang.String uri, Parameters parameters)
public static java.lang.String appendParameters(java.lang.String uri, SourceParameters parameters)
public static java.lang.String encodeBASE64(java.lang.String s)
public static java.lang.String encodeBASE64(byte[] octetString)
public static java.lang.String encode(java.lang.String s)
x-www-form-urlencoded
format.
s
- String
to be translated.
String
.public static java.lang.String encode(java.lang.String s, java.lang.String enc) throws java.io.UnsupportedEncodingException
x-www-form-urlencoded
format
with specified encoding
s
- String
to be translated.enc
- The name of a supported charset
String
.
java.io.UnsupportedEncodingException
public static java.io.File getFile(Source source)
File
object associated with the Source
object.
File
object or null if the
Source
object does not point to a file URI.public static void move(Source source, Source destination) throws SourceException
source
- Source of the source.destination
- Destination of the source.
SourceException
- If an exception occurs during
the move.public static int indexOfSchemeColon(java.lang.String uri)
Source
implementors that want to separate
the scheme part from the specific part of an URI.
Use this method when you need both the scheme and the scheme-specific part of an URI,
as calling successively getScheme(String)
and getSpecificPart(String)
will call this method twice, and as such won't be efficient.
uri
- the URI
-1
if not found.public static java.lang.String getScheme(java.lang.String uri)
uri
- the absolute URI
public static java.lang.String getSpecificPart(java.lang.String uri)
uri
- the absolute URI
public static void copy(Source source, Source destination) throws SourceException
source
- Source of the source.destination
- Destination of the source.
SourceException
- If an exception occurs during
the copy.public static void copy(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
InputStream
to an OutputStream
.
in
- out
-
java.io.IOException
public static java.lang.String absolutize(java.lang.String url1, java.lang.String url2)
public static java.lang.String absolutize(java.lang.String url1, java.lang.String url2, boolean treatAuthorityAsBelongingToPath)
public static java.lang.String absolutize(java.lang.String url1, java.lang.String url2, boolean treatAuthorityAsBelongingToPath, boolean normalizePath)
url1
- the baseURIurl2
- the locationtreatAuthorityAsBelongingToPath
- considers the authority to belong to the path. These
special kind of URIs are used in the Apache Cocoon project.normalizePath
- should the path be normalized, i.e. remove ../ and /./ etc.public static java.lang.String[] parseUrl(java.lang.String url)
The parsing is designed to be robust in the sense that it will never fail, even when an invalid URL is given. The parser will simply look for the most important delimiter characters. Basically it does the same as what would be achieved using the following regular expression (from RFC 2396):
^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))? 12 3 4 5 6 7 8 9but without actually using the regular expression.
The result is returned as a string array, use the constants SCHEME, AUTHORITY, PATH, QUERY and FRAGMENT_IDENTIFIER to access the different parts.
If a part is missing, its corresponding entry in the array will be null, except for the path, which will never be null.
public static java.lang.String decodePath(java.lang.String path)
Interprets %XX (where XX is hexadecimal number) as UTF-8 encoded bytes.
The validity of the input path is not checked (i.e. characters that were not encoded will not be reported as errors).
This method differs from URLDecoder.decode in that it always uses UTF-8 (while URLDecoder uses the platform default encoding, often ISO-8859-1), and doesn't translate + characters to spaces.
path
- the path to decode
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |