public class ParameterizedFilter
extends java.lang.Object
A filter with associated parameters which can modify its runtime behaviour.
A filter, whether implemented in XSLT or Java, can usefully be parameterized so that its behaviour can be modified at runtime. This class can be used to represent the underlying filter and a set of parameters. At the present time only String parameters are supported.
The constructors of this class support the various underlying filter types used in the rest of this package. These comprise
Class
based filters implemented in Java and XSLT based filters represented in their precompiled form by
Templates
objects, and in their source form by File
or URL
objects. Once constructed the
ParameterizedFilter.getType()
method can be used to determine the underlying filter implementation.
Once constructed a ParameterizedFilter can be used as an input filter or output filter by using the appropriate filter setting
methods which take a List
parameter: PipelinedComparator.setInputFilters(java.util.List)
and
PipelinedComparator.setOutputFilters(java.util.List)
.
Requirements for parameterization
The capabilities provided by this method are only applicable to filters which have been designed for parameterization. In particular:
ParameterizedFilter.setStringParameter(java.lang.String, java.lang.String)
Error handling
Many issues with incorrect parameterization (such as the above requirements being violated) will not be detected when the
ParameterizedFilter.setStringParameter(java.lang.String, java.lang.String)
method is used. Instead they will be detected and thrown as exceptions when the filters are
associated with the pipeline through the PipelinedComparator.setInputFilters(java.util.List)
and
PipelinedComparator.setOutputFilters(java.util.List)
methods.
Constructor and Description |
---|
ParameterizedFilter(java.lang.Class<? extends org.xml.sax.helpers.XMLFilterImpl> c)
Creates a filter based on Java code.
|
ParameterizedFilter(java.io.File file)
Creates a filter based on an underlying XSLT File.
|
ParameterizedFilter(javax.xml.transform.Templates template)
Creates a filter using a precompiled XSLT script represented by a JAXP Templates Object.
|
ParameterizedFilter(java.net.URL url)
Creates a filter based on an XSLT scripts at the specified URL.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Class<? extends org.xml.sax.helpers.XMLFilterImpl> |
getClassParam()
Provides access to the underlying Class Object used to create this ParameterizedFilter.
|
java.io.File |
getFile()
Provides access to the underlying File used to create this ParameterizedFilter.
|
java.lang.String |
getStringParameter(java.lang.String name)
Allows a String parameter's current setting to be looked up by name.
|
java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> |
getStringParametersIterator()
An iterator over the Map.Entry elements representing the String parameters associated with the filter.
|
javax.xml.transform.Templates |
getTemplate()
Provides access to the underlying JAXP Templates Object used to create this ParameterizedFilter.
|
ParameterType |
getType()
Allows the type of the underlying filter to be determined.
|
java.net.URL |
getURL()
Provides access to the underlying URL used to create this ParameterizedFilter.
|
void |
setStringParameter(java.lang.String name,
java.lang.String value)
Sets a specified parameter with a new String value.
|
public ParameterizedFilter(javax.xml.transform.Templates template)
template
- the Templates containing a precompiled XSLT FilterPipelinedComparator.setInputFilters(Templates[])
,
PipelinedComparator.setOutputFilters(Templates[])
public ParameterizedFilter(java.lang.Class<? extends org.xml.sax.helpers.XMLFilterImpl> c)
c
- A class object representing a Filter implementation in JavaPipelinedComparator.setInputFilters(Class[])
,
PipelinedComparator.setOutputFilters(Class[])
public ParameterizedFilter(java.net.URL url)
url
- a URL to locate the source of an XSLT filterPipelinedComparator.setInputFilters(URL[])
,
PipelinedComparator.setOutputFilters(URL[])
public ParameterizedFilter(java.io.File file)
file
- a File used to locate the source of an XSLT filterPipelinedComparator.setInputFilters(File[])
,
PipelinedComparator.setOutputFilters(File[])
public void setStringParameter(java.lang.String name, java.lang.String value)
name
- the name of the parameter to setvalue
- the new value for the parameterpublic java.lang.String getStringParameter(java.lang.String name)
name
- the name of the parameter to lookuppublic java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> getStringParametersIterator()
public ParameterType getType()
public java.net.URL getURL() throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
- if the underlying filter implementation is not of ParameterType.URLpublic java.lang.Class<? extends org.xml.sax.helpers.XMLFilterImpl> getClassParam() throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
- if the underlying filter implementation is not of ParameterType.CLASSpublic java.io.File getFile() throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
- if the underlying filter implementation is not of ParameterType.FILEpublic javax.xml.transform.Templates getTemplate() throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
- if the underlying filter implementation is not of ParameterType.TEMPLATESCopyright © 2001-2018 DeltaXML Ltd. All Rights Reserved.