question: @ SuppressWarnings ( { "unchecked" } ) @ Override public byte [ ] serialize ( List list ) { if ( list == null ) return null ; final int size = list . size ( ) ; final int [ ] valueIDs = new int [ size ] ; final byte [ ] [ ] valueBytes = new byte [ size ] [ ] ; int totalSize = 4 + size * 8 ; int i = 0 ; Iterator iter = list . iterator ( ) ; while ( iter . hasNext ( ) ) { final Object value = iter . next ( ) ; Class < ? > valueClass = value . getClass ( ) ; int valueTypeID = EntityDefinitionManager . getIDBySerDerClass ( valueClass ) ; if ( valueTypeID == - 1 ) { if ( value instanceof List ) { valueClass = List . class ; valueTypeID = EntityDefinitionManager . getIDBySerDerClass ( valueClass ) ; } else if ( value instanceof Map ) { valueClass = Map . class ; valueTypeID = EntityDefinitionManager . getIDBySerDerClass ( valueClass ) ; } else { throw new IllegalArgumentException ( "Unsupported class: " + valueClass . getName ( ) ) ; } } valueIDs [ i ] = valueTypeID ; final EntitySerDeser valueSerDer = EntityDefinitionManager . getSerDeser ( valueClass ) ; if ( valueSerDer == null ) { throw new IllegalArgumentException ( "Unsupported class: " + valueClass . getName ( ) ) ; } valueBytes [ i ] = valueSerDer . serialize ( value ) ; totalSize += valueBytes [ i ] . length ; ++ i ; } final byte [ ] result = new byte [ totalSize ] ; int offset = 0 ; ByteUtil . intToBytes ( size , result , offset ) ; offset += 4 ; for ( i = 0 ; i < size ; ++ i ) { ByteUtil . intToBytes ( valueIDs [ i ] , result , offset ) ; offset += 4 ; ByteUtil . intToBytes ( valueBytes [ i ] . length , result , offset ) ; offset += 4 ; System . arraycopy ( valueBytes [ i ] , 0 , result , offset , valueBytes [ i ] . length ) ; offset += valueBytes [ i ] . length ; } return result ; }
target:  size + value1 type id + value length + value1 binary content + ... 4B         4B              4B              value1 bytes