net.sf.joost.trax
Class TransformerFactoryImpl

java.lang.Object
  extended by javax.xml.transform.TransformerFactory
      extended by javax.xml.transform.sax.SAXTransformerFactory
          extended by net.sf.joost.trax.TransformerFactoryImpl
All Implemented Interfaces:
Constants, TrAXConstants

public class TransformerFactoryImpl
extends SAXTransformerFactory
implements TrAXConstants

This class implements the TransformerFactory-Interface for TraX. With the help of this factory you can get a templates-object or directly a transformer-object for the transformation process. If you use a SAXResult you can simply downcast to SAXTransformerFactory and use it like a Sax-Parser.

Author:
Zubow

Field Summary
protected  boolean allowExternalFunctions
           
private  boolean debugmode
           
protected  ConfigurationErrListener defaultErrorListener
           
private  ErrorListener errorListener
           
private static org.apache.commons.logging.Log log
           
private  StxEmitter msgEmitter
           
protected  OutputURIResolver outputUriResolver
           
private  ParserListenerMgr parserListenerMgr
          The parserlistener manager for tracing purpose.
private  Boolean reentryGuard
           
protected  TransformerHandlerResolver thResolver
           
private  URIResolver uriResolver
           
 
Fields inherited from class javax.xml.transform.sax.SAXTransformerFactory
FEATURE, FEATURE_XMLFILTER
 
Fields inherited from interface net.sf.joost.trax.TrAXConstants
ALLOW_EXTERNAL_FUNCTIONS, DEBUG_FEATURE, IDENTITY_TRANSFORM, KEY_OUTPUT_URI_RESOLVER, KEY_TH_RESOLVER, KEY_XSLT_FACTORY, MESSAGE_EMITTER_CLASS, OUTPUT_KEY_SUPPORT_DISABLE_OUTPUT_ESCAPING
 
Fields inherited from interface net.sf.joost.Constants
DEBUG, DEFAULT_ENCODING, FEAT_NS, FEAT_NSPREFIX, FEATURE_URI_PREFIX, FUNC_NS, JOOST_EXT_NS, PR_ATTRIBUTES, PR_BUFFER, PR_CHILDREN, PR_CONTINUE, PR_ERROR, PR_SELF, PR_SIBLINGS, STX_NS
 
Constructor Summary
TransformerFactoryImpl()
          The default constructor.
 
Method Summary
 StxEmitter buildMessageEmitter(String emitterClass)
          Method creates a new Emitter for stx:message output
 Source getAssociatedStylesheet(Source source, String media, String title, String charset)
          Returns the Source of the stylesheet associated with the xml-document.
 Object getAttribute(String name)
          Allows the user to retrieve specific attributes of the underlying implementation.
 ErrorListener getErrorListener()
          Getter for errorListener
 boolean getFeature(String name)
          Supplied features.
 StxEmitter getMessageEmitter()
          returns the value of msgEmitter
 ParserListenerMgr getParserListenerMgr()
          returns the value of parserListenerMgr
 URIResolver getURIResolver()
          Getter for uriResolver
private  Class loadClass(String className)
           
 Templates newTemplates(Source source)
          Creates a new Templates for Transformations.
 TemplatesHandler newTemplatesHandler()
          Gets a TemplatesHandler object that can process SAX ContentHandler events into a Templates object.
 Transformer newTransformer()
          Creates a new Transformer object that performs a copy of the source to the result.
 Transformer newTransformer(Source source)
          Gets a new Transformer object for transformation.
 TransformerHandler newTransformerHandler()
          Gets a TransformerHandler object that can process SAX ContentHandler events into a Result.
 TransformerHandler newTransformerHandler(Source src)
          Gets a TransformerHandler object that can process SAX ContentHandler events into a Result, based on the transformation instructions specified by the argument.
 TransformerHandler newTransformerHandler(Templates templates)
          Gets a TransformerHandler object that can process SAX ContentHandler events into a Result, based on the Templates argument.
 XMLFilter newXMLFilter(Source src)
          Creates an XMLFilter that uses the given Source as the transformation instructions.
 XMLFilter newXMLFilter(Templates templates)
          Creates an XMLFilter, based on the Templates argument.
 void setAttribute(String name, Object value)
          Allows the user to set specific attributes on the underlying implementation.
 void setErrorListener(ErrorListener errorListener)
          Setter for errorListener
 void setFeature(String name, boolean value)
          see TransformerFactory.setFeature(java.lang.String, boolean)
 void setURIResolver(URIResolver resolver)
          Setter for uriResolver
 
Methods inherited from class javax.xml.transform.TransformerFactory
newInstance, newInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.commons.logging.Log log

uriResolver

private URIResolver uriResolver

errorListener

private ErrorListener errorListener

thResolver

protected TransformerHandlerResolver thResolver

outputUriResolver

protected OutputURIResolver outputUriResolver

allowExternalFunctions

protected boolean allowExternalFunctions

defaultErrorListener

protected ConfigurationErrListener defaultErrorListener

debugmode

private boolean debugmode

msgEmitter

private StxEmitter msgEmitter

reentryGuard

private Boolean reentryGuard

parserListenerMgr

private ParserListenerMgr parserListenerMgr
The parserlistener manager for tracing purpose.

Constructor Detail

TransformerFactoryImpl

public TransformerFactoryImpl()
The default constructor.

Method Detail

getAssociatedStylesheet

public Source getAssociatedStylesheet(Source source,
                                      String media,
                                      String title,
                                      String charset)
                               throws TransformerConfigurationException
Returns the Source of the stylesheet associated with the xml-document. Feature is not supported.

Specified by:
getAssociatedStylesheet in class TransformerFactory
Parameters:
source - The Source of the xml-document.
media - Matching media-type.
title - Matching title-type.
charset - Matching charset-type.
Returns:
A Source of the stylesheet.
Throws:
TransformerConfigurationException

getAttribute

public Object getAttribute(String name)
                    throws IllegalArgumentException
Allows the user to retrieve specific attributes of the underlying implementation.

Specified by:
getAttribute in class TransformerFactory
Parameters:
name - The attribute name.
Returns:
An object according to the attribute-name
Throws:
IllegalArgumentException - When such a attribute does not exists.

setAttribute

public void setAttribute(String name,
                         Object value)
                  throws IllegalArgumentException
Allows the user to set specific attributes on the underlying implementation. An attribute in this context is defined to be an option that the implementation provides.

Specified by:
setAttribute in class TransformerFactory
Parameters:
name - Name of the attribute (key)
value - Value of the attribute.
Throws:
IllegalArgumentException

getErrorListener

public ErrorListener getErrorListener()
Getter for errorListener

Specified by:
getErrorListener in class TransformerFactory
Returns:
The registered ErrorListener

setErrorListener

public void setErrorListener(ErrorListener errorListener)
                      throws IllegalArgumentException
Setter for errorListener

Specified by:
setErrorListener in class TransformerFactory
Parameters:
errorListener - The ErrorListener object.
Throws:
IllegalArgumentException

getURIResolver

public URIResolver getURIResolver()
Getter for uriResolver

Specified by:
getURIResolver in class TransformerFactory
Returns:
The registered URIResolver

setURIResolver

public void setURIResolver(URIResolver resolver)
Setter for uriResolver

Specified by:
setURIResolver in class TransformerFactory
Parameters:
resolver - The URIResolver object.

setFeature

public void setFeature(String name,
                       boolean value)
                throws TransformerConfigurationException
see TransformerFactory.setFeature(java.lang.String, boolean)

Specified by:
setFeature in class TransformerFactory
Throws:
TransformerConfigurationException

getFeature

public boolean getFeature(String name)
Supplied features.

Specified by:
getFeature in class TransformerFactory
Parameters:
name - Name of the feature.
Returns:
true if feature is supported.

newTemplates

public Templates newTemplates(Source source)
                       throws TransformerConfigurationException
Creates a new Templates for Transformations.

Specified by:
newTemplates in class TransformerFactory
Parameters:
source - The Source of the stylesheet.
Returns:
A Templates object or null when an error occured (no user defined ErrorListener)
Throws:
TransformerConfigurationException

newTransformer

public Transformer newTransformer()
                           throws TransformerConfigurationException
Creates a new Transformer object that performs a copy of the source to the result.

Specified by:
newTransformer in class TransformerFactory
Returns:
A Transformer object for an identical transformation.
Throws:
TransformerConfigurationException

newTransformer

public Transformer newTransformer(Source source)
                           throws TransformerConfigurationException
Gets a new Transformer object for transformation.

Specified by:
newTransformer in class TransformerFactory
Parameters:
source - The Source of the stylesheet.
Returns:
A Transformer object according to the Templates object.
Throws:
TransformerConfigurationException

newTemplatesHandler

public TemplatesHandler newTemplatesHandler()
                                     throws TransformerConfigurationException
Gets a TemplatesHandler object that can process SAX ContentHandler events into a Templates object. Implementation of the SAXTransformerFactory

Specified by:
newTemplatesHandler in class SAXTransformerFactory
Returns:
TemplatesHandler ready to parse a stylesheet.
Throws:
TransformerConfigurationException
See Also:
SAXTransformerFactory

newTransformerHandler

public TransformerHandler newTransformerHandler()
                                         throws TransformerConfigurationException
Gets a TransformerHandler object that can process SAX ContentHandler events into a Result. The transformation is defined as an identity (or copy) transformation, for example to copy a series of SAX parse events into a DOM tree. Implementation of the SAXTransformerFactory

Specified by:
newTransformerHandler in class SAXTransformerFactory
Returns:
TransformerHandler ready to transform SAX events.
Throws:
TransformerConfigurationException

newTransformerHandler

public TransformerHandler newTransformerHandler(Source src)
                                         throws TransformerConfigurationException
Gets a TransformerHandler object that can process SAX ContentHandler events into a Result, based on the transformation instructions specified by the argument. Implementation of the SAXTransformerFactory

Specified by:
newTransformerHandler in class SAXTransformerFactory
Parameters:
src - The Source of the transformation instructions
Returns:
TransformerHandler ready to transform SAX events.
Throws:
TransformerConfigurationException

newTransformerHandler

public TransformerHandler newTransformerHandler(Templates templates)
                                         throws TransformerConfigurationException
Gets a TransformerHandler object that can process SAX ContentHandler events into a Result, based on the Templates argument. Implementation of the SAXTransformerFactory

Specified by:
newTransformerHandler in class SAXTransformerFactory
Parameters:
templates - - The compiled transformation instructions.
Returns:
TransformerHandler ready to transform SAX events.
Throws:
TransformerConfigurationException

newXMLFilter

public XMLFilter newXMLFilter(Source src)
                       throws TransformerConfigurationException
Creates an XMLFilter that uses the given Source as the transformation instructions. Implementation of the SAXTransformerFactory

Specified by:
newXMLFilter in class SAXTransformerFactory
Parameters:
src - - The Source of the transformation instructions.
Returns:
An XMLFilter object, or null if this feature is not supported.
Throws:
TransformerConfigurationException

newXMLFilter

public XMLFilter newXMLFilter(Templates templates)
Creates an XMLFilter, based on the Templates argument. Implementation of the SAXTransformerFactory

Specified by:
newXMLFilter in class SAXTransformerFactory
Parameters:
templates - - The compiled transformation instructions.
Returns:
An XMLFilter object, or null if this feature is not supported.

getParserListenerMgr

public ParserListenerMgr getParserListenerMgr()
returns the value of parserListenerMgr


getMessageEmitter

public StxEmitter getMessageEmitter()
returns the value of msgEmitter


buildMessageEmitter

public StxEmitter buildMessageEmitter(String emitterClass)
                               throws TransformerConfigurationException
Method creates a new Emitter for stx:message output

Parameters:
emitterClass - the name of the emitter class
Returns:
a StxEmitter
Throws:
TransformerConfigurationException - in case of errors

loadClass

private Class loadClass(String className)
                 throws TransformerConfigurationException
Throws:
TransformerConfigurationException