Examples of DatabindingException


Examples of org.apache.cxf.aegis.DatabindingException

            Element docElement = doc.getDocumentElement();
            if (docElement == null) {
                if (isNillable()) {
                    writer.writeXsiNil();
                } else {
                    throw new DatabindingException("Could not write xml: null document element.");
                }
            } else {
                StaxUtils.writeElement(docElement, ((ElementWriter)writer).getXMLStreamWriter(), false);
            }
        } catch (XMLStreamException e) {
            throw new DatabindingException("Could not write xml.", e);
        }
    }
View Full Code Here

Examples of org.apache.cxf.aegis.DatabindingException

            if ("element".equals(style)) {
                mapElement(pd.getName(), mappedName);
            } else if ("attribute".equals(style)) {
                mapAttribute(pd.getName(), mappedName);
            } else {
                throw new DatabindingException("Invalid style: " + style);
            }
        } catch (DatabindingException ex) {
            ex.prepend("Couldn't create type for property " + pd.getName() + " on " + getTypeClass());

            throw ex;
View Full Code Here

Examples of org.apache.cxf.aegis.DatabindingException

                }
            }

            return map;
        } catch (IllegalArgumentException e) {
            throw new DatabindingException("Illegal argument.", e);
        }
    }
View Full Code Here

Examples of org.apache.cxf.aegis.DatabindingException

            map = new HashMap<Object, Object>();
        } else {
            try {
                map = (Map<Object, Object>)getTypeClass().newInstance();
            } catch (Exception e) {
                throw new DatabindingException("Could not create map implementation: "
                                               + getTypeClass().getName(), e);
            }
        }

        return map;
View Full Code Here

Examples of org.apache.cxf.aegis.DatabindingException

                Map.Entry entry = (Map.Entry)itr.next();

                writeEntry(writer, context, kType, vType, entry);
            }
        } catch (IllegalArgumentException e) {
            throw new DatabindingException("Illegal argument.", e);
        }
    }
View Full Code Here

Examples of org.apache.cxf.aegis.DatabindingException

            if (asArray) {
                return makeArray(getComponentType().getTypeClass(), values);
            }
            return values;
        } catch (IllegalArgumentException e) {
            throw new DatabindingException("Illegal argument.", e);
        }
    }
View Full Code Here

Examples of org.apache.cxf.aegis.DatabindingException

            }
        }

        // check min occurs
        if (values.size() < minOccurs) {
            throw new DatabindingException("The number of elements in " + getSchemaType()
                                           + " does not meet the minimum of " + minOccurs);
        }
        return values;
    }
View Full Code Here

Examples of org.apache.cxf.aegis.DatabindingException

        }

        // check max occurs
        int size = values.size();
        if (size > maxOccurs) {
            throw new DatabindingException("The number of elements in " + getSchemaType()
                                           + " exceeds the maximum of " + maxOccurs);
        }
    }
View Full Code Here

Examples of org.apache.cxf.aegis.DatabindingException

            values = c.toArray();
        }

        AegisType type = getComponentType();
        if (type == null) {
            throw new DatabindingException("Couldn't find type for array.");
        }
        if (XmlSchemaConstants.ANY_TYPE_QNAME.equals(type.getSchemaType())) {
            forceXsiWrite = true;
        }
View Full Code Here

Examples of org.apache.cxf.aegis.DatabindingException

                    try {
                        clazz = ClassLoaderUtils.loadClass(impl, getClass());
                        object = clazz.newInstance();
                        target = object;
                    } catch (ClassNotFoundException e) {
                        throw new DatabindingException("Could not find implementation class " + impl
                                                       + " for class " + clazz.getName());
                    }
                }
            } else if (isException) {
                object = createFromFault(context);
                target = object;
            } else {
                object = clazz.newInstance();
                target = object;
            }

            // Read attributes
            while (reader.hasMoreAttributeReaders()) {
                MessageReader childReader = reader.getNextAttributeReader();
                QName name = childReader.getName();

                AegisType type = inf.getType(name);

                if (type != null) {
                    Object writeObj = type.readObject(childReader, context);
                    writeProperty(name, target, writeObj, clazz, inf);
                }
            }

            // Read child elements
            while (reader.hasMoreElementReaders()) {
                MessageReader childReader = reader.getNextElementReader();
                QName name = childReader.getName();

                // Find the BeanTypeInfo that contains a property for the element name
                BeanTypeInfo propertyTypeInfo = getBeanTypeInfoWithProperty(name);

                // Get the AegisType for the property
                AegisType type = getElementType(name, propertyTypeInfo, childReader, context);

                if (type != null) {
                    if (!childReader.isXsiNil()) {
                        Object writeObj;
                        if (type.isFlatArray()) {
                            ArrayType aType = (ArrayType) type;
                            PropertyDescriptor desc = inf.getPropertyDescriptorFromMappedName(name);
                            boolean isList =  List.class.isAssignableFrom(desc.getPropertyType());
                            writeObj = aType.readObject(childReader, name, context, !isList);
                        } else {
                            writeObj = type.readObject(childReader, context);
                        }

                        writeProperty(name, target, writeObj, clazz, propertyTypeInfo);
                    } else {
                        if (!alwaysAllowNillables() && !propertyTypeInfo.isNillable(name)) {
                            throw new DatabindingException(name.getLocalPart()
                                                           + " is nil, but not nillable.");

                        }
                        childReader.readToEnd();
                    }
                } else {
                    childReader.readToEnd();
                }
            }

            return object;
        } catch (IllegalAccessException e) {
            throw new DatabindingException("Illegal access. " + e.getMessage(), e);
        } catch (InstantiationException e) {
            throw new DatabindingException("Couldn't instantiate class. " + e.getMessage(), e);
        } catch (SecurityException e) {
            throw new DatabindingException("Illegal access. " + e.getMessage(), e);
        } catch (IllegalArgumentException e) {
            throw new DatabindingException("Illegal argument. " + e.getMessage(), e);
        } catch (InvocationTargetException e) {
            throw new DatabindingException("Could not create class: " + e.getMessage(), e);
        }
    }
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.