|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.mockrunner.jdbc.StringValuesTable
public class StringValuesTable
A data structure providing tabular (row and column) access semantics to
items within. While applicable to several usages, the primary purpose is
(in conjunction with ArrayResultSetFactory
) to provide for easy
set up of unit test fixtures and assertion of outcomes with the same data
structures, without any need for external sources of test data.
Constructor Summary | |
---|---|
StringValuesTable(java.lang.String name,
java.lang.String[][] stringMatrix)
Creates a new StringValuesTable with the given name,
columns and string matrix. |
|
StringValuesTable(java.lang.String name,
java.lang.String[] columnNames,
java.lang.String[][] stringMatrix)
Creates a new StringValuesTable with the given name,
columns and string matrix. |
Method Summary | |
---|---|
java.lang.String[] |
getColumn(int columnNumber)
Returns the contents of the given column. |
java.lang.String[] |
getColumn(java.lang.String columnName)
Returns the contents of the given column. |
java.lang.String[] |
getColumnNames()
Returns the column names. |
java.lang.String |
getItem(int rowNumber,
int columnNumber)
Returns the item found in the string matrix at the given coordinate. |
java.lang.String |
getItem(int rowNumber,
java.lang.String columnName)
Returns the item found in the string matrix at the given coordinate. |
java.lang.String |
getName()
Returns the table name. |
int |
getNumberOfColumns()
Returns the number of columns found in the string matrix for this StringValuesTable . |
int |
getNumberOfRows()
Returns the number of rows found in the string matrix for this StringValuesTable . |
java.lang.String[] |
getRow(int rowNumber)
Returns the elements of the given row. |
java.lang.String[][] |
getStringMatrix()
Returns the tabular data for this StringValuesTable . |
boolean |
isValidColumnName(java.lang.String columnName)
Returns true if the given column name is valid for this
StringValuesTable ; returns false
otherwise. |
boolean |
isValidColumnNumber(int columnNumber)
Returns true if the given column number is valid for this
StringValuesTable ; returns false
otherwise. |
boolean |
isValidRowNumber(int row)
Returns true if the given row number is valid for this
StringValuesTable ; returns false
otherwise. |
static java.lang.String[] |
verifyColumnNames(java.lang.String[] columnNames,
java.lang.String[][] stringMatrix)
Returns the given array if it is found to indeed be valid according to the published contract. |
static java.lang.String[][] |
verifyStringMatrix(java.lang.String[][] stringMatrix)
Returns the given matrix if it is found to indeed be valid according to the published contract. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StringValuesTable(java.lang.String name, java.lang.String[][] stringMatrix)
StringValuesTable
with the given name,
columns and string matrix.
name
- the table name. This argument cannot be null
and must contain at least 1
non-blank character.stringMatrix
- the string matrix. This argument cannot be null
,
must not contain any null values, and each array in the matrix
must contain the same number of elements as the first (stringMatrix[0].length == stringMatrix[n].length
for any given valid row number, n
). Further,
this matrix must, at a minimum represent 1
row
and 1
column of items (stringMatrix.length >= 1
,
and stringMatrix[0].length >= 1
).public StringValuesTable(java.lang.String name, java.lang.String[] columnNames, java.lang.String[][] stringMatrix)
StringValuesTable
with the given name,
columns and string matrix.
name
- the table name. This argument cannot be null
and must contain at least 1
non-blank character.columnNames
- the names for the columns in this
StringValuesTable
. This argument may be null
if no column names
are desired, but if a non-null
array reference
is given, the array cannot contain any null
nor
duplicate elements, and must have the same number of elements
as there are columns in the given string matrix (stringMatrix[n]
for any given valid row number, n
).stringMatrix
- the string matrix. This argument cannot be null
,
must not contain any null values, and each array in the matrix
must contain the same number of elements as the first (stringMatrix[0].length == stringMatrix[n].length
for any given valid row number, n
). Further,
this matrix must, at a minimum represent 1
row
and 1
column of items (stringMatrix.length >= 1
,
and stringMatrix[0].length >= 1
).Method Detail |
---|
public java.lang.String[] getColumn(java.lang.String columnName)
columnName
- the name of the desired column. This argument cannot be
null
and must be a valid column for this
StringValuesTable
.
public java.lang.String[] getColumn(int columnNumber)
columnNumber
- the index of the desired column (1
-based).
This argument must be a valid column index for this
StringValuesTable
.
public java.lang.String[] getColumnNames()
public java.lang.String getItem(int rowNumber, java.lang.String columnName)
rowNumber
- the number of the desired row (1
-based). This
argument must be a valid row number for this
StringValuesTable
.columnName
- the name of the desired column. This argument cannot be
null
and must be a valid column for this
StringValuesTable
.
public java.lang.String getItem(int rowNumber, int columnNumber)
rowNumber
- the number of the desired row (1
-based). This
argument must be a valid row number for this
StringValuesTable
.columnNumber
- the index of the desired column (1
-based).
This argument must be a valid column index for this
StringValuesTable
.
public java.lang.String getName()
public int getNumberOfColumns()
StringValuesTable
.
StringValuesTable
.public int getNumberOfRows()
StringValuesTable
.
StringValuesTable
.public java.lang.String[] getRow(int rowNumber)
rowNumber
- the number of the desired row (1
-based). This
argument must be a valid row number for this
StringValuesTable
.
public boolean isValidColumnName(java.lang.String columnName)
true
if the given column name is valid for this
StringValuesTable
; returns false
otherwise.
columnName
- the column name to verify.
true
if the given column name is valid for this
StringValuesTable
.public boolean isValidColumnNumber(int columnNumber)
true
if the given column number is valid for this
StringValuesTable
; returns false
otherwise.
columnNumber
- the column number to verify.
true
if the given column number is valid for this
StringValuesTable
.public boolean isValidRowNumber(int row)
true
if the given row number is valid for this
StringValuesTable
; returns false
otherwise.
row
- the row number to verify.
true
if the given index is valid for this
StringValuesTable
.public java.lang.String[][] getStringMatrix()
StringValuesTable
.
StringValuesTable
.public static java.lang.String[] verifyColumnNames(java.lang.String[] columnNames, java.lang.String[][] stringMatrix)
public static java.lang.String[][] verifyStringMatrix(java.lang.String[][] stringMatrix)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |