Package org.jibx.runtime

Examples of org.jibx.runtime.JiBXException


        if (index >= 0) {
           
            // get prefix defined for namespace
            String prefix = ixw.getNamespacePrefix(index);
            if (prefix == null) {
                throw new JiBXException("Namespace URI " + qname.m_uri +
                    " cannot be used since it is not active");
            } else if (prefix.length() > 0) {
                return prefix + ':' + qname.m_name;
            } else {
                return qname.m_name;
            }
           
        } else {
            throw new JiBXException("Unknown namespace URI " + qname.m_uri);
        }
    }
View Full Code Here


            try {
                String mname = m_deserializer.getName();
                String cname = m_deserializer.getClassFile().getName();
                Class clas = ClassFile.loadClass(cname);
                if (clas == null) {
                    throw new JiBXException("Deserializer class " + cname +
                        " not found for converting default value");
                } else {
                   
                    // try first to find a declared method, then a public one
                    Method meth;
                    try {
                        meth = clas.getDeclaredMethod(mname,
                            SINGLE_STRING_ARGS);
                        meth.setAccessible(true);
                    } catch (NoSuchMethodException ex) {
                        meth = clas.getMethod(mname, SINGLE_STRING_ARGS);
                    }
                    String text;
                    if (value instanceof String || value == null) {
                        text = (String)value;
                    } else {
                        text = value.toString();
                    }
                    value = meth.invoke(null, new Object[] { text });
                   
                }
            } catch (IllegalAccessException ex) {
                throw new JiBXException("Conversion method not accessible", ex);
            } catch (InvocationTargetException ex) {
                throw new JiBXException("Internal error", ex);
            } catch (NoSuchMethodException ex) {
                throw new JiBXException("Internal error", ex);
            }
        }
        mb.appendLoadConstant(value);
       
        BranchWrapper ifne = null;
View Full Code Here

            try {
                String mname = m_deserializer.getName();
                String cname = m_deserializer.getClassFile().getName();
                Class clas = ClassFile.loadClass(cname);
                if (clas == null) {
                    throw new JiBXException("Deserializer class " + cname +
                        " not found for converting default value");
                } else {
                   
                    // try first to find a declared method, then a public one
                    Method meth;
                    try {
                        meth = clas.getDeclaredMethod(mname,
                            SINGLE_STRING_ARGS);
                        meth.setAccessible(true);
                    } catch (NoSuchMethodException ex) {
                        meth = clas.getMethod(mname, SINGLE_STRING_ARGS);
                    }
                    return meth.invoke(null, new Object[] { text });
                   
                }
            } catch (IllegalAccessException ex) {
                throw new JiBXException("Conversion method not accessible", ex);
            } catch (InvocationTargetException ex) {
                throw new JiBXException("Internal error", ex);
            } catch (NoSuchMethodException ex) {
                throw new JiBXException("Internal error", ex);
            }
        } else {
            return text;
        }
    }
View Full Code Here

            if (index >= 0) {
               
                // get prefix defined for namespace
                prefix = ixw.getNamespacePrefix(index);
                if (prefix == null) {
                    throw new JiBXException("Namespace URI " + qname.getUri() +
                        " cannot be used since it is not active");
                } else if (prefix.length() > 0) {
                    return prefix + ':' + qname.getName();
                } else {
                    return qname.getName();
                }
               
            } else {
                throw new JiBXException("Unknown namespace URI " + qname.getUri());
            }
        }
    }
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 {
           
            // check if ID already defined
            MarshallingContext ctx = (MarshallingContext)ictx;
            HashMap map = ctx.getIdMap();
            String id = getIdValue(obj);
            Object value = map.get(id);
            if (value == null) {
                if (obj instanceof IMarshallable) {
                   
                    // new id, write full representation and add to map
                    map.put(id, obj);
                    ((IMarshallable)obj).marshal(ctx);
                   
                } else {
                    throw new JiBXException("Object of type " +
                        obj.getClass().getName() + " is not marshallable");
                }
            } else if (value.equals(obj)) {
               
                // generate reference to previously-defined item
                ctx.startTagAttributes(m_index, m_name);
                ctx.attribute(0, getAttributeName(), id);
                ctx.closeStartEmpty();
               
            } else {
                throw new JiBXException("Duplicate definition for ID " + id);
            }
        }
    }
View Full Code Here

    public void marshal(Object obj, IMarshallingContext ictx)
        throws JiBXException {
       
        // make sure the parameters are as expected
        if (!(obj instanceof Map)) {
            throw new JiBXException("Invalid object type for marshaller");
        } else if (!(ictx instanceof MarshallingContext)) {
            throw new JiBXException("Invalid object type for marshaller");
        } else {
           
            // start by generating start tag for container
            MarshallingContext ctx = (MarshallingContext)ictx;
            Map map = (Map)obj;
            ctx.startTagAttributes(m_index, m_name).
                attribute(m_index, getSizeAttributeName(), map.size()).
                closeStartContent();
           
            // loop through all entries in map
            Iterator iter = map.entrySet().iterator();
            while (iter.hasNext()) {
                Map.Entry entry = (Map.Entry)iter.next();
                ctx.startTagAttributes(m_index, getEntryElementName());
                ctx.attribute(m_index, getKeyAttributeName(),
                    entry.getKey().toString());
                ctx.closeStartContent();
                if (entry.getValue() instanceof IMarshallable) {
                    ((IMarshallable)entry.getValue()).marshal(ctx);
                    ctx.endTag(m_index, getEntryElementName());
                } else {
                    throw new JiBXException("Mapped value is not marshallable");
                }
            }
           
            // finish with end tag for container element
            ctx.endTag(m_index, m_name);
View Full Code Here

            try {
                m_factory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE,
                    nsf ? Boolean.TRUE : Boolean.FALSE);
                m_isNamespaceEnabled = nsf;
            } catch (IllegalArgumentException e) {
                throw new JiBXException
                    ("Unable to create parser with required namespace handling");
            }
        }
    }
View Full Code Here

                        m_factory.createXMLStreamReader(is, enc);
                    return new StAXReaderWrapper(rdr, name, nsf);
                }
            }
        } catch (XMLStreamException e) {
            throw new JiBXException("Error creating parser", e);
        }
    }
View Full Code Here

                setNamespacesState(nsf);
                return new StAXReaderWrapper(m_factory.createXMLStreamReader(rdr),
                    name, nsf);
            }
        } catch (XMLStreamException e) {
            throw new JiBXException("Error creating parser", e);
        }
    }
View Full Code Here

                    String name = prefix.length() > 0 ? "xmlns:" + prefix : "xmlns";
                    writer.addAttribute(0, name, uris[i]);
                }
               
            } catch (IOException e) {
                throw new JiBXException("Error writing output 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.