public class TransformerHelper extends Object
| Constructor and Description |
|---|
TransformerHelper()
Initializes a new instance of the
TransformerHelper. |
TransformerHelper(Class<? extends TransformerFactory> transformerFactoryClass)
Initializes a new instance of the
TransformerHelper with the specified TransformerFactory class. |
TransformerHelper(TransformerFactory transformerFactory)
Initializes a new instance of the
TransformerHelper with the specified TransformerFactory. |
| Modifier and Type | Method and Description |
|---|---|
Transformer |
createTransformer()
Creates a new
Transformer. |
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. |
void |
transform(Source source,
Result result)
|
public TransformerHelper()
TransformerHelper.public TransformerHelper(TransformerFactory transformerFactory)
TransformerHelper with the specified TransformerFactory.public TransformerHelper(Class<? extends TransformerFactory> transformerFactoryClass)
TransformerHelper with the specified TransformerFactory class.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()public TransformerFactory getTransformerFactory()
TransformerFactory.public Transformer createTransformer() throws TransformerConfigurationException
Transformer. Must be called per thread, as transformers are not thread-safe.TransformerConfigurationException - if thrown by JAXP methodspublic 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 methods