当前位置: 首页>>代码示例>>Java>>正文


Java JsonParser.isClosed方法代码示例

本文整理汇总了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);
       }
   }
 
开发者ID:graphium-project,项目名称:graphium,代码行数:27,代码来源:GenericJacksonSegmentInputFormat.java

示例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);
       }
   }
 
开发者ID:graphium-project,项目名称:graphium,代码行数:27,代码来源:JacksonBaseSegmentDTOInputFormat.java

示例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);
       }		
}
 
开发者ID:graphium-project,项目名称:graphium,代码行数:28,代码来源:GenericQueuingJacksonSegmentInputFormat.java

示例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);
    }
}
 
开发者ID:graphium-project,项目名称:graphium,代码行数:47,代码来源:GenericQueuingJacksonGraphInputFormat.java


注:本文中的com.fasterxml.jackson.core.JsonParser.isClosed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。