Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1611 | - | 1 | package dongfang.mkt.configuration; |
2 | |||
3 | public class BitSetEntry extends ParameterEntry { |
||
4 | BitSetEntry(String name, String[] bitNames) { |
||
5 | super(name); |
||
6 | this.bitNames = bitNames; |
||
7 | } |
||
8 | |||
9 | int value; |
||
10 | String[] bitNames; |
||
11 | |||
12 | int getByteCount() { |
||
13 | return 1; |
||
14 | } |
||
15 | |||
16 | int getValue() { |
||
17 | return value; |
||
18 | } |
||
19 | |||
20 | int setValue(int[] data, int offset) { |
||
21 | value = data[offset]; |
||
22 | return getByteCount(); |
||
23 | } |
||
24 | |||
25 | String toStringWithValues() { |
||
26 | StringBuilder result = new StringBuilder(name + "\t["); |
||
27 | for (int i = 0; i < Math.min(bitNames.length, 8); i++) { |
||
28 | if (i != 0) |
||
29 | result.append(", "); |
||
30 | result.append(bitNames[i] + ":" |
||
31 | + ((value & (1 << i)) != 0 ? "1" : "0")); |
||
32 | } |
||
33 | return result.toString(); |
||
34 | } |
||
35 | |||
36 | void toXML(StringBuilder result) { |
||
37 | result.append(" <parameter name=\"" + name + "\">\n"); |
||
38 | for (int i = 0; i < Math.min(bitNames.length, 8); i++) { |
||
39 | result.append(" <bit name=\"" + bitNames[i] + "\" value=\"" |
||
40 | + ((value & (1 << i)) != 0 ? "1" : "0") + "\"/>\n"); |
||
41 | } |
||
42 | result.append(" </parameter>\n"); |
||
43 | } |
||
44 | } |