예제 #1
0
 @Override
 public void writeDynamicGroup(ByteSink out, Object group)
     throws IOException, IllegalArgumentException {
   if (out instanceof ByteBuf) {
     ByteBuf buf = (ByteBuf) out;
     int start = buf.position();
     buf.skip(4); // size
     writeStaticGroupWithId(buf, group);
     int end = buf.position();
     int size = end - start - 4;
     buf.position(start);
     buf.writeIntLE(size);
     buf.position(end);
   } else {
     byte[] tmpBuf = codec.bufferPool().get();
     try {
       ByteArrayBuf tmpOut = new ByteArrayBuf(tmpBuf);
       writeDynamicGroup(tmpOut, group);
       tmpOut.flip();
       tmpOut.copyTo(out);
     } finally {
       codec.bufferPool().release(tmpBuf);
     }
   }
 }