KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgroups > conf > ClassMap


1 // $Id: ClassMap.java,v 1.3 2005/04/23 12:44:05 belaban Exp $
2

3 package org.jgroups.conf;
4
5
6 /**
7  * Maintains mapping between magic number and class
8  *
9  * @author Filip Hanik (<a HREF="mailto:filip@filip.net">filip@filip.net)
10  * @version 1.0
11  */

12 public class ClassMap {
13     private final String JavaDoc mClassname;
14     private final String JavaDoc mDescription;
15     private final boolean mPreload;
16     private final int mMagicNumber;
17
18     public ClassMap(String JavaDoc clazz,
19                     String JavaDoc desc,
20                     boolean preload,
21                     int magicnumber) {
22         mClassname=clazz;
23         mDescription=desc;
24         mPreload=preload;
25         mMagicNumber=magicnumber;
26     }
27
28     public int hashCode() {
29         return getMagicNumber();
30     }
31
32     public String JavaDoc getClassName() {
33         return mClassname;
34     }
35
36     public String JavaDoc getDescription() {
37         return mDescription;
38     }
39
40     public boolean getPreload() {
41         return mPreload;
42     }
43
44     public int getMagicNumber() {
45         return mMagicNumber;
46     }
47
48
49     /**
50      * Returns the Class object for this class<BR>
51      */

52     public Class JavaDoc getClassForMap() throws ClassNotFoundException JavaDoc {
53         return Thread.currentThread().getContextClassLoader().loadClass(getClassName());
54     }
55
56
57     public boolean equals(Object JavaDoc another) {
58         if(another instanceof ClassMap) {
59             ClassMap obj=(ClassMap)another;
60             return getClassName().equals(obj.getClassName());
61         }
62         else
63             return false;
64     }
65
66
67 }
68
Popular Tags