|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.ctc.wstx.sr.InputElementStack
com.ctc.wstx.sr.NsInputElementStack
public final class NsInputElementStack
Sub-class of InputElementStack used when operating in
namespace-aware mode.
Implementation note: this class reuses NamespaceContext
instances, so that consequtive accesses just return the same instance,
as long as nothing in bindings change. As a result, only those instances
that explicitly add new bindings create distinct non-shareable context
instances. Although it would also be possible to share underlying String
array to further improve object sharing, it seems like marginal gain
with more complexity: as such the current simple scheme should work
just fine (and is measure to be very close to optimal for most common
namespace-heavey document types like Soap messages).
| Field Summary | |
|---|---|
protected NsAttributeCollector |
mAttrCollector
|
protected String[] |
mElements
Array that contains path of open elements from root; for each there are 4 Strings; prefix, localname, URI, and default name space URI. |
protected String |
mLastLocalName
|
protected QName |
mLastName
|
protected BaseNsContext |
mLastNsContext
Last potentially shareable NamespaceContext created by this stack. |
protected String |
mLastNsURI
|
protected String |
mLastPrefix
|
protected boolean |
mMayHaveNsDefaults
|
protected StringVector |
mNamespaces
Vector that contains all currently active namespaces; one String for prefix, another for matching URI. |
protected int[] |
mNsCounts
Array that contains namespace offsets for each element; that is, index of first 'local' name space entry, entry declared for current element. |
protected NsDefaultProvider |
mNsDefaultProvider
Object that will need to be consulted about namespace bindings, since it has some knowledge about default namespace declarations (has default attribute value expansion). |
protected int |
mSize
Number of Strings in mElements that are valid (ie depth
multiplied by 4) |
protected static InternCache |
sInternCache
|
| Fields inherited from class com.ctc.wstx.sr.InputElementStack |
|---|
mConfig, mIdAttrIndex, mReporter, mValidator |
| Constructor Summary | |
|---|---|
NsInputElementStack(int initialSize,
ReaderConfig cfg)
|
|
| Method Summary | |
|---|---|
int |
addDefaultAttribute(String localName,
String uri,
String prefix,
String value)
Method called by actual validator instances when attributes with default values have no explicit values for the element; if so, default value needs to be added as if it was parsed from the element. |
void |
addNsBinding(String prefix,
String uri)
Callback method called by the namespace default provider. |
BaseNsContext |
createNonTransientNsContext(Location loc)
Method called to construct a non-transient NamespaceContext instance; generally needed when creating events to return from event-based iterators. |
int |
findAttributeIndex(String nsURI,
String localName)
|
AttributeCollector |
getAttrCollector()
Method called by BasicStreamReader, to retrieve the
attribute collector it needs for some direct access. |
int |
getAttributeCount()
This method returns number of attributes accessible from within currently active start element. |
QName |
getCurrentElementName()
Method that can be used to access name information of the innermost (top) element in the element stack. |
int |
getCurrentNsCount()
|
String |
getDefaultNsURI()
|
int |
getDepth()
|
String |
getLocalName()
|
String |
getLocalNsPrefix(int index)
|
String |
getLocalNsURI(int index)
|
String |
getNamespaceURI(String prefix)
Method that can be called by the validator to resolve a namespace prefix of the currently active top-level element. |
String |
getNsURI()
|
String |
getPrefix()
|
String |
getPrefix(String nsURI)
|
Iterator |
getPrefixes(String nsURI)
|
String |
getTopElementDesc()
|
int |
getTotalNsCount()
|
boolean |
isEmpty()
|
boolean |
isNamespaceAware()
|
boolean |
isPrefixLocallyDeclared(String internedPrefix)
|
boolean |
matches(String prefix,
String localName)
|
boolean |
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. |
void |
push(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. |
void |
push(String prefix,
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. |
int |
resolveAndValidateElement()
Method called to update information about top of the stack, with attribute information passed in. |
protected void |
setAutomaticDTDValidator(XMLValidator validator,
NsDefaultProvider nsDefs)
Method called to connect the automatically handled DTD validator (one detected from DOCTYPE, loaded and completely handled by the stream reader without application calling validation methods). |
int |
validateEndElement()
Method called after parsing (but before returning) end element, to allow for pluggable validators to verify correctness of the content model for the closing element. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final InternCache sInternCache
protected final NsAttributeCollector mAttrCollector
protected NsDefaultProvider mNsDefaultProvider
protected final StringVector mNamespaces
protected String[] mElements
protected int mSize
mElements that are valid (ie depth
multiplied by 4)
protected int[] mNsCounts
mCurrNsCount - mNsCounts[mSize-1]
protected boolean mMayHaveNsDefaults
protected String mLastLocalName
protected String mLastPrefix
protected String mLastNsURI
protected QName mLastName
protected BaseNsContext mLastNsContext
| Constructor Detail |
|---|
public NsInputElementStack(int initialSize,
ReaderConfig cfg)
| Method Detail |
|---|
protected void setAutomaticDTDValidator(XMLValidator validator,
NsDefaultProvider nsDefs)
InputElementStack
setAutomaticDTDValidator in class InputElementStack
public final void push(String prefix,
String localName)
InputElementStack
push in class InputElementStackpublic final void push(String fullName)
InputElementStack
push in class InputElementStack
public boolean pop()
throws XMLStreamException
InputElementStack
pop in class InputElementStackXMLStreamException
public int resolveAndValidateElement()
throws XMLStreamException
resolveAndValidateElement in class InputElementStackXMLStreamException
public int validateEndElement()
throws XMLStreamException
InputElementStack
validateEndElement in class InputElementStackXMLStreamExceptionpublic final AttributeCollector getAttrCollector()
InputElementStackBasicStreamReader, to retrieve the
attribute collector it needs for some direct access.
getAttrCollector in class InputElementStackpublic final BaseNsContext createNonTransientNsContext(Location loc)
createNonTransientNsContext in class InputElementStackpublic final String getNamespaceURI(String prefix)
ValidationContext
getNamespaceURI in interface NamespaceContextgetNamespaceURI in interface ValidationContextgetNamespaceURI in class InputElementStackpublic final String getPrefix(String nsURI)
getPrefix in interface NamespaceContextgetPrefix in class InputElementStackpublic final Iterator getPrefixes(String nsURI)
getPrefixes in interface NamespaceContextgetPrefixes in class InputElementStackpublic final int getAttributeCount()
ValidationContext
Note: this method is only guaranteed to be callable during execution
of XMLValidator methods
XMLValidator.validateElementStart(java.lang.String, java.lang.String, java.lang.String),
XMLValidator.validateAttribute(java.lang.String, java.lang.String, java.lang.String, java.lang.String) and
XMLValidator.validateElementAndAttributes(). At other times
implementations may choose to allow it to be called (for example,
with information regarding last start element processed), to throw
a IllegalArgumentException, or to return 0 to indicate no
attribute information is available.
Also note that whether defaulted attributes (attributes for which values are only available via attribute defaulting) are accessible depends on exact time when this method is called, and in general can not be assumed to function reliably.
getAttributeCount in interface AttributeInfogetAttributeCount in interface ValidationContextgetAttributeCount in class InputElementStack
public final int findAttributeIndex(String nsURI,
String localName)
findAttributeIndex in interface AttributeInfofindAttributeIndex in interface ValidationContextfindAttributeIndex in class InputElementStackpublic final QName getCurrentElementName()
ValidationContext
getCurrentElementName in interface ValidationContextgetCurrentElementName in class InputElementStack
public int addDefaultAttribute(String localName,
String uri,
String prefix,
String value)
InputElementStack
addDefaultAttribute in interface ValidationContextaddDefaultAttribute in class InputElementStackpublic boolean isPrefixLocallyDeclared(String internedPrefix)
isPrefixLocallyDeclared in class InputElementStack
public void addNsBinding(String prefix,
String uri)
addNsBinding in class InputElementStackpublic final boolean isNamespaceAware()
isNamespaceAware in class InputElementStackpublic final boolean isEmpty()
isEmpty in class InputElementStackpublic final int getDepth()
getDepth in class InputElementStackpublic final String getDefaultNsURI()
getDefaultNsURI in class InputElementStackpublic final String getNsURI()
getNsURI in class InputElementStackpublic final String getPrefix()
getPrefix in class InputElementStackpublic final String getLocalName()
getLocalName in class InputElementStack
public final boolean matches(String prefix,
String localName)
matches in class InputElementStackpublic final String getTopElementDesc()
getTopElementDesc in class InputElementStackpublic final int getTotalNsCount()
getTotalNsCount in class InputElementStackpublic final int getCurrentNsCount()
getCurrentNsCount in class InputElementStackpublic final String getLocalNsPrefix(int index)
getLocalNsPrefix in class InputElementStackpublic final String getLocalNsURI(int index)
getLocalNsURI in class InputElementStack
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||