com.ctc.wstx.sr
Class InputElementStack

java.lang.Object
  extended bycom.ctc.wstx.sr.InputElementStack
All Implemented Interfaces:
AttributeInfo, InputConfigFlags, javax.xml.namespace.NamespaceContext
Direct Known Subclasses:
NonNsInputElementStack, NsInputElementStack

public abstract class InputElementStack
extends java.lang.Object
implements AttributeInfo, javax.xml.namespace.NamespaceContext, InputConfigFlags

Shared base class that defines API stream reader uses to communicate with the element stack implementation, independent of whether it's operating in namespace-aware or non-namespace modes. Element stack class is used for storing nesting information about open elements, and for namespace-aware mode, also information about namespaces active (including default namespace), during parsing of XML input.

This class also implements NamespaceContext, since it has all the information necessary, so parser can just return element stack instance as necesary.


Field Summary
protected  InputProblemReporter mReporter
           
protected static java.lang.String UNKNOWN_ATTR_TYPE
          Constants used when no DTD handling is done, and we do not know the 'real' type of an attribute.
 
Fields inherited from interface com.ctc.wstx.cfg.InputConfigFlags
CFG_CACHE_DTDS, CFG_COALESCE_TEXT, CFG_INTERN_NS_URIS, CFG_LAZY_PARSING, CFG_NAMESPACE_AWARE, CFG_NORMALIZE_ATTR_VALUES, CFG_NORMALIZE_LFS, CFG_PRESERVE_LOCATION, CFG_REPLACE_ENTITY_REFS, CFG_REPORT_ALL_TEXT_AS_CHARACTERS, CFG_REPORT_PROLOG_WS, CFG_SUPPORT_DTD, CFG_SUPPORT_DTDPP, CFG_SUPPORT_EXTERNAL_ENTITIES, CFG_VALIDATE_AGAINST_DTD, CFG_VALIDATE_TEXT_CHARS, CONTENT_ALLOW_DTD_ANY, CONTENT_ALLOW_MIXED, CONTENT_ALLOW_NON_MIXED, CONTENT_ALLOW_NONE, CONTENT_ALLOW_UNDEFINED
 
Constructor Summary
protected InputElementStack()
           
 
Method Summary
 void connectReporter(InputProblemReporter rep)
           
abstract  BaseNsContext createNonTransientNsContext(javax.xml.stream.Location loc)
          Method called to construct a non-transient NamespaceContext instance; generally needed when creating events to return from event-based iterators.
abstract  int findAttributeIndex(java.lang.String nsURI, java.lang.String localName)
           
abstract  AttributeCollector getAttrCollector()
           
abstract  int getAttributeCount()
           
 java.lang.String getAttributeType(int index)
          Default implementation just returns the 'unknown' type; validating sub-classes need to override
abstract  int getCurrentNsCount()
           
abstract  java.lang.String getDefaultNsURI()
           
abstract  int getDepth()
           
 int getIdAttributeIndex()
          Default implementation just indicates it does not know of such attributes; this because that requires DTD information that only some implementations have.
abstract  java.lang.String getLocalName()
           
abstract  java.lang.String getLocalNsPrefix(int index)
           
abstract  java.lang.String getLocalNsURI(int index)
           
abstract  java.lang.String getNamespaceURI(java.lang.String prefix)
           
 int getNotationAttributeIndex()
          Default implementation just indicates it does not know of such attributes; this because that requires DTD information that only some implementations have.
abstract  java.lang.String getNsURI()
           
abstract  java.lang.String getPrefix()
           
abstract  java.lang.String getPrefix(java.lang.String nsURI)
           
abstract  java.util.Iterator getPrefixes(java.lang.String nsURI)
           
abstract  javax.xml.namespace.QName getQName()
           
abstract  java.lang.String getTopElementDesc()
           
abstract  int getTotalNsCount()
           
abstract  boolean isEmpty()
           
abstract  boolean isNamespaceAware()
           
abstract  boolean matches(java.lang.String prefix, java.lang.String localName)
           
abstract  int pop()
          Method called by the stream reader to remove the topmost (start) element from the stack; called when an end element is encountered during parsing.
abstract  void push(java.lang.String fullName)
          Method called by the stream reader to add new (start) element into the stack in non-namespace mode; called when a start element is encountered during parsing, but only in non-namespace mode.
abstract  void push(java.lang.String prefix, java.lang.String localName)
          Method called by the stream reader to add new (start) element into the stack in namespace-aware mode; called when a start element is encountered during parsing, but only in ns-aware mode.
abstract  int resolveElem(boolean internNsURIs)
          Method called to update information about top of the stack, with attribute information passed in.
 void setElementSpecs(java.util.Map elemSpecs, SymbolTable symbols, boolean normAttrs, java.util.Map generalEntities)
          Stub implementation for method that specialized sub-classes use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNKNOWN_ATTR_TYPE

protected static final java.lang.String UNKNOWN_ATTR_TYPE
Constants used when no DTD handling is done, and we do not know the 'real' type of an attribute. Seems like CDATA is the safe choice.

See Also:
Constant Field Values

mReporter

protected InputProblemReporter mReporter
Constructor Detail

InputElementStack

protected InputElementStack()
Method Detail

connectReporter

public void connectReporter(InputProblemReporter rep)

setElementSpecs

public void setElementSpecs(java.util.Map elemSpecs,
                            SymbolTable symbols,
                            boolean normAttrs,
                            java.util.Map generalEntities)
Stub implementation for method that specialized sub-classes use. Default implementation is fine for non-validating stacks.


getAttrCollector

public abstract AttributeCollector getAttrCollector()

createNonTransientNsContext

public abstract BaseNsContext createNonTransientNsContext(javax.xml.stream.Location loc)
Method called to construct a non-transient NamespaceContext instance; generally needed when creating events to return from event-based iterators.


push

public abstract void push(java.lang.String prefix,
                          java.lang.String localName)
Method called by the stream reader to add new (start) element into the stack in namespace-aware mode; called when a start element is encountered during parsing, but only in ns-aware mode.


push

public abstract void push(java.lang.String fullName)
Method called by the stream reader to add new (start) element into the stack in non-namespace mode; called when a start element is encountered during parsing, but only in non-namespace mode.


pop

public abstract int pop()
                 throws WstxException
Method called by the stream reader to remove the topmost (start) element from the stack; called when an end element is encountered during parsing.

Returns:
Validation state that should be effective for the parent element state
Throws:
WstxException

resolveElem

public abstract int resolveElem(boolean internNsURIs)
                         throws WstxException
Method called to update information about top of the stack, with attribute information passed in. In namespace aware mode, will resolve namespace mapping.

Returns:
Validation state that should be effective for the fully resolved element context
Throws:
WstxException

getAttributeCount

public abstract int getAttributeCount()
Specified by:
getAttributeCount in interface AttributeInfo
Returns:
Number of all attributes accessible (including ones created from the default values, if any) using this Object.

findAttributeIndex

public abstract int findAttributeIndex(java.lang.String nsURI,
                                       java.lang.String localName)
Specified by:
findAttributeIndex in interface AttributeInfo
Returns:
Index of the specified attribute, if the current element has such an attribute (explicit, or one created via default value expansion); -1 if not.

getIdAttributeIndex

public int getIdAttributeIndex()
Default implementation just indicates it does not know of such attributes; this because that requires DTD information that only some implementations have.

Specified by:
getIdAttributeIndex in interface AttributeInfo
Returns:
Index of the ID attribute of current element, if the current element has such an attribute defined; -1 if not.

getNotationAttributeIndex

public int getNotationAttributeIndex()
Default implementation just indicates it does not know of such attributes; this because that requires DTD information that only some implementations have.

Specified by:
getNotationAttributeIndex in interface AttributeInfo
Returns:
Index of the NOTATION attribute of current element, if the current element has such an attribute defined; -1 if not.

getNamespaceURI

public abstract java.lang.String getNamespaceURI(java.lang.String prefix)
Specified by:
getNamespaceURI in interface javax.xml.namespace.NamespaceContext

getPrefix

public abstract java.lang.String getPrefix(java.lang.String nsURI)
Specified by:
getPrefix in interface javax.xml.namespace.NamespaceContext

getPrefixes

public abstract java.util.Iterator getPrefixes(java.lang.String nsURI)
Specified by:
getPrefixes in interface javax.xml.namespace.NamespaceContext

isNamespaceAware

public abstract boolean isNamespaceAware()

getDepth

public abstract int getDepth()
Returns:
Number of open elements in the stack; 0 when parser is in prolog/epilog, 1 inside root element and so on.

isEmpty

public abstract boolean isEmpty()

getDefaultNsURI

public abstract java.lang.String getDefaultNsURI()

getNsURI

public abstract java.lang.String getNsURI()

getPrefix

public abstract java.lang.String getPrefix()

getLocalName

public abstract java.lang.String getLocalName()

getQName

public abstract javax.xml.namespace.QName getQName()

matches

public abstract boolean matches(java.lang.String prefix,
                                java.lang.String localName)

getTopElementDesc

public abstract java.lang.String getTopElementDesc()

getTotalNsCount

public abstract int getTotalNsCount()

getCurrentNsCount

public abstract int getCurrentNsCount()
Returns:
Number of active prefix/namespace mappings for current scope, NOT including mappings from enclosing elements.

getLocalNsPrefix

public abstract java.lang.String getLocalNsPrefix(int index)

getLocalNsURI

public abstract java.lang.String getLocalNsURI(int index)

getAttributeType

public java.lang.String getAttributeType(int index)
Default implementation just returns the 'unknown' type; validating sub-classes need to override