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/jsontype/impl/MinimalClassNameIdResolver.java
package com.fasterxml.jackson.databind.jsontype.impl;
import java.io.IOException;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.DatabindContext;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.cfg.MapperConfig;
import com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator;
import com.fasterxml.jackson.databind.type.TypeFactory;
public class MinimalClassNameIdResolver
extends ClassNameIdResolver
{
/**
* Package name of the base class, to be used for determining common
* prefix that can be omitted from included type id.
* Does not include the trailing dot.
*/
protected final String _basePackageName;
/**
* Same as {@link #_basePackageName}, but includes trailing dot.
*/
protected final String _basePackagePrefix;
protected MinimalClassNameIdResolver(JavaType baseType, TypeFactory typeFactory,
PolymorphicTypeValidator ptv)
{
super(baseType, typeFactory, ptv);
String base = baseType.getRawClass().getName();
int ix = base.lastIndexOf('.');
if (ix < 0) { // can this ever occur?
_basePackageName = "";
_basePackagePrefix = ".";
} else {
_basePackagePrefix = base.substring(0, ix+1);
_basePackageName = base.substring(0, ix);
}
}
public static MinimalClassNameIdResolver construct(JavaType baseType, MapperConfig<?> config,
PolymorphicTypeValidator ptv) {
return new MinimalClassNameIdResolver(baseType, config.getTypeFactory(), ptv);
}
@Override
public JsonTypeInfo.Id getMechanism() { return JsonTypeInfo.Id.MINIMAL_CLASS; }
@Override
public String idFromValue(Object value)
{
String n = value.getClass().getName();
if (n.startsWith(_basePackagePrefix)) {
// note: we will leave the leading dot in there
return n.substring(_basePackagePrefix.length()-1);
}
return n;
}
@Override
protected JavaType _typeFromId(String id, DatabindContext ctxt) throws IOException
{
if (id.startsWith(".")) {
StringBuilder sb = new StringBuilder(id.length() + _basePackageName.length());
if (_basePackageName.isEmpty()) {
// no package; must remove leading '.' from id
sb.append(id.substring(1));
} else {
// otherwise just concatenate package, with leading-dot-partial name
sb.append(_basePackageName).append(id);
}
id = sb.toString();
}
return super._typeFromId(id, ctxt);
}
}
⏎ com/fasterxml/jackson/databind/jsontype/impl/MinimalClassNameIdResolver.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, ≈190🔥, 0💬
Popular Posts:
commons-collections4-4.4 -sources.jaris the source JAR file for Apache Commons Collections 4.2, whic...
pache Derby is an open source relational database implemented entirely in Java and available under t...
iText is an ideal library for developers looking to enhance web- and other applications with dynamic...
JDK 11 jdk.jdi.jmod is the JMOD file for JDK 11 JDI (Java Debug Interface) tool. JDK 11 JDI tool com...
Apache ZooKeeper is an open-source server which enables highly reliable distributed coordination. Ap...