类 JsonItemReader<T>
- java.lang.Object
- org.springframework.batch.item.ItemStreamSupport
- org.springframework.batch.item.support.AbstractItemStreamItemReader<T>
- org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader<T>
- org.springframework.batch.item.json.JsonItemReader<T>
- 类型参数:
T
- the type of json objects to read
- 所有已实现的接口:
ResourceAwareItemReaderItemStream<T>
,ItemReader<T>
,ItemStream
,ItemStreamReader<T>
public class JsonItemReader<T> extends AbstractItemCountingItemStreamItemReader<T> implements ResourceAwareItemReaderItemStream<T>
ItemStreamReader
implementation that reads Json objects from aResource
having the following format:[ { // JSON object }, { // JSON object } ]
The implementation is not thread-safe.
- 从以下版本开始:
- 4.1
- 作者:
- Mahmoud Ben Hassine
构造器概要
构造器 构造器 说明 JsonItemReader(org.springframework.core.io.Resource resource, JsonObjectReader<T> jsonObjectReader)
Create a newJsonItemReader
instance.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected void
doClose()
Close the resources opened inAbstractItemCountingItemStreamItemReader.doOpen()
.protected void
doOpen()
Open resources necessary to start reading input.protected T
doRead()
Read next item from input.void
setJsonObjectReader(JsonObjectReader<T> jsonObjectReader)
Set theJsonObjectReader
to use to read and map Json fragments to domain objects.void
setResource(org.springframework.core.io.Resource resource)
void
setStrict(boolean strict)
In strict mode the reader will throw an exception onAbstractItemCountingItemStreamItemReader.open(org.springframework.batch.item.ExecutionContext)
if the input resource does not exist.从类继承的方法 org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader
close, getCurrentItemCount, isSaveState, jumpToItem, open, read, setCurrentItemCount, setMaxItemCount, setSaveState, update
从类继承的方法 org.springframework.batch.item.ItemStreamSupport
getExecutionContextKey, setExecutionContextName, setName
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 org.springframework.batch.item.ItemReader
read
从接口继承的方法 org.springframework.batch.item.ItemStream
close, open, update
构造器详细资料
JsonItemReader
public JsonItemReader(org.springframework.core.io.Resource resource, JsonObjectReader<T> jsonObjectReader)
Create a newJsonItemReader
instance.- 参数:
resource
- the input json resourcejsonObjectReader
- the json object reader to use
方法详细资料
setJsonObjectReader
public void setJsonObjectReader(JsonObjectReader<T> jsonObjectReader)
Set theJsonObjectReader
to use to read and map Json fragments to domain objects.- 参数:
jsonObjectReader
- the json object reader to use
setStrict
public void setStrict(boolean strict)
In strict mode the reader will throw an exception onAbstractItemCountingItemStreamItemReader.open(org.springframework.batch.item.ExecutionContext)
if the input resource does not exist.- 参数:
strict
- true by default
setResource
public void setResource(org.springframework.core.io.Resource resource)
- 指定者:
setResource
在接口中ResourceAwareItemReaderItemStream<T>
doRead
protected T doRead() throws java.lang.Exception
Read next item from input.- 指定者:
doRead
在类中AbstractItemCountingItemStreamItemReader<T>
- 返回:
- an item or
null
if the data source is exhausted - 抛出:
java.lang.Exception
- Allows subclasses to throw checked exceptions for interpretation by the framework
doOpen
protected void doOpen() throws java.lang.Exception
Open resources necessary to start reading input.- 指定者:
doOpen
在类中AbstractItemCountingItemStreamItemReader<T>
- 抛出:
java.lang.Exception
- Allows subclasses to throw checked exceptions for interpretation by the framework
doClose
protected void doClose() throws java.lang.Exception
Close the resources opened inAbstractItemCountingItemStreamItemReader.doOpen()
.- 指定者:
doClose
在类中AbstractItemCountingItemStreamItemReader<T>
- 抛出:
java.lang.Exception
- Allows subclasses to throw checked exceptions for interpretation by the framework