info.informatica.doc.dom4j
Class DOM4JUserAgent<C>

java.lang.Object
  extended by info.informatica.doc.dom4j.DOM4JUserAgent<C>
All Implemented Interfaces:
UserAgent<C>
Direct Known Subclasses:
Java2DUserAgent, PDFUserAgent

public abstract class DOM4JUserAgent<C>
extends Object
implements UserAgent<C>

User Agent based on DOM4J document trees.

Author:
Carlos Amengual (amengual at informatica.info)

Constructor Summary
protected DOM4JUserAgent()
           
 
Method Summary
 void addDownloadListener(URL url, DownloadListener<C> listener)
          Adds a download listener for asynchronous retrieval of resources (embedded images, etc.)
protected abstract  ResourceDownloader<C> createDownloader(URL url)
           
 ResourceDownloader<C> download(URL url)
          Registers an URL for downloading with this user agent.
 ElementReplacer<C> getElementReplacer(String namespaceUri)
          Gets the element replacer for the given namespace URI.
 ResourceDownloader<C> getResourceDownloader(URL url)
          Gets the resource downloader for the given URL, creating one if none exists.
abstract  StyleDatabase getStyleDatabase()
          Gets the style database used for the styles applied by this agent.
 XHTMLDocument readURL(URL url)
          Convenience method that reads and parses an XHTML document located in the given URL, with a default entity resolver.
 XHTMLDocument readURL(URL url, EntityResolver resolver)
          Reads and parses an XHTML document located in the given URL.
 void setElementReplacer(String namespaceUri, ElementReplacer<C> replacer)
          Sets the element replacer for the given namespace URI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DOM4JUserAgent

protected DOM4JUserAgent()
Method Detail

readURL

public XHTMLDocument readURL(URL url)
                      throws IOException,
                             org.dom4j.DocumentException
Convenience method that reads and parses an XHTML document located in the given URL, with a default entity resolver.

Parameters:
url - the URL that points to the document.
Returns:
the XHTMLDocument.
Throws:
IOException
org.dom4j.DocumentException

readURL

public XHTMLDocument readURL(URL url,
                             EntityResolver resolver)
                      throws IOException,
                             org.dom4j.DocumentException
Reads and parses an XHTML document located in the given URL.

Parameters:
url - the URL that points to the document.
resolver - the entity resolver.
Returns:
the XHTMLDocument.
Throws:
IOException
org.dom4j.DocumentException

download

public ResourceDownloader<C> download(URL url)
Description copied from interface: UserAgent
Registers an URL for downloading with this user agent.

Specified by:
download in interface UserAgent<C>
Parameters:
url - the URL to be downloaded.
Returns:
the downloader for the URL.

addDownloadListener

public void addDownloadListener(URL url,
                                DownloadListener<C> listener)
Description copied from interface: UserAgent
Adds a download listener for asynchronous retrieval of resources (embedded images, etc.)

In the process, it creates a resource downloader object.

Specified by:
addDownloadListener in interface UserAgent<C>
Parameters:
url - the URL for the resource to be downloaded.
listener - the download listener.

getResourceDownloader

public ResourceDownloader<C> getResourceDownloader(URL url)
Description copied from interface: UserAgent
Gets the resource downloader for the given URL, creating one if none exists.

Specified by:
getResourceDownloader in interface UserAgent<C>
Parameters:
url - the URL.
Returns:
the resource downloader.

getElementReplacer

public ElementReplacer<C> getElementReplacer(String namespaceUri)
Description copied from interface: UserAgent
Gets the element replacer for the given namespace URI.

Specified by:
getElementReplacer in interface UserAgent<C>
Parameters:
namespaceUri - the namespace URI of the requested replacer. If passed an empty string, will return the replacer for the namespace of XHTML.
Returns:
the element replacer, or null if the namespace is not known to this user agent.

setElementReplacer

public void setElementReplacer(String namespaceUri,
                               ElementReplacer<C> replacer)
Description copied from interface: UserAgent
Sets the element replacer for the given namespace URI.

Specified by:
setElementReplacer in interface UserAgent<C>
Parameters:
namespaceUri - the namespace URI of the supplied replacer.
replacer - the element replacer.

getStyleDatabase

public abstract StyleDatabase getStyleDatabase()
Description copied from interface: UserAgent
Gets the style database used for the styles applied by this agent.

Specified by:
getStyleDatabase in interface UserAgent<C>
Returns:
the style database.

createDownloader

protected abstract ResourceDownloader<C> createDownloader(URL url)


Copyright © 2011 informatica.info. All Rights Reserved.