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

📄 cinotefile.java

📁 一个日本流行的,功能较全的开源Web办公管理(Groupware)系统。
💻 JAVA
字号:
/*-
 * 夞棗斅僨乕僞  CINoteFile.java
 */
package jp.co.sjts.gsession.circular;

import java.io.FileOutputStream;
import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.util.Properties;
import java.util.StringTokenizer;
import jp.co.sjts.gsession.tools.*;

/**
 * <p>夞棗斅僨乕僞
 * <p>Copyright (C) 1999-2000 Japan Total System Co,LTD
 *
 * @author   Masakatu O	  &lt;ookubo@sjts.co.jp&gt;
 * @author   Satoru K   &lt;koni@sjts.co.jp&gt;
 */
public class CINoteFile extends GSTextFile
{
	private String  entuserid="";	// 儐乕僓ID
	private String  name="";		// 儐乕僓柤
	private String  title="";		// 僞僀僩儖
	private String  messege="";		// 杮暥
	private String  limit="";		// 桳岠婜尷
	private String  timestamp="";	// 嶌惉擔
	private String  tmpfile="";		// 揧晅僼傽僀儖
	private String  tmptype="";		// 揧晅僼傽僀儖僞僀僾

	/**
	 * <P>擖椡偝傟偨僨乕僞傪尦偵僆僽僕僃僋僩傪惗惉
	 *
	 * @param entuserid - 儐乕僓ID
	 * @param name - 儐乕僓柤
	 * @param title - 僞僀僩儖
	 * @param message - 儊僢僙乕僕
	 * @param limit - 桳岠婜尷
	 * @param timestamp - 嶌惉擔
	 * @param tmpfile - 揧晅僼傽僀儖柤
	 * @param tmptype - 揧晅僼傽僀儖僞僀僾
	 */
	public void CINote(String entuserid,String name,String title,String messege,String limit,String timestamp, String tmpfile, String tmptype)
	{
		this.entuserid = entuserid;
		this.name = name;
		this.title = title;
		this.messege = messege;
		this.limit = limit;
		this.timestamp = timestamp;
		this.tmpfile = tmpfile;
		this.tmptype = tmptype;
	}

	/**
	 * <P>儐乕僓ID傪巜掕偝傟偨抣偵愝掕偡傞丅
	 *
	 * @param entuserid - 儐乕僓ID
	 */
	public void setEntuserid(String entuserid) { this.entuserid = entuserid; }
	/**
	 * <P>儐乕僓柤傪巜掕偝傟偨抣偵愝掕偡傞丅
	 *
	 * @param name - 儐乕僓柤
	 */
	public void setName(String name) { this.name = name; }
	/**
	 * <P>僞僀僩儖傪巜掕偝傟偨抣偵愝掕偡傞丅
	 *
	 * @param title - 僞僀僩儖
	 */
	public void setTaitol(String title) { this.title = title; }
	/**
	 * <P>杮暥傪巜掕偝傟偨抣偵愝掕偡傞丅
	 *
	 * @param message - 杮暥
	 */
	public void setMessege(String messege) { this.messege = messege; }
	/**
	 * <P>桳岠婜尷傪巜掕偝傟偨抣偵愝掕偡傞丅
	 *
	 * @param limit - 桳岠婜尷
	 */
	public void setLimit(String limit) { this.limit = limit; }
	/**
	 * <P>嶌惉擔傪巜掕偝傟偨抣偵愝掕偡傞丅
	 *
	 * @param timestamp - 嶌惉擔
	 */
	public void setTimestamp(String timestamp) { this.timestamp = timestamp; }
	/**
	 * <P>揧晅僼傽僀儖柤傪巜掕偝傟偨抣偵愝掕偡傞丅
	 *
	 * @param tmpfile - 揧晅僼傽僀儖柤
	 */
	public void setTmpfile(String tmpfile) { this.tmpfile = tmpfile; }
	/**
	 * <P>揧晅僼傽僀儖僞僀僾傪巜掕偝傟偨抣偵愝掕偡傞丅
	 *
	 * @param tmptype - 揧晅僼傽僀儖僞僀僾
	 */
	public void setTmptype(String tmptype) { this.tmptype = tmptype; }

	/**
	 * <P>儐乕僓ID傪庢摼偡傞丅
	 *
	 * @return 儐乕僓ID
	 */
	public String getEntuserid() { return entuserid; }
	/**
	 * <P>儐乕僓柤傪庢摼偡傞丅
	 *
	 * @return 儐乕僓柤
	 */
	public String getName() { return name; }
	/**
	 * <P>僞僀僩儖傪庢摼偡傞丅
	 *
	 * @return 僞僀僩儖
	 */
	public String getTaitol() { return title; }
	/**
	 * <P>杮暥傪庢摼偡傞丅
	 *
	 * @return 杮暥
	 */
	public String getMessege() { return messege; }
	/**
	 * <P>桳岠婜尷傪庢摼偡傞丅
	 *
	 * @return 桳岠婜尷
	 */
	public String getLimit() { return limit; }
	/**
	 * <P>嶌惉擔傪庢摼偡傞丅
	 *
	 * @return 嶌惉擔
	 */
	public String getTimestamp() { return timestamp; }
	/**
	 * <P>揧晅僼傽僀儖柤傪庢摼偡傞丅
	 *
	 * @return 揧晅僼傽僀儖柤
	 */
	public String getTmpfile() { return tmpfile; }
	/**
	 * <P>揧晅僼傽僀儖僞僀僾傪庢摼偡傞丅
	 *
	 * @return 揧晅僼傽僀儖僞僀僾
	 */
	public String getTmptype() { return tmptype; }

	/**
	 * <P>儐乕僓ID傪帵偡暥帤楍偱偡丅
	 */
	public static final String V1 = "entuserid";	//儐乕僓ID
	/**
	 * <P>儐乕僓柤傪帵偡暥帤楍偱偡丅
	 */
	public static final String V2 = "name";			//儐乕僓柤
	/**
	 * <P>僞僀僩儖傪帵偡暥帤楍偱偡丅
	 */
	public static final String V3 = "taitol";		//僞僀僩儖
	/**
	 * <P>杮暥傪帵偡暥帤楍偱偡丅
	 */
	public static final String V4 = "messege";		//杮暥
	/**
	 * <P>桳岠婜尷傪帵偡暥帤楍偱偡丅
	 */
	public static final String V5 = "limit";		//桳岠婜尷
	/**
	 * <P>嶌惉擔傪帵偡暥帤楍偱偡丅
	 */
	public static final String V6 = "timestamp";	//僞僀儉僗僞儞僾
	/**
	 * <P>揧晅僼傽僀儖柤傪帵偡暥帤楍偱偡丅
	 */
	public static final String V7 = "tmpfile";		//揧晅僼傽僀儖
	/**
	 * <P>揧晅僼傽僀儖僞僀僾傪帵偡暥帤楍偱偡丅
	 */
	public static final String V8 = "tmptype";		//揧晅僼傽僀儖僞僀僾

	/**
	 * <P>僼傽僀儖偺嬫愗傝暥帤偱偡丅
	 */
	public final static String SPATH = File.separator ;
	public final static String DIR0 = "data" + File.separator;
	public final static String DIR1 = "user" + File.separator;
	/**
	 * <P>夞棗斅僨乕僞僼傽僀儖柤傪帵偡暥帤楍偱偡丅
	 */
	public final static String NAME = "note";

	private Properties properties=null;

	private File file;
	private String filePath = null;
	private String GrpDir = null;

	/**
	 * <P>巜掕偝傟偨抣傪尦偵僆僽僕僃僋僩傪惗惉偟傑偡丅
	 *
	 * @param HomeDir - 夞棗斅僨乕僞僨傿儗僋僩儕
	 * @param Id - 夞棗斅ID(mode=1偺応崌)丄傑偨偼儐乕僓乕ID(mode<>0偺応崌)
	 * @param mode - 
	 */
	public CINoteFile(String HomeDir,String Id,int mode) throws GSException
	{
		properties = System.getProperties();
		if(mode == 1)
			GrpDir = HomeDir + DIR1 + Id;//ID偼夞棗斅ID
		else
			GrpDir = HomeDir + DIR0 + Id ;//ID偼儐乕僓乕ID
		GrpDir = GrpDir.replace('/',this.properties.getProperty("file.separator").charAt(0));

		File file1 = new File(GrpDir);

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

		filePath = GrpDir + SPATH + NAME;
		this.file = new File(filePath);

	}

	public synchronized boolean Get(String HomeDir,String Id) throws GSException
	{
		properties = System.getProperties();
		GrpDir = HomeDir + DIR0 + Id + SPATH + NAME;
		filePath = GrpDir.replace('/',this.properties.getProperty("file.separator").charAt(0));

		this.file = new File(filePath);

		if(file.exists()) {
			Load();
			return	true;
		}else{
			return	false;
		}
	}

//昁偢偄傞
	synchronized protected File GetFile()
	{
		return file;
	}

//昁偢偄傞
	synchronized protected void Read(BufferedReader bf) throws GSException
	{
		try {
			String buf = null;

			tmptype = "application/octet-stream";


			for(buf=bf.readLine();buf!=null;buf=bf.readLine()) {
				StringTokenizer st = new StringTokenizer(buf,"=");
				String label = st.nextToken();
				String value = st.nextToken();
				if(label.equals(V1))
					entuserid = value;
				else if(label.equals(V2))
					name = GSTool.delimitDecorde("=",value);
				else if(label.equals(V3))
					title = GSTool.delimitDecorde("=",value);
				else if(label.equals(V4))
					messege = GSTool.delimitDecorde("=",value);
				else if(label.equals(V5))
					limit = value;
				else if(label.equals(V6))
					timestamp = value;
				else if(label.equals(V7))
					tmpfile = value;
				else if(label.equals(V8))
					tmptype = value;
			}
		} catch(IOException e) {
			throw new GSException("\"Data file\"撉崬傒僄儔乕");
		}
	}

//昁偢偄傞
	synchronized protected void Write(PrintWriter pw) throws GSException
	{
		pw.println(V1 + "=" + getEntuserid());
		pw.println(V2 + "=" + GSTool.delimitEncorde("=",getName()));
		pw.println(V3 + "=" + GSTool.delimitEncorde("=",getTaitol()));
		pw.println(V4 + "=" + GSTool.delimitEncorde("=",getMessege()));
		pw.println(V5 + "=" + getLimit());
		pw.println(V6 + "=" + getTimestamp());
		pw.println(V7 + "=" + getTmpfile());
		pw.println(V8 + "=" + getTmptype());
	}


	public void setContent(byte[] content) throws GSException
	{
		try{
			FileOutputStream fos = new FileOutputStream(filePath+"b");
			BufferedOutputStream bos = new BufferedOutputStream(fos,content.length+1);
			bos.write(content,0,content.length);
			bos.flush();
			bos.close();
		}catch(FileNotFoundException e){
			throw new GSException("僼傽僀儖偑尒偮偐傝傑偣傫丅",e);
		}catch(IOException e){
			throw new GSException("IO僄儔乕偱偡丅",e);
		}
	}

	/**
	 * <P>夞棗斅僨乕僞僼傽僀儖傪嶍彍偟傑偡丅
	 */
	public synchronized void Delete() throws GSException
	{
		if(file.exists())
			file.delete();
	}


}

⌨️ 快捷键说明

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