|
26 | 26 | import com.fasterxml.jackson.databind.util.BeanUtil;
|
27 | 27 | import com.fasterxml.jackson.databind.util.ClassUtil;
|
28 | 28 | import com.fasterxml.jackson.databind.util.Converter;
|
29 |
| - |
30 | 29 | import com.fasterxml.jackson.module.jaxb.deser.DataHandlerJsonDeserializer;
|
31 | 30 | import com.fasterxml.jackson.module.jaxb.ser.DataHandlerJsonSerializer;
|
32 | 31 |
|
|
60 | 59 | * <li>Any property annotated with {@link XmlValue} will have a property named 'value' on its JSON object.
|
61 | 60 | * </li>
|
62 | 61 | * </ul>
|
| 62 | + * |
| 63 | + * |
| 64 | + *<p> |
| 65 | + * A note on compatibility with Jackson XML module: since this module does not depend |
| 66 | + * on Jackson XML module, it is bit difficult to make sure we will properly expose |
| 67 | + * all information. But effort is made (as of version 2.3.3) to expose this information, |
| 68 | + * even without using a specific sub-class from that project. |
63 | 69 | *
|
64 | 70 | * @author Ryan Heaton
|
65 | 71 | * @author Tatu Saloranta
|
@@ -134,6 +140,67 @@ public Version version() {
|
134 | 140 | return PackageVersion.VERSION;
|
135 | 141 | }
|
136 | 142 |
|
| 143 | + /* |
| 144 | + /********************************************************** |
| 145 | + /* Extended API (XmlAnnotationIntrospector) |
| 146 | + /********************************************************** |
| 147 | + */ |
| 148 | + |
| 149 | + // From XmlAnnotationIntrospector |
| 150 | + // @Override |
| 151 | + public String findNamespace(Annotated ann) { |
| 152 | + String ns = null; |
| 153 | + if (ann instanceof AnnotatedClass) { |
| 154 | + // For classes, it must be @XmlRootElement. Also, we do |
| 155 | + // want to use defaults from package, base class |
| 156 | + XmlRootElement elem = findRootElementAnnotation((AnnotatedClass) ann); |
| 157 | + if (elem != null) { |
| 158 | + ns = elem.namespace(); |
| 159 | + } |
| 160 | + } else { |
| 161 | + // For others, XmlElement or XmlAttribute work (anything else?) |
| 162 | + XmlElement elem = findAnnotation(XmlElement.class, ann, false, false, false); |
| 163 | + if (elem != null) { |
| 164 | + ns = elem.namespace(); |
| 165 | + } |
| 166 | + if (ns == null || MARKER_FOR_DEFAULT.equals(ns)) { |
| 167 | + XmlAttribute attr = findAnnotation(XmlAttribute.class, ann, false, false, false); |
| 168 | + if (attr != null) { |
| 169 | + ns = attr.namespace(); |
| 170 | + } |
| 171 | + } |
| 172 | + } |
| 173 | + // JAXB uses marker for "not defined" |
| 174 | + if (MARKER_FOR_DEFAULT.equals(ns)) { |
| 175 | + ns = null; |
| 176 | + } |
| 177 | + return ns; |
| 178 | + } |
| 179 | + |
| 180 | + // From XmlAnnotationIntrospector |
| 181 | + // @Override |
| 182 | + public Boolean isOutputAsAttribute(Annotated ann) { |
| 183 | + XmlAttribute attr = findAnnotation(XmlAttribute.class, ann, false, false, false); |
| 184 | + if (attr != null) { |
| 185 | + return Boolean.TRUE; |
| 186 | + } |
| 187 | + XmlElement elem = findAnnotation(XmlElement.class, ann, false, false, false); |
| 188 | + if (elem != null) { |
| 189 | + return Boolean.FALSE; |
| 190 | + } |
| 191 | + return null; |
| 192 | + } |
| 193 | + |
| 194 | + // From XmlAnnotationIntrospector |
| 195 | + // @Override |
| 196 | + public Boolean isOutputAsText(Annotated ann) { |
| 197 | + XmlValue attr = findAnnotation(XmlValue.class, ann, false, false, false); |
| 198 | + if (attr != null) { |
| 199 | + return Boolean.TRUE; |
| 200 | + } |
| 201 | + return null; |
| 202 | + } |
| 203 | + |
137 | 204 | /*
|
138 | 205 | /**********************************************************
|
139 | 206 | /* General annotations (for classes, properties)
|
|
0 commit comments