Javolution 6.0.0 java
javolution.xml.internal.stream.AttributesImpl Class Reference
Inheritance diagram for javolution.xml.internal.stream.AttributesImpl:
[legend]
Collaboration diagram for javolution.xml.internal.stream.AttributesImpl:
[legend]

Classes

class  AttributeImpl
 

Public Member Functions

 AttributesImpl (NamespacesImpl namespaces)
 
void addAttribute (CharArray localName, CharArray prefix, CharArray qName, CharArray value)
 
int getIndex (CharSequence qName)
 
int getIndex (CharSequence uri, CharSequence localName)
 
int getLength ()
 
CharArray getLocalName (int index)
 
CharArray getPrefix (int index)
 
CharArray getQName (int index)
 
CharArray getType (CharSequence qName)
 
CharArray getType (CharSequence uri, CharSequence localName)
 
CharArray getType (int index)
 
CharArray getURI (int index)
 
CharArray getValue (CharSequence qName)
 
CharArray getValue (CharSequence uri, CharSequence localName)
 
CharArray getValue (int index)
 
void reset ()
 

Private Attributes

final FastTable< AttributeImplattributes = new FastTable<AttributeImpl>()
 
int length
 
final NamespacesImpl namespaces
 

Static Private Attributes

static final CharArray CDATA = new CharArray("CDATA")
 
static final CharArray EMPTY = new CharArray()
 

Detailed Description

This class provides the implementation of the Attributes interface for the StAX parser.

Definition at line 11 of file AttributesImpl.java.

Constructor & Destructor Documentation

◆ AttributesImpl()

javolution.xml.internal.stream.AttributesImpl.AttributesImpl ( NamespacesImpl  namespaces)

Creates a list of attribute using the specified namespace stack.

Definition at line 48 of file AttributesImpl.java.

48  {
49  this.namespaces = namespaces;
50  }

References javolution.xml.internal.stream.AttributesImpl.namespaces.

Member Function Documentation

◆ addAttribute()

void javolution.xml.internal.stream.AttributesImpl.addAttribute ( CharArray  localName,
CharArray  prefix,
CharArray  qName,
CharArray  value 
)

Adds an attribute to the end of the attribute list.

Parameters
localNamethe local name.
prefixthe prefix or null if none.
qNamethe qualified (prefixed) name.
valuethe attribute value.

Definition at line 60 of file AttributesImpl.java.

61  {
62  AttributeImpl attribute;
63  if (length >= attributes.size()) {
64  attribute = new AttributeImpl();
65  attributes.add(attribute);
66  } else {
67  attribute = attributes.get(length);
68  }
69  attribute.localName = localName;
70  attribute.prefix = prefix;
71  attribute.qName = qName;
72  attribute.value = value;
73  length++;
74  }

References javolution.xml.internal.stream.AttributesImpl.attributes, javolution.xml.internal.stream.AttributesImpl.length, javolution.xml.internal.stream.AttributesImpl.AttributeImpl.localName, javolution.xml.internal.stream.AttributesImpl.AttributeImpl.prefix, javolution.xml.internal.stream.AttributesImpl.AttributeImpl.qName, and javolution.xml.internal.stream.AttributesImpl.AttributeImpl.value.

Referenced by javolution.xml.internal.stream.XMLStreamReaderImpl.processAttribute().

Here is the caller graph for this function:

◆ getIndex() [1/2]

int javolution.xml.internal.stream.AttributesImpl.getIndex ( CharSequence  qName)

Looks up the index of an attribute by XML 1.0 qualified name (convenience method). This method returns the index of the attribute whose name has the same character content as the specified qName.

Parameters
qNamethe qualified (prefixed) name.
Returns
the index of the attribute, or -1 if it does not appear in the list.

Implements javolution.xml.sax.Attributes.

Definition at line 77 of file AttributesImpl.java.

77  {
78  for (int i = 0; i < length; i++) {
79  if (qName.equals(attributes.get(i).qName))
80  return i;
81  }
82  return -1;
83  }

References javolution.xml.internal.stream.AttributesImpl.attributes, and javolution.xml.internal.stream.AttributesImpl.length.

Referenced by javolution.xml.internal.stream.AttributesImpl.getType(), and javolution.xml.internal.stream.AttributesImpl.getValue().

Here is the caller graph for this function:

◆ getIndex() [2/2]

int javolution.xml.internal.stream.AttributesImpl.getIndex ( CharSequence  uri,
CharSequence  localName 
)

Looks up the index of an attribute by namespace name (convenience method). This method returns the index of the attribute whose uri/localName have the same character content as the specified uri/localName.

Parameters
urithe Namespace URI, or an empty character sequence if the name has no Namespace URI.
localNamethe attribute's local name.
Returns
the index of the attribute, or -1 if it does not appear in the list.

Implements javolution.xml.sax.Attributes.

Definition at line 86 of file AttributesImpl.java.

86  {
87  for (int i = 0; i < length; i++) {
88  AttributeImpl attribute = attributes.get(i);
89  if (localName.equals(attribute.localName)) {
90  if (attribute.prefix == null) { // No namespace URI.
91  if (uri.length() == 0)
92  return i;
93  } else { // Check if matching namespace URI.
94  if (uri.equals(namespaces.getNamespaceURI(attribute.prefix)))
95  return i;
96  }
97  }
98  }
99  return -1;
100  }

References javolution.xml.internal.stream.AttributesImpl.attributes, javolution.xml.internal.stream.NamespacesImpl.getNamespaceURI(), javolution.xml.internal.stream.AttributesImpl.length, javolution.xml.internal.stream.AttributesImpl.AttributeImpl.localName, javolution.xml.internal.stream.AttributesImpl.namespaces, and javolution.xml.internal.stream.AttributesImpl.AttributeImpl.prefix.

Here is the call graph for this function:

◆ getLength()

int javolution.xml.internal.stream.AttributesImpl.getLength ( )

Returns the number of attributes in this list of attributes.

Returns
the number of attributes.

Implements javolution.xml.sax.Attributes.

Definition at line 103 of file AttributesImpl.java.

103  {
104  return length;
105  }

References javolution.xml.internal.stream.AttributesImpl.length.

Referenced by javolution.xml.internal.stream.XMLStreamReaderImpl.getAttributeCount().

Here is the caller graph for this function:

◆ getLocalName()

CharArray javolution.xml.internal.stream.AttributesImpl.getLocalName ( int  index)

Looks up an attribute's local name by index.

Parameters
indexthe attribute index (zero-based).
Returns
the local name, or an empty character sequence if Namespace processing is not being performed, or null if the index is out of range.
See also
getLength

Implements javolution.xml.sax.Attributes.

Definition at line 108 of file AttributesImpl.java.

108  {
109  if ((index < 0) || (index >= length)) return null;
110  return attributes.get(index).localName;
111  }

References javolution.xml.internal.stream.AttributesImpl.attributes, and javolution.xml.internal.stream.AttributesImpl.length.

Referenced by javolution.xml.internal.stream.XMLStreamReaderImpl.getAttributeLocalName().

Here is the caller graph for this function:

◆ getPrefix()

CharArray javolution.xml.internal.stream.AttributesImpl.getPrefix ( int  index)

Definition at line 113 of file AttributesImpl.java.

113  {
114  if ((index < 0) || (index >= length)) return null;
115  return attributes.get(index).prefix;
116  }

References javolution.xml.internal.stream.AttributesImpl.attributes, and javolution.xml.internal.stream.AttributesImpl.length.

Referenced by javolution.xml.internal.stream.XMLStreamReaderImpl.getAttributeNamespace(), and javolution.xml.internal.stream.XMLStreamReaderImpl.getAttributePrefix().

Here is the caller graph for this function:

◆ getQName()

CharArray javolution.xml.internal.stream.AttributesImpl.getQName ( int  index)

Looks up an attribute's XML 1.0 qualified name by index.

Parameters
indexthe attribute index (zero-based).
Returns
the XML 1.0 qualified name, or an empty character sequence if none is available, or null if the index is out of range.
See also
getLength

Implements javolution.xml.sax.Attributes.

Definition at line 119 of file AttributesImpl.java.

119  {
120  if ((index < 0) || (index >= length)) return null;
121  return attributes.get(index).qName;
122  }

References javolution.xml.internal.stream.AttributesImpl.attributes, and javolution.xml.internal.stream.AttributesImpl.length.

◆ getType() [1/3]

CharArray javolution.xml.internal.stream.AttributesImpl.getType ( CharSequence  qName)

Looks up an attribute's type by XML 1.0 qualified name. This method returns the type of the attribute whose qName has the same character content as the specified qName.

Parameters
qNameThe XML 1.0 qualified name.
Returns
the attribute type as a string, or null if the attribute is not in the list or if qualified names are not available.

Implements javolution.xml.sax.Attributes.

Definition at line 125 of file AttributesImpl.java.

125  {
126  return (getIndex(qName) >= 0) ? CDATA : null;
127  }

References javolution.xml.internal.stream.AttributesImpl.CDATA, and javolution.xml.internal.stream.AttributesImpl.getIndex().

Referenced by javolution.xml.internal.stream.XMLStreamReaderImpl.getAttributeType().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getType() [2/3]

CharArray javolution.xml.internal.stream.AttributesImpl.getType ( CharSequence  uri,
CharSequence  localName 
)

Looks up an attribute's type by Namespace name (convenience method). This method returns the type of the attribute whose uri/localName have the same character content as the specified uri/localName.

Parameters
urithe Namespace URI, or an empty string if the name has no Namespace URI.
localNamethe local name of the attribute.
Returns
the attribute type as a string, or null if the attribute is not in the list or if Namespace processing is not being performed.

Implements javolution.xml.sax.Attributes.

Definition at line 130 of file AttributesImpl.java.

130  {
131  return (getIndex(uri, localName) >= 0) ? CDATA : null;
132  }

References javolution.xml.internal.stream.AttributesImpl.CDATA, and javolution.xml.internal.stream.AttributesImpl.getIndex().

Here is the call graph for this function:

◆ getType() [3/3]

CharArray javolution.xml.internal.stream.AttributesImpl.getType ( int  index)

Looks up an attribute's type by index.

The attribute type is one of the strings "CDATA", "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES", or "NOTATION" (always in upper case).

If the parser has not read a declaration for the attribute, or if the parser does not report attribute types, then it must return the value "CDATA" as stated in the XML 1.0 Recommentation (clause 3.3.3, "Attribute-TextBuilder Normalization").

For an enumerated attribute that is not a notation, the parser will report the type as "NMTOKEN".

Parameters
indexthe attribute index (zero-based).
Returns
the attribute's type as a string, or null if the index is out of range.
See also
getLength

Implements javolution.xml.sax.Attributes.

Definition at line 135 of file AttributesImpl.java.

135  {
136  if ((index < 0) || (index >= length)) return null;
137  return CDATA;
138  }

References javolution.xml.internal.stream.AttributesImpl.CDATA, and javolution.xml.internal.stream.AttributesImpl.length.

◆ getURI()

CharArray javolution.xml.internal.stream.AttributesImpl.getURI ( int  index)

Looks up an attribute's Namespace URI by index.

Parameters
indexthe attribute index (zero-based).
Returns
the Namespace URI, or an empty character sequence if none is available, or null if the index is out of range.
See also
getLength

Implements javolution.xml.sax.Attributes.

Definition at line 140 of file AttributesImpl.java.

140  {
141  if ((index < 0) || (index >= length)) return null;
142  CharArray prefix = attributes.get(index).prefix;
143  return (prefix == null) ? EMPTY : namespaces.getNamespaceURI(prefix);
144  }

References javolution.xml.internal.stream.AttributesImpl.attributes, javolution.xml.internal.stream.AttributesImpl.EMPTY, javolution.xml.internal.stream.NamespacesImpl.getNamespaceURI(), javolution.xml.internal.stream.AttributesImpl.length, and javolution.xml.internal.stream.AttributesImpl.namespaces.

Here is the call graph for this function:

◆ getValue() [1/3]

CharArray javolution.xml.internal.stream.AttributesImpl.getValue ( CharSequence  qName)

Looks up an attribute's value by XML 1.0 qualified name (convenience method). This method returns the value of the attribute whose qName has the same character content as the specified qName.

Parameters
qNameThe XML 1.0 qualified name.
Returns
the attribute value as a character sequence, or null if the attribute is not in the list or if qualified names are not available.

Implements javolution.xml.sax.Attributes.

Definition at line 147 of file AttributesImpl.java.

147  {
148  final int index = getIndex(qName);
149  return (index >= 0) ? attributes.get(index).value : null;
150  }

References javolution.xml.internal.stream.AttributesImpl.attributes, and javolution.xml.internal.stream.AttributesImpl.getIndex().

Referenced by javolution.xml.internal.stream.XMLStreamReaderImpl.getAttributeValue(), and javolution.xml.internal.stream.XMLStreamReaderImpl.isAttributeSpecified().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getValue() [2/3]

CharArray javolution.xml.internal.stream.AttributesImpl.getValue ( CharSequence  uri,
CharSequence  localName 
)

Looks up an attribute's value by Namespace name (convenience method). This method returns the value of the attribute whose uri/localName have the same character content as the specified uri/localName.

Parameters
urithe Namespace URI, or the empty string if the name has no Namespace URI.
localNamethe local name of the attribute.
Returns
the attribute value as a character sequence, or null if the attribute is not in the list.

Implements javolution.xml.sax.Attributes.

Definition at line 153 of file AttributesImpl.java.

153  {
154  final int index = getIndex(uri, localName);
155  return (index >= 0) ? attributes.get(index).value : null;
156  }

References javolution.xml.internal.stream.AttributesImpl.attributes, and javolution.xml.internal.stream.AttributesImpl.getIndex().

Here is the call graph for this function:

◆ getValue() [3/3]

CharArray javolution.xml.internal.stream.AttributesImpl.getValue ( int  index)

Looks up an attribute's value by index.

If the attribute value is a list of tokens (IDREFS, ENTITIES, or NMTOKENS), the tokens will be concatenated into a single string with each token separated by a single space.

Parameters
indexthe attribute index (zero-based).
Returns
the attribute's value as a character sequence, null if the index is out of range.
See also
getLength

Implements javolution.xml.sax.Attributes.

Definition at line 159 of file AttributesImpl.java.

159  {
160  if ((index < 0) || (index >= length)) return null;
161  return attributes.get(index).value;
162  }

References javolution.xml.internal.stream.AttributesImpl.attributes, and javolution.xml.internal.stream.AttributesImpl.length.

◆ reset()

void javolution.xml.internal.stream.AttributesImpl.reset ( )

Clear the attribute list for reuse.

Definition at line 167 of file AttributesImpl.java.

167  {
168  length = 0;
169  }

References javolution.xml.internal.stream.AttributesImpl.length.

Referenced by javolution.xml.internal.stream.XMLStreamReaderImpl.next(), and javolution.xml.internal.stream.XMLStreamReaderImpl.reset().

Here is the caller graph for this function:

Member Data Documentation

◆ attributes

◆ CDATA

final CharArray javolution.xml.internal.stream.AttributesImpl.CDATA = new CharArray("CDATA")
staticprivate

◆ EMPTY

final CharArray javolution.xml.internal.stream.AttributesImpl.EMPTY = new CharArray()
staticprivate

◆ length

◆ namespaces

final NamespacesImpl javolution.xml.internal.stream.AttributesImpl.namespaces
private

The documentation for this class was generated from the following file:
javolution.xml.internal.stream.AttributesImpl.length
int length
Definition: AttributesImpl.java:38
javolution.xml.internal.stream.AttributesImpl.namespaces
final NamespacesImpl namespaces
Definition: AttributesImpl.java:43
javolution.xml.internal.stream.AttributesImpl.attributes
final FastTable< AttributeImpl > attributes
Definition: AttributesImpl.java:33
javolution.xml.internal.stream.NamespacesImpl.getNamespaceURI
CharArray getNamespaceURI(CharSequence prefix)
Definition: NamespacesImpl.java:95
javolution.xml.internal.stream.AttributesImpl.EMPTY
static final CharArray EMPTY
Definition: AttributesImpl.java:28
javolution.xml.internal.stream.AttributesImpl.CDATA
static final CharArray CDATA
Definition: AttributesImpl.java:26
javolution.xml.internal.stream.AttributesImpl.getIndex
int getIndex(CharSequence qName)
Definition: AttributesImpl.java:77