Package org.jibx.runtime

Examples of org.jibx.runtime.IMarshallingContext


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

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


                throw new RuntimeException(e);
            }
        } else {
            try {
                IBindingFactory factory = BindingDirectory.getFactory(obj.getClass());
                IMarshallingContext ctx = getMarshallingContext(obj);
                StAXWriter writer = new StAXWriter(factory.getNamespaces(), output);
                ctx.setXmlWriter(writer);
                ((IMarshallable)obj).marshal(ctx);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
View Full Code Here

    @Override
    public void write(Writer writer) throws IOException {
        try {
            IBindingFactory jibxBFact = JibxRepresentation.getBindingFactory(
                    this.bindingName, this.bindingClass);
            IMarshallingContext mctx = jibxBFact.createMarshallingContext();
            mctx.setOutput(writer);
            ((IMarshallable) getObject()).marshal(mctx);
        } catch (JiBXException e) {
            throw new IOException(e.getMessage());
        }
    }
View Full Code Here

     */
    public void serialize(OutputStream output, OMOutputFormat format) throws XMLStreamException {
        try {
           
            // marshal with all namespace declarations, since external state unknown
            IMarshallingContext ctx = bindingFactory.createMarshallingContext();
            ctx.setOutput(output, format == null ? null : format.getCharSetEncoding());
            marshal(true, ctx);
           
        } catch (JiBXException e) {
            throw new XMLStreamException("Error in JiBX marshalling: " + e.getMessage(), e);
        }
View Full Code Here

     */
    public void serialize(Writer writer, OMOutputFormat format) throws XMLStreamException {
        try {
           
            // marshal with all namespace declarations, since external state unknown
            IMarshallingContext ctx = bindingFactory.createMarshallingContext();
            ctx.setOutput(writer);
            marshal(true, ctx);
           
        } catch (JiBXException e) {
            throw new XMLStreamException("Error in JiBX marshalling: " + e.getMessage(), e);
        }
View Full Code Here

                }
            }
           
            // marshal with all namespace declarations, since external state unknown
            IXMLWriter writer = new StAXWriter(nss, xmlWriter);
            IMarshallingContext ctx = bindingFactory.createMarshallingContext();
            ctx.setXmlWriter(writer);
            marshal(full, ctx);
           
        } catch (JiBXException e) {
            throw new XMLStreamException("Error in JiBX marshalling: " + e.getMessage(), e);
        }
View Full Code Here

  @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);
    }
View Full Code Here

  }

  @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);
    }
View Full Code Here

   * Create a new <code>IMarshallingContext</code>, configured with the correct indentation.
   * @return the created marshalling context
   * @throws JiBXException in case of errors
   */
  protected IMarshallingContext createMarshallingContext() throws JiBXException {
    IMarshallingContext marshallingContext = this.bindingFactory.createMarshallingContext();
    marshallingContext.setIndent(this.indent);
    return marshallingContext;
  }
View Full Code Here

                throw new RuntimeException(e);
            }
        } else {
            try {
                IBindingFactory factory = BindingDirectory.getFactory(obj.getClass());
                IMarshallingContext ctx = getMarshallingContext(obj);
                StAXWriter writer = new StAXWriter(factory.getNamespaces(), output);
                ctx.setXmlWriter(writer);
                ((IMarshallable)obj).marshal(ctx);
            } catch (Exception 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.