if (type == null) {
throw new DatabindingException("Couldn't find type for " + value.getClass()
+ " for property " + name);
}
MessageWriter cwriter = writer.getAttributeWriter(name);
type.writeObject(value, cwriter, context);
cwriter.close();
}
}
if (inf.isExtension()) {
AegisType t = getSuperType();
if (t != null) {
t.writeObject(object, writer, context);
}
}
for (QName name : inf.getElements()) {
if (inf.isExtension()
&& inf.getPropertyDescriptorFromMappedName(name).getReadMethod().getDeclaringClass() != inf
.getTypeClass()) {
continue;
}
Object value = readProperty(object, name);
AegisType defaultType = getType(inf, name);
AegisType type = TypeUtil.getWriteType(context.getGlobalContext(), value, defaultType);
// Write the value if it is not null.
if (value != null) {
if (type == null) {
throw new DatabindingException("Couldn't find type for " + value.getClass()
+ " for property " + name);
}
writeElement(name, value, type, writer, context);
} else if (inf.isNillable(name)) {
MessageWriter cwriter = getWriter(writer, name, type);
// Write the xsi:nil if it is null.
cwriter.writeXsiNil();
cwriter.close();
}
}
}