private static final int MAX_REFERECNES_COUNT = 10;
- public String classFullyQualifiedName;
+ private String fullyQualifiedName;
private final Map<String, FieldDescriptor> nameToFieldMap = new TreeMap<String, FieldDescriptor>();
this.classGraph = classGraph;
}
- public void analyzeClass(final Class<? extends Object> clazz) {
+ protected void analyzeClass(final Class<? extends Object> clazz) {
- classFullyQualifiedName = clazz.getName();
+ fullyQualifiedName = clazz.getName();
isArray = clazz.isArray();
};
- public boolean areReferencesShown() {
+ protected boolean areReferencesShown() {
return referencesCount <= MAX_REFERECNES_COUNT;
}
- public void enlistFieldReferences(final StringBuffer result) {
+ private void enlistFieldReferences(final StringBuffer result) {
if (nameToFieldMap.isEmpty())
return;
result.append(entry.getValue().getDot());
}
- public void enlistFields(final StringBuffer result) {
+ private void enlistFields(final StringBuffer result) {
if (nameToFieldMap.isEmpty())
return;
result.append(entry.getValue().getEmbeddedDot());
}
- public void enlistImplementedInterfaces(final StringBuffer result) {
+ private void enlistImplementedInterfaces(final StringBuffer result) {
if (interfaces.isEmpty())
return;
result.append("\n");
result.append(" // interfaces implemented by class: "
- + classFullyQualifiedName + "\n");
+ + fullyQualifiedName + "\n");
for (final ClassDescriptor interfaceDescriptor : interfaces) {
if (!interfaceDescriptor.isVisible())
}
}
- public void enlistMethodReferences(final StringBuffer result) {
+ private void enlistMethodReferences(final StringBuffer result) {
if (methods.isEmpty())
return;
result.append(methodDescriptor.getDot());
}
- public void enlistMethods(final StringBuffer result) {
+ private void enlistMethods(final StringBuffer result) {
if (methods.isEmpty())
return;
result.append(methodDescriptor.getEmbeddedDot());
}
- public void enlistSuperClass(final StringBuffer result) {
+ private void enlistSuperClass(final StringBuffer result) {
if (superClass == null)
return;
return;
result.append("\n");
- result.append(" // super class for: " + classFullyQualifiedName
- + "\n");
+ result.append(" // super class for: " + fullyQualifiedName + "\n");
result.append(" " + superClass.getGraphId() + " -> " + getGraphId()
+ "[ color=\"" + superClass.getSuperClassColor()
+ "\", penwidth=10, dir=\"forward\"];\n");
}
- public void generateDotHeader(final StringBuffer result) {
+ private void generateDotHeader(final StringBuffer result) {
result.append("\n");
- result.append("// Class: " + classFullyQualifiedName + "\n");
+ result.append("// Class: " + fullyQualifiedName + "\n");
result.append(" " + getGraphId() + "[label=<<TABLE "
+ getBackgroundColor() + " BORDER=\"" + getBorderWidth()
+ "</B></FONT>" + "</TD></TR>\n");
}
- public List<FieldDescriptor> getAllFields() {
- final List<FieldDescriptor> result = new ArrayList<FieldDescriptor>();
-
- for (final Map.Entry<String, FieldDescriptor> entry : nameToFieldMap
- .entrySet())
- result.add(entry.getValue());
-
- return result;
- }
-
- public String getBackgroundColor() {
+ private String getBackgroundColor() {
String bgColor = "";
if (isEnum)
return bgColor;
}
- public String getBorderWidth() {
+ private String getBorderWidth() {
if (!areReferencesShown())
return "4";
return "1";
}
- public ClassGraph getClassGraph() {
+ protected ClassGraph getClassGraph() {
return classGraph;
}
- public String getClassName(final boolean differentiateArray) {
+ protected String getClassName(final boolean differentiateArray) {
// this is needed for nested classes
- final String actualClassName = classFullyQualifiedName
- .replace('$', '.');
+ final String actualClassName = fullyQualifiedName.replace('$', '.');
String result;
if (isArray) {
// for arrays use array component instead of array class name
- result = arrayComponent.classFullyQualifiedName;
+ result = arrayComponent.fullyQualifiedName;
if (result.contains(".")) {
final int i = result.lastIndexOf('.');
result = result.substring(i + 1);
return result;
}
- public String getColor() {
- if (getDistinctiveColor() == null)
- setDistinctiveColor(Utils.getNextDarkColor());
+ protected String getColor() {
+ if (distinctiveReferenceColor == null)
+ distinctiveReferenceColor = Utils.getNextDarkColor();
- return getDistinctiveColor();
- }
-
- public String getDistinctiveColor() {
return distinctiveReferenceColor;
}
* Returns field with given name (case is ignored). Or <code>null</code> if
* field is not found.
*/
- public FieldDescriptor getFieldIgnoreCase(final String fieldToSearch) {
+ protected FieldDescriptor getFieldIgnoreCase(final String fieldToSearch) {
for (final String fieldName : nameToFieldMap.keySet())
if (fieldToSearch.equalsIgnoreCase(fieldName))
return null;
}
+ protected String getFullyQualifiedName() {
+ return fullyQualifiedName;
+ }
+
@Override
public String getGraphId() {
final String result = "class_"
- + classFullyQualifiedName.replace('.', '_').replace(";", "")
- .replace("[L", "").replace('$', '_');
+ + fullyQualifiedName.replace('.', '_').replace(";", "")
+ .replace("[L", "").replace('$', '_');
return result;
}
- public String getInterfaceColor() {
+ private String getInterfaceColor() {
if (interfaceColor == null)
interfaceColor = Utils.getNextDarkColor();
return interfaceColor;
}
- // public String getReadableName() {
- //
- // // do not print full class name for well known system classes
- // final String packageName = getPackageName();
- //
- // if (packageName.equals("java.util"))
- // return getClassName();
- //
- // if (packageName.equals("java.lang"))
- // return getClassName();
- //
- // return fullyQualifiedName;
- // }
-
private FieldDescriptor getOrCreateFieldDescriptor(final Field field) {
final String fieldName = field.getName();
return result;
}
- public String getPackageName() {
+ private String getPackageName() {
- final int i = classFullyQualifiedName.lastIndexOf('.');
+ final int i = fullyQualifiedName.lastIndexOf('.');
if (i == -1)
return "";
- return classFullyQualifiedName.substring(0, i).replace("[L", "");
+ return fullyQualifiedName.substring(0, i).replace("[L", "");
}
- public String getParentClassesName() {
- int i = classFullyQualifiedName.lastIndexOf('.');
- final String fullClassName = classFullyQualifiedName.substring(i + 1);
+ private String getParentClassesName() {
+ int i = fullyQualifiedName.lastIndexOf('.');
+ final String fullClassName = fullyQualifiedName.substring(i + 1);
i = fullClassName.lastIndexOf('$');
if (i == -1)
return parentClassesName.replace('$', '.');
}
- public String getSuperClassColor() {
+ private String getSuperClassColor() {
if (superClassColor == null)
superClassColor = Utils.getNextLightColor();
* Checks if class has field with given name (case is ignored). Returns
* <code>true</code> if such field is found.
*/
- public boolean hasFieldIgnoreCase(final String fieldToSearch) {
+ protected boolean hasFieldIgnoreCase(final String fieldToSearch) {
for (final String fieldName : nameToFieldMap.keySet())
if (fieldToSearch.equalsIgnoreCase(fieldName))
return false;
}
- public void hide() {
+ private void hide() {
isShown = false;
}
- public void hideClassIfNoReferences() {
+ protected void hideClassIfNoReferences() {
if (!isVisible())
return;
return;
}
- public void indexFields(final Field[] fields) {
+ private void indexFields(final Field[] fields) {
for (final Field field : fields)
getOrCreateFieldDescriptor(field);
}
@Override
public boolean isVisible() {
- if (Utils.isSystemDataType(classFullyQualifiedName))
+ if (Utils.isSystemDataType(fullyQualifiedName))
return false;
- if (Utils.isSystemPackage(classFullyQualifiedName))
+ if (Utils.isSystemPackage(fullyQualifiedName))
return false;
- if (!getClassGraph().getFilter().isClassShown(classFullyQualifiedName))
+ if (!getClassGraph().getFilter().isClassShown(fullyQualifiedName))
return false;
if (isArray)
if (arrayComponent != null)
- if (Utils
- .isSystemDataType(arrayComponent.classFullyQualifiedName))
+ if (Utils.isSystemDataType(arrayComponent.fullyQualifiedName))
// Do not show references to primitive data types in arrays.
// That is: there is no point to show reference to byte when
// we have class with byte array field.
/**
* Register event when another class is extending this one.
*/
- public void registerExtension() {
+ protected void registerExtension() {
extensionsCount++;
}
- public void registerImplementation() {
+ protected void registerImplementation() {
implementationsCount++;
}
- public void registerReference() {
+ protected void registerReference() {
referencesCount++;
}
- public void setDistinctiveColor(final String distinctiveColor) {
- distinctiveReferenceColor = distinctiveColor;
- }
}