本文整理匯總了Java中com.fasterxml.jackson.core.JsonParser.isClosed方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonParser.isClosed方法的具體用法?Java JsonParser.isClosed怎麽用?Java JsonParser.isClosed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.fasterxml.jackson.core.JsonParser
的用法示例。
在下文中一共展示了JsonParser.isClosed方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: deserialize
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public List<T> deserialize(InputStream stream) throws WaySegmentDeserializationException {
try {
JsonParser jp = jsonFactory.createParser(stream);
List<T> segments = new ArrayList<T>();
JsonToken token = jp.nextToken();
ISegmentAdapter<IBaseSegmentDTO, T> adapter = null;
while(!jp.isClosed()){
token = jp.nextToken();
// extract type of segments. its encoded as the name of the array field holding the segments
if (jp.getCurrentToken() == JsonToken.FIELD_NAME) {
String segmentType = jp.getCurrentName();
adapter = this.getAndRegisterDeserializers(segmentType);
}
else if(token != null && token != JsonToken.END_ARRAY && token != JsonToken.END_OBJECT) {
segments.add(processSegment(jp, adapter));
}
}
log.info("parsed: " + segments.size() + " segments");
return segments;
} catch (Exception e) {
throw new WaySegmentDeserializationException(e.getMessage(),e);
}
}
示例2: deserialize
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public List<IBaseSegmentDTO> deserialize(InputStream stream) throws WaySegmentDeserializationException {
try {
JsonParser jp = jsonFactory.createParser(stream);
List<IBaseSegmentDTO> segments = new ArrayList<IBaseSegmentDTO>();
JsonToken token = jp.nextToken();
ISegmentAdapter<IBaseSegmentDTO, T> adapter = null;
while(!jp.isClosed()){
token = jp.nextToken();
// extract type of segments. its encoded as the name of the array field holding the segments
if (jp.getCurrentToken() == JsonToken.FIELD_NAME) {
String segmentType = jp.getCurrentName();
adapter = this.getAndRegisterDeserializers(segmentType);
}
else if(token != null && token != JsonToken.END_ARRAY && token != JsonToken.END_OBJECT) {
segments.add(processSegment(jp, adapter));
}
}
log.info("parsed: " + segments.size() + " segments");
return segments;
} catch (Exception e) {
throw new WaySegmentDeserializationException(e.getMessage(),e);
}
}
示例3: deserialize
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
@Override
public void deserialize(InputStream stream, BlockingQueue<T> outputQueue)
throws WaySegmentDeserializationException {
try {
JsonParser jp = jsonFactory.createParser(stream);
JsonToken token = jp.nextToken();
long count = 0;
ISegmentAdapter<IBaseSegmentDTO, T> adapter = null;
while(!jp.isClosed()){
token = jp.nextToken();
// extract type of segments. its encoded as the name of the array field holding the segments
if (jp.getCurrentToken() == JsonToken.FIELD_NAME) {
String segmentType = jp.getCurrentName();
adapter = this.getAndRegisterDeserializers(segmentType);
}
else if(token != null && token != JsonToken.END_ARRAY && token != JsonToken.END_OBJECT) {
enqueue(outputQueue, processSegment(jp, adapter));
count++;
}
}
log.info("parsed and enqueued: " + count + " segments");
} catch (Exception e) {
throw new WaySegmentDeserializationException(e.getMessage(),e);
}
}
示例4: deserialize
import com.fasterxml.jackson.core.JsonParser; //導入方法依賴的package包/類
/**
* @param stream InputStream containing JSON data
* @param segmentsQueue Queue retrieving parsed way segment objects
* @param metadataQueue Queue retrieving parsed metadata object; there will be retrieved only one object
*/
@Override
public void deserialize(InputStream stream, BlockingQueue<T> segmentsQueue,
BlockingQueue<IWayGraphVersionMetadata> metadataQueue)
throws WaySegmentDeserializationException {
try {
JsonParser jp = jsonFactory.createParser(stream);
JsonToken token = jp.nextToken();
long count = 0;
ISegmentAdapter<IBaseSegmentDTO, T> adapter = null;
while (!jp.isClosed()){
token = jp.nextToken();
if (token != null && token != JsonToken.END_ARRAY) {
if (jp.getCurrentToken() == JsonToken.FIELD_NAME &&
jp.getCurrentName().equals("graphVersionMetadata")) {
jp.nextToken();
IGraphVersionMetadataDTO dto = jp.readValueAs(GraphVersionMetadataDTOImpl.class);
IWayGraphVersionMetadata metadata = metadataAdapter.adapt(dto);
metadataQueue.offer(metadata, 500, TimeUnit.MILLISECONDS);
}
// extract type of segments. its encoded as the name of the array field holding the segments
else if (jp.getCurrentToken() == JsonToken.FIELD_NAME) {
String segmentType = jp.getCurrentName();
adapter = this.getAndRegisterDeserializers(segmentType);
}
else if (jp.getCurrentToken() != JsonToken.END_OBJECT) {
enqueue(segmentsQueue, processSegment(jp, adapter));
count++;
}
}
}
log.info("parsed and enqueued: " + count + " segments");
} catch (Exception e) {
throw new WaySegmentDeserializationException(e.getMessage(),e);
}
}