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

📄 dbconfig.java

📁 数据挖掘的工具代码(包含fp-tree,appriory
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/*ARMiner - Association Rules MinerCopyright (C) 2000  UMass/Boston - Computer Science DepartmentThis program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2 of the License, or (atyour option) any later version.This program is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USAThe ARMiner Server was written by Dana Cristofor and LaurentiuCristofor.The ARMiner Client was written by Abdelmajid Karatihy, Xiaoyong Kuang,and Lung-Tsung Li.The ARMiner package is currently maintained by Laurentiu Cristofor(laur@cs.umb.edu).*/import java.util.*;import java.io.*;/**   DBConfig.java<P>   DBConfig will keep the information related to users, groups,    algorithms, and databases and will provide locking mechanisms    in view of being used in a multithreaded environment.<P>   *//*     This file is a part of the ARMiner project.      (P)1999-2000 by ARMiner Server Team:   Dana Cristofor   Laurentiu Cristofor*/public class DBConfig implements Serializable{  public static final int ADD_NEW_GROUPS          = 1;  public static final int ADD_NEW_ALGORITHMS      = 2;  public static final int ADD_NEW_DATABASES       = 4;  public static final int CACHE_NOT_CREATED       = 0;  public static final int CACHE_INITIAL_CREATION  = 1;  public static final int CACHE_CREATED           = 2;  public static final int CACHE_IN_CREATION       = 3;  private static final int ADMIN_GID      = 0;  private static final int ALL_GID        = 1;  private static final int ADMIN_UID      = 0;  private static final int ANONYMOUS_UID  = 1;  private static final int FIRST_FREE_UID  = 2;  private static final int FIRST_FREE_GID  = 2;  private static final int FIRST_FREE_AID  = 2;  private static final int FIRST_FREE_DBID = 1;  public static final String CONFIG_FILE          = "arminer.cfg";  // inner classes for group, user, algorithm and database informations  // group informations  class Group implements Serializable  {    int    gid;    String name;    int    uid; //owner    Group(int gid, String name, int uid)    {      this.gid  = gid;      this.name = name;      this.uid  = uid; //owner    }    public String toString()    {      return new StringBuffer().append('<').append(gid).append(" ").append(name).append(" ").append(uid).append('>').toString();    }  }  // user informations  class User implements Serializable, Cloneable  {    int     uid;    String  name;    String  password;    long    permissions;    int     countLogged;    boolean toBeDeleted;    User(int uid, String name, String password, long permissions)    {      this.uid         = uid;      this.name        = name;      this.password    = password;      this.permissions = permissions;      countLogged      = 0;      toBeDeleted      = false;    }    public String toString()    {      return new StringBuffer().append('<').append(uid).append(" ").append(name).append(" ").append(password).append(" ").append(permissions).append(" ").append(countLogged).append(" ").append(toBeDeleted).append('>').toString();    }    public Object clone()      throws CloneNotSupportedException    {      return super.clone();    }  }  // user - group association  class UserGroup implements Serializable  {    int uid;    int gid;    UserGroup(int uid, int gid)    {      this.uid = uid;      this.gid = gid;    }    public String toString()    {      return new StringBuffer().append('<').append(uid).append(" ").append(gid).append('>').toString();    }  }  // algorithm informations  class Algorithm implements Serializable  {    int     aid;    String  name;    int     uid; // owner    int     gid;    int     countUsage;    boolean toBeDeleted;    Algorithm(int aid, String name, int uid, int gid)    {      this.aid    = aid;      this.name   = name;      this.uid    = uid;      this.gid    = gid;      countUsage  = 0;      toBeDeleted = false;    }    public String toString()    {      return new StringBuffer().append('<').append(aid).append(" ").append(name).append(" ").append(uid).append(" ").append(gid).append(" ").append(countUsage).append(" ").append(toBeDeleted).append('>').toString();    }  }  //database informations  class Database implements Serializable  {    int     dbid;    String  name;    int     uid; // owner    int     gid;    int     countUsage;    boolean toBeDeleted;    int     cacheStatus;    double  cacheSupport;    Database(int dbid, String name, int uid, int gid)    {      this.dbid    = dbid;      this.name    = name;      this.uid     = uid;      this.gid     = gid;      countUsage   = 0;      toBeDeleted  = false;      cacheStatus  = CACHE_NOT_CREATED;      cacheSupport = 0.0;    }    public String toString()    {      return new StringBuffer().append('<').append(dbid).append(" ").append(name).append(" ").append(uid).append(" ").append(gid).append(" ").append(countUsage).append(" ").append(toBeDeleted).append(" ").append(cacheStatus).append(" ").append(cacheSupport).append('>').toString();    }  }  // global configuration informations  class Global implements Serializable  {    int nextUID;    int nextGID;    int nextAID;    int nextDBID;      Global()    {      nextUID  = 0;      nextGID  = 0;      nextAID  = 0;      nextDBID = 0;    }  }  // used for returning more information by different methods  static class ID  {    int id;    int index; // the index in the Vector        ID(int id, int index)    {      this.id    = id;      this.index = index;    }  }  // private system data  /**    * @serial   */  private Vector groups;  /**    * @serial   */  private Vector users;  /**    * @serial   */  private Vector usersGroups;  /**    * @serial   */  private Vector algorithms;  /**    * @serial   */  private Vector databases;    // private configuration data  /**    * @serial   */  private Global globalInfo;  // THE DBConfig !  /**    * @serial   */  private static DBConfig dbconfig = null;     // private constructor  private DBConfig()  {    // create the global info object    globalInfo = new Global();    // create the first two groups, "admin" and "all"    groups = new Vector();        // the "admin" group has gid equal to ADMIN_GID    // and the owner is the ADMIN_UID    groups.add(new Group(ADMIN_GID, "admin", ADMIN_UID));    // the "all" group has gid equal to ALL_GID    // and the owner is the ADMIN_UID    groups.add(new Group(ALL_GID, "all", ADMIN_UID));    // adjust the nextGID in the global info object    globalInfo.nextGID = FIRST_FREE_GID;    // create the first two users, the admin and anonymous    users = new Vector();    // the "admin" user has all the permissions, can create    // new groups, algorithms and databases    users.add(new User(ADMIN_UID, "admin", "renimra", 		       ADD_NEW_GROUPS | ADD_NEW_ALGORITHMS 		       | ADD_NEW_DATABASES));    // the "anonymous" user has no permission to create    // new resources on the system    users.add(new User(ANONYMOUS_UID, "anonymous", "", 0));    // adjust the nextUID in the global info object    globalInfo.nextUID = FIRST_FREE_UID;    // create the user - group associations    usersGroups = new Vector();        // the user "admin" belongs to the group "admin"    usersGroups.add(new UserGroup(ADMIN_UID, ADMIN_GID));    // the user "anonymous" belongs to the group "all"    usersGroups.add(new UserGroup(ANONYMOUS_UID, ALL_GID));    // create the list of algorithms    algorithms = new Vector();    // create the list of databases    databases  = new Vector();    // This part will be deleted from the final version    // add the algorithm ''Apriori'', with aid 0, owner ADMIN_UID    // and gid ALL_GID    algorithms.add(new Algorithm(0, "Apriori", ADMIN_UID, ALL_GID));    // add the algorithm ''Closure'', with aid 1, owner ADMIN_UID    // and gid ALL_GID    algorithms.add(new Algorithm(1, "Closure", ADMIN_UID, ALL_GID));    // add the database "csc.db", with dbid 0, owner ADMIN_UID    // and gid ALL_GID    databases.add(new Database(0, "csc.db", ADMIN_UID, ALL_GID));  }    // private methods  // returns the next available user id  private int getNextUID()  {    int i;    int id = globalInfo.nextUID;    // check if it is in use    while (true)      {	for (i = 0; i < users.size(); i++)	  if (((User)users.get(i)).uid == id) 	    break;		// id is not in use	if (i == users.size())	  {	    globalInfo.nextUID++;	    if (globalInfo.nextUID < 0)	      globalInfo.nextUID = FIRST_FREE_UID;	    return id;	  }	// id is in use	else	  id = ++globalInfo.nextUID;      }  }  // returns the next available group id  private int getNextGID()  {    int i;    int id = globalInfo.nextGID;    // check if it is in use    while (true)      {	for (i = 0; i < groups.size(); i++)	  if (((Group)groups.get(i)).gid == id) 	    break;	// id is not in use	if (i == groups.size())	  {	    globalInfo.nextGID++;	    if( globalInfo.nextGID < 0 )	      globalInfo.nextGID = FIRST_FREE_GID;	    return id;	  }	// id is in use	else	  id = ++globalInfo.nextGID;      }  }  // returns the next available algorithm id  private int getNextAID()  {    int i;    int id = globalInfo.nextAID;    // check if it is in use    while (true)      {	for (i = 0; i < algorithms.size(); i++)	  if (((Algorithm)algorithms.get(i)).aid == id) 	    break;		// id is not in use	if (i == algorithms.size())	  {	    globalInfo.nextAID++;	    if ( globalInfo.nextAID < 0 )	      globalInfo.nextAID = FIRST_FREE_AID;	    return id;	  }	// id is in use	else	  id = ++globalInfo.nextAID;      }  }  // returns the next available database id  private int getNextDBID()  {    int i;    int id = globalInfo.nextDBID;    // check if it is in use    while (true)      {	for (i = 0; i < databases.size(); i++)	  if (((Database)databases.get(i)).dbid == id) 	    break;	// id is not in use	if (i == databases.size())	  {	    globalInfo.nextDBID++;	    if ( globalInfo.nextDBID < 0 )	      globalInfo.nextDBID = FIRST_FREE_DBID;	    return id;	  }	// id is in use

⌨️ 快捷键说明

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