com.calitha.xml
Class XSLTemplatesCache

java.lang.Object
  extended by com.calitha.xml.XSLTemplatesCache

public class XSLTemplatesCache
extends Object

A XSLTemplatesCache object is used to cache the templates created from XSL files.

Templates can be used to create Transformer objects used to transform a Document.

Author:
Robert van Loenhout

Constructor Summary
XSLTemplatesCache()
          Creates a new cache.
 
Method Summary
 void add(File file)
          Adds an XSL file to the cache.
 void add(URL url)
          Adds an XSL file, indicated by an URI, to the cache.
 boolean contains(File file)
          Determines if this cache contains templates associated with this file.
 boolean contains(URL url)
          Determines if this cache contains templates associated with this URL.
 Templates getTemplates(File file)
          Gets templates for the XSL file object.
 Templates getTemplates(URL url)
          Gets templates for the XSL at the URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XSLTemplatesCache

public XSLTemplatesCache()
Creates a new cache.

Method Detail

contains

public boolean contains(File file)
Determines if this cache contains templates associated with this file.

Parameters:
file - XSL file
Returns:
true if the cache contains templates for this file, otherwise false
Throws:
IllegalArgumentException - if any argument is null

contains

public boolean contains(URL url)
Determines if this cache contains templates associated with this URL.

Parameters:
url - url of the XSLT
Returns:
true if the cache contains the template, otherwise false
Throws:
IllegalArgumentException - if any argument is null

add

public void add(File file)
         throws IOException,
                TransformerConfigurationException
Adds an XSL file to the cache.

Parameters:
file - XSL file
Throws:
IOException - if an I/O error occurs
TransformerConfigurationException - if a serious configuration error occurs.
IllegalArgumentException - if any argument is null

add

public void add(URL url)
         throws IOException,
                TransformerConfigurationException
Adds an XSL file, indicated by an URI, to the cache.

Parameters:
url - url of the XSL file
Throws:
IOException - if an I/O error occurs
TransformerConfigurationException - if a serious configuration error occurs.
IllegalArgumentException - if any argument is null

getTemplates

public Templates getTemplates(File file)
                       throws IOException,
                              TransformerConfigurationException
Gets templates for the XSL file object.

The templates will be cached if the file was not added yet.

Parameters:
file - XSL file
Returns:
transformer object
Throws:
IOException - if an I/O error occurs
TransformerConfigurationException - if a serious configuration error occurs.
IllegalArgumentException - if any argument is null

getTemplates

public Templates getTemplates(URL url)
                       throws IOException,
                              TransformerConfigurationException
Gets templates for the XSL at the URL.

The templates will be cached if the URL was not added yet.

Parameters:
url - XSL file, indicated by a URL
Returns:
templates
Throws:
IOException - if an I/O error occurs
TransformerConfigurationException - if a serious configuration error occurs.
IllegalArgumentException - if any argument is null