added possibility to whitelist or blacklist classes of packages by wildcard pattern
[javainspect.git] / src / main / java / eu / svjatoslav / inspector / java / structure / ClassDescriptor.java
index 9f4be8a..fbd491b 100644 (file)
@@ -46,7 +46,7 @@ public class ClassDescriptor implements GraphElement {
 
        private boolean isShown = true;
 
-       private final ClassGraph dump;
+       private final ClassGraph classGraph;
 
        List<ClassDescriptor> interfaces = new ArrayList<ClassDescriptor>();
 
@@ -59,7 +59,7 @@ public class ClassDescriptor implements GraphElement {
 
        public ClassDescriptor(final Class<? extends Object> clazz,
                        final ClassGraph dump) {
-               this.dump = dump;
+               classGraph = dump;
 
                fullyQualifiedName = clazz.getName();
                dump.nameToClassMap.put(fullyQualifiedName, this);
@@ -188,8 +188,15 @@ public class ClassDescriptor implements GraphElement {
                result.append("    // class descriptor header\n");
                result.append("    <TR><TD colspan=\"2\" PORT=\"f0\">"
                                + "<FONT POINT-SIZE=\"8.0\" >" + getPackageName()
-                               + "</FONT><br/>" + "<FONT POINT-SIZE=\"25.0\"><B>"
-                               + getClassName(false) + "</B></FONT>" + "</TD></TR>\n");
+                               + "</FONT><br/>");
+
+               final String parentClassesName = getParentClassesName();
+               if (parentClassesName.length() > 0)
+                       result.append("<FONT POINT-SIZE=\"12.0\"><B>" + parentClassesName
+                                       + "</B></FONT><br/>\n");
+
+               result.append("<FONT POINT-SIZE=\"25.0\"><B>" + getClassName(false)
+                               + "</B></FONT>" + "</TD></TR>\n");
        }
 
        public List<FieldDescriptor> getAllFields() {
@@ -222,10 +229,12 @@ public class ClassDescriptor implements GraphElement {
        }
 
        public String getClassName(final boolean differentiateArray) {
+               // this is needed for nested classes
+               final String actualClassName = fullyQualifiedName.replace('$', '.');
 
-               final int i = fullyQualifiedName.lastIndexOf('.');
+               final int i = actualClassName.lastIndexOf('.');
 
-               String result = fullyQualifiedName.substring(i + 1);
+               String result = actualClassName.substring(i + 1);
 
                if (isArray)
                        result = result.substring(0, result.length() - 1);
@@ -235,7 +244,7 @@ public class ClassDescriptor implements GraphElement {
                                result += " []";
 
                // this is needed for nested classes
-               result = result.replace('$', '.');
+               // result = result.replace('$', '.');
                return result;
        }
 
@@ -309,6 +318,17 @@ public class ClassDescriptor implements GraphElement {
                return fullyQualifiedName.substring(0, i).replace("[L", "");
        }
 
+       public String getParentClassesName() {
+               int i = fullyQualifiedName.lastIndexOf('.');
+               final String fullClassName = fullyQualifiedName.substring(i + 1);
+
+               i = fullClassName.lastIndexOf('$');
+               if (i == -1)
+                       return "";
+               final String parentClassesName = fullClassName.substring(0, i);
+               return parentClassesName.replace('$', '.');
+       }
+
        // public String getReadableName() {
        //
        // // do not print full class name for well known system classes
@@ -340,7 +360,7 @@ public class ClassDescriptor implements GraphElement {
                                continue;
 
                        final FieldDescriptor fieldDescriptor = new FieldDescriptor(field,
-                                       this, dump);
+                                       this, classGraph);
 
                }
        }
@@ -349,7 +369,7 @@ public class ClassDescriptor implements GraphElement {
                final Method[] methods = clazz.getMethods();
 
                for (final Method method : methods)
-                       new MethodDescriptor(method, this, dump);
+                       new MethodDescriptor(method, this, classGraph);
 
        }
 
@@ -362,6 +382,9 @@ public class ClassDescriptor implements GraphElement {
                if (Utils.isSystemPackage(fullyQualifiedName))
                        return false;
 
+               if (!classGraph.filter.isClassShown(fullyQualifiedName))
+                       return false;
+
                return isShown;
        }