* @return the JDOClass instance for the specified class name or
* <code>null</code> if the specified resource has no XML metadata.
*/
private JDOClass loadXMLResource(String resource, String className) {
boolean debug = xmlLogger.isDebugEnabled();
JDOClass jdoClass = null;
InputStream stream = javaModel.getInputStreamForResource(resource);
if (stream == null) {
if (debug)
xmlLogger.debug(" XML " + resource + " not available"); //NOI18N
}
else {
// resource exists => parse it
// Store all pc classes specified in this resource in this
// JDOModel instance => pass this to the handler
JDOHandler handler = new JDOHandlerImpl(this);
JDOParser parser = new JDOParser(handler);
try {
if (debug)
xmlLogger.debug(" XML " + resource + //NOI18N
" found, start parsing ..."); //NOI18N
parser.parse(new InputSource(new InputStreamReader(stream)));
}
catch (SAXException ex) {
throw new ModelFatalException(
msg.msg("EXC_XMLError", resource), ex); //NOI18N
}
catch (ParserConfigurationException ex) {
throw new ModelFatalException(
msg.msg("EXC_XMLError", resource), ex); //NOI18N
}
catch (IOException ex) {
throw new ModelFatalException(
msg.msg("EXC_XMLError", resource), ex); //NOI18N
}
finally {
try { stream.close(); }
catch (IOException ex) {
// ignore close exception, stream will be nullified anyway
}
}
stream = null;
// post process loaded JDOClasses
Collection newJDOClasses = handler.handledJDOClasses();
if (debug)
xmlLogger.debug(" XML " + resource + //NOI18N
" has JDO metadata for class(es) " + //NOI18N
newJDOClasses);
for (Iterator i = newJDOClasses.iterator(); i.hasNext();) {
JDOClass next = (JDOClass)i.next();
if (className.equals(next.getName())) {
jdoClass = next;
}
checkSuperclass(next);
}
if (jdoClass == null)