本文整理汇总了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);
}
}
}
示例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);
}
示例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);
}
示例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);
}