Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/alicebot/server/core/util/ClassRegistry.java


1   // Decompiled by Jad v1.5.8c. Copyright 2001 Pavel Kouznetsov.
2   // Jad home page: http://www.geocities.com/kpdus/jad.html
3   // Decompiler options: packimports(3) 
4   
5   package org.alicebot.server.core.util;
6   
7   import java.lang.reflect.Field;
8   import java.util.Hashtable;
9   
10  // Referenced classes of package org.alicebot.server.core.util:
11  //            UserError, DeveloperError
12  
13  public abstract class ClassRegistry extends Hashtable
14  {
15  
16      public ClassRegistry(String s, String as[], String s1)
17      {
18          super(as.length);
19          version = s;
20          classesToRegister = as;
21          baseClassName = s1;
22          Class class1 = null;
23          try
24          {
25              class1 = Class.forName(s1);
26          }
27          catch(ClassNotFoundException classnotfoundexception)
28          {
29              throw new UserError("Could not find base class \"" + s1 + "\"!", classnotfoundexception);
30          }
31          for(int i = as.length; --i >= 0;)
32          {
33              Class class2;
34              try
35              {
36                  class2 = Class.forName(as[i]);
37              }
38              catch(ClassNotFoundException classnotfoundexception1)
39              {
40                  throw new UserError("\"" + as[i] + "\" is missing from your classpath.  Cannot initialize registry.", classnotfoundexception1);
41              }
42              if(!class1.isAssignableFrom(class2))
43                  throw new DeveloperError("Developer has incorrectly specified \"" + as[i] + "\" as a registrable class.");
44              Field field = null;
45              if(class2 != null)
46                  try
47                  {
48                      field = class2.getDeclaredField("label");
49                  }
50                  catch(NoSuchFieldException nosuchfieldexception)
51                  {
52                      throw new DeveloperError("Unlikely error: \"" + as[i] + "\" is missing label field!");
53                  }
54              else
55                  throw new DeveloperError("Failed to get processor \"" + as[i] + "\"");
56              String s2 = null;
57              try
58              {
59                  s2 = (String)field.get(null);
60              }
61              catch(IllegalAccessException illegalaccessexception)
62              {
63                  throw new DeveloperError("Label field for \"" + as[i] + "\" is not accessible!");
64              }
65              if(s2 != null)
66                  put(s2, class2);
67              else
68                  throw new DeveloperError("Tried to register class with null label!");
69          }
70  
71      }
72  
73      protected static String version;
74      protected static String classesToRegister[];
75      protected static String baseClassName;
76      private static final String LABEL = "label";
77  }