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


Java JSONParser.EOF属性代码示例

本文整理汇总了Java中org.noggit.JSONParser.EOF属性的典型用法代码示例。如果您正苦于以下问题:Java JSONParser.EOF属性的具体用法?Java JSONParser.EOF怎么用?Java JSONParser.EOF使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.noggit.JSONParser的用法示例。


在下文中一共展示了JSONParser.EOF属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleStreamingSingleDocs

private void handleStreamingSingleDocs() throws IOException
{
  while( true ) {
    int ev = parser.nextEvent();
    if(ev == JSONParser.EOF) return;
    if(ev == JSONParser.OBJECT_START) {
      assertEvent(ev, JSONParser.OBJECT_START);
      AddUpdateCommand cmd = new AddUpdateCommand(req);
      cmd.commitWithin = commitWithin;
      cmd.overwrite = overwrite;
      cmd.solrDoc = parseDoc(ev);
      processor.processAdd(cmd);
    } else if(ev == JSONParser.ARRAY_START){
      handleAdds();
    } else{
      throw  new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unexpected event :"+ev);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:JsonLoader.java

示例2: noggit

@Benchmark
public void noggit(Blackhole bh) throws Exception {
	JSONParser p = new JSONParser(chars, 0, chars.length);
	p.setFlags(JSONParser.FLAGS_STRICT);
	int i = 0, e;
	while ((e = p.nextEvent()) != JSONParser.EOF)
		i += e;
	bh.consume(i);
}
 
开发者ID:httpdigest,项目名称:ftljson,代码行数:9,代码来源:B.java

示例3: OpenExchangeRates

public OpenExchangeRates(InputStream ratesStream) throws IOException {
  parser = new JSONParser(new InputStreamReader(ratesStream, StandardCharsets.UTF_8));
  rates = new HashMap<>();
  
  int ev;
  do {
    ev = parser.nextEvent();
    switch( ev ) {
      case JSONParser.STRING:
        if( parser.wasKey() ) {
          String key = parser.getString();
          if(key.equals("disclaimer")) {
            parser.nextEvent();
            disclaimer = parser.getString();
          } else if(key.equals("license")) {
            parser.nextEvent();
            license = parser.getString();
          } else if(key.equals("timestamp")) {
            parser.nextEvent();
            timestamp = parser.getLong();
          } else if(key.equals("base")) {
            parser.nextEvent();
            baseCurrency = parser.getString();
          } else if(key.equals("rates")) {
            ev = parser.nextEvent();
            assert(ev == JSONParser.OBJECT_START);
            ev = parser.nextEvent();
            while (ev != JSONParser.OBJECT_END) {
              String curr = parser.getString();
              ev = parser.nextEvent();
              Double rate = parser.getDouble();
              rates.put(curr, rate);
              ev = parser.nextEvent();                  
            }
          } else {
            log.warn("Unknown key "+key);
          }
          break;
        } else {
          log.warn("Expected key, got "+JSONParser.getEventString(ev));
          break;
        }
         
      case JSONParser.OBJECT_END:
      case JSONParser.OBJECT_START:
      case JSONParser.EOF:
        break;

      default:
        log.info("Noggit UNKNOWN_EVENT_ID:"+JSONParser.getEventString(ev));
        break;
    }
  } while( ev != JSONParser.EOF);
}
 
开发者ID:europeana,项目名称:search,代码行数:54,代码来源:OpenExchangeRatesOrgProvider.java

示例4: OpenExchangeRates

public OpenExchangeRates(InputStream ratesStream) throws IOException {
  parser = new JSONParser(new InputStreamReader(ratesStream, IOUtils.CHARSET_UTF_8));
  rates = new HashMap<String, Double>();
  
  int ev;
  do {
    ev = parser.nextEvent();
    switch( ev ) {
      case JSONParser.STRING:
        if( parser.wasKey() ) {
          String key = parser.getString();
          if(key.equals("disclaimer")) {
            parser.nextEvent();
            disclaimer = parser.getString();
          } else if(key.equals("license")) {
            parser.nextEvent();
            license = parser.getString();
          } else if(key.equals("timestamp")) {
            parser.nextEvent();
            timestamp = parser.getLong();
          } else if(key.equals("base")) {
            parser.nextEvent();
            baseCurrency = parser.getString();
          } else if(key.equals("rates")) {
            ev = parser.nextEvent();
            assert(ev == JSONParser.OBJECT_START);
            ev = parser.nextEvent();
            while (ev != JSONParser.OBJECT_END) {
              String curr = parser.getString();
              ev = parser.nextEvent();
              Double rate = parser.getDouble();
              rates.put(curr, rate);
              ev = parser.nextEvent();                  
            }
          } else {
            log.warn("Unknown key "+key);
          }
          break;
        } else {
          log.warn("Expected key, got "+JSONParser.getEventString(ev));
          break;
        }
         
      case JSONParser.OBJECT_END:
      case JSONParser.OBJECT_START:
      case JSONParser.EOF:
        break;

      default:
        log.info("Noggit UNKNOWN_EVENT_ID:"+JSONParser.getEventString(ev));
        break;
    }
  } while( ev != JSONParser.EOF);
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:54,代码来源:OpenExchangeRatesOrgProvider.java


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