protected Class readClass(XMLStreamReader reader, boolean useAttributes)
throws XMLStreamException {
QName classQName;
if (useAttributes) {
if (_classAttribute == null)
throw new XMLStreamException(
"Binding has no class attribute defined, cannot retrieve class");
classQName = QName.valueOf(reader.getAttributeValue(_classAttribute
.getNamespaceURI(), _classAttribute.getLocalName()));
if (classQName == null)
throw new XMLStreamException(
"Cannot retrieve class (class attribute not found)");
} else {
classQName = QName.valueOf(reader.getNamespaceURI(), reader
.getLocalName());
}
// Searches aliases with namespace URI.
Class cls = (Class) _aliasToClass.get(classQName);
if (cls != null)
return cls;
// Searches aliases without namespace URI.
cls = (Class) _aliasToClass.get(QName.valueOf(classQName.getLocalName()));
if (cls != null)
return cls;
// Finally convert the qualified name to a class (ignoring namespace URI).
cls = Reflection.getInstance().getClass(classQName.getLocalName());
if (cls == null)
throw new XMLStreamException("Class " + classQName.getLocalName() +
" not found (see javolution.lang.Reflection to support additional class loader)");
_aliasToClass.put(classQName, cls);
return cls;
}