private static void exception(String message, long line, long col) { throw new JsonParseException(message, (int)line, (int)col) ; } }
public JsonParseException(int line, int column) { super() ; set(line, column) ; }
public static void main(String... args) { if ( args.length == 0 ) args = new String[] {"-"} ; try { for ( String fn : args ) { JsonValue json =null ; try { json = JSON.readAny(fn) ; } catch (JsonParseException ex) { String name = fn.equals("-") ? "<stdin>" : fn ; System.err.println(name+": "+JsonParseException.formatMessage(ex.getMessage(), ex.getLine(), ex.getColumn())) ; continue ; } JSON.write(IndentedWriter.stdout, json) ; IndentedWriter.stdout.ensureStartOfLine() ; } } finally { IndentedWriter.stdout.flush() ; } }
/** * Read from a file if possible. * Return null if the file is not found or has a syntax error. */ public static StoreParams read(String filename) { try { InputStream in = IO.openFileEx(filename); if ( in == null ) return null; JsonObject obj = JSON.parse(in) ; return StoreParamsCodec.decode(obj) ; } catch (FileNotFoundException ex) { return null; } catch (JsonParseException ex) { FmtLog.warn(StoreParamsCodec.class, "Ignoring store params : Syntax error in '%s': [line:%d, col:%d] %s", filename, ex.getLine(), ex.getColumn(), ex.getMessage()); return null ; } catch (IOException e) { IO.exception(e); return null; } }
public static void main(String... args) { if ( args.length == 0 ) args = new String[] {"-"} ; try { for ( String fn : args ) { JsonValue json =null ; try { json = JSON.readAny(fn) ; } catch (JsonParseException ex) { String name = fn.equals("-") ? "<stdin>" : fn ; System.err.println(name+": "+JsonParseException.formatMessage(ex.getMessage(), ex.getLine(), ex.getColumn())) ; continue ; } JSON.write(IndentedWriter.stdout, json) ; IndentedWriter.stdout.ensureStartOfLine() ; } } finally { IndentedWriter.stdout.flush() ; } }
/** * Read from a file if possible. * Return null if the file is not found or has a syntax error. */ public static StoreParams read(String filename) { try { InputStream in = IO.openFileEx(filename); if ( in == null ) return null; JsonObject obj = JSON.parse(in) ; return StoreParamsCodec.decode(obj) ; } catch (FileNotFoundException ex) { return null; } catch (JsonParseException ex) { FmtLog.warn(StoreParamsCodec.class, "Ignoring store params : Syntax error in '%s': [line:%d, col:%d] %s", filename, ex.getLine(), ex.getColumn(), ex.getMessage()); return null ; } catch (IOException e) { IO.exception(e); return null; } }
public static void main(String... args) { if ( args.length == 0 ) args = new String[] {"-"} ; try { for ( String fn : args ) { JsonValue json =null ; try { json = JSON.readAny(fn) ; } catch (JsonParseException ex) { String name = fn.equals("-") ? "<stdin>" : fn ; System.err.println(name+": "+JsonParseException.formatMessage(ex.getMessage(), ex.getLine(), ex.getColumn())) ; continue ; } JSON.write(IndentedWriter.stdout, json) ; IndentedWriter.stdout.ensureStartOfLine() ; } } finally { IndentedWriter.stdout.flush() ; } }
private static void exception(String message, long line, long col) { throw new JsonParseException(message, (int)line, (int)col) ; } }
public JsonParseException(String msg, Throwable cause,int line, int column) { super(msg, cause) ; set(line, column) ; }
final protected void exception(String msg, Object... args) { throw new JsonParseException(String.format(msg, args), (int)tokens.getLine(), (int)tokens.getColumn()) ; } }
public JsonParseException(String msg, int line, int column) { super(msg) ; set(line, column) ; }
final protected void exception(String msg, Object... args) { throw new JsonParseException(String.format(msg, args), (int)tokens.getLine(), (int)tokens.getColumn()) ; } }
public JsonParseException(Throwable cause, int line, int column) { super(cause) ; set(line, column) ; }
private static void parseAny(JSON_Parser p, JSONHandler handler) { p.setHandler(handler) ; try { p.any() ; } catch (ParseException ex) { throw new JsonParseException(ex.getMessage(), ex.currentToken.beginLine, ex.currentToken.beginColumn) ; } catch (TokenMgrError tErr) { // Last valid token : not the same as token error message - but this should not happen int col = p.token.endColumn ; int line = p.token.endLine ; throw new JsonParseException(tErr.getMessage(), line, col) ; } }
public JsonParseException(int line, int column) { super() ; set(line, column) ; }
private static void parseAny(JSON_Parser p, JSONHandler handler) { p.setHandler(handler) ; try { p.any() ; } catch (ParseException ex) { throw new JsonParseException(ex.getMessage(), ex.currentToken.beginLine, ex.currentToken.beginColumn) ; } catch (TokenMgrError tErr) { // Last valid token : not the same as token error message - but this should not happen int col = p.token.endColumn ; int line = p.token.endLine ; throw new JsonParseException(tErr.getMessage(), line, col) ; } }
public JsonParseException(String msg, int line, int column) { super(msg) ; set(line, column) ; }
private static void parse(JSON_Parser p, JSONHandler handler) { p.setHandler(handler) ; try { p.unit() ; // Checks for EOF // //<EOF> test : EOF is always token 0. // if ( p.token_source.getNextToken().kind != 0 ) // throw new JSONParseException("Trailing characters after "+item, item.getLine(), item.getColumn()) ; } catch (ParseException ex) { throw new JsonParseException(ex.getMessage(), ex.currentToken.beginLine, ex.currentToken.beginColumn) ; } catch (TokenMgrError tErr) { // Last valid token : not the same as token error message - but this should not happen int col = p.token.endColumn ; int line = p.token.endLine ; throw new JsonParseException(tErr.getMessage(), line, col) ; } }
public JsonParseException(String msg, Throwable cause,int line, int column) { super(msg, cause) ; set(line, column) ; }
private static void parse(JSON_Parser p, JSONHandler handler) { p.setHandler(handler) ; try { p.unit() ; // Checks for EOF // //<EOF> test : EOF is always token 0. // if ( p.token_source.getNextToken().kind != 0 ) // throw new JSONParseException("Trailing characters after "+item, item.getLine(), item.getColumn()) ; } catch (ParseException ex) { throw new JsonParseException(ex.getMessage(), ex.currentToken.beginLine, ex.currentToken.beginColumn) ; } catch (TokenMgrError tErr) { // Last valid token : not the same as token error message - but this should not happen int col = p.token.endColumn ; int line = p.token.endLine ; throw new JsonParseException(tErr.getMessage(), line, col) ; } }