org.itsnat.core.domutil
Interface ElementListBase

All Superinterfaces:
ElementGroup, ItsNatUserData, org.w3c.dom.NodeList
All Known Subinterfaces:
ElementList, ElementListFree, ElementTable, ElementTableBase, ElementTableFree

public interface ElementListBase
extends ElementGroup, org.w3c.dom.NodeList

This utility interface represents and manages an integer indexed DOM Element list, a list of consecutive elements with a single parent element.

Objects implementing this interface are attached to a real DOM element list with a single parent element, this "initial" list may be not empty, in fact it is automatically synchronized with the "real" DOM element list to show the current state when the utility object is created.

This interface only manages DOM Element objects as list elements, other node types like text nodes are ignored (filtered).

Indexes are zero-based.

When a DOM element is added or removed using this interface, this element is added/removed to/from the DOM list too.

The interface inherits from org.w3c.dom.NodeList, the method NodeList.item(int) is equivalent to getElementAt(int) and NodeList.getLength() return the number of child DOM Elements in the list.

Author:
Jose Maria Arranz Santamaria

Method Summary
 org.w3c.dom.Element getElementAt(int index)
          Returns the element at the specified index.
 org.w3c.dom.Element getElementFromNode(org.w3c.dom.Node node)
          Returns the child element of the list containing the specified node.
 org.w3c.dom.Element[] getElements()
          Returns the element list as an array.
 org.w3c.dom.Element getFirstElement()
          Returns the first child element (element at position 0).
 org.w3c.dom.Element getLastElement()
          Returns the last child element (element at position getLength() - 1).
 ListElementInfo getListElementInfoAt(int index)
          Returns an object info of the child element at the specified position.
 ListElementInfo getListElementInfoFromNode(org.w3c.dom.Node node)
          Returns an object info of the child element containing the specified node (or the node is itself an element of the list).
 int indexOfElement(org.w3c.dom.Element elem)
          Returns the position of the specified element.
 boolean isEmpty()
          Informs whether the list is empty (no elements).
 int lastIndexOfElement(org.w3c.dom.Element elem)
          Returns the position of the specified element searching backwards.
 void moveElement(int start, int end, int to)
          Moves one or more elements from the inclusive range start to end to the to position in the list.
 void removeAllElements()
          Removes all elements.
 org.w3c.dom.Element removeElementAt(int index)
          Removes the specified element.
 void removeElementRange(int fromIndex, int toIndex)
          Removes the elements between the specified indexes.
 
Methods inherited from interface org.itsnat.core.domutil.ElementGroup
getItsNatDocument, getParentElement
 
Methods inherited from interface org.itsnat.core.ItsNatUserData
containsUserValueName, getUserValue, getUserValueNames, removeUserValue, setUserValue
 
Methods inherited from interface org.w3c.dom.NodeList
getLength, item
 

Method Detail

isEmpty

boolean isEmpty()
Informs whether the list is empty (no elements).

Returns:
true if the list is empty.

removeElementAt

org.w3c.dom.Element removeElementAt(int index)
Removes the specified element.

Parameters:
index - index of the element to remove.
Returns:
the removed element or null if index is out of bounds.

removeElementRange

void removeElementRange(int fromIndex,
                        int toIndex)
Removes the elements between the specified indexes.

Parameters:
fromIndex - low index (inclusive).
toIndex - high index (inclusive).

removeAllElements

void removeAllElements()
Removes all elements. The list is now empty.


moveElement

void moveElement(int start,
                 int end,
                 int to)
Moves one or more elements from the inclusive range start to end to the to position in the list. After the move, the element that was at index start will be at index to.
  Examples of moves:
  

1. moveRow(1,3,5); a|B|C|D|e|f|g|h|i|j|k - before a|e|f|g|h|B|C|D|i|j|k - after

2. moveRow(6,7,1); a|b|c|d|e|f|G|H|i|j|k - before a|G|H|b|c|d|e|f|i|j|k - after

Behavior and documentation is based on DefaultTableModel.moveRow(int,int,int)

Parameters:
start - the starting element index to be moved
end - the ending element index to be moved
to - the destination of the elements to be moved

getElements

org.w3c.dom.Element[] getElements()
Returns the element list as an array.

Returns:
the element array.

getElementAt

org.w3c.dom.Element getElementAt(int index)
Returns the element at the specified index.

Parameters:
index - index of the element to search.
Returns:
the element in this position or null if index is out of range.

getFirstElement

org.w3c.dom.Element getFirstElement()
Returns the first child element (element at position 0).

Returns:
the first child element or null is the list is empty.

getLastElement

org.w3c.dom.Element getLastElement()
Returns the last child element (element at position getLength() - 1).

Returns:
the last child element or null is the list is empty.

indexOfElement

int indexOfElement(org.w3c.dom.Element elem)
Returns the position of the specified element.

Parameters:
elem - the element to search.
Returns:
the position or -1 if the specified element is not in the list.

lastIndexOfElement

int lastIndexOfElement(org.w3c.dom.Element elem)
Returns the position of the specified element searching backwards.

The result must be the same as indexOfElement(Element) because there is no "duplicated" elements. Use this method if the specified element is near to the end of the list.

Parameters:
elem - the element to search.
Returns:
the element position or -1 if the specified element is not in the list.

getElementFromNode

org.w3c.dom.Element getElementFromNode(org.w3c.dom.Node node)
Returns the child element of the list containing the specified node. If the node is itself an element of the list, self is returned.

Parameters:
node - the node to search for.
Returns:
the element containing or equal the specified node. Null if this node is not contained by the list.
See Also:
indexOfElement(Element), getListElementInfoFromNode(Node)

getListElementInfoAt

ListElementInfo getListElementInfoAt(int index)
Returns an object info of the child element at the specified position.

Parameters:
index - index of the element to search for.
Returns:
the object info of the matched child element. Null if index is out of range.
See Also:
getElementFromNode(Node)

getListElementInfoFromNode

ListElementInfo getListElementInfoFromNode(org.w3c.dom.Node node)
Returns an object info of the child element containing the specified node (or the node is itself an element of the list).

Parameters:
node - the node to search for.
Returns:
the object info of the matched child element. Null if this node is not contained by the list.
See Also:
getListElementInfoAt(int)


Copyright © 2007 Innowhere Software Services S.L. All Rights Reserved.