org.apache.xalan.xsltc.runtime
Class AbstractTranslet

java.lang.Object
  extended by org.apache.xalan.xsltc.runtime.AbstractTranslet
All Implemented Interfaces:
Translet

public abstract class AbstractTranslet
extends java.lang.Object
implements Translet


Field Summary
private  Hashtable _auxClasses
           
 java.util.Vector _cdata
           
private  int _currentRootForKeys
           
 java.lang.String _doctypePublic
           
 java.lang.String _doctypeSystem
           
private  DOMCache _domCache
          DOM cache handling
protected  org.w3c.dom.DOMImplementation _domImplementation
          DOMImplementation caching for basis library
private  KeyIndex _emptyKeyIndex
           
 java.lang.String _encoding
           
 Hashtable _formatSymbols
          Decimal number format symbol handling
protected  boolean _hasIdCall
           
 boolean _indent
           
 int _indentamount
           
private  int _indexSize
           
private  Hashtable _keyIndexes
          Index(es) for / key() / id()
 java.lang.String _mediaType
           
 java.lang.String _method
           
private  MessageHandler _msgHandler
          Message handling - implementation of
 boolean _omitHeader
           
 java.lang.String _standalone
           
protected  javax.xml.transform.Templates _templates
           
 java.lang.String _version
           
static int CURRENT_TRANSLET_VERSION
           
private static java.lang.String EMPTYSTRING
           
static int FIRST_TRANSLET_VERSION
           
private static java.lang.String ID_INDEX_NAME
           
protected  java.lang.String[] namesArray
           
protected  java.lang.String[] namespaceArray
           
protected  java.util.ArrayList paramsStack
           
protected  int pbase
          Parameter handling
protected  int pframe
          Parameter handling
protected  StringValueHandler stringValueHandler
           
protected  int transletVersion
           
protected  int[] typesArray
           
protected  java.lang.String[] urisArray
           
static int VER_SPLIT_NAMES_ARRAY
           
 
Constructor Summary
AbstractTranslet()
           
 
Method Summary
 void addAuxiliaryClass(java.lang.Class auxClass)
           
 void addCdataElement(java.lang.String name)
          Add's a name of an element whose text contents should be output as CDATA
 void addDecimalFormat(java.lang.String name, java.text.DecimalFormatSymbols symbols)
          Adds a DecimalFormat object to the _formatSymbols hashtable.
 java.lang.Object addParameter(java.lang.String name, java.lang.Object value)
          Add a new global parameter if not already in the current frame.
 java.lang.Object addParameter(java.lang.String name, java.lang.Object value, boolean isDefault)
          Add a new global or local parameter if not already in the current frame.
private  void buildIDIndex(DOM document)
          Leverages the Key Class to implement the XSLT id() function.
 void buildKeyIndex(java.lang.String name, DOM dom)
          Create an empty KeyIndex in the DOM case
 void buildKeyIndex(java.lang.String name, int node, java.lang.Object value)
          Adds a value to a key/id index
 void buildKeys(DOM document, DTMAxisIterator iterator, SerializationHandler handler, int root)
          This method builds key indexes - it is overridden in the compiled translet in cases where the element is used
 void characters(java.lang.String string, SerializationHandler handler)
          Used by some compiled code as a shortcut for passing strings to the output handler
 void clearParameters()
          Clears the parameter stack.
 void closeOutputHandler(SerializationHandler handler)
           
 KeyIndex createKeyIndex()
          Creates a KeyIndex object of the desired size - don't want to resize!!!
 void displayMessage(java.lang.String msg)
          Pass a message to the message handler - used by Message class.
 java.lang.Class getAuxiliaryClass(java.lang.String className)
           
 java.text.DecimalFormat getDecimalFormat(java.lang.String name)
          Retrieves a named DecimalFormat object from _formatSymbols hashtable.
 DOMCache getDOMCache()
          Returns the DOM cache used for this translet.
 KeyIndex getKeyIndex(java.lang.String name)
          Returns the index for a given key (or id).
 java.lang.String[] getNamesArray()
           
 java.lang.String[] getNamespaceArray()
           
 java.lang.Object getParameter(java.lang.String name)
          Get the value of a parameter from the current frame or null if undefined.
 javax.xml.transform.Templates getTemplates()
           
 int[] getTypesArray()
           
 java.lang.String[] getUrisArray()
           
 boolean hasIdCall()
           
 DOMAdapter makeDOMAdapter(DOM dom)
          Wrap the initial input DOM in a dom adapter.
 org.w3c.dom.Document newDocument(java.lang.String uri, java.lang.String qname)
           
 SerializationHandler openOutputHandler(java.lang.String filename)
           
 SerializationHandler openOutputHandler(java.lang.String filename, boolean append)
          Multiple output document extension.
 void popParamFrame()
          Pop the topmost parameter frame.
 void postInitialization()
          After constructing the translet object, this method must be called to perform any version-specific post-initialization that's required.
 void prepassDocument(DOM document)
          Give the translet an opportunity to perform a prepass on the document to extract any information that it can store in an optimized form.
 void printInternalState()
          Debugging
 void pushParamFrame()
          Push a new parameter frame.
 void setAuxiliaryClasses(Hashtable auxClasses)
           
 void setDOMCache(DOMCache cache)
          Sets the DOM cache used for additional documents loaded using the document() function.
 void setIndexSize(int size)
          This method is used to pass the largest DOM size to the translet.
 void setKeyIndexDom(java.lang.String name, DOM document)
          This method builds key indexes - it is overridden in the compiled translet in cases where the element is used
 void setMessageHandler(MessageHandler handler)
          Set the translet's message handler - must implement MessageHandler
private  void setRootForKeys(int root)
           
 void setTemplates(javax.xml.transform.Templates templates)
           
protected  void transferOutputSettings(SerializationHandler handler)
          Transfer the output settings to the output post-processor
abstract  void transform(DOM document, DTMAxisIterator iterator, SerializationHandler handler)
          Main transform() method - this is overridden by the compiled translet
 void transform(DOM document, SerializationHandler handler)
          Calls transform() with a given output handler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.xalan.xsltc.Translet
transform
 

Field Detail

_version

public java.lang.String _version

_method

public java.lang.String _method

_encoding

public java.lang.String _encoding

_omitHeader

public boolean _omitHeader

_standalone

public java.lang.String _standalone

_doctypePublic

public java.lang.String _doctypePublic

_doctypeSystem

public java.lang.String _doctypeSystem

_indent

public boolean _indent

_mediaType

public java.lang.String _mediaType

_cdata

public java.util.Vector _cdata

_indentamount

public int _indentamount

FIRST_TRANSLET_VERSION

public static final int FIRST_TRANSLET_VERSION
See Also:
Constant Field Values

VER_SPLIT_NAMES_ARRAY

public static final int VER_SPLIT_NAMES_ARRAY
See Also:
Constant Field Values

CURRENT_TRANSLET_VERSION

public static final int CURRENT_TRANSLET_VERSION
See Also:
Constant Field Values

transletVersion

protected int transletVersion

namesArray

protected java.lang.String[] namesArray

urisArray

protected java.lang.String[] urisArray

typesArray

protected int[] typesArray

namespaceArray

protected java.lang.String[] namespaceArray

_templates

protected javax.xml.transform.Templates _templates

_hasIdCall

protected boolean _hasIdCall

stringValueHandler

protected StringValueHandler stringValueHandler

EMPTYSTRING

private static final java.lang.String EMPTYSTRING
See Also:
Constant Field Values

ID_INDEX_NAME

private static final java.lang.String ID_INDEX_NAME
See Also:
Constant Field Values

pbase

protected int pbase
Parameter handling


pframe

protected int pframe
Parameter handling


paramsStack

protected java.util.ArrayList paramsStack

_msgHandler

private MessageHandler _msgHandler
Message handling - implementation of


_formatSymbols

public Hashtable _formatSymbols
Decimal number format symbol handling


_keyIndexes

private Hashtable _keyIndexes
Index(es) for / key() / id()


_emptyKeyIndex

private KeyIndex _emptyKeyIndex

_indexSize

private int _indexSize

_currentRootForKeys

private int _currentRootForKeys

_domCache

private DOMCache _domCache
DOM cache handling


_auxClasses

private Hashtable _auxClasses

_domImplementation

protected org.w3c.dom.DOMImplementation _domImplementation
DOMImplementation caching for basis library

Constructor Detail

AbstractTranslet

public AbstractTranslet()
Method Detail

printInternalState

public void printInternalState()
Debugging


makeDOMAdapter

public final DOMAdapter makeDOMAdapter(DOM dom)
                                throws TransletException
Wrap the initial input DOM in a dom adapter. This adapter is wrapped in a DOM multiplexer if the document() function is used (handled by compiled code in the translet - see compiler/Stylesheet.compileTransform()).

Throws:
TransletException

pushParamFrame

public final void pushParamFrame()
Push a new parameter frame.


popParamFrame

public final void popParamFrame()
Pop the topmost parameter frame.


addParameter

public final java.lang.Object addParameter(java.lang.String name,
                                           java.lang.Object value)
Add a new global parameter if not already in the current frame. To setParameters of the form {http://foo.bar}xyz This needs to get mapped to an instance variable in the class The mapping created so that the global variables in the generated class become http$colon$$flash$$flash$foo$dot$bar$colon$xyz

Specified by:
addParameter in interface Translet

addParameter

public final java.lang.Object addParameter(java.lang.String name,
                                           java.lang.Object value,
                                           boolean isDefault)
Add a new global or local parameter if not already in the current frame. The 'isDefault' parameter is set to true if the value passed is the default value from the element's select attribute or element body.


clearParameters

public void clearParameters()
Clears the parameter stack.


getParameter

public final java.lang.Object getParameter(java.lang.String name)
Get the value of a parameter from the current frame or null if undefined.


setMessageHandler

public final void setMessageHandler(MessageHandler handler)
Set the translet's message handler - must implement MessageHandler


displayMessage

public final void displayMessage(java.lang.String msg)
Pass a message to the message handler - used by Message class.


addDecimalFormat

public void addDecimalFormat(java.lang.String name,
                             java.text.DecimalFormatSymbols symbols)
Adds a DecimalFormat object to the _formatSymbols hashtable. The entry is created with the input DecimalFormatSymbols.


getDecimalFormat

public final java.text.DecimalFormat getDecimalFormat(java.lang.String name)
Retrieves a named DecimalFormat object from _formatSymbols hashtable.


prepassDocument

public final void prepassDocument(DOM document)
Give the translet an opportunity to perform a prepass on the document to extract any information that it can store in an optimized form. Currently, it only extracts information about attributes of type ID.


buildIDIndex

private final void buildIDIndex(DOM document)
Leverages the Key Class to implement the XSLT id() function. buildIdIndex creates the index (##id) that Key Class uses. The index contains the element node index (int) and Id value (String).


postInitialization

public final void postInitialization()
After constructing the translet object, this method must be called to perform any version-specific post-initialization that's required.


setIndexSize

public void setIndexSize(int size)
This method is used to pass the largest DOM size to the translet. Needed to make sure that the translet can index the whole DOM.


createKeyIndex

public KeyIndex createKeyIndex()
Creates a KeyIndex object of the desired size - don't want to resize!!!


buildKeyIndex

public void buildKeyIndex(java.lang.String name,
                          int node,
                          java.lang.Object value)
Adds a value to a key/id index

Parameters:
name - is the name of the index (the key or ##id)
node - is the node handle of the node to insert
value - is the value that will look up the node in the given index

buildKeyIndex

public void buildKeyIndex(java.lang.String name,
                          DOM dom)
Create an empty KeyIndex in the DOM case

Parameters:
name - is the name of the index (the key or ##id)
dom - is the DOM

getKeyIndex

public KeyIndex getKeyIndex(java.lang.String name)
Returns the index for a given key (or id). The index implements our internal iterator interface


setRootForKeys

private void setRootForKeys(int root)

buildKeys

public void buildKeys(DOM document,
                      DTMAxisIterator iterator,
                      SerializationHandler handler,
                      int root)
               throws TransletException
This method builds key indexes - it is overridden in the compiled translet in cases where the element is used

Specified by:
buildKeys in interface Translet
Throws:
TransletException

setKeyIndexDom

public void setKeyIndexDom(java.lang.String name,
                           DOM document)
This method builds key indexes - it is overridden in the compiled translet in cases where the element is used


setDOMCache

public void setDOMCache(DOMCache cache)
Sets the DOM cache used for additional documents loaded using the document() function.


getDOMCache

public DOMCache getDOMCache()
Returns the DOM cache used for this translet. Used by the LoadDocument class (if present) when the document() function is used.


openOutputHandler

public SerializationHandler openOutputHandler(java.lang.String filename,
                                              boolean append)
                                       throws TransletException
Multiple output document extension. See compiler/TransletOutput for actual implementation.

Throws:
TransletException

openOutputHandler

public SerializationHandler openOutputHandler(java.lang.String filename)
                                       throws TransletException
Throws:
TransletException

closeOutputHandler

public void closeOutputHandler(SerializationHandler handler)

transform

public abstract void transform(DOM document,
                               DTMAxisIterator iterator,
                               SerializationHandler handler)
                        throws TransletException
Main transform() method - this is overridden by the compiled translet

Specified by:
transform in interface Translet
Throws:
TransletException

transform

public final void transform(DOM document,
                            SerializationHandler handler)
                     throws TransletException
Calls transform() with a given output handler

Specified by:
transform in interface Translet
Throws:
TransletException

characters

public final void characters(java.lang.String string,
                             SerializationHandler handler)
                      throws TransletException
Used by some compiled code as a shortcut for passing strings to the output handler

Throws:
TransletException

addCdataElement

public void addCdataElement(java.lang.String name)
Add's a name of an element whose text contents should be output as CDATA


transferOutputSettings

protected void transferOutputSettings(SerializationHandler handler)
Transfer the output settings to the output post-processor


addAuxiliaryClass

public void addAuxiliaryClass(java.lang.Class auxClass)
Specified by:
addAuxiliaryClass in interface Translet

setAuxiliaryClasses

public void setAuxiliaryClasses(Hashtable auxClasses)

getAuxiliaryClass

public java.lang.Class getAuxiliaryClass(java.lang.String className)
Specified by:
getAuxiliaryClass in interface Translet

getNamesArray

public java.lang.String[] getNamesArray()
Specified by:
getNamesArray in interface Translet

getUrisArray

public java.lang.String[] getUrisArray()
Specified by:
getUrisArray in interface Translet

getTypesArray

public int[] getTypesArray()
Specified by:
getTypesArray in interface Translet

getNamespaceArray

public java.lang.String[] getNamespaceArray()
Specified by:
getNamespaceArray in interface Translet

hasIdCall

public boolean hasIdCall()

getTemplates

public javax.xml.transform.Templates getTemplates()

setTemplates

public void setTemplates(javax.xml.transform.Templates templates)

newDocument

public org.w3c.dom.Document newDocument(java.lang.String uri,
                                        java.lang.String qname)
                                 throws javax.xml.parsers.ParserConfigurationException
Throws:
javax.xml.parsers.ParserConfigurationException