net.sf.joost.trax
Class TransformerImpl

java.lang.Object
  extended by javax.xml.transform.Transformer
      extended by net.sf.joost.trax.TransformerImpl
All Implemented Interfaces:
Constants, TrAXConstants

public class TransformerImpl
extends Transformer
implements TrAXConstants

This class implements the Transformer-Interface for TraX. With a Transformer-object you can proceed transformations, but be careful, because a Transformer-object is not thread- safe. For threads you should use Templates.

Author:
Zubow

Field Summary
 boolean cancelTransformation
          This is a run-time flag (only used when DEBUG_MODE is true).
static boolean DEBUG_MODE
          This is a compile-time flag to enable or disable calling of trace listeners.
private  ErrorListener errorListener
           
private  HashSet ignoredProperties
           
private static org.apache.commons.logging.Log log
           
private  Processor processor
           
private  Boolean reentryGuard
          Synch object to gaurd against setting values from the TrAX interface or reentry while the transform is going on.
private  HashSet supportedProperties
           
private  TraceManager traceManager
          The trace manager.
private  URIResolver uriRes
           
 
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
protected TransformerImpl(Processor processor)
          Constructor
 
Method Summary
 void clearParameters()
          Clears all parameters
 ErrorListener getErrorListener()
          Setter for errorListener
 Properties getOutputProperties()
          Getter for Processor.outputProperties
 String getOutputProperty(String name)
          Getter for an output property.
 Object getParameter(String name)
          Getter for parameters.
 Processor getStxProcessor()
          Getter for processor
 TraceManager getTraceManager()
          Get an instance of the tracemanager for this transformation.
 URIResolver getURIResolver()
          Getter for uriRes
private  boolean isValidOutputMethod(String value)
           
private  void performResults(Result result, StxEmitter out)
          Performs the Result.
 void setErrorListener(ErrorListener listener)
           
 void setOutputProperties(Properties oformat)
          Setter for Processor.outputProperties
 void setOutputProperty(String name, String value)
          Setter for an output property.
 void setParameter(String name, Object value)
          Setter for parameters.
 void setURIResolver(URIResolver resolver)
          Setter for uriRes
 void transform(Source xmlSource, Result result)
          Transforms a xml-source : SAXSource, DOMSource, StreamSource to SAXResult, DOMResult and StreamResult
 
Methods inherited from class javax.xml.transform.Transformer
reset
 
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

processor

private Processor processor

uriRes

private URIResolver uriRes

errorListener

private ErrorListener errorListener

supportedProperties

private HashSet supportedProperties

ignoredProperties

private HashSet ignoredProperties

reentryGuard

private Boolean reentryGuard
Synch object to gaurd against setting values from the TrAX interface or reentry while the transform is going on.


DEBUG_MODE

public static boolean DEBUG_MODE
This is a compile-time flag to enable or disable calling of trace listeners. For optimization purposes this flag must be set to false.


cancelTransformation

public boolean cancelTransformation
This is a run-time flag (only used when DEBUG_MODE is true). If the value is true, the transformation will be cancelled at the next possible execution step.


traceManager

private TraceManager traceManager
The trace manager.

Constructor Detail

TransformerImpl

protected TransformerImpl(Processor processor)
Constructor

Parameters:
processor - A Processor object.
Method Detail

getTraceManager

public TraceManager getTraceManager()
Get an instance of the tracemanager for this transformation. This object can be used to set tracelisteners on various events during the transformation.

Returns:
A reference to a tracemanager

transform

public void transform(Source xmlSource,
                      Result result)
               throws TransformerException
Transforms a xml-source : SAXSource, DOMSource, StreamSource to SAXResult, DOMResult and StreamResult

Specified by:
transform in class Transformer
Parameters:
xmlSource - A Source
result - A Result
Throws:
TransformerException

performResults

private void performResults(Result result,
                            StxEmitter out)
Performs the Result.

Parameters:
result - A Result
out - StxEmitter.

getOutputProperty

public String getOutputProperty(String name)
                         throws IllegalArgumentException
Getter for an output property.

Specified by:
getOutputProperty in class Transformer
Parameters:
name - The key of the output property.
Returns:
The value for that property, null if not set.
Throws:
IllegalArgumentException

setOutputProperty

public void setOutputProperty(String name,
                              String value)
                       throws IllegalArgumentException
Setter for an output property.

Specified by:
setOutputProperty in class Transformer
Parameters:
name - The key of the outputProperty.
value - The value of the outputProperty.
Throws:
IllegalArgumentException

getOutputProperties

public Properties getOutputProperties()
Getter for Processor.outputProperties

Specified by:
getOutputProperties in class Transformer
Returns:
a copy of the current output properties

setOutputProperties

public void setOutputProperties(Properties oformat)
                         throws IllegalArgumentException
Setter for Processor.outputProperties

Specified by:
setOutputProperties in class Transformer
Parameters:
oformat - A Properties object, that replaces the current set of output properties.
Throws:
IllegalArgumentException

isValidOutputMethod

private boolean isValidOutputMethod(String value)
Returns:
true if value is a valid output method

getURIResolver

public URIResolver getURIResolver()
Getter for uriRes

Specified by:
getURIResolver in class Transformer
Returns:
URIResolver

setURIResolver

public void setURIResolver(URIResolver resolver)
Setter for uriRes

Specified by:
setURIResolver in class Transformer
Parameters:
resolver - A URIResolver object.

clearParameters

public void clearParameters()
Clears all parameters

Specified by:
clearParameters in class Transformer

setParameter

public void setParameter(String name,
                         Object value)
Setter for parameters.

Specified by:
setParameter in class Transformer
Parameters:
name - The key of the parameter.
value - The value of the parameter.

getParameter

public Object getParameter(String name)
Getter for parameters.

Specified by:
getParameter in class Transformer
Parameters:
name - The key-value of the parameter.
Returns:
An Object according to the key-value or null.

setErrorListener

public void setErrorListener(ErrorListener listener)
                      throws IllegalArgumentException
Specified by:
setErrorListener in class Transformer
Parameters:
listener -
Throws:
IllegalArgumentException

getErrorListener

public ErrorListener getErrorListener()
Setter for errorListener

Specified by:
getErrorListener in class Transformer
Returns:
A ErrorListener

getStxProcessor

public Processor getStxProcessor()
Getter for processor

Returns:
A Processor object.