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 Dataformat XML Source Code
Jackson is "the Java JSON library" or "the best JSON parser for Java". Or simply as "JSON for Java".
Jackson also allows you to parse or generate XML messages with the Jackson Dataformat XML Extension.
Jackson Dataformat XML Source Code files are provided in the source packge (jackson-dataformat-xml-2.14.0-sources.jar). You can download it at Jackson Maven Website.
You can also browse Jackson Dataformat XML Source Code below:
✍: FYIcenter.com
⏎ com/fasterxml/jackson/dataformat/xml/util/XmlRootNameLookup.java
package com.fasterxml.jackson.dataformat.xml.util;
import javax.xml.namespace.QName;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.cfg.MapperConfig;
import com.fasterxml.jackson.databind.introspect.AnnotatedClass;
import com.fasterxml.jackson.databind.type.ClassKey;
import com.fasterxml.jackson.databind.util.LRUMap;
/**
* Helper class used for efficiently finding root element name used with
* XML serializations.
*/
public class XmlRootNameLookup
implements java.io.Serializable
{
private static final long serialVersionUID = 1L;
/**
* If all we get to serialize is a null, there's no way to figure out
* expected root name; so let's just default to literal {@code "null"}.
*/
public final static QName ROOT_NAME_FOR_NULL = new QName("null");
/**
* For efficient operation, let's try to minimize number of times we
* need to introspect root element name to use.
*<p>
* Note: changed to <code>transient</code> for 2.3; no point in serializing such
* state
*/
protected final transient LRUMap<ClassKey,QName> _rootNames;
public XmlRootNameLookup() {
_rootNames = new LRUMap<ClassKey,QName>(40, 200);
}
protected Object readResolve() {
// just need to make 100% sure it gets set to non-null, that's all
// 05-Jan-2020, tatu: How is that possibly, you ask? JDK serialization, that's how
// (it by-passes calls to constructors, as well as initializers)
// ... and if you don't believe, try commenting it out and see test failure you get
if (_rootNames == null) {
return new XmlRootNameLookup();
}
return this;
}
public QName findRootName(JavaType rootType, MapperConfig<?> config) {
return findRootName(rootType.getRawClass(), config);
}
public QName findRootName(Class<?> rootType, MapperConfig<?> config)
{
ClassKey key = new ClassKey(rootType);
QName name;
synchronized (_rootNames) {
name = _rootNames.get(key);
}
if (name != null) {
return name;
}
name = _findRootName(config, rootType);
synchronized (_rootNames) {
_rootNames.put(key, name);
}
return name;
}
protected QName _findRootName(MapperConfig<?> config, Class<?> rootType)
{
BeanDescription beanDesc = config.introspectClassAnnotations(rootType);
AnnotationIntrospector intr = config.getAnnotationIntrospector();
AnnotatedClass ac = beanDesc.getClassInfo();
String localName = null;
String ns = null;
PropertyName root = intr.findRootName(ac);
if (root != null) {
localName = root.getSimpleName();
ns = root.getNamespace();
}
// No answer so far? Let's just default to using simple class name
if (localName == null || localName.length() == 0) {
// Should we strip out enclosing class tho? For now, nope:
// one caveat: array simple names end with "[]"; also, "$" needs replacing
localName = StaxUtil.sanitizeXmlTypeName(rootType.getSimpleName());
return _qname(ns, localName);
}
// Otherwise let's see if there's namespace, too (if we are missing it)
if (ns == null || ns.isEmpty()) {
ns = _findNamespace(config, intr, ac);
}
return _qname(ns, localName);
}
private QName _qname(String ns, String localName) {
if (ns == null) { // some QName impls barf on nulls...
ns = "";
}
return new QName(ns, localName);
}
private String _findNamespace(MapperConfig<?> config, AnnotationIntrospector ai,
AnnotatedClass ann)
{
for (AnnotationIntrospector intr : ai.allIntrospectors()) {
if (intr instanceof AnnotationIntrospector.XmlExtensions) {
String ns = ((AnnotationIntrospector.XmlExtensions) intr).findNamespace(config, ann);
if (ns != null) {
return ns;
}
}
}
return null;
}
}
⏎ com/fasterxml/jackson/dataformat/xml/util/XmlRootNameLookup.java
Or download all of them as a single archive file:
File name: jackson-dataformat-xml-2.14.0-sources.jar File size: 98015 bytes Release date: 2022-11-05 Download
⇒ Download Jackson Dataformat Binary Packages
⇐ Jackson Dataformat Extensions
2021-10-10, ≈36🔥, 0💬
Popular Posts:
JEuclid Source Code Files are provided the JEuclid GitHub Website . You can browse JEuclid Source Co...
What Is poi-examples-5.2.3.jar? poi-examples-5.2.3.jar is one of the JAR files for Apache POI 5.2.3,...
Woodstox 6.4.0 Source Code Files are provided at the Woodstox GitHub Website . You can download them...
maven-core-3.5.4.jar is the JAR file for Apache Maven 3.5.4 Core module. Apache Maven is a software ...
JRE 8 deploy.jar is the JAR file for JRE 8 Java Control Panel and other deploy tools. JRE (Java Runt...