* @throws JiBXException on error
*/
public Object unmarshal(Object obj, IUnmarshallingContext ictx) throws JiBXException {
// position to start tag and create instance to unmarshal
ValidationContext vctx = (ValidationContext)ictx.getUserContext();
UnmarshallingContext ctx = (UnmarshallingContext)ictx;
ctx.parseToStartTag(null, ELEMENT_NAME);
// accumulate attribute values for constructor
String check = ctx.attributeText(null, "check-method", null);
String dser = ctx.attributeText(null, "deserializer", null);
String format = ctx.attributeText(null, "format-name", null);
String jclas = ctx.attributeText(null, "java-class", null);
String ser = ctx.attributeText(null, "serializer", null);
String stype = ctx.attributeText(null, "type-name");
boolean valid = true;
if (jclas == null && format == null) {
// need either 'java-class' or 'format-name', just report error and skip
vctx.addError("'java-class' attribute is required unless 'format-name' is used", ctx.getStackTop());
valid = false;
} else if (format != null) {
// check format for existence and consistency
FormatElement def = (FormatElement)s_nameToFormat.get(format);
if (def == null) {
vctx.addError('\'' + format + "' is not a valid built-in format name", ctx.getStackTop());
valid = false;
} else {
if (jclas == null) {
jclas = def.getTypeName();
}
}
}
// look through all attributes of current element
for (int i = 0; i < ctx.getAttributeCount(); i++) {
// check if nonamespace attribute is in the allowed set
String name = ctx.getAttributeName(i);
if (ctx.getAttributeNamespace(i).length() == 0) {
if (s_allowedAttributes.indexOf(name) < 0) {
vctx.addWarning("Undefined attribute " + name, ctx.getStackTop());
}
}
}
// skip content, and create and return object instance