public <T> T deepCopy(T metadata) { return (T) asObject(asByteArray(metadata)); }
public <T> T deepCopy(T metadata) { return (T) asObject(asByteArray(metadata)); }
public static <T> T unserialize(byte[] bytes) { return (T) CONFIGURATION.asObject(bytes); }
@Override public <T> T deserialize(byte[] bytes, Class<T> clz) throws IOException { if (bytes == null || bytes.length == 0) { return null; } return (T) fst.asObject(bytes); }
@Override public Object deserialize(byte[] bytes, Class<?> type) throws Exception { return FST.asObject(bytes); } }
@Override public Object deserialize(byte[] bytes) { return conf.asObject(bytes); }
@Override public Object deserialize(byte[] data) { return conf.asObject(data); } }
public Object deserialize(byte[] bytes, Type clazz) { if (null == bytes || bytes.length == 0) { return null; } try { return conf.asObject(bytes); } catch (Exception e) { logger.error("反序列化失败", e); return null; } }
@SuppressWarnings("unchecked") @Override public E deserialize(ByteBuffer buf) { int length = buf.getInt(); byte[] array = new byte[length]; buf.get(array); return (E) FST.asObject(array); }
@Override public Object deserialize(byte[] bytes) { if (bytes == null || bytes.length == 0) { return null; } try { return fst.asObject(bytes); } catch (Throwable ex) { LOG.error(ex.toString(), ex); } return null; }
@Override public Optional<Serializable> deserialize(JsonNode json) { try { return Optional.of((Serializable) CONFIGURATION.asObject(new ObjectMapper().writer().writeValueAsBytes(json))); } catch (JsonProcessingException e) { throw new UncheckedIOException(e); } }
@SuppressWarnings("unchecked") public static <T> T fromJson(FSTConfiguration fst, String json, Class<T> clazz) { if (StringUtils.isEmpty(json)) { throw new SerializerException("Json is null or empty"); } return (T) fst.asObject(json.getBytes()); } }
@Override public T decode(CachedData cachedData) { final FSTConfiguration fstConfiguration = fstConfigurationContainer.get(); @SuppressWarnings("unchecked") final T deserialized = (T) fstConfiguration.asObject(cachedData.getData()); return deserialized; }
@SuppressWarnings("unchecked") public static <T> T deserialize(FSTConfiguration fst, byte[] bytes) { if (ArrayUtils.isEmpty(bytes)) { throw new SerializerException("Bytes is null or empty"); } return (T) fst.asObject(bytes); } }
/** * Deserializes the specified Class type from the specified byte array * * @param bytes the byte array containing the object to be deserialized * @return the deserialized object of type <T> */ @SuppressWarnings("unchecked") public <T extends Persistable> T deSerialize(byte[] bytes) { T retVal = (T)fastSerialConfig.asObject(bytes); return retVal.postDeSerialize(); }
@OnMessage public void onMessage(byte[] message) { if ( DumpProtocol ) { System.out.println("resp:"); System.out.println(new String(message,0)); } sink.receiveObject(conf.asObject(message), null, null ); }
@OnMessage public void onTextMessage(String message) { if ( DumpProtocol ) { System.out.println("resp:"); System.out.println(message); } sink.receiveObject(conf.asObject(message.getBytes() /*is already utf 8*/), null, null ); }
@Override public Optional<ResourceMetadata> get(Context context, Resource resource) { try (Jedis jedis = m_pool.getResource()) { final byte[] bytes = jedis.get(key(METADATA_PREFIX, context.getId(), resource.getId())); return (bytes != null) ? Optional.of((ResourceMetadata)conf.asObject(bytes)): Optional.absent(); } }
@Override public Optional<ResourceMetadata> get(Context context, Resource resource) { try (Jedis jedis = m_pool.getResource()) { final byte[] bytes = jedis.get(key(METADATA_PREFIX, context.getId(), resource.getId())); return (bytes != null) ? Optional.of((ResourceMetadata)conf.asObject(bytes)): Optional.absent(); } }
private SerializableBindableModel fstRoundTrip(SerializableBindableModel model) { byte[] bytes = conf.asByteArray(model); SerializableBindableModel rehydrated = (SerializableBindableModel)conf.asObject(bytes); Assert.assertEquals(model, rehydrated); return rehydrated; } }