Spring Web Services Framework

org.springframework.xml.transform
Class TransformerHelper

java.lang.Object
  extended by org.springframework.xml.transform.TransformerHelper

public class TransformerHelper
extends Object

Helper class for Transformer usage. Provides createTransformer() and transform(Source, Result).

Since:
3.0
Author:
Arjen Poutsma

Constructor Summary
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.
 
Method Summary
 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)
          Transforms the given Source to the given Result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransformerHelper

public TransformerHelper()
Initializes a new instance of the TransformerHelper.


TransformerHelper

public TransformerHelper(TransformerFactory transformerFactory)
Initializes a new instance of the TransformerHelper with the specified TransformerFactory.


TransformerHelper

public TransformerHelper(Class<? extends TransformerFactory> transformerFactoryClass)
Initializes a new instance of the TransformerHelper with the specified TransformerFactory class.

Method Detail

setTransformerFactoryClass

public void setTransformerFactoryClass(Class<? extends TransformerFactory> transformerFactoryClass)
Specify the TransformerFactory class to use.


newTransformerFactory

protected TransformerFactory newTransformerFactory(Class<? extends TransformerFactory> transformerFactoryClass)
Instantiate a new TransformerFactory.

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.

Parameters:
transformerFactoryClass - the specified factory class (if any)
Returns:
the new TransactionFactory instance
See Also:
setTransformerFactoryClass(java.lang.Class), getTransformerFactory()

getTransformerFactory

public TransformerFactory getTransformerFactory()
Returns the TransformerFactory.

Returns:
the transformer factory

createTransformer

public Transformer createTransformer()
                              throws TransformerConfigurationException
Creates a new Transformer. Must be called per thread, as transformers are not thread-safe.

Returns:
the created transformer
Throws:
TransformerConfigurationException - if thrown by JAXP methods

transform

public void transform(Source source,
                      Result result)
               throws TransformerException
Transforms the given Source to the given Result. Creates a new Transformer for every call, as transformers are not thread-safe.

Parameters:
source - the source to transform from
result - the result to transform to
Throws:
TransformerException - if thrown by JAXP methods

Spring Web Services Framework

Copyright © 2005-2013 The Spring Web Services Framework. All Rights Reserved.