protected void _reportBase64EOF() throws JsonParseException { throw new JsonParseException("Unexpected end-of-String when base64 content", JsonLocation.NA); } }
protected final JsonParseException _constructError(String msg, Throwable t) { return new JsonParseException(msg, getCurrentLocation(), t); } }
/** * Helper method for constructing {@link JsonParseException}s * based on current state of the parser */ protected JsonParseException _constructError(String msg) { return new JsonParseException(msg, getCurrentLocation()); } }
@Override public Date deserialize(JsonParser parser, DeserializationContext context) throws IOException, JsonProcessingException { try { synchronized (dateFormat) { return dateFormat.parse(parser.getText()); } } catch (ParseException e) { throw new JsonParseException("Could not parse date", parser.getCurrentLocation(), e); } }
/** * @param bindex Relative index within base64 character unit; between 0 * and 3 (as unit has exactly 4 characters) */ protected void _reportInvalidBase64(Base64Variant b64variant, char ch, int bindex, String msg) throws JsonParseException { String base; if (ch <= INT_SPACE) { base = "Illegal white space character (code 0x"+Integer.toHexString(ch)+") as character #"+(bindex+1)+" of 4-char base64 unit: can only used between units"; } else if (b64variant.usesPaddingChar(ch)) { base = "Unexpected padding character ('"+b64variant.getPaddingChar()+"') as character #"+(bindex+1)+" of 4-char base64 unit: padding only legal as 3rd or 4th character"; } else if (!Character.isDefined(ch) || Character.isISOControl(ch)) { // Not sure if we can really get here... ? (most illegal xml chars are caught at lower level) base = "Illegal character (code 0x"+Integer.toHexString(ch)+") in base64 content"; } else { base = "Illegal character '"+ch+"' (code 0x"+Integer.toHexString(ch)+") in base64 content"; } if (msg != null) { base = base + ": " + msg; } throw new JsonParseException(base, JsonLocation.NA); }
/** * Convenience accessor that can be called when the current * token is {@link JsonToken#VALUE_TRUE} or * {@link JsonToken#VALUE_FALSE}. *<p> * Note: if the token is not of above-mentioned boolean types, an integer, but its value falls * outside of range of Java long, a {@link JsonParseException} * may be thrown to indicate numeric overflow/underflow. * * @since 1.3 */ public boolean getBooleanValue() throws IOException, JsonParseException { if (getCurrentToken() == JsonToken.VALUE_TRUE) return true; if (getCurrentToken() == JsonToken.VALUE_FALSE) return false; throw new JsonParseException("Current token ("+_currToken+") not of boolean type", getCurrentLocation()); }
protected void _reportBase64EOF() throws JsonParseException { throw new JsonParseException("Unexpected end-of-String when base64 content", JsonLocation.NA); } }
/** * Helper method for constructing {@link JsonParseException}s * based on current state of the parser */ protected JsonParseException _constructError(String msg) { return new JsonParseException(msg, getCurrentLocation()); } }
protected final JsonParseException _constructError(String msg, Throwable t) { return new JsonParseException(msg, getCurrentLocation(), t); } }
/** * @param bindex Relative index within base64 character unit; between 0 * and 3 (as unit has exactly 4 characters) */ protected void _reportInvalidBase64(Base64Variant b64variant, char ch, int bindex, String msg) throws JsonParseException { String base; if (ch <= INT_SPACE) { base = "Illegal white space character (code 0x"+Integer.toHexString(ch)+") as character #"+(bindex+1)+" of 4-char base64 unit: can only used between units"; } else if (b64variant.usesPaddingChar(ch)) { base = "Unexpected padding character ('"+b64variant.getPaddingChar()+"') as character #"+(bindex+1)+" of 4-char base64 unit: padding only legal as 3rd or 4th character"; } else if (!Character.isDefined(ch) || Character.isISOControl(ch)) { // Not sure if we can really get here... ? (most illegal xml chars are caught at lower level) base = "Illegal character (code 0x"+Integer.toHexString(ch)+") in base64 content"; } else { base = "Illegal character '"+ch+"' (code 0x"+Integer.toHexString(ch)+") in base64 content"; } if (msg != null) { base = base + ": " + msg; } throw new JsonParseException(base, JsonLocation.NA); }
/** * Convenience accessor that can be called when the current * token is {@link JsonToken#VALUE_TRUE} or * {@link JsonToken#VALUE_FALSE}. *<p> * Note: if the token is not of above-mentioned boolean types, an integer, but its value falls * outside of range of Java long, a {@link JsonParseException} * may be thrown to indicate numeric overflow/underflow. * * @since 1.3 */ public boolean getBooleanValue() throws IOException, JsonParseException { if (getCurrentToken() == JsonToken.VALUE_TRUE) return true; if (getCurrentToken() == JsonToken.VALUE_FALSE) return false; throw new JsonParseException("Current token ("+_currToken+") not of boolean type", getCurrentLocation()); }
protected void _reportBase64EOF() throws JsonParseException { throw new JsonParseException("Unexpected end-of-String when base64 content", JsonLocation.NA); } }
protected void _reportBase64EOF() throws JsonParseException { throw new JsonParseException("Unexpected end-of-String when base64 content", JsonLocation.NA); }
protected final void _wrapError(String msg, Throwable t) throws JsonParseException { throw new JsonParseException(msg, getCurrentLocation(), t); }
protected final JsonParseException _constructError(String msg, Throwable t) { return new JsonParseException(msg, getCurrentLocation(), t); } }
private void validateText(JsonParser jsonParser, String input) throws JsonProcessingException { Matcher m = textPattern.matcher(input); if (!m.matches()) { throw new JsonParseException("Unexpected token: " + input, jsonParser.getTokenLocation()); } }
private void validate(JsonParser jsonParser, String input, String expected) throws JsonProcessingException { if (!input.equals(expected)) { throw new JsonParseException("Unexpected token: " + input, jsonParser.getTokenLocation()); } } }
/** * Helper method for constructing {@link JsonParseException}s * based on current state of the parser */ protected JsonParseException _constructError(String msg) { return new JsonParseException(msg, getCurrentLocation()); } }
@Override public Date deserialize(JsonParser parser, DeserializationContext context) throws IOException, JsonProcessingException { try { synchronized (dateFormat) { return dateFormat.parse(parser.getText()); } } catch (ParseException e) { throw new JsonParseException("Could not parse date", parser.getCurrentLocation(), e); } }
protected <V> V getNextObjectValue (JsonParser jp, String fieldName, Class<V> valueType, V curValue) throws IOException { JsonToken token=jp.nextToken(); if (!JsonToken.START_OBJECT.equals(token)) { throw new JsonParseException("getNextObjectValue(" + fieldName + ")" + "[" + valueType.getSimpleName() + "]" + ": not start-of-object token: " + token, jp.getCurrentLocation()); } return getObjectValue(jp, fieldName, valueType, curValue); }