protected InvalidNullException(DeserializationContext ctxt, String msg, PropertyName pname) { super(ctxt.getParser(), msg); _propertyName = pname; }
/** * @since 2.7 */ public static JsonMappingException from(DeserializationContext ctxt, String msg) { return new JsonMappingException(ctxt.getParser(), msg); }
/** * @since 2.7 */ public static JsonMappingException from(DeserializationContext ctxt, String msg, Throwable t) { return new JsonMappingException(ctxt.getParser(), msg, t); }
/** * @since 2.8 * * @deprecated Since 2.9: not clear this ever occurs */ @Deprecated // since 2.9 public void reportMissingContent(String msg, Object... msgArgs) throws JsonMappingException { throw MismatchedInputException.from(getParser(), (JavaType) null, "No content to map due to end-of-input"); }
/** * Helper method for constructing generic mapping exception with specified * message and current location information. * Note that application code should almost always call * one of <code>handleXxx</code> methods, or {@link #reportMappingException(String, Object...)} * instead. * * @since 2.6 * * @deprecated Since 2.9 use more specific error reporting methods instead */ @Deprecated public JsonMappingException mappingException(String message) { return JsonMappingException.from(getParser(), message); }
/** * Helper method for constructing generic mapping exception with specified * message and current location information * Note that application code should almost always call * one of <code>handleXxx</code> methods, or {@link #reportMappingException(String, Object...)} * instead. * * @since 2.6 * * @deprecated Since 2.9 use more specific error reporting methods instead */ @Deprecated public JsonMappingException mappingException(String msg, Object... msgArgs) { return JsonMappingException.from(getParser(), _format(msg, msgArgs)); }
/** * Helper method used to indicate a problem with input in cases where more * specific <code>reportXxx()</code> method was not available. * * @since 2.9 */ public <T> T reportInputMismatch(Class<?> targetType, String msg, Object... msgArgs) throws JsonMappingException { msg = _format(msg, msgArgs); throw MismatchedInputException.from(getParser(), targetType, msg); }
/** * Helper method used to indicate a problem with input in cases where more * specific <code>reportXxx()</code> method was not available. * * @since 2.9 */ public <T> T reportInputMismatch(JavaType targetType, String msg, Object... msgArgs) throws JsonMappingException { msg = _format(msg, msgArgs); throw MismatchedInputException.from(getParser(), targetType, msg); }
/** * Fallback method that may be called if no other <code>reportXxx</code> * is applicable -- but only in that case. * * @since 2.8 * * @deprecated Since 2.9: use a more specific method, or {@link #reportBadDefinition(JavaType, String)}, * or {@link #reportInputMismatch} instead */ @Deprecated // since 2.9 public void reportMappingException(String msg, Object... msgArgs) throws JsonMappingException { throw JsonMappingException.from(getParser(), _format(msg, msgArgs)); }
/** * Method for deserializers to call * when the token encountered was of type different than what <b>should</b> * be seen at that position, usually within a sequence of expected tokens. * Note that this method will throw a {@link JsonMappingException} and no * recovery is attempted (via {@link DeserializationProblemHandler}, as * problem is considered to be difficult to recover from, in general. * * @since 2.9 */ public void reportWrongTokenException(JavaType targetType, JsonToken expToken, String msg, Object... msgArgs) throws JsonMappingException { msg = _format(msg, msgArgs); throw wrongTokenException(getParser(), targetType, expToken, msg); }
/** * Method for deserializers to call * when the token encountered was of type different than what <b>should</b> * be seen at that position, usually within a sequence of expected tokens. * Note that this method will throw a {@link JsonMappingException} and no * recovery is attempted (via {@link DeserializationProblemHandler}, as * problem is considered to be difficult to recover from, in general. * * @since 2.9 */ public void reportWrongTokenException(Class<?> targetType, JsonToken expToken, String msg, Object... msgArgs) throws JsonMappingException { msg = _format(msg, msgArgs); throw wrongTokenException(getParser(), targetType, expToken, msg); }
private UUID _fromBytes(byte[] bytes, DeserializationContext ctxt) throws JsonMappingException { if (bytes.length != 16) { throw InvalidFormatException.from(ctxt.getParser(), "Can only construct UUIDs from byte[16]; got "+bytes.length+" bytes", bytes, handledType()); } return new UUID(_long(bytes, 0), _long(bytes, 8)); }
/** * Helper method used to indicate a problem with input in cases where more * specific <code>reportXxx()</code> method was not available. * * @since 2.9 */ public <T> T reportInputMismatch(JsonDeserializer<?> src, String msg, Object... msgArgs) throws JsonMappingException { msg = _format(msg, msgArgs); throw MismatchedInputException.from(getParser(), src.handledType(), msg); }
/** * Helper method used to indicate a problem with input in cases where more * specific <code>reportXxx()</code> method was not available. * * @since 2.9 */ public <T> T reportInputMismatch(BeanProperty prop, String msg, Object... msgArgs) throws JsonMappingException { msg = _format(msg, msgArgs); JavaType type = (prop == null) ? null : prop.getType(); throw MismatchedInputException.from(getParser(), type, msg); }
/** * Method for deserializers to call * when the token encountered was of type different than what <b>should</b> * be seen at that position, usually within a sequence of expected tokens. * Note that this method will throw a {@link JsonMappingException} and no * recovery is attempted (via {@link DeserializationProblemHandler}, as * problem is considered to be difficult to recover from, in general. * * @since 2.9 */ public void reportWrongTokenException(JsonDeserializer<?> deser, JsonToken expToken, String msg, Object... msgArgs) throws JsonMappingException { msg = _format(msg, msgArgs); throw wrongTokenException(getParser(), deser.handledType(), expToken, msg); }
/** * Method that deserializer may call if it is called to do an update ("merge") * but deserializer operates on a non-mergeable type. Although this should * usually be caught earlier, sometimes it may only be caught during operation * and if so this is the method to call. * Note that if {@link MapperFeature#IGNORE_MERGE_FOR_UNMERGEABLE} is enabled, * this method will simply return null; otherwise {@link InvalidDefinitionException} * will be thrown. * * @since 2.9 */ public <T> T reportBadMerge(JsonDeserializer<?> deser) throws JsonMappingException { if (isEnabled(MapperFeature.IGNORE_MERGE_FOR_UNMERGEABLE)) { return null; } JavaType type = constructType(deser.handledType()); String msg = String.format("Invalid configuration: values of type %s cannot be merged", type); throw InvalidDefinitionException.from(getParser(), msg, type); }
/** * @since 2.4 (demoted from <code>StdValueInstantiator</code>) */ protected Object _createFromStringFallbacks(DeserializationContext ctxt, String value) throws IOException { /* 28-Sep-2011, tatu: Ok this is not clean at all; but since there are legacy * systems that expect conversions in some cases, let's just add a minimal * patch (note: same could conceivably be used for numbers too). */ if (canCreateFromBoolean()) { String str = value.trim(); if ("true".equals(str)) { return createFromBoolean(ctxt, true); } if ("false".equals(str)) { return createFromBoolean(ctxt, false); } } // also, empty Strings might be accepted as null Object... if (value.length() == 0) { if (ctxt.isEnabled(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)) { return null; } } return ctxt.handleMissingInstantiator(getValueClass(), this, ctxt.getParser(), "no String-argument constructor/factory method to deserialize from String value ('%s')", value); }
@SuppressWarnings("resource") @Override public final Object deserializeKey(String key, DeserializationContext ctxt) throws IOException { if (key == null) { // is this even legal call? return null; } TokenBuffer tb = new TokenBuffer(ctxt.getParser(), ctxt); tb.writeString(key); try { // Ugh... should not have to give parser which may or may not be correct one... JsonParser p = tb.asParser(); p.nextToken(); Object result = _delegate.deserialize(p, ctxt); if (result != null) { return result; } return ctxt.handleWeirdKey(_keyClass, key, "not a valid representation"); } catch (Exception re) { return ctxt.handleWeirdKey(_keyClass, key, "not a valid representation: %s", re.getMessage()); } }
throw InvalidDefinitionException.from(ctxt.getParser(), ClassUtil.exceptionMessage(e), beanDesc, null);