01: // $Id: ClassMap.java,v 1.4 2005/08/08 14:58:32 belaban Exp $
02:
03: package org.jgroups.conf;
04:
05: import org.jgroups.util.Util;
06:
07: /**
08: * Maintains mapping between magic number and class
09: *
10: * @author Filip Hanik (<a href="mailto:filip@filip.net">filip@filip.net)
11: * @version 1.0
12: */
13: public class ClassMap {
14: private final String mClassname;
15: private final String mDescription;
16: private final boolean mPreload;
17: private final int mMagicNumber;
18:
19: public ClassMap(String clazz, String desc, boolean preload,
20: int magicnumber) {
21: mClassname = clazz;
22: mDescription = desc;
23: mPreload = preload;
24: mMagicNumber = magicnumber;
25: }
26:
27: public int hashCode() {
28: return getMagicNumber();
29: }
30:
31: public String getClassName() {
32: return mClassname;
33: }
34:
35: public String getDescription() {
36: return mDescription;
37: }
38:
39: public boolean getPreload() {
40: return mPreload;
41: }
42:
43: public int getMagicNumber() {
44: return mMagicNumber;
45: }
46:
47: /**
48: * Returns the Class object for this class<BR>
49: */
50: public Class getClassForMap() throws ClassNotFoundException {
51: return Util.loadClass(getClassName(), this .getClass());
52: }
53:
54: public boolean equals(Object another) {
55: if (another instanceof ClassMap) {
56: ClassMap obj = (ClassMap) another;
57: return getClassName().equals(obj.getClassName());
58: } else
59: return false;
60: }
61:
62: }
|