public < TYPE > void write ( @ NotNull final TYPE obj , @ NotNull final Writer writer , @ NotNull final JAXBContext jaxbContext ) throws MarshalObjectException { Contract . requireArgNotNull ( "obj" , obj ) ; Contract . requireArgNotNull ( "writer" , writer ) ; Contract . requireArgNotNull ( "jaxbContext" , jaxbContext ) ; try { final Marshaller marshaller = jaxbContext . createMarshaller ( ) ; marshaller . setProperty ( Marshaller . JAXB_FORMATTED_OUTPUT , formattedOutput ) ; marshaller . marshal ( obj , writer ) ; } catch ( final JAXBException ex ) { throw new MarshalObjectException ( "Unable to write XML to writer" , ex ) ; } }
Marshals the object as XML to a writer .