public static Pair<Integer,Integer> streamReadBytes(ActiveMQBuffer buff,int remainingBytes,byte[] value){
  if (remainingBytes == -1) {
    return new Pair<>(0,-1);
  }
 else   if (remainingBytes == 0) {
    byte type=buff.readByte();
    if (type != DataConstants.BYTES) {
      throw new IllegalStateException("Invalid conversion");
    }
    remainingBytes=buff.readInt();
  }
  int read=Math.min(value.length,remainingBytes);
  buff.readBytes(value,0,read);
  remainingBytes-=read;
  if (remainingBytes == 0) {
    remainingBytes=-1;
  }
  return new Pair<>(remainingBytes,read);
}

public static Pair < Integer , Integer > streamReadBytes ( ActiveMQBuffer buff , int remainingBytes , byte [ ] value ) { if ( remainingBytes == - 1 ) { return new Pair < > ( 0 , - 1 ) ; } else if ( remainingBytes == 0 ) { byte type = buff . readByte ( ) ; if ( type != DataConstants . BYTES ) { throw new IllegalStateException ( "Invalid conversion" ) ; } remainingBytes = buff . readInt ( ) ; } int read = Math . min ( value . length , remainingBytes ) ; buff . readBytes ( value , 0 , read ) ; remainingBytes -= read ; if ( remainingBytes == 0 ) { remainingBytes = - 1 ; } return new Pair < > ( remainingBytes , read ) ; }
utility for reading bytes out of streaming . it will return remainingbytes , bytesread
