AttributeList represents legal JDOM
Attribute content.
This class is NOT PUBLIC; users should see it as a simple List implementation, although it behaves something like a Set because you cannot add duplicate Attributes. An attribute is considered duplicate if it has the same Namespace URI and Attribute name as another existing Attribute.
| Modifier and Type | Class and Description |
|---|---|
| private class | AttributeList.ALIterator
A fast iterator that can beat AbstractList because we can access the data directly. |
| Modifier and Type | Field and Description |
|---|---|
| private static final Comparator | |
| private Attribute[] | attributeData
The backing array |
| private static final int | INITIAL_ARRAY_SIZE
The initial size to start the backing array. |
| private final Element | parent
The parent Element |
| private int | size
The current size |
| Access | Constructor and Description |
|---|---|
| pack-priv | AttributeList(final Element
Element whose Attributes are to be held parent)Create a new instance of the AttributeList representing parent Element's Attributes |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true as specified byCollection.add().The attribute)Attribute to insert into the list.Overrides java. Implements java. Attribute with the same name and
Namespace.
|
| public void | add(final int
where to add/insert the index, final Attribute AttributeAttribute to addOverrides java. Implements java. |
| public boolean | Returns: true if the list was modified as a result of the
add.The collection)Collection of Attributes to add.Overrides java. Implements java. Attributes in collection.
|
| public boolean | Returns: true if the list was modified as a result of the
add.The offset at which to start adding the index, final Collection<? extends Attribute> AttributesThe collection)Collection containing the Attributes
to add.Overrides java. Implements java. Attributes in collection at the specified
index in this list.
|
| private final int | Returns: the insertion point.The pointers to search within indexes, final int The number of pointers to search within len, final int The pointer we are checking for. val, final Comparator<? super Attribute> The Comparator to compare with comp)Unlike the Arrays.binarySearch, this method never expects an "already exists" condition, we only ever add, thus there will never be a negative insertion-point. |
| public void | clear()
Overrides java. Implements java. |
| pack-priv void | clearAndSet(final Collection<? extends Attribute>
The collection)Collection to use.Clear the current list and set it to the contents of collection. |
| private void | ensureCapacity(final int
the desired minimum capacity. minCapacity)Increases the capacity of this |
| public Attribute | Returns: TheAttribute at position index.The position of the index)Attribute to retrieve.Implements abstract java. Implements java. Attribute at offset.
|
| pack-priv Attribute | |
| pack-priv int | |
| private int | indexOfDuplicate(final Attribute attribute)
Return index of attribute with same name and Namespace, or -1 if one doesn't exist |
| public boolean | isEmpty()
Overrides java. Implements java. true if this list contains no elements.
|
| public Iterator | Returns: an iterator.Overrides java. Implements java. Iterator over the Attributes in this
list in the proper sequence.
|
| public Attribute | Returns: The removedAttribute.The offset of the index)Attribute to remove.Overrides java. Implements java. Attribute at index.
|
| pack-priv boolean | |
| public Attribute | Returns: The replacedAttribute.The location to set the value to. index, final Attribute The attribute)Attribute to set.Overrides java. Implements java. Attribute at index to be attribute.
|
| public int | Returns: The number ofAttributes in this list.Implements abstract java. Implements java. Attributes in this list
|
| public void | sort(Comparator<? super Attribute>
The Comparator to use for sorting. comp)Overrides default java. |
| private void | |
| public String | |
| pack-priv final void | uncheckedAddAttribute(final Attribute
an Attribute to add without any checks a)Package internal method to support building from sources that are 100% trusted. |
| ATTRIBUTE_NATURAL | back to summary |
|---|---|
| private static final Comparator<Attribute> ATTRIBUTE_NATURAL | |
| attributeData | back to summary |
|---|---|
| private Attribute[] attributeData The backing array | |
| INITIAL_ARRAY_SIZE | back to summary |
|---|---|
| private static final int INITIAL_ARRAY_SIZE The initial size to start the backing array. | |
| parent | back to summary |
|---|---|
| private final Element parent The parent Element | |
| size | back to summary |
|---|---|
| private int size The current size | |
| AttributeList | back to summary |
|---|---|
| pack-priv AttributeList(final Element parent) Create a new instance of the AttributeList representing parent Element's Attributes
| |
| add | back to summary |
|---|---|
| public boolean add(final Attribute attribute) Overrides java. Implements java. Check and add attribute to the end of the list or replace an
existing
| |
| add | back to summary |
|---|---|
| public void add(final int index, final Attribute attribute) Overrides java. Implements java. Check and add attribute to this list at index.
| |
| addAll | back to summary |
|---|---|
| public boolean addAll(final Collection<? extends Attribute> collection) Overrides java. Implements java. Add all the
| |
| addAll | back to summary |
|---|---|
| public boolean addAll(final int index, final Collection<? extends Attribute> collection) Overrides java. Implements java. Inserts the
| |
| binarySearch | back to summary |
|---|---|
| private final int binarySearch(final int[] indexes, final int len, final int val, final Comparator<? super Attribute> comp) Unlike the Arrays.binarySearch, this method never expects an "already exists" condition, we only ever add, thus there will never be a negative insertion-point.
| |
| clear | back to summary |
|---|---|
| public void clear() Overrides java. Implements java. Clear the current list.
| |
| clearAndSet | back to summary |
|---|---|
| pack-priv void clearAndSet(final Collection<? extends Attribute> collection) Clear the current list and set it to the contents of collection.
| |
| ensureCapacity | back to summary |
|---|---|
| private void ensureCapacity(final int minCapacity) Increases the capacity of this
| |
| get | back to summary |
|---|---|
| public Attribute get(final int index) Implements abstract java. Implements java. Retrieve the | |
| get | back to summary |
|---|---|
| pack-priv Attribute get(final String name, final Namespace namespace) Retrieve the | |
| indexOf | back to summary |
|---|---|
| pack-priv int indexOf(final String name, final Namespace namespace) Return index of the | |
| indexOfDuplicate | back to summary |
|---|---|
| private int indexOfDuplicate(final Attribute attribute) Return index of attribute with same name and Namespace, or -1 if one doesn't exist | |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Overrides java. Implements java. Doc from java. Returns
| |
| iterator | back to summary |
|---|---|
| public Iterator Overrides java. Implements java. Returns an | |
| remove | back to summary |
|---|---|
| public Attribute remove(final int index) Overrides java. Implements java. Remove the | |
| remove | back to summary |
|---|---|
| pack-priv boolean remove(final String name, final Namespace namespace) Remove the | |
| set | back to summary |
|---|---|
| public Attribute set(final int index, final Attribute attribute) Overrides java. Implements java. Set the
| |
| size | back to summary |
|---|---|
| public int size() Implements abstract java. Implements java. Return the number of
| |
| sort | back to summary |
|---|---|
| public void sort(Comparator<? super Attribute> comp) Overrides default java. Sort the attributes using the supplied comparator. The attributes are never added using regular mechanisms, so there are never problems with detached or already-attached Attributes. The sort happens 'in place'. If the comparator identifies two (or more) Attributes to be equal, then the relative order of those attributes will not be changed.
| |
| sortInPlace | back to summary |
|---|---|
| private void sortInPlace(final int[] indexes) | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Return this list as a
| |
| uncheckedAddAttribute | back to summary |
|---|---|
| pack-priv final void uncheckedAddAttribute(final Attribute a) Package internal method to support building from sources that are 100% trusted.
| |
for (Attribute a : element.getAttributes()) {...},
and that uses iterator().
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private int | |
| private int |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public Attribute | |
| public void | remove()
Overrides default java. |
| canremove | back to summary |
|---|---|
| private boolean canremove | |
| cursor | back to summary |
|---|---|
| private int cursor | |
| expect | back to summary |
|---|---|
| private int expect | |
| ALIterator | back to summary |
|---|---|
| private ALIterator() | |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns
| |
| next | back to summary |
|---|---|
| public Attribute next() Implements java. Doc from java. Returns the next element in the iteration. | |
| remove | back to summary |
|---|---|
| public void remove() Overrides default java. Doc from java. Removes from the underlying collection the last element returned
by this iterator (optional operation). This method can be called
only once per call to The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.
The behavior of an iterator is unspecified if this method is called
after a call to the
| |