Class Summary : TAttributesImpl

Default implementation of the Attributes interface.
This module, both source code and documentation, is in the Public Domain, and comes with NO WARRANTY.

This class provides a default implementation of the SAX2 IAttributes 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 IAttributes object in a SAX2 driver or filter.

This class replaces the now-deprecated SAX1 AttributeListImpl class; in addition to supporting the updated Attributes interface rather than the deprecated IAttributeList interface, it also includes a much more efficient implementation using a single array rather than a set of Vectors.


Since : SAX 2.0

Methods

procedure ensureCapacity(Integer)
procedure badIndex(Integer)
function getLength() : Integer
function getURI(Integer) : SAXString
function getLocalName(Integer) : SAXString
function getQName(Integer) : SAXString
function getType(Integer) : SAXString
function getType(SAXString, SAXString) : SAXString
function getType(SAXString) : SAXString
function getValue(Integer) : SAXString
function getValue(SAXString, SAXString) : SAXString
function getValue(SAXString) : SAXString
function getIndex(SAXString, SAXString) : Integer
function getIndex(SAXString) : Integer
procedure clear()
procedure setAttributes(IAttributes)
procedure addAttribute(SAXString, SAXString, SAXString, SAXString, SAXString)
procedure setAttribute(Integer, SAXString, SAXString, SAXString, SAXString, SAXString)
procedure removeAttribute(Integer)
procedure setURI(Integer, SAXString)
procedure setLocalName(Integer, SAXString)
procedure setQName(Integer, SAXString)
procedure setType(Integer, SAXString)
procedure setValue(Integer, SAXString)


procedure ensureCapacity( n : Integer);

Ensure the internal array's capacity.
Parameter : n The minimum number of attributes that the array must be able to hold.

Top


procedure badIndex( index : Integer);

Report a bad array index in a manipulator.
Parameter : index The index to report.
Exception : Exception Always.

Top


function getLength() : Integer;

Return the number of attributes in the list.
Result : The number of attributes in the list.
See : IAttributes.getLength

Top


function getURI( index : Integer) : SAXString;

Return an attribute's Namespace URI.
Parameter : index The attribute's index (zero-based).
Result : The Namespace URI, the empty string if none is available or if the index is out of range.
See : IAttributes.getURI

Top


function getLocalName( index : Integer) : SAXString;

Return an attribute's local name.
Parameter : index The attribute's index (zero-based).
Result : The attribute's local name, the empty string if none is available or if the index if out of range.
See : IAttributes.getLocalName

Top


function getQName( index : Integer) : SAXString;

Return an attribute's qualified (prefixed) name.
Parameter : index The attribute's index (zero-based).
Result : The attribute's qualified name, the empty string if none is available or if the index is out of bounds.
See : IAttributes.getQName

Top


function getType( index : Integer) : SAXString;

Return an attribute's type by index.
Parameter : index The attribute's index (zero-based).
Result : The attribute's type, 'CDATA' if the type is unknown, or an empty string if the index is out of bounds.
See : IAttributes.getType(Integer)

Top


function getType(const uri : SAXString; const localName : SAXString) : SAXString;

Look up an attribute's type by Namespace-qualified name.
Parameter : uri The Namespace URI, or the empty string for a name with no explicit Namespace URI.
Parameter : localName The local name.
Result : The attribute's type, or an empty if there is no matching attribute.
See : IAttributes.getType(SAXString,SAXString)

Top


function getType(const qName : SAXString) : SAXString;

Look up an attribute's type by qualified (prefixed) name.
Parameter : qName The qualified name.
Result : The attribute's type, or an empty string if there is no matching attribute.
See : IAttributes.getType(SAXString)

Top


function getValue( index : Integer) : SAXString;

Return an attribute's value by index.
Parameter : index The attribute's index (zero-based).
Result : The attribute's value or an empty string if the index is out of bounds.
See : IAttributes.getValue(Integer)

Top


function getValue(const uri : SAXString; const localName : SAXString) : SAXString;

Look up an attribute's value by Namespace-qualified name.
Parameter : uri The Namespace URI, or the empty string for a name with no explicit Namespace URI.
Parameter : localName The local name.
Result : The attribute's value, or an empty string if there is no matching attribute.
See : IAttributes.getValue(SAXString,SAXString)

Top


function getValue(const qName : SAXString) : SAXString;

Look up an attribute's value by qualified (prefixed) name.
Parameter : qName The qualified name.
Result : The attribute's value, or an empty string if there is no matching attribute.
See : IAttributes.getValue(SAXString)

Top


function getIndex(const uri : SAXString; const localName : SAXString) : Integer;

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.


Parameter : uri The attribute's Namespace URI, or the empty string if none is available.
Parameter : localName The attribute's local name.
Result : The attribute's index, or -1 if none matches.
See : IAttributes.getIndex(SAXString,SAXString)

Top


function getIndex(const qName : SAXString) : Integer;

Look up an attribute's index by qualified (prefixed) name.
Parameter : qName The qualified name.
Result : The attribute's index, or -1 if none matches.
See : IAttributes.getIndex(SAXString)

Top


procedure clear();

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.


Top


procedure setAttributes(const atts : IAttributes);

Copy an entire Attributes object.

It may be more efficient to reuse an existing object rather than constantly allocating new ones.


Parameter : atts The attributes to copy.

Top


procedure addAttribute(const uri : SAXString; const localName : SAXString; const qName : SAXString; const attrType : SAXString; const value : SAXString);

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.


Parameter : uri The Namespace URI, or the empty string if none is available or Namespace processing is not being performed.
Parameter : localName The local name, or the empty string if Namespace processing is not being performed.
Parameter : qName The qualified (prefixed) name, or the empty string if qualified names are not available.
Parameter : type The attribute type as a string.
Parameter : value The attribute value.

Top


procedure setAttribute( index : Integer; const uri : SAXString; const localName : SAXString; const qName : SAXString; const attrType : SAXString; const value : SAXString);

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.


Parameter : index The index of the attribute (zero-based).
Parameter : uri The Namespace URI, or the empty string if none is available or Namespace processing is not being performed.
Parameter : localName The local name, or the empty string if Namespace processing is not being performed.
Parameter : qName The qualified name, or the empty string if qualified names are not available.
Parameter : type The attribute type as a string.
Parameter : value The attribute value.
Exception : Exception when the supplied index does not point to an attribute in the list.

Top


procedure removeAttribute( index : Integer);

Remove an attribute from the list.
Parameter : index The index of the attribute (zero-based).
Exception : Exception when the supplied index does not point to an attribute in the list.

Top


procedure setURI( index : Integer; const uri : SAXString);

Set the Namespace URI of a specific attribute.
Parameter : index The index of the attribute (zero-based).
Parameter : uri The attribute's Namespace URI, or the empty string for none.
Exception : Exception when the supplied index does not point to an attribute in the list.

Top


procedure setLocalName( index : Integer; const localName : SAXString);

Set the local name of a specific attribute.
Parameter : index The index of the attribute (zero-based).
Parameter : localName The attribute's local name, or the empty string for none.
Exception : Exception when the supplied index does not point to an attribute in the list.

Top


procedure setQName( index : Integer; const qName : SAXString);

Set the qualified name of a specific attribute.
Parameter : index The index of the attribute (zero-based).
Parameter : qName The attribute's qualified name, or the empty string for none.
Exception : Exception when the supplied index does not point to an attribute in the list.

Top


procedure setType( index : Integer; const attrType : SAXString);

Set the type of a specific attribute.
Parameter : index The index of the attribute (zero-based).
Parameter : type The attribute's type.
Exception : Exception when the supplied index does not point to an attribute in the list.

Top


procedure setValue( index : Integer; const value : SAXString);

Set the value of a specific attribute.
Parameter : index The index of the attribute (zero-based).
Parameter : value The attribute's value.
Exception : Exception when the supplied index does not point to an attribute in the list.

Top