private Length orphanContentLimit;
/** collection of columns in this table */
- protected List columns = new ArrayList();
+ private List columns = new ArrayList();
/** helper variables for implicit column-numbering */
private int columnIndex = 1;
return columns;
}
+ /**
+ * Returns the column at the given index, if any.
+ *
+ * @param index index of the column to be retrieved, 0-based
+ * @return the corresponding column, or null if their is no column at the given index
+ */
+ TableColumn getColumn(int index) {
+ if (index >= columns.size()) {
+ return null;
+ } else {
+ return (TableColumn) columns.get(index);
+ }
+ }
+
+ int getNumberOfColumns() {
+ return columns.size();
+ }
+
/** @return the body for the table-header. */
public TableBody getTableHeader() {
return tableHeader;
FObj fobj = (FObj) super.clone(parent, removeChildren);
if (removeChildren) {
Table t = (Table) fobj;
- t.columns = null;
+ t.columns = new ArrayList();
t.tableHeader = null;
t.tableFooter = null;
}
Attributes attlist, PropertyList pList)
throws FOPException {
if (!inMarker()) {
- if (getTable().columns != null) {
- int cap = getTable().columns.size();
- pendingSpans = new java.util.ArrayList(cap);
- usedColumnIndices = new java.util.BitSet(cap);
- } else {
- pendingSpans = new java.util.ArrayList();
- usedColumnIndices = new java.util.BitSet();
+ int cap = getTable().getNumberOfColumns();
+ if (cap == 0) {
+ cap = 10; // Default value for ArrayList
}
+ pendingSpans = new java.util.ArrayList(cap);
+ usedColumnIndices = new java.util.BitSet(cap);
setNextColumnIndex();
}
super.processNode(elementName, locator, attlist, pList);
if (child.getNameId() == FO_TABLE_ROW) {
pendingSpans = ((TableRow) child).pendingSpans;
} else if (pendingSpans == null) {
- if (getTable().columns != null) {
- List tableCols = getTable().columns;
- pendingSpans = new java.util.ArrayList(tableCols.size());
- for (int i = tableCols.size(); --i >= 0;) {
+ int colNumber = getTable().getNumberOfColumns();
+ if (colNumber == 0) {
+ pendingSpans = new java.util.ArrayList();
+ } else {
+ pendingSpans = new java.util.ArrayList(colNumber);
+ for (int i = colNumber; --i >= 0;) {
pendingSpans.add(null);
}
- } else {
- pendingSpans = new java.util.ArrayList();
}
}
}
//the index is not assigned to any
//column, increment further until the next
//index occupied by a column...
- if (getTable().columns != null) {
- while (columnIndex <= getTable().columns.size()
- && !getTable().isColumnNumberUsed(columnIndex) ) {
- columnIndex++;
- }
+ while (columnIndex <= getTable().getNumberOfColumns()
+ && !getTable().isColumnNumberUsed(columnIndex) ) {
+ columnIndex++;
}
}
}
for (int i = colNr; i < colNr + colSpan; ++i) {
- if (t.columns.size() < i
- || t.columns.get(i - 1) == null) {
+ TableColumn col = t.getColumn(i - 1);
+ if (col == null) {
t.addDefaultColumn(colWidth,
i == colNr
? cell.getColumnNumber()
: 0);
} else {
- TableColumn col =
- (TableColumn) t.columns.get(i - 1);
if (!col.isDefaultColumn()
&& colWidth != null) {
col.setColumnWidth(colWidth);
*/
int startIndex = columnIndex - 1;
int endIndex = startIndex + colSpan;
- if (getTable().columns != null) {
- List cols = getTable().columns;
- int tmpIndex = endIndex;
- for (i = startIndex; i <= tmpIndex; ++i) {
- if (i < cols.size() && cols.get(i) == null) {
- endIndex++;
- }
+ List cols = getTable().getColumns();
+ int tmpIndex = endIndex;
+ for (i = startIndex; i <= tmpIndex; ++i) {
+ if (i < cols.size() && cols.get(i) == null) {
+ endIndex++;
}
}
flagColumnIndices(startIndex, endIndex);