in CasViewerEclipsePlugin/uimaj-ep-casviewer-core/src/main/java/org/apache/uima/casviewer/core/internal/casreader/XcasOrXmiUtil.java [329:386]
static public BaseCASObject createCASObjectFromFile (String xcasOrxmiFileName)
{
// Check for null or empty file name
if (xcasOrxmiFileName == null || xcasOrxmiFileName.trim().length()==0 ) {
return null;
}
// Which file format (XMI or XCAS) ?
if (!xcasOrxmiFileName.endsWith("xmi") && !xcasOrxmiFileName.endsWith("xcas")) {
Trace.bug("Cannot open this unknown file: " + xcasOrxmiFileName);
return null;
}
String s = xcasOrxmiFileName.replace('\\', '/');
int lastIndex = s.lastIndexOf('/');
// Look for TypePriorities xml file
String typePrioritiesFileName = null;
if ( lastIndex != -1) {
typePrioritiesFileName = s.substring(0, lastIndex+1) + DEFAULT_TYPE_PRIORITIES_FOR_XCAS;
}
if ( ! (new File(typePrioritiesFileName)).exists() ) {
// No Type Priorities file
// Trace.err("NO priority file: " + typePrioritiesFileName);
typePrioritiesFileName = null;
}
// Look for Type System used with this Xcas or Xmi
// Prefix with the path from this instance file. Make the file absolute
String typesystemFileName = null;
if ( lastIndex != -1) {
typesystemFileName = s.substring(0, lastIndex+1) + DEFAULT_TYPE_SYSTEM_FOR_XCAS;
} else {
typesystemFileName = DEFAULT_TYPE_SYSTEM_FOR_XCAS;
}
if ( ! (new File(typesystemFileName)).exists() ) {
// No Type System file
return null;
}
// De-serialize and create BaseCASObject
BaseCASObject casObject = null;
try {
casObject = createBaseCASObjectFromFile(typesystemFileName,
xcasOrxmiFileName, typePrioritiesFileName);
} catch (InvalidXMLException e) {
e.printStackTrace();
} catch (ResourceInitializationException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
}
return casObject;
} // createCASObjectFromFile