📄 monitorjob.java
字号:
package cn.edu.hust.cgcl.biogrid.monitor;
import java.io.Serializable;
import java.text.ParseException;
import cn.edu.hust.cgcl.biogrid.user.desc.JobDesc;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
////////////////////////////////////////////////////////////////////////////////////////
public class MonitorJob implements Serializable
{
String JobID = "aa";
String fileName = "bb";
String dataServerIp = "cc";
int dataServerPort =0;
String projectName = "ccd";
String fileString = "dffa";
String userId;
String userPwd;
public MonitorJob(JobDesc jobdesc)
{
JobID=jobdesc.getID();
this.dataServerIp=jobdesc.getDataPool().getPoolIP();
this.dataServerPort=jobdesc.getDataPool().getPoolPort();
this.userId=jobdesc.getDataPool().getLoginName();
this.userPwd=jobdesc.getDataPool().getPassword();
//jobdesc.getDataPool()
} // MonitorJob
public MonitorJob(String filename)
throws Exception
{
this.fileName=filename;
//this.parseFile();
} // MonitorJobDescFile
public String getJobID() {
return JobID;
}
public String getUserId()
{
return userId;
}
public String getUserPwd()
{
return userPwd;
}
public String getfileName()
{
return fileName;
}
public String getdataServerIp()
{
return dataServerIp;
}
public int getdataServerPort()
{
return dataServerPort;
}
public String getprojectName()
{
return projectName;
}
//***************************************************************************
//函数名: getBracketStr
//功能: 字符串处理专用函数 将一个字符串提取方括号内的部分
//参数: inStr --- 源字符串;
// beginIndex --- "<"这个字符在源字符串中所在的位置;
// bracketStr --- 出口参数,即中间的部分;
// 返回值:1 --- 成功 失败返回 :-1
//创建: 唐晓辉 日期:2004-7-10
//****************************************************************************
public static int getBracketStr(String inStr, int beginIndex,
StringBuffer bracketStr)
throws Exception
{
if (bracketStr == null)
{
System.out.println("null");
return -1;
} // if
if (beginIndex >= inStr.length() || beginIndex < 0)
{
throw new ParseException("BracketStr parse error!", beginIndex);
} // if
int begin = inStr.indexOf('<', beginIndex);
if (begin < 0)
{
throw new ParseException("BracketStr parse error!", begin);
} // if
int end = inStr.indexOf('>', begin);
if (end < 0)
{
throw new ParseException("BracketStr parse error!", end);
} // if
bracketStr.replace(0, bracketStr.length(),
inStr.substring(begin + 1, end));
return end;
} // getBracketStr
//***************************************************************************
//函数名: getCiteStr
//功能: 字符串处理专用函数 将一个字符串提取方括号内的部分
//参数: inStr --- 源字符串;
// beginIndex --- "("这个字符在源字符串中所在的位置;
// bracketStr --- 出口参数,即中间的部分;
// 返回值:1 --- 成功 失败返回 :-1
//创建: 唐晓辉 日期:2004-7-10
//****************************************************************************
public static int getCiteStr(String inStr, int beginIndex,
StringBuffer CiteStr)
throws Exception
{
if (CiteStr == null)
{
System.out.println("null");
return -1;
} // if
if (beginIndex >= inStr.length() || beginIndex < 0)
{
throw new ParseException("BracketStr parse error!", beginIndex);
} // if
int begin = inStr.indexOf('(', beginIndex);
if (begin < 0)
{
throw new ParseException("BracketStr parse error!", begin);
} // if
int end = inStr.indexOf(')', begin);
if (end < 0)
{
throw new ParseException("BracketStr parse error!", end);
} // if
CiteStr.replace(0, CiteStr.length(), inStr.substring(begin + 1, end));
return end;
} // getBracketStr
//***************************************************************************
//函数名: parseFile
//性质: 成员函数;
//功能: 解析子任务说明文件,把固定格式文件中的内容返回给各个变量:
// JobID fileName dataServerIp dataServerPort projectName
//创建: 徐胜超 日期:2004-7-16
//****************************************************************************
private void parseFile()
throws Exception
{ //这个函数是用来解析文件
/*
FileReader file = new FileReader(fileName);
BufferedReader buff = new BufferedReader(file);
int n = 5;
int ret1, ret2;
String tempa1 = "";
StringBuffer tempd1 = new StringBuffer();
String result1 = "";
String result2 = "";
String tempa2 = "";
StringBuffer tempd2 = new StringBuffer();
boolean eof = false;
MonitorJob mynewclass;
mynewclass = new MonitorJob(fileName);
for (n = 5, eof = false; n >= 1; n--)
{
String line = null;
while ( (line = buff.readLine()).equals("") || line == null)
{
} // while
if (n == 5)
{
tempa1 = line;
ret1 = mynewclass.getBracketStr(tempa1, 0, tempd1);
result1 = new String(tempd1);
if (result1.equals("jobid"))
{
ret2 = mynewclass.getCiteStr(tempa1, 0, tempd2);
result2 = new String(tempd2);
JobID = result2;
}
}
if (n == 4)
{
tempa1 = line;
ret1 = mynewclass.getBracketStr(tempa1, 0, tempd1);
result1 = new String(tempd1);
if (result1.equals("filename"))
{
ret2 = mynewclass.getCiteStr(tempa1, 0, tempd2);
result2 = new String(tempd2);
fileName = result2;
}
}
if (n == 3)
{
tempa1 = line;
ret1 = mynewclass.getBracketStr(tempa1, 0, tempd1);
result1 = new String(tempd1);
if (result1.equals("dataserverip"))
{
ret2 = mynewclass.getCiteStr(tempa1, 0, tempd2);
result2 = new String(tempd2);
dataServerIp = result2;
}
}
if (n == 2)
{
tempa1 = line;
ret1 = mynewclass.getBracketStr(tempa1, 0, tempd1);
result1 = new String(tempd1);
if (result1.equals("dataserverport"))
{
ret2 = mynewclass.getCiteStr(tempa1, 0, tempd2);
result2 = new String(tempd2);
dataServerPort = result2;
}
}
if (n == 1)
{
tempa1 = line;
ret1 = mynewclass.getBracketStr(tempa1, 0, tempd1);
result1 = new String(tempd1);
if (result1.equals("projectname"))
{
ret2 = mynewclass.getCiteStr(tempa1, 0, tempd2);
result2 = new String(tempd2);
projectName = result2;
}
}
fileString = JobID + "," + fileName + "," + dataServerIp + "," +
dataServerPort + "," + projectName;
} // for //fileString 是用逗号分开的属性值;
buff.close();
*/
}
// parseFile
//***************************************************************************
//函数名: writeToFile
//性质: 成员函数;
//功能: 根据fileString,先分解,然后把各个变量按照固定的格式写入文件名为fileName的文件中:
//创建: 徐胜超 日期:2004-7-17
//****************************************************************************
private void writeToFile() //根据下载的流来写入到文件中。
{
/*
try
{
int position_1;
position_1 = fileString.indexOf(44);
JobID = fileString.substring(0, position_1);
JobID = "<jobid>" + "(" + JobID + ")"; //1
fileString = fileString.substring(position_1 + 1);
position_1 = fileString.indexOf(44);
fileName = fileString.substring(0, position_1);
fileName = "<filename>" + "(" + fileName + ")"; //2
fileString = fileString.substring(position_1 + 1);
position_1 = fileString.indexOf(44);
dataServerIp = fileString.substring(0, position_1);
dataServerIp = "<dataserverip>" + "(" + dataServerIp + ")"; //3
fileString = fileString.substring(position_1 + 1);
position_1 = fileString.indexOf(44);
dataServerPort = fileString.substring(0, position_1);
dataServerPort = "<dataserverport>" + "(" + dataServerPort + ")";
fileString = fileString.substring(position_1 + 1);
projectName = fileString;
projectName = "<projectname>" + "(" + projectName + ")"; //5
FileWriter fw = new FileWriter(fileName);
fw.write(JobID);
fw.write("\r" + "\n"); //添加回车和换行
fw.write(fileName);
fw.write("\r" + "\n");
fw.write(dataServerIp);
fw.write("\r" + "\n");
fw.write(dataServerPort);
fw.write("\r" + "\n");
fw.write(projectName);
fw.write("\r" + "\n");
fw.close();
}
catch (IOException e)
{
System.out.println("Error --" + e.toString());
}
*/
} // writeToFile
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -