/** * Formats the given data into a string value depending on the data type.<p> * * @param data the data to format * * @return a string representation of the given data */ public static String format(Object data) { if (data == null) { return null; } Class<?> clazz = data.getClass(); if (clazz.equals(Date.class)) { return format(((Date)data).getTime()); } return data.toString(); }
/** * Formats the given data into a string value depending on the data type.<p> * * @param data the data to format * * @return a string representation of the given data */ public static String format(Object data) { if (data == null) { return null; } Class clazz = data.getClass(); if (clazz.equals(Date.class)) { return format(((Date)data).getTime()); } return data.toString(); }
/** * Returns a ready to export string representation of the given object.<p> * * For not parseable objects, base64 encoded string with the serialized object is generated.<p> * * @param data the object to export * * @return the string representation * * @throws IOException if something goes wrong */ public static String dataExport(Object data) throws IOException { if (CmsDataTypeUtil.isParseable(data.getClass())) { return CmsDataTypeUtil.format(data); } ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream oout = new ObjectOutputStream(bout); oout.writeObject(data); oout.close(); return new String(Base64.encodeBase64(bout.toByteArray())); }
/** * Returns a ready to export string representation of the given object.<p> * * For not parseable objects, base64 encoded string with the serialized object is generated.<p> * * @param data the object to export * * @return the string representation * * @throws IOException if something goes wrong */ public static String dataExport(Object data) throws IOException { if (CmsDataTypeUtil.isParseable(data.getClass())) { return CmsDataTypeUtil.format(data); } ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream oout = new ObjectOutputStream(bout); oout.writeObject(data); oout.close(); return new String(Base64.encodeBase64(bout.toByteArray())); }
return format(data).getBytes();
return format(data).getBytes();