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

📄 ifhelper.java

📁 用Java写的面相对象的数据库管理系统
💻 JAVA
字号:
// You can redistribute this software and/or modify it under the terms of// the Ozone Library 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: IfHelper.java,v 1.9 2000/10/28 16:55:20 daniela Exp $package org.ozoneDB.tools.OPP;import java.io.*;import java.lang.reflect.*;//import org.apache.regexp.*;import org.ozoneDB.DxLib.*;/** * Helper class that allows to parse the Java source code of interface files * to find out extra class information. *  *  * @author <a href="http://www.softwarebuero.de/">SMB</a> * @version $Revision: 1.9 $Date: 2000/10/28 16:55:20 $ */class IfHelper {        protected Class cl;        protected Class dbInterface;        protected boolean quiet;        protected Object re;        protected String outputDir;        /**     * Names of update methods as Strings.     */    protected DxHashMap updateMethodsIf = new DxHashMap();            public IfHelper( Class _cl, String _outputDir, boolean _quiet ) {        cl = _cl;        outputDir = _outputDir;        quiet = _quiet;    }            /**     * Search all remote interfaces (implement OzoneRemote) for update methods.     */    public void searchUpdateMethods( DxHashMap updateMethodsIf ) throws Exception {        Class dbRemote = Class.forName( "org.ozoneDB.OzoneRemote" );        Class[] ifs = cl.getInterfaces();        for (int i = 0; i < ifs.length; i++) {            if (dbRemote.isAssignableFrom( ifs[i] ) && !dbRemote.equals( ifs[i] )) {                searchUpdateMethods( ifs[i], updateMethodsIf );            }         }     }             /**     * Search all methods that are marked in the source code of the remote     * Java interface.     */    public void searchUpdateMethods( Class dbInterface, DxHashMap updateMethodsIf ) throws Exception {                Object re = OPPHelper.newRE( OPP.UPDATE_SIGN, true );        Object mre = OPPHelper.newRE( OPP.METHOD_PATTERN, false );                //search *.java source in current and in output directory        String sourceName = OPPHelper.rawClassName( dbInterface ) + ".java";                if (!quiet) {            System.out.print( "      trying to process " + sourceName + "... " );        }                 if (!new File( sourceName ).exists()) {            sourceName = outputDir + OPPHelper.rawClassName( dbInterface ) + ".java";            if (!new File( sourceName ).exists()) {                if (!quiet) {                    System.out.println( " no interface file found." );                }                 return;            }         }                 if (!quiet) {            System.out.println( "(" + sourceName + ")" );        }                 LineNumberReader in = new LineNumberReader( new FileReader( sourceName ) );        String line = in.readLine();        while (line != null) {            // System.out.println (line);            boolean isUpdate = OPPHelper.reSearch( re, line, 0, 0 ) != null;            String match = OPPHelper.reSearch( mre, line, 0, 1 );            // if (isUpdate)            //     System.out.println ("UPDATE: method=" + match);                        if (match != null && isUpdate) {                String methodName = match;                // System.out.println ("method: " + methodName);                updateMethodsIf.addForKey( methodName, methodName );            } else if (match == null && isUpdate) {                OPPHelper.warnMsg( OPPHelper.rawClassName( dbInterface ) + ".java", in.getLineNumber(),                        "Unable to determine method name." );            } else {                if (match != null && !isUpdate) {                    String methodName = match;                    if (updateMethodsIf.contains( methodName )) {                        OPPHelper.warnMsg( OPPHelper.rawClassName( dbInterface ) + ".java", in.getLineNumber(),                                "All '" + methodName + "' methods will be marked as update methods." );                    }                 }             }             line = in.readLine();        }         in.close();    }     }

⌨️ 快捷键说明

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