org.itsnat.core.domutil
Interface ElementTableBase

All Superinterfaces:
ElementGroup, ElementListBase, ItsNatUserData, org.w3c.dom.NodeList
All Known Subinterfaces:
ElementTable, ElementTableFree

public interface ElementTableBase
extends ElementListBase

This utility interface represents and manages an integer indexed DOM Element table, a row list of consecutive elements with a single parent element, every row element contains again an element list (cells).

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

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

Indexes are zero-based.

When a DOM element (a new row or a new cell/column) is added or removed using this interface, this element is added/removed to/from the DOM table too.

This interface inherits from ElementListBase, the list interface see the table as a list of rows.

Author:
Jose Maria Arranz Santamaria

Method Summary
 org.w3c.dom.Element getCellElementAt(int row, int column)
          Returns the cell element at the specified row and column.
 org.w3c.dom.Element[] getCellElementsOfColumn(int column)
          Returns the cell elements of the specified column as an array.
 org.w3c.dom.Element[] getCellElementsOfRow(int row)
          Returns the cell elements of the specified row as an array.
 org.w3c.dom.Element[] getElementRows()
          Returns the row element list as an array.
 org.w3c.dom.Element getFirstRowElement()
          Returns the first row element (row at position 0).
 org.w3c.dom.Element getLastRowElement()
          Returns the last row element (row at position length - 1).
 int getRowCount()
          Returns the number of rows.
 org.w3c.dom.Element getRowElementAt(int row)
          Returns the row element at the specified index.
 org.w3c.dom.Element getRowElementFromNode(org.w3c.dom.Node node)
          Returns the row element of the table containing the specified node.
 ListElementInfo getRowListElementInfoAt(int index)
          Returns an object info of the row element at the specified position.
 ListElementInfo getRowListElementInfoFromNode(org.w3c.dom.Node node)
          Returns an object info of the row element containing the specified node (or the node is itself a row element).
 TableCellElementInfo getTableCellElementInfoAt(int row, int column)
          Returns an object info of the cell element specified by the row and column indexes.
 TableCellElementInfo getTableCellElementInfoFromNode(org.w3c.dom.Node node)
          Returns an object info of the cell element containing the specified node (or the node is itself a cell element of the table).
 int indexOfRowElement(org.w3c.dom.Element elem)
          Returns the position of the specified row element.
 int lastIndexOfRowElement(org.w3c.dom.Element elem)
          Returns the position of the specified row element searching backwards.
 void moveColumn(int columnIndex, int newIndex)
          Moves the column at columnIndex to newIndex.
 void moveRow(int start, int end, int to)
          Moves one or more row elements from the inclusive range start to end to the to position in the table.
 void removeAllColumns()
          Removes all columns.
 void removeAllRows()
          Removes all row elements.
 void removeColumnAt(int column)
          Removes the specified column.
 org.w3c.dom.Element removeRowAt(int row)
          Removes the specified row element.
 void removeRowRange(int fromIndex, int toIndex)
          Removes the row elements between the specified indexes.
 
Methods inherited from interface org.itsnat.core.domutil.ElementListBase
getElementAt, getElementFromNode, getElements, getFirstElement, getLastElement, getListElementInfoAt, getListElementInfoFromNode, indexOfElement, isEmpty, lastIndexOfElement, moveElement, removeAllElements, removeElementAt, removeElementRange
 
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

removeRowAt

org.w3c.dom.Element removeRowAt(int row)
Removes the specified row element.

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

removeRowRange

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

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

removeAllRows

void removeAllRows()
Removes all row elements. The table is now empty.


moveRow

void moveRow(int start,
             int end,
             int to)
Moves one or more row elements from the inclusive range start to end to the to position in the table. After the move, the row element that was at index start will be at index to.

The algorithm is explained in ElementListBase.moveElement(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

getRowCount

int getRowCount()
Returns the number of rows.

Returns:
the number of rows.

getElementRows

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

Returns:
the element array.

getRowElementAt

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

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

getFirstRowElement

org.w3c.dom.Element getFirstRowElement()
Returns the first row element (row at position 0).

Returns:
the first row element or null is the table is empty.

getLastRowElement

org.w3c.dom.Element getLastRowElement()
Returns the last row element (row at position length - 1).

Returns:
the last row element or null is the table is empty.

indexOfRowElement

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

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

lastIndexOfRowElement

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

The result must be the same as indexOfRowElement(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 row list.

getRowElementFromNode

org.w3c.dom.Element getRowElementFromNode(org.w3c.dom.Node node)
Returns the row element of the table containing the specified node. If the node is itself a row element, self is returned.

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

getRowListElementInfoAt

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

Parameters:
index - index of the row.
Returns:
the object info of the specified row element. Null if index is out of range.
See Also:
getRowListElementInfoFromNode(Node)

getRowListElementInfoFromNode

ListElementInfo getRowListElementInfoFromNode(org.w3c.dom.Node node)
Returns an object info of the row element containing the specified node (or the node is itself a row element).

Parameters:
node - the node to search for.
Returns:
the object info of the matched row element. Null if this node is not contained by the table.
See Also:
getRowElementFromNode(Node)

getTableCellElementInfoFromNode

TableCellElementInfo getTableCellElementInfoFromNode(org.w3c.dom.Node node)
Returns an object info of the cell element containing the specified node (or the node is itself a cell element of the table).

Parameters:
node - the node to search for.
Returns:
the object info of the matched cell element. Null if this node is not contained by the table.
See Also:
getTableCellElementInfoAt(int,int)

getTableCellElementInfoAt

TableCellElementInfo getTableCellElementInfoAt(int row,
                                               int column)
Returns an object info of the cell element specified by the row and column indexes.

Parameters:
row - row index of the cell element.
column - column index of the cell element.
Returns:
the object info of the matched cell element. Null if some index is out of range.
See Also:
getTableCellElementInfoFromNode(Node)

getCellElementsOfRow

org.w3c.dom.Element[] getCellElementsOfRow(int row)
Returns the cell elements of the specified row as an array.

Parameters:
row - the row index.
Returns:
the cell element array or null if index is out of range.

getCellElementAt

org.w3c.dom.Element getCellElementAt(int row,
                                     int column)
Returns the cell element at the specified row and column.

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

removeColumnAt

void removeColumnAt(int column)
Removes the specified column.

Parameters:
column - index of the column to remove.

removeAllColumns

void removeAllColumns()
Removes all columns. The table remains as a row list with no cells.


moveColumn

void moveColumn(int columnIndex,
                int newIndex)
Moves the column at columnIndex to newIndex. The old column at columnIndex will now be found at newIndex. The column that used to be at newIndex is shifted left or right to make room. This will not move any columns if columnIndex equals newIndex.

Parameters:
columnIndex - the index of the column to be moved
newIndex - new index to move the column

getCellElementsOfColumn

org.w3c.dom.Element[] getCellElementsOfColumn(int column)
Returns the cell elements of the specified column as an array.

Parameters:
column - the column index.
Returns:
the cell element array or null if index is out of range..


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