Package org.jibx.runtime

Examples of org.jibx.runtime.IMarshallingContext


            throws JiBXException, IOException, JDOMException {

        // marshal XML
        final IBindingFactory bfact =
            BindingDirectory.getFactory(object.getClass());
        final IMarshallingContext mctx = bfact.createMarshallingContext();
        mctx.setIndent(4);
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        mctx.marshalDocument(object, "UTF-8", null, baos);
        baos.close();
        final String xmlContent = baos.toString();

        // validate XML
        SAX_BUILDER.build(new StringReader(xmlContent));
View Full Code Here


    // javadoc inherited
    public void write(ReportingConfig config, OutputStream stream) {
        try {
            IBindingFactory bfact = BindingDirectory
                .getFactory(ReportingConfig.class);
            IMarshallingContext mctx = bfact.createMarshallingContext();
            mctx.setIndent(4, null, ' ');
            mctx.marshalDocument(config, "UTF-8", null, stream);
        } catch (JiBXException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

     */
    public void writeProject(RuntimeProjectConfiguration configuration,
                             Writer writer)
            throws JiBXException {

        IMarshallingContext uctx = getMarshallingContext();

        uctx.marshalDocument(configuration, "UTF-8", null, writer);
    }
View Full Code Here

     */
    public void writeProject(RuntimeProjectConfiguration configuration,
                             OutputStream stream)
            throws JiBXException {

        IMarshallingContext uctx = getMarshallingContext();

        uctx.marshalDocument(configuration, "UTF-8", null, stream);
    }
View Full Code Here

    private IMarshallingContext getMarshallingContext()
            throws JiBXException {
        IBindingFactory bfact =
                BindingDirectory.getFactory(RuntimeProjectConfiguration.class);

        IMarshallingContext uctx = bfact.createMarshallingContext();
        return uctx;
    }
View Full Code Here

         */
        public void write(DatasourceConfiguration config, OutputStream stream) {
            try {
                IBindingFactory bfact = BindingDirectory
                    .getFactory(TestAnonymousMarshallerElement.class);
                IMarshallingContext mctx = bfact.createMarshallingContext();
                mctx.setIndent(4, null, ' ');
                mctx.marshalDocument(config, "UTF-8", null, stream);
            } catch (JiBXException e) {
                throw new RuntimeException(e);
            }
        }
View Full Code Here

         */
        public void write(DatasourceConfiguration config, OutputStream stream) {
            try {
                IBindingFactory bfact = BindingDirectory
                    .getFactory(TestDefaultMarshallerElement.class);
                IMarshallingContext mctx = bfact.createMarshallingContext();
                mctx.setIndent(4, null, ' ');
                mctx.marshalDocument(config, "UTF-8", null, stream);
            } catch (JiBXException e) {
                throw new RuntimeException(e);
            }
        }
View Full Code Here

    }
  }
 
  public void marshall(Object obj, OutputStream out, String encoding) {
    try {
      IMarshallingContext mctx = bindingFactory.createMarshallingContext();
      doConfigureIndentation(mctx);
      mctx.marshalDocument(obj, encoding, null, out);
    }
    catch(JiBXException ex) {
      throw new JibxAccessException(ex.getMessage(), ex);
    }
    finally {
View Full Code Here

    OutputStreamWriter out = null;
    try {
      ByteArrayOutputStream bout = new ByteArrayOutputStream(5000);
      out = new OutputStreamWriter(bout, options.getEncoding());
      IBindingFactory bf = BindingDirectory.getFactory(JibxBinding.class);
      IMarshallingContext mctx = bf.createMarshallingContext();
      mctx.setIndent(1, null, '\t');
      mctx.marshalDocument(root, options.getEncoding(), null, out);
      return bout.toByteArray();

    } finally {
      if(out!=null) try { out.close(); } catch(Exception ex) {}
    }
View Full Code Here

    // javadoc inherited
    public void write(SendRequest sendRequest, OutputStream out) {
        try {
            IBindingFactory factory = BindingDirectory.getFactory(DefaultSendRequest.class);
            IMarshallingContext context = factory.createMarshallingContext();

            // @todo any indentation, etc?
            context.marshalDocument(sendRequest, "UTF-8", null, out);
        } catch (JiBXException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

TOP

Related Classes of org.jibx.runtime.IMarshallingContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.