Package org.jibx.runtime

Examples of org.jibx.runtime.JiBXException


     * @param ex nested exception
     * @exception JiBXException always thrown
     */
    public void throwStartTagException(String msg, Exception ex)
        throws JiBXException {
        throw new JiBXException(msg + " at tag " + currentNameString() +
            buildPositionString(), ex);
    }
View Full Code Here


     *
     * @param msg exception message text
     * @exception JiBXException always thrown
     */
    public void throwException(String msg) throws JiBXException {
        throw new JiBXException(msg + " " + buildPositionString());
    }
View Full Code Here

               
                // configure marshaller for writing document
                context.setIndent(m_outputIndent);
                if (m_outputWriter == null) {
                    if (m_outputStream == null) {
                        throw new JiBXException("Output not configured");
                    } else {
                        context.setOutput(m_outputStream, m_outputEncoding);
                    }
                } else {
                    context.setOutput(m_outputWriter);
                }
               
                // output object as document
                context.startDocument(m_outputEncoding, null);
                ((IMarshallable)obj).marshal(context);
                context.endDocument();
                return;
               
            }
        }
       
        // error if unknown version in document
        throw new JiBXException("Unrecognized document version " + version);
    }
View Full Code Here

        PropertyDefinition prop = m_property;
        if (mdef == null) {
           
            // generate generic mapping to unknown type
            if (m_name != null) {
                throw new JiBXException
                    ("Name not allowed for generic mapping of type " + m_type);
            }
            wrap = new DirectGeneric(m_container, m_type, prop);
           
        } else if (m_isSynthetic && mdef.isAbstract() && !mdef.isBase()) {
           
            // collection reference to abstract non-base mapping as generic
            wrap = new DirectGeneric(m_container, m_type, prop);
           
        } else {
           
            // check for reference from collection
            if (prop.isImplicit()) {
                prop.setOptional(false);
            }
           
            // add mapping namespaces to context (only if no element on mapping)
            if (mdef.getName() == null) {
                mdef.setLinkages();
                ArrayList nss = mdef.getNamespaces();
                if (nss != null) {
                    for (int i = 0; i < nss.size(); i++) {
                        defc.addImpliedNamespace((NamespaceDefinition)nss.get(i));
                    }
                }
            }
           
            // generate wrapped component for all calls
            String type = mdef.getBoundType();
            if (prop.getTypeName() == null) {
                prop = new PropertyDefinition(type, m_contextObject,
                    prop.isOptional());
            }
            if (m_name == null) {
                wrap = mdef.buildRef(m_container, m_contextObject,
                    prop.getTypeName(), prop);
            } else {
               
                // force property required for internal structure
                PropertyDefinition propcopy = new PropertyDefinition(prop);
                propcopy.setOptional(false);
                wrap = mdef.buildRef(m_container, m_contextObject,
                    prop.getTypeName(), propcopy);
                m_wrappedReference = wrap;
                if (mdef.getName() == null) {
                   
                    // create the replacement components
                    IComponent icomp = wrap;
                    wrap = new ElementWrapper(defc, m_name, icomp, m_isNillable);
                    if (prop.isImplicit()) {
                        ((ElementWrapper)wrap).setDirect(true);
                    }
                    if (prop.isOptional()) {
                       
                        // make element optional
                        if (icomp instanceof ComponentProperty) {
                            ((ComponentProperty)icomp).setSkipping(true);
                        }
                        ((ElementWrapper)wrap).setOptionalNormal(true);
                        ((ElementWrapper)wrap).setStructureObject(true);
                        ((ElementWrapper)wrap).setDirect(true);
                        wrap = new OptionalStructureWrapper(wrap, prop,
                            true);
                    }
                   
                } else {
                    throw new JiBXException
                        ("Name not allowed for reference to mapping of type " +
                        type + ", which already defines a name");
                }
            }
           
View Full Code Here

               
            }
        }
       
        // error if unknown version in document
        throw new JiBXException("Unrecognized document version " + version);
    }
View Full Code Here

     * @param msg exception message text
     * @param ex nested exception
     * @exception JiBXException always thrown
     */
    public void throwException(String msg, Exception ex) throws JiBXException {
        throw new JiBXException(msg + " " + buildPositionString(), ex);
    }
View Full Code Here

     */
    public void popObject() throws JiBXException {
        if (m_stackDepth > 0) {
            --m_stackDepth;
        } else {
            throw new JiBXException("No object on stack");
        }
    }
View Full Code Here

       
        // make sure the parameters are as expected
        if (obj == null) {
            return;
        } else if (!(ictx instanceof MarshallingContext)) {
            throw new JiBXException("Invalid context type for marshaller");
        } else {
           
            // generate the element start tag
            MarshallingContext ctx = (MarshallingContext)ictx;
            ctx.startTagAttributes(m_index, m_name);
View Full Code Here

                    // force loading of superclass as well (to root)
                    String sname = cf.getSuperName();
                    if (!name.equals(sname) && sname != null) {
                        ClassFile sf = getClassFileImpl(sname);
                        if (sf == null) {
                            throw new JiBXException("Superclass " + sname +
                                " of class " + name + " not found");
                        }
                        cf.setSuperFile(sf);
                    }
                   
                    // add class information to cache
                    m_classMap.put(name, cf);
               
                }
                return cf;
               
            } catch (IOException ex) {
                throw new JiBXException("Error loading class " + name);
            }
        }
    }
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 content list with no indentation
                m_xmlWriter = ictx.getXmlWriter();
                int indent = ictx.getIndent();
                ictx.setIndent(-1);
                m_defaultNamespaceURI = null;
                for (Iterator iter = ((List)obj).iterator(); iter.hasNext();) {
                    Object item = iter.next();
                    if (item instanceof Node) {
                        marshalNode((Node)item);
                    } else {
                        throw new JiBXException
                            ("List item is not an org.w3c.dom.Node");
                    }
                }
                ictx.setIndent(indent);
               
            } catch (IOException e) {
                throw new JiBXException("Error writing to document", e);
            }
        }
    }
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.