Top Description Fields Constructors Methods
org.jdom

pack-priv Class AttributeList

extends AbstractList
implements List, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.util.List, java.util.SequencedCollection, java.util.Collection, java.lang.Iterable
Imports
java.util.*

AttributeList represents legal JDOM Attribute content. This class is NOT PUBLIC; users should see it as a simple List implementation.
Authors
Alex Rosen, Philippe Riand, Bradley S. Huffman
Version
$Revision: 1.24 $, $Date: 2007/11/10 05:28:58 $
See Also
CDATA, Comment, Element, EntityRef, ProcessingInstruction, Text

Field Summary

Modifier and TypeField and Description
private static final String
private Attribute[]
elementData

The backing list

private static final int
private Element
parent

The parent Element

private int
Inherited from java.util.AbstractList:
modCount

Constructor Summary

AccessConstructor and Description
private
AttributeList()

Force an Element parent

pack-priv
AttributeList(Element
element whose attributes are to be held
parent
)

Create a new instance of the AttributeList representing Element content

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true (as per the general contract of Collection.add).
add
(Object
The object to insert into the list.
obj
)

Overrides java.util.AbstractList.add.

Implements java.util.List.add, java.util.Collection.add.

Add a attribute to the end of the list or replace a existing attribute with the same name and Namespace.
public void
add(int
The location to set the value to.
index
,
Object
The object to insert into the list. throws IndexOutOfBoundsException if index < 0 || index > size()
obj
)

Overrides java.util.AbstractList.add.

Implements java.util.List.add.

Inserts the specified attribute at the specified position in this list.
pack-priv void
add(int
index where to add Attribute
index
,
Attribute
Attribute to add
attribute
)

Overrides java.util.AbstractList.add.

Implements java.util.List.add.

Check and add the Attribute to this list at the given index.
public boolean

Returns:

true if the list was modified as a result of the add.
addAll
(Collection<E>
The collection containing all the objects to add.
collection
)

Overrides java.util.AbstractCollection.addAll.

Implements java.util.List.addAll, java.util.Collection.addAll.

Add all the objects in the specified collection.
public boolean

Returns:

true if the list was modified as a result of the add. throws IndexOutOfBoundsException if index < 0 || index > size()
addAll
(int
The offset to start adding the data in the collection
index
,
Collection<E>
The collection to insert into the list.
collection
)

Overrides java.util.AbstractList.addAll.

Implements java.util.List.addAll.

Inserts the specified collecton at the specified position in this list.
public void
clear()

Overrides java.util.AbstractList.clear.

Implements java.util.List.clear, java.util.Collection.clear.

Clear the current list.
pack-priv void
clearAndSet(Collection<E>
The collection to use.
collection
)

Clear the current list and set it to the contents of the Collection.

private void
ensureCapacity(int
the desired minimum capacity.
minCapacity
)

Increases the capacity of this AttributeList instance, if necessary, to ensure that it can hold at least the number of items specified by the minimum capacity argument.

public Object

Returns:

The Object which was returned.
get
(int
The offset of the object.
index
)

Implements abstract java.util.AbstractList.get.

Implements java.util.List.get.

Return the object at the specified offset.
pack-priv Object

Returns:

the Attribute, or null if one doesn't exist.
get
(String
name of attribute to return
name
,
Namespace
Namespace to match
namespace
)

Return the Attribute with the given name and Namespace.

pack-priv int
indexOf(String name, Namespace namespace)

Return index of the Attribute with the given name and uri.

private int
indexOfDuplicate(Attribute attribute)

Return index of attribute with same name and Namespace, or -1 if one doesn't exist

public Object

Returns:

The Object which was removed.
remove
(int
The offset of the object.
index
)

Overrides java.util.AbstractList.remove.

Implements java.util.List.remove.

Remove the object at the specified offset.
pack-priv boolean

Returns:

the true if attribute was removed, false otherwise
remove
(String name, Namespace
Namespace to match
namespace
)

Remove the Attribute with the given name and Namespace.

public Object

Returns:

The object which was replaced. throws IndexOutOfBoundsException if index < 0 || index >= size()
set
(int
The location to set the value to.
index
,
Object
The location to set the value to.
obj
)

Overrides java.util.AbstractList.set.

Implements java.util.List.set.

Set the object at the specified location to the supplied object.
pack-priv Object

Returns:

The object which was replaced. throws IndexOutOfBoundsException if index < 0 || index >= size()
set
(int
The location to set the value to.
index
,
Attribute
The attribute to set.
attribute
)

Overrides java.util.AbstractList.set.

Implements java.util.List.set.

Set the object at the specified location to the supplied object.
public int

Returns:

The number of items in this list.
size
()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.List.size, java.util.Collection.size.

Return the number of items in this list
public String
toString()

Overrides java.util.AbstractCollection.toString.

Return this list as a String
pack-priv final void
uncheckedAddAttribute(Attribute
attribute to add without any checks
a
)

Package internal method to support building from sources that are 100% trusted.

Inherited from java.util.AbstractList:
equalshashCodeindexOfiteratorlastIndexOflistIteratorlistIteratorremoveRangesubList

Field Detail

CVS_IDback to summary
private static final String CVS_ID
elementDataback to summary
private Attribute[] elementData

The backing list

INITIAL_ARRAY_SIZEback to summary
private static final int INITIAL_ARRAY_SIZE
parentback to summary
private Element parent

The parent Element

sizeback to summary
private int size

Constructor Detail

AttributeListback to summary
private AttributeList()

Force an Element parent

AttributeListback to summary
pack-priv AttributeList(Element parent)

Create a new instance of the AttributeList representing Element content

Parameters
parent:Element

element whose attributes are to be held

Method Detail

addback to summary
public boolean add(Object obj)

Overrides java.util.AbstractList.add.

Implements java.util.List.add, java.util.Collection.add.

Add a attribute to the end of the list or replace a existing attribute with the same name and Namespace.

Parameters
obj:Object

The object to insert into the list.

Returns:boolean

true (as per the general contract of Collection.add).

Exceptions
IndexOutOfBoundsException:
if index < 0 || index > size()
addback to summary
public void add(int index, Object obj)

Overrides java.util.AbstractList.add.

Implements java.util.List.add.

Inserts the specified attribute at the specified position in this list. Shifts the attribute currently at that position (if any) and any subsequent attributes to the right (adds one to their indices).

Parameters
index:int

The location to set the value to.

obj:Object

The object to insert into the list. throws IndexOutOfBoundsException if index < 0 || index > size()

addback to summary
pack-priv void add(int index, Attribute attribute)

Overrides java.util.AbstractList.add.

Implements java.util.List.add.

Check and add the Attribute to this list at the given index.

Note

does not check for duplicate attributes.

Parameters
index:int

index where to add Attribute

attribute:Attribute

Attribute to add

addAllback to summary
public boolean addAll(Collection<E> collection)

Overrides java.util.AbstractCollection.addAll.

Implements java.util.List.addAll, java.util.Collection.addAll.

Add all the objects in the specified collection.

Parameters
collection:Collection<E>

The collection containing all the objects to add.

Returns:boolean

true if the list was modified as a result of the add.

addAllback to summary
public boolean addAll(int index, Collection<E> collection)

Overrides java.util.AbstractList.addAll.

Implements java.util.List.addAll.

Inserts the specified collecton at the specified position in this list. Shifts the attribute currently at that position (if any) and any subsequent attributes to the right (adds one to their indices).

Parameters
index:int

The offset to start adding the data in the collection

collection:Collection<E>

The collection to insert into the list.

Returns:boolean

true if the list was modified as a result of the add. throws IndexOutOfBoundsException if index < 0 || index > size()

clearback to summary
public void clear()

Overrides java.util.AbstractList.clear.

Implements java.util.List.clear, java.util.Collection.clear.

Clear the current list.

clearAndSetback to summary
pack-priv void clearAndSet(Collection<E> collection)

Clear the current list and set it to the contents of the Collection. object.

Parameters
collection:Collection<E>

The collection to use.

ensureCapacityback to summary
private void ensureCapacity(int minCapacity)

Increases the capacity of this AttributeList instance, if necessary, to ensure that it can hold at least the number of items specified by the minimum capacity argument.

Parameters
minCapacity:int

the desired minimum capacity.

getback to summary
public Object get(int index)

Implements abstract java.util.AbstractList.get.

Implements java.util.List.get.

Return the object at the specified offset.

Parameters
index:int

The offset of the object.

Returns:Object

The Object which was returned.

getback to summary
pack-priv Object get(String name, Namespace namespace)

Return the Attribute with the given name and Namespace.

Parameters
name:String

name of attribute to return

namespace:Namespace

Namespace to match

Returns:Object

the Attribute, or null if one doesn't exist.

indexOfback to summary
pack-priv int indexOf(String name, Namespace namespace)

Return index of the Attribute with the given name and uri.

indexOfDuplicateback to summary
private int indexOfDuplicate(Attribute attribute)

Return index of attribute with same name and Namespace, or -1 if one doesn't exist

removeback to summary
public Object remove(int index)

Overrides java.util.AbstractList.remove.

Implements java.util.List.remove.

Remove the object at the specified offset.

Parameters
index:int

The offset of the object.

Returns:Object

The Object which was removed.

removeback to summary
pack-priv boolean remove(String name, Namespace namespace)

Remove the Attribute with the given name and Namespace.

Parameters
namespace:Namespace

Namespace to match

Returns:boolean

the true if attribute was removed, false otherwise

setback to summary
public Object set(int index, Object obj)

Overrides java.util.AbstractList.set.

Implements java.util.List.set.

Set the object at the specified location to the supplied object.

Parameters
index:int

The location to set the value to.

obj:Object

The location to set the value to.

Returns:Object

The object which was replaced. throws IndexOutOfBoundsException if index < 0 || index >= size()

setback to summary
pack-priv Object set(int index, Attribute attribute)

Overrides java.util.AbstractList.set.

Implements java.util.List.set.

Set the object at the specified location to the supplied object.

Note

does not check for duplicate attributes.

Parameters
index:int

The location to set the value to.

attribute:Attribute

The attribute to set.

Returns:Object

The object which was replaced. throws IndexOutOfBoundsException if index < 0 || index >= size()

sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.List.size, java.util.Collection.size.

Return the number of items in this list

Returns:int

The number of items in this list.

toStringback to summary
public String toString()

Overrides java.util.AbstractCollection.toString.

Return this list as a String

Returns:String

Doc from java.util.AbstractCollection.toString.

a string representation of this collection

uncheckedAddAttributeback to summary
pack-priv final void uncheckedAddAttribute(Attribute a)

Package internal method to support building from sources that are 100% trusted.

Parameters
a:Attribute

attribute to add without any checks