/** * Method for re-sorting lists of bean properties such that attributes are strictly written before * elements. */ protected static int _orderAttributesFirst( BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties) { int attrCount = 0; for (int i = 0, len = properties.length; i < len; ++i) { BeanPropertyWriter bpw = properties[i]; if (!_isAttribute(bpw)) { continue; } // Move attribute a few places done as necessary int moveBy = i - attrCount; if (moveBy > 0) { System.arraycopy(properties, attrCount, properties, attrCount + 1, moveBy); properties[attrCount] = bpw; if (filteredProperties != null) { BeanPropertyWriter fbpw = filteredProperties[i]; System.arraycopy( filteredProperties, attrCount, filteredProperties, attrCount + 1, moveBy); filteredProperties[attrCount] = fbpw; } } ++attrCount; } return attrCount; }
@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; }