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 import java.util.List;
20
21
22
23
24 public class CPSignature extends ConstantPoolEntry implements Comparable {
25
26 private final CPUTF8 signatureForm;
27 private final List<CPClass> classes;
28 private final String signature;
29 private final boolean formStartsWithBracket;
30
31 public CPSignature(final String signature, final CPUTF8 signatureForm, final List<CPClass> classes) {
32 this.signature = signature;
33 this.signatureForm = signatureForm;
34 this.classes = classes;
35 formStartsWithBracket = signatureForm.toString().startsWith("(");
36 }
37
38 @Override
39 public int compareTo(final Object arg0) {
40 if (signature.equals(((CPSignature) arg0).signature)) {
41 return 0;
42 }
43 if (formStartsWithBracket && !((CPSignature) arg0).formStartsWithBracket) {
44 return 1;
45 }
46 if (((CPSignature) arg0).formStartsWithBracket && !formStartsWithBracket) {
47 return -1;
48 }
49 if (classes.size() - ((CPSignature) arg0).classes.size() != 0) {
50 return classes.size() - ((CPSignature) arg0).classes.size();
51 }
52 if (classes.size() > 0) {
53 for (int i = classes.size() - 1; i >= 0; i--) {
54 final CPClass cpClass = classes.get(i);
55 final CPClass compareClass = ((CPSignature) arg0).classes.get(i);
56 final int classComp = cpClass.compareTo(compareClass);
57 if (classComp != 0) {
58 return classComp;
59 }
60 }
61 }
62 return signature.compareTo(((CPSignature) arg0).signature);
63 }
64
65 public List<CPClass> getClasses() {
66 return classes;
67 }
68
69 public int getIndexInCpUtf8() {
70 return signatureForm.getIndex();
71 }
72
73 public CPUTF8 getSignatureForm() {
74 return signatureForm;
75 }
76
77 public String getUnderlyingString() {
78 return signature;
79 }
80
81 @Override
82 public String toString() {
83 return signature;
84 }
85 }