Package org.jibx.runtime

Examples of org.jibx.runtime.JiBXException


            frag = m_document.createDocumentFragment();
            created = true;
        } else if (obj instanceof DocumentFragment) {
            frag = (DocumentFragment)obj;
        } else {
            throw new JiBXException
                ("Supplied object is not an org.w3c.dom.DocumentFragment");
        }
        if (!(ictx instanceof UnmarshallingContext)) {
            throw new JiBXException
                ("Unmarshalling context not of expected type");
        }
       
        // unmarshal content to document model
        m_unmarshalContext = (UnmarshallingContext)ictx;
        try {
            Node node;
            while ((node = unmarshalNode()) != null) {
                frag.appendChild(node);
            }
            if (created && !frag.hasChildNodes()) {
                return null;
            } else {
                return frag;
            }
    } catch (IOException e) {
            throw new JiBXException("Error reading from document", e);
    }
    }
View Full Code Here


    public void marshal(Object obj, IMarshallingContext ictx)
        throws JiBXException {
       
        // make sure the parameters are as expected
        if (!(obj instanceof List)) {
            throw new JiBXException("Mapped object not a java.util.List");
        } else {
            try {
                   
                // marshal all content with no indentation
                m_xmlWriter = ictx.getXmlWriter();
                int indent = ictx.getIndent();
                ictx.setIndent(-1);
                m_defaultNamespaceURI = null;
                marshalContent((List)obj);
                ictx.setIndent(indent);
               
            } catch (IOException e) {
                throw new JiBXException("Error writing to document", e);
            }
        }
    }
View Full Code Here

    /* (non-Javadoc)
     * @see org.jibx.runtime.IUnmarshaller#isPresent(org.jibx.runtime.IUnmarshallingContext)
     */
    public boolean isPresent(IUnmarshallingContext ctx) throws JiBXException {
        if (!(ctx instanceof UnmarshallingContext)) {
            throw new JiBXException
                ("Unmarshalling context not of expected type");
        } else {
            return ((UnmarshallingContext)ctx).currentEvent() !=
                IXMLReader.END_TAG;
        }
View Full Code Here

            list = new ArrayList();
            created = true;
        } else if (obj instanceof List) {
            list = (List)obj;
        } else {
            throw new JiBXException("Supplied object is not a java.util.List");
        }
        if (!(ictx instanceof UnmarshallingContext)) {
            throw new JiBXException
                ("Unmarshalling context not of expected type");
        }
       
        // unmarshal content to document model
        m_unmarshalContext = (UnmarshallingContext)ictx;
        try {
      unmarshalContent(list);
            if (created && list.isEmpty()) {
                return null;
            } else {
                return list;
            }
    } catch (IOException e) {
            throw new JiBXException("Error reading from document", e);
    }
    }
View Full Code Here

            if (mcf != null) {
                if (mcf.getInitializerMethod(ANY_INIT_SIG) != null) {
                    m_marshaller = mcf;
                } else if (mcf.getInitializerMethod
                    (ANY_INITCLASS_SIG) == null) {
                    throw new JiBXException("Marshaller class " +
                        mcf.getName() + " requires name to be set");
                }
            }
            if (ucf != null) {
                if (ucf.getInitializerMethod(ANY_INIT_SIG) != null) {
                    m_unmarshaller = ucf;
                } else if (ucf.getInitializerMethod
                    (ANY_INITCLASS_SIG) == null) {
                    throw new JiBXException("Unmarshaller class " +
                        ucf.getName() + " requires name to be set");
                }
            }
        }
        if (name != null) {
           
            // name supplied, make sure both support it
            if (mcf != null && !mcf.isImplements(ALIASABLE_INTERFACETYPE)) {
                throw new JiBXException("Marshaller class " +
                    mcf.getName() + " does not allow name to be set");
            }
            if (ucf != null && !ucf.isImplements(ALIASABLE_INTERFACETYPE)) {
                throw new JiBXException("Unmarshaller class " +
                    ucf.getName() + " does not allow name to be set");
            }
        }
    }
View Full Code Here

        }
       
        // make sure the initializer is defined and public
        if (init == null || ((init.getAccessFlags() &
            Constants.ACC_PUBLIC) == 0)) {
            throw new JiBXException("No usable constructor for " +
                "marshaller or unmarshaller based on " + base.getName());
        }
       
        // get package and target name from bound class
        String tname = base.getName();
View Full Code Here

     */
    public void genIfPresentTest(UnmarshalBuilder mb) throws JiBXException {
       
        // make sure this is an appropriate call
        if (m_name == null) {
            throw new JiBXException("Method call on invalid value");
        }
       
        // load the unmarshalling context and name information, then call the
        //  appropriate method to test for item present
        mb.loadContext();
View Full Code Here

    public void genAttrPresentTest(ContextMethodBuilder mb)
        throws JiBXException {
       
        // make sure this is an appropriate call
        if (m_valueStyle != ATTRIBUTE_STYLE || m_name == null) {
            throw new JiBXException("Method call on invalid structure");
        }
       
        // generate load of the unmarshalling context and the name information,
        //  then just call the attribute check method
        mb.loadContext();
View Full Code Here

            mb.loadContext();
            m_name.genPushUriPair(mb);
            mb.appendCallVirtual(CHECK_ELEMENT_NAME, CHECK_SIGNATURE);
           
        } else if (m_valueStyle == ATTRIBUTE_STYLE) {
            throw new JiBXException("Method call on invalid structure");
        } else {
           
            // handle text content by always returned true
            mb.appendICONST_1();
           
View Full Code Here

                type = m_property.getTypeName();
            }
            m_idRefMap = m_container.getDefinitionContext().
                getClassMapping(type);
            if (m_idRefMap == null) {
                throw new JiBXException("No mapping defined for " +
                    type + " used as IDREF target");
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.jibx.runtime.JiBXException

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.