public void parse(InputSource input) throws IOException, SAXException {
try {
CharStream charStream;
InputStream inputStream = null;
if(null != input.getByteStream()) {
charStream = new ANTLRInputStream(input.getByteStream());
} else if (null != input.getCharacterStream()){
charStream = new ANTLRReaderStream(input.getCharacterStream());
} else {
try {
URL url = new URL(input.getSystemId());
inputStream = url.openStream();
} catch(MalformedURLException malformedURLException) {
try {
inputStream = new FileInputStream(input.getSystemId());
} catch(FileNotFoundException fileNotFoundException) {
inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(input.getSystemId());
if (null == inputStream) {
throw malformedURLException;
}
}
}
charStream = new ANTLRInputStream(inputStream);
}
JSONLexer lexer = new JSONLexer(charStream);
TokenRewriteStream tokens = new TokenRewriteStream(lexer);
ExtendedJSONParser parser = new ExtendedJSONParser(tokens, input, getErrorHandler());
CommonTree commonTree = (CommonTree) parser.message().getTree();