/** * Gets a value as bytes. If the column is Blob, bytes are * read directly, if not, then the value is converted to String first, then * string bytes are returned. Be careful out there, this will read entire * Blob onto memory. * * @param attributeName name of attribute * @return value as bytes. */ //TODO: use converters here? public byte[] getBytes(String attributeName) { Object value = get(attributeName); return Convert.toBytes(value); }
/** * Converts value to bytes array if it can. If the value is byte array, it is simply returned, * if it is a <code>java.sql.Blob</code>, then data is read from it as bytes. * In all other cases the object is converted to <code>String</code>, then bytes are read from it. * * @param value value to be converted. * @return value converted to byte array. */ public static byte[] toBytes(Object value) { if (value == null) { return null; } else if (value instanceof byte[]) { return (byte[]) value; } else if (value instanceof Blob) { return toBytes((Blob) value); } else { return toString(value).getBytes(); } }
/** * Gets a value as bytes. If the column is Blob, bytes are * read directly, if not, then the value is converted to String first, then * string bytes are returned. Be careful out there, this will read entire * Blob onto memory. * * @param attributeName name of attribute * @return value as bytes. */ //TODO: use converters here? public byte[] getBytes(String attributeName) { Object value = get(attributeName); return Convert.toBytes(value); }
/** * Gets a value as bytes. If the column is Blob, bytes are * read directly, if not, then the value is converted to String first, then * string bytes are returned. Be careful out there, this will read entire * Blob onto memory. * * @param attributeName name of attribute * @return value as bytes. */ //TODO: use converters here? public byte[] getBytes(String attributeName) { Object value = get(attributeName); return Convert.toBytes(value); }
/** * Converts value to bytes array if it can. If the value is byte array, it is simply returned, * if it is a <code>java.sql.Blob</code>, then data is read from it as bytes. * In all other cases the object is converted to <code>String</code>, then bytes are read from it. * * @param value value to be converted. * @return value converted to byte array. */ public static byte[] toBytes(Object value) { if (value == null) { return null; } else if (value instanceof byte[]) { return (byte[]) value; } else if (value instanceof Blob) { return toBytes((Blob) value); } else { return toString(value).getBytes(); } }
/** * Converts value to bytes array if it can. If the value is byte array, it is simply returned, * if it is a <code>java.sql.Blob</code>, then data is read from it as bytes. * In all other cases the object is converted to <code>String</code>, then bytes are read from it. * * @param value value to be converted. * @return value converted to byte array. */ public static byte[] toBytes(Object value) { if (value == null) { return null; } else if (value instanceof byte[]) { return (byte[]) value; } else if (value instanceof Blob) { return toBytes((Blob) value); } else { return toString(value).getBytes(); } }