com.fasterxml.jackson.dataformat.xml.ser
Class XmlBeanSerializer

java.lang.Object
  extended by com.fasterxml.jackson.databind.JsonSerializer<T>
      extended by com.fasterxml.jackson.databind.ser.std.StdSerializer<Object>
          extended by com.fasterxml.jackson.databind.ser.std.BeanSerializerBase
              extended by com.fasterxml.jackson.databind.ser.BeanSerializer
                  extended by com.fasterxml.jackson.dataformat.xml.ser.XmlBeanSerializer
All Implemented Interfaces:
com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitable, com.fasterxml.jackson.databind.jsonschema.SchemaAware, com.fasterxml.jackson.databind.ser.ContextualSerializer, com.fasterxml.jackson.databind.ser.ResolvableSerializer

public class XmlBeanSerializer
extends com.fasterxml.jackson.databind.ser.BeanSerializer

Specific sub-class of BeanSerializer needed to take care of some xml-specific aspects, such as distinction between attributes and elements.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.JsonSerializer
com.fasterxml.jackson.databind.JsonSerializer.None
 
Field Summary
protected  int _attributeCount
          Number of attributes to write; these will have been ordered to be the first properties to write.
protected  int _textPropertyIndex
          Index of "text value" property we have, if any; can have at most one such property.
protected  QName[] _xmlNames
          Array that contains namespace URIs associated with properties, if any; null if no namespace definitions have been assigned
static String KEY_XML_INFO
          Marker used for storing associated internal data with BeanPropertyWriter instances; to mark instances that are to be written out as attributes.
 
Fields inherited from class com.fasterxml.jackson.databind.ser.std.BeanSerializerBase
_anyGetterWriter, _filteredProps, _objectIdWriter, _propertyFilterId, _props, _serializationShape, _typeId, NO_PROPS
 
Fields inherited from class com.fasterxml.jackson.databind.ser.std.StdSerializer
_handledType
 
Constructor Summary
  XmlBeanSerializer(com.fasterxml.jackson.databind.ser.std.BeanSerializerBase src)
           
protected XmlBeanSerializer(XmlBeanSerializer src, com.fasterxml.jackson.databind.ser.impl.ObjectIdWriter objectIdWriter)
           
 
Method Summary
protected static boolean _isAttribute(com.fasterxml.jackson.databind.ser.BeanPropertyWriter bpw)
           
protected static int _orderAttributesFirst(com.fasterxml.jackson.databind.ser.BeanPropertyWriter[] properties, com.fasterxml.jackson.databind.ser.BeanPropertyWriter[] filteredProperties)
          Method for re-sorting lists of bean properties such that attributes are strictly written before elements.
protected  void serializeFields(Object bean, com.fasterxml.jackson.core.JsonGenerator jgen0, com.fasterxml.jackson.databind.SerializerProvider provider)
          Main serialization method needs to be overridden to allow XML-specific extra handling, such as indication of whether to write attributes or elements.
 void serializeWithType(Object bean, com.fasterxml.jackson.core.JsonGenerator jgen, com.fasterxml.jackson.databind.SerializerProvider provider, com.fasterxml.jackson.databind.jsontype.TypeSerializer typeSer)
           
 com.fasterxml.jackson.databind.JsonSerializer<Object> unwrappingSerializer(com.fasterxml.jackson.databind.util.NameTransformer unwrapper)
           
 com.fasterxml.jackson.databind.ser.BeanSerializer withObjectIdWriter(com.fasterxml.jackson.databind.ser.impl.ObjectIdWriter objectIdWriter)
           
 
Methods inherited from class com.fasterxml.jackson.databind.ser.BeanSerializer
asArraySerializer, createDummy, serialize, toString, withIgnorals
 
Methods inherited from class com.fasterxml.jackson.databind.ser.std.BeanSerializerBase
acceptJsonFormatVisitor, createContextual, findFilter, getSchema, resolve, serializeFieldsFiltered, usesObjectId
 
Methods inherited from class com.fasterxml.jackson.databind.ser.std.StdSerializer
createObjectNode, createSchemaNode, createSchemaNode, getSchema, handledType, isDefaultSerializer, wrapAndThrow, wrapAndThrow
 
Methods inherited from class com.fasterxml.jackson.databind.JsonSerializer
getDelegatee, isEmpty, isUnwrappingSerializer, replaceDelegatee
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.fasterxml.jackson.databind.jsonschema.SchemaAware
getSchema
 

Field Detail

KEY_XML_INFO

public static final String KEY_XML_INFO
Marker used for storing associated internal data with BeanPropertyWriter instances; to mark instances that are to be written out as attributes. Created as separate non-interned String to ensure there are no collisions.


_attributeCount

protected final int _attributeCount
Number of attributes to write; these will have been ordered to be the first properties to write.


_textPropertyIndex

protected final int _textPropertyIndex
Index of "text value" property we have, if any; can have at most one such property.


_xmlNames

protected final QName[] _xmlNames
Array that contains namespace URIs associated with properties, if any; null if no namespace definitions have been assigned

Constructor Detail

XmlBeanSerializer

public XmlBeanSerializer(com.fasterxml.jackson.databind.ser.std.BeanSerializerBase src)

XmlBeanSerializer

protected XmlBeanSerializer(XmlBeanSerializer src,
                            com.fasterxml.jackson.databind.ser.impl.ObjectIdWriter objectIdWriter)
Method Detail

unwrappingSerializer

public com.fasterxml.jackson.databind.JsonSerializer<Object> unwrappingSerializer(com.fasterxml.jackson.databind.util.NameTransformer unwrapper)
Overrides:
unwrappingSerializer in class com.fasterxml.jackson.databind.ser.BeanSerializer

withObjectIdWriter

public com.fasterxml.jackson.databind.ser.BeanSerializer withObjectIdWriter(com.fasterxml.jackson.databind.ser.impl.ObjectIdWriter objectIdWriter)
Overrides:
withObjectIdWriter in class com.fasterxml.jackson.databind.ser.BeanSerializer

serializeFields

protected void serializeFields(Object bean,
                               com.fasterxml.jackson.core.JsonGenerator jgen0,
                               com.fasterxml.jackson.databind.SerializerProvider provider)
                        throws IOException,
                               com.fasterxml.jackson.core.JsonGenerationException
Main serialization method needs to be overridden to allow XML-specific extra handling, such as indication of whether to write attributes or elements.

Overrides:
serializeFields in class com.fasterxml.jackson.databind.ser.std.BeanSerializerBase
Throws:
IOException
com.fasterxml.jackson.core.JsonGenerationException

serializeWithType

public void serializeWithType(Object bean,
                              com.fasterxml.jackson.core.JsonGenerator jgen,
                              com.fasterxml.jackson.databind.SerializerProvider provider,
                              com.fasterxml.jackson.databind.jsontype.TypeSerializer typeSer)
                       throws IOException,
                              com.fasterxml.jackson.core.JsonGenerationException
Overrides:
serializeWithType in class com.fasterxml.jackson.databind.ser.std.BeanSerializerBase
Throws:
IOException
com.fasterxml.jackson.core.JsonGenerationException

_isAttribute

protected static boolean _isAttribute(com.fasterxml.jackson.databind.ser.BeanPropertyWriter bpw)

_orderAttributesFirst

protected static int _orderAttributesFirst(com.fasterxml.jackson.databind.ser.BeanPropertyWriter[] properties,
                                           com.fasterxml.jackson.databind.ser.BeanPropertyWriter[] filteredProperties)
Method for re-sorting lists of bean properties such that attributes are strictly written before elements.



Copyright © 2012 FasterXML. All Rights Reserved.