类 DefaultFieldSet
- java.lang.Object
- org.springframework.batch.item.file.transform.DefaultFieldSet
- 所有已实现的接口:
FieldSet
public class DefaultFieldSet extends java.lang.Object implements FieldSet
Default implementation ofFieldSet
using Java using Java primitive and standard types and utilities. Strings are trimmed before parsing by default, and so are plain String values.- 作者:
- Rob Harrop, Dave Syer
构造器概要
构造器 构造器 说明 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.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 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 thename
parameter.protected java.lang.String
readAndTrim(int index)
Read and trim theString
value at 'index
'.java.math.BigDecimal
readBigDecimal(int index)
Read theBigDecimal
value at index 'index
'.java.math.BigDecimal
readBigDecimal(int index, java.math.BigDecimal defaultValue)
Read theBigDecimal
value at index 'index
', returning the supplieddefaultValue
if the trimmed string value at index 'index
' is blank.java.math.BigDecimal
readBigDecimal(java.lang.String name)
Read theBigDecimal
value from column with given 'name
.java.math.BigDecimal
readBigDecimal(java.lang.String name, java.math.BigDecimal defaultValue)
Read theBigDecimal
value from column with given 'name
, returning the supplieddefaultValue
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 thejava.util.Date
value in default format at designated columnindex
.java.util.Date
readDate(int index, java.lang.String pattern)
Read thejava.util.Date
value in default format at designated columnindex
.java.util.Date
readDate(int index, java.lang.String pattern, java.util.Date defaultValue)
Read thejava.util.Date
value in default format at designated columnindex
.java.util.Date
readDate(int index, java.util.Date defaultValue)
Read thejava.util.Date
value in default format at designated columnindex
.java.util.Date
readDate(java.lang.String name)
Read thejava.sql.Date
value in given format from column with givenname
.java.util.Date
readDate(java.lang.String name, java.lang.String pattern)
Read thejava.sql.Date
value in given format from column with givenname
.java.util.Date
readDate(java.lang.String name, java.lang.String pattern, java.util.Date defaultValue)
Read thejava.sql.Date
value in given format from column with givenname
.java.util.Date
readDate(java.lang.String name, java.util.Date defaultValue)
Read thejava.sql.Date
value in given format from column with givenname
.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 supplieddefaultValue
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 supplieddefaultValue
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 supplieddefaultValue
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 supplieddefaultValue
if the field value is blank.java.lang.String
readRawString(int index)
Read theString
value at index 'index
' including trailing whitespace (don't trim).java.lang.String
readRawString(java.lang.String name)
Read theString
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 theString
value at index 'index
'.java.lang.String
readString(java.lang.String name)
Read theString
value from column with given 'name
'.void
setDateFormat(java.text.DateFormat dateFormat)
TheDateFormat
to use for parsing numbers.void
setNumberFormat(java.text.NumberFormat numberFormat)
TheNumberFormat
to use for parsing numbers.java.lang.String
toString()
构造器详细资料
DefaultFieldSet
public DefaultFieldSet(java.lang.String[] tokens)
Create a FieldSet with anonymous tokens. They can only be retrieved by column number.- 参数:
tokens
- the token values- 另请参阅:
FieldSet.readString(int)
DefaultFieldSet
public DefaultFieldSet(java.lang.String[] tokens, java.lang.String[] names)
Create a FieldSet with named tokens. The token values can then be retrieved either by name or by column number.- 参数:
tokens
- the token valuesnames
- the names of the tokens- 另请参阅:
FieldSet.readString(String)
方法详细资料
setNumberFormat
public final void setNumberFormat(java.text.NumberFormat numberFormat)
TheNumberFormat
to use for parsing numbers. If unset the US locale will be used ('.' as decimal place).- 参数:
numberFormat
- theNumberFormat
to use for number parsing
setDateFormat
public void setDateFormat(java.text.DateFormat dateFormat)
TheDateFormat
to use for parsing numbers. If unset the default pattern is ISO standardyyyy/MM/dd
.- 参数:
dateFormat
- theDateFormat
to use for date parsing
getValues
public java.lang.String[] getValues()
readString
public java.lang.String readString(int index)
从接口复制的说明:FieldSet
Read theString
value at index 'index
'.- 指定者:
readString
在接口中FieldSet
- 参数:
index
- the field index.- 返回:
String
containing the value at the index.
readString
public java.lang.String readString(java.lang.String name)
从接口复制的说明:FieldSet
Read theString
value from column with given 'name
'.- 指定者:
readString
在接口中FieldSet
- 参数:
name
- the fieldname
.- 返回:
String
containing the value from the specifiedname
.
readRawString
public java.lang.String readRawString(int index)
从接口复制的说明:FieldSet
Read theString
value at index 'index
' including trailing whitespace (don't trim).- 指定者:
readRawString
在接口中FieldSet
- 参数:
index
- the field index.- 返回:
String
containing the value from the specifiedindex
.
readRawString
public java.lang.String readRawString(java.lang.String name)
从接口复制的说明:FieldSet
Read theString
value from column with given 'name
' including trailing whitespace (don't trim).- 指定者:
readRawString
在接口中FieldSet
- 参数:
name
- the fieldname
.- 返回:
String
containing the value from the specifiedname
.
readBoolean
public boolean readBoolean(int index)
从接口复制的说明:FieldSet
Read the 'boolean
' value at index 'index
'.- 指定者:
readBoolean
在接口中FieldSet
- 参数:
index
- the field index.- 返回:
- boolean containing the value from the specified
index
.
readBoolean
public boolean readBoolean(java.lang.String name)
从接口复制的说明:FieldSet
Read the 'boolean
' value from column with given 'name
'.- 指定者:
readBoolean
在接口中FieldSet
- 参数:
name
- the fieldname
.- 返回:
- boolean containing the value from the specified
name
.
readBoolean
public boolean readBoolean(int index, java.lang.String trueValue)
从接口复制的说明:FieldSet
Read the 'boolean
' value at index 'index
'.- 指定者:
readBoolean
在接口中FieldSet
- 参数:
index
- the field index.trueValue
- the value that signifiestrue
; case-sensitive.- 返回:
- boolean containing the value from the specified
index
.
readBoolean
public boolean readBoolean(java.lang.String name, java.lang.String trueValue)
从接口复制的说明:FieldSet
Read the 'boolean
' value from column with given 'name
'.- 指定者:
readBoolean
在接口中FieldSet
- 参数:
name
- the fieldname
.trueValue
- the value that signifiestrue
; case-sensitive.- 返回:
- boolean containing the value from the specified
name
.
readChar
public char readChar(java.lang.String name)
从接口复制的说明:FieldSet
Read the 'char
' value from column with given 'name
'.
readByte
public byte readByte(java.lang.String name)
从接口复制的说明:FieldSet
Read the 'byte
' value from column with given 'name
'.
readShort
public short readShort(int index)
从接口复制的说明:FieldSet
Read the 'short
' value at index 'index
'.
readShort
public short readShort(java.lang.String name)
从接口复制的说明:FieldSet
Read the 'short
' value from column with given 'name
'.
readInt
public int readInt(java.lang.String name)
从接口复制的说明:FieldSet
Read the 'int
' value from column with given 'name
'.
readInt
public int readInt(int index, int defaultValue)
从接口复制的说明:FieldSet
Read the 'int
' value at index 'index
', using the supplieddefaultValue
if the field value is blank.
readInt
public int readInt(java.lang.String name, int defaultValue)
从接口复制的说明:FieldSet
Read the 'int
' value from column with given 'name
', using the supplieddefaultValue
if the field value is blank.
readLong
public long readLong(java.lang.String name)
从接口复制的说明:FieldSet
Read the 'long
' value from column with given 'name
'.
readLong
public long readLong(int index, long defaultValue)
从接口复制的说明:FieldSet
Read the 'long
' value at index 'index
', using the supplieddefaultValue
if the field value is blank.
readLong
public long readLong(java.lang.String name, long defaultValue)
从接口复制的说明:FieldSet
Read the 'long
' value from column with given 'name
', using the supplieddefaultValue
if the field value is blank.
readFloat
public float readFloat(int index)
从接口复制的说明:FieldSet
Read the 'float
' value at index 'index
'.
readFloat
public float readFloat(java.lang.String name)
从接口复制的说明:FieldSet
Read the 'float
' value from column with given 'name
.
readDouble
public double readDouble(int index)
从接口复制的说明:FieldSet
Read the 'double
' value at index 'index
'.- 指定者:
readDouble
在接口中FieldSet
- 参数:
index
- the field index.- 返回:
- double containing the value from the specified index.
readDouble
public double readDouble(java.lang.String name)
从接口复制的说明:FieldSet
Read the 'double
' value from column with given 'name
.- 指定者:
readDouble
在接口中FieldSet
- 参数:
name
- the fieldname
.- 返回:
- double containing the value from the specified
name
.
readBigDecimal
public java.math.BigDecimal readBigDecimal(int index)
从接口复制的说明:FieldSet
Read theBigDecimal
value at index 'index
'.- 指定者:
readBigDecimal
在接口中FieldSet
- 参数:
index
- the field index.- 返回:
BigDecimal
containing the value from the specified index.
readBigDecimal
public java.math.BigDecimal readBigDecimal(java.lang.String name)
从接口复制的说明:FieldSet
Read theBigDecimal
value from column with given 'name
.- 指定者:
readBigDecimal
在接口中FieldSet
- 参数:
name
- the fieldname
.- 返回:
BigDecimal
containing the value from the specifiedname
.
readBigDecimal
public java.math.BigDecimal readBigDecimal(int index, java.math.BigDecimal defaultValue)
从接口复制的说明:FieldSet
Read theBigDecimal
value at index 'index
', returning the supplieddefaultValue
if the trimmed string value at index 'index
' is blank.- 指定者:
readBigDecimal
在接口中FieldSet
- 参数:
index
- the field index.defaultValue
- the value to use if the field value is blank.- 返回:
BigDecimal
containing the value from the specified index.
readBigDecimal
public java.math.BigDecimal readBigDecimal(java.lang.String name, java.math.BigDecimal defaultValue)
从接口复制的说明:FieldSet
Read theBigDecimal
value from column with given 'name
, returning the supplieddefaultValue
if the trimmed string value at index 'index
' is blank.- 指定者:
readBigDecimal
在接口中FieldSet
- 参数:
name
- the fieldname
.defaultValue
- the default value to use if the field is blank- 返回:
BigDecimal
containing the value from the specifiedname
.
readDate
public java.util.Date readDate(int index)
从接口复制的说明:FieldSet
Read thejava.util.Date
value in default format at designated columnindex
.
readDate
public java.util.Date readDate(int index, java.util.Date defaultValue)
从接口复制的说明:FieldSet
Read thejava.util.Date
value in default format at designated columnindex
.
readDate
public java.util.Date readDate(java.lang.String name)
从接口复制的说明:FieldSet
Read thejava.sql.Date
value in given format from column with givenname
.
readDate
public java.util.Date readDate(java.lang.String name, java.util.Date defaultValue)
从接口复制的说明:FieldSet
Read thejava.sql.Date
value in given format from column with givenname
.
readDate
public java.util.Date readDate(int index, java.lang.String pattern)
从接口复制的说明:FieldSet
Read thejava.util.Date
value in default format at designated columnindex
.
readDate
public java.util.Date readDate(int index, java.lang.String pattern, java.util.Date defaultValue)
从接口复制的说明:FieldSet
Read thejava.util.Date
value in default format at designated columnindex
.
readDate
public java.util.Date readDate(java.lang.String name, java.lang.String pattern)
从接口复制的说明:FieldSet
Read thejava.sql.Date
value in given format from column with givenname
.
readDate
public java.util.Date readDate(java.lang.String name, java.lang.String pattern, java.util.Date defaultValue)
从接口复制的说明:FieldSet
Read thejava.sql.Date
value in given format from column with givenname
.
getFieldCount
public int getFieldCount()
从接口复制的说明:FieldSet
Return the number of fields in this 'FieldSet
'.- 指定者:
getFieldCount
在接口中FieldSet
- 返回:
- int containing the number of fields in this field set.
readAndTrim
protected java.lang.String readAndTrim(int index)
Read and trim theString
value at 'index
'.- 参数:
index
- the offset in the token array to obtain the value to be trimmed.- 返回:
- null if the field value is
null
.
indexOf
protected int indexOf(java.lang.String name)
Retrieve the index of where a specified column is located based on thename
parameter.- 参数:
name
- the value to search in theList
of names.- 返回:
- the index in the
List
of names where the name was found. - 抛出:
java.lang.IllegalArgumentException
- if a column with given name is not defined.
toString
public java.lang.String toString()
- 覆盖:
toString
在类中java.lang.Object
equals
public boolean equals(java.lang.Object object)
- 覆盖:
equals
在类中java.lang.Object
- 另请参阅:
Object.equals(java.lang.Object)
hashCode
public int hashCode()
- 覆盖:
hashCode
在类中java.lang.Object
getProperties
public java.util.Properties getProperties()
从接口复制的说明:FieldSet
Construct name-value pairs from the field names and string values. Null values are omitted.- 指定者:
getProperties
在接口中FieldSet
- 返回:
- some properties representing the field set.