protected 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 ; } }
Serialize an object using the contxt and the serializerWrapper .