01: package jdepend.framework;
02:
03: import java.util.*;
04:
05: /**
06: * The <code>JavaClass</code> class represents a Java
07: * class or interface.
08: *
09: * @author <b>Mike Clark</b>
10: * @author Clarkware Consulting, Inc.
11: */
12:
13: public class JavaClass {
14:
15: private String className;
16: private String packageName;
17: private boolean isAbstract;
18: private HashMap imports;
19: private String sourceFile;
20:
21: public JavaClass(String name) {
22: className = name;
23: packageName = "default";
24: isAbstract = false;
25: imports = new HashMap();
26: sourceFile = "Unknown";
27: }
28:
29: public void setName(String name) {
30: className = name;
31: }
32:
33: public String getName() {
34: return className;
35: }
36:
37: public void setPackageName(String name) {
38: packageName = name;
39: }
40:
41: public String getPackageName() {
42: return packageName;
43: }
44:
45: public void setSourceFile(String name) {
46: sourceFile = name;
47: }
48:
49: public String getSourceFile() {
50: return sourceFile;
51: }
52:
53: public Collection getImportedPackages() {
54: return imports.values();
55: }
56:
57: public void addImportedPackage(JavaPackage jPackage) {
58: if (!jPackage.getName().equals(getPackageName())) {
59: imports.put(jPackage.getName(), jPackage);
60: }
61: }
62:
63: public boolean isAbstract() {
64: return isAbstract;
65: }
66:
67: public void isAbstract(boolean isAbstract) {
68: this .isAbstract = isAbstract;
69: }
70:
71: public boolean equals(Object other) {
72:
73: if (other instanceof JavaClass) {
74: JavaClass otherClass = (JavaClass) other;
75: return otherClass.getName().equals(getName());
76: }
77:
78: return false;
79: }
80:
81: public int hashCode() {
82: return getName().hashCode();
83: }
84:
85: public static class ClassComparator implements Comparator {
86:
87: public int compare(Object a, Object b) {
88: JavaClass c1 = (JavaClass) a;
89: JavaClass c2 = (JavaClass) b;
90:
91: return c1.getName().compareTo(c2.getName());
92: }
93: }
94: }
|