org.apache.xalan.xsltc.trax
Class TemplatesImpl

java.lang.Object
  extended by org.apache.xalan.xsltc.trax.TemplatesImpl
All Implemented Interfaces:
java.io.Serializable, javax.xml.transform.Templates

public final class TemplatesImpl
extends java.lang.Object
implements javax.xml.transform.Templates, java.io.Serializable

See Also:
Serialized Form

Nested Class Summary
(package private) static class TemplatesImpl.TransletClassLoader
           
 
Field Summary
private  Hashtable _auxClasses
          Contains the list of auxiliary class definitions.
private  byte[][] _bytecodes
          Contains the actual class definition for the translet class and any auxiliary classes.
private  java.lang.Class[] _class
          Contains the translet class definition(s).
private  int _indentNumber
          Number of spaces to add for output indentation.
private  java.lang.String _name
          Name of the main class or default name if unknown.
private  java.util.Properties _outputProperties
          Output properties of this translet.
private  java.lang.ThreadLocal _sdom
          Cache the DTM for the stylesheet in a thread local variable, which is used by the document('') function.
private  TransformerFactoryImpl _tfactory
          A reference to the transformer factory that this templates object belongs to.
private  int _transletIndex
          The index of the main translet class in the arrays _class[] and _bytecodes.
private  javax.xml.transform.URIResolver _uriResolver
          This URIResolver is passed to all Transformers.
private static java.lang.String ABSTRACT_TRANSLET
          Name of the superclass of all translets.
(package private) static long serialVersionUID
           
 
Constructor Summary
  TemplatesImpl()
          Need for de-serialization, see readObject().
protected TemplatesImpl(byte[][] bytecodes, java.lang.String transletName, java.util.Properties outputProperties, int indentNumber, TransformerFactoryImpl tfactory)
          Create an XSLTC template object from the bytecodes.
protected TemplatesImpl(java.lang.Class[] transletClasses, java.lang.String transletName, java.util.Properties outputProperties, int indentNumber, TransformerFactoryImpl tfactory)
          Create an XSLTC template object from the translet class definition(s).
 
Method Summary
private  void defineTransletClasses()
          Defines the translet class and auxiliary classes.
 java.util.Properties getOutputProperties()
          Implements JAXP's Templates.getOutputProperties().
 DOM getStylesheetDOM()
          Return the thread local copy of the stylesheet DOM.
 byte[][] getTransletBytecodes()
          Returns the translet bytecodes stored in this template
 java.lang.Class[] getTransletClasses()
          Returns the translet bytecodes stored in this template
 int getTransletIndex()
          Returns the index of the main class in array of bytecodes
private  Translet getTransletInstance()
          This method generates an instance of the translet class that is wrapped inside this Template.
protected  java.lang.String getTransletName()
          Returns the name of the main translet class stored in this template
 javax.xml.transform.Transformer newTransformer()
          Implements JAXP's Templates.newTransformer()
private  void readObject(java.io.ObjectInputStream is)
          Overrides the default readObject implementation since we decided it would be cleaner not to serialize the entire tranformer factory.
 void setStylesheetDOM(DOM sdom)
          Set the thread local copy of the stylesheet DOM.
protected  void setTransletBytecodes(byte[][] bytecodes)
          The TransformerFactory must pass us the translet bytecodes using this method before we can create any translet instances
protected  void setTransletName(java.lang.String name)
          The TransformerFactory should call this method to set the translet name
 void setURIResolver(javax.xml.transform.URIResolver resolver)
          Store URIResolver needed for Transformers.
private  void writeObject(java.io.ObjectOutputStream os)
          This is to fix bugzilla bug 22438 If the user defined class implements URIResolver and Serializable then we want it to get serialized
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values

ABSTRACT_TRANSLET

private static java.lang.String ABSTRACT_TRANSLET
Name of the superclass of all translets. This is needed to determine which, among all classes comprising a translet, is the main one.


_name

private java.lang.String _name
Name of the main class or default name if unknown.


_bytecodes

private byte[][] _bytecodes
Contains the actual class definition for the translet class and any auxiliary classes.


_class

private java.lang.Class[] _class
Contains the translet class definition(s). These are created when this Templates is created or when it is read back from disk.


_transletIndex

private int _transletIndex
The index of the main translet class in the arrays _class[] and _bytecodes.


_auxClasses

private Hashtable _auxClasses
Contains the list of auxiliary class definitions.


_outputProperties

private java.util.Properties _outputProperties
Output properties of this translet.


_indentNumber

private int _indentNumber
Number of spaces to add for output indentation.


_uriResolver

private transient javax.xml.transform.URIResolver _uriResolver
This URIResolver is passed to all Transformers. Declaring it transient to fix bug 22438


_sdom

private transient java.lang.ThreadLocal _sdom
Cache the DTM for the stylesheet in a thread local variable, which is used by the document('') function. Use ThreadLocal because a DTM cannot be shared between multiple threads. Declaring it transient to fix bug 22438


_tfactory

private transient TransformerFactoryImpl _tfactory
A reference to the transformer factory that this templates object belongs to.

Constructor Detail

TemplatesImpl

protected TemplatesImpl(byte[][] bytecodes,
                        java.lang.String transletName,
                        java.util.Properties outputProperties,
                        int indentNumber,
                        TransformerFactoryImpl tfactory)
Create an XSLTC template object from the bytecodes. The bytecodes for the translet and auxiliary classes, plus the name of the main translet class, must be supplied.


TemplatesImpl

protected TemplatesImpl(java.lang.Class[] transletClasses,
                        java.lang.String transletName,
                        java.util.Properties outputProperties,
                        int indentNumber,
                        TransformerFactoryImpl tfactory)
Create an XSLTC template object from the translet class definition(s).


TemplatesImpl

public TemplatesImpl()
Need for de-serialization, see readObject().

Method Detail

readObject

private void readObject(java.io.ObjectInputStream is)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Overrides the default readObject implementation since we decided it would be cleaner not to serialize the entire tranformer factory. [ ref bugzilla 12317 ] We need to check if the user defined class for URIResolver also implemented Serializable if yes then we need to deserialize the URIResolver Fix for bugzilla bug 22438

Throws:
java.io.IOException
java.lang.ClassNotFoundException

writeObject

private void writeObject(java.io.ObjectOutputStream os)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
This is to fix bugzilla bug 22438 If the user defined class implements URIResolver and Serializable then we want it to get serialized

Throws:
java.io.IOException
java.lang.ClassNotFoundException

setURIResolver

public void setURIResolver(javax.xml.transform.URIResolver resolver)
Store URIResolver needed for Transformers.


setTransletBytecodes

protected void setTransletBytecodes(byte[][] bytecodes)
The TransformerFactory must pass us the translet bytecodes using this method before we can create any translet instances


getTransletBytecodes

public byte[][] getTransletBytecodes()
Returns the translet bytecodes stored in this template


getTransletClasses

public java.lang.Class[] getTransletClasses()
Returns the translet bytecodes stored in this template


getTransletIndex

public int getTransletIndex()
Returns the index of the main class in array of bytecodes


setTransletName

protected void setTransletName(java.lang.String name)
The TransformerFactory should call this method to set the translet name


getTransletName

protected java.lang.String getTransletName()
Returns the name of the main translet class stored in this template


defineTransletClasses

private void defineTransletClasses()
                            throws javax.xml.transform.TransformerConfigurationException
Defines the translet class and auxiliary classes. Returns a reference to the Class object that defines the main class

Throws:
javax.xml.transform.TransformerConfigurationException

getTransletInstance

private Translet getTransletInstance()
                              throws javax.xml.transform.TransformerConfigurationException
This method generates an instance of the translet class that is wrapped inside this Template. The translet instance will later be wrapped inside a Transformer object.

Throws:
javax.xml.transform.TransformerConfigurationException

newTransformer

public javax.xml.transform.Transformer newTransformer()
                                               throws javax.xml.transform.TransformerConfigurationException
Implements JAXP's Templates.newTransformer()

Specified by:
newTransformer in interface javax.xml.transform.Templates
Throws:
javax.xml.transform.TransformerConfigurationException

getOutputProperties

public java.util.Properties getOutputProperties()
Implements JAXP's Templates.getOutputProperties(). We need to instanciate a translet to get the output settings, so we might as well just instanciate a Transformer and use its implementation of this method.

Specified by:
getOutputProperties in interface javax.xml.transform.Templates

getStylesheetDOM

public DOM getStylesheetDOM()
Return the thread local copy of the stylesheet DOM.


setStylesheetDOM

public void setStylesheetDOM(DOM sdom)
Set the thread local copy of the stylesheet DOM.