當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。