public String[] deserialize(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext) { if (!paramJsonParser.isExpectedStartArrayToken()) return handleNonArray(paramJsonParser, paramDeserializationContext); ObjectBuffer localObjectBuffer = paramDeserializationContext.leaseObjectBuffer(); Object[] arrayOfObject = localObjectBuffer.resetAndStart(); int i = 0; JsonToken localJsonToken = paramJsonParser.nextToken(); String str; if (localJsonToken != JsonToken.END_ARRAY) if (localJsonToken == JsonToken.VALUE_NULL) { str = null; label53: if (i < arrayOfObject.length) break label122; arrayOfObject = localObjectBuffer.appendCompletedChunk(arrayOfObject); } label122: for (int j = 0; ; j = i) { i = j + 1; arrayOfObject[j] = str; break; str = _parseString(paramJsonParser, paramDeserializationContext); break label53; String[] arrayOfString = (String[])localObjectBuffer.completeAndClearBuffer(arrayOfObject, i, String.class); paramDeserializationContext.returnObjectBuffer(localObjectBuffer); return arrayOfString; } }
/** * Method to call to return object buffer previously leased with {@link #leaseObjectBuffer}. * * @param buf Returned object buffer */ public final void returnObjectBuffer(ObjectBuffer buf) { /* Already have a reusable buffer? Let's retain bigger one * (or if equal, favor newer one, shorter life-cycle) */ if (_objectBuffer == null || buf.initialCapacity() >= _objectBuffer.initialCapacity()) { _objectBuffer = buf; } }
/** Offlined version used when we do not use the default deserialization method. */ protected final String[] _deserializeCustom( JsonParser p, DeserializationContext ctxt, String[] old) throws IOException { final ObjectBuffer buffer = ctxt.leaseObjectBuffer(); int ix; Object[] chunk; if (old == null) { ix = 0; chunk = buffer.resetAndStart(); } else { ix = old.length; chunk = buffer.resetAndStart(old, ix); } final JsonDeserializer<String> deser = _elementDeserializer; try { while (true) { /* 30-Dec-2014, tatu: This may look odd, but let's actually call method * that suggest we are expecting a String; this helps with some formats, * notably XML. Note, however, that while we can get String, we can't * assume that's what we use due to custom deserializer */ String value; if (p.nextTextValue() == null) { JsonToken t = p.getCurrentToken(); if (t == JsonToken.END_ARRAY) { break; } // Ok: no need to convert Strings, but must recognize nulls value = (t == JsonToken.VALUE_NULL) ? deser.getNullValue(ctxt) : deser.deserialize(p, ctxt); } else { value = deser.deserialize(p, ctxt); } if (ix >= chunk.length) { chunk = buffer.appendCompletedChunk(chunk); ix = 0; } chunk[ix++] = value; } } catch (Exception e) { // note: pass String.class, not String[].class, as we need element type for error info throw JsonMappingException.wrapWithPath(e, String.class, ix); } String[] result = buffer.completeAndClearBuffer(chunk, ix, String.class); ctxt.returnObjectBuffer(buffer); return result; }
@Override public String[] deserialize(JsonParser p, DeserializationContext ctxt, String[] intoValue) throws IOException { // Ok: must point to START_ARRAY (or equivalent) if (!p.isExpectedStartArrayToken()) { String[] arr = handleNonArray(p, ctxt); if (arr == null) { return intoValue; } final int offset = intoValue.length; String[] result = new String[offset + arr.length]; System.arraycopy(intoValue, 0, result, 0, offset); System.arraycopy(arr, 0, result, offset, arr.length); return result; } if (_elementDeserializer != null) { return _deserializeCustom(p, ctxt, intoValue); } final ObjectBuffer buffer = ctxt.leaseObjectBuffer(); int ix = intoValue.length; Object[] chunk = buffer.resetAndStart(intoValue, ix); try { while (true) { String value = p.nextTextValue(); if (value == null) { JsonToken t = p.getCurrentToken(); if (t == JsonToken.END_ARRAY) { break; } if (t != JsonToken.VALUE_NULL) { value = _parseString(p, ctxt); } } if (ix >= chunk.length) { chunk = buffer.appendCompletedChunk(chunk); ix = 0; } chunk[ix++] = value; } } catch (Exception e) { throw JsonMappingException.wrapWithPath(e, chunk, buffer.bufferedSize() + ix); } String[] result = buffer.completeAndClearBuffer(chunk, ix, String.class); ctxt.returnObjectBuffer(buffer); return result; }