Package org.jibx.runtime

Examples of org.jibx.runtime.IMarshallingContext


      IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
      Object obj =
         uctx.unmarshalDocument(new FileInputStream("src/test/resources/portal/portal/classic/navigation.xml"), null);
      assertEquals(PageNavigation.class, obj.getClass());

      IMarshallingContext mctx = bfact.createMarshallingContext();
      mctx.setIndent(2);
      mctx.marshalDocument(obj, "UTF-8", null, new FileOutputStream("target/navigation.xml"));

      obj = uctx.unmarshalDocument(new FileInputStream("target/navigation.xml"), null);
      assertEquals(PageNavigation.class, obj.getClass());
   }
View Full Code Here


      Object obj =
         uctx.unmarshalDocument(
            new FileInputStream("src/test/resources/portal/portal/classic/portlet-preferences.xml"), null);
      assertEquals(PortletPreferencesSet.class, obj.getClass());

      IMarshallingContext mctx = bfact.createMarshallingContext();
      mctx.setIndent(2);
      mctx.marshalDocument(obj, "UTF-8", null, new FileOutputStream("target/portlet-preferences.xml"));
      assertEquals(PortletPreferencesSet.class, obj.getClass());
   }
View Full Code Here

        if (enc == null) {
            enc = "UTF-8";
        }
       
        // marshal root object back out to document in memory
        IMarshallingContext mctx = bfact.createMarshallingContext();
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        try {
            XMLOutputFactory ofact = XMLOutputFactory.newInstance();
            XMLStreamWriter wrtr = ofact.createXMLStreamWriter(bos, enc);
            mctx.setXmlWriter(new StAXWriter(bfact.getNamespaces(), wrtr));
            mctx.marshalDocument(obj);
        } catch (XMLStreamException e) {
            throw new JiBXException("Error creating writer", e);
        }
       
        // compare with original input document
View Full Code Here

                    customs, beans, enums, ignores);
               
                // marshal binding out to file
                IBindingFactory bfact =
                    BindingDirectory.getFactory("normal", BindingElement.class);
                IMarshallingContext mctx = bfact.createMarshallingContext();
                mctx.setIndent(2);
                mctx.marshalDocument(binding, "UTF-8", null,
                    new FileOutputStream(fname));
               
            } catch (JiBXException ex) {
                ex.printStackTrace(System.out);
                System.exit(1);
View Full Code Here

                    if (enc == null) {
                        enc = "UTF-8";
                    }
                   
                    // marshal root object back out to document in memory
                    IMarshallingContext mctx = factory.createMarshallingContext();
                    ByteArrayOutputStream bos = new ByteArrayOutputStream();
                    mctx.setIndent(2);
                    mctx.marshalDocument(obj, "UTF-8", null, bos);
                   
                    // compare with original input document
                    InputStreamReader brdr =
                        new InputStreamReader(new ByteArrayInputStream(bos.toByteArray()), "UTF-8");
                    InputStreamReader frdr = new InputStreamReader(resolver.getContent(), enc);
View Full Code Here

            SchemaElement schema = (SchemaElement)iter.next();
            File file = new File(destdir, schema.getResolver().getName());
            OutputStream stream = new FileOutputStream(file);
            Writer writer = new OutputStreamWriter(stream, "utf-8");
            IBindingFactory factory = BindingDirectory.getFactory(SchemaUtils.XS_PREFIX_BINDING, SchemaElement.class);
            IMarshallingContext ictx = factory.createMarshallingContext();
            ictx.setOutput(writer);
            ictx.setIndent(2);
            ictx.marshalDocument(schema);
            writer.close();
        }
    }
View Full Code Here

                    if (enc == null) {
                        enc = "UTF-8";
                    }
                   
                    // marshal root object back out to document in memory
                    IMarshallingContext mctx = factory.createMarshallingContext();
                    ByteArrayOutputStream bos = new ByteArrayOutputStream();
                    mctx.setIndent(2);
                    mctx.marshalDocument(schema, "UTF-8", null, bos);
                   
                    // compare with original input document
                    InputStreamReader brdr =
                        new InputStreamReader(new ByteArrayInputStream(bos.toByteArray()), "UTF-8");
                    InputStreamReader frdr = new InputStreamReader(resolver.getContent(), enc);
View Full Code Here

     * @throws JiBXException
     * @throws IOException
     */
    public void writeBindings(File dir) throws JiBXException, IOException {
        IBindingFactory fact = BindingDirectory.getFactory("normal", BindingElement.class);
        IMarshallingContext ictx = fact.createMarshallingContext();
        ictx.setIndent(2);
        List keys = getKeys();
        for (Iterator iter = keys.iterator(); iter.hasNext();) {
            BindingHolder holder = (BindingHolder)m_objectBindings.get(iter.next());
            if (holder != null) {
                File file = new File(dir, holder.getFileName());
                ictx.setOutput(new FileOutputStream(file), null);
                ((IMarshallable)holder.getBinding()).marshal(ictx);
                ictx.getXmlWriter().flush();
            }
        }
    }
View Full Code Here

                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

        }
    }
   
    private static void writeBinding(BindingHolder holder, OutputStream os) throws JiBXException, IOException {
        IBindingFactory fact = BindingDirectory.getFactory("normal", BindingElement.class);
        IMarshallingContext ictx = fact.createMarshallingContext();
        ictx.setIndent(2);
        ictx.setOutput(os, null);
        ((IMarshallable)holder.getBinding()).marshal(ictx);
        ictx.getXmlWriter().flush();
    }
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.