org.apache.excalibur.source
Class SourceUtil

java.lang.Object
  |
  +--org.apache.excalibur.source.SourceUtil

public final class SourceUtil
extends Object

Utility class for source resolving.

Version:
CVS $Revision: 1.7 $ $Date: 2003/05/20 20:56:43 $
Author:
Carsten Ziegeler, Stephan Michels

Constructor Summary
SourceUtil()
           
 
Method Summary
static String appendParameters(String uri, Parameters parameters)
          Append parameters to the uri.
static String appendParameters(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(InputStream in, 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 String encode(String s)
          Translates a string into x-www-form-urlencoded format.
static String encodeBASE64(byte[] octetString)
          BASE 64 encoding.
static String encodeBASE64(String s)
          BASE 64 encoding.
static File getFile(Source source)
          Return a File object associated with the Source object.
static String getScheme(String uri)
          Get the scheme of an absolute URI.
static String getSpecificPart(String uri)
          Get the scheme-specific part of an absolute URI.
static int indexOfSchemeColon(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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SourceUtil

public SourceUtil()
Method Detail

appendParameters

public static String appendParameters(String uri,
                                      Parameters parameters)
Append parameters to the uri. Each parameter is appended to the uri with "parameter=value", the parameters are separated by "&".


appendParameters

public static String appendParameters(String uri,
                                      SourceParameters parameters)
Append parameters to the uri Each parameter is appended to the uri with "parameter=value", the parameters are separated by "&".


encodeBASE64

public static String encodeBASE64(String s)
BASE 64 encoding. See also RFC 1421


encodeBASE64

public static String encodeBASE64(byte[] octetString)
BASE 64 encoding. See also RFC 1421


encode

public static String encode(String s)
Translates a string into x-www-form-urlencoded format.

Parameters:
s - String to be translated.
Returns:
the translated String.

getFile

public static File getFile(Source source)
Return a File object associated with the Source object.

Returns:
The corresponding File object or null if the Source object does not point to a file URI.

move

public static void move(Source source,
                        Source destination)
                 throws SourceException
Move the source to a specified destination.

Parameters:
source - Source of the source.
destination - Destination of the source.
Throws:
SourceException - If an exception occurs during the move.

indexOfSchemeColon

public static int indexOfSchemeColon(String uri)
Get the position of the scheme-delimiting colon in an absolute URI, as specified by RFC 2396, appendix A. This method is primarily useful for 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.

Parameters:
uri - the URI
Returns:
int the scheme-delimiting colon, or -1 if not found.

getScheme

public static String getScheme(String uri)
Get the scheme of an absolute URI.

Parameters:
uri - the absolute URI
Returns:
the URI scheme

getSpecificPart

public static String getSpecificPart(String uri)
Get the scheme-specific part of an absolute URI. Note that this includes everything after the separating colon, including the fragment, if any (RFC 2396 separates it from the scheme-specific part).

Parameters:
uri - the absolute URI
Returns:
the scheme-specific part of the URI

copy

public static void copy(Source source,
                        Source destination)
                 throws SourceException
Copy the source to a specified destination.

Parameters:
source - Source of the source.
destination - Destination of the source.
Throws:
SourceException - If an exception occurs during the copy.

copy

public static void copy(InputStream in,
                        OutputStream out)
                 throws IOException
Copy the contents of an InputStream to an OutputStream.

Parameters:
in -
out -
Throws:
IOException


Copyright © 2000-2003 Apache Avalon Project. All Rights Reserved.