⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ozoneclassloader.java

📁 用Java写的面相对象的数据库管理系统
💻 JAVA
字号:
// You can redistribute this software and/or modify it under the terms of// the Ozone Core License version 1 published by ozone-db.org.//// The original code and portions created by SMB are// Copyright (C) 1997-2000 by SMB GmbH. All rights reserved.//// $Id: OzoneClassLoader.java,v 1.3 2000/10/28 16:55:17 daniela Exp $package org.ozoneDB.core;import java.io.*;import org.ozoneDB.*;import org.ozoneDB.DxLib.*;/** * Ozone specific class loader. This compiles/runs with JDK 1.2 only. To make * it run with JDK 1.1 see CLassManager.classForName() method. *  *  * @author <a href="http://www.softwarebuero.de/">SMB</a> * @version $Revision: 1.3 $Date: 2000/10/28 16:55:17 $ */class OzoneClassLoader extends ClassLoader {        protected DxMap classTable;            public OzoneClassLoader() {        super();        flushCache();    }            protected void flushCache() {        classTable = new DxHashMap( 100 );    }             protected Class findClass( String name ) throws ClassNotFoundException {        if (name.startsWith( "java" )) {            throw new ClassNotFoundException( "I'm not here to load system classes." );        }                 StringBuffer resourceName = new StringBuffer( name );        for (int i = 0; i < resourceName.length(); i++) {            if (resourceName.charAt( i ) == '.') {                resourceName.setCharAt( i, '/' );            }         }         resourceName.append( ".class" );                InputStream classIn = getSystemClassLoader().getSystemResourceAsStream( resourceName.toString() );        if (classIn == null) {            throw new ClassNotFoundException( "Unable to locate resource." );        }                 try {            byte[] classBytes = new byte[classIn.available()];            classIn.read( classBytes );            classIn.close();            Class cl = defineClass( name, classBytes, 0, classBytes.length, null );            return cl;        } catch (Exception e) {            e.printStackTrace();            throw new ClassNotFoundException( e.toString() );        }     }             public Class loadClass( String name ) throws ClassNotFoundException {        return loadClass( name, false );    }             protected Class loadClass( String name, boolean resolve ) throws ClassNotFoundException {        if (name.startsWith( "java" )) {            return getSystemClassLoader().loadClass( name );        } else {            Class cl = (Class)classTable.elementForKey( name );            if (cl == null) {                cl = primitiveType( name );                if (cl == null) {                    // this really loads the requested class in this ClassLoader but cause                    // compatibility problems with already loaded classes                    //cl = findClass (name);                    //if (resolve)                    //    resolveClass (cl);                                        // this works around the compatibility problems but causes the reloadClasses()                    // method to not work                    cl = getSystemClassLoader().loadClass( name );                }                 classTable.addForKey( cl, name );            }             return cl;        }     }             /**     * Load primitive types with default class loader.     */    protected static Class primitiveType( String name ) {        if (name.equals( "int" )) {            return Integer.TYPE;        } else if (name.equals( "char" )) {            return Character.TYPE;        } else if (name.equals( "byte" )) {            return Byte.TYPE;        } else if (name.equals( "double" )) {            return Byte.TYPE;        } else if (name.equals( "float" )) {            return Byte.TYPE;        } else if (name.equals( "long" )) {            return Long.TYPE;        } else if (name.equals( "short" )) {            return Short.TYPE;        } else if (name.equals( "boolean" )) {            return Boolean.TYPE;        } else {            return null;        }     }     }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -