/** * @since 2.7 */ protected JsonMappingException wrapAsJsonMappingException(DeserializationContext ctxt, Throwable t) { // 05-Nov-2015, tatu: Only avoid wrapping if already a JsonMappingException if (t instanceof JsonMappingException) { return (JsonMappingException) t; } return ctxt.instantiationException(getValueClass(), t); }
/** * @since 2.7 */ protected JsonMappingException unwrapAndWrapException(DeserializationContext ctxt, Throwable t) { // 05-Nov-2015, tatu: This used to always unwrap the whole exception, but now only // does so if and until `JsonMappingException` is found. for (Throwable curr = t; curr != null; curr = curr.getCause()) { if (curr instanceof JsonMappingException) { return (JsonMappingException) curr; } } return ctxt.instantiationException(getValueClass(), t); }
throw instantiationException(instClass, t);
@Override public Object deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { // This method should never be called... throw ctxt.instantiationException(_baseType.getRawClass(), "abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information"); }
/** * @since 2.7 */ protected JsonMappingException wrapAsJsonMappingException(DeserializationContext ctxt, Throwable t) { // 05-Nov-2015, tatu: Only avoid wrapping if already a JsonMappingException if (t instanceof JsonMappingException) { return (JsonMappingException) t; } return ctxt.instantiationException(getValueClass(), t); }
@Override public Object deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { // This method should never be called... throw ctxt.instantiationException(_baseType.getRawClass(), "abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information"); }
/** * @since 2.7 */ protected JsonMappingException wrapAsJsonMappingException(DeserializationContext ctxt, Throwable t) { // 05-Nov-2015, tatu: Only avoid wrapping if already a JsonMappingException if (t instanceof JsonMappingException) { return (JsonMappingException) t; } return ctxt.instantiationException(getValueClass(), t); }
@Override public Object deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { // This method should never be called... throw ctxt.instantiationException(_baseType.getRawClass(), "abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information"); }
@Override public Object deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { // This method should never be called... throw ctxt.instantiationException(_baseType.getRawClass(), "abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information"); }
/** * @since 2.7 */ protected JsonMappingException unwrapAndWrapException(DeserializationContext ctxt, Throwable t) { // 05-Nov-2015, tatu: This used to always unwrap the whole exception, but now only // does so if and until `JsonMappingException` is found. for (Throwable curr = t; curr != null; curr = curr.getCause()) { if (curr instanceof JsonMappingException) { return (JsonMappingException) curr; } } return ctxt.instantiationException(getValueClass(), t); }
/** * @since 2.7 */ protected JsonMappingException unwrapAndWrapException(DeserializationContext ctxt, Throwable t) { // 05-Nov-2015, tatu: This used to always unwrap the whole exception, but now only // does so if and until `JsonMappingException` is found. for (Throwable curr = t; curr != null; curr = curr.getCause()) { if (curr instanceof JsonMappingException) { return (JsonMappingException) curr; } } return ctxt.instantiationException(getValueClass(), t); }
@Override public Calendar deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { Date d = _parseDate(jp, ctxt); if (d == null) { return null; } if (_calendarClass == null) { return ctxt.constructCalendar(d); } try { Calendar c = _calendarClass.newInstance(); c.setTimeInMillis(d.getTime()); return c; } catch (Exception e) { throw ctxt.instantiationException(_calendarClass, e); } } }
@Override public Calendar deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { Date d = _parseDate(jp, ctxt); if (d == null) { return null; } if (_calendarClass == null) { return ctxt.constructCalendar(d); } try { Calendar c = _calendarClass.newInstance(); c.setTimeInMillis(d.getTime()); return c; } catch (Exception e) { throw ctxt.instantiationException(_calendarClass, e); } } }
@Override public ObjectName deserialize(JsonParser jsonParser, DeserializationContext context) throws IOException { JsonToken token = jsonParser.getCurrentToken(); if (token == JsonToken.VALUE_STRING) { try { return ObjectName.getInstance(jsonParser.getText()); } catch (MalformedObjectNameException e) { throw context.instantiationException(getValueClass(), e); } } throw context.mappingException(getValueClass()); } }
@Override public Class<?> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonToken curr = jp.getCurrentToken(); // Currently will only accept if given simple class name if (curr == JsonToken.VALUE_STRING) { String className = jp.getText().trim(); try { return ctxt.findClass(className); } catch (Exception e) { throw ctxt.instantiationException(_valueClass, ClassUtil.getRootCause(e)); } } throw ctxt.mappingException(_valueClass, curr); } }
@Override public ObjectName deserialize(JsonParser jsonParser, DeserializationContext context) throws IOException { JsonToken token = jsonParser.getCurrentToken(); if (token == JsonToken.VALUE_STRING) { try { return ObjectName.getInstance(jsonParser.getText()); } catch (MalformedObjectNameException e) { throw context.instantiationException(getValueClass(), e); } } throw context.mappingException(getValueClass()); } }
@Override public ObjectName deserialize(JsonParser jsonParser, DeserializationContext context) throws IOException { JsonToken token = jsonParser.getCurrentToken(); if (token == JsonToken.VALUE_STRING) { try { return ObjectName.getInstance(jsonParser.getText()); } catch (MalformedObjectNameException e) { throw context.instantiationException(getValueClass(), e); } } throw context.mappingException(getValueClass()); } }
@Override public Class<?> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonToken curr = jp.getCurrentToken(); // Currently will only accept if given simple class name if (curr == JsonToken.VALUE_STRING) { String className = jp.getText().trim(); try { return ctxt.findClass(className); } catch (Exception e) { throw ctxt.instantiationException(_valueClass, ClassUtil.getRootCause(e)); } } throw ctxt.mappingException(_valueClass, curr); } }
@Override public String deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { Object object = jp.getEmbeddedObject(); if (object == null) { return null; } else if (object instanceof ObjectId) { return ((ObjectId) object).toHexString(); } else if (object instanceof DBRef) { Object id = ((DBRef) object).getId(); if (!(id instanceof ObjectId)) { throw ctxt.instantiationException(String.class, "Expected an ObjectId id in the DBRef to deserialise to string, but found " + id.getClass()); } return ((ObjectId) id).toHexString(); } else { throw ctxt.instantiationException(String.class, "Expected an ObjectId to deserialise to string, but found " + object.getClass()); } } }
@Override protected Class<?> _deserialize(final String value, final DeserializationContext ctxt) throws IOException { try { return ctxt.findClass(SimpleClassNameIdResolver.getClassName(value)); } catch (final Exception e) { throw ctxt.instantiationException(_valueClass, ClassUtil.getRootCause(e)); } } }