/** * Deserializes the input parameter and returns an Object which must then be cast to a core data * type * * @param <T> type * @param in input * @param target target * @return Object object */ @SuppressWarnings("unchecked") public <T> T deserialize(Input in, Type target) { byte type = in.readDataType(); log.debug("Type: {}", type); while (type == DataTypes.CORE_SKIP) { type = in.readDataType(); log.debug("Type (skip): {}", type); } log.debug("Datatype: {}", DataTypes.toStringValue(type)); Object result; switch (type) { case DataTypes.CORE_NULL: result = in.readNull(target); break; case DataTypes.CORE_BOOLEAN: result = in.readBoolean(target); break; case DataTypes.CORE_NUMBER: result = in.readNumber(target); break; case DataTypes.CORE_STRING: result = in.readString(target); break; case DataTypes.CORE_DATE: result = in.readDate(target); break; case DataTypes.CORE_ARRAY: result = in.readArray(this, target); break; case DataTypes.CORE_MAP: result = in.readMap(this, target); break; case DataTypes.CORE_XML: result = in.readXML(target); break; case DataTypes.CORE_OBJECT: result = in.readObject(this, target); break; case DataTypes.CORE_BYTEARRAY: result = in.readByteArray(target); break; case DataTypes.OPT_REFERENCE: result = in.readReference(target); break; default: result = in.readCustom(target); break; } return (T) postProcessExtension(result, target); }
/** * Deserializes the input parameter and returns an Object which must then be cast to a core data * type * * @param in * @param target * @return Object */ public <T> T deserialize(Input in, Class<T> target) { byte type = in.readDataType(); while (type == DataTypes.CORE_SKIP) { type = in.readDataType(); } if (log.isDebugEnabled()) { log.debug("Datatype: " + DataTypes.toStringValue(type)); } Object result; switch (type) { case DataTypes.CORE_NULL: result = in.readNull(); break; case DataTypes.CORE_BOOLEAN: result = in.readBoolean(); break; case DataTypes.CORE_NUMBER: result = in.readNumber(); break; case DataTypes.CORE_STRING: result = in.readString(); break; case DataTypes.CORE_DATE: result = in.readDate(); break; case DataTypes.CORE_ARRAY: result = in.readArray(this); break; case DataTypes.CORE_MAP: result = in.readMap(this); break; case DataTypes.CORE_XML: result = in.readXML(); break; case DataTypes.CORE_OBJECT: result = in.readObject(this); break; case DataTypes.CORE_BYTEARRAY: result = in.readByteArray(); break; case DataTypes.OPT_REFERENCE: result = in.readReference(); break; default: result = in.readCustom(); break; } return (T) postProcessExtension(result, target); }