org.apache.commons.betwixt.io
Class AbstractBeanWriter.ElementAttributes

java.lang.Object
  extended byorg.apache.commons.betwixt.io.AbstractBeanWriter.ElementAttributes
All Implemented Interfaces:
org.xml.sax.Attributes
Direct Known Subclasses:
AbstractBeanWriter.IDElementAttributes
Enclosing class:
AbstractBeanWriter

private class AbstractBeanWriter.ElementAttributes
extends java.lang.Object
implements org.xml.sax.Attributes

Attributes backed by attribute descriptors. ID/IDREFs not set.


Field Summary
private  AttributeDescriptor[] attributes
          Attribute descriptors backing the Attributes
private  Context context
          Context to be evaluated when finding values
private  int length
          The number of unsuppressed attributes
private  java.lang.String[] values
          Cached attribute values
 
Constructor Summary
(package private) AbstractBeanWriter.ElementAttributes(ElementDescriptor descriptor, Context context)
          Construct attributes for element and context.
 
Method Summary
 int getIndex(java.lang.String qName)
          Gets the index of an attribute by qualified name.
 int getIndex(java.lang.String uri, java.lang.String localName)
          Gets the index of an attribute by namespace name.
 int getLength()
          Gets the number of attributes in the list.
 java.lang.String getLocalName(int index)
          Gets the local name by index.
 java.lang.String getQName(int index)
          Gets the qualified name by index.
 java.lang.String getType(int index)
          Gets the attribute SAX type by namespace name.
 java.lang.String getType(java.lang.String qName)
          Gets the attribute SAX type by qualified name.
 java.lang.String getType(java.lang.String uri, java.lang.String localName)
          Gets the attribute SAX type by namespace name.
 java.lang.String getURI(int index)
          Gets the namespace URI for attribute at the given index.
 java.lang.String getValue(int index)
          Gets the value for the attribute at given index.
 java.lang.String getValue(java.lang.String qName)
          Gets the value for the attribute by qualified name.
 java.lang.String getValue(java.lang.String uri, java.lang.String localName)
          Gets the value for the attribute by namespace name.
private  boolean indexInRange(int index)
          Is the given index within the range of the attribute list
private  void init(AttributeDescriptor[] baseAttributes)
           
private  java.lang.String valueAttribute(AttributeDescriptor attribute)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

attributes

private AttributeDescriptor[] attributes
Attribute descriptors backing the Attributes


context

private Context context
Context to be evaluated when finding values


values

private java.lang.String[] values
Cached attribute values


length

private int length
The number of unsuppressed attributes

Constructor Detail

AbstractBeanWriter.ElementAttributes

AbstractBeanWriter.ElementAttributes(ElementDescriptor descriptor,
                                     Context context)
Construct attributes for element and context.

Parameters:
descriptor - the ElementDescriptor describing the element
context - evaluate against this context
Method Detail

init

private void init(AttributeDescriptor[] baseAttributes)

valueAttribute

private java.lang.String valueAttribute(AttributeDescriptor attribute)

getIndex

public int getIndex(java.lang.String qName)
Gets the index of an attribute by qualified name.

Specified by:
getIndex in interface org.xml.sax.Attributes
Parameters:
qName - the qualified name of the attribute
Returns:
the index of the attribute - or -1 if there is no matching attribute

getIndex

public int getIndex(java.lang.String uri,
                    java.lang.String localName)
Gets the index of an attribute by namespace name.

Specified by:
getIndex in interface org.xml.sax.Attributes
Parameters:
uri - the namespace uri of the attribute
localName - the local name of the attribute
Returns:
the index of the attribute - or -1 if there is no matching attribute

getLength

public int getLength()
Gets the number of attributes in the list.

Specified by:
getLength in interface org.xml.sax.Attributes
Returns:
the number of attributes in this list

getLocalName

public java.lang.String getLocalName(int index)
Gets the local name by index.

Specified by:
getLocalName in interface org.xml.sax.Attributes
Parameters:
index - the attribute index (zero based)
Returns:
the attribute local name - or null if the index is out of range

getQName

public java.lang.String getQName(int index)
Gets the qualified name by index.

Specified by:
getQName in interface org.xml.sax.Attributes
Parameters:
index - the attribute index (zero based)
Returns:
the qualified name of the element - or null if the index is our of range

getType

public java.lang.String getType(int index)
Gets the attribute SAX type by namespace name.

Specified by:
getType in interface org.xml.sax.Attributes
Parameters:
index - the attribute index (zero based)
Returns:
the attribute type (as a string) or null if the index is out of range

getType

public java.lang.String getType(java.lang.String qName)
Gets the attribute SAX type by qualified name.

Specified by:
getType in interface org.xml.sax.Attributes
Parameters:
qName - the qualified name of the attribute
Returns:
the attribute type (as a string) or null if the attribute is not in the list

getType

public java.lang.String getType(java.lang.String uri,
                                java.lang.String localName)
Gets the attribute SAX type by namespace name.

Specified by:
getType in interface org.xml.sax.Attributes
Parameters:
uri - the namespace uri of the attribute
localName - the local name of the attribute
Returns:
the attribute type (as a string) or null if the attribute is not in the list

getURI

public java.lang.String getURI(int index)
Gets the namespace URI for attribute at the given index.

Specified by:
getURI in interface org.xml.sax.Attributes
Parameters:
index - the attribute index (zero-based)
Returns:
the namespace URI (empty string if none is available) or null if the index is out of range

getValue

public java.lang.String getValue(int index)
Gets the value for the attribute at given index.

Specified by:
getValue in interface org.xml.sax.Attributes
Parameters:
index - the attribute index (zero based)
Returns:
the attribute value or null if the index is out of range

getValue

public java.lang.String getValue(java.lang.String qName)
Gets the value for the attribute by qualified name.

Specified by:
getValue in interface org.xml.sax.Attributes
Parameters:
qName - the qualified name
Returns:
the attribute value or null if there are no attributes with the given qualified name

getValue

public java.lang.String getValue(java.lang.String uri,
                                 java.lang.String localName)
Gets the value for the attribute by namespace name.

Specified by:
getValue in interface org.xml.sax.Attributes
Parameters:
uri - the namespace URI of the attribute
localName - the local name of the attribute
Returns:
the attribute value or null if there are not attributes with the given namespace and local name

indexInRange

private boolean indexInRange(int index)
Is the given index within the range of the attribute list

Parameters:
index - the index whose range will be checked
Returns:
true if the index with within the range of the attribute list