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

📄 databasescripts.java

📁 java 写的一个新闻发布系统
💻 JAVA
字号:
// $Id: DatabaseScripts.java,v 1.3 2002/07/19 16:17:19 pmartin Exp $////                                   ____.//                       __/\ ______|    |__/\.     _______//            __   .____|    |       \   |    +----+       \//    _______|  /--|    |    |    -   \  _    |    :    -   \_________//   \\______: :---|    :    :           |    :    |         \________>//           |__\---\_____________:______:    :____|____:_____\//                                      /_____|////              . . . i n   j a h i a   w e   t r u s t . . .//////  DatabaseScripts////  30.03.2001  AK  added in jahia.//  01.04.2001  AK  change the package.//package org.jahia.admin.database;import java.io.*;import java.util.*;import org.jahia.bin.*;/** * desc:  This class is used by the installation and the administration * to get all informations required from database scripts, like msaccess.script * or hypersonic.script, from the jahia database script path (a jahiafiles * subfolder). * * Copyright:    Copyright (c) 2002 * Company:      Jahia Ltd * * @author Alexandre Kraft * @version 1.0 */public class DatabaseScripts{    /**	 * Default constructor.	 * @author  Alexandre Kraft	 */    public DatabaseScripts()    {        // do nothing :o)    } // end constructor    /**     * Get an enumeration containing all the database scripts in File objects     * from the jahia database scripts path.     * @author  Alexandre Kraft     *     * @return  Enumeration containing all scripts in File objects.     */    public Enumeration getDatabaseScriptsFileObjects()    throws IOException    {        File   scriptsFolderFileObject =  new File( Jahia.jahiaDatabaseScriptsPath );        File[] scriptsListFileArray    =  scriptsFolderFileObject.listFiles();        Vector scriptsListVector       =  new Vector();        for(int i=0; i<scriptsListFileArray.length; i++) {            if(!scriptsListFileArray[i].isDirectory()) {                if (scriptsListFileArray[i].getName().endsWith(".script")) {                    scriptsListVector.add( scriptsListFileArray[i] );                }            }        }        return scriptsListVector.elements();    } // getDatabaseScriptsFileObjects    /**     * Get a vector containing all database scripts informations in four-entry     * HashMap's. These HashMap contains the script name, script username,     * script password and script driver for each database.     * @author  Alexandre Kraft     *     * @param   fileObjects   Enumeration containing all scripts File objects.     * @return  Vector containing all scripts infos in HashMap.     */    public Vector getDatabaseScriptsInfos( Enumeration fileObjects )    throws IOException    {        Vector scriptsInfosVector  = new Vector();        while(fileObjects.hasMoreElements())        {            File            scriptFileObject  = (File) fileObjects.nextElement();            FileInputStream scriptInputStream = new FileInputStream(scriptFileObject.getPath());            Properties      scriptProperties  = new Properties();            scriptProperties.load( scriptInputStream );            Enumeration scriptPropertiesEnum  = scriptProperties.propertyNames();            HashMap     scriptPropertiesHash  = new HashMap();            while(scriptPropertiesEnum.hasMoreElements())            {                String scriptPropertyName  = (String) scriptPropertiesEnum.nextElement();                try {                    if(scriptPropertyName.substring(0,6).equals("jahia.")) {                        scriptPropertiesHash.put(scriptPropertyName, scriptProperties.getProperty(scriptPropertyName));                    }                } catch (IndexOutOfBoundsException ioobe) {                    // this property-name length is smaller than 6 characters. do nothing.                }            }            if(scriptPropertiesHash.size() == 5) {                scriptPropertiesHash.put("jahia.database.script", scriptFileObject.getName());                scriptsInfosVector.add(scriptPropertiesHash);            }        }        return scriptsInfosVector;    } // getDatabaseScriptsInfos    /**     * Get a enumeration containing all lines of the sql runtime from a     * database script. This database script is getted in parameter like     * a File object. The method use the BufferedReader object on a     * FileReader object instanciate on the script file name.     * @author  Alexandre Kraft     *     * @param   fileObject   File object of the database script file.     * @return  Enumeration containing all lines of the database script.     */    public Enumeration getDatabaseScriptsRuntime( File fileObject )    throws IOException    {        Vector scriptsRuntimeVector  = new Vector();        BufferedReader  buffered     = new BufferedReader( new FileReader(fileObject.getPath()) );        String          buffer       = "";        while((buffer = buffered.readLine()) != null)        {            if(buffer.trim().length() > 0) {                if(!buffer.trim().substring(0,1).equals("#")) {                    try {                        if(!buffer.trim().substring(0,6).equals("jahia.")) {                            scriptsRuntimeVector.add(buffer);                        }                    } catch (IndexOutOfBoundsException ioobe) {                        // this property-name length is smaller than 6 characters. do nothing.                    }                }            }        }        buffered.close();        return scriptsRuntimeVector.elements();    } // getDatabaseScriptsRuntime} // end DatabaseScripts

⌨️ 快捷键说明

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