- newFieldDescriptor.analyzeField(field);
-
- return newFieldDescriptor;
- }
-
- private int getOutgoingReferencesCount() {
- int result = 0;
-
- // count method references
- for (final MethodDescriptor methodDescriptor : methods)
- result += methodDescriptor.getOutsideVisibleReferencesCount();
-
- // count field references
- for (final FieldDescriptor fieldDescriptor : nameToFieldMap.values())
- result += fieldDescriptor.getOutsideVisibleReferencesCount();
-
- // count implemented interfaces
- for (final ClassDescriptor classDescriptor : interfaces)
- if (classDescriptor.isVisible())
- result++;
-
- // count superclass
- if (superClass != null)
- if (superClass.isVisible())
- result++;
-
- return result;
- }
-
- private String getPackageName() {
-
- final int i = fullyQualifiedName.lastIndexOf('.');
-
- if (i == -1)
- return "";
-
- return fullyQualifiedName.substring(0, i).replace("[L", "");
- }
-
- private 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('$', '.');
- }
-
- private String getSuperClassColor() {
- if (superClassColor == null)
- superClassColor = Utils.getNextLightColor();
-
- return superClassColor;
- }
-
- /**
- * Checks if class has field with given name (case is ignored). Returns
- * <code>true</code> if such field is found.
- */
- protected boolean hasFieldIgnoreCase(final String fieldToSearch) {
-
- for (final String fieldName : nameToFieldMap.keySet())
- if (fieldToSearch.equalsIgnoreCase(fieldName))
- return true;
-
- return false;
- }
-
- private void hide() {
- isShown = false;
- }
-
- protected void hideClassIfNoReferences() {
- if (!isVisible())
- return;
-
- final int totalReferencesCount = getOutgoingReferencesCount()
- + referencesCount + extensionsCount + implementationsCount;
-
- if (totalReferencesCount == 0) {
- hide();
- return;
- }
-
- return;
- }
-
- private void indexFields(final Field[] fields) {
- for (final Field field : fields)
- getOrCreateFieldDescriptor(field);
- }
-
- private void indexMethods(final Class<? extends Object> clazz) {
- for (final Method method : clazz.getMethods()) {
- final MethodDescriptor methodDescriptor = new MethodDescriptor(
- this, method.getName());
-
- methods.add(methodDescriptor);
-
- methodDescriptor.analyze(method);
- }
-
- }
-
- @Override
- public boolean isVisible() {
-
- if (Utils.isSystemDataType(fullyQualifiedName))
- return false;
-
- if (Utils.isSystemPackage(fullyQualifiedName))
- return false;
-
- if (!getClassGraph().getFilter().isClassShown(fullyQualifiedName))
- return false;
-
- if (isArray)
- if (arrayComponent != null)
- 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.
- return false;
-
- return isShown;
- }
-
- /**
- * Register event when another class is extending this one.
- */
- protected void registerExtension() {
- extensionsCount++;
- }
-
- protected void registerImplementation() {
- implementationsCount++;
- }
-
- protected void registerReference() {
- referencesCount++;
- }