接口 FieldSet
- 所有已知实现类:
DefaultFieldSet
public interface FieldSet
Interface used by flat file input sources to encapsulate concerns of converting an array of Strings to Java native types. A bit like the role played byResultSetin JDBC, clients will know the name or position of strongly typed fields that they want to extract.- 作者:
- Dave Syer
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 intgetFieldCount()Return the number of fields in this 'FieldSet'.java.lang.String[]getNames()Accessor for the names of the fields.java.util.PropertiesgetProperties()Construct name-value pairs from the field names and string values.java.lang.String[]getValues()booleanhasNames()Check if there are names defined for the fields.java.math.BigDecimalreadBigDecimal(int index)Read theBigDecimalvalue at index 'index'.java.math.BigDecimalreadBigDecimal(int index, java.math.BigDecimal defaultValue)Read theBigDecimalvalue at index 'index', returning the supplieddefaultValueif the trimmed string value at index 'index' is blank.java.math.BigDecimalreadBigDecimal(java.lang.String name)Read theBigDecimalvalue from column with given 'name.java.math.BigDecimalreadBigDecimal(java.lang.String name, java.math.BigDecimal defaultValue)Read theBigDecimalvalue from column with given 'name, returning the supplieddefaultValueif the trimmed string value at index 'index' is blank.booleanreadBoolean(int index)Read the 'boolean' value at index 'index'.booleanreadBoolean(int index, java.lang.String trueValue)Read the 'boolean' value at index 'index'.booleanreadBoolean(java.lang.String name)Read the 'boolean' value from column with given 'name'.booleanreadBoolean(java.lang.String name, java.lang.String trueValue)Read the 'boolean' value from column with given 'name'.bytereadByte(int index)Read the 'byte' value at index 'index'.bytereadByte(java.lang.String name)Read the 'byte' value from column with given 'name'.charreadChar(int index)Read the 'char' value at index 'index'.charreadChar(java.lang.String name)Read the 'char' value from column with given 'name'.java.util.DatereadDate(int index)Read thejava.util.Datevalue in default format at designated columnindex.java.util.DatereadDate(int index, java.lang.String pattern)Read thejava.util.Datevalue in default format at designated columnindex.java.util.DatereadDate(int index, java.lang.String pattern, java.util.Date defaultValue)Read thejava.util.Datevalue in default format at designated columnindex.java.util.DatereadDate(int index, java.util.Date defaultValue)Read thejava.util.Datevalue in default format at designated columnindex.java.util.DatereadDate(java.lang.String name)Read thejava.sql.Datevalue in given format from column with givenname.java.util.DatereadDate(java.lang.String name, java.lang.String pattern)Read thejava.sql.Datevalue in given format from column with givenname.java.util.DatereadDate(java.lang.String name, java.lang.String pattern, java.util.Date defaultValue)Read thejava.sql.Datevalue in given format from column with givenname.java.util.DatereadDate(java.lang.String name, java.util.Date defaultValue)Read thejava.sql.Datevalue in given format from column with givenname.doublereadDouble(int index)Read the 'double' value at index 'index'.doublereadDouble(java.lang.String name)Read the 'double' value from column with given 'name.floatreadFloat(int index)Read the 'float' value at index 'index'.floatreadFloat(java.lang.String name)Read the 'float' value from column with given 'name.intreadInt(int index)Read the 'int' value at index 'index'.intreadInt(int index, int defaultValue)Read the 'int' value at index 'index', using the supplieddefaultValueif the field value is blank.intreadInt(java.lang.String name)Read the 'int' value from column with given 'name'.intreadInt(java.lang.String name, int defaultValue)Read the 'int' value from column with given 'name', using the supplieddefaultValueif the field value is blank.longreadLong(int index)Read the 'long' value at index 'index'.longreadLong(int index, long defaultValue)Read the 'long' value at index 'index', using the supplieddefaultValueif the field value is blank.longreadLong(java.lang.String name)Read the 'long' value from column with given 'name'.longreadLong(java.lang.String name, long defaultValue)Read the 'long' value from column with given 'name', using the supplieddefaultValueif the field value is blank.java.lang.StringreadRawString(int index)Read theStringvalue at index 'index' including trailing whitespace (don't trim).java.lang.StringreadRawString(java.lang.String name)Read theStringvalue from column with given 'name' including trailing whitespace (don't trim).shortreadShort(int index)Read the 'short' value at index 'index'.shortreadShort(java.lang.String name)Read the 'short' value from column with given 'name'.java.lang.StringreadString(int index)Read theStringvalue at index 'index'.java.lang.StringreadString(java.lang.String name)Read theStringvalue from column with given 'name'.
方法详细资料
getNames
java.lang.String[] getNames()
Accessor for the names of the fields.- 返回:
- the names
- 抛出:
java.lang.IllegalStateException- if the names are not defined
hasNames
boolean hasNames()
Check if there are names defined for the fields.- 返回:
- true if there are names for the fields
getValues
java.lang.String[] getValues()
- 返回:
- fields wrapped by this '
FieldSet' instance as String values.
readString
java.lang.String readString(int index)
Read theStringvalue at index 'index'.- 参数:
index- the field index.- 返回:
Stringcontaining the value at the index.- 抛出:
java.lang.IndexOutOfBoundsException- if theindexis out of bounds.
readString
java.lang.String readString(java.lang.String name)
Read theStringvalue from column with given 'name'.- 参数:
name- the fieldname.- 返回:
Stringcontaining the value from the specifiedname.
readRawString
java.lang.String readRawString(int index)
Read theStringvalue at index 'index' including trailing whitespace (don't trim).- 参数:
index- the field index.- 返回:
Stringcontaining the value from the specifiedindex.- 抛出:
java.lang.IndexOutOfBoundsException- if theindexis out of bounds.
readRawString
java.lang.String readRawString(java.lang.String name)
Read theStringvalue from column with given 'name' including trailing whitespace (don't trim).- 参数:
name- the fieldname.- 返回:
Stringcontaining the value from the specifiedname.
readBoolean
boolean readBoolean(int index)
Read the 'boolean' value at index 'index'.- 参数:
index- the field index.- 返回:
- boolean containing the value from the specified
index. - 抛出:
java.lang.IndexOutOfBoundsException- if theindexis out of bounds.
readBoolean
boolean readBoolean(java.lang.String name)
Read the 'boolean' value from column with given 'name'.- 参数:
name- the fieldname.- 返回:
- boolean containing the value from the specified
name. - 抛出:
java.lang.IllegalArgumentException- if a column with givennameis not defined.
readBoolean
boolean readBoolean(int index, java.lang.String trueValue)
Read the 'boolean' value at index 'index'.- 参数:
index- the field index.trueValue- the value that signifiestrue; case-sensitive.- 返回:
- boolean containing the value from the specified
index. - 抛出:
java.lang.IndexOutOfBoundsException- if the index is out of bounds, or if the suppliedtrueValueisnull.
readBoolean
boolean readBoolean(java.lang.String name, java.lang.String trueValue)
Read the 'boolean' value from column with given 'name'.- 参数:
name- the fieldname.trueValue- the value that signifiestrue; case-sensitive.- 返回:
- boolean containing the value from the specified
name. - 抛出:
java.lang.IllegalArgumentException- if a column with givennameis not defined, or if the suppliedtrueValueisnull.
readChar
char readChar(int index)
Read the 'char' value at index 'index'.- 参数:
index- the field index.- 返回:
- char containing the value from the specified
index. - 抛出:
java.lang.IndexOutOfBoundsException- if the index is out of bounds.
readChar
char readChar(java.lang.String name)
Read the 'char' value from column with given 'name'.- 参数:
name- the fieldname.- 返回:
- char containing the value from the specified
name. - 抛出:
java.lang.IllegalArgumentException- if a column with givennameis not defined.
readByte
byte readByte(int index)
Read the 'byte' value at index 'index'.- 参数:
index- the field index.- 返回:
- byte containing the value from the specified
index. - 抛出:
java.lang.IndexOutOfBoundsException- if the index is out of bounds.
readByte
byte readByte(java.lang.String name)
Read the 'byte' value from column with given 'name'.- 参数:
name- the fieldname.- 返回:
- byte containing the value from the specified
name.
readShort
short readShort(int index)
Read the 'short' value at index 'index'.- 参数:
index- the fieldindex.- 返回:
- short containing the value from the specified index.
- 抛出:
java.lang.IndexOutOfBoundsException- if the index is out of bounds.
readShort
short readShort(java.lang.String name)
Read the 'short' value from column with given 'name'.- 参数:
name- the fieldname.- 返回:
- short containing the value from the specified
name. - 抛出:
java.lang.IllegalArgumentException- if a column with givennameis not defined.
readInt
int readInt(int index)
Read the 'int' value at index 'index'.- 参数:
index- the field index.- 返回:
- int containing the value from the specified index.
- 抛出:
java.lang.IndexOutOfBoundsException- if the index is out of bounds.
readInt
int readInt(java.lang.String name)
Read the 'int' value from column with given 'name'.- 参数:
name- the fieldname.- 返回:
- int containing the value from the specified
name. - 抛出:
java.lang.IllegalArgumentException- if a column with givennameis not defined.
readInt
int readInt(int index, int defaultValue)
Read the 'int' value at index 'index', using the supplieddefaultValueif the field value is blank.- 参数:
index- the field index.defaultValue- the value to use if the field value is blank.- 返回:
- int containing the value from the specified index.
- 抛出:
java.lang.IndexOutOfBoundsException- if the index is out of bounds.
readInt
int readInt(java.lang.String name, int defaultValue)
Read the 'int' value from column with given 'name', using the supplieddefaultValueif the field value is blank.- 参数:
name- the fieldname.defaultValue- the value to use if the field value is blank.- 返回:
- int containing the value from the specified
name. - 抛出:
java.lang.IllegalArgumentException- if a column with givennameis not defined.
readLong
long readLong(int index)
Read the 'long' value at index 'index'.- 参数:
index- the field index.- 返回:
- long containing the value from the specified index.
- 抛出:
java.lang.IndexOutOfBoundsException- if the index is out of bounds.
readLong
long readLong(java.lang.String name)
Read the 'long' value from column with given 'name'.- 参数:
name- the fieldname.- 返回:
- long containing the value from the specified
name. - 抛出:
java.lang.IllegalArgumentException- if a column with givennameis not defined.
readLong
long readLong(int index, long defaultValue)
Read the 'long' value at index 'index', using the supplieddefaultValueif the field value is blank.- 参数:
index- the field index.defaultValue- the value to use if the field value is blank.- 返回:
- long containing the value from the specified index.
- 抛出:
java.lang.IndexOutOfBoundsException- if the index is out of bounds.
readLong
long readLong(java.lang.String name, long defaultValue)
Read the 'long' value from column with given 'name', using the supplieddefaultValueif the field value is blank.- 参数:
name- the fieldname.defaultValue- the value to use if the field value is blank.- 返回:
- long containing the value from the specified
name. - 抛出:
java.lang.IllegalArgumentException- if a column with givennameis not defined.
readFloat
float readFloat(int index)
Read the 'float' value at index 'index'.- 参数:
index- the field index.- 返回:
- float containing the value from the specified index.
- 抛出:
java.lang.IndexOutOfBoundsException- if the index is out of bounds.
readFloat
float readFloat(java.lang.String name)
Read the 'float' value from column with given 'name.- 参数:
name- the fieldname.- 返回:
- float containing the value from the specified
name. - 抛出:
java.lang.IllegalArgumentException- if a column with givennameis not defined.
readDouble
double readDouble(int index)
Read the 'double' value at index 'index'.- 参数:
index- the field index.- 返回:
- double containing the value from the specified index.
- 抛出:
java.lang.IndexOutOfBoundsException- if the index is out of bounds.
readDouble
double readDouble(java.lang.String name)
Read the 'double' value from column with given 'name.- 参数:
name- the fieldname.- 返回:
- double containing the value from the specified
name. - 抛出:
java.lang.IllegalArgumentException- if a column with givennameis not defined.
readBigDecimal
java.math.BigDecimal readBigDecimal(int index)
Read theBigDecimalvalue at index 'index'.- 参数:
index- the field index.- 返回:
BigDecimalcontaining the value from the specified index.- 抛出:
java.lang.IndexOutOfBoundsException- if the index is out of bounds.
readBigDecimal
java.math.BigDecimal readBigDecimal(java.lang.String name)
Read theBigDecimalvalue from column with given 'name.- 参数:
name- the fieldname.- 返回:
BigDecimalcontaining the value from the specifiedname.- 抛出:
java.lang.IllegalArgumentException- if a column with givennameis not defined.
readBigDecimal
java.math.BigDecimal readBigDecimal(int index, java.math.BigDecimal defaultValue)
Read theBigDecimalvalue at index 'index', returning the supplieddefaultValueif the trimmed string value at index 'index' is blank.- 参数:
index- the field index.defaultValue- the value to use if the field value is blank.- 返回:
BigDecimalcontaining the value from the specified index.- 抛出:
java.lang.IndexOutOfBoundsException- if the index is out of bounds.
readBigDecimal
java.math.BigDecimal readBigDecimal(java.lang.String name, java.math.BigDecimal defaultValue)
Read theBigDecimalvalue from column with given 'name, returning the supplieddefaultValueif the trimmed string value at index 'index' is blank.- 参数:
name- the fieldname.defaultValue- the default value to use if the field is blank- 返回:
BigDecimalcontaining the value from the specifiedname.- 抛出:
java.lang.IllegalArgumentException- if a column with givennameis not defined.
readDate
java.util.Date readDate(int index)
Read thejava.util.Datevalue in default format at designated columnindex.- 参数:
index- the field index.- 返回:
Datecontaining the value from the specified index.- 抛出:
java.lang.IndexOutOfBoundsException- if the index is out of bounds.java.lang.IllegalArgumentException- if the value is not parseablejava.lang.NullPointerException- if the value is empty
readDate
java.util.Date readDate(java.lang.String name)
Read thejava.sql.Datevalue in given format from column with givenname.- 参数:
name- the fieldname.- 返回:
Datecontaining the value from the specifiedname.- 抛出:
java.lang.IllegalArgumentException- if a column with givennameis not defined or if the value is not parseablejava.lang.NullPointerException- if the value is empty
readDate
java.util.Date readDate(int index, java.util.Date defaultValue)
Read thejava.util.Datevalue in default format at designated columnindex.- 参数:
index- the field index.defaultValue- the default value to use if the field is blank- 返回:
Datecontaining the value from the specified index.- 抛出:
java.lang.IndexOutOfBoundsException- if the index is out of bounds.java.lang.IllegalArgumentException- if the value is not parseablejava.lang.NullPointerException- if the value is empty
readDate
java.util.Date readDate(java.lang.String name, java.util.Date defaultValue)
Read thejava.sql.Datevalue in given format from column with givenname.- 参数:
name- the fieldname.defaultValue- the default value to use if the field is blank- 返回:
Datecontaining the value from the specifiedname.- 抛出:
java.lang.IllegalArgumentException- if a column with givennameis not defined.
readDate
java.util.Date readDate(int index, java.lang.String pattern)
Read thejava.util.Datevalue in default format at designated columnindex.- 参数:
index- the field index.pattern- the pattern describing the date and time format- 返回:
Datecontaining the value from the specified index.- 抛出:
java.lang.IndexOutOfBoundsException- if the index is out of bounds.java.lang.IllegalArgumentException- if the date cannot be parsed.
readDate
java.util.Date readDate(java.lang.String name, java.lang.String pattern)
Read thejava.sql.Datevalue in given format from column with givenname.- 参数:
name- the fieldname.pattern- the pattern describing the date and time format- 返回:
Datecontaining the value from the specifiedname.- 抛出:
java.lang.IllegalArgumentException- if a column with givennameis not defined or if the specified field cannot be parsed
readDate
java.util.Date readDate(int index, java.lang.String pattern, java.util.Date defaultValue)
Read thejava.util.Datevalue in default format at designated columnindex.- 参数:
index- the field index.pattern- the pattern describing the date and time formatdefaultValue- the default value to use if the field is blank- 返回:
Datecontaining the value from the specified index.- 抛出:
java.lang.IndexOutOfBoundsException- if the index is out of bounds.java.lang.IllegalArgumentException- if the date cannot be parsed.
readDate
java.util.Date readDate(java.lang.String name, java.lang.String pattern, java.util.Date defaultValue)
Read thejava.sql.Datevalue in given format from column with givenname.- 参数:
name- the fieldname.pattern- the pattern describing the date and time formatdefaultValue- the default value to use if the field is blank- 返回:
Datecontaining the value from the specifiedname.- 抛出:
java.lang.IllegalArgumentException- if a column with givennameis not defined or if the specified field cannot be parsed
getFieldCount
int getFieldCount()
Return the number of fields in this 'FieldSet'.- 返回:
- int containing the number of fields in this field set.
getProperties
java.util.Properties getProperties()
Construct name-value pairs from the field names and string values. Null values are omitted.- 返回:
- some properties representing the field set.
- 抛出:
java.lang.IllegalStateException- if the field name meta data is not available.