Examples of IMarshallingContext


Examples of org.jibx.runtime.IMarshallingContext

     * @return output schema text
     * @throws Exception
     */
    protected String writeSchema(SchemaElement schema) throws Exception {
        StringWriter writer = new StringWriter();
        IMarshallingContext ictx = m_bindingFactory.createMarshallingContext();
        ictx.setOutput(writer);
        ictx.setIndent(2);
        ictx.marshalDocument(schema);
        return writer.toString();
    }
View Full Code Here

Examples of org.jibx.runtime.IMarshallingContext

                total += item.getPrice() * item.getQuantity();
            }
            order.setTotal(new Float(total));
           
      // marshal object back out to file (with nice indentation, as UTF-8)
      IMarshallingContext mctx = bfact.createMarshallingContext();
      mctx.setIndent(2);
      FileOutputStream out = new FileOutputStream(args[1]);
      mctx.setOutput(out, null);
      mctx.marshalDocument(order);
      System.out.println("Unmarshalled and marshalled order with " +
          order.getItems().size() + " items and total value " + total);
     
    } catch (FileNotFoundException e) {
      e.printStackTrace();
View Full Code Here

Examples of org.jibx.runtime.IMarshallingContext

     * @param root the Object to marshal
     * @return the Document representation
     */
    private static Document marshalActualDocument(Object root) throws JiBXException {
        final IBindingFactory bfact = BindingDirectory.getFactory(root.getClass());
        final IMarshallingContext mctx = bfact.createMarshallingContext();
       
        final JDOMWriter jdomWriter = new JDOMWriter(bfact.getNamespaces());
       
        return marshalDocument(root, mctx, jdomWriter);
    }
View Full Code Here

Examples of org.jibx.runtime.IMarshallingContext

        return marshalDocument(root, mctx, jdomWriter);
    }
   
    private static Document marshalActualDocument(Object root, Document document) throws JiBXException {
        final IBindingFactory bfact = BindingDirectory.getFactory(root.getClass());
        final IMarshallingContext mctx = bfact.createMarshallingContext();
       
        final JDOMWriter jdomWriter = new JDOMWriter(bfact.getNamespaces(), document);
       
        return marshalDocument(root, mctx, jdomWriter);
    }
View Full Code Here

Examples of org.jibx.runtime.IMarshallingContext

        return marshalDocument(root, mctx, jdomWriter);
    }
   
    private static Document marshalActualDocument(Object root, Element element) throws JiBXException {
        final IBindingFactory bfact = BindingDirectory.getFactory(root.getClass());
        final IMarshallingContext mctx = bfact.createMarshallingContext();
       
        final JDOMWriter jdomWriter = new JDOMWriter(bfact.getNamespaces(), element);
       
        return marshalDocument(root, mctx, jdomWriter);
    }
View Full Code Here

Examples of org.jibx.runtime.IMarshallingContext

            Customer customer = (Customer)uctx.unmarshalDocument(in, null);
           
            // you can add code here to alter the unmarshalled customer
           
      // marshal object back out to file (with nice indentation, as UTF-8)
      IMarshallingContext mctx = bfact.createMarshallingContext();
      mctx.setIndent(2);
      FileOutputStream out = new FileOutputStream(args[1]);
      mctx.marshalDocument(customer, "UTF-8", null, out);
     
    } catch (FileNotFoundException e) {
      e.printStackTrace();
            System.exit(1);
    } catch (JiBXException e) {
View Full Code Here

Examples of org.jibx.runtime.IMarshallingContext

    public static void writeSchemas(File dir, Collection schemas) throws JiBXException, IOException {
        IBindingFactory fact = BindingDirectory.getFactory(SchemaUtils.XS_PREFIX_BINDING, SchemaElement.class);
        for (Iterator iter = schemas.iterator(); iter.hasNext();) {
            SchemaHolder holder = (SchemaHolder)iter.next();
            if (!holder.isExistingFile()) {
                IMarshallingContext ictx = fact.createMarshallingContext();
                File file = new File(dir, holder.getFileName());
                ictx.setOutput(new FileOutputStream(file), null);
                ictx.setIndent(2);
                ((IMarshallable)holder.getSchema()).marshal(ictx);
                ictx.getXmlWriter().flush();
            }
        }
    }
View Full Code Here

Examples of org.jibx.runtime.IMarshallingContext

                    uctx.setDocument(new FileInputStream(file), null);
                    Object object = uctx.unmarshalElement();
                    String encoding = ((UnmarshallingContext)uctx).getInputEncoding();
                   
                    // marshal object back out to document in memory
                    IMarshallingContext mctx = factory.createMarshallingContext();
                    mctx.setIndent(2);
                    ByteArrayOutputStream bos = new ByteArrayOutputStream();
                    mctx.setOutput(bos, "UTF-8");
                    ((IMarshallable)object).marshal(mctx);
                    mctx.endDocument();
                   
                    // compare with original input document
                    InputStreamReader brdr = new InputStreamReader
                        (new ByteArrayInputStream(bos.toByteArray()), "UTF-8");
                    InputStreamReader frdr = new InputStreamReader(new FileInputStream(file), encoding);
View Full Code Here

Examples of org.jibx.runtime.IMarshallingContext

    public void writeObject(Object object, MessageWriter writer, MessageContext context)
        throws XFireFault
    {
        try
        {
            IMarshallingContext mctx = bfact.createMarshallingContext();

            XMLStreamWriter noCloseWriter = new NoCloseXMLStreamWriter(((ElementWriter) writer)
                    .getXMLStreamWriter());
            mctx.setXmlWriter(new StAXWriter(bfact.getNamespaces(), noCloseWriter));

            mctx.marshalDocument(object);
        }
        catch (JiBXException e)
        {
            throw new XFireRuntimeException("Could not write Jibx type.", e);
        }
View Full Code Here

Examples of org.jibx.runtime.IMarshallingContext

      if (choice.ifNamedLayer()) {
        NamedLayerInfo layer = choice.getNamedLayer();
        Assert.assertEquals("OCEANSEA_1M:Foundation", layer.getName());
      }
    }
    IMarshallingContext ctx = bfact.createMarshallingContext();
    StringWriter sw = new StringWriter();
    ctx.setOutput(sw);
    ctx.marshalDocument(sld);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.