Package org.apache.pivot.xml
Class Element.AttributeSequence
- java.lang.Object
-
- org.apache.pivot.xml.Element.AttributeSequence
-
- All Implemented Interfaces:
java.lang.Iterable<Element.Attribute>,Sequence<Element.Attribute>
- Enclosing class:
- Element
public final class Element.AttributeSequence extends java.lang.Object implements Sequence<Element.Attribute>, java.lang.Iterable<Element.Attribute>
Sequence representing the attributes declared by this element.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.pivot.collections.Sequence
Sequence.Tree<T>
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intadd(Element.Attribute attribute)Adds an attribute to the sequence.Element.Attributeget(int index)Returns the attribute at a given index.intgetLength()Returns the length of the sequence.intindexOf(Element.Attribute attribute)Determines the index of an attribute.voidinsert(Element.Attribute attribute, int index)Inserts an attribute into the sequence at a specific location.java.util.Iterator<Element.Attribute>iterator()Sequence<Element.Attribute>remove(int index, int count)Removes a range of attributes from the sequence.intremove(Element.Attribute attribute)Removes an attribute from the sequence.Element.Attributeupdate(int index, Element.Attribute item)Updates the item at the given index.
-
-
-
Method Detail
-
add
public int add(Element.Attribute attribute)
Adds an attribute to the sequence.- Specified by:
addin interfaceSequence<Element.Attribute>- Parameters:
attribute- New attribute to add.- Returns:
- The index at which the item was added, or
-1if the item was not added to the sequence.
-
insert
public void insert(Element.Attribute attribute, int index)
Inserts an attribute into the sequence at a specific location.- Specified by:
insertin interfaceSequence<Element.Attribute>- Parameters:
attribute- The new attribute to insert.index- The location where it is to be inserted.- Throws:
java.lang.IllegalArgumentException- if the attribute isnullor if the attribute already is assigned to an element, or if the attribute's name has already been added here.
-
update
@UnsupportedOperation public Element.Attribute update(int index, Element.Attribute item)
Description copied from interface:SequenceUpdates the item at the given index.- Specified by:
updatein interfaceSequence<Element.Attribute>- Parameters:
index- Not used.item- Not used.- Returns:
- The item that was previously stored at the given index.
- Throws:
java.lang.UnsupportedOperationException- This method is not supported. UseElement.Attribute.setValue(String)instead.
-
remove
public int remove(Element.Attribute attribute)
Removes an attribute from the sequence.- Specified by:
removein interfaceSequence<Element.Attribute>- Parameters:
attribute- The attribute to remove.- Returns:
- The index of the item that was removed, or
-1if the item could not be found. - See Also:
Sequence.remove(int, int)
-
remove
public Sequence<Element.Attribute> remove(int index, int count)
Removes a range of attributes from the sequence.- Specified by:
removein interfaceSequence<Element.Attribute>- Parameters:
index- Starting location for the attributes to remove.count- Number to remove.- Returns:
- A sequence containing the items that were removed.
-
get
public Element.Attribute get(int index)
Returns the attribute at a given index.- Specified by:
getin interfaceSequence<Element.Attribute>- Parameters:
index- Index of the item to retrieve.- Returns:
- The item at that index, or
nullif there is no attribute at that index.
-
indexOf
public int indexOf(Element.Attribute attribute)
Determines the index of an attribute.- Specified by:
indexOfin interfaceSequence<Element.Attribute>- Parameters:
attribute- The attribute to look up.- Returns:
- The index of the attribute, if found; otherwise
-1.
-
getLength
public int getLength()
Description copied from interface:SequenceReturns the length of the sequence.- Specified by:
getLengthin interfaceSequence<Element.Attribute>- Returns:
- The number of attributes in the sequence.
-
iterator
public java.util.Iterator<Element.Attribute> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<Element.Attribute>- Returns:
- An iterator over the attribute sequence.
-
-