类 SingleItemPeekableItemReader<T>
- java.lang.Object
- org.springframework.batch.item.support.SingleItemPeekableItemReader<T>
- 所有已实现的接口:
ItemReader<T>
,ItemStream
,ItemStreamReader<T>
,PeekableItemReader<T>
public class SingleItemPeekableItemReader<T> extends java.lang.Object implements ItemStreamReader<T>, PeekableItemReader<T>
A
PeekableItemReader
that allows the user to peek one item ahead. Repeated calls topeek()
will return the same item, and this will be the next item returned fromread()
.Intentionally not thread-safe: it wouldn't be possible to honour the peek in multiple threads because only one of the threads that peeked would get that item in the next call to read.
- 作者:
- Dave Syer
构造器概要
构造器 构造器 说明 SingleItemPeekableItemReader()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
close()
If the delegate is anItemStream
, just pass the call on, otherwise reset the peek cache.void
open(ExecutionContext executionContext)
If the delegate is anItemStream
, just pass the call on, otherwise reset the peek cache.T
peek()
Peek at the next item, ensuring that if the delegate is anItemStream
the state is stored for the next call toupdate(ExecutionContext)
.T
read()
Get the next item from the delegate (whether or not it has already been peeked at).void
setDelegate(ItemReader<T> delegate)
The item reader to use as a delegate.void
update(ExecutionContext executionContext)
If there is a cached peek, then retrieve the execution context state from that point.
构造器详细资料
SingleItemPeekableItemReader
public SingleItemPeekableItemReader()
方法详细资料
setDelegate
public void setDelegate(ItemReader<T> delegate)
The item reader to use as a delegate. Items are read from the delegate and passed to the caller inread()
.- 参数:
delegate
- the delegate to set
read
public T read() throws java.lang.Exception, UnexpectedInputException, ParseException
Get the next item from the delegate (whether or not it has already been peeked at).- 指定者:
read
在接口中ItemReader<T>
- 返回:
- T the item to be processed or
null
if the data source is exhausted - 抛出:
ParseException
- if there is a problem parsing the current record (but the next one may still be valid)NonTransientResourceException
- if there is a fatal exception in the underlying resource. After throwing this exception implementations should endeavour to return null from subsequent calls to read.UnexpectedInputException
- if there is an uncategorised problem with the input data. Assume potentially transient, so subsequent calls to read might succeed.java.lang.Exception
- if an there is a non-specific error.- 另请参阅:
ItemReader.read()
peek
public T peek() throws java.lang.Exception, UnexpectedInputException, ParseException
Peek at the next item, ensuring that if the delegate is anItemStream
the state is stored for the next call toupdate(ExecutionContext)
.- 指定者:
peek
在接口中PeekableItemReader<T>
- 返回:
- the next item (or null if there is none).
- 抛出:
java.lang.Exception
- if there is a problemUnexpectedInputException
ParseException
- 另请参阅:
PeekableItemReader.peek()
close
public void close() throws ItemStreamException
If the delegate is anItemStream
, just pass the call on, otherwise reset the peek cache.- 指定者:
close
在接口中ItemStream
- 抛出:
ItemStreamException
- if there is a problem- 另请参阅:
ItemStream.close()
open
public void open(ExecutionContext executionContext) throws ItemStreamException
If the delegate is anItemStream
, just pass the call on, otherwise reset the peek cache.- 指定者:
open
在接口中ItemStream
- 参数:
executionContext
- the current context- 抛出:
ItemStreamException
- if there is a problem- 另请参阅:
ItemStream.open(ExecutionContext)
update
public void update(ExecutionContext executionContext) throws ItemStreamException
If there is a cached peek, then retrieve the execution context state from that point. If there is no peek cached, then call directly to the delegate.- 指定者:
update
在接口中ItemStream
- 参数:
executionContext
- the current context- 抛出:
ItemStreamException
- if there is a problem- 另请参阅:
ItemStream.update(ExecutionContext)