Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
Jackson Data Binding Source Code
Jackson is "the Java JSON library" or "the best JSON parser for Java". Or simply as "JSON for Java".
Jackson Databind Source Code files are provided in the source packge (jackson-databind-2.14.0-sources.jar). You can download it at Jackson Maven Website.
You can also browse Jackson Databind Source Code below:
✍: FYIcenter.com
⏎ com/fasterxml/jackson/databind/ser/std/StaticListSerializerBase.java
package com.fasterxml.jackson.databind.ser.std;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.*;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.introspect.AnnotatedMember;
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonArrayFormatVisitor;
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import com.fasterxml.jackson.databind.ser.ContextualSerializer;
/**
* Intermediate base class for Lists, Collections and Arrays
* that contain static (non-dynamic) value types.
*/
@SuppressWarnings("serial")
public abstract class StaticListSerializerBase<T extends Collection<?>>
extends StdSerializer<T>
implements ContextualSerializer
{
/**
* Setting for specific local override for "unwrap single element arrays":
* true for enable unwrapping, false for preventing it, `null` for using
* global configuration.
*
* @since 2.6
*/
protected final Boolean _unwrapSingle;
protected StaticListSerializerBase(Class<?> cls) {
super(cls, false);
_unwrapSingle = null;
}
/**
* @since 2.9
*/
protected StaticListSerializerBase(StaticListSerializerBase<?> src,
Boolean unwrapSingle) {
super(src);
_unwrapSingle = unwrapSingle;
}
/**
* @since 2.9
*/
public abstract JsonSerializer<?> _withResolved(BeanProperty prop,
Boolean unwrapSingle);
/*
/**********************************************************
/* Post-processing
/**********************************************************
*/
@SuppressWarnings("unchecked")
@Override
public JsonSerializer<?> createContextual(SerializerProvider serializers,
BeanProperty property)
throws JsonMappingException
{
JsonSerializer<?> ser = null;
Boolean unwrapSingle = null;
if (property != null) {
final AnnotationIntrospector intr = serializers.getAnnotationIntrospector();
AnnotatedMember m = property.getMember();
if (m != null) {
Object serDef = intr.findContentSerializer(m);
if (serDef != null) {
ser = serializers.serializerInstance(m, serDef);
}
}
}
JsonFormat.Value format = findFormatOverrides(serializers, property, handledType());
if (format != null) {
unwrapSingle = format.getFeature(JsonFormat.Feature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED);
}
// [databind#124]: May have a content converter
ser = findContextualConvertingSerializer(serializers, property, ser);
if (ser == null) {
ser = serializers.findContentValueSerializer(String.class, property);
}
// Optimization: default serializer just writes String, so we can avoid a call:
if (isDefaultSerializer(ser)) {
if (Objects.equals(unwrapSingle, _unwrapSingle)) {
return this;
}
return _withResolved(property, unwrapSingle);
}
// otherwise...
// note: will never have TypeSerializer, because Strings are "natural" type
return new CollectionSerializer(serializers.constructType(String.class),
true, /*TypeSerializer*/ null, (JsonSerializer<Object>) ser);
}
@Override
public boolean isEmpty(SerializerProvider provider, T value) {
return (value == null) || (value.isEmpty());
}
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint) {
return createSchemaNode("array", true).set("items", contentSchema());
}
@Override
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException {
JsonArrayFormatVisitor v2 = visitor.expectArrayFormat(typeHint);
if (v2 != null) {
acceptContentVisitor(v2);
}
}
/*
/**********************************************************
/* Abstract methods for sub-classes to implement
/**********************************************************
*/
protected abstract JsonNode contentSchema();
protected abstract void acceptContentVisitor(JsonArrayFormatVisitor visitor)
throws JsonMappingException;
// just to make sure it gets implemented:
@Override
public abstract void serializeWithType(T value, JsonGenerator g,
SerializerProvider provider, TypeSerializer typeSer) throws IOException;
}
⏎ com/fasterxml/jackson/databind/ser/std/StaticListSerializerBase.java
Or download all of them as a single archive file:
File name: jackson-databind-2.14.0-sources.jar File size: 1187952 bytes Release date: 2022-11-05 Download
⇒ Jackson Annotations Source Code
⇐ Download and Install Jackson Binary Package
2022-03-29, ≈297🔥, 0💬
Popular Posts:
What Is jaxb-api-2.1.6.jar? Java Architecture for XML Binding (JAXB) is a Java API that allows Java ...
JDK 17 jdk.jdeps.jmod is the JMOD file for JDK 17 JDeps tool, which can be invoked by the "jdeps" co...
What Is poi-5.2.3.jar? poi-5.2.3.jar is one of the JAR files for Apache POI 5.2.3, which provides an...
JDK 17 jdk.crypto.cryptoki.jmod is the JMOD file for JDK 17 Crypto Cryptoki module. JDK 17 Crypto KI...
Apache Log4j IOStreams is a Log4j API extension that provides numerous classes from java.io that can...