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/deser/XmlBeanDeserializerModifier.java
package com.fasterxml.jackson.dataformat.xml.deser; import java.util.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.deser.*; import com.fasterxml.jackson.databind.introspect.AnnotatedMember; import com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition; import com.fasterxml.jackson.dataformat.xml.util.AnnotationUtil; /** * The main reason for a modifier is to support handling of * 'wrapped' Collection types. */ public class XmlBeanDeserializerModifier extends BeanDeserializerModifier implements java.io.Serializable { private static final long serialVersionUID = 1L; /** * Virtual name used for text segments. */ protected String _cfgNameForTextValue = ""; public XmlBeanDeserializerModifier(String nameForTextValue) { _cfgNameForTextValue = nameForTextValue; } @Override public List<BeanPropertyDefinition> updateProperties(DeserializationConfig config, BeanDescription beanDesc, List<BeanPropertyDefinition> propDefs) { final AnnotationIntrospector intr = config.getAnnotationIntrospector(); int changed = 0; for (int i = 0, propCount = propDefs.size(); i < propCount; ++i) { BeanPropertyDefinition prop = propDefs.get(i); AnnotatedMember acc = prop.getPrimaryMember(); // should not be null, but just in case: if (acc == null) { continue; } /* First: handle "as text"? Such properties * are exposed as values of 'unnamed' fields; so one way to * map them is to rename property to have name ""... (and * hope this does not break other parts...) */ Boolean b = AnnotationUtil.findIsTextAnnotation(config, intr, acc); if (b != null && b.booleanValue()) { // unwrapped properties will appear as 'unnamed' (empty String) BeanPropertyDefinition newProp = prop.withSimpleName(_cfgNameForTextValue); if (newProp != prop) { propDefs.set(i, newProp); } continue; } // second: do we need to handle wrapping (for Lists)? PropertyName wrapperName = prop.getWrapperName(); if (wrapperName != null && wrapperName != PropertyName.NO_NAME) { String localName = wrapperName.getSimpleName(); if ((localName != null && localName.length() > 0) && !localName.equals(prop.getName())) { // make copy-on-write as necessary if (changed == 0) { propDefs = new ArrayList<BeanPropertyDefinition>(propDefs); } ++changed; propDefs.set(i, prop.withSimpleName(localName)); continue; } // otherwise unwrapped; needs handling but later on } } return propDefs; } @Override public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config, BeanDescription beanDesc, JsonDeserializer<?> deser0) { if (!(deser0 instanceof BeanDeserializerBase)) { return deser0; } /* 17-Aug-2013, tatu: One important special case first: if we have one "XML Text" * property, it may be exposed as VALUE_STRING token (depending on whether any attribute * values are exposed): and to deserialize from that, we need special handling unless POJO * has appropriate single-string creator method. */ BeanDeserializerBase deser = (BeanDeserializerBase) deser0; // Heuristics are bit tricky; but for now let's assume that if POJO // can already work with VALUE_STRING, it's ok and doesn't need extra support ValueInstantiator inst = deser.getValueInstantiator(); // 03-Aug-2017, tatu: [dataformat-xml#254] suggests we also should // allow passing `int`/`Integer`/`long`/`Long` cases, BUT // unfortunately we can not simply use default handling. Would need // coercion. // 30-Apr-2020, tatu: Complication from [dataformat-xml#318] as we now // have a delegate too... if (!inst.canCreateFromString()) { SettableBeanProperty textProp = _findSoleTextProp(config, deser.properties()); if (textProp != null) { return new XmlTextDeserializer(deser, textProp); } } return new WrapperHandlingDeserializer(deser); } private SettableBeanProperty _findSoleTextProp(DeserializationConfig config, Iterator<SettableBeanProperty> propIt) { final AnnotationIntrospector ai = config.getAnnotationIntrospector(); SettableBeanProperty textProp = null; while (propIt.hasNext()) { SettableBeanProperty prop = propIt.next(); AnnotatedMember m = prop.getMember(); if (m != null) { // Ok, let's use a simple check: we should have renamed it earlier so: PropertyName n = prop.getFullName(); if (_cfgNameForTextValue.equals(n.getSimpleName())) { // should we verify we only got one? textProp = prop; continue; } // as-attribute are ok as well Boolean b = AnnotationUtil.findIsAttributeAnnotation(config, ai, m); if (b != null && b.booleanValue()) { continue; } } // Otherwise, it's something else; no go return null; } return textProp; } }
⏎ com/fasterxml/jackson/dataformat/xml/deser/XmlBeanDeserializerModifier.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, 13155👍, 0💬
Popular Posts:
MP3SPI is a Java Service Provider Interface that adds MP3 (MPEG 1/2/2.5 Layer 1/2/3) audio format su...
What Is ojdbc14.jar for Oracle 10g R2? ojdbc14.jar for Oracle 10g R2 is the JAR files of ojdbc.jar, ...
The JDT project provides the tool plug-ins that implement a Java IDE supporting the development of a...
JDK 11 jdk.jlink.jmod is the JMOD file for JDK 11 JLink tool, which can be invoked by the "jlink" co...
How to show the XML parsing flow with sax\DocumentTracer.java provided in the Apache Xerces package?...