}
/* Store current values. */
final public static byte[] storeValues(Item[] items) {
//#ifdef DLOGGING
Logger logger = Logger.getLogger("UiUtil");
boolean finestLoggable = logger.isLoggable(Level.FINEST);
//#endif
ByteArrayOutputStream bout = new
ByteArrayOutputStream();
DataOutputStream dout = new
DataOutputStream( bout );
for (int ic = 0; ic < items.length; ic++) {
try {
final Item item = items[ic];
if (item instanceof ChoiceGroup) {
dout.writeInt(((ChoiceGroup)item).getSelectedIndex());
//#ifdef DLOGGING
if (finestLoggable) {logger.finest("stored selected " + item.getLabel() + "," + ((ChoiceGroup)item).getSelectedIndex());}
//#endif
} else if (item instanceof TextField) {
final String value = ((TextField)item).getString();
dout.writeInt(value.length());
byte [] bvalue;
try {
bvalue = value.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
bvalue = value.getBytes();
//#ifdef DLOGGING
logger.severe("cannot store value=" + value, e);
//#endif
}
dout.write( bvalue, 0, bvalue.length );
//#ifdef DLOGGING
if (finestLoggable) {logger.finest("set string " + item.getLabel() + "," + ((TextField)item).getString());}
//#endif
}
} catch (IOException e) {
//#ifdef DLOGGING
logger.severe("IOException storing selected.", e);
//#endif
}
}
//#ifdef DLOGGING
if (finestLoggable) {logger.finest("bout.toByteArray().length=" + bout.toByteArray().length);}
//#endif
if (dout != null) {
try { dout.close(); } catch (IOException e) {}
}
return bout.toByteArray();