public int transferFrom ( MessageBatch other , boolean clear ) { if ( other == null || this == other ) return 0 ; int capacity = messages . length , other_size = other . size ( ) ; if ( other_size == 0 ) return 0 ; if ( capacity < other_size ) messages = new Message [ other_size ] ; System . arraycopy ( other . messages , 0 , this . messages , 0 , other_size ) ; if ( this . index > other_size ) for ( int i = other_size ; i < this . index ; i ++ ) messages [ i ] = null ; this . index = other_size ; if ( clear ) other . clear ( ) ; return other_size ; }
Transfers messages from other to this batch . Optionally clears the other batch after the transfer