Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/* ============
* Orson Charts
* ============
*
* (C)opyright 2013-2020, by Object Refinery Limited.
*
* https://github.com/jfree/orson-charts
*
* JSON.simple
* -----------
* The code in this file originates from the JSON.simple project by
* FangYidong:
*
* https://code.google.com/p/json-simple/
*
* which is licensed under the Apache Software License version 2.0.
*
* It has been modified locally and repackaged under
* org.jfree.chart3d.util.json.* to avoid conflicts with any other version that
* may be present on the classpath.
*
*/
package org.jfree.chart3d.util.json.parser;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.jfree.chart3d.util.json.JSONArray;
import org.jfree.chart3d.util.json.JSONObject;
/**
* Parser for JSON text. Please note that JSONParser is NOT thread-safe.
*/
public class JSONParser {
public static final int S_INIT = 0;
public static final int S_IN_FINISHED_VALUE = 1;//string,number,boolean,null,object,array
public static final int S_IN_OBJECT = 2;
public static final int S_IN_ARRAY = 3;
public static final int S_PASSED_PAIR_KEY = 4;
public static final int S_IN_PAIR_VALUE = 5;
public static final int S_END = 6;
public static final int S_IN_ERROR = -1;
private LinkedList handlerStatusStack;
private Yylex lexer = new Yylex((Reader)null);
private Yytoken token = null;
private int status = S_INIT;
private int peekStatus(LinkedList statusStack){
if (statusStack.isEmpty()) {
return -1;
}
return statusStack.getFirst();
}
/**
* Reset the parser to the initial state without resetting the underlying
* reader.
*/
public void reset(){
token = null;
status = S_INIT;
handlerStatusStack = null;
}
/**
* Reset the parser to the initial state with a new character reader.
*
* @param in the new character reader.
*/
public void reset(Reader in){
lexer.yyreset(in);
reset();
}
/**
* @return The position of the beginning of the current token.
*/
public int getPosition(){
return lexer.getPosition();
}
public Object parse(String s) throws ParseException {
return parse(s, (ContainerFactory) null);
}
public Object parse(String s, ContainerFactory containerFactory)
throws ParseException {
StringReader in = new StringReader(s);
try {
return parse(in, containerFactory);
}
catch(IOException ie){
/*
* Actually it will never happen.
*/
throw new ParseException(-1,
ParseException.ERROR_UNEXPECTED_EXCEPTION, ie);
}
}
public Object parse(Reader in) throws IOException, ParseException {
return parse(in, (ContainerFactory) null);
}
/**
* Parse JSON text into java object from the input source.
*
* @param in the input source.
* @param containerFactory use this factory to create your own JSON
* object and JSON array containers.
* @return Instance of the following:
* org.jfree.chart3d.util.json.simple.JSONObject,
* org.jfree.chart3d.util.json.simple.JSONArray,
* java.lang.String,
* java.lang.Number,
* java.lang.Boolean,
* null
*
* @throws IOException if there is an I/O problem.
* @throws ParseException if there is a parsing problem.
*/
@SuppressWarnings("unchecked")
public Object parse(Reader in, ContainerFactory containerFactory)
throws IOException, ParseException{
reset(in);
LinkedList statusStack = new LinkedList<>();
LinkedList