|
Apache JMeter | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.jorphan.collections.Data
public class Data
Use this class to store database-like data. This class uses rows and columns to organize its data. It has some convenience methods that allow fast loading and retrieval of the data into and out of string arrays. It is also handy for reading CSV files. WARNING: the class assumes that column names are unique, but does not enforce this.
Constructor Summary | |
---|---|
Data()
Constructor - takes no arguments. |
Method Summary | |
---|---|
void |
addColumnValue(String column,
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(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(String column,
Object value)
Returns the row number where a certain value is. |
String[] |
getColumn(String columnName)
This method will retrieve every entry in a certain column. |
List<Object> |
getColumnAsObjectArray(String columnName)
This method will retrieve every entry in a certain column. |
Object |
getColumnValue(int column)
Gets the value in the current row of the given column. |
Object |
getColumnValue(int column,
int row)
|
Object |
getColumnValue(String column)
Gets the value in the current row of the given column. |
int |
getCurrentPos()
Get the number of the current row. |
String[] |
getDataAsText()
Returns all the data in the Data set as an array of strings. |
static Data |
getDataFromResultSet(ResultSet rs)
Gets a Data object from a ResultSet. |
int |
getHeaderCount()
|
String[] |
getHeaders()
Returns a String array of the column headers. |
boolean |
hasHeader(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(String oldHeader,
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,
List<?> data)
|
void |
setColumnData(String colName,
Object value)
Sets the data for every row in the column. |
void |
setColumnValue(String column,
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(String[] contents,
String delimiter)
Use this method to set the entire data set. |
void |
setHeaders(String[] h)
Sets the headers for the data set. |
void |
setLine(String[] line)
Sets a row of data using an array of strings as input. |
void |
setLine(String[] line,
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(String column,
boolean asc)
Sorts the data using a given row as the sorting criteria. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Data()
Method Detail |
---|
public void replaceHeader(String oldHeader, 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(String column, boolean asc)
column
- name of column to use as sorting criteria.asc
- boolean value indicating whether to sort ascending or
descending. True for asc, false for desc. Currently this
feature is not enabled and all sorts are asc.public int size()
public void addColumnValue(String column, Object value)
column
- the name of the column to set.value
- value to set into column.public int findValue(String column, Object value)
column
- column to be searched for value.value
- object in Search of.
public void setColumnValue(String column, Object value)
column
- the name of the column to set.value
- value to set into column.public boolean hasHeader(String column)
column
- Name of column header to check for.
public boolean next()
public static Data getDataFromResultSet(ResultSet rs) throws SQLException
rs
- ResultSet passed in from a database query
SQLException
public boolean previous()
public void reset()
public Object getColumnValue(String column)
column
- name of the column.
public Object getColumnValue(int column)
column
- index of the column (starts at 0).
public Object getColumnValue(int column, int row)
public void removeColumn(int col)
public void setHeaders(String[] h)
h
- array of strings representing the column headers.
these must be distinct - duplicates will cause incorrect behaviourpublic String[] getHeaders()
public int getHeaderCount()
public List<Object> getColumnAsObjectArray(String columnName)
columnName
- name of the column.
public String[] getColumn(String columnName)
columnName
- name of the column.
public void setData(String[] contents, 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(String colName, Object value)
public void setColumnData(int col, List<?> data)
public void addHeader(String s)
s
- name of header.public void setLine(String[] line)
line
- array of strings representing column values.public void setLine(String[] line, 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 String[] getDataAsText()
public String toString()
toString
in class Object
|
Apache JMeter | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |