Class TransformerHelper
java.lang.Object
org.springframework.xml.transform.TransformerHelper
- Since:
- 3.0
- Author:
- Arjen Poutsma
-
Constructor Summary
ConstructorsConstructorDescriptionInitializes a new instance of theTransformerHelper.TransformerHelper(Class<? extends TransformerFactory> transformerFactoryClass) Initializes a new instance of theTransformerHelperwith the specifiedTransformerFactoryclass.TransformerHelper(TransformerFactory transformerFactory) Initializes a new instance of theTransformerHelperwith the specifiedTransformerFactory. -
Method Summary
Modifier and TypeMethodDescriptionCreates a newTransformer.Returns theTransformerFactory.protected TransformerFactorynewTransformerFactory(Class<? extends TransformerFactory> transformerFactoryClass) Instantiate a new TransformerFactory.voidsetTransformerFactoryClass(Class<? extends TransformerFactory> transformerFactoryClass) Specify theTransformerFactoryclass to use.void
-
Constructor Details
-
TransformerHelper
public TransformerHelper()Initializes a new instance of theTransformerHelper. -
TransformerHelper
Initializes a new instance of theTransformerHelperwith the specifiedTransformerFactory. -
TransformerHelper
Initializes a new instance of theTransformerHelperwith the specifiedTransformerFactoryclass.
-
-
Method Details
-
setTransformerFactoryClass
Specify theTransformerFactoryclass to use. -
newTransformerFactory
protected TransformerFactory newTransformerFactory(Class<? extends TransformerFactory> transformerFactoryClass) Instantiate a new TransformerFactory.The default implementation simply calls
TransformerFactory.newInstance(). If atransformerFactoryClasshas been specified explicitly, the default constructor of the specified class will be called instead.Can be overridden in subclasses.
- Parameters:
transformerFactoryClass- the specified factory class (if any)- Returns:
- the new TransactionFactory instance
- See Also:
-
getTransformerFactory
Returns theTransformerFactory.- Returns:
- the transformer factory
-
createTransformer
Creates a newTransformer. Must be called per thread, as transformers are not thread-safe.- Returns:
- the created transformer
- Throws:
TransformerConfigurationException- if thrown by JAXP methods
-
transform
Transforms the givenSourceto the givenResult. Creates a newTransformerfor every call, as transformers are not thread-safe.- Parameters:
source- the source to transform fromresult- the result to transform to- Throws:
TransformerException- if thrown by JAXP methods
-