📄 scsidevice.java
字号:
package jcdwriter.model;import java.io.*;import java.util.Vector;/* Author: Ram Mallappa * */public class SCSIDevice implements java.io.Serializable{ String bus; String target; String lun; String description = ""; String osDescription = null; public static SCSIDevice from(String s) { SCSIDevice dev = null; if (stringHasDeviceInfo(s)) { Log.writeln("SCSIDevice:found", s, 3); dev = new SCSIDevice(); int begin = 0; int end = s.indexOf(','); if (end > 0) { dev.bus = (s.substring(begin, end)).trim(); begin = end + 1; end = s.indexOf(',', begin); dev.target = (s.substring(begin, end)).trim(); begin = end + 1; end = s.indexOf('\t', begin); dev.lun = (s.substring(begin, end)).trim(); begin = end; begin = s.indexOf(')') + 1; end = s.length() ; dev.description = (s.substring(begin, end)).trim(); dev.osDescription = s; } } return dev; } public String osDescription() { return osDescription; } public static boolean stringHasDeviceInfo(String line) { return (java.util.regex.Pattern.matches("\\s*\\d*,\\d*,\\d*\\s*\\d*\\)\\s'.*", line)); } public boolean valid() { return ((bus != null && target != null && lun != null) && !((description.length() == 1) && (description.charAt(0) == '*'))); } public static Vector devicesScannedFrom(BufferedReader buffReader) { String line; Vector devices = new Vector(); try { while ( (line = buffReader.readLine()) != null) { if((line.length() > 0) && (line.indexOf("scsibus") < 0) && (line.indexOf("*") < 0)) devices.add(SCSIDevice.from(line.trim())); } } catch(IOException ie) { System.out.println(ie); } return devices; } public String toString() { return ("("+bus+","+target+","+lun+") "+ description); } public String deviceString() { return (""+bus+","+target+","+lun); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -