📄 wknotefile.java
字号:
/*-
* 儚乕僋僼儘乕僨乕僞 WKNoteFile.java
*/
package jp.co.sjts.gsession.work;
import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
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 <ookubo@sjts.co.jp>
* @author Satoru K <koni@sjts.co.jp>
*/
public class WKNoteFile extends GSTextFile
{
private String userid=""; // 儐乕僓ID
private String groupid=""; // 僌儖乕僾ID
private String status=""; // 忬懺
private String timestamp=""; // 嶌惉擔
private String titol=""; // 僞僀僩儖
private String messege=""; // 撪梕
private String compdate=""; // 姰椆擔
private String tmpfile=""; // 揧晅僼傽僀儖
private String index=""; //
private String username=""; // 儐乕僓ID
private String groupname=""; // 僌儖乕僾ID
private String tmptype=""; // 揧晅僼傽僀儖僞僀僾
public void WKNote(String userid,String groupid,String status,String timestamp,String titol,String messege, String compdate,String tmpfile,String index,String username,String groupname,String tmptype)
{
this.userid = userid;
this.groupid = groupid;
this.status = status;
this.timestamp = timestamp;
this.titol = titol;
this.messege = messege;
this.compdate = compdate;
this.tmpfile = tmpfile;
this.index = index;
this.username = username;
this.groupname = groupname;
this.tmptype = tmptype;
}
public void setUserid(String userid) { this.userid = userid; }
public void setGroupid(String groupid) { this.groupid = groupid; }
public void setStatus(String status) { this.status = status; }
public void setTimestamp(String timestamp) { this.timestamp = timestamp; }
public void setTitol(String titol) { this.titol = titol; }
public void setMessege(String messege) { this.messege = messege; }
public void setCompdate(String compdate) { this.compdate = compdate; }
public void setTmpfile(String tmpfile) { this.tmpfile = tmpfile; }
public void setIndex(String index) { this.index = index; }
public void setIndex(int index) { this.index = Integer.toString(index); }
public void setUsername(String username) { this.username = username; }
public void setGroupname(String groupname) { this.groupname = groupname; }
public void setTmptype(String tmptype) { this.tmptype = tmptype; }
public String getUserid() { return userid; }
public int getIntUserid() { return Integer.parseInt(userid); }
public String getGroupid() { return groupid; }
public String getStatus() { return status; }
public int getIntStatus() { return Integer.parseInt(status); }
public String getTimestamp() { return timestamp; }
public String getTitol() { return titol; }
public String getMessege() { return messege; }
public String getCompdate() { return compdate; }
public String getTmpfile() { return tmpfile; }
public String getIndex() { return index; }
public int getIntIndex() { return Integer.parseInt(index); }
public String getUsername() { return username; }
public String getGroupname() { return groupname; }
public String getTmptype() { return tmptype; }
public static final String V1 = "userid"; //儐乕僓ID
public static final String V2 = "groupid"; //僌儖乕僾ID
public static final String V3 = "status"; //忬懺
public static final String V4 = "timestamp"; //嶌惉擔
public static final String V5 = "titol"; //僞僀僩儖
public static final String V6 = "messege"; //撪梕
public static final String V7 = "compdate"; //姰椆擔
public static final String V8 = "tmpfile"; //揧晅僼傽僀儖
public static final String V9 = "index"; //揧晅僼傽僀儖
public static final String V10 = "username"; //儐乕僓柤
public static final String V11 = "groupname"; //僌儖乕僾柤
public static final String V12 = "tmptype"; //揧晅僼傽僀儖僞僀僾
public final static String SPATH = File.separator ;
public final static String[] DIR = {"data" + File.separator + "motion" + File.separator , "data" + File.separator + "complete" + File.separator , "user" + File.separator };
public final static String NAME = "note";
private Properties properties=null;
private File file;
private String filePath = null;
private String GrpDir = null;
public WKNoteFile(String HomeDir,String Id,int mode) throws GSException
{
GrpDir = HomeDir + DIR[mode] + Id ;//ID偼彂椶ID
File file1 = new File(GrpDir);
if(!file1.exists()) // 僼傽僀儖偑懚嵼偡傞偐
file1.mkdirs(); // 僼傽僀儖偑懚嵼偟側偄応崌偼丄嶌惉傪帋傒傞
filePath = GrpDir + SPATH + NAME;
this.file = new File(filePath);
}
public synchronized void Get(String HomeDir,String Id,int mode) throws GSException
{
filePath = HomeDir + DIR[mode] + Id + SPATH + NAME;
this.file = new File(filePath);
if(file.exists()) {
Load();
}
}
//昁偢偄傞
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))
userid = value;
else if(label.equals(V2))
groupid = value;
else if(label.equals(V3))
status = value;
else if(label.equals(V4))
timestamp = value;
else if(label.equals(V5))
titol = GSTool.delimitDecorde("=",value);
else if(label.equals(V6))
messege = GSTool.delimitDecorde("=",value);
else if(label.equals(V7))
compdate = value;
else if(label.equals(V8))
tmpfile = GSTool.delimitDecorde("=",value);
else if(label.equals(V9))
index = value;
else if(label.equals(V10))
username = GSTool.delimitDecorde("=",value);
else if(label.equals(V11))
groupname = GSTool.delimitDecorde("=",value);
else if(label.equals(V12))
tmptype = GSTool.delimitDecorde("=",value);
}
} catch(IOException e) {
throw new GSException("\"Data file\"撉崬傒僄儔乕");
}
}
//昁偢偄傞
synchronized protected void Write(PrintWriter pw) throws GSException
{
pw.println(V1 + "=" + getUserid());
pw.println(V2 + "=" + getGroupid());
pw.println(V3 + "=" + getStatus());
pw.println(V4 + "=" + getTimestamp());
pw.println(V5 + "=" + GSTool.delimitEncorde("=",getTitol()));
pw.println(V6 + "=" + GSTool.delimitEncorde("=",getMessege()));
pw.println(V7 + "=" + getCompdate());
pw.println(V8 + "=" + GSTool.delimitEncorde("=",getTmpfile()));
pw.println(V9 + "=" + getIndex());
pw.println(V10 + "=" + GSTool.delimitEncorde("=",getUsername()));
pw.println(V11 + "=" + GSTool.delimitEncorde("=",getGroupname()));
pw.println(V12 + "=" + GSTool.delimitEncorde("=",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);
}
}
public synchronized void Delete() throws GSException
{
if(file.exists())
file.delete();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -