package com.fasterxml.jackson.dataformat.xml.ser;
import java.io.IOException;
import java.util.Set;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.BeanPropertyWriter;
import com.fasterxml.jackson.databind.ser.BeanSerializer;
import com.fasterxml.jackson.databind.ser.impl.BeanAsArraySerializer;
import com.fasterxml.jackson.databind.ser.impl.ObjectIdWriter;
import com.fasterxml.jackson.databind.ser.std.BeanSerializerBase;
import com.fasterxml.jackson.databind.util.NameTransformer;
public class XmlBeanSerializer extends XmlBeanSerializerBase
{
private static final long serialVersionUID = 1L;
public XmlBeanSerializer(BeanSerializerBase src) {
super(src);
}
public XmlBeanSerializer(XmlBeanSerializerBase src, ObjectIdWriter objectIdWriter, Object filterId) {
super(src, objectIdWriter, filterId);
}
public XmlBeanSerializer(XmlBeanSerializerBase src, ObjectIdWriter objectIdWriter) {
super(src, objectIdWriter);
}
public XmlBeanSerializer(XmlBeanSerializerBase src, Set<String> toIgnore) {
super(src, toIgnore);
}
@Override
public JsonSerializer<Object> unwrappingSerializer(NameTransformer unwrapper) {
return new UnwrappingXmlBeanSerializer(this, unwrapper);
}
@Override
public BeanSerializerBase withObjectIdWriter(ObjectIdWriter objectIdWriter) {
return new XmlBeanSerializer(this, objectIdWriter, _propertyFilterId);
}
@Override
public BeanSerializerBase withFilterId(Object filterId) {
return new XmlBeanSerializer(this, _objectIdWriter, filterId);
}
@Override
protected BeanSerializerBase withIgnorals(Set<String> toIgnore) {
return new XmlBeanSerializer(this, toIgnore);
}
@Override
protected BeanSerializerBase asArraySerializer()
{
if ((_objectIdWriter == null)
&& (_anyGetterWriter == null)
&& (_propertyFilterId == null)
) {
return new BeanAsArraySerializer(this);
}
return this;
}
@Override
public void serialize(Object bean, JsonGenerator g, SerializerProvider provider) throws IOException
{
if (_objectIdWriter != null) {
_serializeWithObjectId(bean, g, provider, true);
return;
}
g.writeStartObject();
if (_propertyFilterId != null) {
serializeFieldsFiltered(bean, g, provider);
} else {
serializeFields(bean, g, provider);
}
g.writeEndObject();
}
@Override
public String toString() {
return "XmlBeanSerializer for " + handledType().getName();
}
}