/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008 Sun Microsystems, Inc.
*/
/**
* A class which can be used to construct tables of information to be
* displayed in a terminal. Once built the table can be output using a
* {@link TableSerializer}.
*/
public final class TableBuilder {
// The current column number in the current row where 0 represents
// the left-most column in the table.
// The current with of each column.
// The list of column headings.
// The current number of rows in the table.
// The list of table rows.
// The linked list of sort keys comparators.
// The linked list of sort keys.
// The current number of columns in the table.
/**
* Creates a new table printer.
*/
public TableBuilder() {
// No implementation required.
}
/**
* Adds a table sort key. The table will be sorted according to the
* case-insensitive string ordering of the cells in the specified
* column.
*
* @param column
* The column which will be used as a sort key.
*/
}
/**
* Adds a table sort key. The table will be sorted according to the
* provided string comparator.
*
* @param column
* The column which will be used as a sort key.
* @param comparator
* The string comparator.
*/
}
/**
* Appends a new blank cell to the current row.
*/
public void appendCell() {
appendCell("");
}
/**
* Appends a new cell to the current row containing the provided
* boolean value.
*
* @param value
* The boolean value.
*/
}
/**
* Appends a new cell to the current row containing the provided
* byte value.
*
* @param value
* The byte value.
*/
}
/**
* Appends a new cell to the current row containing the provided
* char value.
*
* @param value
* The char value.
*/
}
/**
* Appends a new cell to the current row containing the provided
* double value.
*
* @param value
* The double value.
*/
}
/**
* Appends a new cell to the current row containing the provided
* float value.
*
* @param value
* The float value.
*/
}
/**
* Appends a new cell to the current row containing the provided
* integer value.
*
* @param value
* The boolean value.
*/
}
/**
* Appends a new cell to the current row containing the provided
* long value.
*
* @param value
* The long value.
*/
}
/**
* Appends a new cell to the current row containing the provided
* object value.
*
* @param value
* The object value.
*/
// Make sure that the first row has been created.
if (height == 0) {
startRow();
}
// Create the cell.
column++;
// Update statistics.
}
}
/**
* Appends a new blank column heading to the header row.
*/
public void appendHeading() {
}
/**
* Appends a new column heading to the header row.
*
* @param value
* The column heading value.
*/
// Update statistics.
}
}
/**
* Gets the width of the current row.
*
* @return Returns the width of the current row.
*/
public int getRowWidth() {
return column;
}
/**
* Gets the number of rows in table.
*
* @return Returns the number of rows in table.
*/
public int getTableHeight() {
return height;
}
/**
* Gets the number of columns in table.
*
* @return Returns the number of columns in table.
*/
public int getTableWidth() {
return width;
}
/**
* Prints the table in its current state using the provided table
* printer.
*
* @param printer
* The table printer.
*/
// Create a new printer instance.
// First sort the table.
if (rc != 0) {
return rc;
}
}
// Both rows are equal.
return 0;
}
};
// Now output the table.
for (int i = 0; i < width; i++) {
}
// Column headings.
}
// Table contents.
// Print each cell in the row, padding missing trailing cells.
for (int i = 0; i < width; i++) {
} else {
}
}
serializer.endRow();
}
}
/**
* Appends a new row to the table.
*/
public void startRow() {
height++;
column = 0;
}
}