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 com.fitbur.fasterxml.jackson.databind.ser;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.InetAddress;
import java.util.*;
import com.fitbur.fasterxml.jackson.annotation.JsonFormat;
import com.fitbur.fasterxml.jackson.databind.*;
import com.fitbur.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fitbur.fasterxml.jackson.databind.annotation.NoClass;
import com.fitbur.fasterxml.jackson.databind.cfg.SerializerFactoryConfig;
import com.fitbur.fasterxml.jackson.databind.ext.OptionalHandlerFactory;
import com.fitbur.fasterxml.jackson.databind.introspect.*;
import com.fitbur.fasterxml.jackson.databind.jsontype.NamedType;
import com.fitbur.fasterxml.jackson.databind.jsontype.TypeResolverBuilder;
import com.fitbur.fasterxml.jackson.databind.jsontype.TypeSerializer;
import com.fitbur.fasterxml.jackson.databind.ser.impl.IndexedStringListSerializer;
import com.fitbur.fasterxml.jackson.databind.ser.impl.StringArraySerializer;
import com.fitbur.fasterxml.jackson.databind.ser.impl.StringCollectionSerializer;
import com.fitbur.fasterxml.jackson.databind.ser.std.*;
import com.fitbur.fasterxml.jackson.databind.type.*;
import com.fitbur.fasterxml.jackson.databind.util.ClassUtil;
import com.fitbur.fasterxml.jackson.databind.util.EnumValues;
import com.fitbur.fasterxml.jackson.databind.util.TokenBuffer;
/**
* Factory class that can provide serializers for standard JDK classes,
* as well as custom classes that extend standard classes or implement
* one of "well-known" interfaces (such as {@link java.util.Collection}).
*
* Since all the serializers are eagerly instantiated, and there is
* no additional introspection or customizability of these types,
* this factory is essentially stateless.
*/
public abstract class BasicSerializerFactory
extends SerializerFactory
implements java.io.Serializable
{
private static final long serialVersionUID = -1416617628045738132L;
/*
/**********************************************************
/* Configuration, lookup tables/maps
/**********************************************************
*/
/**
* Since these are all JDK classes, we shouldn't have to worry
* about ClassLoader used to load them. Rather, we can just
* use the class name, and keep things simple and efficient.
*/
protected final static HashMap> _concrete =
new HashMap>();
/**
* Actually it may not make much sense to eagerly instantiate all
* kinds of serializers: so this Map actually contains class references,
* not instances
*/
protected final static HashMap>> _concreteLazy =
new HashMap>>();
static {
/* String and string-like types (note: date types explicitly
* not included -- can use either textual or numeric serialization)
*/
_concrete.put(String.class.getName(), new StringSerializer());
final ToStringSerializer sls = ToStringSerializer.instance;
_concrete.put(StringBuffer.class.getName(), sls);
_concrete.put(StringBuilder.class.getName(), sls);
_concrete.put(Character.class.getName(), sls);
_concrete.put(Character.TYPE.getName(), sls);
// Primitives/wrappers for primitives (primitives needed for Beans)
NumberSerializers.addAll(_concrete);
_concrete.put(Boolean.TYPE.getName(), new BooleanSerializer(true));
_concrete.put(Boolean.class.getName(), new BooleanSerializer(false));
// Other numbers, more com.fitburplicated
final JsonSerializer> ns = new NumberSerializers.NumberSerializer();
_concrete.put(BigInteger.class.getName(), ns);
_concrete.put(BigDecimal.class.getName(), ns);
// Other discrete non-container types:
// First, Date/Time zoo:
_concrete.put(Calendar.class.getName(), CalendarSerializer.instance);
DateSerializer dateSer = DateSerializer.instance;
_concrete.put(java.util.Date.class.getName(), dateSer);
// note: timestamps are very similar to java.util.Date, thus serialized as such
_concrete.put(java.sql.Timestamp.class.getName(), dateSer);
_concrete.put(java.sql.Date.class.getName(), new SqlDateSerializer());
_concrete.put(java.sql.Time.class.getName(), new SqlTimeSerializer());
// And then other standard non-structured JDK types
for (Map.Entry,Object> en : new StdJdkSerializers().provide()) {
Object value = en.getValue();
if (value instanceof JsonSerializer>) {
_concrete.put(en.getKey().getName(), (JsonSerializer>) value);
} else if (value instanceof Class>) {
@SuppressWarnings("unchecked")
Class extends JsonSerializer>> cls = (Class extends JsonSerializer>>) value;
_concreteLazy.put(en.getKey().getName(), cls);
} else { // should never happen, but:
throw new IllegalStateException("Internal error: unrecognized value of type "+en.getClass().getName());
}
}
// Jackson-specific type(s)
// (Q: can this ever be sub-classed?)
_concreteLazy.put(TokenBuffer.class.getName(), TokenBufferSerializer.class);
}
/*
/**********************************************************
/* Configuration
/**********************************************************
*/
/**
* Configuration settings for this factory; immutable instance (just like this
* factory), new version created via copy-constructor (fluent-style)
*/
protected final SerializerFactoryConfig _factoryConfig;
/**
* Helper object used to com.fitbural with serializers for optional JDK types (like ones
* omitted from GAE, Android)
*/
protected OptionalHandlerFactory optionalHandlers = OptionalHandlerFactory.instance;
/*
/**********************************************************
/* Life cycle
/**********************************************************
*/
/**
* We will provide com.fitburfault constructor to allow sub-classing,
* but make it protected so that no non-singleton instances of
* the class will be instantiated.
*/
protected BasicSerializerFactory(SerializerFactoryConfig config) {
_factoryConfig = (config == null) ? new SerializerFactoryConfig() : config;
}
/**
* Method for getting current {@link SerializerFactoryConfig}.
*
* Note that since instances are immutable, you can NOT change settings
* by accessing an instance and calling methods: this will simply create
* new instance of config object.
*/
public SerializerFactoryConfig getFactoryConfig() {
return _factoryConfig;
}
/**
* Method used for creating a new instance of this factory, but with different
* configuration. Reason for specifying factory method (instead of plain constructor)
* is to allow proper sub-classing of factories.
*
* Note that custom sub-classes generally must override implementation
* of this method, as it usually requires instantiating a new instance of
* factory type. Check out javadocs for
* {@link com.fitbur.fasterxml.jackson.databind.ser.BeanSerializerFactory} for more com.fitburtails.
*/
public abstract SerializerFactory withConfig(SerializerFactoryConfig config);
/**
* Convenience method for creating a new factory instance with an additional
* serializer provider.
*/
@Override
public final SerializerFactory withAdditionalSerializers(Serializers additional) {
return withConfig(_factoryConfig.withAdditionalSerializers(additional));
}
/**
* Convenience method for creating a new factory instance with an additional
* key serializer provider.
*/
@Override
public final SerializerFactory withAdditionalKeySerializers(Serializers additional) {
return withConfig(_factoryConfig.withAdditionalKeySerializers(additional));
}
/**
* Convenience method for creating a new factory instance with additional bean
* serializer modifier.
*/
@Override
public final SerializerFactory withSerializerModifier(BeanSerializerModifier modifier) {
return withConfig(_factoryConfig.withSerializerModifier(modifier));
}
/*
/**********************************************************
/* SerializerFactory impl
/**********************************************************
*/
// Implemented by sub-classes
@Override
public abstract JsonSerializer