spring-batch FieldSet 源码
spring-batch FieldSet 代码
文件路径:/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/file/transform/FieldSet.java
/*
* Copyright 2006-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.item.file.transform;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.util.Date;
import java.util.Properties;
/**
* 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 by {@link ResultSet}
* in JDBC, clients will know the name or position of strongly typed fields that they want
* to extract.
*
* @author Dave Syer
*
*/
public interface FieldSet {
/**
* Accessor for the names of the fields.
* @return the names
* @throws IllegalStateException if the names are not defined
*/
String[] getNames();
/**
* Check if there are names defined for the fields.
* @return true if there are names for the fields
*/
boolean hasNames();
/**
* @return fields wrapped by this '<code>FieldSet</code>' instance as String values.
*/
String[] getValues();
/**
* Read the {@link String} value at index '<code>index</code>'.
* @param index the field index.
* @return {@link String} containing the value at the index.
* @throws IndexOutOfBoundsException if the {@code index} is out of bounds.
*/
String readString(int index);
/**
* Read the {@link String} value from column with given '<code>name</code>'.
* @param name the field {@code name}.
* @return {@link String} containing the value from the specified {@code name}.
*/
String readString(String name);
/**
* Read the {@link String} value at index '<code>index</code>' including trailing
* whitespace (don't trim).
* @param index the field index.
* @return {@link String} containing the value from the specified {@code index}.
* @throws IndexOutOfBoundsException if the {@code index} is out of bounds.
*/
String readRawString(int index);
/**
* Read the {@link String} value from column with given '<code>name</code>' including
* trailing whitespace (don't trim).
* @param name the field {@code name}.
* @return {@link String} containing the value from the specified {@code name}.
*/
String readRawString(String name);
/**
* Read the '<code>boolean</code>' value at index '<code>index</code>'.
* @param index the field index.
* @return boolean containing the value from the specified {@code index}.
* @throws IndexOutOfBoundsException if the {@code index} is out of bounds.
*/
boolean readBoolean(int index);
/**
* Read the '<code>boolean</code>' value from column with given '<code>name</code>'.
* @param name the field {@code name}.
* @return boolean containing the value from the specified {@code name}.
* @throws IllegalArgumentException if a column with given {@code name} is not
* defined.
*/
boolean readBoolean(String name);
/**
* Read the '<code>boolean</code>' value at index '<code>index</code>'.
* @param index the field index.
* @param trueValue the value that signifies {@link Boolean#TRUE true};
* case-sensitive.
* @return boolean containing the value from the specified {@code index}.
* @throws IndexOutOfBoundsException if the index is out of bounds, or if the supplied
* <code>trueValue</code> is <code>null</code>.
*/
boolean readBoolean(int index, String trueValue);
/**
* Read the '<code>boolean</code>' value from column with given '<code>name</code>'.
* @param name the field {@code name}.
* @param trueValue the value that signifies {@link Boolean#TRUE true};
* case-sensitive.
* @return boolean containing the value from the specified {@code name}.
* @throws IllegalArgumentException if a column with given {@code name} is not
* defined, or if the supplied <code>trueValue</code> is <code>null</code>.
*/
boolean readBoolean(String name, String trueValue);
/**
* Read the '<code>char</code>' value at index '<code>index</code>'.
* @param index the field index.
* @return char containing the value from the specified {@code index}.
* @throws IndexOutOfBoundsException if the index is out of bounds.
*/
char readChar(int index);
/**
* Read the '<code>char</code>' value from column with given '<code>name</code>'.
* @param name the field {@code name}.
* @return char containing the value from the specified {@code name}.
* @throws IllegalArgumentException if a column with given {@code name} is not
* defined.
*/
char readChar(String name);
/**
* Read the '<code>byte</code>' value at index '<code>index</code>'.
* @param index the field index.
* @return byte containing the value from the specified {@code index}.
* @throws IndexOutOfBoundsException if the index is out of bounds.
*/
byte readByte(int index);
/**
* Read the '<code>byte</code>' value from column with given '<code>name</code>'.
* @param name the field {@code name}.
* @return byte containing the value from the specified {@code name}.
*/
byte readByte(String name);
/**
* Read the '<code>short</code>' value at index '<code>index</code>'.
* @param index the field {@code index}.
* @return short containing the value from the specified index.
* @throws IndexOutOfBoundsException if the index is out of bounds.
*/
short readShort(int index);
/**
* Read the '<code>short</code>' value from column with given '<code>name</code>'.
* @param name the field {@code name}.
* @return short containing the value from the specified {@code name}.
* @throws IllegalArgumentException if a column with given {@code name} is not
* defined.
*/
short readShort(String name);
/**
* Read the '<code>int</code>' value at index '<code>index</code>'.
* @param index the field index.
* @return int containing the value from the specified index.
* @throws IndexOutOfBoundsException if the index is out of bounds.
*/
int readInt(int index);
/**
* Read the '<code>int</code>' value from column with given '<code>name</code>'.
* @param name the field {@code name}.
* @return int containing the value from the specified {@code name}.
* @throws IllegalArgumentException if a column with given {@code name} is not
* defined.
*/
int readInt(String name);
/**
* Read the '<code>int</code>' value at index '<code>index</code>', using the supplied
* <code>defaultValue</code> if the field value is blank.
* @param index the field index.
* @param defaultValue the value to use if the field value is blank.
* @return int containing the value from the specified index.
* @throws IndexOutOfBoundsException if the index is out of bounds.
*/
int readInt(int index, int defaultValue);
/**
* Read the '<code>int</code>' value from column with given '<code>name</code>', using
* the supplied <code>defaultValue</code> if the field value is blank.
* @param name the field {@code name}.
* @param defaultValue the value to use if the field value is blank.
* @return int containing the value from the specified {@code name}.
* @throws IllegalArgumentException if a column with given {@code name} is not
* defined.
*/
int readInt(String name, int defaultValue);
/**
* Read the '<code>long</code>' value at index '<code>index</code>'.
* @param index the field index.
* @return long containing the value from the specified index.
* @throws IndexOutOfBoundsException if the index is out of bounds.
*/
long readLong(int index);
/**
* Read the '<code>long</code>' value from column with given '<code>name</code>'.
* @param name the field {@code name}.
* @return long containing the value from the specified {@code name}.
* @throws IllegalArgumentException if a column with given {@code name} is not
* defined.
*/
long readLong(String name);
/**
* Read the '<code>long</code>' value at index '<code>index</code>', using the
* supplied <code>defaultValue</code> if the field value is blank.
* @param index the field index.
* @param defaultValue the value to use if the field value is blank.
* @return long containing the value from the specified index.
* @throws IndexOutOfBoundsException if the index is out of bounds.
*/
long readLong(int index, long defaultValue);
/**
* Read the '<code>long</code>' value from column with given '<code>name</code>',
* using the supplied <code>defaultValue</code> if the field value is blank.
* @param name the field {@code name}.
* @param defaultValue the value to use if the field value is blank.
* @return long containing the value from the specified {@code name}.
* @throws IllegalArgumentException if a column with given {@code name} is not
* defined.
*/
long readLong(String name, long defaultValue);
/**
* Read the '<code>float</code>' value at index '<code>index</code>'.
* @param index the field index.
* @return float containing the value from the specified index.
* @throws IndexOutOfBoundsException if the index is out of bounds.
*/
float readFloat(int index);
/**
* Read the '<code>float</code>' value from column with given '<code>name</code>.
* @param name the field {@code name}.
* @return float containing the value from the specified {@code name}.
* @throws IllegalArgumentException if a column with given {@code name} is not
* defined.
*/
float readFloat(String name);
/**
* Read the '<code>double</code>' value at index '<code>index</code>'.
* @param index the field index.
* @return double containing the value from the specified index.
* @throws IndexOutOfBoundsException if the index is out of bounds.
*/
double readDouble(int index);
/**
* Read the '<code>double</code>' value from column with given '<code>name</code>.
* @param name the field {@code name}.
* @return double containing the value from the specified {@code name}.
* @throws IllegalArgumentException if a column with given {@code name} is not
* defined.
*/
double readDouble(String name);
/**
* Read the {@link java.math.BigDecimal} value at index '<code>index</code>'.
* @param index the field index.
* @return {@link BigDecimal} containing the value from the specified index.
* @throws IndexOutOfBoundsException if the index is out of bounds.
*/
BigDecimal readBigDecimal(int index);
/**
* Read the {@link java.math.BigDecimal} value from column with given
* '<code>name</code>.
* @param name the field {@code name}.
* @return {@link BigDecimal} containing the value from the specified {@code name}.
* @throws IllegalArgumentException if a column with given {@code name} is not
* defined.
*/
BigDecimal readBigDecimal(String name);
/**
* Read the {@link BigDecimal} value at index '<code>index</code>', returning the
* supplied <code>defaultValue</code> if the trimmed string value at index
* '<code>index</code>' is blank.
* @param index the field index.
* @param defaultValue the value to use if the field value is blank.
* @return {@link BigDecimal} containing the value from the specified index.
* @throws IndexOutOfBoundsException if the index is out of bounds.
*/
BigDecimal readBigDecimal(int index, BigDecimal defaultValue);
/**
* Read the {@link BigDecimal} value from column with given '<code>name</code>,
* returning the supplied <code>defaultValue</code> if the trimmed string value at
* index '<code>index</code>' is blank.
* @param name the field {@code name}.
* @param defaultValue the default value to use if the field is blank
* @return {@link BigDecimal} containing the value from the specified {@code name}.
* @throws IllegalArgumentException if a column with given {@code name} is not
* defined.
*/
BigDecimal readBigDecimal(String name, BigDecimal defaultValue);
/**
* Read the <code>java.util.Date</code> value in default format at designated column
* <code>index</code>.
* @param index the field index.
* @return {@link Date} containing the value from the specified index.
* @throws IndexOutOfBoundsException if the index is out of bounds.
* @throws IllegalArgumentException if the value is not parseable
* @throws NullPointerException if the value is empty
*/
Date readDate(int index);
/**
* Read the <code>java.sql.Date</code> value in given format from column with given
* <code>name</code>.
* @param name the field {@code name}.
* @return {@link Date} containing the value from the specified {@code name}.
* @throws IllegalArgumentException if a column with given {@code name} is not defined
* or if the value is not parseable
* @throws NullPointerException if the value is empty
*/
Date readDate(String name);
/**
* Read the <code>java.util.Date</code> value in default format at designated column
* <code>index</code>.
* @param index the field index.
* @param defaultValue the default value to use if the field is blank
* @return {@link Date} containing the value from the specified index.
* @throws IndexOutOfBoundsException if the index is out of bounds.
* @throws IllegalArgumentException if the value is not parseable
* @throws NullPointerException if the value is empty
*/
Date readDate(int index, Date defaultValue);
/**
* Read the <code>java.sql.Date</code> value in given format from column with given
* <code>name</code>.
* @param name the field {@code name}.
* @param defaultValue the default value to use if the field is blank
* @return {@link Date} containing the value from the specified {@code name}.
* @throws IllegalArgumentException if a column with given {@code name} is not
* defined.
*/
Date readDate(String name, Date defaultValue);
/**
* Read the <code>java.util.Date</code> value in default format at designated column
* <code>index</code>.
* @param index the field index.
* @param pattern the pattern describing the date and time format
* @return {@link Date} containing the value from the specified index.
* @throws IndexOutOfBoundsException if the index is out of bounds.
* @throws IllegalArgumentException if the date cannot be parsed.
*
*/
Date readDate(int index, String pattern);
/**
* Read the <code>java.sql.Date</code> value in given format from column with given
* <code>name</code>.
* @param name the field {@code name}.
* @param pattern the pattern describing the date and time format
* @return {@link Date} containing the value from the specified {@code name}.
* @throws IllegalArgumentException if a column with given {@code name} is not defined
* or if the specified field cannot be parsed
*
*/
Date readDate(String name, String pattern);
/**
* Read the <code>java.util.Date</code> value in default format at designated column
* <code>index</code>.
* @param index the field index.
* @param pattern the pattern describing the date and time format
* @param defaultValue the default value to use if the field is blank
* @return {@link Date} containing the value from the specified index.
* @throws IndexOutOfBoundsException if the index is out of bounds.
* @throws IllegalArgumentException if the date cannot be parsed.
*
*/
Date readDate(int index, String pattern, Date defaultValue);
/**
* Read the <code>java.sql.Date</code> value in given format from column with given
* <code>name</code>.
* @param name the field {@code name}.
* @param pattern the pattern describing the date and time format
* @param defaultValue the default value to use if the field is blank
* @return {@link Date} containing the value from the specified {@code name}.
* @throws IllegalArgumentException if a column with given {@code name} is not defined
* or if the specified field cannot be parsed
*
*/
Date readDate(String name, String pattern, Date defaultValue);
/**
* Return the number of fields in this '<code>FieldSet</code>'.
* @return int containing the number of fields in this field set.
*/
int getFieldCount();
/**
* Construct name-value pairs from the field names and string values. Null values are
* omitted.
* @return some properties representing the field set.
* @throws IllegalStateException if the field name meta data is not available.
*/
Properties getProperties();
}
相关信息
相关文章
spring-batch AbstractLineTokenizer 源码
spring-batch BeanWrapperFieldExtractor 源码
spring-batch ConversionException 源码
spring-batch DefaultFieldSet 源码
spring-batch DefaultFieldSetFactory 源码
spring-batch DelimitedLineAggregator 源码
spring-batch DelimitedLineTokenizer 源码
spring-batch ExtractorLineAggregator 源码
0
赞
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦