Blame |
Last modification |
View Log
| RSS feed
package dongfang.mkt.configuration;
public class BitSetEntry
extends ParameterEntry
{
BitSetEntry
(String name,
String[] bitNames
) {
super(name
);
this.
bitNames = bitNames
;
}
int value
;
String[] bitNames
;
int getByteCount
() {
return 1;
}
int getValue
() {
return value
;
}
int setValue
(int[] data,
int offset
) {
value = data
[offset
];
return getByteCount
();
}
String toStringWithValues
() {
StringBuilder result =
new StringBuilder(name +
"\t[");
for (int i =
0; i
< Math.
min(bitNames.
length,
8); i++
) {
if (i
!=
0)
result.
append(", ");
result.
append(bitNames
[i
] +
":"
+
((value
& (1 << i
)) !=
0 ? "1" :
"0"));
}
return result.
toString();
}
void toXML
(StringBuilder result
) {
result.
append(" <parameter name=\"" + name +
"\">\n");
for (int i =
0; i
< Math.
min(bitNames.
length,
8); i++
) {
result.
append(" <bit name=\"" + bitNames
[i
] +
"\" value=\""
+
((value
& (1 << i
)) !=
0 ? "1" :
"0") +
"\"/>\n");
}
result.
append(" </parameter>\n");
}
}