Added in API level 1

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:

  1. to take a persistent snapshot of an Attributes object in a startElement event; or
  2. 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.

Copy an existing Attributes object.

Public methods
open Unit
addAttribute(uri: String!, localName: String!, qName: String!, type: String!, value: String!)

Add an attribute to the end of the list.

open Unit

Clear the attribute list for reuse.

open Int
getIndex(qName: String!)

Look up an attribute's index by qualified (prefixed) name.

open Int
getIndex(uri: String!, localName: String!)

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!
getQName(index: Int)

Return an attribute's qualified (prefixed) name.

open String!
getType(index: Int)

Return an attribute's type by index.

open String!
getType(qName: String!)

Look up an attribute's type by qualified (prefixed) name.

open String!
getType(uri: String!, localName: String!)

Look up an attribute's type by Namespace-qualified name.

open String!
getURI(index: Int)

Return an attribute's Namespace URI.

open String!
getValue(index: Int)

Return an attribute's value by index.

open String!
getValue(qName: String!)

Look up an attribute's value by qualified (prefixed) name.

open String!
getValue(uri: String!, localName: String!)

Look up an attribute's value by Namespace-qualified name.

open Unit

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

Copy an entire Attributes object.

open Unit
setLocalName(index: Int, localName: String!)

Set the local name of a specific attribute.

open Unit
setQName(index: Int, qName: String!)

Set the qualified name of a specific attribute.

open Unit
setType(index: Int, type: String!)

Set the type of a specific attribute.

open Unit
setURI(index: Int, uri: String!)

Set the Namespace URI of a specific attribute.

open Unit
setValue(index: Int, value: String!)

Set the value of a specific attribute.

Public constructors

AttributesImpl

Added in API level 1
AttributesImpl()

Construct a new, empty AttributesImpl object.

AttributesImpl

Added in API level 1
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

Added in API level 1
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

Added in API level 1
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

Added in API level 1
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

Added in API level 1
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

Added in API level 1
open fun getLength(): Int

Return the number of attributes in the list.

Return
Int The number of attributes in the list.

getLocalName

Added in API level 1
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.

getQName

Added in API level 1
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.

getType

Added in API level 1
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.

getType

Added in API level 1
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

Added in API level 1
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

Added in API level 1
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.

getValue

Added in API level 1
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.

getValue

Added in API level 1
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

Added in API level 1
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

Added in API level 1
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

Added in API level 1
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

Added in API level 1
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

Added in API level 1
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

Added in API level 1
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

Added in API level 1
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

Added in API level 1
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

Added in API level 1
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.