m_preparedStatement.setBytes(i + 1, CmsDataTypeUtil.dataSerialize(item)); } catch (IOException e) { e.printStackTrace();
/** * Returns the import data object.<p> * * @param value the exported value * @param type the expected data type * * @return the import data object * * @throws ClassNotFoundException if something goes wrong * @throws IOException if something goes wrong */ public static Object dataImport(String value, String type) throws ClassNotFoundException, IOException { Class<?> clazz = Class.forName(type); if (CmsDataTypeUtil.isParseable(clazz)) { return CmsDataTypeUtil.parse(value, clazz); } byte[] data = Base64.decodeBase64(value.getBytes()); return dataDeserialize(data, type); }
/** * Creates a new additional information entry for the current user.<p> * * @param infoName the name of the additional information entry * @param infoType the type of the additional information entry * @param infoValue the value of the additional information entry */ public void importUserInfo(String infoName, String infoType, String infoValue) { if (m_userInfos == null) { m_userInfos = new HashMap<String, Object>(); } try { m_userInfos.put(infoName, CmsDataTypeUtil.dataImport(infoValue, infoType)); } catch (Throwable e) { if (LOG.isErrorEnabled()) { LOG.error(e.getLocalizedMessage(), e); } } }
/** * Returns the deserialized (if needed) object.<p> * * @param data the data to deserialize * @param type the data type * * @return the deserialized object * * @throws IOException if the inputstream fails * @throws ClassNotFoundException if the serialized object fails */ public static Object dataDeserialize(byte[] data, String type) throws IOException, ClassNotFoundException { // check the type of the stored data Class<?> clazz = Class.forName(type); if (isParseable(clazz)) { // this is parseable data return parse(new String(data), clazz); } // this is a serialized object ByteArrayInputStream bin = new ByteArrayInputStream(data); ObjectInputStream oin = new ObjectInputStream(bin); return oin.readObject(); }
/** * 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 parseByte(data); return parseShort(data); return parseLong(data); return parseInt(data); return parseFloat(data); return parseDouble(data); return parseBoolean(data); return parseChar(data); return parseUUID(data); return parseDate(data);
Class<?>[] clazz = methods[i].getParameterTypes(); for (int j = 0; j < clazz.length; j++) { if (!CmsDataTypeUtil.isParseable(clazz[j])) {
String value = parameters.get(j); try { converted[j] = CmsDataTypeUtil.parse(value, clazz[j]); } catch (Throwable t) { match = false;
data = CmsDataTypeUtil.dataDeserialize(value, type);
/** * 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(); }
try { entryNode.addCDATA(CmsDataTypeUtil.dataExport(value)); } catch (IOException ioe) { getReport().println(ioe);
return parseByte(data); return parseShort(data); return parseLong(data); return parseInt(data); return parseFloat(data); return parseDouble(data); return parseBoolean(data); return parseChar(data); return parseUUID(data); return parseDate(data);
/** * Returns the deserialized (if needed) object.<p> * * @param data the data to deserialize * @param type the data type * * @return the deserialized object * * @throws IOException if the inputstream fails * @throws ClassNotFoundException if the serialized object fails */ public static Object dataDeserialize(byte[] data, String type) throws IOException, ClassNotFoundException { // check the type of the stored data Class clazz = Class.forName(type); if (isParseable(clazz)) { // this is parseable data return parse(new String(data), clazz); } // this is a serialized object ByteArrayInputStream bin = new ByteArrayInputStream(data); ObjectInputStream oin = new ObjectInputStream(bin); return oin.readObject(); }
/** * 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())); }
Class[] clazz = methods[i].getParameterTypes(); for (int j = 0; j < clazz.length; j++) { if (!CmsDataTypeUtil.isParseable(clazz[j])) {
String value = (String)parameters.get(j); try { converted[j] = CmsDataTypeUtil.parse(value, clazz[j]); } catch (Throwable t) { match = false;
data = CmsDataTypeUtil.dataDeserialize(value, type); } catch (Exception e) { LOG.warn(
/** * 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(); }
try { entryNode.addCDATA(CmsDataTypeUtil.dataExport(value)); } catch (IOException ioe) { getReport().println(ioe);
/** * Returns the import data object.<p> * * @param value the exported value * @param type the expected data type * * @return the import data object * * @throws ClassNotFoundException if something goes wrong * @throws IOException if something goes wrong */ public static Object dataImport(String value, String type) throws ClassNotFoundException, IOException { Class clazz = Class.forName(type); if (CmsDataTypeUtil.isParseable(clazz)) { return CmsDataTypeUtil.parse(value, clazz); } byte[] data = Base64.decodeBase64(value.getBytes()); return dataDeserialize(data, type); }