01: /*
02: * Copyright (C) The MX4J Contributors.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the MX4J License version 1.0.
06: * See the terms of the MX4J License in the documentation provided with this software.
07: */
08:
09: package test.javax.management.compliance.signature.support;
10:
11: import java.lang.reflect.Modifier;
12: import java.util.ArrayList;
13: import java.util.Collections;
14:
15: /**
16: * @version $Revision: 1.3 $
17: */
18: public abstract class MemberWrapper {
19: protected int modifiers;
20: protected String type;
21: protected String name;
22: protected String toString;
23:
24: protected MemberWrapper() {
25: }
26:
27: public int hashCode() {
28: return toString().hashCode();
29: }
30:
31: public boolean equals(Object obj) {
32: if (obj == this )
33: return true;
34: if (obj == null)
35: return false;
36: return toString().equals(obj.toString());
37: }
38:
39: public String toString() {
40: if (toString == null) {
41: StringBuffer buffer = new StringBuffer(Modifier
42: .toString(modifiers)).append(" ");
43: buffer.append(type).append(" ");
44: buffer.append(name);
45: toString = buffer.toString();
46: }
47: return toString;
48: }
49:
50: protected ArrayList convert(Class[] classes, boolean sort) {
51: ArrayList list = new ArrayList();
52: for (int i = 0; i < classes.length; ++i) {
53: list.add(classes[i].getName());
54: }
55:
56: if (sort)
57: Collections.sort(list);
58:
59: return list;
60: }
61: }
|