// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.geocities.com/kpdus/jad.html // Decompiler options: braces fieldsfirst space lnc package com.fasterxml.jackson.databind.ser; import com.fasterxml.jackson.annotation.ObjectIdGenerator; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.PropertyName; import com.fasterxml.jackson.databind.SerializationConfig; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.cfg.HandlerInstantiator; import com.fasterxml.jackson.databind.introspect.Annotated; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; import com.fasterxml.jackson.databind.jsonschema.JsonSchema; import com.fasterxml.jackson.databind.jsonschema.SchemaAware; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.ser.impl.WritableObjectId; import com.fasterxml.jackson.databind.util.ClassUtil; import java.io.IOException; import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.IdentityHashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicReference; // Referenced classes of package com.fasterxml.jackson.databind.ser: // SerializerCache, SerializerFactory public abstract class DefaultSerializerProvider extends SerializerProvider implements Serializable { public static final class Impl extends DefaultSerializerProvider { private static final long serialVersionUID = 1L; public DefaultSerializerProvider copy() { if (getClass() != com/fasterxml/jackson/databind/ser/DefaultSerializerProvider$Impl) { return copy(); } else { return new Impl(this); } } public Impl createInstance(SerializationConfig serializationconfig, SerializerFactory serializerfactory) { return new Impl(this, serializationconfig, serializerfactory); } public volatile DefaultSerializerProvider createInstance(SerializationConfig serializationconfig, SerializerFactory serializerfactory) { return createInstance(serializationconfig, serializerfactory); } public Impl() { } protected Impl(SerializerProvider serializerprovider, SerializationConfig serializationconfig, SerializerFactory serializerfactory) { super(serializerprovider, serializationconfig, serializerfactory); } public Impl(Impl impl) { super(impl); } } private static final long serialVersionUID = 1L; protected transient ArrayList _objectIdGenerators; protected transient Map _seenObjectIds; protected DefaultSerializerProvider() { } protected DefaultSerializerProvider(SerializerProvider serializerprovider, SerializationConfig serializationconfig, SerializerFactory serializerfactory) { super(serializerprovider, serializationconfig, serializerfactory); } protected DefaultSerializerProvider(DefaultSerializerProvider defaultserializerprovider) { super(defaultserializerprovider); } protected Map _createObjectIdMap() { if (isEnabled(SerializationFeature.USE_EQUALITY_FOR_OBJECT_ID)) { return new HashMap(); } else { return new IdentityHashMap(); } } protected void _serializeNull(JsonGenerator jsongenerator) throws IOException { JsonSerializer jsonserializer = getDefaultNullValueSerializer(); try { jsonserializer.serialize(null, jsongenerator, this); return; } // Misplaced declaration of an exception variable catch (JsonGenerator jsongenerator) { throw jsongenerator; } catch (Exception exception) { String s = exception.getMessage(); jsongenerator = s; if (s == null) { jsongenerator = (new StringBuilder()).append("[no message for ").append(exception.getClass().getName()).append("]").toString(); } throw new JsonMappingException(jsongenerator, exception); } } public void acceptJsonFormatVisitor(JavaType javatype, JsonFormatVisitorWrapper jsonformatvisitorwrapper) throws JsonMappingException { if (javatype == null) { throw new IllegalArgumentException("A class must be provided"); } else { jsonformatvisitorwrapper.setProvider(this); findValueSerializer(javatype, null).acceptJsonFormatVisitor(jsonformatvisitorwrapper, javatype); return; } } public int cachedSerializersCount() { return _serializerCache.size(); } public DefaultSerializerProvider copy() { throw new IllegalStateException("DefaultSerializerProvider sub-class not overriding copy()"); } public abstract DefaultSerializerProvider createInstance(SerializationConfig serializationconfig, SerializerFactory serializerfactory); public WritableObjectId findObjectId(Object obj, ObjectIdGenerator objectidgenerator) { Object obj1; ObjectIdGenerator objectidgenerator1; if (_seenObjectIds == null) { _seenObjectIds = _createObjectIdMap(); } else { obj1 = (WritableObjectId)_seenObjectIds.get(obj); if (obj1 != null) { return ((WritableObjectId) (obj1)); } } objectidgenerator1 = null; if (_objectIdGenerators != null) goto _L2; else goto _L1 _L1: _objectIdGenerators = new ArrayList(8); obj1 = objectidgenerator1; _L4: objectidgenerator1 = ((ObjectIdGenerator) (obj1)); if (obj1 == null) { objectidgenerator1 = objectidgenerator.newForSerialization(this); _objectIdGenerators.add(objectidgenerator1); } objectidgenerator = new WritableObjectId(objectidgenerator1); _seenObjectIds.put(obj, objectidgenerator); return objectidgenerator; _L2: int i; int j; i = 0; j = _objectIdGenerators.size(); _L6: obj1 = objectidgenerator1; if (i >= j) goto _L4; else goto _L3 _L3: obj1 = (ObjectIdGenerator)_objectIdGenerators.get(i); if (!((ObjectIdGenerator) (obj1)).canUseFor(objectidgenerator)) goto _L5; else goto _L4 _L5: i++; goto _L6 } public void flushCachedSerializers() { _serializerCache.flush(); } public JsonSchema generateJsonSchema(Class class1) throws JsonMappingException { if (class1 == null) { throw new IllegalArgumentException("A class must be provided"); } Object obj = findValueSerializer(class1, null); if (obj instanceof SchemaAware) { obj = ((SchemaAware)obj).getSchema(this, null); } else { obj = JsonSchema.getDefaultSchemaNode(); } if (!(obj instanceof ObjectNode)) { throw new IllegalArgumentException((new StringBuilder()).append("Class ").append(class1.getName()).append(" would not be serialized as a JSON object and therefore has no schema").toString()); } else { return new JsonSchema((ObjectNode)obj); } } public boolean hasSerializerFor(Class class1, AtomicReference atomicreference) { boolean flag = false; class1 = _findExplicitUntypedSerializer(class1); if (class1 != null) { flag = true; } _L2: return flag; class1; if (atomicreference != null) { atomicreference.set(class1); return false; } if (true) goto _L2; else goto _L1 _L1: class1; if (atomicreference == null) { throw class1; } else { atomicreference.set(class1); return false; } } public void serializePolymorphic(JsonGenerator jsongenerator, Object obj, JavaType javatype, JsonSerializer jsonserializer, TypeSerializer typeserializer) throws IOException { if (obj != null) goto _L2; else goto _L1 _L1: _serializeNull(jsongenerator); _L4: return; _L2: if (javatype != null && !javatype.getRawClass().isAssignableFrom(obj.getClass())) { _reportIncompatibleRootType(obj, javatype); } JsonSerializer jsonserializer1 = jsonserializer; boolean flag; if (jsonserializer == null) { if (javatype != null && javatype.isContainerType()) { jsonserializer1 = findValueSerializer(javatype, null); } else { jsonserializer1 = findValueSerializer(obj.getClass(), null); } } javatype = _config.getFullRootName(); if (javatype == null) { boolean flag1 = _config.isEnabled(SerializationFeature.WRAP_ROOT_VALUE); flag = flag1; if (flag1) { jsongenerator.writeStartObject(); jsongenerator.writeFieldName(_config.findRootName(obj.getClass()).simpleAsEncoded(_config)); flag = flag1; } } else if (javatype.isEmpty()) { flag = false; } else { flag = true; jsongenerator.writeStartObject(); jsongenerator.writeFieldName(javatype.getSimpleName()); } jsonserializer1.serializeWithType(obj, jsongenerator, this, typeserializer); if (flag) { try { jsongenerator.writeEndObject(); return; } // Misplaced declaration of an exception variable catch (JsonGenerator jsongenerator) { throw jsongenerator; } // Misplaced declaration of an exception variable catch (JavaType javatype) { obj = javatype.getMessage(); } jsongenerator = ((JsonGenerator) (obj)); if (obj == null) { jsongenerator = (new StringBuilder()).append("[no message for ").append(javatype.getClass().getName()).append("]").toString(); } throw new JsonMappingException(jsongenerator, javatype); } if (true) goto _L4; else goto _L3 _L3: } public void serializePolymorphic(JsonGenerator jsongenerator, Object obj, TypeSerializer typeserializer) throws IOException { JavaType javatype; if (obj == null) { javatype = null; } else { javatype = _config.constructType(obj.getClass()); } serializePolymorphic(jsongenerator, obj, javatype, null, typeserializer); } public void serializeValue(JsonGenerator jsongenerator, Object obj) throws IOException { if (obj != null) goto _L2; else goto _L1 _L1: _serializeNull(jsongenerator); _L4: return; _L2: JsonSerializer jsonserializer = findTypedValueSerializer(obj.getClass(), true, null); PropertyName propertyname = _config.getFullRootName(); boolean flag; if (propertyname == null) { boolean flag1 = _config.isEnabled(SerializationFeature.WRAP_ROOT_VALUE); flag = flag1; if (flag1) { jsongenerator.writeStartObject(); jsongenerator.writeFieldName(_config.findRootName(obj.getClass()).simpleAsEncoded(_config)); flag = flag1; } } else if (propertyname.isEmpty()) { flag = false; } else { flag = true; jsongenerator.writeStartObject(); jsongenerator.writeFieldName(propertyname.getSimpleName()); } try { jsonserializer.serialize(obj, jsongenerator, this); } // Misplaced declaration of an exception variable catch (JsonGenerator jsongenerator) { throw jsongenerator; } catch (Exception exception) { obj = exception.getMessage(); jsongenerator = ((JsonGenerator) (obj)); if (obj == null) { jsongenerator = (new StringBuilder()).append("[no message for ").append(exception.getClass().getName()).append("]").toString(); } throw new JsonMappingException(jsongenerator, exception); } if (!flag) goto _L4; else goto _L3 _L3: jsongenerator.writeEndObject(); return; } public void serializeValue(JsonGenerator jsongenerator, Object obj, JavaType javatype) throws IOException { if (obj != null) goto _L2; else goto _L1 _L1: _serializeNull(jsongenerator); _L4: return; _L2: if (!javatype.getRawClass().isAssignableFrom(obj.getClass())) { _reportIncompatibleRootType(obj, javatype); } javatype = findTypedValueSerializer(javatype, true, null); PropertyName propertyname = _config.getFullRootName(); boolean flag; if (propertyname == null) { boolean flag1 = _config.isEnabled(SerializationFeature.WRAP_ROOT_VALUE); flag = flag1; if (flag1) { jsongenerator.writeStartObject(); jsongenerator.writeFieldName(_config.findRootName(obj.getClass()).simpleAsEncoded(_config)); flag = flag1; } } else if (propertyname.isEmpty()) { flag = false; } else { flag = true; jsongenerator.writeStartObject(); jsongenerator.writeFieldName(propertyname.getSimpleName()); } javatype.serialize(obj, jsongenerator, this); if (flag) { try { jsongenerator.writeEndObject(); return; } // Misplaced declaration of an exception variable catch (JsonGenerator jsongenerator) { throw jsongenerator; } // Misplaced declaration of an exception variable catch (JavaType javatype) { obj = javatype.getMessage(); } jsongenerator = ((JsonGenerator) (obj)); if (obj == null) { jsongenerator = (new StringBuilder()).append("[no message for ").append(javatype.getClass().getName()).append("]").toString(); } throw new JsonMappingException(jsongenerator, javatype); } if (true) goto _L4; else goto _L3 _L3: } public void serializeValue(JsonGenerator jsongenerator, Object obj, JavaType javatype, JsonSerializer jsonserializer) throws IOException { if (obj != null) goto _L2; else goto _L1 _L1: _serializeNull(jsongenerator); _L4: return; _L2: if (javatype != null && !javatype.getRawClass().isAssignableFrom(obj.getClass())) { _reportIncompatibleRootType(obj, javatype); } JsonSerializer jsonserializer1 = jsonserializer; if (jsonserializer == null) { jsonserializer1 = findTypedValueSerializer(javatype, true, null); } jsonserializer = _config.getFullRootName(); boolean flag; if (jsonserializer == null) { boolean flag1 = _config.isEnabled(SerializationFeature.WRAP_ROOT_VALUE); flag = flag1; if (flag1) { jsongenerator.writeStartObject(); if (javatype == null) { javatype = _config.findRootName(obj.getClass()); } else { javatype = _config.findRootName(javatype); } jsongenerator.writeFieldName(javatype.simpleAsEncoded(_config)); flag = flag1; } } else if (jsonserializer.isEmpty()) { flag = false; } else { flag = true; jsongenerator.writeStartObject(); jsongenerator.writeFieldName(jsonserializer.getSimpleName()); } jsonserializer1.serialize(obj, jsongenerator, this); if (flag) { try { jsongenerator.writeEndObject(); return; } // Misplaced declaration of an exception variable catch (JsonGenerator jsongenerator) { throw jsongenerator; } // Misplaced declaration of an exception variable catch (JavaType javatype) { obj = javatype.getMessage(); } jsongenerator = ((JsonGenerator) (obj)); if (obj == null) { jsongenerator = (new StringBuilder()).append("[no message for ").append(javatype.getClass().getName()).append("]").toString(); } throw new JsonMappingException(jsongenerator, javatype); } if (true) goto _L4; else goto _L3 _L3: } public JsonSerializer serializerInstance(Annotated annotated, Object obj) throws JsonMappingException { if (obj != null) goto _L2; else goto _L1 _L1: return null; _L2: if (obj instanceof JsonSerializer) { annotated = (JsonSerializer)obj; } else { if (!(obj instanceof Class)) { throw new IllegalStateException((new StringBuilder()).append("AnnotationIntrospector returned serializer definition of type ").append(obj.getClass().getName()).append("; expected type JsonSerializer or Class instead").toString()); } Class class1 = (Class)obj; if (class1 == com/fasterxml/jackson/databind/JsonSerializer$None || ClassUtil.isBogusClass(class1)) { continue; /* Loop/switch isn't completed */ } if (!com/fasterxml/jackson/databind/JsonSerializer.isAssignableFrom(class1)) { throw new IllegalStateException((new StringBuilder()).append("AnnotationIntrospector returned Class ").append(class1.getName()).append("; expected Class").toString()); } obj = _config.getHandlerInstantiator(); if (obj == null) { obj = null; } else { obj = ((HandlerInstantiator) (obj)).serializerInstance(_config, annotated, class1); } annotated = ((Annotated) (obj)); if (obj == null) { annotated = (JsonSerializer)ClassUtil.createInstance(class1, _config.canOverrideAccessModifiers()); } } return _handleResolvable(annotated); if (true) goto _L1; else goto _L3 _L3: } }