@Test public void testSerializeNull() { Serializer serializer = new JavaObjectSerializer(); byte[] bvalue = serializer.serialize(null, null); char c = (char) Byte.valueOf( (byte)0 ).byteValue(); byte s = "0".getBytes()[0] ; System.out.println("asc 0: " + s +", c: " + c); }
public byte[] serialize(Object o, Object arg) { byte[] bvalue = null; if( o == null ) { bvalue = new byte[]{ Byte.valueOf( (byte) 0 )}; return bvalue; } ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject( o ); bvalue = baos.toByteArray(); return bvalue; } catch (IOException e) { throw new RuntimeException("Fail to serialize object: " + o +", cause: " + e, e); }finally { try { baos.close(); } catch (IOException e) { } } }
JavaObjectSerializer implements Serializer { public byte[] serialize(Object o, Object arg) { byte[] bvalue = null; if( o == null ) { bvalue = new byte[]{ Byte.valueOf( (byte) 0 )}; return bvalue; } ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject( o ); bvalue = baos.toByteArray(); return bvalue; } catch (IOException e) { throw new RuntimeException("Fail to serialize object: " + o +", cause: " + e, e); }finally { try { baos.close(); } catch (IOException e) { } } } }
JavaObjectSerializer implements Serializer { public byte[] serialize(Object o, Object arg) { byte[] bvalue = null; if( o == null ) { bvalue = new byte[]{ Byte.valueOf( (byte) 0 )}; return bvalue; } ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject( o ); bvalue = baos.toByteArray(); return bvalue; } catch (IOException e) { throw new RuntimeException("Fail to serialize object: " + o +", cause: " + e, e); }finally { try { baos.close(); } catch (IOException e) { } } }  }
JavaObjectSerializer implements Serializer { public byte[] serialize(Object o, Object arg) { byte[] bvalue = null; if( o == null ) { bvalue = new byte[]{ Byte.valueOf( (byte) 0 )}; return bvalue; } ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject( o ); bvalue = baos.toByteArray(); return bvalue; } catch (IOException e) { throw new RuntimeException("Fail to serialize object: " + o +", cause: " + e, e); }finally { try { baos.close(); } catch (IOException e) { } } }  Object deserialize(byte[] bvalue, Object deserializeTarget); byte[] serialize(Object o, Object arg); }
JavaObjectSerializer implements Serializer { public byte[] serialize(Object o, Object arg) { byte[] bvalue = null; if( o == null ) { bvalue = new byte[]{ Byte.valueOf( (byte) 0 )}; return bvalue; } ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject( o ); bvalue = baos.toByteArray(); return bvalue; } catch (IOException e) { throw new RuntimeException("Fail to serialize object: " + o +", cause: " + e, e); }finally { try { baos.close(); } catch (IOException e) { } } }  Object deserialize(byte[] bvalue, Object deserializeTarget); byte[] serialize(Object o, Object arg);  }