use of org.diirt.util.array.ListByte in project yamcs-studio by yamcs.
the class SimpleValueFormat method format.
/**
* Formats a numeric array. This method can be overridden to change
* the way numeric arrays are formatted.
*
* @param array the array to format
* @param toAppendTo the buffer to append to
* @param pos the position of the field
* @return the string buffer
*/
protected StringBuffer format(VNumberArray array, StringBuffer toAppendTo, FieldPosition pos) {
NumberFormat f = nf(array);
toAppendTo.append("[");
boolean hasMore = false;
ListNumber data = array.getData();
if (data.size() > maxElements) {
hasMore = true;
}
for (int i = 0; i < Math.min(data.size(), maxElements); i++) {
if (i != 0) {
toAppendTo.append(", ");
}
if (data instanceof ListByte || data instanceof ListShort || data instanceof ListInt || data instanceof ListLong) {
toAppendTo.append(f.format(data.getLong(i)));
} else {
toAppendTo.append(f.format(data.getDouble(i)));
}
}
if (hasMore) {
toAppendTo.append(", ...");
}
toAppendTo.append("]");
return toAppendTo;
}
Aggregations