// 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; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.Version; import com.fasterxml.jackson.core.Versioned; import com.fasterxml.jackson.databind.cfg.PackageVersion; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.ser.DefaultSerializerProvider; import com.fasterxml.jackson.databind.ser.impl.PropertySerializerMap; import com.fasterxml.jackson.databind.ser.impl.TypeWrappedSerializer; import java.io.Closeable; import java.io.Flushable; import java.io.IOException; import java.util.Collection; import java.util.Iterator; // Referenced classes of package com.fasterxml.jackson.databind: // SerializationFeature, SerializationConfig, JsonMappingException, JavaType, // JsonSerializer public class SequenceWriter implements Versioned, Closeable, Flushable { protected final boolean _cfgCloseCloseable; protected final boolean _cfgFlush; protected final boolean _closeGenerator; protected boolean _closed; protected final SerializationConfig _config; protected PropertySerializerMap _dynamicSerializers; protected final JsonGenerator _generator; protected boolean _openArray; protected final DefaultSerializerProvider _provider; protected final JsonSerializer _rootSerializer; protected final TypeSerializer _typeSerializer; public SequenceWriter(DefaultSerializerProvider defaultserializerprovider, JsonGenerator jsongenerator, boolean flag, ObjectWriter.Prefetch prefetch) throws IOException { _provider = defaultserializerprovider; _generator = jsongenerator; _closeGenerator = flag; _rootSerializer = prefetch.getValueSerializer(); _typeSerializer = prefetch.getTypeSerializer(); _config = defaultserializerprovider.getConfig(); _cfgFlush = _config.isEnabled(SerializationFeature.FLUSH_AFTER_WRITE_VALUE); _cfgCloseCloseable = _config.isEnabled(SerializationFeature.CLOSE_CLOSEABLE); _dynamicSerializers = PropertySerializerMap.emptyForRootValues(); } private final JsonSerializer _findAndAddDynamic(JavaType javatype) throws JsonMappingException { if (_typeSerializer == null) { javatype = _dynamicSerializers.findAndAddRootValueSerializer(javatype, _provider); } else { javatype = _dynamicSerializers.addSerializer(javatype, new TypeWrappedSerializer(_typeSerializer, _provider.findValueSerializer(javatype, null))); } _dynamicSerializers = ((com.fasterxml.jackson.databind.ser.impl.PropertySerializerMap.SerializerAndMapResult) (javatype)).map; return ((com.fasterxml.jackson.databind.ser.impl.PropertySerializerMap.SerializerAndMapResult) (javatype)).serializer; } private final JsonSerializer _findAndAddDynamic(Class class1) throws JsonMappingException { if (_typeSerializer == null) { class1 = _dynamicSerializers.findAndAddRootValueSerializer(class1, _provider); } else { class1 = _dynamicSerializers.addSerializer(class1, new TypeWrappedSerializer(_typeSerializer, _provider.findValueSerializer(class1, null))); } _dynamicSerializers = ((com.fasterxml.jackson.databind.ser.impl.PropertySerializerMap.SerializerAndMapResult) (class1)).map; return ((com.fasterxml.jackson.databind.ser.impl.PropertySerializerMap.SerializerAndMapResult) (class1)).serializer; } protected SequenceWriter _writeCloseableValue(Object obj) throws IOException { Closeable closeable; Closeable closeable1; closeable1 = (Closeable)obj; closeable = closeable1; JsonSerializer jsonserializer1 = _rootSerializer; JsonSerializer jsonserializer; jsonserializer = jsonserializer1; if (jsonserializer1 != null) { break MISSING_BLOCK_LABEL_64; } closeable = closeable1; Class class1 = obj.getClass(); closeable = closeable1; jsonserializer1 = _dynamicSerializers.serializerFor(class1); jsonserializer = jsonserializer1; if (jsonserializer1 != null) { break MISSING_BLOCK_LABEL_64; } closeable = closeable1; jsonserializer = _findAndAddDynamic(class1); closeable = closeable1; _provider.serializeValue(_generator, obj, null, jsonserializer); closeable = closeable1; if (!_cfgFlush) { break MISSING_BLOCK_LABEL_101; } closeable = closeable1; _generator.flush(); closeable = null; closeable1.close(); if (false) { try { throw new NullPointerException(); } // Misplaced declaration of an exception variable catch (Object obj) { return this; } } else { return this; } obj; if (closeable != null) { try { closeable.close(); } catch (IOException ioexception) { } } throw obj; } protected SequenceWriter _writeCloseableValue(Object obj, JavaType javatype) throws IOException { Closeable closeable; Closeable closeable1; closeable1 = (Closeable)obj; closeable = closeable1; JsonSerializer jsonserializer1 = _dynamicSerializers.serializerFor(javatype.getRawClass()); JsonSerializer jsonserializer; jsonserializer = jsonserializer1; if (jsonserializer1 != null) { break MISSING_BLOCK_LABEL_41; } closeable = closeable1; jsonserializer = _findAndAddDynamic(javatype); closeable = closeable1; _provider.serializeValue(_generator, obj, javatype, jsonserializer); closeable = closeable1; if (!_cfgFlush) { break MISSING_BLOCK_LABEL_79; } closeable = closeable1; _generator.flush(); closeable = null; closeable1.close(); if (false) { try { throw new NullPointerException(); } // Misplaced declaration of an exception variable catch (Object obj) { return this; } } else { return this; } obj; if (closeable != null) { try { closeable.close(); } // Misplaced declaration of an exception variable catch (JavaType javatype) { } } throw obj; } public void close() throws IOException { if (!_closed) { _closed = true; if (_openArray) { _openArray = false; _generator.writeEndArray(); } if (_closeGenerator) { _generator.close(); } } } public void flush() throws IOException { if (!_closed) { _generator.flush(); } } public SequenceWriter init(boolean flag) throws IOException { if (flag) { _generator.writeStartArray(); _openArray = true; } return this; } public Version version() { return PackageVersion.VERSION; } public SequenceWriter write(Object obj) throws IOException { if (obj == null) { _provider.serializeValue(_generator, null); } else { if (_cfgCloseCloseable && (obj instanceof Closeable)) { return _writeCloseableValue(obj); } JsonSerializer jsonserializer1 = _rootSerializer; JsonSerializer jsonserializer = jsonserializer1; if (jsonserializer1 == null) { Class class1 = obj.getClass(); JsonSerializer jsonserializer2 = _dynamicSerializers.serializerFor(class1); jsonserializer = jsonserializer2; if (jsonserializer2 == null) { jsonserializer = _findAndAddDynamic(class1); } } _provider.serializeValue(_generator, obj, null, jsonserializer); if (_cfgFlush) { _generator.flush(); return this; } } return this; } public SequenceWriter write(Object obj, JavaType javatype) throws IOException { if (obj == null) { _provider.serializeValue(_generator, null); } else { if (_cfgCloseCloseable && (obj instanceof Closeable)) { return _writeCloseableValue(obj, javatype); } JsonSerializer jsonserializer1 = _dynamicSerializers.serializerFor(javatype.getRawClass()); JsonSerializer jsonserializer = jsonserializer1; if (jsonserializer1 == null) { jsonserializer = _findAndAddDynamic(javatype); } _provider.serializeValue(_generator, obj, javatype, jsonserializer); if (_cfgFlush) { _generator.flush(); return this; } } return this; } public SequenceWriter writeAll(Collection collection) throws IOException { for (collection = collection.iterator(); collection.hasNext(); write(collection.next())) { } return this; } public SequenceWriter writeAll(Object aobj[]) throws IOException { int i = 0; for (int j = aobj.length; i < j; i++) { write(aobj[i]); } return this; } }