public class Data
extends java.lang.Object
implements java.io.Serializable
Constructor and Description |
---|
Data()
Constructor - takes no arguments.
|
Modifier and Type | Method and Description |
---|---|
void |
addColumnValue(java.lang.String column,
java.lang.Object value)
Adds a value into the Data set at the current row, using a column name to
find the column in which to insert the new value.
|
void |
addHeader(java.lang.String s)
Adds a header name to the Data object.
|
void |
addRow() |
void |
append(Data d)
Adds the rows of the given Data object to this Data object.
|
int |
findValue(java.lang.String column,
java.lang.Object value)
Returns the row number where a certain value is.
|
java.lang.String[] |
getColumn(java.lang.String columnName)
This method will retrieve every entry in a certain column.
|
java.util.List<java.lang.Object> |
getColumnAsObjectArray(java.lang.String columnName)
This method will retrieve every entry in a certain column.
|
java.lang.Object |
getColumnValue(int column)
Gets the value in the current row of the given column.
|
java.lang.Object |
getColumnValue(int column,
int row) |
java.lang.Object |
getColumnValue(java.lang.String column)
Gets the value in the current row of the given column.
|
int |
getCurrentPos()
Get the number of the current row.
|
java.lang.String[] |
getDataAsText()
Returns all the data in the Data set as an array of strings.
|
int |
getHeaderCount() |
java.lang.String[] |
getHeaders()
Returns a String array of the column headers.
|
boolean |
hasHeader(java.lang.String column)
Checks to see if a column exists in the Data object.
|
boolean |
next()
Sets the current position of the Data set to the next row.
|
boolean |
previous()
Sets the current position of the Data set to the previous row.
|
void |
removeColumn(int col) |
void |
removeRow()
Removes the current row.
|
void |
removeRow(int index) |
void |
replaceHeader(java.lang.String oldHeader,
java.lang.String newHeader)
Replaces the given header name with a new header name.
|
void |
reset()
Resets the current position of the data set to just before the first
element.
|
void |
setColumnData(int col,
java.util.List<?> data) |
void |
setColumnData(java.lang.String colName,
java.lang.Object value)
Sets the data for every row in the column.
|
void |
setColumnValue(java.lang.String column,
java.lang.Object value)
Sets the value in the Data set at the current row, using a column name to
find the column in which to insert the new value.
|
void |
setCurrentPos(int r)
Sets the current pos.
|
void |
setData(java.lang.String[] contents,
java.lang.String delimiter)
Use this method to set the entire data set.
|
void |
setHeaders(java.lang.String[] h)
Sets the headers for the data set.
|
void |
setLine(java.lang.String[] line)
Sets a row of data using an array of strings as input.
|
void |
setLine(java.lang.String[] line,
java.lang.String deflt)
Sets a row of data using an array of strings as input.
|
int |
size()
Gets the number of rows in the Data object.
|
void |
sort(java.lang.String column)
Sorts the data using a given row as the sorting criteria.
|
java.lang.String |
toString() |
public void replaceHeader(java.lang.String oldHeader, java.lang.String newHeader)
oldHeader
- Old header name.newHeader
- New header name.public void append(Data d)
d
- data object to be appended to this onepublic int getCurrentPos()
public void removeRow()
public void removeRow(int index)
public void addRow()
public void setCurrentPos(int r)
r
- position to set to.public void sort(java.lang.String column)
column
- name of column to use as sorting criteria.public int size()
public void addColumnValue(java.lang.String column, java.lang.Object value)
column
- the name of the column to set.value
- value to set into column.public int findValue(java.lang.String column, java.lang.Object value)
column
- column to be searched for value.value
- object in Search of.public void setColumnValue(java.lang.String column, java.lang.Object value)
column
- the name of the column to set.value
- value to set into column.public boolean hasHeader(java.lang.String column)
column
- Name of column header to check for.public boolean next()
public boolean previous()
public void reset()
public java.lang.Object getColumnValue(java.lang.String column)
column
- name of the column.public java.lang.Object getColumnValue(int column)
column
- index of the column (starts at 0).public java.lang.Object getColumnValue(int column, int row)
public void removeColumn(int col)
public void setHeaders(java.lang.String[] h)
h
- array of strings representing the column headers.
these must be distinct - duplicates will cause incorrect behaviourpublic java.lang.String[] getHeaders()
public int getHeaderCount()
public java.util.List<java.lang.Object> getColumnAsObjectArray(java.lang.String columnName)
columnName
- name of the column.public java.lang.String[] getColumn(java.lang.String columnName)
columnName
- name of the column.public void setData(java.lang.String[] contents, java.lang.String delimiter)
contents
- array of strings, the first element is a list of the column
headers, the next elements each represent a single row of
data.delimiter
- the delimiter character that separates columns within the
string array.public void setColumnData(java.lang.String colName, java.lang.Object value)
colName
- name of the columnvalue
- value to be setpublic void setColumnData(int col, java.util.List<?> data)
public void addHeader(java.lang.String s)
s
- name of header.public void setLine(java.lang.String[] line)
line
- array of strings representing column values.public void setLine(java.lang.String[] line, java.lang.String deflt)
line
- array of strings representing column values.deflt
- default value to be placed in data if line is not as long as
headers.public java.lang.String[] getDataAsText()
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 1998-2019 Apache Software Foundation. All Rights Reserved.