|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.xml.dtm.ref.DTMDefaultBase org.apache.xml.dtm.ref.DTMDefaultBaseTraversers org.apache.xml.dtm.ref.DTMDefaultBaseIterators org.apache.xml.dtm.ref.sax2dtm.SAX2DTM org.apache.xml.dtm.ref.sax2dtm.SAX2DTM2
public class SAX2DTM2
SAX2DTM2 is an optimized version of SAX2DTM which is used in non-incremental situation. It is used as the super class of the XSLTC SAXImpl. Many of the interfaces in SAX2DTM and DTMDefaultBase are overridden in SAX2DTM2 in order to allow fast, efficient access to the DTM model. Some nested iterators in DTMDefaultBaseIterators are also overridden in SAX2DTM2 for performance reasons.
Performance is the biggest consideration in the design of SAX2DTM2. To make the code most efficient, the incremental support is dropped in SAX2DTM2, which means that you should not use it in incremental situation. To reduce the overhead of pulling data from the DTM model, a few core interfaces in SAX2DTM2 have direct access to the internal arrays of the SuballocatedIntVectors.
The design of SAX2DTM2 may limit its extensibilty. If you have a reason to extend the SAX2DTM model, please extend from SAX2DTM instead of this class.
TODO: This class is currently only used by XSLTC. We need to investigate the possibility of also using it in Xalan-J Interpretive. Xalan's performance is likely to get an instant boost if we use SAX2DTM2 instead of SAX2DTM in non-incremental case.
%MK% The code in this class is critical to the XSLTC_DTM performance. Be very careful when making changes here!
Nested Class Summary | |
---|---|
class |
SAX2DTM2.AncestorIterator
Iterator that returns the ancestors of a given node in document order. |
class |
SAX2DTM2.AttributeIterator
Iterator that returns attribute nodes (of what nodes?) |
class |
SAX2DTM2.ChildrenIterator
Iterator that returns all immediate children of a given node |
class |
SAX2DTM2.DescendantIterator
Iterator that returns the descendants of a given node. |
class |
SAX2DTM2.FollowingIterator
Iterator that returns following nodes of for a given node. |
class |
SAX2DTM2.FollowingSiblingIterator
Iterator that returns all siblings of a given node. |
class |
SAX2DTM2.ParentIterator
Iterator that returns the parent of a given node. |
class |
SAX2DTM2.PrecedingIterator
Iterator that returns preceding nodes of a given node. |
class |
SAX2DTM2.PrecedingSiblingIterator
Iterator that returns preceding siblings of a given node |
class |
SAX2DTM2.TypedAncestorIterator
Typed iterator that returns the ancestors of a given node. |
class |
SAX2DTM2.TypedAttributeIterator
Iterator that returns attribute nodes of a given type |
class |
SAX2DTM2.TypedChildrenIterator
Iterator that returns children of a given type for a given node. |
class |
SAX2DTM2.TypedDescendantIterator
Typed iterator that returns the descendants of a given node. |
class |
SAX2DTM2.TypedFollowingIterator
Iterator that returns following nodes of a given type for a given node. |
class |
SAX2DTM2.TypedFollowingSiblingIterator
Iterator that returns all following siblings of a given node. |
class |
SAX2DTM2.TypedPrecedingIterator
Iterator that returns preceding nodes of agiven type for a given node. |
class |
SAX2DTM2.TypedPrecedingSiblingIterator
Iterator that returns preceding siblings of a given type for a given node |
class |
SAX2DTM2.TypedRootIterator
Iterator that returns the namespace nodes as defined by the XPath data model for a given node, filtered by extended type ID. |
class |
SAX2DTM2.TypedSingletonIterator
Iterator that returns a given node only if it is of a given type. |
Field Summary | |
---|---|
private static java.lang.String |
EMPTY_STR
|
private static XMLString |
EMPTY_XML_STR
|
protected int |
m_blocksize
|
protected boolean |
m_buildIdIndex
|
private int[][] |
m_exptype_map
|
private int[] |
m_exptype_map0
End of nested iterators |
protected ExtendedType[] |
m_extendedTypes
|
private int[][] |
m_firstch_map
|
private int[] |
m_firstch_map0
|
protected int |
m_MASK
|
private int |
m_maxNodeIndex
|
private int[][] |
m_nextsib_map
|
private int[] |
m_nextsib_map0
|
private int[][] |
m_parent_map
|
private int[] |
m_parent_map0
|
protected int |
m_SHIFT
|
private int |
m_valueIndex
|
protected java.util.Vector |
m_values
|
protected static int |
TEXT_LENGTH_BITS
%OPT% If the offset and length of a Text node are within certain limits, we store a bitwise encoded value into an int, using 10 bits (max. |
protected static int |
TEXT_LENGTH_MAX
|
protected static int |
TEXT_OFFSET_BITS
|
protected static int |
TEXT_OFFSET_MAX
|
Fields inherited from class org.apache.xml.dtm.ref.sax2dtm.SAX2DTM |
---|
m_chars, m_coalescedTextType, m_contextIndexes, m_data, m_dataOrQName, m_endDocumentOccured, m_idAttributes, m_insideDTD, m_locator, m_parents, m_pastFirstElement, m_prefixMappings, m_previous, m_sourceColumn, m_sourceLine, m_sourceSystemId, m_textPendingStart, m_textType, m_useSourceLocationProperty, m_valuesOrPrefixes, m_walker |
Fields inherited from class org.apache.xml.dtm.ref.DTMDefaultBase |
---|
DEFAULT_BLOCKSIZE, DEFAULT_NUMBLOCKS, DEFAULT_NUMBLOCKS_SMALL, m_documentBaseURI, m_dtmIdent, m_elemIndexes, m_expandedNameTable, m_exptype, m_firstch, m_indexing, m_mgr, m_mgrDefault, m_namespaceDeclSetElements, m_namespaceDeclSets, m_nextsib, m_parent, m_prevsib, m_shouldStripWhitespaceStack, m_shouldStripWS, m_size, m_traversers, m_wsfilter, m_xstrf, NOTPROCESSED, ROOTNODE |
Fields inherited from interface org.apache.xml.dtm.DTM |
---|
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NAMESPACE_NODE, NOTATION_NODE, NTYPES, NULL, PROCESSING_INSTRUCTION_NODE, ROOT_NODE, TEXT_NODE |
Constructor Summary | |
---|---|
SAX2DTM2(DTMManager mgr,
javax.xml.transform.Source source,
int dtmIdentity,
DTMWSFilter whiteSpaceFilter,
XMLStringFactory xstringfactory,
boolean doIndexing)
Construct a SAX2DTM2 object using the default block size. |
|
SAX2DTM2(DTMManager mgr,
javax.xml.transform.Source source,
int dtmIdentity,
DTMWSFilter whiteSpaceFilter,
XMLStringFactory xstringfactory,
boolean doIndexing,
int blocksize,
boolean usePrevsib,
boolean buildIdIndex,
boolean newNameTable)
Construct a SAX2DTM2 object using the given block size. |
Method Summary | |
---|---|
int |
_exptype(int identity)
Override DTMDefaultBase._exptype() by dropping the incremental code. |
int |
_exptype2(int identity)
The optimized version of DTMDefaultBase._exptype(). |
int |
_exptype2Type(int exptype)
Return the node type from the expanded type |
int |
_firstch2(int identity)
The optimized version of DTMDefaultBase._firstch(). |
int |
_nextsib2(int identity)
The optimized version of DTMDefaultBase._nextsib(). |
int |
_parent2(int identity)
The optimized version of DTMDefaultBase._parent(). |
int |
_type2(int identity)
The optimized version of DTMDefaultBase._type(). |
protected int |
addNode(int type,
int expandedTypeID,
int parentIndex,
int previousSibling,
int dataOrPrefix,
boolean canHaveFirstChild)
Construct the node map from the node. |
protected void |
charactersFlush()
Check whether accumulated text should be stripped; if not, append the appropriate flavor of text/cdata node. |
void |
comment(char[] ch,
int start,
int length)
Report an XML comment anywhere in the document. |
protected void |
copyAttribute(int nodeID,
int exptype,
SerializationHandler handler)
Copy an Attribute node to a SerializationHandler |
protected void |
copyAttributes(int nodeID,
SerializationHandler handler)
Copy attribute nodes from an element . |
protected java.lang.String |
copyElement(int nodeID,
int exptype,
SerializationHandler handler)
Copy an Element node to a SerializationHandler. |
protected void |
copyNS(int nodeID,
SerializationHandler handler,
boolean inScope)
Copy namespace nodes. |
protected void |
copyTextNode(int nodeID,
SerializationHandler handler)
Copy the String value of a Text node to a SerializationHandler |
void |
dispatchCharactersEvents(int nodeHandle,
org.xml.sax.ContentHandler ch,
boolean normalize)
The optimized version of SAX2DTM.dispatchCharactersEvents(int, ContentHandler, boolean). |
void |
endDocument()
Receive notification of the end of the document. |
void |
endElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName)
Receive notification of the end of an element. |
int |
getExpandedTypeID2(int nodeHandle)
The optimized version of DTMDefaultBase.getExpandedTypeID(int). |
int |
getFirstAttribute(int nodeHandle)
The optimized version of DTMDefaultBase.getFirstAttribute(). |
protected int |
getFirstAttributeIdentity(int identity)
The optimized version of DTMDefaultBase.getFirstAttributeIdentity(int). |
int |
getIdForNamespace(java.lang.String uri)
Get a prefix either from the uri mapping, or just make one up! |
java.lang.String |
getLocalName(int nodeHandle)
Override SAX2DTM.getLocalName() in SAX2DTM2. |
protected int |
getNextAttributeIdentity(int identity)
The optimized version of DTMDefaultBase.getNextAttributeIdentity(int). |
protected int |
getNextNamespaceNode2(int baseID)
Return the next namespace node following the given base node. |
java.lang.String |
getNodeName(int nodeHandle)
The optimized version of SAX2DTM.getNodeName(). |
java.lang.String |
getNodeNameX(int nodeHandle)
The optimized version of SAX2DTM.getNodeNameX(). |
java.lang.String |
getNodeValue(int nodeHandle)
Given a node handle, return its node value. |
java.lang.String |
getStringValue()
Returns the string value of the entire tree |
XMLString |
getStringValue(int nodeHandle)
Override SAX2DTM.getStringValue(int) |
java.lang.String |
getStringValueX(int nodeHandle)
The optimized version of SAX2DTM.getStringValue(int). |
protected int |
getTypedAttribute(int nodeHandle,
int attType)
The optimized version of DTMDefaultBase.getTypedAttribute(int, int). |
void |
processingInstruction(java.lang.String target,
java.lang.String data)
Override the processingInstruction() interface in SAX2DTM2. |
void |
startDocument()
Receive notification of the beginning of the document. |
void |
startElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName,
org.xml.sax.Attributes attributes)
Override SAX2DTM.startElement() |
Methods inherited from class org.apache.xml.dtm.ref.DTMDefaultBaseIterators |
---|
getAxisIterator, getTypedAxisIterator |
Methods inherited from class org.apache.xml.dtm.ref.DTMDefaultBaseTraversers |
---|
getAxisTraverser |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private int[] m_exptype_map0
private int[] m_nextsib_map0
private int[] m_firstch_map0
private int[] m_parent_map0
private int[][] m_exptype_map
private int[][] m_nextsib_map
private int[][] m_firstch_map
private int[][] m_parent_map
protected ExtendedType[] m_extendedTypes
protected java.util.Vector m_values
private int m_valueIndex
private int m_maxNodeIndex
protected int m_SHIFT
protected int m_MASK
protected int m_blocksize
protected static final int TEXT_LENGTH_BITS
protected static final int TEXT_OFFSET_BITS
protected static final int TEXT_LENGTH_MAX
protected static final int TEXT_OFFSET_MAX
protected boolean m_buildIdIndex
private static final java.lang.String EMPTY_STR
private static final XMLString EMPTY_XML_STR
Constructor Detail |
---|
public SAX2DTM2(DTMManager mgr, javax.xml.transform.Source source, int dtmIdentity, DTMWSFilter whiteSpaceFilter, XMLStringFactory xstringfactory, boolean doIndexing)
public SAX2DTM2(DTMManager mgr, javax.xml.transform.Source source, int dtmIdentity, DTMWSFilter whiteSpaceFilter, XMLStringFactory xstringfactory, boolean doIndexing, int blocksize, boolean usePrevsib, boolean buildIdIndex, boolean newNameTable)
Method Detail |
---|
public final int _exptype(int identity)
This one is less efficient than _exptype2. It is only used during DTM building. _exptype2 is used after the document is fully built.
_exptype
in class DTMDefaultBase
identity
- The node identity.
public final int _exptype2(int identity)
identity
- A node identity, which must not be equal to
DTM.NULL
public final int _nextsib2(int identity)
identity
- A node identity, which must not be equal to
DTM.NULL
public final int _firstch2(int identity)
identity
- A node identity, which must not be equal to
DTM.NULL
public final int _parent2(int identity)
identity
- A node identity, which must not be equal to
DTM.NULL
public final int _type2(int identity)
identity
- A node identity, which must not be equal to
DTM.NULL
public final int getExpandedTypeID2(int nodeHandle)
This one is only used by DOMAdapter.getExpandedTypeID(int), which is mostly called from the compiled translets.
public final int _exptype2Type(int exptype)
public int getIdForNamespace(java.lang.String uri)
getIdForNamespace
in class SAX2DTM
uri
- The namespace URI, which may be null.
public void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes) throws org.xml.sax.SAXException
Receive notification of the start of an element.
By default, do nothing. Application writers may override this method in a subclass to take specific actions at the start of each element (such as allocating a new tree node or writing output to a file).
startElement
in interface org.xml.sax.ContentHandler
startElement
in class SAX2DTM
uri
- The Namespace URI, or the empty string if the
element has no Namespace URI or if Namespace
processing is not being performed.localName
- The local name (without prefix), or the
empty string if Namespace processing is not being
performed.qName
- The qualified name (with prefix), or the
empty string if qualified names are not available.attributes
- The specified or defaulted attributes.
org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
public void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXException
By default, do nothing. Application writers may override this method in a subclass to take specific actions at the end of each element (such as finalising a tree node or writing output to a file).
endElement
in interface org.xml.sax.ContentHandler
endElement
in class SAX2DTM
uri
- The Namespace URI, or the empty string if the
element has no Namespace URI or if Namespace
processing is not being performed.localName
- The local name (without prefix), or the
empty string if Namespace processing is not being
performed.qName
- The qualified XML 1.0 name (with prefix), or the
empty string if qualified names are not available.
org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)
public void comment(char[] ch, int start, int length) throws org.xml.sax.SAXException
This callback will be used for comments inside or outside the document element, including comments in the external DTD subset (if read).
comment
in interface org.xml.sax.ext.LexicalHandler
comment
in class SAX2DTM
ch
- An array holding the characters in the comment.start
- The starting position in the array.length
- The number of characters to use from the array.
org.xml.sax.SAXException
- The application may raise an exception.public void startDocument() throws org.xml.sax.SAXException
startDocument
in interface org.xml.sax.ContentHandler
startDocument
in class SAX2DTM
org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.ContentHandler.startDocument()
public void endDocument() throws org.xml.sax.SAXException
endDocument
in interface org.xml.sax.ContentHandler
endDocument
in class SAX2DTM
org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.ContentHandler.endDocument()
protected final int addNode(int type, int expandedTypeID, int parentIndex, int previousSibling, int dataOrPrefix, boolean canHaveFirstChild)
addNode
in class SAX2DTM
type
- raw type ID, one of DTM.XXX_NODE.expandedTypeID
- The expended type ID.parentIndex
- The current parent index.previousSibling
- The previous sibling index.dataOrPrefix
- index into m_data table, or string handle.canHaveFirstChild
- true if the node can have a first child, false
if it is atomic.
protected final void charactersFlush()
charactersFlush
in class SAX2DTM
public void processingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXException
%OPT% This one is different from SAX2DTM.processingInstruction() in that we do not use extended types for PI nodes. The name of the PI is saved in the DTMStringPool. Receive notification of a processing instruction.
processingInstruction
in interface org.xml.sax.ContentHandler
processingInstruction
in class SAX2DTM
target
- The processing instruction target.data
- The processing instruction data, or null if
none is supplied.
org.xml.sax.SAXException
- Any SAX exception, possibly
wrapping another exception.ContentHandler.processingInstruction(java.lang.String, java.lang.String)
public final int getFirstAttribute(int nodeHandle)
Given a node handle, get the index of the node's first attribute.
getFirstAttribute
in interface DTM
getFirstAttribute
in class DTMDefaultBase
nodeHandle
- int Handle of the node.
protected int getFirstAttributeIdentity(int identity)
Given a node identity, get the index of the node's first attribute.
getFirstAttributeIdentity
in class DTMDefaultBase
identity
- int identity of the node.
protected int getNextAttributeIdentity(int identity)
Given a node identity for an attribute, advance to the next attribute.
getNextAttributeIdentity
in class DTMDefaultBase
identity
- int identity of the attribute node. This
must be an attribute node.
protected final int getTypedAttribute(int nodeHandle, int attType)
Given a node handle and an expanded type ID, get the index of the node's attribute of that type, if any.
getTypedAttribute
in class DTMDefaultBase
nodeHandle
- int Handle of the node.attType
- int expanded type ID of the required attribute.
public java.lang.String getLocalName(int nodeHandle)
Processing for PIs is different. Given a node handle, return its XPath- style localname. (As defined in Namespaces, this is the portion of the name after any colon character).
getLocalName
in interface DTM
getLocalName
in class SAX2DTM
nodeHandle
- the id of the node.
public final java.lang.String getNodeNameX(int nodeHandle)
Given a node handle, return the XPath node name. This should be the name as described by the XPath data model, NOT the DOM- style name.
getNodeNameX
in interface DTM
getNodeNameX
in class SAX2DTM
nodeHandle
- the id of the node.
public java.lang.String getNodeName(int nodeHandle)
Given a node handle, return its DOM-style node name. This will include names such as #text or #document.
getNodeName
in interface DTM
getNodeName
in class SAX2DTM
nodeHandle
- the id of the node.
public XMLString getStringValue(int nodeHandle)
This method is only used by Xalan-J Interpretive. It is not used by XSLTC.
If the caller supplies an XMLStringFactory, the getStringValue() interface in SAX2DTM will be called. Otherwise just calls getStringValueX() and wraps the returned String in an XMLString. Get the string-value of a node as a String object (see http://www.w3.org/TR/xpath#data-model for the definition of a node's string-value).
getStringValue
in interface DTM
getStringValue
in class SAX2DTM
nodeHandle
- The node ID.
public final java.lang.String getStringValueX(int nodeHandle)
%OPT% This is one of the most often used interfaces. Performance is critical here. This one is different from SAX2DTM.getStringValue(int) in that it returns a String instead of a XMLString. Get the string- value of a node as a String object (see http: //www. w3. org/TR/xpath#data- model for the definition of a node's string- value).
nodeHandle
- The node ID.
public java.lang.String getStringValue()
public final void dispatchCharactersEvents(int nodeHandle, org.xml.sax.ContentHandler ch, boolean normalize) throws org.xml.sax.SAXException
Directly call the characters method on the passed ContentHandler for the string-value of the given node (see http://www.w3.org/TR/xpath#data-model for the definition of a node's string-value). Multiple calls to the ContentHandler's characters methods may well occur for a single call to this method.
dispatchCharactersEvents
in interface DTM
dispatchCharactersEvents
in class SAX2DTM
nodeHandle
- The node ID.ch
- A non-null reference to a ContentHandler.normalize
- true if the content should be normalized according to
the rules for the XPath
normalize-space
function.
org.xml.sax.SAXException
public java.lang.String getNodeValue(int nodeHandle)
getNodeValue
in interface DTM
getNodeValue
in class SAX2DTM
nodeHandle
- The node id.
protected final void copyTextNode(int nodeID, SerializationHandler handler) throws org.xml.sax.SAXException
org.xml.sax.SAXException
protected final java.lang.String copyElement(int nodeID, int exptype, SerializationHandler handler) throws org.xml.sax.SAXException
nodeID
- The node identityexptype
- The expanded type of the Element nodehandler
- The SerializationHandler
org.xml.sax.SAXException
protected final void copyNS(int nodeID, SerializationHandler handler, boolean inScope) throws org.xml.sax.SAXException
nodeID
- The Element node identityhandler
- The SerializationHandlerinScope
- true if all namespaces in scope should be copied,
false if only the namespace declarations should be copied.
org.xml.sax.SAXException
protected final int getNextNamespaceNode2(int baseID)
protected final void copyAttributes(int nodeID, SerializationHandler handler) throws org.xml.sax.SAXException
nodeID
- The Element node identityhandler
- The SerializationHandler
org.xml.sax.SAXException
protected final void copyAttribute(int nodeID, int exptype, SerializationHandler handler) throws org.xml.sax.SAXException
nodeID
- The node identityexptype
- The expanded type of the Element nodehandler
- The SerializationHandler
org.xml.sax.SAXException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |