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 int
add(Element.Attribute attribute)
Adds an attribute to the sequence.Element.Attribute
get(int index)
Returns the attribute at a given index.int
getLength()
Returns the length of the sequence.int
indexOf(Element.Attribute attribute)
Determines the index of an attribute.void
insert(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.int
remove(Element.Attribute attribute)
Removes an attribute from the sequence.Element.Attribute
update(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:
add
in interfaceSequence<Element.Attribute>
- Parameters:
attribute
- New attribute to add.- Returns:
- The index at which the item was added, or
-1
if 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:
insert
in 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 isnull
or 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:Sequence
Updates the item at the given index.- Specified by:
update
in 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:
remove
in interfaceSequence<Element.Attribute>
- Parameters:
attribute
- The attribute to remove.- Returns:
- The index of the item that was removed, or
-1
if 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:
remove
in 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:
get
in interfaceSequence<Element.Attribute>
- Parameters:
index
- Index of the item to retrieve.- Returns:
- The item at that index, or
null
if there is no attribute at that index.
-
indexOf
public int indexOf(Element.Attribute attribute)
Determines the index of an attribute.- Specified by:
indexOf
in 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:Sequence
Returns the length of the sequence.- Specified by:
getLength
in interfaceSequence<Element.Attribute>
- Returns:
- The number of attributes in the sequence.
-
iterator
public java.util.Iterator<Element.Attribute> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<Element.Attribute>
- Returns:
- An iterator over the attribute sequence.
-
-