Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
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 (309)
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/ser/XmlBeanPropertyWriter.java
package com.fasterxml.jackson.dataformat.xml.ser; import javax.xml.namespace.QName; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.ser.*; import com.fasterxml.jackson.databind.ser.impl.PropertySerializerMap; /** * Property writer sub-class used for handling element wrapping needed for serializing * collection (array, Collection; possibly Map) types. */ public class XmlBeanPropertyWriter extends BeanPropertyWriter { private static final long serialVersionUID = 1L; /* /********************************************************** /* Config settings /********************************************************** */ /** * Element name used as wrapper for collection. */ protected final QName _wrapperQName; /** * Element name used for items in the collection */ protected final QName _wrappedQName; /* /********************************************************** /* Life-cycle: construction, configuration /********************************************************** */ public XmlBeanPropertyWriter(BeanPropertyWriter wrapped, PropertyName wrapperName, PropertyName wrappedName) { this(wrapped, wrapperName, wrappedName, null); } public XmlBeanPropertyWriter(BeanPropertyWriter wrapped, PropertyName wrapperName, PropertyName wrappedName, JsonSerializer<Object> serializer) { super(wrapped); _wrapperQName = _qname(wrapperName); _wrappedQName = _qname(wrappedName); if (serializer != null) { assignSerializer(serializer); } } private QName _qname(PropertyName n) { String ns = n.getNamespace(); if (ns == null) { ns = ""; } return new QName(ns, n.getSimpleName()); } /* /********************************************************** /* Overridden methods /********************************************************** */ /** * Overridden version so that we can wrap output within wrapper element if * and as necessary. */ @Override public void serializeAsField(Object bean, JsonGenerator jgen, SerializerProvider prov) throws Exception { Object value = get(bean); /* 13-Feb-2014, tatu: As per [#103], default handling does not really * work here. Rather, we need just a wrapping and should NOT call * null handler, as it does not know what to do... * * Question, however, is what should it be serialized as. We have two main * choices; equivalent empty List, and "nothing" (missing). Let's start with * empty List? But producing missing entry is non-trivial... */ if (value == null) { // if (_nullSerializer != null) { ... } // For Empty List, we'd do this: /* @SuppressWarnings("resource") final ToXmlGenerator xmlGen = (jgen instanceof ToXmlGenerator) ? (ToXmlGenerator) jgen : null; if (xmlGen != null) { xmlGen.startWrappedValue(_wrapperQName, _wrappedQName); xmlGen.finishWrappedValue(_wrapperQName, _wrappedQName); } */ // but for missing thing, well, just output nothing return; } // then find serializer to use JsonSerializer<Object> ser = _serializer; if (ser == null) { Class<?> cls = value.getClass(); PropertySerializerMap map = _dynamicSerializers; ser = map.serializerFor(cls); if (ser == null) { ser = _findAndAddDynamic(map, cls, prov); } } // and then see if we must suppress certain values (default, empty) if (_suppressableValue != null) { if (MARKER_FOR_EMPTY == _suppressableValue) { if (ser.isEmpty(prov, value)) { return; } } else if (_suppressableValue.equals(value)) { return; } } // For non-nulls: simple check for direct cycles if (value == bean) { // NOTE: method signature here change 2.3->2.4 if (_handleSelfReference(bean, jgen, prov, ser)) { return; } } final ToXmlGenerator xmlGen = (jgen instanceof ToXmlGenerator) ? (ToXmlGenerator) jgen : null; // Ok then; addition we want to do is to add wrapper element, and that's what happens here // 19-Aug-2013, tatu: ... except for those nasty 'convertValue()' calls... if (xmlGen != null) { xmlGen.startWrappedValue(_wrapperQName, _wrappedQName); } jgen.writeFieldName(_name); if (_typeSerializer == null) { ser.serialize(value, jgen, prov); } else { ser.serializeWithType(value, jgen, prov, _typeSerializer); } if (xmlGen != null) { xmlGen.finishWrappedValue(_wrapperQName, _wrappedQName); } } }
⏎ com/fasterxml/jackson/dataformat/xml/ser/XmlBeanPropertyWriter.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, 13139👍, 0💬
Popular Posts:
What Is ojdbc8.jar for Oracle 12c R2? ojdbc8.jar for Oracle 12c R2 is the JAR files of ojdbc.jar, JD...
What Is log4j-1.2.15.jar? I got the JAR file from apache-log4j-1.2.15.zip. log4j-1.2.15.jar is the v...
Saxon-HE (home edition) is an open source product available under the Mozilla Public License. It pro...
JDK 11 jdk.crypto.cryptoki.jmod is the JMOD file for JDK 11 Crypto Cryptoki module. JDK 11 Crypto KI...
What Is poi-ooxml-3.5.jar? poi-ooxml-3.5.jar is one of the JAR files for Apache POI 3.5, which provi...