/** * Method for checking whether instances of given type can be serialized, * and optionally why (as per {@link Throwable} returned). * * @since 2.3 */ public boolean canSerialize(Class<?> type, AtomicReference<Throwable> cause) { return _serializerProvider().hasSerializerFor(type, cause); }
public boolean canSerialize(Class<?> type) { return _serializerProvider().hasSerializerFor(type, null); }
/** * Method for visiting type hierarchy for given type, using specified visitor. * Visitation uses <code>Serializer</code> hierarchy and related properties *<p> * This method can be used for things like * generating <a href="http://json-schema.org/">Json Schema</a> * instance for specified type. * * @param type Type to generate schema for (possibly with generic signature) * * @since 2.2 */ public void acceptJsonFormatVisitor(JavaType type, JsonFormatVisitorWrapper visitor) throws JsonMappingException { if (type == null) { throw new IllegalArgumentException("type must be provided"); } _serializerProvider().acceptJsonFormatVisitor(type, visitor); }
/** * Helper method used when value to serialize is {@link Closeable} and its <code>close()</code> * method is to be called right after serialization has been called */ private final void _writeCloseable(JsonGenerator gen, Object value) throws IOException { Closeable toClose = (Closeable) value; try { _prefetch.serialize(gen, value, _serializerProvider()); Closeable tmpToClose = toClose; toClose = null; tmpToClose.close(); } catch (Exception e) { ClassUtil.closeOnFailAndThrowAsIOE(gen, toClose, e); return; } gen.close(); }
/** * Method that can be used to serialize any Java value as * JSON output, using provided {@link JsonGenerator}. */ public void writeValue(JsonGenerator gen, Object value) throws IOException { _configureGenerator(gen); if (_config.isEnabled(SerializationFeature.CLOSE_CLOSEABLE) && (value instanceof Closeable)) { Closeable toClose = (Closeable) value; try { _prefetch.serialize(gen, value, _serializerProvider()); if (_config.isEnabled(SerializationFeature.FLUSH_AFTER_WRITE_VALUE)) { gen.flush(); } } catch (Exception e) { ClassUtil.closeOnFailAndThrowAsIOE(null, toClose, e); return; } toClose.close(); } else { _prefetch.serialize(gen, value, _serializerProvider()); if (_config.isEnabled(SerializationFeature.FLUSH_AFTER_WRITE_VALUE)) { gen.flush(); } } }
/** * Overridable factory method called by {@link #writeValues(OutputStream)} * method (and its various overrides), and initializes it as necessary. * * @since 2.5 */ @SuppressWarnings("resource") protected SequenceWriter _newSequenceWriter(boolean wrapInArray, JsonGenerator gen, boolean managedInput) throws IOException { _configureGenerator(gen); return new SequenceWriter(_serializerProvider(), gen, managedInput, _prefetch) .init(wrapInArray); }
/** * Method called to configure the generator as necessary and then * call write functionality */ protected final void _configAndWriteValue(JsonGenerator gen, Object value) throws IOException { _configureGenerator(gen); if (_config.isEnabled(SerializationFeature.CLOSE_CLOSEABLE) && (value instanceof Closeable)) { _writeCloseable(gen, value); return; } try { _prefetch.serialize(gen, value, _serializerProvider()); } catch (Exception e) { ClassUtil.closeOnFailAndThrowAsIOE(gen, e); return; } gen.close(); }
DefaultSerializerProvider prov = parent._serializerProvider();
/** * Method for checking whether instances of given type can be serialized, * and optionally why (as per {@link Throwable} returned). * * @since 2.3 */ public boolean canSerialize(Class<?> type, AtomicReference<Throwable> cause) { return _serializerProvider().hasSerializerFor(type, cause); }
/** * Method for checking whether instances of given type can be serialized, * and optionally why (as per {@link Throwable} returned). * * @since 2.3 */ public boolean canSerialize(Class<?> type, AtomicReference<Throwable> cause) { return _serializerProvider().hasSerializerFor(type, cause); }
/** * Method for checking whether instances of given type can be serialized, * and optionally why (as per {@link Throwable} returned). * * @since 2.3 */ public boolean canSerialize(Class<?> type, AtomicReference<Throwable> cause) { return _serializerProvider(_config).hasSerializerFor(type, cause); }
/** * Method for checking whether instances of given type can be serialized, * and optionally why (as per {@link Throwable} returned). * * @since 2.3 */ public boolean canSerialize(Class<?> type, AtomicReference<Throwable> cause) { return _serializerProvider(_config).hasSerializerFor(type, cause); }
public boolean canSerialize(Class<?> type) { return _serializerProvider(_config).hasSerializerFor(type, null); }
public boolean canSerialize(Class<?> type) { return _serializerProvider().hasSerializerFor(type, null); }
public boolean canSerialize(Class<?> type) { return _serializerProvider(_config).hasSerializerFor(type); }
public boolean canSerialize(Class<?> type) { return _serializerProvider(_config).hasSerializerFor(type, null); }
public boolean canSerialize(Class<?> type) { return _serializerProvider().hasSerializerFor(type, null); }
public boolean canSerialize(Class<?> type) { return _serializerProvider(_config).hasSerializerFor(type); }
/** * Overridable factory method called by {@link #writeValues(OutputStream)} * method (and its various overrides), and initializes it as necessary. * * @since 2.5 */ @SuppressWarnings("resource") protected SequenceWriter _newSequenceWriter(boolean wrapInArray, JsonGenerator gen, boolean managedInput) throws IOException { _configureGenerator(gen); return new SequenceWriter(_serializerProvider(), gen, managedInput, _prefetch) .init(wrapInArray); }
/** * Overridable factory method called by {@link #createSequenceWriter(JsonGenerator)} * method (and its various overrides), and initializes it as necessary. * * @since 2.5 */ @SuppressWarnings("resource") protected SequenceWriter _newSequenceWriter(boolean wrapInArray, JsonGenerator gen, boolean managedInput) throws IOException { return new SequenceWriter(_serializerProvider(_config), _configureGenerator(gen), managedInput, _prefetch) .init(wrapInArray); }