org.xlattice.corexml.om
Class AttrList

java.lang.Object
  extended by org.xlattice.corexml.om.AttrList

public class AttrList
extends java.lang.Object

A container for attributes. The order of attributes in the container is not significant and is not guaranteed to be repeatable.

Author:
Jim Dixon

Constructor Summary
AttrList()
          Create a container with a default size of 8.
AttrList(Attr attr)
          Create the container that will hold one attribute, initializing it to that size.
AttrList(int sizeHint)
          Create the container, specifying a size.
 
Method Summary
 AttrList add(Attr attr)
          Add an attribute to an existing container.
 Attr get(int n)
          Get the Nth attribute.
 Holder getHolder()
           
 AttrList insert(int n, Attr attr)
          Insert an attribute into an existing container in a particular place, displacing any existing attributes if necessary.
 void setHolder(Element h)
          Set the Holder for this attribute.
 int size()
           
 java.lang.String toXml()
           
 void walkAll(Visitor v)
          Walk a Visitor through the list of attributes, visiting each in turn.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AttrList

AttrList(int sizeHint)
Create the container, specifying a size.

Parameters:
sizeHint - preferred size

AttrList

AttrList(Attr attr)
Create the container that will hold one attribute, initializing it to that size.

Parameters:
attr - the attribute held

AttrList

AttrList()
Create a container with a default size of 8.

Method Detail

add

public AttrList add(Attr attr)
Add an attribute to an existing container.

Parameters:
attr - the attribute to be inserted
Returns:
a reference to this list, to allow chaining
Throws:
java.lang.NullPointerException - if the Attr argument is null

insert

public AttrList insert(int n,
                       Attr attr)
Insert an attribute into an existing container in a particular place, displacing any existing attributes if necessary.

Parameters:
n - zero-based index at which the Attr is to be inserted
attr - the attribute to be inserted
Returns:
a reference to this list, to allow chaining
Throws:
java.lang.IndexOutOfBoundsException - if n is negative or out of range
java.lang.NullPointerException - if the Attr argument is null

get

public Attr get(int n)
Get the Nth attribute.

Parameters:
n - index of the Attr to be returned
Returns:
the Nth attr in the list
Throws:
java.lang.IndexOutOfBoundsException

size

public int size()
Returns:
number of attrs in the list

getHolder

public Holder getHolder()
Returns:
the Element that the attribute belongs to

setHolder

public void setHolder(Element h)
Set the Holder for this attribute. By definition the Holder must be an XML Element.

Parameters:
h - the Holder being assigned

walkAll

public void walkAll(Visitor v)
Walk a Visitor through the list of attributes, visiting each in turn.

Parameters:
v - the visitor

toXml

public java.lang.String toXml()
Returns:
the list in XML String form