|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jqurantree.analysis.AnalysisTable
public class AnalysisTable
The AnalyisTable
is a general purpose class which may be used to
tabulate, sort, group and export results. The table organizes a set of cells
into rows and columns, with each column having a unique column name. The
analysis table may be used as follows:
Once the table has been populated, the following operations may be performed:
Constructor Summary | |
---|---|
AnalysisTable(java.lang.String... columnNames)
Creates an empty analysis table with the specified columns and without any rows. |
Method Summary | |
---|---|
void |
add(java.lang.Object... values)
Adds a new row to the analysis table using of the specified values. |
int |
getColumnCount()
Gets the number of columns in the table. |
int |
getColumnIndex(java.lang.String columnName)
Gets the index of a column in the table, by column name. |
java.lang.String |
getColumnName(int columnIndex)
Gets the name of a column in the table, by column index. |
int |
getInteger(int rowIndex,
int columnIndex)
Converts the value of a cell to an int , given the cell's row
index and column index. |
int |
getInteger(int rowIndex,
java.lang.String columnName)
Converts the value of a cell to an int , given the cell's row
index and column name. |
int |
getRowCount()
Gets the number of rows in the table. |
java.lang.String |
getString(int rowIndex,
int columnIndex)
Converts the value of a cell to a string , given the cell's
row index and column index. |
java.lang.String |
getString(int rowIndex,
java.lang.String columnName)
Converts the value of a cell to a string , given the cell's
row index and column name. |
java.lang.Object |
getValue(int rowIndex,
int columnIndex)
Gets the value of a cell in the table, given the cell's row index and column index. |
java.lang.Object |
getValue(int rowIndex,
java.lang.String columnName)
Gets the value of a cell in the table, given the cell's row index and column name. |
AnalysisTable |
group(java.lang.String... columnNames)
Creates a new table by grouping this analysis table by the specified list of columns. |
java.util.Iterator<java.lang.Object[]> |
iterator()
Returns an iterator used to enumerate through all rows in
the table. |
void |
sort(java.lang.String columnName)
Sorts all rows in ascending order, by the specified column. |
void |
sort(java.lang.String columnName,
SortOrder direction)
Sorts all rows by a column, in the specified sort order. |
java.lang.String |
toString()
Converts the analysis table to a string . |
java.lang.String |
toString(int rowCount)
Converts the top rows of the analysis table to a string . |
void |
writeFile(java.lang.String filename)
Saves the contents of the analysis table to disk, by writing out a delimited file. |
void |
writeFile(java.lang.String filename,
char delimiter)
Saves the contents of the analysis table to disk, by writing out a delimited file. |
void |
writeFile(java.lang.String filename,
char delimiter,
int rowCount)
Saves the top rows of the analysis table to disk, by writing out a delimited file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public AnalysisTable(java.lang.String... columnNames)
columnNames
- an array of column names.Method Detail |
---|
public void add(java.lang.Object... values)
values
- the values that make up the row. The number of values
specified should match the number of columns in the table.public int getRowCount()
public int getColumnCount()
public java.lang.String getColumnName(int columnIndex)
columnIndex
- the zero-based index of the column.
public int getColumnIndex(java.lang.String columnName)
columnName
- the name of column.
public java.lang.Object getValue(int rowIndex, int columnIndex)
rowIndex
- the zero-based index of the row containing the cell.columnIndex
- the zero-based index of the column containing the cell.
public java.lang.Object getValue(int rowIndex, java.lang.String columnName)
rowIndex
- the zero-based index of the row containing the cell.columnName
- the name of the column containing the cell.
public int getInteger(int rowIndex, int columnIndex)
int
, given the cell's row
index and column index.
rowIndex
- the zero-based index of the row containing the cell.columnIndex
- the zero-based index of the column containing the cell.
public int getInteger(int rowIndex, java.lang.String columnName)
int
, given the cell's row
index and column name.
rowIndex
- the zero-based index of the row containing the cell.columnName
- the name of the column containing the cell.
public java.lang.String getString(int rowIndex, int columnIndex)
string
, given the cell's
row index and column index.
rowIndex
- the zero-based index of the row containing the cell.columnIndex
- the zero-based index of the column containing the cell.
public java.lang.String getString(int rowIndex, java.lang.String columnName)
string
, given the cell's
row index and column name.
rowIndex
- the zero-based index of the row containing the cell.columnName
- the name of the column containing the cell.
public java.lang.String toString()
string
. The table will be
correctly formatted and all columns will be aligned.
toString
in class java.lang.Object
public java.lang.String toString(int rowCount)
string
.
rowCount
- the number of rows to use when converting the table. This
value should be a positive number.
public void writeFile(java.lang.String filename)
filename
- the name of the file to write to.public void writeFile(java.lang.String filename, char delimiter)
filename
- the name of the file to write to.delimiter
- the delimiter character used to write the filepublic void writeFile(java.lang.String filename, char delimiter, int rowCount)
filename
- the name of the file to write to.delimiter
- the delimiter character used to write the filerowCount
- the number of rows to write to file. This value should be a
positive number.public java.util.Iterator<java.lang.Object[]> iterator()
iterator
used to enumerate through all rows in
the table.
iterator
in interface java.lang.Iterable<java.lang.Object[]>
iterator
.public void sort(java.lang.String columnName)
columnName
- the name of the column to sort by.public void sort(java.lang.String columnName, SortOrder direction)
columnName
- the name of the column to sort by.direction
- the order to sort the rows in, ascending or descending.public AnalysisTable group(java.lang.String... columnNames)
columnNames
- the list of columns to group by.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |