* @return a Map from the string of the fully qualified type name to LoadedJCasType instances
*/
private synchronized Map<String, LoadedJCasType> loadJCasClasses(ClassLoader cl) {
final TypeSystem ts = casImpl.getTypeSystem();
Iterator<Type> typeIt = ts.getTypeIterator();
TypeImpl t;
String casName;
Map<String, LoadedJCasType> jcasTypes = new HashMap<String, LoadedJCasType>();
// * note that many of these may have already been loaded
// * load all the others. Actually, we ask to load all the types
// * and the ones already loaded - we just get their loaded versions
// returned.
// * Loading will run the static init functions.
while (typeIt.hasNext()) {
t = (TypeImpl) typeIt.next();
casName = t.getName();
String name_Type;
if (builtInsWithNoJCas.contains(casName))
continue;
if (builtInsWithAltNames.contains(casName))
// * convert uima.cas.Xxx -> org.apache.uima.jcas.cas.Xxx
// * convert uima.tcas.Annotator ->
// org.apache.uima.jcas.tcas.Annotator
try {
String nameBase = "org.apache.uima.jcas." + casName.substring(5);
name_Type = nameBase + "_Type";
jcasTypes.put(nameBase, new LoadedJCasType(t.getName(), Class
.forName(name_Type, true, cl), cl));
} catch (ClassNotFoundException e1) {
// OK for DocumentAnnotation, which may not have a cover class.
// Otherwise, not OK.
if (!CAS.TYPE_NAME_DOCUMENT_ANNOTATION.equals(casName)) {
assert false : "never get here because built-ins have java cover types";
e1.printStackTrace();
}
}
// this is done unconditionally to pick up old style cover functions if
// any
// as well as other JCas model types
try {
name_Type = casName + "_Type";
jcasTypes.put(casName, new LoadedJCasType(t.getName(), Class.forName(name_Type, true, cl),
cl));
// also force the load the plain name without _Type for
// old-style - that's where
// the index is incremented
Class.forName(casName, true, cl);