Data.Row

public class Data.Row
Hierarchy:
Object ⯈ Data.Row
Enclosing class:
Data

Contains one row of values.

Values are stored as nullable strings. The number of cells matches the number of headers in the enclosing Data. (TODO explain row referencing)

Summary

Instance Methods
int colCount ()
Get number of columns in the enclosing Data.
void copy (Data.Row dst, int begin, int end, int dstBegin)
Copy cell values to another row.
String[] copy (String[] dst)
Copy all cell values to another array.
void copy (String[] dst, int begin, int end, int dstBegin)
Copy cell values to another array.
String get (int index)
Get value of a cell by column index.
String get (String hdr)
Get cell value.
Boolean getBool (String hdr)
Get cell value as boolean.
Integer getInt (String hdr)
Get cell value as integer.
Double getNum (String hdr)
Get cell value as a double-precision real number.
void set (int index, Object v)
Update value of a cell by column index.
void set (String hdr, Object v)
Update cell value.
void update (String... vs)
Set multiple cell values at once.
Show all inherited methods (11 more)
protected native Object clone ()
Inherited from Object.
boolean equals (Object)
Inherited from Object.
protected void finalize ()
Inherited from Object.
final native Class<?> getClass ()
Inherited from Object.
native int hashCode ()
Inherited from Object.
final native void notify ()
Inherited from Object.
final native void notifyAll ()
Inherited from Object.
String toString ()
Inherited from Object.
final void wait ()
Inherited from Object.
final native void wait (long)
Inherited from Object.
final void wait (long, int)
Inherited from Object.

colCount

public int colCount ();

Get number of columns in the enclosing Data. (TODO explain row referencing)

Returns

number of columns

get

public String get (
	int index
);

Get value of a cell by column index. Use for faster access.

Parameters
index
column index
Returns

cell value

Throws
ArrayIndexOutOfBoundsException
if index is outside column range
See also

colCount(), get(String)

set

public void set (
	int index,
	Object v
);

Update value of a cell by column index. Use for faster access. The value of v is converted to String using Object.toString() unless v is null.

Parameters
index
column index
v
new value
Throws
ArrayIndexOutOfBoundsException
if index is outside column range
See also

colCount(), set(String, Object)

copy

public void copy (
	String[] dst,
	int begin,
	int end,
	int dstBegin
);

Copy cell values to another array.

Parameters
dst
destination array, cannot be null
begin
start index in this row
end
end index in this row (inclusive)
dstBegin
start index in destination array
Throws
NullPointerException
if dst is null
ArrayIndexOutOfBoundsException
if goes outside column range or dst range
See also

colCount()

copy

public String[] copy (
	String[] dst
);

Copy all cell values to another array.

Parameters
dst
destination array. If null, a new array is created and returned.
Returns

destination array

copy

public void copy (
	Data.Row dst,
	int begin,
	int end,
	int dstBegin
);

Copy cell values to another row.

Parameters
dst
destination row, cannot be null
begin
start index in this row
end
end index in this row (inclusive)
dstBegin
start index in destination row
Throws
NullPointerException
if dst is null
ArrayIndexOutOfBoundsException
if goes outside column range or dst range
See also

colCount()

get

public String get (
	String hdr
);

Get cell value.

Parameters
hdr
column name
Returns

cell value, which can be null

Throws
NoSuchElementException
column not found

getInt

public Integer getInt (
	String hdr
);

Get cell value as integer. Conversion is done by Integer.parseInt(String) and can throw a NumberFormatException; null is returned only if the cell value is null.

Parameters
hdr
column name
Returns

cell value, which can be null

Throws
NoSuchElementException
column not found
NumberFormatException
if the value is not null and does not contain a parsable integer.

getNum

public Double getNum (
	String hdr
);

Get cell value as a double-precision real number. Conversion is done by Double.parseDouble(String) and can throw a NumberFormatException; null is returned only if the cell value is null.

Parameters
hdr
column name
Returns

cell value, which can be null

Throws
NoSuchElementException
column not found
NumberFormatException
if the value is not null and does not contain a parsable double.

getBool

public Boolean getBool (
	String hdr
);

Get cell value as boolean. Conversion is done by Boolean.parseBoolean(String); null is returned only if the cell value is null.

Parameters
hdr
column name
Returns

cell value, which can be null

Throws
NoSuchElementException
column not found

set

public void set (
	String hdr,
	Object v
);

Update cell value. The value of v is converted to String using Object.toString() unless v is null.

Parameters
hdr
column header
v
new value
Throws
NoSuchElementException
column not found

update

public void update (
	String... vs
);

Set multiple cell values at once. Column order is inferred from the enclosing Data. Copying is range-safe in case the number of values in vs does not match the number of columns.

Parameters
vs
new values