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

📄 bluserconffile.java

📁 一个日本流行的,功能较全的开源Web办公管理(Groupware)系统。
💻 JAVA
字号:
package jp.co.sjts.gsession.bulletin;

import java.io.File;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.Properties;
import java.util.StringTokenizer;
import java.util.Iterator;
import java.util.Set;
import java.util.HashSet;
import jp.co.sjts.gsession.tools.*;

/**
 * <p>宖帵斅偺屄恖愝掕僼傽僀儖娗棟梡
 *
 * @author   Masakatu O   &lt;ookubo@sjts.co.jp&gt;
 * @author   Satoru K
 */
public class BLUserConfFile extends GSTextFile{

	/** 儊僀儞侾儁乕僕昞帵峴悢 */
	private int Display;
	/** 宖帵斅侾儁乕僕昞帵峴悢 */
	private int Dispcnt;
	/** */
    private int[] gids;
	/** */
    private Set Groups;
	/** 侾儁乕僕昞帵峴悢 */
	private int[] ken = {10,20,30,40,50} ;
	/** */
	public final static String FILENAME = BLCmd.USERFILENAME;
	/** */
	public final static String DIR = GSFilename.GS_DIR_USER + File.separator ;
	/** */
    public final static String GROUPS = "groups";
	/** */
	private Properties properties=null;
	/** */
	private File file;

	/**
	 *
	 */
	public synchronized int GetDisplay() {
		return Display;
	}

	/**
	 *
	 */
	public synchronized int GetDisplayMax() {
		return ken[Display];
	}

	/**
	 *
	 */
	public synchronized int GetDispcnt() {
		return Dispcnt;
	}

	/**
	 *
	 */
	public synchronized int GetDispcntMax() {
		return ken[Dispcnt];
	}

	/**
	 *
	 */
	public synchronized void SetDisplay(int display) {
		Display = display;
	}

	/**
	 *
	 */
	public synchronized void SetDisplay(String display) {
		Display = Integer.parseInt(display);
	}

	/**
	 *
	 */
	public synchronized void SetDispcnt(int dispcnt) {
		Dispcnt = dispcnt;
	}

	/**
	 *
	 */
	public synchronized void SetDispcnt(String dispcnt) {
		Dispcnt = Integer.parseInt(dispcnt);
	}
    
    /* 2002/04/09 add by a.matsubara ------------------------------------------------------------- */
	/**
	 *
	 */
    public synchronized void AddGroup(int GID) {
		Groups.add(new Integer(GID));
	}

	/**
	 *
	 */
    public synchronized void DelGroup(int GID) {
		Groups.remove(new Integer(GID));
	}

	/**
	 *
	 */
    public synchronized Iterator GetGroupIterator() {
		return Groups.iterator();
	}

	/**
	 *
	 */
    public synchronized boolean containsGroup(int GID) {
		return Groups.contains(new Integer(GID));
	}

    /* ------------------------------------------------------------------------------------------- */

	/**
	 *
	 */
	public BLUserConfFile(String BulletinDir,String UserId) throws GSException{
		properties = System.getProperties();
		String UserDir = BulletinDir + DIR + UserId ;
		UserDir = UserDir.replace('/',this.properties.getProperty("file.separator").charAt(0));

		File file1 = new File(UserDir);

		if(!file1.exists())		// 僼傽僀儖偑懚嵼偡傞偐
			file1.mkdirs();		// 僼傽僀儖偑懚嵼偟側偄応崌偼丄嶌惉傪帋傒傞

        this.file = new File(UserDir, getFilename());

        Groups = new HashSet(10);

		if(!file.exists()) {				// 僼傽僀儖偑側偄応崌偼丄僨僼僅儖僩抣偱嶌惉
            SetDisplay(0);
            Save();
		}
	}
	
    /* 2002/04/09 add by a.matsubara ------------------------------------------------------------ */

	/**
	 *
	 */
    protected String getFilename(){
    	return FILENAME;
    }
    

	/**
	 *
	 */
    public boolean exists(){
    	if(file==null)
        	return false;
        
        return file.exists();
    }
    

	/**
	 *
	 */
    public boolean delete(){
    	if(file==null)
        	return false;
        
        try{
        	return file.delete();
        } catch(SecurityException e) {
        }
        return false;
    }
    

	/**
	 *
	 */
    public int[] GetGroupArray(){
    	int gid[] = new int[Groups.size()];
        Iterator it = GetGroupIterator();
        for( int i=0; it.hasNext(); i++ )
        	gid[i] = ( (Integer)it.next() ).intValue();
        return gid;
    }
    

	/**
	 *
	 */
    public boolean existGroup(int GID){
    	boolean ret = false;
        Iterator it = Groups.iterator();
        while(it.hasNext())
        {
        	Integer i = (Integer)it.next();
            if( GID==i.intValue() )
            	ret = true;
        }
        return ret;
    }
    /* ------------------------------------------------------------------------------------------ */


	/**
	 * <p>僼傽僀儖僆僽僕僃僋僩傪庢摼偟傑偡丅
	 *
	 * @return 僼傽僀儖僆僽僕僃僋僩
	 */
	synchronized protected File GetFile(){
		return file;
	}

	/**
	 * <p>僼傽僀儖偵儔僀僩偟傑偡丅
	 * <p>偙偺Write儊僜僢僪傪捈愙巊梡偡傞偙偲偼偁傝傑偣傫丅Save儊僜僢僪偐傜屇傃弌偝傟傑偡丅
	 * <BR>僥儞僾儗乕僩儊僜僢僪僷僞乕儞
	 *
	 * @param pw PrintWriter僆僽僕僃僋僩
	 */
	synchronized protected void Write(PrintWriter pw) throws GSException{
		pw.println("display=" + Integer.toString(GetDisplay()));
		pw.println("dispcnt=" + Integer.toString(GetDispcnt()));
        
        String buf = new String(GROUPS + "=");
        Iterator it = Groups.iterator();
        while(it.hasNext())
        {
        	Integer gid = (Integer)it.next();
            buf += gid.toString() + ":";
        }
        pw.println(buf);
	}

	/**
	 * <p>僨乕僞傪撉傒崬傒傑偡丅
	 * <p>偙偺Read儊僜僢僪傪捈愙巊梡偡傞偙偲偼偁傝傑偣傫丅Load儊僜僢僪偐傜屇傃弌偝傟傑偡丅
	 * <BR>僥儞僾儗乕僩儊僜僢僪僷僞乕儞
	 *
	 * @param bf 僶僢僼傽乕儕乕僟乕
	 */
	synchronized protected void Read(BufferedReader bf) throws GSException{
		try{
			String buf = null;
			String label,value,gid;

			for(buf=bf.readLine();buf!=null;buf=bf.readLine()) {
				StringTokenizer st = new StringTokenizer(buf,"=");
				label = st.nextToken();
				if(st.hasMoreTokens())
					value = st.nextToken();
				else
					value = "";
				if(label.equals("display"))
					Display = Integer.parseInt(value);
				else if(label.equals("dispcnt"))
					Dispcnt = Integer.parseInt(value);
                else if(label.equals(GROUPS)){
                	StringTokenizer st2 = new StringTokenizer(value,":");
                    while(st2.hasMoreTokens())
                    {
                    	gid = st2.nextToken();
                        Groups.add(new Integer(gid));
                    }
                }
			}
		}catch(IOException e){
			throw new GSException("宖帵斉僐儞僼僼傽僀儖偺撉崬傒偵幐攕");
		}
	}
}

⌨️ 快捷键说明

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