Search in sources :

Example 1 with NoDefaultConstructorBeanKeyImpl

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

the class NoDefaultConstructorBeanKeyType method readObject.

@Override
public Object readObject(MessageReader reader, Context context) throws DatabindingException {
    BeanTypeInfo inf = getTypeInfo();
    try {
        String key = null;
        // Read child elements
        while (reader.hasMoreElementReaders()) {
            MessageReader childReader = reader.getNextElementReader();
            if (childReader.isXsiNil()) {
                childReader.readToEnd();
                continue;
            }
            QName name = childReader.getName();
            AegisType defaultType = inf.getType(name);
            AegisType type = TypeUtil.getReadType(childReader.getXMLStreamReader(), context.getGlobalContext(), defaultType);
            if (type != null) {
                String value = (String) type.readObject(childReader, context);
                if ("key".equals(name.getLocalPart())) {
                    key = value;
                }
            } else {
                childReader.readToEnd();
            }
        }
        return new NoDefaultConstructorBeanKeyImpl(key);
    } 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) NoDefaultConstructorBeanKeyImpl(org.apache.cxf.aegis.custom.service.NoDefaultConstructorBeanKeyImpl) MessageReader(org.apache.cxf.aegis.xml.MessageReader)

Aggregations

QName (javax.xml.namespace.QName)1 DatabindingException (org.apache.cxf.aegis.DatabindingException)1 NoDefaultConstructorBeanKeyImpl (org.apache.cxf.aegis.custom.service.NoDefaultConstructorBeanKeyImpl)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