1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.compress.harmony.pack200;
18
19
20
21
22 public class CPMethodOrField extends ConstantPoolEntry implements Comparable {
23
24 private final CPClass className;
25 private final CPNameAndType nameAndType;
26 private int indexInClass = -1;
27 private int indexInClassForConstructor = -1;
28
29 public CPMethodOrField(final CPClass className, final CPNameAndType nameAndType) {
30 this.className = className;
31 this.nameAndType = nameAndType;
32 }
33
34 @Override
35 public int compareTo(final Object obj) {
36 if (obj instanceof CPMethodOrField) {
37 final CPMethodOrField mof = (CPMethodOrField) obj;
38 final int compareName = className.compareTo(mof.className);
39 if (compareName == 0) {
40 return nameAndType.compareTo(mof.nameAndType);
41 }
42 return compareName;
43 }
44 return 0;
45 }
46
47 public int getClassIndex() {
48 return className.getIndex();
49 }
50
51 public CPClass getClassName() {
52 return className;
53 }
54
55 public CPNameAndType getDesc() {
56 return nameAndType;
57 }
58
59 public int getDescIndex() {
60 return nameAndType.getIndex();
61 }
62
63 public int getIndexInClass() {
64 return indexInClass;
65 }
66
67 public int getIndexInClassForConstructor() {
68 return indexInClassForConstructor;
69 }
70
71 public void setIndexInClass(final int index) {
72 indexInClass = index;
73 }
74
75 public void setIndexInClassForConstructor(final int index) {
76 indexInClassForConstructor = index;
77 }
78
79 @Override
80 public String toString() {
81 return className + ": " + nameAndType;
82 }
83
84 }