use of org.apache.cxf.aegis.DatabindingException in project cxf by apache.
the class XMLStreamReaderType method writeObject.
@Override
public void writeObject(Object object, MessageWriter writer, Context context) throws DatabindingException {
XMLStreamReader reader = (XMLStreamReader) object;
try {
StaxUtils.copy(reader, ((ElementWriter) writer).getXMLStreamWriter());
reader.close();
} catch (XMLStreamException e) {
throw new DatabindingException("Could not write xml.", e);
}
}
use of org.apache.cxf.aegis.DatabindingException in project cxf by apache.
the class ElementReader method checkHasMoreChildReaders.
private boolean checkHasMoreChildReaders() {
try {
int event = root.getEventType();
while (root.hasNext()) {
switch(event) {
case XMLStreamConstants.START_ELEMENT:
if (root.getDepth() > depth) {
hasCheckedChildren = true;
hasChildren = true;
return true;
}
break;
case XMLStreamConstants.END_ELEMENT:
if (root.getDepth() < depth) {
hasCheckedChildren = true;
hasChildren = false;
if (root.hasNext()) {
root.next();
}
return false;
}
break;
case XMLStreamConstants.END_DOCUMENT:
// We should never get here...
hasCheckedChildren = true;
hasChildren = false;
return false;
default:
break;
}
if (root.hasNext()) {
event = root.next();
}
}
hasCheckedChildren = true;
hasChildren = false;
return false;
} catch (XMLStreamException e) {
throw new DatabindingException("Error parsing document.", e);
}
}
use of org.apache.cxf.aegis.DatabindingException 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);
}
}
Aggregations