Search in sources :

Example 1 with NoDefaultConstructorBeanImpl

use of org.apache.cxf.aegis.custom.service.NoDefaultConstructorBeanImpl in project cxf by apache.

the class NoDefaultConstructorBeanType method readObject.

@Override
public Object readObject(MessageReader reader, Context context) throws DatabindingException {
    BeanTypeInfo inf = getTypeInfo();
    try {
        String id = null;
        String name = null;
        // Read child elements
        while (reader.hasMoreElementReaders()) {
            MessageReader childReader = reader.getNextElementReader();
            if (childReader.isXsiNil()) {
                childReader.readToEnd();
                continue;
            }
            QName qName = childReader.getName();
            AegisType defaultType = inf.getType(qName);
            AegisType type = TypeUtil.getReadType(childReader.getXMLStreamReader(), context.getGlobalContext(), defaultType);
            if (type != null) {
                String value = (String) type.readObject(childReader, context);
                if ("id".equals(qName.getLocalPart())) {
                    id = value;
                } else if ("name".equals(qName.getLocalPart())) {
                    name = value;
                }
            } else {
                childReader.readToEnd();
            }
        }
        return new NoDefaultConstructorBeanImpl(id, name);
    } catch (IllegalArgumentException e) {
        throw new DatabindingException("Illegal argument. " + e.getMessage(), e);
    }
}
Also used : BeanTypeInfo(org.apache.cxf.aegis.type.basic.BeanTypeInfo) DatabindingException(org.apache.cxf.aegis.DatabindingException) AegisType(org.apache.cxf.aegis.type.AegisType) QName(javax.xml.namespace.QName) MessageReader(org.apache.cxf.aegis.xml.MessageReader) NoDefaultConstructorBeanImpl(org.apache.cxf.aegis.custom.service.NoDefaultConstructorBeanImpl)

Aggregations

QName (javax.xml.namespace.QName)1 DatabindingException (org.apache.cxf.aegis.DatabindingException)1 NoDefaultConstructorBeanImpl (org.apache.cxf.aegis.custom.service.NoDefaultConstructorBeanImpl)1 AegisType (org.apache.cxf.aegis.type.AegisType)1 BeanTypeInfo (org.apache.cxf.aegis.type.basic.BeanTypeInfo)1 MessageReader (org.apache.cxf.aegis.xml.MessageReader)1