/** * Method called to configure the generator as necessary and then * call write functionality */ protected final void _configAndWriteValue(JsonGenerator g, Object value) throws IOException { SerializationConfig cfg = getSerializationConfig(); cfg.initialize(g); // since 2.5 if (cfg.isEnabled(SerializationFeature.CLOSE_CLOSEABLE) && (value instanceof Closeable)) { _configAndWriteCloseable(g, value, cfg); return; } try { _serializerProvider(cfg).serializeValue(g, value); } catch (Exception e) { ClassUtil.closeOnFailAndThrowAsIOE(g, e); return; } g.close(); }
_configAndWriteCloseable(jgen, value, cfg); return;
protected final void _configAndWriteValue(JsonGenerator jgen, Object value, Class<?> viewClass) throws IOException, JsonGenerationException, JsonMappingException { SerializationConfig cfg = getSerializationConfig().withView(viewClass); if (cfg.isEnabled(SerializationFeature.INDENT_OUTPUT)) { jgen.useDefaultPrettyPrinter(); } // [JACKSON-282]: consider Closeable if (cfg.isEnabled(SerializationFeature.CLOSE_CLOSEABLE) && (value instanceof Closeable)) { _configAndWriteCloseable(jgen, value, cfg); return; } boolean closed = false; try { _serializerProvider(cfg).serializeValue(jgen, value); closed = true; jgen.close(); } finally { if (!closed) { try { jgen.close(); } catch (IOException ioe) { } } } }
protected final void _configAndWriteValue(JsonGenerator jgen, Object value, Class<?> viewClass) throws IOException, JsonGenerationException, JsonMappingException { SerializationConfig cfg = getSerializationConfig().withView(viewClass); if (cfg.isEnabled(SerializationFeature.INDENT_OUTPUT)) { jgen.useDefaultPrettyPrinter(); } // [JACKSON-282]: consider Closeable if (cfg.isEnabled(SerializationFeature.CLOSE_CLOSEABLE) && (value instanceof Closeable)) { _configAndWriteCloseable(jgen, value, cfg); return; } boolean closed = false; try { _serializerProvider(cfg).serializeValue(jgen, value); closed = true; jgen.close(); } finally { if (!closed) { try { jgen.close(); } catch (IOException ioe) { } } } }
_configAndWriteCloseable(jgen, value, cfg); return;
_configAndWriteCloseable(jgen, value, cfg); return;
protected final void _configAndWriteValue(JsonGenerator jgen, Object value, Class<?> viewClass) throws IOException { SerializationConfig cfg = getSerializationConfig().withView(viewClass); cfg.initialize(jgen); // since 2.5 // [JACKSON-282]: consider Closeable if (cfg.isEnabled(SerializationFeature.CLOSE_CLOSEABLE) && (value instanceof Closeable)) { _configAndWriteCloseable(jgen, value, cfg); return; } boolean closed = false; try { _serializerProvider(cfg).serializeValue(jgen, value); closed = true; jgen.close(); } finally { if (!closed) { // 04-Mar-2014, tatu: But! Let's try to prevent auto-closing of // structures, which typically causes more damage. jgen.disable(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT); try { jgen.close(); } catch (IOException ioe) { } } } }
_configAndWriteCloseable(jgen, value, cfg); return;
/** * Method called to configure the generator as necessary and then * call write functionality */ protected final void _configAndWriteValue(JsonGenerator g, Object value) throws IOException { SerializationConfig cfg = getSerializationConfig(); cfg.initialize(g); // since 2.5 if (cfg.isEnabled(SerializationFeature.CLOSE_CLOSEABLE) && (value instanceof Closeable)) { _configAndWriteCloseable(g, value, cfg); return; } try { _serializerProvider(cfg).serializeValue(g, value); } catch (Exception e) { ClassUtil.closeOnFailAndThrowAsIOE(g, e); return; } g.close(); }
/** * Method called to configure the generator as necessary and then * call write functionality */ protected final void _configAndWriteValue(JsonGenerator g, Object value) throws IOException { SerializationConfig cfg = getSerializationConfig(); cfg.initialize(g); // since 2.5 if (cfg.isEnabled(SerializationFeature.CLOSE_CLOSEABLE) && (value instanceof Closeable)) { _configAndWriteCloseable(g, value, cfg); return; } try { _serializerProvider(cfg).serializeValue(g, value); } catch (Exception e) { ClassUtil.closeOnFailAndThrowAsIAE(g, e); return; } g.close(); }
protected final void _configAndWriteValue(JsonGenerator jgen, Object value, Class<?> viewClass) throws IOException { SerializationConfig cfg = getSerializationConfig().withView(viewClass); cfg.initialize(jgen); // since 2.5 // [JACKSON-282]: consider Closeable if (cfg.isEnabled(SerializationFeature.CLOSE_CLOSEABLE) && (value instanceof Closeable)) { _configAndWriteCloseable(jgen, value, cfg); return; } boolean closed = false; try { _serializerProvider(cfg).serializeValue(jgen, value); closed = true; jgen.close(); } finally { if (!closed) { // 04-Mar-2014, tatu: But! Let's try to prevent auto-closing of // structures, which typically causes more damage. jgen.disable(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT); try { jgen.close(); } catch (IOException ioe) { } } } }