H - column-header type. to use the binarySearch of Arrays, H must implement ComparableID - row identifier typepublic class TableList<H extends Comparable<H>,ID> extends Object implements Serializable
indexOf(Object).| Modifier and Type | Field and Description |
|---|---|
static String |
CELL_ROOT |
protected static String |
DIV
used by dumps
|
static String |
FILE_EXT |
protected H[] |
header |
protected Class<H> |
headerType |
protected static String |
LF |
protected String |
name |
protected List<de.tsl2.nano.collection.Row<ID>> |
rows |
| Modifier | Constructor and Description |
|---|---|
protected |
TableList() |
protected |
TableList(Class<H> headerType,
H... header)
base constructor
|
|
TableList(Class<H> headerType,
int columnCount)
constructor to create any columns
|
|
TableList(H... header)
constructor
|
|
TableList(String name,
int columnCount)
column headers will be of type String.
|
|
TableList(String name,
int cols,
int rows) |
| Modifier and Type | Method and Description |
|---|---|
TableList<H,ID> |
add(ID rowId,
Object... values)
adds a new row to the table. if no values are given, an empty row will be added. if some values were given, but
not the size of the header, an exception will be thrown
|
TableList<H,ID> |
add(int index,
ID rowId,
Object... values)
adds a new row to the table. if no values are given, an empty row will be added. if some values were given, but
not the size of the header, an exception will be thrown
|
TableList<H,ID> |
addAll(boolean includedRowIds,
List values) |
TableList<H,ID> |
addAll(boolean includedRowIds,
Object... values)
addAll
|
protected void |
checkColumnSize(int column) |
protected void |
checkRowSize(int row) |
protected void |
checkRowSize(Object... values) |
protected void |
checkSizes(int row,
int column) |
protected static Object |
createDefaultHeader(Object source)
wraps the given source string into a default header instance of this class. this implementatino simply returns
the source string. each extension class shuold provide its own 'createDefaultHeader(string)'
|
protected de.tsl2.nano.collection.Row<ID> |
createRow(int index,
Object... values) |
protected ID |
createRowID(int i) |
String |
dump() |
String |
dump(String div,
boolean resolve)
dump
|
protected void |
dumpValues(StringBuilder buf,
String div,
boolean resolve) |
<T extends TableList<H,ID>> |
fill(Class<ID> idType,
int rowCount)
pre fill (e.g. a fixed sized table) with empty values
|
<T extends TableList<H,ID>> |
fill(ID... ids)
pre fill the table - all values will be null
|
<T extends TableList<H,ID>> |
fill(int rowCount) |
Object[] |
get(ID rowId)
gets row content directly. be careful using that method from outside. the base method
get(int, int) is
not used. |
<S> S[] |
get(ID rowId,
Class<S> arrayType)
convenience to get a row wrapped into a known object type. delegates to
get(Object). no check will be
done for the compatibility of the given array type! |
Object |
get(ID row,
H column)
get
|
Object |
get(ID rowId,
int column)
get cell value
|
Object |
get(int row,
H column)
get
|
Object |
get(int row,
int column)
base implementation of getting a cell value. overwrite this method to do extended formatting.
|
int |
getColumnCount()
getColumnCount
|
String[] |
getColumns()
getColumns
|
H[] |
getHeader() |
String |
getName() |
int |
getRowCount() |
ID |
getRowID(int row)
getRowID
|
int |
indexOf(ID rowId)
like in
List. works only, if row ID type implements its equals(Object) correctly. |
static <T> T |
load(String file) |
static <T extends TableList> |
load(String file,
Class<T> type) |
static <T extends TableList> |
load(String file,
Class<T> type,
String div) |
void |
remove(ID rowId)
remove row
|
de.tsl2.nano.collection.Row<ID> |
remove(int index)
remove row at given index
|
void |
save(String relDir) |
TableList<H,ID> |
set(ID rowID,
H column,
Object value)
resets an existing value of a given row and column of the table.
|
TableList<H,ID> |
set(ID rowID,
int column,
Object value)
resets an existing value of a given row and column of the table.
|
<S> TableList<H,ID> |
set(ID rowId,
S... values)
convenience to refresh the values of the given row (the table-value instances wont change!).
|
TableList<H,ID> |
set(int row,
H column,
Object value)
resets an existing value of a given row and column of the table.
|
TableList<H,ID> |
set(int index,
ID rowId,
Object... values)
resets an existing row of the table. if no values are given, an empty row will be added. if some values were
given, but not the size of the header, an exception will be thrown
|
TableList<H,ID> |
set(int row,
int column,
Object value)
resets an existing value of a given row and column of the table.
|
int |
size()
size
|
String |
toString() |
protected String name
protected Class<H extends Comparable<H>> headerType
protected H extends Comparable<H>[] header
protected static final String DIV
protected static final String LF
public static final String FILE_EXT
public static final String CELL_ROOT
protected TableList()
public TableList(String name, int cols, int rows)
public TableList(String name, int columnCount)
TableList(Class, int)public TableList(Class<H> headerType, int columnCount)
headerType - header type. if String, the column names will have their index as column-text. On
default, the default constructor of the header type will be called to create an instance.columnCount - count of columns to createpublic TableList(H... header)
header - array columns. must not be null and must contain at least one element!public <T extends TableList<H,ID>> T fill(Class<ID> idType, int rowCount)
idType - row identifier typerowCount - rows to fillpublic <T extends TableList<H,ID>> T fill(ID... ids)
ids - row identifierspublic H[] getHeader()
public String[] getColumns()
public TableList<H,ID> addAll(boolean includedRowIds, Object... values)
includedRowIds - if true, row-ids are included in the valuesvalues - to be splitted and packed into col/rowsprotected ID createRowID(int i)
public TableList<H,ID> add(ID rowId, Object... values)
rowId - (optional) row identifiervalues - row valuespublic TableList<H,ID> add(int index, ID rowId, Object... values)
index - row indexrowId - (optional) row identifiervalues - row valuespublic TableList<H,ID> set(int index, ID rowId, Object... values)
index - row indexrowId - (optional) new row identifiervalues - row valuespublic <S> TableList<H,ID> set(ID rowId, S... values)
get(Object, Class).no check will be done for the compatibility of the
given array type!rowId - row identifiervalues - new values to be copied to the table rowpublic TableList<H,ID> set(int row, int column, Object value)
row - index indexcolumn - column indexvalues - row valuespublic TableList<H,ID> set(int row, H column, Object value)
row - index indexcolumn - column indexvalues - row valuespublic TableList<H,ID> set(ID rowID, int column, Object value)
row - index indexcolumn - column indexvalues - row valuespublic TableList<H,ID> set(ID rowID, H column, Object value)
row - index indexcolumn - column indexvalues - row valuespublic void remove(ID rowId)
rowId - row identifierpublic de.tsl2.nano.collection.Row<ID> remove(int index)
index - row indexpublic Object get(int row, int column)
rowId - row identifercolumn - column identifierNullPointerException - if rowId couldn't be foundpublic Object get(ID row, H column)
rowId - row identifercolumn - column identifierNullPointerException - if rowId couldn't be foundpublic Object get(int row, H column)
row - row indexcolumn - column identifierpublic ID getRowID(int row)
row - row indexpublic Object[] get(ID rowId)
get(int, int) is
not used.rowId - row identifierarrType - array type. this must be the type, you gave on constructing this class! the value-array will not
be changed!public <S> S[] get(ID rowId, Class<S> arrayType)
get(Object). no check will be
done for the compatibility of the given array type! the returned array is a copy of th origin table row. please
see set(Object, Object...) to refresh your changed values.S - array type to pack the given row into.rowId - row values to be returnedarrayType - array typepublic Object get(ID rowId, int column)
rowId - row identifercolumn - column identifierArrayIndexOutOfBoundsException - if rowId couldn't be foundpublic int indexOf(ID rowId)
List. works only, if row ID type implements its equals(Object) correctly.rowId - public int size()
public int getColumnCount()
public int getRowCount()
protected final void checkSizes(int row,
int column)
protected final void checkRowSize(int row)
protected final void checkColumnSize(int column)
protected final void checkRowSize(Object... values)
public void save(String relDir)
public String getName()
public static <T> T load(String file)
protected static Object createDefaultHeader(Object source)
source - header to be wrappedpublic String dump()
protected void dumpValues(StringBuilder buf, String div, boolean resolve)
Copyright © 2012–2018. All rights reserved.