/** * Default method overridden so that we can add location information */ @Override public String getMessage() { String msg = super.getMessage(); if (msg == null) { msg = "N/A"; } JsonLocation loc = getLocation(); String suffix = getMessageSuffix(); // mild optimization, if nothing extra is needed: if (loc != null || suffix != null) { StringBuilder sb = new StringBuilder(100); sb.append(msg); if (suffix != null) { sb.append(suffix); } if (loc != null) { sb.append('\n'); sb.append(" at "); sb.append(loc.toString()); } msg = sb.toString(); } return msg; }
/** * Default method overridden so that we can add location information */ @Override public String getMessage() { String msg = super.getMessage(); if (msg == null) { msg = "N/A"; } JsonLocation loc = getLocation(); String suffix = getMessageSuffix(); // mild optimization, if nothing extra is needed: if (loc != null || suffix != null) { StringBuilder sb = new StringBuilder(100); sb.append(msg); if (suffix != null) { sb.append(suffix); } if (loc != null) { sb.append('\n'); sb.append(" at "); sb.append(loc.toString()); } msg = sb.toString(); } return msg; }
private void acceptStartArray(JsonParser p) throws IOException { if (p.nextToken() != JsonToken.START_ARRAY) { throw new IOException("malformed document, expected array at " + p.getCurrentLocation().toString()); } }
private void acceptEndArray(JsonParser p) throws IOException { if (p.getCurrentToken() == JsonToken.END_ARRAY) { return; } if (p.nextToken() != JsonToken.END_ARRAY) { throw new IOException("malformed document, expected array end but found " + p.getCurrentToken() + " at " + p.getCurrentLocation().toString()); } }
InvalidConstantTensor(JsonParser parser, Exception base) { super("Failed to parse JSON stream " + parser.getCurrentLocation().toString(), base); } }
InvalidConstantTensor(JsonParser parser, String message) { super(message + " " + parser.getCurrentLocation().toString()); }
private void readArrayValues(CompositeResource res, JsonParser p) throws IOException { JsonToken next = p.nextToken(); if (null == next) { throw new IOException("malformed document, not a supported array value at " + p.getCurrentLocation().toString()); } else switch (next) { case VALUE_STRING: res.value = p.getText(); break; case START_ARRAY: if (p.nextToken() == JsonToken.END_ARRAY) { res.value = Collections.EMPTY_LIST; } else { ArrayList<String> a = new ArrayList<>(); res.value = a; do { a.add(p.getText()); } while (p.nextToken() != JsonToken.END_ARRAY); } break; default: throw new IOException("malformed document, not a supported array value at " + p.getCurrentLocation().toString()); } }
public JSONException(Exception e, JsonLocation location) { super(e); this.location = location.toString(); this.line = location.getLineNr(); this.column = location.getColumnNr(); }
/** * Default method overridden so that we can add location information */ @Override public String getMessage() { String msg = super.getMessage(); if (msg == null) { msg = "N/A"; } JsonLocation loc = getLocation(); String suffix = getMessageSuffix(); // mild optimization, if nothing extra is needed: if (loc != null || suffix != null) { StringBuilder sb = new StringBuilder(100); sb.append(msg); if (suffix != null) { sb.append(suffix); } if (loc != null) { sb.append('\n'); sb.append(" at "); sb.append(loc.toString()); } msg = sb.toString(); } return msg; }
/** * Default method overridden so that we can add location information */ @Override public String getMessage() { String msg = super.getMessage(); if (msg == null) { msg = "N/A"; } JsonLocation loc = getLocation(); String suffix = getMessageSuffix(); // mild optimization, if nothing extra is needed: if (loc != null || suffix != null) { StringBuilder sb = new StringBuilder(100); sb.append(msg); if (suffix != null) { sb.append(suffix); } if (loc != null) { sb.append('\n'); sb.append(" at "); sb.append(loc.toString()); } msg = sb.toString(); } return msg; }
private List<Object> readSubResources(CompositeResource parent, JsonParser p) throws IOException, ClassNotFoundException { acceptStartArray(p); if (p.nextToken() == JsonToken.END_ARRAY) { return Collections.emptyList(); } if (p.getCurrentToken() != JsonToken.START_OBJECT) { throw new IOException("malformed document, expected object start at " + p.getCurrentLocation().toString()); } List<Object> resources = new ArrayList<>(); do { resources.add(readResource(parent, p)); } while (p.nextToken() == JsonToken.START_OBJECT); acceptEndArray(p); return resources; }
public JSONException(String message, JsonLocation location) { super(message); this.location = location.toString(); this.line = location.getLineNr(); this.column = location.getColumnNr(); }
public JSONException(Exception e, JsonLocation location) { super(e); this.location = location.toString(); this.line = location.getLineNr(); this.column = location.getColumnNr(); }
/** * Default method overridden so that we can add location information */ @Override public String getMessage() { String msg = super.getMessage(); if (msg == null) { msg = "N/A"; } JsonLocation loc = getLocation(); String suffix = getMessageSuffix(); // mild optimization, if nothing extra is needed: if (loc != null || suffix != null) { StringBuilder sb = new StringBuilder(100); sb.append(msg); if (suffix != null) { sb.append(suffix); } if (loc != null) { sb.append('\n'); sb.append(" at "); sb.append(loc.toString()); } msg = sb.toString(); } return msg; }
public JSONException(String message, JsonLocation location) { super(message); this.location = location.toString(); this.line = location.getLineNr(); this.column = location.getColumnNr(); }
/** * Default method overridden so that we can add location information */ @Override public String getMessage() { String msg = super.getMessage(); if (msg == null) { msg = "N/A"; } JsonLocation loc = getLocation(); String suffix = getMessageSuffix(); // mild optimization, if nothing extra is needed: if (loc != null || suffix != null) { StringBuilder sb = new StringBuilder(100); sb.append(msg); if (suffix != null) { sb.append(suffix); } if (loc != null) { sb.append('\n'); sb.append(" at "); sb.append(loc.toString()); } msg = sb.toString(); } return msg; }
/** * Default method overridden so that we can add location information */ @Override public String getMessage() { String msg = super.getMessage(); if (msg == null) { msg = "N/A"; } JsonLocation loc = getLocation(); String suffix = getMessageSuffix(); // mild optimization, if nothing extra is needed: if (loc != null || suffix != null) { StringBuilder sb = new StringBuilder(100); sb.append(msg); if (suffix != null) { sb.append(suffix); } if (loc != null) { sb.append('\n'); sb.append(" at "); sb.append(loc.toString()); } msg = sb.toString(); } return msg; }
/** * Default method overridden so that we can add location information */ @Override public String getMessage() { String msg = super.getMessage(); if (msg == null) { msg = "N/A"; } JsonLocation loc = getLocation(); String suffix = getMessageSuffix(); // mild optimization, if nothing extra is needed: if (loc != null || suffix != null) { StringBuilder sb = new StringBuilder(100); sb.append(msg); if (suffix != null) { sb.append(suffix); } if (loc != null) { sb.append('\n'); sb.append(" at "); sb.append(loc.toString()); } msg = sb.toString(); } return msg; }
@Override public List<NotificationAttribute> deserialize(JsonParser parser, DeserializationContext ctx) throws JsonParseException, IOException { List<NotificationAttribute> result = new ArrayList<NotificationAttribute>(); JsonToken token = parser.getCurrentToken(); // v1.0: array of objects if (token == JsonToken.START_ARRAY) { NotificationAttribute[] attributes = parser.readValueAs(NotificationAttribute[].class); result.addAll(Arrays.asList(attributes)); } else if (token == JsonToken.START_OBJECT) { // v2.0: series of string arrays while (parser.nextToken() != JsonToken.END_OBJECT) { NotificationAttribute attr = new NotificationAttribute(); attr.setName(parser.getCurrentName()); parser.nextToken(); // Should be the array of values String[] values = parser.readValueAs(String[].class); attr.setValues(Arrays.asList(values)); result.add(attr); } } else throw new IllegalArgumentException("Invalid attributes value. Expected array of NotificationAttribute" + " objects or object with a series of string arrays. See https://issues.jasig.org/browse/NOTIFPLT-32" + " for format." + parser.getCurrentLocation().toString()); return result; }
while ((tok = p.nextToken()) != JsonToken.END_OBJECT) { if (tok != JsonToken.FIELD_NAME) { throw new IOException("malformed document, expected field at " + p.getCurrentLocation().toString());