QName itemType = context.getTypeFromAttributes(namespace,
localName,
attributes);
// Get the deserializer for the type.
Deserializer dSer = null;
if (itemType != null && (context.getCurElement().getHref() == null)) {
dSer = context.getDeserializerForType(itemType);
}
if (dSer == null) {
// No deserializer can be found directly. Need to look harder
QName defaultType = defaultItemType;
Class javaType = null;
if (arrayClass != null &&
arrayClass.isArray() &&
defaultType == null) {
javaType = arrayClass.getComponentType();
defaultType = context.getTypeMapping().getTypeQName(javaType);
}
// We don't have a deserializer, the safest thing to do
// is to set up using the DeserializerImpl below.
// The DeserializerImpl will take care of href/id and
// install the appropriate serializer, etc. The problem
// is that takes a lot of time and will occur
// all the time if no xsi:types are sent. Most of the
// time an item is a simple schema type (i.e. String)
// so the following shortcut is used to get a Deserializer
// for these cases.
if (itemType == null && dSer == null) {
if (defaultType != null && SchemaUtils.isSimpleSchemaType(defaultType)) {
dSer = context.getDeserializer(javaType, defaultType);
}
}
// If no deserializer is
// found, the deserializer is set to DeserializerImpl().
// It is possible that the element has an href, thus we
// won't know the type until the definitition is encountered.
if (dSer == null) {
dSer = new DeserializerImpl();
// Determine a default type for the deserializer
if (itemType == null) {
dSer.setDefaultType(defaultType);
}
}
}
// Register the callback value target, and
// keep track of this index so we know when it has been set.
dSer.registerValueTarget(
new DeserializerTarget(this, new Integer(curIndex)));
// The framework handles knowing when the value is complete, as
// long as we tell it about each child we're waiting on...
addChildDeserializer(dSer);