private List children;
static ClassDescriptor fromClass(Log log, JavaClass javaClass) {
DocletTag tag = javaClass.getTagByName(TAG_CLASS_DESCRIPTOR);
if (tag == null) {
return null;
}
ClassDescriptor cd = new ClassDescriptor(log, tag);
cd.className = javaClass.getFullyQualifiedName();
cd.isInterface = javaClass.isInterface();
cd.isAbstract = !cd.isInterface && javaClass.isAbstract();
cd.extend = tag.getNamedParameter(EXTEND);
if (cd.extend == null) {
if (javaClass.getSuperJavaClass() != null) {
cd.extend = javaClass.getSuperJavaClass().getFullyQualifiedName();
// do not declare extending Object :-)
if (Object.class.getName().equals(cd.extend)) {
cd.extend = null;
}
}
} else if (cd.extend.length() == 0) {
// explicit empty extend value prevents extend attribute from being
// set
cd.extend = null;
}
String interfaceList = tag.getNamedParameter(INTERFACES);
if (interfaceList == null) {
if (javaClass.getImplementedInterfaces() != null) {
JavaClass[] implInterfaces = javaClass.getImplementedInterfaces();
cd.interfaces = new HashSet();
for (int i = 0; i < implInterfaces.length; i++) {
cd.interfaces.add(implInterfaces[i].getFullyQualifiedName());
}
}
} else if (interfaceList.length() == 0) {
// empty interface list prevents creation of interface element
cd.interfaces = null;
} else {
// split list and create set for interface elements
StringTokenizer tokener = new StringTokenizer(interfaceList, ",");
cd.interfaces = new HashSet();
while (tokener.hasMoreTokens()) {
String iface = tokener.nextToken().trim();
if (iface.length() > 0) {
cd.interfaces.add(iface);
}
}
}
cd.jcrType = tag.getNamedParameter(JCR_TYPE);
cd.jcrSuperTypes = tag.getNamedParameter(JCR_SUPER_TYPES);
cd.jcrMixinTypes = tag.getNamedParameter(JCR_MIXIN_TYPES);
// only reset default if explicitly stated
if (tag.getNamedParameter(DISCRIMINATOR) != null) {
cd.discriminator = Boolean.valueOf(
tag.getNamedParameter(DISCRIMINATOR)).booleanValue();
}
return cd;
}