/** * Method that will construct a new instance that uses specified * serialization view for serialization (with null basically disables * view processing) */ public ObjectWriter withView(Class<?> view) { if (view == _config.getSerializationView()) return this; return new ObjectWriter(this, _config.withView(view)); }
/** * Factory method for constructing {@link ObjectWriter} that will * serialize objects using specified JSON View (filter). * * @since 1.9 */ public ObjectWriter writerWithView(Class<?> serializationView) { return new ObjectWriter(this, copySerializationConfig().withView(serializationView)); }
protected final void _configAndWriteValue(JsonGenerator jgen, Object value, Class<?> viewClass) throws IOException, JsonGenerationException, JsonMappingException { SerializationConfig cfg = copySerializationConfig().withView(viewClass); if (cfg.isEnabled(SerializationConfig.Feature.INDENT_OUTPUT)) { jgen.useDefaultPrettyPrinter(); } // [JACKSON-282]: consider Closeable if (cfg.isEnabled(SerializationConfig.Feature.CLOSE_CLOSEABLE) && (value instanceof Closeable)) { _configAndWriteCloseable(jgen, value, cfg); return; } boolean closed = false; try { _serializerProvider.serializeValue(cfg, jgen, value, _serializerFactory); closed = true; jgen.close(); } finally { if (!closed) { try { jgen.close(); } catch (IOException ioe) { } } } }
/** * Method that will construct a new instance that uses specified * serialization view for serialization (with null basically disables * view processing) */ public ObjectWriter withView(Class<?> view) { if (view == _config.getSerializationView()) return this; return new ObjectWriter(this, _config.withView(view)); }
/** * Factory method for constructing {@link ObjectWriter} that will * serialize objects using specified JSON View (filter). * * @since 1.9 */ public ObjectWriter writerWithView(Class<?> serializationView) { return new ObjectWriter(this, copySerializationConfig().withView(serializationView)); }
protected final void _configAndWriteValue(JsonGenerator jgen, Object value, Class<?> viewClass) throws IOException, JsonGenerationException, JsonMappingException { SerializationConfig cfg = copySerializationConfig().withView(viewClass); if (cfg.isEnabled(SerializationConfig.Feature.INDENT_OUTPUT)) { jgen.useDefaultPrettyPrinter(); } // [JACKSON-282]: consider Closeable if (cfg.isEnabled(SerializationConfig.Feature.CLOSE_CLOSEABLE) && (value instanceof Closeable)) { _configAndWriteCloseable(jgen, value, cfg); return; } boolean closed = false; try { _serializerProvider.serializeValue(cfg, jgen, value, _serializerFactory); closed = true; jgen.close(); } finally { if (!closed) { try { jgen.close(); } catch (IOException ioe) { } } } }
/** * Method that will construct a new instance that uses specified * serialization view for serialization (with null basically disables * view processing) */ public ObjectWriter withView(Class<?> view) { if (view == _config.getSerializationView()) return this; return new ObjectWriter(this, _config.withView(view)); }
/** * Method that will construct a new instance that uses specified * serialization view for serialization (with null basically disables * view processing) */ public ObjectWriter withView(Class<?> view) { if (view == _config.getSerializationView()) return this; return new ObjectWriter(this, _config.withView(view)); }
/** * Factory method for constructing {@link ObjectWriter} that will * serialize objects using specified JSON View (filter). * * @since 1.9 */ public ObjectWriter writerWithView(Class<?> serializationView) { return new ObjectWriter(this, copySerializationConfig().withView(serializationView)); }
/** * Method that will construct a new instance that uses specified * serialization view for serialization (with null basically disables * view processing) */ public ObjectWriter withView(Class<?> view) { if (view == _config.getSerializationView()) return this; return new ObjectWriter(this, _config.withView(view)); }
/** * Factory method for constructing {@link ObjectWriter} that will * serialize objects using specified JSON View (filter). * * @since 1.5 */ public ObjectWriter viewWriter(Class<?> serializationView) { return new ObjectWriter(this, copySerializationConfig().withView(serializationView)); }
/** * Factory method for constructing {@link ObjectWriter} that will * serialize objects using specified JSON View (filter). * * @since 1.9 */ public ObjectWriter writerWithView(Class<?> serializationView) { return new ObjectWriter(this, copySerializationConfig().withView(serializationView)); }
/** * Wraps a DB collection in a JacksonDBCollection * * @param dbCollection The DB collection to wrap * @param type The type of objects to deserialise to * @param keyType The type of the objects key * @param view The JSON view to use for serialisation * @return The wrapped collection */ public static <T, K> JacksonDBCollection<T, K> wrap(DBCollection dbCollection, Class<T> type, Class<K> keyType, Class<?> view) { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.setSerializationConfig(objectMapper.getSerializationConfig().withView(view)); MongoJacksonMapperModule.configure(objectMapper); return new JacksonDBCollection<T, K>(dbCollection, DEFAULT_OBJECT_MAPPER.constructType(type), DEFAULT_OBJECT_MAPPER.constructType(keyType), objectMapper, null); }
/** * Wraps a DB collection in a JacksonDBCollection * * @param dbCollection The DB collection to wrap * @param type The type of objects to deserialise to * @param keyType The type of the objects key * @param view The JSON view to use for serialisation * @return The wrapped collection */ public static <T, K> JacksonDBCollection<T, K> wrap(DBCollection dbCollection, Class<T> type, Class<K> keyType, Class<?> view) { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.setSerializationConfig(objectMapper.getSerializationConfig().withView(view)); MongoJacksonMapperModule.configure(objectMapper); return new JacksonDBCollection<T, K>(dbCollection, DEFAULT_OBJECT_MAPPER.constructType(type), DEFAULT_OBJECT_MAPPER.constructType(keyType), objectMapper, null); }
protected final void _configAndWriteValue(JsonGenerator jgen, Object value, Class<?> viewClass) throws IOException, JsonGenerationException, JsonMappingException { SerializationConfig cfg = copySerializationConfig().withView(viewClass); if (cfg.isEnabled(SerializationConfig.Feature.INDENT_OUTPUT)) { jgen.useDefaultPrettyPrinter(); } // [JACKSON-282]: consider Closeable if (cfg.isEnabled(SerializationConfig.Feature.CLOSE_CLOSEABLE) && (value instanceof Closeable)) { _configAndWriteCloseable(jgen, value, cfg); return; } boolean closed = false; try { _serializerProvider.serializeValue(cfg, jgen, value, _serializerFactory); 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 = copySerializationConfig().withView(viewClass); if (cfg.isEnabled(SerializationConfig.Feature.INDENT_OUTPUT)) { jgen.useDefaultPrettyPrinter(); } // [JACKSON-282]: consider Closeable if (cfg.isEnabled(SerializationConfig.Feature.CLOSE_CLOSEABLE) && (value instanceof Closeable)) { _configAndWriteCloseable(jgen, value, cfg); return; } boolean closed = false; try { _serializerProvider.serializeValue(cfg, jgen, value, _serializerFactory); 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 = copySerializationConfig().withView(viewClass); if (cfg.isEnabled(SerializationConfig.Feature.INDENT_OUTPUT)) { jgen.useDefaultPrettyPrinter(); } // [JACKSON-282]: consider Closeable if (cfg.isEnabled(SerializationConfig.Feature.CLOSE_CLOSEABLE) && (value instanceof Closeable)) { _configAndWriteCloseable(jgen, value, cfg); return; } boolean closed = false; try { _serializerProvider.serializeValue(cfg, jgen, value, _serializerFactory); closed = true; jgen.close(); } finally { if (!closed) { try { jgen.close(); } catch (IOException ioe) { } } } }