📄 servlistdata.java
字号:
package jMaint;import java.util.*;public class ServListData { Vector id,name,type; public ServListData() { id = new Vector(); name = new Vector(); type = new Vector(); } public void addRecord(int ID, String Name, String Type) { this.id.addElement(new Integer(ID)); this.name.addElement(new String(Name)); this.type.addElement(new String(Type)); } public String convertIDtoName(int ID) { return this.getName(this.indexOf(ID)); } public int convertNameToID(String Name) { return Integer.parseInt(this.id.get(this.name.indexOf(new String(Name))).toString()); } public Vector createIDVector() { Vector v = new Vector(); for (int i=0; i<this.size(); i++) v.addElement(new Integer(this.getID(i))); return v; } public Vector createNameVector() { Vector v = new Vector(); for (int i=0; i<this.size(); i++) v.addElement(new String(this.getName(i))); return v; } public void deleteRecord(int x) { this.id.removeElementAt(x); this.name.removeElementAt(x); this.type.removeElementAt(x); } public String exportRecord(int x) { String t = String.valueOf('\t'); String nl = String.valueOf('\n'); return this.getID(x)+t+this.getName(x)+t+this.getType(x)+nl; } public int getID(int x) { return Integer.parseInt(this.id.get(x).toString()); } public String getName(int x) { return this.name.get(x).toString(); } public String getType(int x) { return this.type.get(x).toString(); } public int indexOf(int ID) { int y = -1; for (int i=0; i<this.size(); i++) if (this.id.get(i).toString().equalsIgnoreCase(String.valueOf(ID))) y=i; return y; } public int indexTypeStart(String Type) { return this.type.indexOf(new String(Type)); } public int indexTypeEnd(String Type) { return this.type.lastIndexOf(new String(Type)); } public void insertRecord(int ID, String Name, String Type){ if (ID==-1) { ID = 0; while (this.indexOf(ID)!=-1) ID++; } int i = this.indexTypeStart(Type); if (i>-1) while ((i<this.indexTypeEnd(Type)+1) && (this.getName(i).compareToIgnoreCase(Name)<0)) i++; else i = this.size(); if ((i==this.size()) && (ID>-1)) this.addRecord(ID,Name,Type); else if (!this.getName(i).equals(Name)) { this.name.insertElementAt(new String(Name), i); this.type.insertElementAt(new String(Type), i); this.id.insertElementAt(new Integer(ID), i); } } public void modifyType(String OldType, String NewType) { int i = this.indexTypeStart(OldType); int j = this.indexTypeEnd(OldType)+1; if (i>-1) for (int x=i; x<j; x++) this.type.setElementAt(new String(NewType), x); } public int size() { return this.id.size(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -