com.ctc.wstx.sr
Class NonNsAttributeCollector

java.lang.Object
  extended by com.ctc.wstx.sr.AttributeCollector
      extended by com.ctc.wstx.sr.NonNsAttributeCollector

public final class NonNsAttributeCollector
extends AttributeCollector

Attribute collector class used in non-namespace parsing mode; much simpler than the one that has to handle namespaces.

Note: only public for testing purposes


Field Summary
protected static java.lang.String DEFAULT_NS_URI
          Default URI that is returned in non-namespace mode for all elements and attributes
protected static java.lang.String DEFAULT_PREFIX
           
 
Fields inherited from class com.ctc.wstx.sr.AttributeCollector
EXP_ATTR_COUNT, LONG_ATTR_LIST_LEN, mAttrCount, mAttrHashSize, mAttrMap, mAttrNames, mAttrSpillEnd, mAttrValues, mNonDefCount, mValueBuffer, mXmlIdAttrIndex, XMLID_IX_DISABLED, XMLID_IX_NONE
 
Constructor Summary
NonNsAttributeCollector(ReaderConfig cfg)
           
 
Method Summary
 int addDefaultAttribute(java.lang.String localName, java.lang.String value)
          Method called by validator to insert an attribute that has a default value and wasn't yet included in collector's attribute set.
 ElemAttrs buildAttrOb()
          Method needed by event creating code, to build a non-transient attribute container, to use with XMLEvent objects (specifically implementation of StartElement event).
 int findIndex(java.lang.String localName)
           
 TextBuilder getAttrBuilder(java.lang.String attrPrefix, java.lang.String attrLocalName)
           
 TextBuilder getDefaultNsBuilder()
           
 java.lang.String getLocalName(int index)
           
 TextBuilder getNsBuilder(java.lang.String localName)
           
 int getNsCount()
           
 java.lang.String getNsPrefix(int index)
           
 java.lang.String getNsURI(int index)
           
 TextBuilder getNsURIs()
           
 java.lang.String getPrefix(int index)
           
 javax.xml.namespace.QName getQName(int index)
           
 java.lang.String getURI(int index)
           
 java.lang.String getValue(java.lang.String nsURI, java.lang.String localName)
           
 void reset()
          Method called to allow reusing of collector, usually right before starting collecting attributes for a new start tag.
 int resolveValues(InputProblemReporter rep)
          Method called to by the input element stack when all attributes for the element have been parsed.
 void writeAttribute(int index, XmlWriter xw)
          Method that basically serializes the specified (read-in) attribute using Writers provided
 
Methods inherited from class com.ctc.wstx.sr.AttributeCollector
allocBuffers, getAttrBuilder, getCount, getNameList, getSpecifiedCount, getValue, getXmlIdAttrIndex, isSpecified, resize, setNormalizedValue, throwDupAttr, throwIndex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_NS_URI

protected static final java.lang.String DEFAULT_NS_URI
Default URI that is returned in non-namespace mode for all elements and attributes


DEFAULT_PREFIX

protected static final java.lang.String DEFAULT_PREFIX
Constructor Detail

NonNsAttributeCollector

public NonNsAttributeCollector(ReaderConfig cfg)
Method Detail

reset

public void reset()
Method called to allow reusing of collector, usually right before starting collecting attributes for a new start tag.

Specified by:
reset in class AttributeCollector

resolveValues

public int resolveValues(InputProblemReporter rep)
                  throws WstxException
Method called to by the input element stack when all attributes for the element have been parsed. Now collector can build data structures it needs, if any.

Returns:
Index of xml:id attribute, if any, -1 if not
Throws:
WstxException

getNsCount

public int getNsCount()
Specified by:
getNsCount in class AttributeCollector
Returns:
Number of namespace declarations collected, including possible default namespace declaration

getNsPrefix

public java.lang.String getNsPrefix(int index)
Specified by:
getNsPrefix in class AttributeCollector

getNsURI

public java.lang.String getNsURI(int index)
Specified by:
getNsURI in class AttributeCollector

getPrefix

public java.lang.String getPrefix(int index)
Specified by:
getPrefix in class AttributeCollector

getLocalName

public java.lang.String getLocalName(int index)
Specified by:
getLocalName in class AttributeCollector

getURI

public java.lang.String getURI(int index)
Specified by:
getURI in class AttributeCollector

getQName

public javax.xml.namespace.QName getQName(int index)
Specified by:
getQName in class AttributeCollector

getValue

public java.lang.String getValue(java.lang.String nsURI,
                                 java.lang.String localName)
Specified by:
getValue in class AttributeCollector

findIndex

public int findIndex(java.lang.String localName)

getDefaultNsBuilder

public TextBuilder getDefaultNsBuilder()
Specified by:
getDefaultNsBuilder in class AttributeCollector

getNsBuilder

public TextBuilder getNsBuilder(java.lang.String localName)
Specified by:
getNsBuilder in class AttributeCollector
Returns:
null if prefix has been already declared; TextBuilder to add value to if not.

getAttrBuilder

public TextBuilder getAttrBuilder(java.lang.String attrPrefix,
                                  java.lang.String attrLocalName)
Specified by:
getAttrBuilder in class AttributeCollector

getNsURIs

public TextBuilder getNsURIs()

buildAttrOb

public ElemAttrs buildAttrOb()
Method needed by event creating code, to build a non-transient attribute container, to use with XMLEvent objects (specifically implementation of StartElement event).

Specified by:
buildAttrOb in class AttributeCollector

addDefaultAttribute

public int addDefaultAttribute(java.lang.String localName,
                               java.lang.String value)
Method called by validator to insert an attribute that has a default value and wasn't yet included in collector's attribute set.

Returns:
Index of the newly added attribute, if added; -1 to indicate this was a duplicate

writeAttribute

public void writeAttribute(int index,
                           XmlWriter xw)
                    throws java.io.IOException,
                           javax.xml.stream.XMLStreamException
Method that basically serializes the specified (read-in) attribute using Writers provided

Specified by:
writeAttribute in class AttributeCollector
Throws:
java.io.IOException
javax.xml.stream.XMLStreamException