Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package org.codehaus.jackson.map;
import java.io.IOException;
import java.util.Date;
import org.codehaus.jackson.*;
import org.codehaus.jackson.map.ser.FilterProvider;
import org.codehaus.jackson.map.type.TypeFactory;
import org.codehaus.jackson.schema.JsonSchema;
import org.codehaus.jackson.type.JavaType;
/**
* Abstract class that defines API used by {@link ObjectMapper} and
* {@link JsonSerializer}s to obtain serializers capable of serializing
* instances of specific types.
*
* Note about usage: for {@link JsonSerializer} instances, only accessors
* for locating other (sub-)serializers are to be used. {@link ObjectMapper},
* on the other hand, is to initialize recursive serialization process by
* calling {@link #serializeValue}.
*/
public abstract class SerializerProvider
{
protected final static JavaType TYPE_OBJECT = TypeFactory.type(Object.class);
/**
* Serialization configuration to use for serialization processing.
*/
protected final SerializationConfig _config;
/**
* View used for currently active serialization
*/
protected final Class> _serializationView;
protected SerializerProvider(SerializationConfig config)
{
_config = config;
_serializationView = (config == null) ? null : _config.getSerializationView();
}
/*
/**********************************************************
/* Methods that ObjectMapper will call
/**********************************************************
*/
/**
* The method to be called by {@link ObjectMapper} to
* execute recursive serialization, using serializers that
* this provider has access to.
*
* @param jsf Underlying factory object used for creating serializers
* as needed
*/
public abstract void serializeValue(SerializationConfig cfg, JsonGenerator jgen,
Object value, SerializerFactory jsf)
throws IOException, JsonGenerationException;
/**
* The method to be called by {@link ObjectMapper} to
* execute recursive serialization, using serializers that
* this provider has access to; and using specified root type
* for locating first-level serializer.
*
* @param rootType Type to use for locating serializer to use, instead of actual
* runtime type. Must be actual type, or one of its super types
*
* @since 1.5
*/
public abstract void serializeValue(SerializationConfig cfg, JsonGenerator jgen,
Object value, JavaType rootType, SerializerFactory jsf)
throws IOException, JsonGenerationException;
/**
* Generate Json-schema for
* given type.
*
* @param type The type for which to generate schema
*/
public abstract JsonSchema generateJsonSchema(Class> type, SerializationConfig config, SerializerFactory jsf)
throws JsonMappingException;
/**
* Method that can be called to see if this serializer provider
* can find a serializer for an instance of given class.
*
* Note that no Exceptions are thrown, including unchecked ones:
* implementations are to swallow exceptions if necessary.
*/
public abstract boolean hasSerializerFor(SerializationConfig cfg,
Class> cls, SerializerFactory jsf);
/*
/**********************************************************
/* Access to configuration
/**********************************************************
*/
/**
* Method for accessing configuration for the serialization processing.
*/
public final SerializationConfig getConfig() { return _config; }
/**
* Convenience method for checking whether specified serialization
* feature is enabled or not.
* Shortcut for:
*
* getConfig().isEnabled(feature);
*
*/
public final boolean isEnabled(SerializationConfig.Feature feature) {
return _config.isEnabled(feature);
}
/**
* Convenience method for accessing serialization view in use (if any); equivalent to:
*
* getConfig().getSerializationView();
*
*
* @since 1.4
*/
public final Class> getSerializationView() { return _serializationView; }
/**
* Convenience method for accessing provider to find serialization filters used,
* equivalent to calling:
*
* getConfig().getFilterProvider();
*
*
* @since 1.4
*/
public final FilterProvider getFilterProvider() {
return _config.getFilterProvider();
}
/*
/**********************************************************
/* General serializer locating functionality
/**********************************************************
*/
/**
* Method called to get hold of a serializer for a value of given type;
* or if no such serializer can be found, a default handler (which
* may do a best-effort generic serialization or just simply
* throw an exception when invoked).
*
* Note: this method is only called for non-null values; not for keys
* or null values. For these, check out other accessor methods.
*
* Note that starting with version 1.5, serializers should also be type-aware
* if they handle polymorphic types. That means that it may be necessary
* to also use a {@link TypeSerializer} based on declared (static) type
* being serializer (whereas actual data may be serialized using dynamic
* type)
*
* @throws JsonMappingException if there are fatal problems with
* accessing suitable serializer; including that of not
* finding any serializer
*/
public abstract JsonSerializer