private int parseCurrentNumber(ByteBuf buffer){
  int number=0;
  int readerIndex=buffer.readerIndex();
  byte b=0;
  while (true) {
    if (!buffer.isReadable())     return Integer.MIN_VALUE;
    b=buffer.readByte();
    if (Character.isDigit(b)) {
      number=number * 10 + (int)(b - '0');
      readerIndex++;
    }
 else {
      buffer.readerIndex(readerIndex);
      break;
    }
  }
  return number;
}

private int parseCurrentNumber ( ByteBuf buffer ) { int number = 0 ; int readerIndex = buffer . readerIndex ( ) ; byte b = 0 ; while ( true ) { if ( ! buffer . isReadable ( ) ) return Integer . MIN_VALUE ; b = buffer . readByte ( ) ; if ( Character . isDigit ( b ) ) { number = number * 10 + ( int ) ( b - '0' ) ; readerIndex ++ ; } else { buffer . readerIndex ( readerIndex ) ; break ; } } return number ; }
helper method to parse the number at the beginning of the buffer
