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/ser/XmlBeanSerializerModifier.java
package com.fasterxml.jackson.dataformat.xml.ser;
import java.util.*;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.introspect.AnnotatedMember;
import com.fasterxml.jackson.databind.ser.*;
import com.fasterxml.jackson.databind.ser.std.BeanSerializerBase;
import com.fasterxml.jackson.dataformat.xml.util.AnnotationUtil;
import com.fasterxml.jackson.dataformat.xml.util.TypeUtil;
import com.fasterxml.jackson.dataformat.xml.util.XmlInfo;
/**
* We need a {@link BeanSerializerModifier} to replace default <code>BeanSerializer</code>
* with XML-specific one; mostly to ensure that attribute properties are output
* before element properties.
*/
public class XmlBeanSerializerModifier
extends BeanSerializerModifier
implements java.io.Serializable
{
private static final long serialVersionUID = 1L;
public XmlBeanSerializerModifier() { }
/*
/**********************************************************
/* Overridden methods
/**********************************************************
*/
/**
* First thing to do is to find annotations regarding XML serialization,
* and wrap collection serializers.
*/
@Override
public List<BeanPropertyWriter> changeProperties(SerializationConfig config,
BeanDescription beanDesc, List<BeanPropertyWriter> beanProperties)
{
final AnnotationIntrospector intr = config.getAnnotationIntrospector();
for (int i = 0, len = beanProperties.size(); i < len; ++i) {
BeanPropertyWriter bpw = beanProperties.get(i);
final AnnotatedMember member = bpw.getMember();
String ns = AnnotationUtil.findNamespaceAnnotation(config, intr, member);
Boolean isAttribute = AnnotationUtil.findIsAttributeAnnotation(config, intr, member);
Boolean isText = AnnotationUtil.findIsTextAnnotation(config, intr, member);
Boolean isCData = AnnotationUtil.findIsCDataAnnotation(config, intr, member);
bpw.setInternalSetting(XmlBeanSerializerBase.KEY_XML_INFO,
new XmlInfo(isAttribute, ns, isText, isCData));
// Actually: if we have a Collection type, easiest place to add wrapping would be here...
// or: let's also allow wrapping of "untyped" (Object): assuming it is a dynamically
// typed Collection...
if (!TypeUtil.isIndexedType(bpw.getType())) {
continue;
}
PropertyName wrappedName = PropertyName.construct(bpw.getName(), ns);
PropertyName wrapperName = bpw.getWrapperName();
// first things first: no wrapping?
if (wrapperName == null || wrapperName == PropertyName.NO_NAME) {
continue;
}
// no local name? Just double the wrapped name for wrapper
String localName = wrapperName.getSimpleName();
if (localName == null || localName.length() == 0) {
wrapperName = wrappedName;
}
beanProperties.set(i, new XmlBeanPropertyWriter(bpw, wrapperName, wrappedName));
}
return beanProperties;
}
@Override
public JsonSerializer<?> modifySerializer(SerializationConfig config,
BeanDescription beanDesc, JsonSerializer<?> serializer)
{
/* First things first: we can only handle real BeanSerializers; question
* is, what to do if it's not one: throw exception or bail out?
* For now let's do latter.
*/
if (!(serializer instanceof BeanSerializerBase)) {
return serializer;
}
return new XmlBeanSerializer((BeanSerializerBase) serializer);
}
}
⏎ com/fasterxml/jackson/dataformat/xml/ser/XmlBeanSerializerModifier.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, ≈21🔥, 0💬
Popular Posts:
How to display XML element type information with the jaxp\TypeInfoWriter.java provided in the Apache...
Woodstox 6.4.0 Source Code Files are provided at the Woodstox GitHub Website . You can download them...
HttpComponents Core Source Code Files are provided in the source package file, httpcomponents-core-5...
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 11 java.base.jmod is the JMOD file for JDK 11 Base module. JDK 11 Base module compiled class fil...