📄 converdata.java
字号:
package fr.umlv.projet.fenetre.table;
import java.util.List;
import fr.umlv.projet.procfs.Processus;
/**
* To convert the data of the table that correspond with the names of column choosed
* @author Ma & Huang
*
*/
public class ConverData {
/**
* Convert the data of the table that correspond with the names of column choosed
* @param listProcess the list that enregister the infomation of the processuses
* @param colomnName the names of the column that the user choose
* (Default: User, Name , Name , Pid , CPU%, MEM%)
* @return the data after converted
*/
public static Object[][] covert(List<Processus> listProcess,List<String> colomnName){
Object[][] data = new Object[colomnName.size()][listProcess.size()];
for(int i=0;i<colomnName.size();i++){
String s = colomnName.get(i);
if(s.equals("User Name")){
for(int j=0;j<listProcess.size();j++){
data[i][j]=listProcess.get(j).getUser();
}
}
if(s.equals("Name")){
for(int j=0;j<listProcess.size();j++){
data[i][j]=listProcess.get(j).getName();
}
}
if(s.equals("SleepAVG%")){
for(int j=0;j<listProcess.size();j++){
String str = listProcess.get(j).getSleepAVG();
data[i][j] = Integer.parseInt(str.substring(0,str.length()-1));
}
}
if(s.equals("Pid")){
for(int j=0;j<listProcess.size();j++){
data[i][j]=listProcess.get(j).getPid();
}
}
if(s.equals("Tgid")){
for(int j=0;j<listProcess.size();j++){
data[i][j]=Integer.parseInt(listProcess.get(j).getTgid());
}
}
if(s.equals("PPid")){
for(int j=0;j<listProcess.size();j++){
data[i][j]=Integer.parseInt(listProcess.get(j).getPpid());
}
}
if(s.equals("TracerPid")){
for(int j=0;j<listProcess.size();j++){
data[i][j]=Integer.parseInt(listProcess.get(j).getTracerPid());
}
}
if(s.equals("Uid")){
for(int j=0;j<listProcess.size();j++){
data[i][j]=Integer.parseInt(listProcess.get(j).getUid());
}
}
if(s.equals("Gid")){
for(int j=0;j<listProcess.size();j++){
data[i][j]=Integer.parseInt(listProcess.get(j).getGid());
}
}
if(s.equals("FDSize")){
for(int j=0;j<listProcess.size();j++){
data[i][j]=Integer.parseInt(listProcess.get(j).getFdsize());
}
}
if(s.equals("VmSize(KB)")){
for(int j=0;j<listProcess.size();j++){
data[i][j]=Integer.parseInt(listProcess.get(j).getVmSize());
}
}
if(s.equals("VmLck(KB)")){
for(int j=0;j<listProcess.size();j++){
data[i][j]=Integer.parseInt(listProcess.get(j).getVmLck());
}
}
if(s.equals("VmRSS(KB)")){
for(int j=0;j<listProcess.size();j++){
data[i][j]=Integer.parseInt(listProcess.get(j).getVmRss());
}
}
if(s.equals("VmData(KB)")){
for(int j=0;j<listProcess.size();j++){
data[i][j]=Integer.parseInt(listProcess.get(j).getVmData());
}
}
if(s.equals("VmStk(KB)")){
for(int j=0;j<listProcess.size();j++){
data[i][j]=Integer.parseInt(listProcess.get(j).getVmStk());
}
}
if(s.equals("VmExe(KB)")){
for(int j=0;j<listProcess.size();j++){
data[i][j]=Integer.parseInt(listProcess.get(j).getVmExe());
}
}
if(s.equals("VmLib(KB)")){
for(int j=0;j<listProcess.size();j++){
data[i][j]=Integer.parseInt(listProcess.get(j).getVmLib());
}
}
if(s.equals("VmPTE(KB)")){
for(int j=0;j<listProcess.size();j++){
data[i][j]=Integer.parseInt(listProcess.get(j).getVmPTE());
}
}
if(s.equals("State")){
for(int j=0;j<listProcess.size();j++){
data[i][j]=listProcess.get(j).getState();
}
}
if(s.equals("Threads")){
for(int j=0;j<listProcess.size();j++){
data[i][j]=Integer.parseInt(listProcess.get(j).getThreads());
}
}
if(s.equals("CMD")){
for(int j=0;j<listProcess.size();j++){
data[i][j]=listProcess.get(j).getCmdLine();
}
}
if(s.equals("MEM%")){
for(int j=0;j<listProcess.size();j++){
data[i][j]=Float.parseFloat(listProcess.get(j).getMeminfo());
}
}
if(s.equals("CPU%")){
for(int j=0;j<listProcess.size();j++){
data[i][j]=Float.parseFloat(listProcess.get(j).getCpuinfo());
}
}
}
return data;
}
public static void main(String[] args) {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -