public abstract class TransformerObjectSupport extends Object
Transformer
. Subclasses can call createTransformer()
or transform(Source, Result)
. This should be done per thread (i.e. per incoming
request), because Transformer
instances are not thread-safe.Transformer
Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.logging.Log |
logger
Logger available to subclasses.
|
Constructor and Description |
---|
TransformerObjectSupport() |
Modifier and Type | Method and Description |
---|---|
protected Transformer |
createTransformer()
Creates a new
Transformer . |
protected TransformerFactory |
getTransformerFactory()
Returns the
TransformerFactory . |
protected TransformerFactory |
newTransformerFactory(Class<? extends TransformerFactory> transformerFactoryClass)
Instantiate a new TransformerFactory.
|
void |
setTransformerFactoryClass(Class<? extends TransformerFactory> transformerFactoryClass)
Specify the
TransformerFactory class to use. |
protected void |
transform(Source source,
Result result)
|
protected final org.apache.commons.logging.Log logger
public void setTransformerFactoryClass(Class<? extends TransformerFactory> transformerFactoryClass)
TransformerFactory
class to use.protected TransformerFactory newTransformerFactory(Class<? extends TransformerFactory> transformerFactoryClass)
The default implementation simply calls TransformerFactory.newInstance()
. If a "transformerFactoryClass"
has been
specified explicitly, the default constructor of the specified class will be called instead.
Can be overridden in subclasses.
transformerFactoryClass
- the specified factory class (if any)setTransformerFactoryClass(java.lang.Class<? extends javax.xml.transform.TransformerFactory>)
,
getTransformerFactory()
protected TransformerFactory getTransformerFactory()
TransformerFactory
.protected final Transformer createTransformer() throws TransformerConfigurationException
Transformer
. Must be called per request, as transformers are not thread-safe.TransformerConfigurationException
- if thrown by JAXP methodsprotected final void transform(Source source, Result result) throws TransformerException
Source
to the given Result
. Creates a new Transformer
for every
call, as transformers are not thread-safe.source
- the source to transform fromresult
- the result to transform toTransformerException
- if thrown by JAXP methodsCopyright © 2020 Pivotal Software. All rights reserved.