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) {