org.apache.excalibur.source.impl
Class AbstractSourceResolver

java.lang.Object
  extended byorg.apache.excalibur.source.impl.AbstractSourceResolver
All Implemented Interfaces:
SourceResolver
Direct Known Subclasses:
DefaultSourceResolver, SourceResolverImpl

public abstract class AbstractSourceResolver
extends java.lang.Object
implements SourceResolver

This is an abstract implementation of a SourceResolver. The source resolving is done relative to a base directory/URI (if the given location is relative). The base directory/URI has to be set using setBaseURL(URL). A subclass should implement getSourceFactory(String) and releaseSourceFactory(SourceFactory) if required. To support various logging frameworks, the subclass should implement the isDebugEnabled() and the debug(String) method.

Version:
$Id: AbstractSourceResolver.java 522060 2007-03-24 17:27:56Z cziegeler $
Author:
Avalon Development Team
See Also:
SourceResolver

Field Summary
protected  java.net.URL m_baseURL
          The base URL
 
Fields inherited from interface org.apache.excalibur.source.SourceResolver
METHOD, ROLE, URI_ENCODING, URI_PARAMETERS
 
Constructor Summary
AbstractSourceResolver()
           
 
Method Summary
protected  void debug(java.lang.String text)
           
protected abstract  SourceFactory getSourceFactory(java.lang.String protocol)
           
protected  boolean isDebugEnabled()
           
 void release(Source source)
          Releases a resolved resource
protected  void releaseSourceFactory(SourceFactory factory)
           
 Source resolveURI(java.lang.String location)
          Get a Source object.
 Source resolveURI(java.lang.String location, java.lang.String baseURI, java.util.Map parameters)
          Get a Source object.
 void setBaseURL(java.net.URL baseurl)
          Set the base url.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_baseURL

protected java.net.URL m_baseURL
The base URL

Constructor Detail

AbstractSourceResolver

public AbstractSourceResolver()
Method Detail

setBaseURL

public void setBaseURL(java.net.URL baseurl)
Set the base url.


isDebugEnabled

protected boolean isDebugEnabled()

debug

protected void debug(java.lang.String text)

getSourceFactory

protected abstract SourceFactory getSourceFactory(java.lang.String protocol)

releaseSourceFactory

protected void releaseSourceFactory(SourceFactory factory)

resolveURI

public Source resolveURI(java.lang.String location)
                  throws java.net.MalformedURLException,
                         java.io.IOException,
                         SourceException
Get a Source object.

Specified by:
resolveURI in interface SourceResolver
Returns:
the resolved source object.
Throws:
SourceNotFoundException - if the source cannot be found
java.io.IOException - if the source couldn't be created for some other reason.
java.net.MalformedURLException - if location is malformed.
SourceException

resolveURI

public Source resolveURI(java.lang.String location,
                         java.lang.String baseURI,
                         java.util.Map parameters)
                  throws java.net.MalformedURLException,
                         java.io.IOException,
                         SourceException
Get a Source object.

Specified by:
resolveURI in interface SourceResolver
Parameters:
location - - the URI to resolve. If this is relative it is either resolved relative to the base parameter (if not null) or relative to a base setting of the source resolver itself.
baseURI - - a base URI for resolving relative locations. This is optional and can be null.
parameters - - Additional parameters for the URI. The parameters are specific to the used scheme.
Returns:
the resolved source object.
Throws:
SourceNotFoundException - if the source cannot be found
java.io.IOException - if the source couldn't be created for some other reason.
java.net.MalformedURLException - if location is malformed.
SourceException

release

public void release(Source source)
Releases a resolved resource

Specified by:
release in interface SourceResolver
Parameters:
source - the source to release


Copyright © 1997-2007 Apache Software Foundation. All Rights Reserved.