use of org.jibx.runtime.IMarshallingContext in project kernel by exoplatform.
the class XMLObject method toByteArray.
public byte[] toByteArray(String encoding) throws Exception {
IBindingFactory bfact = getBindingFactoryInPriviledgedMode(XMLObject.class);
IMarshallingContext mctx = bfact.createMarshallingContext();
mctx.setIndent(2);
ByteArrayOutputStream os = new ByteArrayOutputStream();
mctx.marshalDocument(this, encoding, null, os);
return os.toByteArray();
}
use of org.jibx.runtime.IMarshallingContext in project RESTdoclet by IG-Group.
the class JiBXUtils method marshallServices.
/**
* Static method for marshalling services (list).
*
* @param services the services to be marshalled.
* @param file the file the services have to be marshalled to.
* @throws JiBXException if JiBX fails.
* @throws IOException if an input- or output-exception occurs.
*/
public static void marshallServices(final Services services, final File file) throws JiBXException, IOException {
final Writer writer = new FileWriter(file);
final IBindingFactory factory = BindingDirectory.getFactory(Services.class);
final IMarshallingContext context = factory.createMarshallingContext();
context.setIndent(INDENT);
context.setOutput(writer);
context.marshalDocument(services, ENCODING, null);
}
use of org.jibx.runtime.IMarshallingContext in project spring-framework by spring-projects.
the class JibxMarshaller method marshalOutputStream.
// Supported marshalling
@Override
protected void marshalOutputStream(Object graph, OutputStream outputStream) throws XmlMappingException, IOException {
try {
IMarshallingContext marshallingContext = createMarshallingContext();
marshallingContext.startDocument(this.encoding, this.standalone, outputStream);
marshalDocument(marshallingContext, graph);
} catch (JiBXException ex) {
throw convertJibxException(ex, true);
}
}
use of org.jibx.runtime.IMarshallingContext in project spring-framework by spring-projects.
the class JibxMarshaller method marshalWriter.
@Override
protected void marshalWriter(Object graph, Writer writer) throws XmlMappingException, IOException {
try {
IMarshallingContext marshallingContext = createMarshallingContext();
marshallingContext.startDocument(this.encoding, this.standalone, writer);
marshalDocument(marshallingContext, graph);
} catch (JiBXException ex) {
throw convertJibxException(ex, true);
}
}
use of org.jibx.runtime.IMarshallingContext in project kernel by exoplatform.
the class Configuration method toXML.
/**
* Dumps the configuration in XML format into the given {@link Writer}
*/
public void toXML(Writer w) {
try {
CURRENT_CONFIG_TO_SERIALIZE.set(this);
IBindingFactory bfact = BindingDirectory.getFactory(Configuration.class);
IMarshallingContext mctx = bfact.createMarshallingContext();
mctx.setIndent(2);
mctx.marshalDocument(this, "UTF-8", null, w);
} catch (Exception e) {
LOG.warn("Couldn't dump the runtime configuration in XML Format", e);
} finally {
CURRENT_CONFIG_TO_SERIALIZE.remove();
}
}
Aggregations