ElemContextpublic final class ElemContext extends Object
(Omit source code)
Fields Summary |
---|
final int | m_currentElemDepthThe nesting depth of the element inside other elements. | ElemDesc | m_elementDescHTML field, the element description of the HTML element | String | m_elementLocalNameThe local name of the element. | String | m_elementNameThe fully qualified name of the element (with prefix, if any). | String | m_elementURIThe URI of the element. | boolean | m_isCdataSectionIf the element is in the cdata-section-names list
then the value is true. If it is true the text children of the element
should be output in CDATA section blocks. | boolean | m_isRawTrue if the current element has output escaping disabled.
This is true for SCRIPT and STYLE elements. | private ElemContext | m_nextThe next element "stack frame". This value will only be
set once as deeper stack frames are not deleted when popped off,
but are rather re-used when a push is required.
This makes for very fast pushing and popping of stack frames
because very few stack frame objects are ever created, they are
mostly re-used. This re-use saves object creation but it also means
that connections between the frames via m_next and m_prev
never changes either. Just the contents of the frames change
as they are re-used. Only the reference to the current stack frame, which
is held by the serializer is changed via a quick pop() or push(). | final ElemContext | m_prevThe previous element "stack frame". | boolean | m_startTagOpenSet to true when a start tag is started, or open, but not all the
attributes or namespace information is yet collected. |
Constructors Summary |
---|
ElemContext()Constructor to create the root of the element contexts.
// this assignment means can never pop this context off
m_prev = this;
// depth 0 because it doesn't correspond to any element
m_currentElemDepth = 0;
| private ElemContext(ElemContext previous)Constructor to create the "stack frame" for a given element depth.
This implementation will re-use the context at each depth. If
a documents deepest element depth is N then there will be (N+1)
such objects created, no more than that.
m_prev = previous;
m_currentElemDepth = previous.m_currentElemDepth + 1;
|
Methods Summary |
---|
final com.sun.org.apache.xml.internal.serializer.ElemContext | pop()Pop the current "stack frame".
/* a very simple pop. No clean up is done of the deeper
* stack frame. All deeper stack frames are still attached
* but dormant, just waiting to be re-used.
*/
return this.m_prev;
| final com.sun.org.apache.xml.internal.serializer.ElemContext | push()This method pushes an element "stack frame"
but with no initialization of values in that frame.
This method is used for optimization purposes, like when pushing
a stack frame for an HTML "IMG" tag which has no children and
the stack frame will almost immediately be popped.
ElemContext frame = this.m_next;
if (frame == null)
{
/* We have never been at this depth yet, and there is no
* stack frame to re-use, so we now make a new one.
*/
frame = new ElemContext(this);
this.m_next = frame;
}
/*
* We shouldn't need to set this true because we should just
* be pushing a dummy stack frame that will be instantly popped.
* Yet we need to be ready in case this element does have
* unexpected children.
*/
frame.m_startTagOpen = true;
return frame;
| final com.sun.org.apache.xml.internal.serializer.ElemContext | push(java.lang.String uri, java.lang.String localName, java.lang.String qName)Push an element context on the stack. This context keeps track of
information gathered about the element.
ElemContext frame = this.m_next;
if (frame == null)
{
/* We have never been at this depth yet, and there is no
* stack frame to re-use, so we now make a new one.
*/
frame = new ElemContext(this);
this.m_next = frame;
}
// Initialize, or reset values in the new or re-used stack frame.
frame.m_elementName = qName;
frame.m_elementLocalName = localName;
frame.m_elementURI = uri;
frame.m_isCdataSection = false;
frame.m_startTagOpen = true;
// is_Raw is already set in the HTML startElement() method
// frame.m_isRaw = false;
return frame;
|
|