Examples of IBindingFactory


Examples of org.jibx.runtime.IBindingFactory

        if (path == null) {
            custom = new SchemasetCustom((SchemasetCustom)null);
        } else {
           
            // unmarshal either a <schema-set> or <schema> element
            IBindingFactory fact = BindingDirectory.getFactory(SchemasetCustom.class);
            IUnmarshallingContext ictx = fact.createUnmarshallingContext();
            FileInputStream is = new FileInputStream(path);
            ictx.setDocument(is, null);
            ictx.setUserContext(vctx);
            Object obj = ictx.unmarshalElement();
            if (obj instanceof SchemasetCustom) {
View Full Code Here

Examples of org.jibx.runtime.IBindingFactory

            System.exit(0);
        }
    try {
           
            // unmarshal customer information from file
            IBindingFactory bfact = BindingDirectory.getFactory(Order.class);
            IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
            FileInputStream in = new FileInputStream(args[0]);
            Order order = (Order)uctx.unmarshalDocument(in, null);
           
            // compute the total amount of the order
            float total = 0.0f;
            for (Iterator iter = order.getItems().iterator(); iter.hasNext();) {
                Item item = (Item)iter.next();
                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 " +
View Full Code Here

Examples of org.jibx.runtime.IBindingFactory

     *
     * @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.IBindingFactory

       
        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.IBindingFactory

       
        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.IBindingFactory

       
        // load or create customization information
        m_global = new GlobalCustom(loc);
        m_global.setNamespaceStyle(new Integer(CustomBase.DERIVE_FIXED));
        if (path != null) {
            IBindingFactory fact = BindingDirectory.getFactory("class-customs-binding", GlobalCustom.class);
            IUnmarshallingContext ictx = fact.createUnmarshallingContext();
            FileInputStream is = new FileInputStream(path);
            ictx.setDocument(is, null);
            ictx.setUserContext(vctx);
            ((IUnmarshallable)m_global).unmarshal(ictx);
        }
View Full Code Here

Examples of org.jibx.runtime.IBindingFactory

     * @throws JiBXException
     * @throws IOException
     */
    protected SchemaElement readSchema(ValidationContext vctx,
        ISchemaResolver resolver) throws JiBXException, IOException {
        IBindingFactory factory = BindingDirectory.getFactory
            (SchemaUtils.XS_PREFIX_BINDING, SchemaElement.class);
        IUnmarshallingContext uctx = factory.createUnmarshallingContext();
        uctx.setDocument(resolver.getContent(), resolver.getId(), null);
        uctx.setUserContext(vctx);
        SchemaElement schema = new SchemaElement();
        ((IUnmarshallable)schema).unmarshal(uctx);
        return schema;
View Full Code Here

Examples of org.jibx.runtime.IBindingFactory

     * @param schemas list of {@link SchemaHolder}
     * @throws JiBXException
     * @throws IOException
     */
    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.IBindingFactory

                            Method method = fclas.getMethod
                                (BindingDirectory.FACTORY_INSTMETHOD,
                                BindingDirectory.EMPTY_ARGS);
                            Object result = method.invoke(null, (Object[])null);
                            if (result instanceof IBindingFactory) {
                                IBindingFactory fact = (IBindingFactory)result;
                                int match = (m_baseHashes.charAt(i*2) << 16) +
                                m_baseHashes.charAt(i*2+1);
                                if (fact.getHash() != match) {
                                    throw new JiBXException("Precompiled base binding '" + m_baseNames[i] + "' has changed since binding '" + getBindingName() + "' was compiled");
                                } else {
                                    classes.addAll(fact.getBindingClasses());
                                }
                            } else {
                                throw new JiBXException("Classloader conflict for precompiled base binding '" + m_baseNames[i] + "' used by binding '" + getBindingName() + '\'');
                            }
                        } catch (IllegalAccessException e) {
View Full Code Here

Examples of org.jibx.runtime.IBindingFactory

       
        // load or create customization information
        setLocator(loc);
        m_global = new GlobalCustom(loc);
        if (path != null) {
            IBindingFactory fact = BindingDirectory.getFactory("class_customs_binding", GlobalCustom.class);
            IUnmarshallingContext ictx = fact.createUnmarshallingContext();
            FileInputStream is = new FileInputStream(path);
            ictx.setDocument(is, null);
            ictx.setUserContext(vctx);
            ((IUnmarshallable)m_global).unmarshal(ictx);
        }
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.