com.fasterxml.jackson.databind.ObjectMapper._configAndWriteCloseable()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(95)

本文整理了Java中com.fasterxml.jackson.databind.ObjectMapper._configAndWriteCloseable()方法的一些代码示例,展示了ObjectMapper._configAndWriteCloseable()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ObjectMapper._configAndWriteCloseable()方法的具体详情如下:
包路径:com.fasterxml.jackson.databind.ObjectMapper
类名称:ObjectMapper
方法名:_configAndWriteCloseable

ObjectMapper._configAndWriteCloseable介绍

[英]Helper method used when value to serialize is Closeable and its close() method is to be called right after serialization has been called
[中]当要序列化的值是可关闭的并且在调用序列化后立即调用其close()方法时使用的帮助器方法

代码示例

代码示例来源:origin: redisson/redisson

/**
 * 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();
}

代码示例来源:origin: hstaudacher/osgi-jax-rs-connector

_configAndWriteCloseable(jgen, value, cfg);
return;

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

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) { }
    }
  }
}

代码示例来源:origin: com.fasterxml.jackson.core/com.springsource.com.fasterxml.jackson.core.jackson-databind

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) { }
    }
  }
}

代码示例来源:origin: com.eclipsesource.jaxrs/jersey-all

_configAndWriteCloseable(jgen, value, cfg);
return;

代码示例来源:origin: com.fasterxml.jackson.core/com.springsource.com.fasterxml.jackson.core.jackson-databind

_configAndWriteCloseable(jgen, value, cfg);
return;

代码示例来源:origin: com.eclipsesource.jaxrs/jersey-all

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) { }
    }
  }
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

_configAndWriteCloseable(jgen, value, cfg);
return;

代码示例来源:origin: com.jwebmp.jackson.core/jackson-databind

/**
 * 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();
}

代码示例来源:origin: Nextdoor/bender

/**
 * 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();
}

代码示例来源:origin: hstaudacher/osgi-jax-rs-connector

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) { }
    }
  }
}

相关文章

微信公众号

最新文章

更多

ObjectMapper类方法