01: // You can redistribute this software and/or modify it under the terms of
02: // the Ozone Core License version 1 published by ozone-db.org.
03: //
04: // The original code and portions created by SMB are
05: // Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
06: //
07: // $Id: OzoneClassLoader11.java,v 1.1 2001/12/18 10:31:30 per_nyfelt Exp $
08:
09: package org.ozoneDB.core;
10:
11: import java.io.*;
12: import org.ozoneDB.*;
13: import org.ozoneDB.DxLib.*;
14:
15: /**
16: * Ozone specific class loader. This compiles/runs with JDK 1.1 only.
17: *
18: *
19: * @author <a href="http://www.softwarebuero.de/">SMB</a>
20: * @version $Revision: 1.1 $Date: 2001/12/18 10:31:30 $
21: */
22: class OzoneClassLoader11 extends ClassLoader {
23:
24: protected DxMap classTable;
25:
26: public OzoneClassLoader11() {
27: super ();
28: classTable = new DxHashMap(100);
29: }
30:
31: protected void flushCache() {
32: }
33:
34: public Class loadClass(String name) throws ClassNotFoundException {
35: return loadClass(name, false);
36: }
37:
38: public Class loadClass(String name, boolean resolve)
39: throws ClassNotFoundException {
40: Class cl = (Class) classTable.elementForKey(name);
41: if (cl == null) {
42: cl = primitiveType(name);
43: if (cl == null) {
44: cl = Class.forName(name);
45: }
46: classTable.addForKey(cl, name);
47: }
48: return cl;
49: }
50:
51: /**
52: * Load primitive types with default class loader.
53: */
54: protected static Class primitiveType(String name) {
55: if (name.equals("int")) {
56: return Integer.TYPE;
57: } else if (name.equals("char")) {
58: return Character.TYPE;
59: } else if (name.equals("byte")) {
60: return Byte.TYPE;
61: } else if (name.equals("double")) {
62: return Byte.TYPE;
63: } else if (name.equals("float")) {
64: return Byte.TYPE;
65: } else if (name.equals("long")) {
66: return Long.TYPE;
67: } else if (name.equals("short")) {
68: return Short.TYPE;
69: } else if (name.equals("boolean")) {
70: return Boolean.TYPE;
71: } else {
72: return null;
73: }
74: }
75:
76: }
|