return file.getName().toLowerCase().endsWith(".class");
}
});
System.out.println("Getting type hierarchy for " + classes.length + " classes.");
TypeHierarchy result= new TypeHierarchy();
final String basePath= library.getAbsolutePath();
for (UniversalFile clazz : classes)
{
String fileName= clazz.getRelativePath(basePath).replace('\\', '.');
DirectClassFile classFile= new DirectClassFile(clazz.getFileAsBytes(), fileName, false);
classFile.setAttributeFactory(StdAttributeFactory.THE_ONE);
try
{
classFile.getMagic();
}
catch (ParseException ex)
{
continue;
}
final int DOT_CLASS_LENGTH= ".class".length();
String className= fileName.substring(0, fileName.length() - DOT_CLASS_LENGTH).replace('/', '.');
// Super-class.
if (classFile.getSuperclass() != null)
{
String superClassName= Util.parseClassName(classFile.getSuperclass().getClassType().getClassName()).toString();
result.addDirectSubType(className, superClassName);
}
// Interfaces
TypeList interfaces= classFile.getInterfaces();
if (interfaces != null)
{
for (int i= 0; i < interfaces.size(); i++)
{
String interfaceName= Util.parseClassName(interfaces.getType(i).getClassName()).toString();
result.addDirectSubType(className, interfaceName);
}
}
}
return result;
}