org.apache.fop.apps

Class FOURIResolver

Implemented Interfaces:
javax.xml.transform.URIResolver

public class FOURIResolver
extends java.lang.Object
implements javax.xml.transform.URIResolver

Provides FOP specific URI resolution. This is the default URIResolver FOUserAgent will use unless overidden.
See Also:
javax.xml.transform.URIResolver

Constructor Summary

FOURIResolver()
Default constructor
FOURIResolver(boolean throwExceptions)
Additional constructor

Method Summary

protected void
applyHttpBasicAuthentication(URLConnection connection, String username, String password)
This is a convenience method for users who want to override updateURLConnection for HTTP basic authentication.
URIResolver
getCustomURIResolver()
Returns the custom URI Resolver.
Source
resolve(String href, String base)
Called by the processor through FOUserAgent when it encounters an uri in an external-graphic element.
void
setCustomURIResolver(URIResolver resolver)
Sets the custom URI Resolver.
void
setThrowExceptions(boolean throwExceptions)
protected void
updateURLConnection(URLConnection connection, String href)
This method allows you to set special values on a URLConnection just before the connect() method is called.

Constructor Details

FOURIResolver

public FOURIResolver()
Default constructor

FOURIResolver

public FOURIResolver(boolean throwExceptions)
Additional constructor
Parameters:
throwExceptions - true if exceptions are to be thrown if the URIs cannot be resolved.

Method Details

applyHttpBasicAuthentication

protected void applyHttpBasicAuthentication(URLConnection connection,
                                            String username,
                                            String password)
This is a convenience method for users who want to override updateURLConnection for HTTP basic authentication. Simply call it using the right username and password.
Parameters:
connection - the URLConnection to set up for HTTP basic authentication
username - the username
password - the password

getCustomURIResolver

public URIResolver getCustomURIResolver()
Returns the custom URI Resolver.
Returns:
the URI Resolver or null, if none is set

resolve

public Source resolve(String href,
                      String base)
            throws TransformerException
Called by the processor through FOUserAgent when it encounters an uri in an external-graphic element. (see also javax.xml.transform.URIResolver.resolve(String, String) This resolver will allow URLs without a scheme, i.e. it assumes 'file:' as the default scheme. It also allows relative URLs with scheme, e.g. file:../../abc.jpg which is not strictly RFC compliant as long as the scheme is the same as the scheme of the base URL. If the base URL is null a 'file:' URL referencing the current directory is used as the base URL. If the method is successful it will return a Source of type javax.xml.transform.stream.StreamSource with its SystemID set to the resolved URL used to open the underlying InputStream.
Parameters:
href - An href attribute, which may be relative or absolute.
base - The base URI against which the first argument will be made absolute if the absolute URI is required.
Returns:
A javax.xml.transform.Source object, or null if the href cannot be resolved.
See Also:
javax.xml.transform.URIResolver.resolve(String, String)

setCustomURIResolver

public void setCustomURIResolver(URIResolver resolver)
Sets the custom URI Resolver. It is used for resolving factory-level URIs like hyphenation patterns and as backup for URI resolution performed during a rendering run.
Parameters:
resolver - the new URI resolver

setThrowExceptions

public void setThrowExceptions(boolean throwExceptions)
Parameters:
throwExceptions - Whether or not to throw exceptions on resolution error

updateURLConnection

protected void updateURLConnection(URLConnection connection,
                                   String href)
This method allows you to set special values on a URLConnection just before the connect() method is called. Subclass FOURIResolver and override this method to do things like adding the user name and password for HTTP basic authentication.
Parameters:
connection - the URLConnection instance
href - the original URI

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