/* */ public void serializeContents(Object[] value, JsonGenerator jgen, SerializerProvider provider) /* */ throws IOException, JsonGenerationException /* */ { /* 79 */ int len = value.length; /* 80 */ if (len == 0) { /* 81 */ return; /* */ } /* 83 */ if (this._elementSerializer != null) { /* 84 */ serializeContentsUsing(value, jgen, provider, this._elementSerializer); /* 85 */ return; /* */ } /* 87 */ if (this._valueTypeSerializer != null) { /* 88 */ serializeTypedContents(value, jgen, provider); /* 89 */ return; /* */ } /* 91 */ int i = 0; /* 92 */ Object elem = null; /* */ try { /* 94 */ PropertySerializerMap serializers = this._dynamicSerializers; /* 95 */ for (; i < len; i++) { /* 96 */ elem = value[i]; /* 97 */ if (elem == null) { /* 98 */ provider.defaultSerializeNull(jgen); /* */ } /* */ else { /* 101 */ Class cc = elem.getClass(); /* 102 */ JsonSerializer serializer = serializers.serializerFor(cc); /* 103 */ if (serializer == null) { /* 104 */ serializer = _findAndAddDynamic(serializers, cc, provider); /* */ } /* 106 */ serializer.serialize(elem, jgen, provider); /* */ } /* */ } /* */ } catch (IOException ioe) { /* 109 */ throw ioe; /* */ } /* */ catch (Exception e) /* */ { /* 116 */ Throwable t = e; /* 117 */ while (((t instanceof InvocationTargetException)) && (t.getCause() != null)) { /* 118 */ t = t.getCause(); /* */ } /* 120 */ if ((t instanceof Error)) { /* 121 */ throw ((Error)t); /* */ } /* 123 */ throw JsonMappingException.wrapWithPath(t, elem, i); /* */ } /* */ }
/* */ public ObjectArraySerializer(JavaType elemType, boolean staticTyping, TypeSerializer vts, BeanProperty property) /* */ { /* 63 */ super([Ljava.lang.Object.class, vts, property); /* 64 */ this._elementType = elemType; /* 65 */ this._staticTyping = staticTyping; /* 66 */ this._dynamicSerializers = PropertySerializerMap.emptyMap(); /* */ }
@Override public void serializeAsField(Object bean, JsonGenerator jgen, SerializerProvider prov) throws Exception { Object value = get(bean); if (value == null) { // Hmmh. I assume we MUST pretty much suppress nulls, since we // can't really unwrap them... return; } JsonSerializer<Object> ser = _serializer; if (ser == null) { Class<?> cls = value.getClass(); PropertySerializerMap map = _dynamicSerializers; ser = map.serializerFor(cls); if (ser == null) { ser = _findAndAddDynamic(map, cls, prov); } } if (_suppressableValue != null) { if (MARKER_FOR_EMPTY == _suppressableValue) { if (ser.isEmpty(value)) { return; } } else if (_suppressableValue.equals(value)) { return; } } // For non-nulls, first: simple check for direct cycles if (value == bean) { if (_handleSelfReference(bean, jgen, prov, ser)) { return; } } // note: must verify we are using unwrapping serializer; if not, will write field name if (!ser.isUnwrappingSerializer()) { jgen.writeFieldName(_name); } if (_typeSerializer == null) { ser.serialize(value, jgen, prov); } else { ser.serializeWithType(value, jgen, prov, _typeSerializer); } }
/* */ protected final JsonSerializer<Object> _findAndAddDynamic(PropertySerializerMap map, Class<?> type, SerializerProvider provider) /* */ throws JsonMappingException /* */ { /* 241 */ PropertySerializerMap.SerializerAndMapResult result = map.findAndAddSerializer(type, provider, this._property); /* */ /* 243 */ if (map != result.map) { /* 244 */ this._dynamicSerializers = result.map; /* */ } /* 246 */ return result.serializer; /* */ }
/* */ public void serializeTypedContents(Object[] value, JsonGenerator jgen, SerializerProvider provider) /* */ throws IOException, JsonGenerationException /* */ { /* 166 */ int len = value.length; /* 167 */ TypeSerializer typeSer = this._valueTypeSerializer; /* 168 */ int i = 0; /* 169 */ Object elem = null; /* */ try { /* 171 */ PropertySerializerMap serializers = this._dynamicSerializers; /* 172 */ for (; i < len; i++) { /* 173 */ elem = value[i]; /* 174 */ if (elem == null) { /* 175 */ provider.defaultSerializeNull(jgen); /* */ } /* */ else { /* 178 */ Class cc = elem.getClass(); /* 179 */ JsonSerializer serializer = serializers.serializerFor(cc); /* 180 */ if (serializer == null) { /* 181 */ serializer = _findAndAddDynamic(serializers, cc, provider); /* */ } /* 183 */ serializer.serializeWithType(elem, jgen, provider, typeSer); /* */ } /* */ } /* */ } catch (IOException ioe) { /* 186 */ throw ioe; /* */ } catch (Exception e) { /* 188 */ Throwable t = e; /* 189 */ while (((t instanceof InvocationTargetException)) && (t.getCause() != null)) { /* 190 */ t = t.getCause(); /* */ } /* 192 */ if ((t instanceof Error)) { /* 193 */ throw ((Error)t); /* */ } /* 195 */ throw JsonMappingException.wrapWithPath(t, elem, i); /* */ } /* */ }