projects
/
javainspect.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Refactoring. API simplifications. Documentation updates.
[javainspect.git]
/
src
/
main
/
java
/
eu
/
svjatoslav
/
inspector
/
java
/
structure
/
FieldDescriptor.java
diff --git
a/src/main/java/eu/svjatoslav/inspector/java/structure/FieldDescriptor.java
b/src/main/java/eu/svjatoslav/inspector/java/structure/FieldDescriptor.java
old mode 100644
(file)
new mode 100755
(executable)
index
42ecfcf
..
7128c4e
--- a/
src/main/java/eu/svjatoslav/inspector/java/structure/FieldDescriptor.java
+++ b/
src/main/java/eu/svjatoslav/inspector/java/structure/FieldDescriptor.java
@@
-1,10
+1,10
@@
/*
* JavaInspect - Utility to visualize java software
/*
* JavaInspect - Utility to visualize java software
- * Copyright (C) 2013, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
- *
+ * Copyright (C) 2013
-2015
, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
+ *
* This program is free software; you can redistribute it and/or
* This program is free software; you can redistribute it and/or
- * modify it under the terms of version
2 of the GNU
General Public License
- * as published by the Free Software Foundation.
+ * modify it under the terms of version
3 of the GNU Lesser
General Public License
+ *
or later
as published by the Free Software Foundation.
*/
package eu.svjatoslav.inspector.java.structure;
*/
package eu.svjatoslav.inspector.java.structure;
@@
-15,34
+15,31
@@
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import java.util.ArrayList;
import java.util.List;
-public class FieldDescriptor implements GraphElement {
+/**
+ * This class corresponds to single field within a java class.
+ */
- /**
- * This class corresponds to single field within a java class.
- */
+public class FieldDescriptor implements GraphElement {
- public String name;
- public ClassDescriptor type;
- private ClassDescriptor parent;
- List<ClassDescriptor> typeArguments = new ArrayList<ClassDescriptor>();
+ private String name;
+ private ClassDescriptor type;
+ private final ClassDescriptor parentClass;
+ private final List<ClassDescriptor> typeArguments = new ArrayList<ClassDescriptor>();
+ private boolean isInherited;
- public FieldDescriptor(final Field field, final ClassDescriptor parent,
- final ClassGraph dump) {
+ public FieldDescriptor(final ClassDescriptor parent) {
+ parentClass = parent;
+ }
- this.parent = parent;
+ public void analyzeField(final Field field) {
if (!field.getDeclaringClass().getName()
if (!field.getDeclaringClass().getName()
- .equals(parent.fullyQualifiedName))
- // if field is inherited, do not index it
- return;
-
- // if (field.getType().isArray())
- // System.out.println("field name: " + field.getName());
-
- parent.nameToFieldMap.put(field.getName(), this);
+ .equals(parentClass.getFullyQualifiedName()))
+ isInherited = true;
name = field.getName();
name = field.getName();
- type = dump.addClass(field.getType());
+ type = parentClass.getClassGraph().getOrCreateClassDescriptor(
+ field.getType());
type.registerReference();
final Type genericType = field.getGenericType();
type.registerReference();
final Type genericType = field.getGenericType();
@@
-51,8
+48,8
@@
public class FieldDescriptor implements GraphElement {
for (final Type t : pt.getActualTypeArguments())
if (t instanceof Class) {
final Class cl = (Class) t;
for (final Type t : pt.getActualTypeArguments())
if (t instanceof Class) {
final Class cl = (Class) t;
- final ClassDescriptor genericTypeDescriptor =
dump
- .
addClass
(cl);
+ final ClassDescriptor genericTypeDescriptor =
parentClass
+ .
getClassGraph().getOrCreateClassDescriptor
(cl);
genericTypeDescriptor.registerReference();
typeArguments.add(genericTypeDescriptor);
}
genericTypeDescriptor.registerReference();
typeArguments.add(genericTypeDescriptor);
}
@@
-83,10
+80,10
@@
public class FieldDescriptor implements GraphElement {
// main type
boolean showLink = type.areReferencesShown();
// main type
boolean showLink = type.areReferencesShown();
- if (type == parent)
+ if (type == parent
Class
)
showLink = false;
showLink = false;
- if (parent.isEnum)
+ if (parent
Class
.isEnum)
showLink = false;
if (showLink)
showLink = false;
if (showLink)
@@
-106,7
+103,7
@@
public class FieldDescriptor implements GraphElement {
final StringBuffer result = new StringBuffer();
result.append(" // " + name + "\n");
final StringBuffer result = new StringBuffer();
result.append(" // " + name + "\n");
- if (parent
.isEnum && (type == parent
)) {
+ if (parent
Class.isEnum && (type == parentClass
)) {
result.append(" <TR><TD colspan=\"2\" PORT=\"" + name);
result.append("\" ALIGN=\"left\"><FONT POINT-SIZE=\"11.0\">");
result.append(name + "</FONT></TD></TR>\n");
result.append(" <TR><TD colspan=\"2\" PORT=\"" + name);
result.append("\" ALIGN=\"left\"><FONT POINT-SIZE=\"11.0\">");
result.append(name + "</FONT></TD></TR>\n");
@@
-123,22
+120,30
@@
public class FieldDescriptor implements GraphElement {
@Override
public String getGraphId() {
@Override
public String getGraphId() {
- return parent.getGraphId() + ":" + name;
+ return parent
Class
.getGraphId() + ":" + name;
}
}
- p
ublic
int getOutsideVisibleReferencesCount() {
+ p
rotected
int getOutsideVisibleReferencesCount() {
if (!isVisible())
return 0;
if (!isVisible())
return 0;
- if (type.isVisible())
- return 1;
+ if (type != null)
+ if (type.isVisible())
+ return 1;
return 0;
}
return 0;
}
+ protected ClassDescriptor getType() {
+ return type;
+ }
+
@Override
public boolean isVisible() {
@Override
public boolean isVisible() {
+ if (isInherited)
+ return false;
+
if (name.contains("$"))
return false;
if (name.contains("$"))
return false;
@@
-147,4
+152,5
@@
public class FieldDescriptor implements GraphElement {
return true;
}
return true;
}
+
}
\ No newline at end of file
}
\ No newline at end of file