/** * Casts to {@link com.opensymphony.util.Data} and returns bytes. */ public byte[] getData(String key) { try { Object data = get(DATA, key); if (data instanceof Data) { return ((Data) data).getBytes(); } else if (data instanceof byte[]) { return (byte[]) data; } } catch (NullPointerException e) { return null; } return null; }
/** * Constructs {@link com.opensymphony.util.Data} wrapper around bytes. */ public void setData(String key, byte[] value) { set(DATA, key, new Data(value)); }
valueNode = doc.createCDATASection(TextUtils.encodeBytes(((Data) value).getBytes())); } catch (IOException ioe) { return; // cannot save data - carry on with rest of properties.
return new Data(TextUtils.decodeBytes(text)); } catch (IOException ioe) { return null; // if data cannot be decoded, ignore it.
value = new sun.misc.BASE64Encoder().encode(((Data) valueEntry.getValue()).getBytes());
item.setData(((Data)value).getBytes());