question: public static CodedInputStream newInstance ( ByteBuffer buf ) { if ( buf . hasArray ( ) ) { return newInstance ( buf . array ( ) , buf . arrayOffset ( ) + buf . position ( ) , buf . remaining ( ) ) ; } else { ByteBuffer temp = buf . duplicate ( ) ; byte [ ] buffer = new byte [ temp . remaining ( ) ] ; temp . get ( buffer ) ; return newInstance ( buffer ) ; } }
target:  Create a new CodedInputStream wrapping the given ByteBuffer. The data starting from the ByteBuffer's current position to its limit will be read. The returned CodedInputStream may or may not share the underlying data in the ByteBuffer, therefore the ByteBuffer cannot be changed while the CodedInputStream is in use. Note that the ByteBuffer's position won't be changed by this function. Concurrent calls with the same ByteBuffer object are safe if no other thread is trying to alter the ByteBuffer's status.