类 ValidatingItemProcessor<T>
- java.lang.Object
- org.springframework.batch.item.validator.ValidatingItemProcessor<T>
- 所有已实现的接口:
ItemProcessor<T,T>,org.springframework.beans.factory.InitializingBean
- 直接已知子类:
BeanValidatingItemProcessor
public class ValidatingItemProcessor<T> extends java.lang.Object implements ItemProcessor<T,T>, org.springframework.beans.factory.InitializingBean
Simple implementation ofItemProcessorthat validates input and returns it without modifications. Should the givenValidatorthrow aValidationExceptionthis processor will re-throw it to indicate the item should be skipped, unlesssetFilter(boolean)is set totrue, in which casenullwill be returned to indicate the item should be filtered.- 作者:
- Robert Kasanicky
构造器概要
构造器 构造器 说明 ValidatingItemProcessor()Default constructorValidatingItemProcessor(Validator<? super T> validator)Creates a ValidatingItemProcessor based on the given Validator.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidafterPropertiesSet()Tprocess(T item)Validate the item and return it unmodifiedvoidsetFilter(boolean filter)Should the processor filter invalid records instead of skipping them?voidsetValidator(Validator<? super T> validator)Set the validator used to validate each item.
构造器详细资料
ValidatingItemProcessor
public ValidatingItemProcessor()
Default constructor
ValidatingItemProcessor
public ValidatingItemProcessor(Validator<? super T> validator)
Creates a ValidatingItemProcessor based on the given Validator.- 参数:
validator- theValidatorinstance to be used.
方法详细资料
setValidator
public void setValidator(Validator<? super T> validator)
Set the validator used to validate each item.- 参数:
validator- theValidatorinstance to be used.
setFilter
public void setFilter(boolean filter)
Should the processor filter invalid records instead of skipping them?- 参数:
filter- if set totrue, items that fail validation are filtered (nullis returned). Otherwise, aValidationExceptionwill be thrown.
process
public T process(T item) throws ValidationException
Validate the item and return it unmodified- 指定者:
process在接口中ItemProcessor<T,T>- 参数:
item- to be processed- 返回:
- the input item
- 抛出:
ValidationException- if validation fails
afterPropertiesSet
public void afterPropertiesSet() throws java.lang.Exception
- 指定者:
afterPropertiesSet在接口中org.springframework.beans.factory.InitializingBean- 抛出:
java.lang.Exception