org.apache.cocoon.components.source.util
Class SourceUtil

java.lang.Object
  extended byorg.apache.cocoon.components.source.util.SourceUtil

public abstract class SourceUtil
extends Object

This class contains some utility methods for the source resolving.

Version:
$Id: SourceUtil.html 1304280 2012-03-23 11:18:01Z ilgrosso $

Field Summary
protected static REProgram uripattern
           
 
Constructor Summary
SourceUtil()
           
 
Method Summary
static String getAuthority(String uri)
          Return the authority of a URI.
static String getFragment(String uri)
          Return the fragment of a URI.
static InputSource getInputSource(Source source)
          Get an InputSource object
static String getPath(String uri)
          Return the path of a URI.
static String getPathWithoutAuthority(String uri)
          Return the path of a URI, if the URI can't contains a authority.
static String getQuery(String uri)
          Return the query of a URI.
static String getScheme(String uri)
          Return the scheme of a URI.
static Source getSource(String uri, Parameters typeParameters, SourceParameters resourceParameters, SourceResolver resolver)
          Get a Source object
static org.apache.cocoon.ProcessingException handle(SourceException se)
          Make a ProcessingException from a SourceException.
static org.apache.cocoon.ProcessingException handle(String message, SourceException se)
          Make a ProcessingException from a SourceException.
static void handleSAXException(String source, SAXException e)
          Handle SAXException catched in Generator's generate method.
static void parse(org.apache.cocoon.core.xml.SAXParser parser, Source source, ContentHandler handler)
          Generates SAX events from the given source by parsing it.
static void parse(ServiceManager manager, Source source, ContentHandler handler)
          Deprecated. use parse(SAXParser, Source, ContentHandler) instead
static void toCharacters(Source source, String encoding, ContentHandler handler)
          Generates character SAX events from the given source.
static Document toDOM(ServiceManager manager, Source source)
          Generates a DOM from the given source
static Document toDOM(ServiceManager manager, String mimeTypeHint, Source source)
          Generates a DOM from the given source
static void toSAX(ServiceManager manager, Source source, ContentHandler handler)
          Generates SAX events from the given source.
static void toSAX(ServiceManager manager, Source source, ContentHandler handler, Parameters typeParameters, boolean filterDocumentEvent)
          Generates SAX events from the given source with possible URL rewriting.
static void toSAX(ServiceManager manager, Source source, String mimeTypeHint, ContentHandler handler)
          Generates SAX events from the given source by using XMLizer.
static void toSAX(XMLizable source, ContentHandler handler)
          Generates SAX events from the XMLizable and handle SAXException.
static void toSAX(XMLizer xmlizer, Source source, String mimeTypeHint, ContentHandler handler)
          Generates SAX events from the given source by using XMLizer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

uripattern

protected static REProgram uripattern
Constructor Detail

SourceUtil

public SourceUtil()
Method Detail

toSAX

public static void toSAX(ServiceManager manager,
                         Source source,
                         ContentHandler handler,
                         Parameters typeParameters,
                         boolean filterDocumentEvent)
                  throws SAXException,
                         IOException,
                         org.apache.cocoon.ProcessingException
Generates SAX events from the given source with possible URL rewriting.

NOTE: If the implementation can produce lexical events, care should be taken that handler can actually directly implement the LexicalHandler interface!

Parameters:
source - the data
Throws:
org.apache.cocoon.ProcessingException - if no suitable converter is found
SAXException
IOException

toSAX

public static void toSAX(XMLizable source,
                         ContentHandler handler)
                  throws SAXException,
                         IOException,
                         org.apache.cocoon.ProcessingException
Generates SAX events from the XMLizable and handle SAXException.

Parameters:
source - the data
Throws:
SAXException
IOException
org.apache.cocoon.ProcessingException

toSAX

public static void toSAX(ServiceManager manager,
                         Source source,
                         ContentHandler handler)
                  throws SAXException,
                         IOException,
                         org.apache.cocoon.ProcessingException
Generates SAX events from the given source.

NOTE: If the implementation can produce lexical events, care should be taken that handler can actually directly implement the LexicalHandler interface!

Parameters:
source - the data
Throws:
org.apache.cocoon.ProcessingException - if no suitable converter is found
SAXException
IOException

toSAX

public static void toSAX(ServiceManager manager,
                         Source source,
                         String mimeTypeHint,
                         ContentHandler handler)
                  throws SAXException,
                         IOException,
                         org.apache.cocoon.ProcessingException
Generates SAX events from the given source by using XMLizer.

NOTE: If the implementation can produce lexical events, care should be taken that handler can actually directly implement the LexicalHandler interface!

Parameters:
source - the data
Throws:
org.apache.cocoon.ProcessingException - if no suitable converter is found
SAXException
IOException

toSAX

public static void toSAX(XMLizer xmlizer,
                         Source source,
                         String mimeTypeHint,
                         ContentHandler handler)
                  throws SAXException,
                         IOException,
                         org.apache.cocoon.ProcessingException
Generates SAX events from the given source by using XMLizer.

NOTE: If the implementation can produce lexical events, care should be taken that handler can actually directly implement the LexicalHandler interface!

Parameters:
source - the data
Throws:
org.apache.cocoon.ProcessingException - if no suitable converter is found
SAXException
IOException

toCharacters

public static void toCharacters(Source source,
                                String encoding,
                                ContentHandler handler)
                         throws SAXException,
                                IOException,
                                org.apache.cocoon.ProcessingException
Generates character SAX events from the given source.

Parameters:
source - The data
encoding - The character encoding of the data
Throws:
SAXException
IOException
org.apache.cocoon.ProcessingException

parse

public static void parse(ServiceManager manager,
                         Source source,
                         ContentHandler handler)
                  throws SAXException,
                         IOException,
                         org.apache.cocoon.ProcessingException
Deprecated. use parse(SAXParser, Source, ContentHandler) instead

Generates SAX events from the given source by parsing it.

NOTE: If the implementation can produce lexical events, care should be taken that handler can actually directly implement the LexicalHandler interface!

Parameters:
source - the data
Throws:
org.apache.cocoon.ProcessingException - if no suitable converter is found
SAXException
IOException

parse

public static void parse(org.apache.cocoon.core.xml.SAXParser parser,
                         Source source,
                         ContentHandler handler)
                  throws SAXException,
                         IOException,
                         org.apache.cocoon.ProcessingException
Generates SAX events from the given source by parsing it.

NOTE: If the implementation can produce lexical events, care should be taken that handler can actually directly implement the LexicalHandler interface!

Parameters:
source - the data
Throws:
org.apache.cocoon.ProcessingException - if error during processing source data occurs
SAXException
IOException

toDOM

public static Document toDOM(ServiceManager manager,
                             Source source)
                      throws SAXException,
                             IOException,
                             org.apache.cocoon.ProcessingException
Generates a DOM from the given source

Parameters:
source - The data
Returns:
Created DOM document.
Throws:
IOException - If a io exception occurs.
org.apache.cocoon.ProcessingException - if no suitable converter is found
SAXException - If a SAX exception occurs.

toDOM

public static Document toDOM(ServiceManager manager,
                             String mimeTypeHint,
                             Source source)
                      throws SAXException,
                             IOException,
                             org.apache.cocoon.ProcessingException
Generates a DOM from the given source

Parameters:
source - The data
Returns:
Created DOM document.
Throws:
IOException - If a io exception occurs.
org.apache.cocoon.ProcessingException - if no suitable converter is found
SAXException - If a SAX exception occurs.

handle

public static org.apache.cocoon.ProcessingException handle(SourceException se)
Make a ProcessingException from a SourceException. If the exception is a SourceNotFoundException then a ResourceNotFoundException is thrown.

Parameters:
se - Source exception
Returns:
Created processing exception.

handle

public static org.apache.cocoon.ProcessingException handle(String message,
                                                           SourceException se)
Make a ProcessingException from a SourceException. If the exception is a SourceNotFoundException then a ResourceNotFoundException is thrown.

Parameters:
message - Additional exception message.
se - Source exception.
Returns:
Created processing exception.

handleSAXException

public static void handleSAXException(String source,
                                      SAXException e)
                               throws org.apache.cocoon.ProcessingException,
                                      IOException,
                                      SAXException
Handle SAXException catched in Generator's generate method.

Parameters:
source - Generator's source
e - SAXException happened in the generator's generate method.
Throws:
org.apache.cocoon.ProcessingException
IOException
SAXException

getInputSource

public static InputSource getInputSource(Source source)
                                  throws IOException,
                                         org.apache.cocoon.ProcessingException
Get an InputSource object

Parameters:
source - Source.
Returns:
Input stream of the source.
Throws:
IOException - If a io exception occurs.
org.apache.cocoon.ProcessingException - If an exception occurs during processing.

getSource

public static Source getSource(String uri,
                               Parameters typeParameters,
                               SourceParameters resourceParameters,
                               SourceResolver resolver)
                        throws IOException,
                               SAXException,
                               SourceException
Get a Source object

Parameters:
uri - URI of the source.
typeParameters - Type of Source query. Currently, only method parameter (value typically GET or POST) is recognized. May be null.
resourceParameters - Parameters of the source. May be null
resolver - Resolver for the source.
Returns:
The resolved source.
Throws:
IOException - If a io exception occurs.
SAXException - If a SAX exception occurs.
SourceException - If the source an exception throws.

getScheme

public static String getScheme(String uri)
Return the scheme of a URI. Just as there are many different methods of access to resources, there are a variety of schemes for identifying such resources. (see RFC 2396).

Parameters:
uri - Uniform resource identifier.
Returns:
Scheme of the URI.

getAuthority

public static String getAuthority(String uri)
Return the authority of a URI. This authority is typically defined by an Internet-based server or a scheme-specific registry of naming authorities (see RFC 2396).

Parameters:
uri - Uniform resource identifier.
Returns:
Scheme of the URI.

getPath

public static String getPath(String uri)
Return the path of a URI. The path contains data, specific to the authority (or the scheme if there is no authority component), identifying the resource within the scope of that scheme and authority (see RFC 2396).

Parameters:
uri - Uniform resource identifier.
Returns:
Path of the URI.

getPathWithoutAuthority

public static String getPathWithoutAuthority(String uri)
Return the path of a URI, if the URI can't contains a authority. This implementation differ to the RFC 2396.

Parameters:
uri - Uniform resource identifier.
Returns:
Path of the URI.

getQuery

public static String getQuery(String uri)
Return the query of a URI. The query is a string of information to be interpreted by the resource (see RFC 2396).

Parameters:
uri - Uniform resource identifier.
Returns:
Query of the URI.

getFragment

public static String getFragment(String uri)
Return the fragment of a URI. When a URI reference is used to perform a retrieval action on the identified resource, the optional fragment identifier, consists of additional reference information to be interpreted by the user agent after the retrieval action has been successfully completed (see RFC 2396).

Parameters:
uri - Uniform resource identifier.
Returns:
Fragment of the URI.


Copyright © 1999-2008 The Apache Software Foundation. All Rights Reserved.