Skip to content
This repository has been archived by the owner on Jan 22, 2019. It is now read-only.

Commit

Permalink
Work on #27
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Mar 25, 2014
1 parent 436ade6 commit acf8695
Showing 1 changed file with 68 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import com.fasterxml.jackson.annotation.SimpleObjectIdResolver;

import com.fasterxml.jackson.core.*;

import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.cfg.MapperConfig;
import com.fasterxml.jackson.databind.introspect.*;
Expand All @@ -27,7 +25,6 @@
import com.fasterxml.jackson.databind.util.BeanUtil;
import com.fasterxml.jackson.databind.util.ClassUtil;
import com.fasterxml.jackson.databind.util.Converter;

import com.fasterxml.jackson.module.jaxb.deser.DataHandlerJsonDeserializer;
import com.fasterxml.jackson.module.jaxb.ser.DataHandlerJsonSerializer;

Expand Down Expand Up @@ -61,6 +58,13 @@
* <li>Any property annotated with {@link XmlValue} will have a property named 'value' on its JSON object.
* </li>
* </ul>
*
*
*<p>
* A note on compatibility with Jackson XML module: since this module does not depend
* on Jackson XML module, it is bit difficult to make sure we will properly expose
* all information. But effort is made (as of version 2.3.3) to expose this information,
* even without using a specific sub-class from that project.
*
* @author Ryan Heaton
* @author Tatu Saloranta
Expand Down Expand Up @@ -135,6 +139,67 @@ public Version version() {
return PackageVersion.VERSION;
}

/*
/**********************************************************
/* Extended API (XmlAnnotationIntrospector)
/**********************************************************
*/

// From XmlAnnotationIntrospector
// @Override
public String findNamespace(Annotated ann) {
String ns = null;
if (ann instanceof AnnotatedClass) {
// For classes, it must be @XmlRootElement. Also, we do
// want to use defaults from package, base class
XmlRootElement elem = findRootElementAnnotation((AnnotatedClass) ann);
if (elem != null) {
ns = elem.namespace();
}
} else {
// For others, XmlElement or XmlAttribute work (anything else?)
XmlElement elem = findAnnotation(XmlElement.class, ann, false, false, false);
if (elem != null) {
ns = elem.namespace();
}
if (ns == null || MARKER_FOR_DEFAULT.equals(ns)) {
XmlAttribute attr = findAnnotation(XmlAttribute.class, ann, false, false, false);
if (attr != null) {
ns = attr.namespace();
}
}
}
// JAXB uses marker for "not defined"
if (MARKER_FOR_DEFAULT.equals(ns)) {
ns = null;
}
return ns;
}

// From XmlAnnotationIntrospector
// @Override
public Boolean isOutputAsAttribute(Annotated ann) {
XmlAttribute attr = findAnnotation(XmlAttribute.class, ann, false, false, false);
if (attr != null) {
return Boolean.TRUE;
}
XmlElement elem = findAnnotation(XmlElement.class, ann, false, false, false);
if (elem != null) {
return Boolean.FALSE;
}
return null;
}

// From XmlAnnotationIntrospector
// @Override
public Boolean isOutputAsText(Annotated ann) {
XmlValue attr = findAnnotation(XmlValue.class, ann, false, false, false);
if (attr != null) {
return Boolean.TRUE;
}
return null;
}

/*
/**********************************************************
/* General annotations (for classes, properties)
Expand Down

0 comments on commit acf8695

Please sign in to comment.