private ParseException error(String message) { int column=index-lineOffset; int offset=isEndOfText()?index:index-1; return new ParseException(message, offset, line, column-1); }
private ParseException error(String message) { int absIndex=bufferOffset+index; int column=absIndex-lineOffset; int offset=isEndOfText() ? absIndex : absIndex-1; return new ParseException(message, offset, line, column-1); }
HjsonParser(String string, HjsonOptions options) { buffer=string; reset(); if (options!=null) { dsfProviders=options.getDsfProviders(); legacyRoot=options.getParseLegacyRoot(); } else { dsfProviders=new IHjsonDsfProvider[0]; legacyRoot=true; } }
private JsonValue readValue() throws IOException { switch(current) { case '\'': case '"': return readString(); case '[': return readArray(); case '{': return readObject(false); default: return readTfnns(); } }
private JsonValue readString() throws IOException { return new JsonString(readStringInternal(true)); }
private JsonValue readString() throws IOException { return new JsonString(readStringInternal()); }
private void skipIndent(int indent) throws IOException { while (indent-->0) { if (isWhiteSpace(current) && current!='\n') read(); else break; } }
private void skipWhiteSpace() throws IOException { while (isWhiteSpace()) { read(); } }
private ParseException expected(String expected) { if (isEndOfText()) { return error("Unexpected end of input"); } return error("Expected "+expected); }
static boolean needsEscapeML(char c) { switch (c) { case '\n': case '\r': case '\t': return false; default: return needsQuotes(c); } } }
/** * Returns a JsonValue instance that represents the given <code>int</code> value. * * @param value the value to get a JSON representation for * @return a JSON value that represents the given value */ public static JsonValue valueOf(int value) { return new JsonNumber(value); }
private boolean readIf(char ch) throws IOException { if (current!=ch) { return false; } read(); return true; }
int get(Object name) { int slot=hashSlotfor (name); // subtract 1, 0 stands for empty return (hashTable[slot] & 0xff)-1; }
/** * Returns a hex DSF provider * * @param stringify true to output all integers as hex values * @return DSF provider */ public static IHjsonDsfProvider hex(boolean stringify) { return new DsfHex(stringify); } // /**
public HjsonWriter(HjsonOptions options) { if (options!=null) { dsfProviders=options.getDsfProviders(); } else { dsfProviders=new IHjsonDsfProvider[0]; } }
HjsonParser(String string, HjsonOptions options) { buffer=string; reset(); if (options!=null) { dsfProviders=options.getDsfProviders(); legacyRoot=options.getParseLegacyRoot(); } else { dsfProviders=new IHjsonDsfProvider[0]; legacyRoot=true; } }
private ParseException error(String message) { int column=index-lineOffset; int offset=isEndOfText()?index:index-1; return new ParseException(message, offset, line, column-1); }
private ParseException error(String message) { int absIndex=bufferOffset+index; int column=absIndex-lineOffset; int offset=isEndOfText() ? absIndex : absIndex-1; return new ParseException(message, offset, line, column-1); }
static boolean needsEscape(char c) { switch (c) { case '\"': case '\\': return true; default: return needsQuotes(c); } }
/** * Returns a JsonValue instance that represents the given <code>double</code> value. * * @param value the value to get a JSON representation for * @return a JSON value that represents the given value */ public static JsonValue valueOf(double value) { return new JsonNumber(value); }