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/ext/DOMDeserializer.java
package com.fasterxml.jackson.databind.ext;
import java.io.StringReader;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.deser.std.FromStringDeserializer;
/**
* Base for serializers that allows parsing DOM Documents from JSON Strings.
* Nominal type can be either {@link org.w3c.dom.Node} or
* {@link org.w3c.dom.Document}.
*/
public abstract class DOMDeserializer<T> extends FromStringDeserializer<T>
{
private static final long serialVersionUID = 1L;
private final static DocumentBuilderFactory DEFAULT_PARSER_FACTORY;
static {
DocumentBuilderFactory parserFactory = DocumentBuilderFactory.newInstance();
// yup, only cave men do XML without recognizing namespaces...
parserFactory.setNamespaceAware(true);
// [databind#1279]: make sure external entities NOT expanded by default
parserFactory.setExpandEntityReferences(false);
// ... and in general, aim for "safety"
try {
parserFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
} catch(ParserConfigurationException pce) {
// not much point to do anything; could log but...
} catch (Error e) {
// 14-Jul-2016, tatu: Not sure how or why, but during code coverage runs
// (via Cobertura) we get `java.lang.AbstractMethodError` so... ignore that too
}
// [databind#2589] add two more settings just in case
try {
parserFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
} catch (Throwable t) { } // as per previous one, nothing much to do
try {
parserFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
} catch (Throwable t) { } // as per previous one, nothing much to do
DEFAULT_PARSER_FACTORY = parserFactory;
}
protected DOMDeserializer(Class<T> cls) { super(cls); }
@Override
public abstract T _deserialize(String value, DeserializationContext ctxt);
protected final Document parse(String value) throws IllegalArgumentException {
try {
return documentBuilder().parse(new InputSource(new StringReader(value)));
} catch (Exception e) {
throw new IllegalArgumentException("Failed to parse JSON String as XML: "+e.getMessage(), e);
}
}
/**
* Overridable factory method used to create {@link DocumentBuilder} for parsing
* XML as DOM.
*
* @since 2.7.6
*/
protected DocumentBuilder documentBuilder() throws ParserConfigurationException {
return DEFAULT_PARSER_FACTORY.newDocumentBuilder();
}
/*
/**********************************************************
/* Concrete deserializers
/**********************************************************
*/
public static class NodeDeserializer extends DOMDeserializer<Node> {
private static final long serialVersionUID = 1L;
public NodeDeserializer() { super(Node.class); }
@Override
public Node _deserialize(String value, DeserializationContext ctxt) throws IllegalArgumentException {
return parse(value);
}
}
public static class DocumentDeserializer extends DOMDeserializer<Document> {
private static final long serialVersionUID = 1L;
public DocumentDeserializer() { super(Document.class); }
@Override
public Document _deserialize(String value, DeserializationContext ctxt) throws IllegalArgumentException {
return parse(value);
}
}
}
⏎ com/fasterxml/jackson/databind/ext/DOMDeserializer.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, ≈203🔥, 0💬
Popular Posts:
How to read XML document with DTD validation from socket connections with the socket\DelayedInput.ja.. .
Apache Avalon began in 1999 as the Java Apache Server Framework and in late 2002 separated from the ...
ANTLR is a powerful parser generator for multiple programming languages including Java. ANTLR contai...
This package is the backport of java.util.concurrent API, introduced in Java 5.0 and further refined...
JDK 11 java.compiler.jmod is the JMOD file for JDK 11 Compiler module. JDK 11 Compiler module compil...