public class DefaultFieldSet extends java.lang.Object implements FieldSet
FieldSet
using Java using Java primitive
and standard types and utilities. Strings are trimmed before parsing by
default, and so are plain String values.Constructor and Description |
---|
DefaultFieldSet(java.lang.String[] tokens)
Create a FieldSet with anonymous tokens.
|
DefaultFieldSet(java.lang.String[] tokens,
java.lang.String[] names)
Create a FieldSet with named tokens.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object object) |
int |
getFieldCount()
Return the number of fields in this '
FieldSet '. |
java.lang.String[] |
getNames()
Accessor for the names of the fields.
|
java.util.Properties |
getProperties()
Construct name-value pairs from the field names and string values.
|
java.lang.String[] |
getValues() |
int |
hashCode() |
boolean |
hasNames()
Check if there are names defined for the fields.
|
protected int |
indexOf(java.lang.String name)
Retrieve the index of where a specified column is located based on the
name parameter. |
protected java.lang.String |
readAndTrim(int index)
Read and trim the
String value at 'index '. |
java.math.BigDecimal |
readBigDecimal(int index)
Read the
BigDecimal value at index 'index '. |
java.math.BigDecimal |
readBigDecimal(int index,
java.math.BigDecimal defaultValue)
Read the
BigDecimal value at index 'index ',
returning the supplied defaultValue if the trimmed string
value at index 'index ' is blank. |
java.math.BigDecimal |
readBigDecimal(java.lang.String name)
Read the
BigDecimal value from column with given 'name . |
java.math.BigDecimal |
readBigDecimal(java.lang.String name,
java.math.BigDecimal defaultValue)
Read the
BigDecimal value from column with given 'name ,
returning the supplied defaultValue if the trimmed string
value at index 'index ' is blank. |
boolean |
readBoolean(int index)
Read the '
boolean ' value at index 'index '. |
boolean |
readBoolean(int index,
java.lang.String trueValue)
Read the '
boolean ' value at index 'index '. |
boolean |
readBoolean(java.lang.String name)
Read the '
boolean ' value from column with given 'name '. |
boolean |
readBoolean(java.lang.String name,
java.lang.String trueValue)
Read the '
boolean ' value from column with given 'name '. |
byte |
readByte(int index)
Read the '
byte ' value at index 'index '. |
byte |
readByte(java.lang.String name)
Read the '
byte ' value from column with given 'name '. |
char |
readChar(int index)
Read the '
char ' value at index 'index '. |
char |
readChar(java.lang.String name)
Read the '
char ' value from column with given 'name '. |
java.util.Date |
readDate(int index)
Read the
java.util.Date value in default format at
designated column index . |
java.util.Date |
readDate(int index,
java.util.Date defaultValue)
Read the
java.util.Date value in default format at
designated column index . |
java.util.Date |
readDate(int index,
java.lang.String pattern)
Read the
java.util.Date value in default format at
designated column index . |
java.util.Date |
readDate(int index,
java.lang.String pattern,
java.util.Date defaultValue)
Read the
java.util.Date value in default format at
designated column index . |
java.util.Date |
readDate(java.lang.String name)
Read the
java.sql.Date value in given format from column
with given name . |
java.util.Date |
readDate(java.lang.String name,
java.util.Date defaultValue)
Read the
java.sql.Date value in given format from column
with given name . |
java.util.Date |
readDate(java.lang.String name,
java.lang.String pattern)
Read the
java.sql.Date value in given format from column
with given name . |
java.util.Date |
readDate(java.lang.String name,
java.lang.String pattern,
java.util.Date defaultValue)
Read the
java.sql.Date value in given format from column
with given name . |
double |
readDouble(int index)
Read the '
double ' value at index 'index '. |
double |
readDouble(java.lang.String name)
Read the '
double ' value from column with given 'name . |
float |
readFloat(int index)
Read the '
float ' value at index 'index '. |
float |
readFloat(java.lang.String name)
Read the '
float ' value from column with given 'name . |
int |
readInt(int index)
Read the '
int ' value at index 'index '. |
int |
readInt(int index,
int defaultValue)
Read the '
int ' value at index 'index ',
using the supplied defaultValue if the field value is
blank. |
int |
readInt(java.lang.String name)
Read the '
int ' value from column with given 'name '. |
int |
readInt(java.lang.String name,
int defaultValue)
Read the '
int ' value from column with given 'name ',
using the supplied defaultValue if the field value is
blank. |
long |
readLong(int index)
Read the '
long ' value at index 'index '. |
long |
readLong(int index,
long defaultValue)
Read the '
long ' value at index 'index ',
using the supplied defaultValue if the field value is
blank. |
long |
readLong(java.lang.String name)
Read the '
long ' value from column with given 'name '. |
long |
readLong(java.lang.String name,
long defaultValue)
Read the '
long ' value from column with given 'name ',
using the supplied defaultValue if the field value is
blank. |
java.lang.String |
readRawString(int index)
Read the
String value at index 'index ' including
trailing whitespace (don't trim). |
java.lang.String |
readRawString(java.lang.String name)
Read the
String value from column with given 'name '
including trailing whitespace (don't trim). |
short |
readShort(int index)
Read the '
short ' value at index 'index '. |
short |
readShort(java.lang.String name)
Read the '
short ' value from column with given 'name '. |
java.lang.String |
readString(int index)
Read the
String value at index 'index '. |
java.lang.String |
readString(java.lang.String name)
Read the
String value from column with given 'name '. |
void |
setDateFormat(java.text.DateFormat dateFormat)
The
DateFormat to use for parsing numbers. |
void |
setNumberFormat(java.text.NumberFormat numberFormat)
The
NumberFormat to use for parsing numbers. |
java.lang.String |
toString() |
public DefaultFieldSet(java.lang.String[] tokens)
tokens
- the token valuesFieldSet.readString(int)
public DefaultFieldSet(java.lang.String[] tokens, java.lang.String[] names)
tokens
- the token valuesnames
- the names of the tokensFieldSet.readString(String)
public final void setNumberFormat(java.text.NumberFormat numberFormat)
NumberFormat
to use for parsing numbers. If unset the US
locale will be used ('.' as decimal place).numberFormat
- the NumberFormat
to use for number parsingpublic void setDateFormat(java.text.DateFormat dateFormat)
DateFormat
to use for parsing numbers. If unset the default
pattern is ISO standard yyyy/MM/dd
.dateFormat
- the DateFormat
to use for date parsingpublic java.lang.String[] getNames()
FieldSet
public boolean hasNames()
FieldSet
public java.lang.String[] getValues()
public java.lang.String readString(int index)
FieldSet
String
value at index 'index
'.readString
in interface FieldSet
index
- the field index.String
containing the value at the index.public java.lang.String readString(java.lang.String name)
FieldSet
String
value from column with given 'name
'.readString
in interface FieldSet
name
- the field name
.String
containing the value from the specified name
.public java.lang.String readRawString(int index)
FieldSet
String
value at index 'index
' including
trailing whitespace (don't trim).readRawString
in interface FieldSet
index
- the field index.String
containing the value from the specified index
.public java.lang.String readRawString(java.lang.String name)
FieldSet
String
value from column with given 'name
'
including trailing whitespace (don't trim).readRawString
in interface FieldSet
name
- the field name
.String
containing the value from the specified name
.public boolean readBoolean(int index)
FieldSet
boolean
' value at index 'index
'.readBoolean
in interface FieldSet
index
- the field index.index
.public boolean readBoolean(java.lang.String name)
FieldSet
boolean
' value from column with given 'name
'.readBoolean
in interface FieldSet
name
- the field name
.name
.public boolean readBoolean(int index, java.lang.String trueValue)
FieldSet
boolean
' value at index 'index
'.readBoolean
in interface FieldSet
index
- the field index.trueValue
- the value that signifies true
;
case-sensitive.index
.public boolean readBoolean(java.lang.String name, java.lang.String trueValue)
FieldSet
boolean
' value from column with given 'name
'.readBoolean
in interface FieldSet
name
- the field name
.trueValue
- the value that signifies true
;
case-sensitive.name
.public char readChar(int index)
FieldSet
char
' value at index 'index
'.public char readChar(java.lang.String name)
FieldSet
char
' value from column with given 'name
'.public byte readByte(int index)
FieldSet
byte
' value at index 'index
'.public byte readByte(java.lang.String name)
FieldSet
byte
' value from column with given 'name
'.public short readShort(int index)
FieldSet
short
' value at index 'index
'.public short readShort(java.lang.String name)
FieldSet
short
' value from column with given 'name
'.public int readInt(int index)
FieldSet
int
' value at index 'index
'.public int readInt(java.lang.String name)
FieldSet
int
' value from column with given 'name
'.public int readInt(int index, int defaultValue)
FieldSet
int
' value at index 'index
',
using the supplied defaultValue
if the field value is
blank.public int readInt(java.lang.String name, int defaultValue)
FieldSet
int
' value from column with given 'name
',
using the supplied defaultValue
if the field value is
blank.public long readLong(int index)
FieldSet
long
' value at index 'index
'.public long readLong(java.lang.String name)
FieldSet
long
' value from column with given 'name
'.public long readLong(int index, long defaultValue)
FieldSet
long
' value at index 'index
',
using the supplied defaultValue
if the field value is
blank.public long readLong(java.lang.String name, long defaultValue)
FieldSet
long
' value from column with given 'name
',
using the supplied defaultValue
if the field value is
blank.public float readFloat(int index)
FieldSet
float
' value at index 'index
'.public float readFloat(java.lang.String name)
FieldSet
float
' value from column with given 'name
.public double readDouble(int index)
FieldSet
double
' value at index 'index
'.readDouble
in interface FieldSet
index
- the field index.public double readDouble(java.lang.String name)
FieldSet
double
' value from column with given 'name
.readDouble
in interface FieldSet
name
- the field name
.name
.public java.math.BigDecimal readBigDecimal(int index)
FieldSet
BigDecimal
value at index 'index
'.readBigDecimal
in interface FieldSet
index
- the field index.BigDecimal
containing the value from the specified index.public java.math.BigDecimal readBigDecimal(java.lang.String name)
FieldSet
BigDecimal
value from column with given 'name
.readBigDecimal
in interface FieldSet
name
- the field name
.BigDecimal
containing the value from the specified name
.public java.math.BigDecimal readBigDecimal(int index, java.math.BigDecimal defaultValue)
FieldSet
BigDecimal
value at index 'index
',
returning the supplied defaultValue
if the trimmed string
value at index 'index
' is blank.readBigDecimal
in interface FieldSet
index
- the field index.defaultValue
- the value to use if the field value is blank.BigDecimal
containing the value from the specified index.public java.math.BigDecimal readBigDecimal(java.lang.String name, java.math.BigDecimal defaultValue)
FieldSet
BigDecimal
value from column with given 'name
,
returning the supplied defaultValue
if the trimmed string
value at index 'index
' is blank.readBigDecimal
in interface FieldSet
name
- the field name
.defaultValue
- the default value to use if the field is blankBigDecimal
containing the value from the specified name
.public java.util.Date readDate(int index)
FieldSet
java.util.Date
value in default format at
designated column index
.public java.util.Date readDate(int index, java.util.Date defaultValue)
FieldSet
java.util.Date
value in default format at
designated column index
.public java.util.Date readDate(java.lang.String name)
FieldSet
java.sql.Date
value in given format from column
with given name
.public java.util.Date readDate(java.lang.String name, java.util.Date defaultValue)
FieldSet
java.sql.Date
value in given format from column
with given name
.public java.util.Date readDate(int index, java.lang.String pattern)
FieldSet
java.util.Date
value in default format at
designated column index
.public java.util.Date readDate(int index, java.lang.String pattern, java.util.Date defaultValue)
FieldSet
java.util.Date
value in default format at
designated column index
.public java.util.Date readDate(java.lang.String name, java.lang.String pattern)
FieldSet
java.sql.Date
value in given format from column
with given name
.public java.util.Date readDate(java.lang.String name, java.lang.String pattern, java.util.Date defaultValue)
FieldSet
java.sql.Date
value in given format from column
with given name
.public int getFieldCount()
FieldSet
FieldSet
'.getFieldCount
in interface FieldSet
protected java.lang.String readAndTrim(int index)
String
value at 'index
'.index
- the offset in the token array to obtain the value to be trimmed.null
.protected int indexOf(java.lang.String name)
name
parameter.name
- the value to search in the List
of names.List
of names where the name was found.java.lang.IllegalArgumentException
- if a column with given name is not
defined.public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
Object.equals(java.lang.Object)
public int hashCode()
hashCode
in class java.lang.Object
public java.util.Properties getProperties()
FieldSet
getProperties
in interface FieldSet