public Object fromString(final String str) { if (attributeMap.containsKey(str)) { return attributeMap.get(str); } ConversionException exception = new ConversionException("Cannot find attribute"); exception.add("attribute-type", type.getName()); exception.add("attribute-name", str); throw exception; }
@Override public Instant fromString(final String str) { try { return Instant.parse(str); } catch (final DateTimeParseException ex) { final ConversionException exception = new ConversionException("Cannot parse value as instant", ex); exception.add("value", str); throw exception; } } }
@Override public Object fromString(final String str) { try { return LocalDateTime.parse(str); } catch (final DateTimeParseException e) { final ConversionException exception = new ConversionException("Cannot parse value as local date time", e); exception.add("value", str); throw exception; } }
@Override public Object fromString(final String str) { try { return LocalTime.parse(str); } catch (final DateTimeParseException e) { final ConversionException exception = new ConversionException("Cannot parse value as local time", e); exception.add("value", str); throw exception; } }
public int accept(Method method) { if (!callbackIndexMap.containsKey(method)) { ConversionException exception = new ConversionException( "CGLIB callback not detected in reverse engineering"); exception.add("CGLIB-callback", method.toString()); throw exception; } return ((Integer)callbackIndexMap.get(method)).intValue(); }
@Override public Object fromString(final String str) { try { return LocalDate.parse(str); } catch (final DateTimeParseException e) { final ConversionException exception = new ConversionException("Cannot parse value as local date", e); exception.add("value", str); throw exception; } }
@Override public Object fromString(final String str) { try { return ZonedDateTime.parse(str); } catch (final DateTimeParseException e) { final ConversionException exception = new ConversionException("Cannot parse value as zoned date time", e); exception.add("value", str); throw exception; } }
public void convertAnother(Object item, Converter converter) { if (converter == null) { converter = converterLookup.lookupConverterForType(item.getClass()); } else { if (!converter.canConvert(item.getClass())) { ConversionException e = new ConversionException( "Explicit selected converter cannot handle item"); e.add("item-type", item.getClass().getName()); e.add("converter-type", converter.getClass().getName()); throw e; } } convert(item, converter); }
@Override public Year fromString(final String str) { try { return Year.of(Integer.parseInt(str)); } catch (final NumberFormatException ex) { final ConversionException exception = new ConversionException("Cannot parse value as year", ex); exception.add("value", str); throw exception; } } }
@Override public ZoneId fromString(final String str) { ConversionException exception; try { return ZoneId.of(str); } catch (final ZoneRulesException e) { exception = new ConversionException("Not a valid zone id", e); } catch (final DateTimeException e) { exception = new ConversionException("Cannot parse value as zone id", e); } exception.add("value", str); throw exception; }
protected void convert(Object item, Converter converter) { if (parentObjects.containsId(item)) { ConversionException e = new CircularReferenceException( "Recursive reference to parent object"); e.add("item-type", item.getClass().getName()); e.add("converter-type", converter.getClass().getName()); throw e; } parentObjects.associateId(item, ""); converter.marshal(item, writer, this); parentObjects.removeId(item); }
@Override public MonthDay fromString(final String str) { try { return MonthDay.parse(str); } catch (final DateTimeParseException ex) { final ConversionException exception = new ConversionException("Cannot parse value as month day", ex); exception.add("value", str); throw exception; } } }
@Override public Period fromString(final String str) { try { return Period.parse(str); } catch (final DateTimeParseException ex) { final ConversionException exception = new ConversionException("Cannot parse period value", ex); exception.add("period", str); throw exception; } } }
@Override public Duration fromString(final String str) { try { return Duration.parse(str); } catch (final DateTimeParseException ex) { final ConversionException exception = new ConversionException("Cannot parse value as duration", ex); exception.add("value", str); throw exception; } } }
@Override public YearMonth fromString(final String str) { try { return YearMonth.parse(str); } catch (final DateTimeParseException ex) { final ConversionException exception = new ConversionException("Cannot parse value as year month", ex); exception.add("value", str); throw exception; } } }
@Override public Object fromString(final String str) { try { return OffsetTime.parse(str); } catch (final DateTimeParseException e) { final ConversionException exception = new ConversionException("Cannot parse value as offset time", e); exception.add("value", str); throw exception; } }
@Override public Object fromString(final String str) { try { return OffsetDateTime.parse(str); } catch (final DateTimeParseException e) { final ConversionException exception = new ConversionException("Cannot parse value as offset date time", e); exception.add("value", str); throw exception; } }
@Override public Chronology fromString(final String str) { if (str == null) { return null; } try { return Chronology.of(str); } catch (final DateTimeException e) { final ConversionException exception = new ConversionException("Cannot parse value as chronology", e); exception.add("value", str); throw exception; } }
public Object convertAnother(Object parent, Class type, Converter converter) { type = mapper.defaultImplementationOf(type); if (converter == null) { converter = converterLookup.lookupConverterForType(type); } else { if (!converter.canConvert(type)) { ConversionException e = new ConversionException( "Explicit selected converter cannot handle type"); e.add("item-type", type.getName()); e.add("converter-type", converter.getClass().getName()); throw e; } } return convert(parent, type, converter); }
@Override public JapaneseEra fromString(final String str) { if (str == null) { return null; } try { return JapaneseEra.valueOf(str); } catch (final IllegalArgumentException e) { final ConversionException exception = new ConversionException("Cannot parse value as Japanese era", e); exception.add("value", str); throw exception; } } }