Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.xalan.xsltc.trax
Class TransformerFactoryImpl  view TransformerFactoryImpl download TransformerFactoryImpl.java

java.lang.Object
  extended byjavax.xml.transform.TransformerFactory
      extended byjavax.xml.transform.sax.SAXTransformerFactory
          extended byorg.apache.xalan.xsltc.trax.TransformerFactoryImpl
All Implemented Interfaces:
javax.xml.transform.ErrorListener, org.apache.xalan.xsltc.compiler.SourceLoader

public class TransformerFactoryImpl
extends javax.xml.transform.sax.SAXTransformerFactory
implements org.apache.xalan.xsltc.compiler.SourceLoader, javax.xml.transform.ErrorListener

Implementation of a JAXP1.1 TransformerFactory for Translets.


Nested Class Summary
private static class TransformerFactoryImpl.PIParamWrapper
          The above hashtable stores objects of this class.
 
Field Summary
private  boolean _autoTranslet
          If this is set to true, we attempt to use translet classes for transformation if possible without compiling the stylesheet.
private  boolean _debug
          Set to true when debugging is enabled.
private  java.lang.String _destinationDirectory
          The destination directory for the translet
private  boolean _enableInlining
          Set to true when templates are inlined.
private  javax.xml.transform.ErrorListener _errorListener
          This error listener is used only for this factory and is not passed to the Templates or Transformer objects that we create.
private  boolean _generateTranslet
          Set to true when we want to generate translet classes from the stylesheet.
private  int _indentNumber
          Number of indent spaces when indentation is turned on.
private  java.lang.String _jarFileName
          The jar file name which the translet classes are packaged into
private  java.lang.String _packageName
          The package name prefix for all generated translet classes
private  java.util.Hashtable _piParams
          This Hashtable is used to store parameters for locating processing instructions in XML docs.
private  java.lang.String _transletName
          The class name of the translet
private  javax.xml.transform.URIResolver _uriResolver
          This URIResolver is passed to all created Templates and Transformers
private  boolean _useClasspath
          If this is set to true, we attempt to load the translet from the CLASSPATH.
(package private) static java.lang.ThreadLocal _xmlReader
          Use a thread local variable to store a copy of an XML Reader.
static java.lang.String AUTO_TRANSLET
           
static java.lang.String DEBUG
           
protected static java.lang.String DEFAULT_TRANSLET_NAME
          As Gregor Samsa awoke one morning from uneasy dreams he found himself transformed in his bed into a gigantic insect.
static java.lang.String DESTINATION_DIRECTORY
           
static java.lang.String ENABLE_INLINING
           
static java.lang.String GENERATE_TRANSLET
           
static java.lang.String INDENT_NUMBER
           
static java.lang.String JAR_NAME
           
private  java.lang.Class m_DTMManagerClass
          The provider of the XSLTC DTM Manager service.
static java.lang.String PACKAGE_NAME
           
static java.lang.String TRANSLET_NAME
           
static java.lang.String USE_CLASSPATH
           
 
Fields inherited from class javax.xml.transform.sax.SAXTransformerFactory
FEATURE, FEATURE_XMLFILTER
 
Constructor Summary
TransformerFactoryImpl()
          javax.xml.transform.sax.TransformerFactory implementation.
 
Method Summary
 void error(javax.xml.transform.TransformerException e)
          Receive notification of a recoverable error.
 void fatalError(javax.xml.transform.TransformerException e)
          Receive notification of a non-recoverable error.
 javax.xml.transform.Source getAssociatedStylesheet(javax.xml.transform.Source source, java.lang.String media, java.lang.String title, java.lang.String charset)
          javax.xml.transform.sax.TransformerFactory implementation.
 java.lang.Object getAttribute(java.lang.String name)
          javax.xml.transform.sax.TransformerFactory implementation.
private  byte[][] getBytecodesFromClasses(javax.xml.transform.Source source, java.lang.String fullClassName)
          Load the translet classes from local .class files and return the bytecode array.
private  byte[][] getBytecodesFromJar(javax.xml.transform.Source source, java.lang.String fullClassName)
          Load the translet classes from the jar file and return the bytecode.
protected  java.lang.Class getDTMManagerClass()
          Returns the Class object the provides the XSLTC DTM Manager service.
 javax.xml.transform.ErrorListener getErrorListener()
          javax.xml.transform.sax.TransformerFactory implementation.
 boolean getFeature(java.lang.String name)
          javax.xml.transform.sax.TransformerFactory implementation.
private  java.lang.String getStylesheetFileName(javax.xml.transform.Source source)
          Return the local file name from the systemId of the Source object
private  java.lang.String getTransletBaseName(javax.xml.transform.Source source)
          Return the base class name of the translet.
 javax.xml.transform.URIResolver getURIResolver()
          javax.xml.transform.sax.TransformerFactory implementation.
 org.xml.sax.InputSource loadSource(java.lang.String href, java.lang.String context, org.apache.xalan.xsltc.compiler.XSLTC xsltc)
          This method implements XSLTC's SourceLoader interface.
 javax.xml.transform.Templates newTemplates(javax.xml.transform.Source source)
          javax.xml.transform.sax.TransformerFactory implementation.
 javax.xml.transform.sax.TemplatesHandler newTemplatesHandler()
          javax.xml.transform.sax.SAXTransformerFactory implementation.
 javax.xml.transform.Transformer newTransformer()
          javax.xml.transform.sax.TransformerFactory implementation.
 javax.xml.transform.Transformer newTransformer(javax.xml.transform.Source source)
          javax.xml.transform.sax.TransformerFactory implementation.
 javax.xml.transform.sax.TransformerHandler newTransformerHandler()
          javax.xml.transform.sax.SAXTransformerFactory implementation.
 javax.xml.transform.sax.TransformerHandler newTransformerHandler(javax.xml.transform.Source src)
          javax.xml.transform.sax.SAXTransformerFactory implementation.
 javax.xml.transform.sax.TransformerHandler newTransformerHandler(javax.xml.transform.Templates templates)
          javax.xml.transform.sax.SAXTransformerFactory implementation.
 org.xml.sax.XMLFilter newXMLFilter(javax.xml.transform.Source src)
          javax.xml.transform.sax.SAXTransformerFactory implementation.
 org.xml.sax.XMLFilter newXMLFilter(javax.xml.transform.Templates templates)
          javax.xml.transform.sax.SAXTransformerFactory implementation.
private  void passErrorsToListener(java.util.Vector messages)
          Pass error messages from the compiler to the error listener
private  void passWarningsToListener(java.util.Vector messages)
          Pass warning messages from the compiler to the error listener
private  void readFromInputStream(byte[] bytes, java.io.InputStream input, int size)
          Read a given number of bytes from the InputStream into a byte array.
private  void resetTransientAttributes()
          Reset the per-session attributes to their default values
 void setAttribute(java.lang.String name, java.lang.Object value)
          javax.xml.transform.sax.TransformerFactory implementation.
 void setErrorListener(javax.xml.transform.ErrorListener listener)
          javax.xml.transform.sax.TransformerFactory implementation.
 void setURIResolver(javax.xml.transform.URIResolver resolver)
          javax.xml.transform.sax.TransformerFactory implementation.
 void warning(javax.xml.transform.TransformerException e)
          Receive notification of a warning.
 
Methods inherited from class javax.xml.transform.TransformerFactory
newInstance, setFeature
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRANSLET_NAME

public static final java.lang.String TRANSLET_NAME
See Also:
Constant Field Values

DESTINATION_DIRECTORY

public static final java.lang.String DESTINATION_DIRECTORY
See Also:
Constant Field Values

PACKAGE_NAME

public static final java.lang.String PACKAGE_NAME
See Also:
Constant Field Values

JAR_NAME

public static final java.lang.String JAR_NAME
See Also:
Constant Field Values

GENERATE_TRANSLET

public static final java.lang.String GENERATE_TRANSLET
See Also:
Constant Field Values

AUTO_TRANSLET

public static final java.lang.String AUTO_TRANSLET
See Also:
Constant Field Values

USE_CLASSPATH

public static final java.lang.String USE_CLASSPATH
See Also:
Constant Field Values

DEBUG

public static final java.lang.String DEBUG
See Also:
Constant Field Values

ENABLE_INLINING

public static final java.lang.String ENABLE_INLINING
See Also:
Constant Field Values

INDENT_NUMBER

public static final java.lang.String INDENT_NUMBER
See Also:
Constant Field Values

_errorListener

private javax.xml.transform.ErrorListener _errorListener
This error listener is used only for this factory and is not passed to the Templates or Transformer objects that we create.


_uriResolver

private javax.xml.transform.URIResolver _uriResolver
This URIResolver is passed to all created Templates and Transformers


DEFAULT_TRANSLET_NAME

protected static java.lang.String DEFAULT_TRANSLET_NAME
As Gregor Samsa awoke one morning from uneasy dreams he found himself transformed in his bed into a gigantic insect. He was lying on his hard, as it were armour plated, back, and if he lifted his head a little he could see his big, brown belly divided into stiff, arched segments, on top of which the bed quilt could hardly keep in position and was about to slide off completely. His numerous legs, which were pitifully thin compared to the rest of his bulk, waved helplessly before his eyes. "What has happened to me?", he thought. It was no dream....


_transletName

private java.lang.String _transletName
The class name of the translet


_destinationDirectory

private java.lang.String _destinationDirectory
The destination directory for the translet


_packageName

private java.lang.String _packageName
The package name prefix for all generated translet classes


_jarFileName

private java.lang.String _jarFileName
The jar file name which the translet classes are packaged into


_piParams

private java.util.Hashtable _piParams
This Hashtable is used to store parameters for locating processing instructions in XML docs.


_xmlReader

static java.lang.ThreadLocal _xmlReader
Use a thread local variable to store a copy of an XML Reader.


_debug

private boolean _debug
Set to true when debugging is enabled.


_enableInlining

private boolean _enableInlining
Set to true when templates are inlined.


_generateTranslet

private boolean _generateTranslet
Set to true when we want to generate translet classes from the stylesheet.


_autoTranslet

private boolean _autoTranslet
If this is set to true, we attempt to use translet classes for transformation if possible without compiling the stylesheet. The translet class is only used if its timestamp is newer than the timestamp of the stylesheet.


_useClasspath

private boolean _useClasspath
If this is set to true, we attempt to load the translet from the CLASSPATH.


_indentNumber

private int _indentNumber
Number of indent spaces when indentation is turned on.


m_DTMManagerClass

private java.lang.Class m_DTMManagerClass
The provider of the XSLTC DTM Manager service. This is fixed for any instance of this class. In order to change service providers, a new XSLTC TransformerFactory must be instantiated.

See Also:
XSLTCDTMManager.getDTMManagerClass()>XSLTCDTMManager.getDTMManagerClass() 55
Constructor Detail

TransformerFactoryImpl

public TransformerFactoryImpl()
javax.xml.transform.sax.TransformerFactory implementation.

Method Detail

setErrorListener

public void setErrorListener(javax.xml.transform.ErrorListener listener)
                      throws java.lang.IllegalArgumentException
javax.xml.transform.sax.TransformerFactory implementation. Set the error event listener for the TransformerFactory, which is used for the processing of transformation instructions, and not for the transformation itself.


getErrorListener

public javax.xml.transform.ErrorListener getErrorListener()
javax.xml.transform.sax.TransformerFactory implementation. Get the error event handler for the TransformerFactory.


getAttribute

public java.lang.Object getAttribute(java.lang.String name)
                              throws java.lang.IllegalArgumentException
javax.xml.transform.sax.TransformerFactory implementation. Returns the value set for a TransformerFactory attribute


setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
                  throws java.lang.IllegalArgumentException
javax.xml.transform.sax.TransformerFactory implementation. Sets the value for a TransformerFactory attribute.


getFeature

public boolean getFeature(java.lang.String name)
javax.xml.transform.sax.TransformerFactory implementation. Look up the value of a feature (to see if it is supported). This method must be updated as the various methods and features of this class are implemented.


getURIResolver

public javax.xml.transform.URIResolver getURIResolver()
javax.xml.transform.sax.TransformerFactory implementation. Get the object that is used by default during the transformation to resolve URIs used in document(), xsl:import, or xsl:include.


setURIResolver

public void setURIResolver(javax.xml.transform.URIResolver resolver)
javax.xml.transform.sax.TransformerFactory implementation. Set the object that is used by default during the transformation to resolve URIs used in document(), xsl:import, or xsl:include. Note that this does not affect Templates and Transformers that are already created with this factory.


getAssociatedStylesheet

public javax.xml.transform.Source getAssociatedStylesheet(javax.xml.transform.Source source,
                                                          java.lang.String media,
                                                          java.lang.String title,
                                                          java.lang.String charset)
                                                   throws javax.xml.transform.TransformerConfigurationException
javax.xml.transform.sax.TransformerFactory implementation. Get the stylesheet specification(s) associated via the xml-stylesheet processing instruction (see http://www.w3.org/TR/xml-stylesheet/) with the document document specified in the source parameter, and that match the given criteria.


newTransformer

public javax.xml.transform.Transformer newTransformer()
                                               throws javax.xml.transform.TransformerConfigurationException
javax.xml.transform.sax.TransformerFactory implementation. Create a Transformer object that copies the input document to the result.


newTransformer

public javax.xml.transform.Transformer newTransformer(javax.xml.transform.Source source)
                                               throws javax.xml.transform.TransformerConfigurationException
javax.xml.transform.sax.TransformerFactory implementation. Process the Source into a Templates object, which is a a compiled representation of the source. Note that this method should not be used with XSLTC, as the time-consuming compilation is done for each and every transformation.


passWarningsToListener

private void passWarningsToListener(java.util.Vector messages)
                             throws javax.xml.transform.TransformerException
Pass warning messages from the compiler to the error listener


passErrorsToListener

private void passErrorsToListener(java.util.Vector messages)
Pass error messages from the compiler to the error listener


newTemplates

public javax.xml.transform.Templates newTemplates(javax.xml.transform.Source source)
                                           throws javax.xml.transform.TransformerConfigurationException
javax.xml.transform.sax.TransformerFactory implementation. Process the Source into a Templates object, which is a a compiled representation of the source.


newTemplatesHandler

public javax.xml.transform.sax.TemplatesHandler newTemplatesHandler()
                                                             throws javax.xml.transform.TransformerConfigurationException
javax.xml.transform.sax.SAXTransformerFactory implementation. Get a TemplatesHandler object that can process SAX ContentHandler events into a Templates object.


newTransformerHandler

public javax.xml.transform.sax.TransformerHandler newTransformerHandler()
                                                                 throws javax.xml.transform.TransformerConfigurationException
javax.xml.transform.sax.SAXTransformerFactory implementation. Get a TransformerHandler object that can process SAX ContentHandler events into a Result. This method will return a pure copy transformer.


newTransformerHandler

public javax.xml.transform.sax.TransformerHandler newTransformerHandler(javax.xml.transform.Source src)
                                                                 throws javax.xml.transform.TransformerConfigurationException
javax.xml.transform.sax.SAXTransformerFactory implementation. Get a TransformerHandler object that can process SAX ContentHandler events into a Result, based on the transformation instructions specified by the argument.


newTransformerHandler

public javax.xml.transform.sax.TransformerHandler newTransformerHandler(javax.xml.transform.Templates templates)
                                                                 throws javax.xml.transform.TransformerConfigurationException
javax.xml.transform.sax.SAXTransformerFactory implementation. Get a TransformerHandler object that can process SAX ContentHandler events into a Result, based on the transformation instructions specified by the argument.


newXMLFilter

public org.xml.sax.XMLFilter newXMLFilter(javax.xml.transform.Source src)
                                   throws javax.xml.transform.TransformerConfigurationException
javax.xml.transform.sax.SAXTransformerFactory implementation. Create an XMLFilter that uses the given source as the transformation instructions.


newXMLFilter

public org.xml.sax.XMLFilter newXMLFilter(javax.xml.transform.Templates templates)
                                   throws javax.xml.transform.TransformerConfigurationException
javax.xml.transform.sax.SAXTransformerFactory implementation. Create an XMLFilter that uses the given source as the transformation instructions.


error

public void error(javax.xml.transform.TransformerException e)
           throws javax.xml.transform.TransformerException
Receive notification of a recoverable error. The transformer must continue to provide normal parsing events after invoking this method. It should still be possible for the application to process the document through to the end.

Specified by:
error in interface javax.xml.transform.ErrorListener

fatalError

public void fatalError(javax.xml.transform.TransformerException e)
                throws javax.xml.transform.TransformerException
Receive notification of a non-recoverable error. The application must assume that the transformation cannot continue after the Transformer has invoked this method, and should continue (if at all) only to collect addition error messages. In fact, Transformers are free to stop reporting events once this method has been invoked.

Specified by:
fatalError in interface javax.xml.transform.ErrorListener

warning

public void warning(javax.xml.transform.TransformerException e)
             throws javax.xml.transform.TransformerException
Receive notification of a warning. Transformers can use this method to report conditions that are not errors or fatal errors. The default behaviour is to take no action. After invoking this method, the Transformer must continue with the transformation. It should still be possible for the application to process the document through to the end.

Specified by:
warning in interface javax.xml.transform.ErrorListener

loadSource

public org.xml.sax.InputSource loadSource(java.lang.String href,
                                          java.lang.String context,
                                          org.apache.xalan.xsltc.compiler.XSLTC xsltc)
This method implements XSLTC's SourceLoader interface. It is used to glue a TrAX URIResolver to the XSLTC compiler's Input and Import classes.

Specified by:
loadSource in interface org.apache.xalan.xsltc.compiler.SourceLoader

resetTransientAttributes

private void resetTransientAttributes()
Reset the per-session attributes to their default values


getBytecodesFromClasses

private byte[][] getBytecodesFromClasses(javax.xml.transform.Source source,
                                         java.lang.String fullClassName)
Load the translet classes from local .class files and return the bytecode array.


getBytecodesFromJar

private byte[][] getBytecodesFromJar(javax.xml.transform.Source source,
                                     java.lang.String fullClassName)
Load the translet classes from the jar file and return the bytecode.


readFromInputStream

private void readFromInputStream(byte[] bytes,
                                 java.io.InputStream input,
                                 int size)
                          throws java.io.IOException
Read a given number of bytes from the InputStream into a byte array.


getTransletBaseName

private java.lang.String getTransletBaseName(javax.xml.transform.Source source)
Return the base class name of the translet. The translet name is resolved using the following rules: 1. if the _transletName attribute is set and its value is not "GregorSamsa", then _transletName is returned. 2. otherwise get the translet name from the base name of the system ID 3. return "GregorSamsa" if the result from step 2 is null.


getStylesheetFileName

private java.lang.String getStylesheetFileName(javax.xml.transform.Source source)
Return the local file name from the systemId of the Source object


getDTMManagerClass

protected java.lang.Class getDTMManagerClass()
Returns the Class object the provides the XSLTC DTM Manager service.