Search in sources :

Example 1 with XmlWrapperSerializer

use of com.abubusoft.kripton.persistence.XmlWrapperSerializer in project kripton by xcesco.

the class AbstractMapper method serialize.

public void serialize(BinderContext context, E object, SerializerWrapper serializerWrapper, boolean writeStartAndEnd) throws Exception {
    switch(context.getSupportedFormat()) {
        case XML:
            try {
                XmlWrapperSerializer wrapper = ((XmlWrapperSerializer) serializerWrapper);
                XMLSerializer xmlSerializer = wrapper.xmlSerializer;
                if (writeStartAndEnd) {
                    xmlSerializer.writeStartDocument();
                }
                serializeOnXml(object, xmlSerializer, 0);
                if (writeStartAndEnd) {
                    xmlSerializer.writeEndDocument();
                }
            } catch (Exception e) {
                e.printStackTrace();
                throw (new KriptonRuntimeException(e));
            }
            break;
        default:
            if (context.getSupportedFormat().onlyText)
                serializeOnJacksonAsString(object, ((JacksonWrapperSerializer) serializerWrapper).jacksonGenerator);
            else
                serializeOnJackson(object, ((JacksonWrapperSerializer) serializerWrapper).jacksonGenerator);
            break;
    }
}
Also used : XMLSerializer(com.abubusoft.kripton.xml.XMLSerializer) KriptonRuntimeException(com.abubusoft.kripton.exception.KriptonRuntimeException) JacksonWrapperSerializer(com.abubusoft.kripton.persistence.JacksonWrapperSerializer) IOException(java.io.IOException) KriptonRuntimeException(com.abubusoft.kripton.exception.KriptonRuntimeException) XmlWrapperSerializer(com.abubusoft.kripton.persistence.XmlWrapperSerializer)

Aggregations

KriptonRuntimeException (com.abubusoft.kripton.exception.KriptonRuntimeException)1 JacksonWrapperSerializer (com.abubusoft.kripton.persistence.JacksonWrapperSerializer)1 XmlWrapperSerializer (com.abubusoft.kripton.persistence.XmlWrapperSerializer)1 XMLSerializer (com.abubusoft.kripton.xml.XMLSerializer)1 IOException (java.io.IOException)1