protected PrimitiveArrayDeserializers() { _allDeserializers = new HashMap<JavaType,JsonDeserializer<Object>>(); // note: we'll use component type as key, not array type add(boolean.class, new BooleanDeser()); /* ByteDeser is bit special, as it has 2 separate modes of operation; * one for String input (-> base64 input), the other for * numeric input */ add(byte.class, new ByteDeser()); add(short.class, new ShortDeser()); add(int.class, new IntDeser()); add(long.class, new LongDeser()); add(float.class, new FloatDeser()); add(double.class, new DoubleDeser()); add(String.class, new StringDeser()); /* also: char[] is most likely only used with Strings; doesn't * seem to make sense to transfer as numbers */ add(char.class, new CharDeser()); }
private final int[] handleNonArray(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { // [JACKSON-620] Empty String can become null... if ((jp.getCurrentToken() == JsonToken.VALUE_STRING) && ctxt.isEnabled(DeserializationConfig.Feature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)) { if (jp.getText().length() == 0) { return null; } } if (!ctxt.isEnabled(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)) { throw ctxt.mappingException(_valueClass); } return new int[] { _parseIntPrimitive(jp, ctxt) }; } }
protected PrimitiveArrayDeserializers() { _allDeserializers = new HashMap<JavaType,JsonDeserializer<Object>>(); // note: we'll use component type as key, not array type add(boolean.class, new BooleanDeser()); /* ByteDeser is bit special, as it has 2 separate modes of operation; * one for String input (-> base64 input), the other for * numeric input */ add(byte.class, new ByteDeser()); add(short.class, new ShortDeser()); add(int.class, new IntDeser()); add(long.class, new LongDeser()); add(float.class, new FloatDeser()); add(double.class, new DoubleDeser()); add(String.class, new StringDeser()); /* also: char[] is most likely only used with Strings; doesn't * seem to make sense to transfer as numbers */ add(char.class, new CharDeser()); }
@Override public int[] deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { if (!jp.isExpectedStartArrayToken()) { return handleNonArray(jp, ctxt); } ArrayBuilders.IntBuilder builder = ctxt.getArrayBuilders().getIntBuilder(); int[] chunk = builder.resetAndStart(); int ix = 0; while (jp.nextToken() != JsonToken.END_ARRAY) { // whether we should allow truncating conversions? int value = _parseIntPrimitive(jp, ctxt); if (ix >= chunk.length) { chunk = builder.appendCompletedChunk(chunk, ix); ix = 0; } chunk[ix++] = value; } return builder.completeAndClearBuffer(chunk, ix); }
protected PrimitiveArrayDeserializers() { _allDeserializers = new HashMap<JavaType,JsonDeserializer<Object>>(); // note: we'll use component type as key, not array type add(boolean.class, new BooleanDeser()); /* ByteDeser is bit special, as it has 2 separate modes of operation; * one for String input (-> base64 input), the other for * numeric input */ add(byte.class, new ByteDeser()); add(short.class, new ShortDeser()); add(int.class, new IntDeser()); add(long.class, new LongDeser()); add(float.class, new FloatDeser()); add(double.class, new DoubleDeser()); add(String.class, new StringDeser()); /* also: char[] is most likely only used with Strings; doesn't * seem to make sense to transfer as numbers */ add(char.class, new CharDeser()); }
@Override public int[] deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { if (!jp.isExpectedStartArrayToken()) { return handleNonArray(jp, ctxt); } ArrayBuilders.IntBuilder builder = ctxt.getArrayBuilders().getIntBuilder(); int[] chunk = builder.resetAndStart(); int ix = 0; while (jp.nextToken() != JsonToken.END_ARRAY) { // whether we should allow truncating conversions? int value = _parseIntPrimitive(jp, ctxt); if (ix >= chunk.length) { chunk = builder.appendCompletedChunk(chunk, ix); ix = 0; } chunk[ix++] = value; } return builder.completeAndClearBuffer(chunk, ix); }
private final int[] handleNonArray(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { // [JACKSON-620] Empty String can become null... if ((jp.getCurrentToken() == JsonToken.VALUE_STRING) && ctxt.isEnabled(DeserializationConfig.Feature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)) { if (jp.getText().length() == 0) { return null; } } if (!ctxt.isEnabled(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)) { throw ctxt.mappingException(_valueClass); } return new int[] { _parseIntPrimitive(jp, ctxt) }; } }
private final int[] handleNonArray(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { // [JACKSON-620] Empty String can become null... if ((jp.getCurrentToken() == JsonToken.VALUE_STRING) && ctxt.isEnabled(DeserializationConfig.Feature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)) { if (jp.getText().length() == 0) { return null; } } if (!ctxt.isEnabled(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)) { throw ctxt.mappingException(_valueClass); } return new int[] { _parseIntPrimitive(jp, ctxt) }; } }
protected PrimitiveArrayDeserializers() { _allDeserializers = new HashMap<JavaType,JsonDeserializer<Object>>(); // note: we'll use component type as key, not array type add(boolean.class, new BooleanDeser()); /* ByteDeser is bit special, as it has 2 separate modes of operation; * one for String input (-> base64 input), the other for * numeric input */ add(byte.class, new ByteDeser()); add(short.class, new ShortDeser()); add(int.class, new IntDeser()); add(long.class, new LongDeser()); add(float.class, new FloatDeser()); add(double.class, new DoubleDeser()); add(String.class, new StringDeser()); /* also: char[] is most likely only used with Strings; doesn't * seem to make sense to transfer as numbers */ add(char.class, new CharDeser()); }
@Override public int[] deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { if (!jp.isExpectedStartArrayToken()) { return handleNonArray(jp, ctxt); } ArrayBuilders.IntBuilder builder = ctxt.getArrayBuilders().getIntBuilder(); int[] chunk = builder.resetAndStart(); int ix = 0; while (jp.nextToken() != JsonToken.END_ARRAY) { // whether we should allow truncating conversions? int value = _parseIntPrimitive(jp, ctxt); if (ix >= chunk.length) { chunk = builder.appendCompletedChunk(chunk, ix); ix = 0; } chunk[ix++] = value; } return builder.completeAndClearBuffer(chunk, ix); }
private final int[] handleNonArray(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { // [JACKSON-620] Empty String can become null... if ((jp.getCurrentToken() == JsonToken.VALUE_STRING) && ctxt.isEnabled(DeserializationConfig.Feature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)) { if (jp.getText().length() == 0) { return null; } } if (!ctxt.isEnabled(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)) { throw ctxt.mappingException(_valueClass); } return new int[] { _parseIntPrimitive(jp, ctxt) }; } }
@Override public int[] deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { if (!jp.isExpectedStartArrayToken()) { return handleNonArray(jp, ctxt); } ArrayBuilders.IntBuilder builder = ctxt.getArrayBuilders().getIntBuilder(); int[] chunk = builder.resetAndStart(); int ix = 0; while (jp.nextToken() != JsonToken.END_ARRAY) { // whether we should allow truncating conversions? int value = _parseIntPrimitive(jp, ctxt); if (ix >= chunk.length) { chunk = builder.appendCompletedChunk(chunk, ix); ix = 0; } chunk[ix++] = value; } return builder.completeAndClearBuffer(chunk, ix); }