Refine search
public static JsonDeserializer<?> find(Class<?> rawType, String clsName) { if (_classNames.contains(clsName)) { JsonDeserializer<?> d = FromStringDeserializer.findDeserializer(rawType); if (d != null) { return d; } if (rawType == UUID.class) { return new UUIDDeserializer(); } if (rawType == StackTraceElement.class) { return new StackTraceElementDeserializer(); } if (rawType == AtomicBoolean.class) { // (note: AtomicInteger/Long work due to single-arg constructor. For now? return new AtomicBooleanDeserializer(); } if (rawType == ByteBuffer.class) { return new ByteBufferDeserializer(); } if (rawType == Void.class) { return NullifyingDeserializer.instance; } } return null; } }
int byteFromChars(String str, int index, DeserializationContext ctxt) throws JsonMappingException { final char c1 = str.charAt(index); final char c2 = str.charAt(index+1); if (c1 <= 127 && c2 <= 127) { int hex = (HEX_DIGITS[c1] << 4) | HEX_DIGITS[c2]; if (hex >= 0) { return hex; } } if (c1 > 127 || HEX_DIGITS[c1] < 0) { return _badChar(str, index, ctxt, c1); } return _badChar(str, index+1, ctxt, c2); }
return _fromBytes(stuff, ctxt); return _badFormat(id, ctxt); _badFormat(id, ctxt); long l1 = intFromChars(id, 0, ctxt); l1 <<= 32; long l2 = ((long) shortFromChars(id, 9, ctxt)) << 16; l2 |= shortFromChars(id, 14, ctxt); long hi = l1 + l2; int i1 = (shortFromChars(id, 19, ctxt) << 16) | shortFromChars(id, 24, ctxt); l1 = i1; l1 <<= 32; l2 = intFromChars(id, 28, ctxt); l2 = (l2 << 32) >>> 32; // sign removal, Java-style. Ugh. long lo = l1 | l2; return new UUID(hi, lo);
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)); }
private UUID _fromBytes(byte[] bytes, DeserializationContext ctxt) throws IOException { if (bytes.length != 16) { ctxt.mappingException("Can only construct UUIDs from byte[16]; got "+bytes.length+" bytes"); } return new UUID(_long(bytes, 0), _long(bytes, 8)); }
int _badChar(String uuidStr, int index, DeserializationContext ctxt, char c) throws JsonMappingException { // 15-May-2016, tatu: Ideally should not throw, but call `handleWeirdStringValue`... // however, control flow is gnarly here, so for now just throw throw ctxt.weirdStringException(uuidStr, handledType(), String.format( "Non-hex character '%c' (value 0x%s), not valid for UUID String", c, Integer.toHexString(c))); }
private UUID _badFormat(String uuidStr, DeserializationContext ctxt) throws IOException { return (UUID) ctxt.handleWeirdStringValue(handledType(), uuidStr, "UUID has to be represented by standard 36-char representation"); }
int intFromChars(String str, int index, DeserializationContext ctxt) throws JsonMappingException { return (byteFromChars(str, index, ctxt) << 24) + (byteFromChars(str, index+2, ctxt) << 16) + (byteFromChars(str, index+4, ctxt) << 8) + byteFromChars(str, index+6, ctxt); }
@Override protected UUID _deserializeEmbedded(Object ob, DeserializationContext ctxt) throws IOException { if (ob instanceof byte[]) { return _fromBytes((byte[]) ob, ctxt); } super._deserializeEmbedded(ob, ctxt); return null; // never gets here }
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)); }
private UUID _fromBytes(byte[] bytes, DeserializationContext ctxt) throws IOException { if (bytes.length != 16) { ctxt.mappingException("Can only construct UUIDs from byte[16]; got "+bytes.length+" bytes"); } return new UUID(_long(bytes, 0), _long(bytes, 8)); }
int _badChar(String uuidStr, int index, DeserializationContext ctxt, char c) throws JsonMappingException { // 15-May-2016, tatu: Ideally should not throw, but call `handleWeirdStringValue`... // however, control flow is gnarly here, so for now just throw throw ctxt.weirdStringException(uuidStr, handledType(), String.format( "Non-hex character '%c' (value 0x%s), not valid for UUID String", c, Integer.toHexString(c))); }
private UUID _badFormat(String uuidStr, DeserializationContext ctxt) throws IOException { return (UUID) ctxt.handleWeirdStringValue(handledType(), uuidStr, "UUID has to be represented by standard 36-char representation"); }
int shortFromChars(String str, int index, DeserializationContext ctxt) throws JsonMappingException { return (byteFromChars(str, index, ctxt) << 8) + byteFromChars(str, index+2, ctxt); }
@Override protected UUID _deserializeEmbedded(Object ob, DeserializationContext ctxt) throws IOException { if (ob instanceof byte[]) { return _fromBytes((byte[]) ob, ctxt); } super._deserializeEmbedded(ob, ctxt); return null; // never gets here }
return _fromBytes(stuff, ctxt); _badFormat(id); _badFormat(id); long l1 = intFromChars(id, 0); l1 <<= 32; long l2 = ((long) shortFromChars(id, 9)) << 16; l2 |= shortFromChars(id, 14); long hi = l1 + l2; int i1 = (shortFromChars(id, 19) << 16) | shortFromChars(id, 24); l1 = i1; l1 <<= 32; l2 = intFromChars(id, 28); l2 = (l2 << 32) >>> 32; // sign removal, Java-style. Ugh. long lo = l1 | l2; return new UUID(hi, lo);
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)); }
int _badChar(String uuidStr, int index, DeserializationContext ctxt, char c) throws JsonMappingException { // 15-May-2016, tatu: Ideally should not throw, but call `handleWeirdStringValue`... // however, control flow is gnarly here, so for now just throw throw ctxt.weirdStringException(uuidStr, handledType(), String.format( "Non-hex character '%c' (value 0x%s), not valid for UUID String", c, Integer.toHexString(c))); }