有故障查询代码,由18位阿拉伯数字表示,每一位的值是0到9表示含义如下,这样的数据放在数据库中还是用xml,还是用MAP
比如
数字位 值 含义
1 0 主动诊断
1 PPPOE
2 正常
3 IE
4 OE
5 Outlook
6 网络掉线
我查询时是输入18位数据如(3454656783202356783)就会得到每一位表示的含义
比如
数字位 值 含义
1 0 主动诊断
1 PPPOE
2 正常
3 IE
4 OE
5 Outlook
6 网络掉线
我查询时是输入18位数据如(3454656783202356783)就会得到每一位表示的含义
如果是不一样的话,使用 String 二维数组
"主动诊断", "PPPOE", "正常", "IE", "OE",
"Outlook", "网络掉线", null, null, null
}; public static void main(String[] args) {
String str = "3454656783202356783";
char[] chs = str.toCharArray();
for(int i = 0; i < chs.length; i++) {
System.out.printf("%2d: %c --> %s%n", i, chs[i], getStatusDesc(chs[i]));
} }
public static String getStatusDesc(char status) {
return STATUS_DESC_ARRAY[status - '0'];
} public static String getStatusDesc(int status) {
return STATUS_DESC_ARRAY[status];
}
}