Top Description Fields Constructors Methods
tools.jackson.dataformat.xml.ser

public abstract Class XmlBeanSerializerBase

extends BeanSerializerBase
Class Inheritance
Known Direct Subclasses
tools.jackson.dataformat.xml.ser.UnwrappingXmlBeanSerializer, tools.jackson.dataformat.xml.ser.XmlBeanSerializer
Imports
java.util.BitSet, .Set, javax.xml.namespace.QName, com.fasterxml.jackson.annotation.JsonTypeInfo, tools.jackson.core.*, tools.jackson.databind.DatabindException, .SerializationContext, tools.jackson.databind.jsontype.TypeSerializer, tools.jackson.databind.ser.BeanPropertyWriter, .PropertyFilter, .WritableObjectId, tools.jackson.databind.ser.bean.BeanSerializerBase, tools.jackson.databind.ser.impl.ObjectIdWriter, tools.jackson.databind.util.NameTransformer, tools.jackson.dataformat.xml.util.XmlInfo

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

Field Summary

Modifier and TypeField and Description
protected final int
_attributeCount

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

protected final BitSet
_cdata

Optional set of indexes of properties that should be serialized as CDATA, instead of regular XML text segment.

protected final int
_textPropertyIndex

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

protected final QName[]
_xmlNames

Array that contains namespace URIs associated with properties, if any; null if no namespace definitions have been assigned

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.

Inherited from tools.jackson.databind.ser.bean.BeanSerializerBase:
_beanType_filteredProps_objectIdWriter_propertyFilterId_props_serializationShape_typeIdNAME_FOR_OBJECT_REFNO_PROPS

Constructor Summary

AccessConstructor and Description
public
protected
protected
protected
public
protected

Method Summary

Modifier and TypeMethod and Description
protected static boolean
protected static boolean
protected static int
_orderAttributesFirst(BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties)

Method for re-sorting lists of bean properties such that attributes are strictly written before elements.

protected void
protected void
_serializeProperties(Object bean, JsonGenerator gen0, SerializationContext ctxt)

Overrides tools.jackson.databind.ser.bean.BeanSerializerBase._serializeProperties.

Main serialization method needs to be overridden to allow XML-specific extra handling, such as indication of whether to write attributes or elements.

protected void
_serializePropertiesFiltered(Object bean, JsonGenerator gen0, SerializationContext ctxt, Object filterId)

Overrides tools.jackson.databind.ser.bean.BeanSerializerBase._serializePropertiesFiltered.

Alternative serialization method that gets called when there is a PropertyFilter that needs to be called to determine which properties are to be serialized (and possibly how)

public void
serializeWithType(Object bean, JsonGenerator gen, SerializationContext ctxt, TypeSerializer typeSer)

Overrides tools.jackson.databind.ser.bean.BeanSerializerBase.serializeWithType.

Method that can be called to ask implementation to serialize values of type this serializer handles, using specified type serializer for embedding necessary type information.

Inherited from tools.jackson.databind.ser.bean.BeanSerializerBase:
_serializePropertiesMaybeView_serializePropertiesNoView_serializeWithObjectId_serializeWithObjectId_typeIdDefacceptJsonFormatVisitorasArraySerializercanCreateArraySerializercreateContextualfindConvertingSerializergetFilterIdhasViewPropertiespropertiespropertyCountresolveserializetoStringunwrappingSerializerusesObjectIdwithByNameInclusionwithFilterIdwithObjectIdWriterwithProperties

Field Detail

_attributeCountback to summary
protected final int _attributeCount

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

_cdataback to summary
protected final BitSet _cdata

Optional set of indexes of properties that should be serialized as CDATA, instead of regular XML text segment. Left as null in cases where none of element values are to be written in such a way.

_textPropertyIndexback to summary
protected final int _textPropertyIndex

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

_xmlNamesback to summary
protected final QName[] _xmlNames

Array that contains namespace URIs associated with properties, if any; null if no namespace definitions have been assigned

KEY_XML_INFOback to summary
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.

Constructor Detail

XmlBeanSerializerBaseback to summary
public XmlBeanSerializerBase(BeanSerializerBase src)
XmlBeanSerializerBaseback to summary
protected XmlBeanSerializerBase(XmlBeanSerializerBase src, ObjectIdWriter objectIdWriter)
XmlBeanSerializerBaseback to summary
protected XmlBeanSerializerBase(XmlBeanSerializerBase src, ObjectIdWriter objectIdWriter, Object filterId)
XmlBeanSerializerBaseback to summary
protected XmlBeanSerializerBase(XmlBeanSerializerBase src, Set<String> toIgnore, Set<String> toInclude)
XmlBeanSerializerBaseback to summary
public XmlBeanSerializerBase(XmlBeanSerializerBase src, NameTransformer transformer)
XmlBeanSerializerBaseback to summary
protected XmlBeanSerializerBase(XmlBeanSerializerBase src, BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties)

Method Detail

_isAttributeback to summary
protected static boolean _isAttribute(BeanPropertyWriter bpw)
_isCDataback to summary
protected static boolean _isCData(BeanPropertyWriter bpw)
_orderAttributesFirstback to summary
protected static int _orderAttributesFirst(BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties)

Method for re-sorting lists of bean properties such that attributes are strictly written before elements.

_serializeObjectIdback to summary
protected void _serializeObjectId(Object bean, JsonGenerator gen, SerializationContext ctxt, TypeSerializer typeSer, WritableObjectId objectId) throws JacksonException

Overrides tools.jackson.databind.ser.bean.BeanSerializerBase._serializeObjectId.

Annotations
@Override
_serializePropertiesback to summary
protected void _serializeProperties(Object bean, JsonGenerator gen0, SerializationContext ctxt) throws JacksonException

Overrides tools.jackson.databind.ser.bean.BeanSerializerBase._serializeProperties.

Main serialization method needs to be overridden to allow XML-specific extra handling, such as indication of whether to write attributes or elements.

Annotations
@Override
_serializePropertiesFilteredback to summary
protected void _serializePropertiesFiltered(Object bean, JsonGenerator gen0, SerializationContext ctxt, Object filterId) throws JacksonException

Overrides tools.jackson.databind.ser.bean.BeanSerializerBase._serializePropertiesFiltered.

Doc from tools.jackson.databind.ser.bean.BeanSerializerBase._serializePropertiesFiltered.

Alternative serialization method that gets called when there is a PropertyFilter that needs to be called to determine which properties are to be serialized (and possibly how)

Annotations
@Override
serializeWithTypeback to summary
public void serializeWithType(Object bean, JsonGenerator gen, SerializationContext ctxt, TypeSerializer typeSer) throws JacksonException

Overrides tools.jackson.databind.ser.bean.BeanSerializerBase.serializeWithType.

Doc from tools.jackson.databind.ValueSerializer.serializeWithType.

Method that can be called to ask implementation to serialize values of type this serializer handles, using specified type serializer for embedding necessary type information.

Default implementation will throw UnsupportedOperationException to indicate that proper type handling needs to be implemented.

For simple datatypes written as a single scalar value (JSON String, Number, Boolean), implementation would look like:

  // note: method to call depends on whether this type is serialized as JSON scalar, object or Array!
  typeSer.writeTypePrefixForScalar(value, gen);
  serialize(value, gen, provider);
  typeSer.writeTypeSuffixForScalar(value, gen);
and implementations for type serialized as JSON Arrays or Objects would differ slightly, as START-ARRAY/END-ARRAY and START-OBJECT/END-OBJECT pairs need to be properly handled with respect to serializing of contents.
Annotations
@Override