001: /*
002: ItsNat Java Web Application Framework
003: Copyright (C) 2007 Innowhere Software Services S.L., Spanish Company
004: Author: Jose Maria Arranz Santamaria
005:
006: This program is free software: you can redistribute it and/or modify
007: it under the terms of the GNU Affero General Public License as published by
008: the Free Software Foundation, either version 3 of the License, or
009: (at your option) any later version. See the GNU Affero General Public
010: License for more details. See the copy of the GNU Affero General Public License
011: included in this program. If not, see <http://www.gnu.org/licenses/>.
012: */
013:
014: package org.itsnat.core.domutil;
015:
016: import org.w3c.dom.Element;
017:
018: /**
019: * Represents an integer indexed DOM Element table, row elements and cell elements can have different
020: * tag names (the meaning of "free").
021: *
022: * <p>The interface inherits from {@link ElementListFree} and <code>java.util.List</code>
023: * indirectly and supports both types of iterators. <code>List</code> and <code>Iterator</code> methods accept
024: * and return DOM Element objects. They see the table as a list of rows.</p>
025: *
026: * <p>The table can work in master and slave modes, see
027: * {@link ElementListFree#isMaster()}. If in master mode direct DOM
028: * structural changes (add/remove/replace a row, column, cell) must be avoided.
029: * </p>
030: *
031: * <p>In a "free" table the number of columns may not be the same between rows.</p>
032: *
033: * @see org.itsnat.core.ItsNatDocument#createElementTableFree(Element,boolean)
034: * @author Jose Maria Arranz Santamaria
035: */
036: public interface ElementTableFree extends ElementTableBase,
037: ElementListFree {
038: /**
039: * Adds a new row element at the end of the table.
040: *
041: * <p>If the new row element is already in the table a deep clone
042: * (calling <code>Node.cloneNode(boolean deep)</code>) is inserted. This avoids
043: * an indirect delete by DOM.</p>
044: *
045: * @param elem the new row element.
046: * @see #insertRowAt(int,org.w3c.dom.Element)
047: */
048: public void addRow(Element elem);
049:
050: /**
051: * Inserts a new row element at the specified position.
052: *
053: * <p>If the new row element is already in the table a deep clone
054: * (calling <code>Node.cloneNode(boolean deep)</code>) is inserted. This avoids
055: * an indirect delete by DOM.</p>
056: *
057: * @param row row index of the element.
058: * @param elem the new element.
059: * @see #addRow(Element)
060: */
061: public void insertRowAt(int row, Element elem);
062:
063: /**
064: * Replaces the specified row element with a new one.
065: *
066: * <p>If the new row element is already in the list a deep clone
067: * (calling <code>Node.cloneNode(boolean deep)</code>) is used to replace the element in that
068: * position. This avoids an indirect delete by DOM.</p>
069: *
070: * @param row row index of the element.
071: * @param elem the new element.
072: * @return the element replaced.
073: * @see #insertRowAt(int,Element)
074: * @see #getRowElementAt(int)
075: */
076: public Element setRowAt(int row, Element elem);
077:
078: /**
079: * Clears the specified row and fills again with new elements. The number of columns of the row may change.
080: *
081: * <p>If a new cell element is already in the list a deep clone
082: * (calling <code>Node.cloneNode(boolean deep)</code>) is used to replace the element in that
083: * position. This avoids an indirect delete by DOM.</p>
084: *
085: * @param cells new cell elements.
086: * @return the cell elements replaced.
087: * @see #getCellElementsOfRow(int)
088: */
089: public Element[] setCellElementsOfRow(int row, Element[] cells);
090:
091: /**
092: * Replaces the specified cell element with a new one.
093: *
094: * <p>If the new cell element is already in the list a deep clone
095: * (calling <code>Node.cloneNode(boolean deep)</code>) is used to replace the element in that
096: * position. This avoids an indirect delete by DOM.</p>
097: *
098: * @param row row index of the cell element.
099: * @param column column index of the cell element.
100: * @param elem the new element.
101: * @return the element replaced.
102: * @see #getCellElementAt(int,int)
103: * @see #setRowAt(int,Element)
104: */
105: public Element setCellElementAt(int row, int column, Element elem);
106:
107: /**
108: * Returns the cell elements of the specified row as an element list.
109: * Modifications performed in this list affects to the original table.
110: *
111: * @param row the row index.
112: * @return the cell element list.
113: */
114: public ElementListFree getCellElementListOfRow(int row);
115:
116: /**
117: * Adds a new column at the end of columns.
118: *
119: * <p>If a new cell element is already in the table a deep clone
120: * (calling <code>Node.cloneNode(boolean deep)</code>) is inserted. This avoids
121: * an indirect delete by DOM.</p>
122: *
123: * @param cells the cells of the new column.
124: * @see #insertColumnAt(int,org.w3c.dom.Element[])
125: */
126: public void addColumn(Element[] cells);
127:
128: /**
129: * Inserts a new column at the specified position.
130: *
131: * <p>If a new cell element is already in the table a deep clone
132: * (calling <code>Node.cloneNode(boolean deep)</code>) is inserted. This avoids
133: * an indirect delete by DOM.</p>
134: *
135: * @param column index of column to insert.
136: * @param cells the cells of the new column.
137: * @see #addColumn(Element[])
138: */
139: public void insertColumnAt(int column, Element[] cells);
140:
141: /**
142: * Replaces the specified column with a new one.
143: *
144: * <p>If a new cell element is already in the list a deep clone
145: * (calling <code>Node.cloneNode(boolean deep)</code>) is used to replace the element in that
146: * position. This avoids an indirect delete by DOM.</p>
147: *
148: * @param column index of column to replace.
149: * @param cells the new cells of the column.
150: * @return the cell elements replaced.
151: * @see #insertColumnAt(int,Element[])
152: * @see #getCellElementsOfColumn(int)
153: */
154: public Element[] setCellElementsOfColumn(int column, Element[] cells);
155:
156: }
|