AttributesImpl
open class AttributesImpl : Attributes
kotlin.Any | |
↳ | org.xml.sax.helpers.AttributesImpl |
Default implementation of the Attributes interface. This module, both source code and documentation, is in the Public Domain, and comes with NO WARRANTY. See http://www.saxproject.org for further information.
This class provides a default implementation of the SAX2 Attributes
interface, with the addition of manipulators so that the list can be modified or reused.
There are two typical uses of this class:
- to take a persistent snapshot of an Attributes object in a
startElement
event; or - to construct or modify an Attributes object in a SAX2 driver or filter.
This class replaces the now-deprecated SAX1 class; in addition to supporting the updated Attributes interface rather than the deprecated AttributeList
interface, it also includes a much more efficient implementation using a single array rather than a set of Vectors.
Summary
Public constructors | |
---|---|
Construct a new, empty AttributesImpl object. |
|
AttributesImpl(atts: Attributes!) Copy an existing Attributes object. |
Public methods | |
---|---|
open Unit |
Add an attribute to the end of the list. |
open Unit |
clear() Clear the attribute list for reuse. |
open Int |
Look up an attribute's index by qualified (prefixed) name. |
open Int |
Look up an attribute's index by Namespace name. |
open Int |
Return the number of attributes in the list. |
open String! |
getLocalName(index: Int) Return an attribute's local name. |
open String! |
Return an attribute's qualified (prefixed) name. |
open String! |
Return an attribute's type by index. |
open String! |
Look up an attribute's type by qualified (prefixed) name. |
open String! |
Look up an attribute's type by Namespace-qualified name. |
open String! |
Return an attribute's Namespace URI. |
open String! |
Return an attribute's value by index. |
open String! |
Look up an attribute's value by qualified (prefixed) name. |
open String! |
Look up an attribute's value by Namespace-qualified name. |
open Unit |
removeAttribute(index: Int) Remove an attribute from the list. |
open Unit |
setAttribute(index: Int, uri: String!, localName: String!, qName: String!, type: String!, value: String!) Set an attribute in the list. |
open Unit |
setAttributes(atts: Attributes!) Copy an entire Attributes object. |
open Unit |
setLocalName(index: Int, localName: String!) Set the local name of a specific attribute. |
open Unit |
Set the qualified name of a specific attribute. |
open Unit |
Set the type of a specific attribute. |
open Unit |
Set the Namespace URI of a specific attribute. |
open Unit |
Set the value of a specific attribute. |
Public constructors
AttributesImpl
AttributesImpl(atts: Attributes!)
Copy an existing Attributes object.
This constructor is especially useful inside a startElement
event.
Parameters | |
---|---|
atts |
Attributes!: The existing Attributes object. |
Public methods
addAttribute
open fun addAttribute(
uri: String!,
localName: String!,
qName: String!,
type: String!,
value: String!
): Unit
Add an attribute to the end of the list.
For the sake of speed, this method does no checking to see if the attribute is already in the list: that is the responsibility of the application.
Parameters | |
---|---|
uri |
String!: The Namespace URI, or the empty string if none is available or Namespace processing is not being performed. |
localName |
String!: The local name, or the empty string if Namespace processing is not being performed. |
qName |
String!: The qualified (prefixed) name, or the empty string if qualified names are not available. |
type |
String!: The attribute type as a string. |
value |
String!: The attribute value. |
clear
open fun clear(): Unit
Clear the attribute list for reuse.
Note that little memory is freed by this call: the current array is kept so it can be reused.
getIndex
open fun getIndex(qName: String!): Int
Look up an attribute's index by qualified (prefixed) name.
Parameters | |
---|---|
qName |
String!: The qualified name. |
Return | |
---|---|
Int |
The attribute's index, or -1 if none matches. |
getIndex
open fun getIndex(
uri: String!,
localName: String!
): Int
Look up an attribute's index by Namespace name.
In many cases, it will be more efficient to look up the name once and use the index query methods rather than using the name query methods repeatedly.
Parameters | |
---|---|
uri |
String!: The attribute's Namespace URI, or the empty string if none is available. |
localName |
String!: The attribute's local name. |
Return | |
---|---|
Int |
The attribute's index, or -1 if none matches. |
getLength
open fun getLength(): Int
Return the number of attributes in the list.
Return | |
---|---|
Int |
The number of attributes in the list. |
See Also
getLocalName
open fun getLocalName(index: Int): String!
Return an attribute's local name.
Parameters | |
---|---|
index |
Int: The attribute's index (zero-based). |
Return | |
---|---|
String! |
The attribute's local name, the empty string if none is available, or null if the index if out of range. |
See Also
getQName
open fun getQName(index: Int): String!
Return an attribute's qualified (prefixed) name.
Parameters | |
---|---|
index |
Int: The attribute's index (zero-based). |
Return | |
---|---|
String! |
The attribute's qualified name, the empty string if none is available, or null if the index is out of bounds. |
See Also
getType
open fun getType(index: Int): String!
Return an attribute's type by index.
Parameters | |
---|---|
index |
Int: The attribute's index (zero-based). |
Return | |
---|---|
String! |
The attribute's type, "CDATA" if the type is unknown, or null if the index is out of bounds. |
See Also
getType
open fun getType(qName: String!): String!
Look up an attribute's type by qualified (prefixed) name.
Parameters | |
---|---|
qName |
String!: The qualified name. |
Return | |
---|---|
String! |
The attribute's type, or null if there is no matching attribute. |
getType
open fun getType(
uri: String!,
localName: String!
): String!
Look up an attribute's type by Namespace-qualified name.
Parameters | |
---|---|
uri |
String!: The Namespace URI, or the empty string for a name with no explicit Namespace URI. |
localName |
String!: The local name. |
Return | |
---|---|
String! |
The attribute's type, or null if there is no matching attribute. |
getURI
open fun getURI(index: Int): String!
Return an attribute's Namespace URI.
Parameters | |
---|---|
index |
Int: The attribute's index (zero-based). |
Return | |
---|---|
String! |
The Namespace URI, the empty string if none is available, or null if the index is out of range. |
See Also
getValue
open fun getValue(index: Int): String!
Return an attribute's value by index.
Parameters | |
---|---|
index |
Int: The attribute's index (zero-based). |
Return | |
---|---|
String! |
The attribute's value or null if the index is out of bounds. |
See Also
getValue
open fun getValue(qName: String!): String!
Look up an attribute's value by qualified (prefixed) name.
Parameters | |
---|---|
qName |
String!: The qualified name. |
Return | |
---|---|
String! |
The attribute's value, or null if there is no matching attribute. |
getValue
open fun getValue(
uri: String!,
localName: String!
): String!
Look up an attribute's value by Namespace-qualified name.
Parameters | |
---|---|
uri |
String!: The Namespace URI, or the empty string for a name with no explicit Namespace URI. |
localName |
String!: The local name. |
Return | |
---|---|
String! |
The attribute's value, or null if there is no matching attribute. |
removeAttribute
open fun removeAttribute(index: Int): Unit
Remove an attribute from the list.
Parameters | |
---|---|
index |
Int: The index of the attribute (zero-based). |
Exceptions | |
---|---|
java.lang.ArrayIndexOutOfBoundsException |
When the supplied index does not point to an attribute in the list. |
setAttribute
open fun setAttribute(
index: Int,
uri: String!,
localName: String!,
qName: String!,
type: String!,
value: String!
): Unit
Set an attribute in the list.
For the sake of speed, this method does no checking for name conflicts or well-formedness: such checks are the responsibility of the application.
Parameters | |
---|---|
index |
Int: The index of the attribute (zero-based). |
uri |
String!: The Namespace URI, or the empty string if none is available or Namespace processing is not being performed. |
localName |
String!: The local name, or the empty string if Namespace processing is not being performed. |
qName |
String!: The qualified name, or the empty string if qualified names are not available. |
type |
String!: The attribute type as a string. |
value |
String!: The attribute value. |
Exceptions | |
---|---|
java.lang.ArrayIndexOutOfBoundsException |
When the supplied index does not point to an attribute in the list. |
setAttributes
open fun setAttributes(atts: Attributes!): Unit
Copy an entire Attributes object.
It may be more efficient to reuse an existing object rather than constantly allocating new ones.
Parameters | |
---|---|
atts |
Attributes!: The attributes to copy. |
setLocalName
open fun setLocalName(
index: Int,
localName: String!
): Unit
Set the local name of a specific attribute.
Parameters | |
---|---|
index |
Int: The index of the attribute (zero-based). |
localName |
String!: The attribute's local name, or the empty string for none. |
Exceptions | |
---|---|
java.lang.ArrayIndexOutOfBoundsException |
When the supplied index does not point to an attribute in the list. |
setQName
open fun setQName(
index: Int,
qName: String!
): Unit
Set the qualified name of a specific attribute.
Parameters | |
---|---|
index |
Int: The index of the attribute (zero-based). |
qName |
String!: The attribute's qualified name, or the empty string for none. |
Exceptions | |
---|---|
java.lang.ArrayIndexOutOfBoundsException |
When the supplied index does not point to an attribute in the list. |
setType
open fun setType(
index: Int,
type: String!
): Unit
Set the type of a specific attribute.
Parameters | |
---|---|
index |
Int: The index of the attribute (zero-based). |
type |
String!: The attribute's type. |
Exceptions | |
---|---|
java.lang.ArrayIndexOutOfBoundsException |
When the supplied index does not point to an attribute in the list. |
setURI
open fun setURI(
index: Int,
uri: String!
): Unit
Set the Namespace URI of a specific attribute.
Parameters | |
---|---|
index |
Int: The index of the attribute (zero-based). |
uri |
String!: The attribute's Namespace URI, or the empty string for none. |
Exceptions | |
---|---|
java.lang.ArrayIndexOutOfBoundsException |
When the supplied index does not point to an attribute in the list. |
setValue
open fun setValue(
index: Int,
value: String!
): Unit
Set the value of a specific attribute.
Parameters | |
---|---|
index |
Int: The index of the attribute (zero-based). |
value |
String!: The attribute's value. |
Exceptions | |
---|---|
java.lang.ArrayIndexOutOfBoundsException |
When the supplied index does not point to an attribute in the list. |