public static Buffer expectDigit(final Buffer buffer) throws SipParseException {
        final int start = buffer.getReaderIndex();
        try {

            while (buffer.hasReadableBytes() && isNextDigit(buffer)) {
                // consume it
                buffer.readByte();
            }

            if (start == buffer.getReaderIndex()) {
                throw new SipParseException(start, "Expected digit");
            }

            return buffer.slice(start, buffer.getReaderIndex());
        } catch (final IndexOutOfBoundsException e) {
            throw new SipParseException(start, "Expected digit but no more bytes to read");
        } catch (final IOException e) {
            throw new SipParseException(start, "Expected digit unable to read from underlying stream");
        }
    }
public static Buffer expectDigit ( final Buffer buffer ) throws SipParseException { final int start = buffer . getReaderIndex ( ) ; try { while ( buffer . hasReadableBytes ( ) && isNextDigit ( buffer ) ) { buffer . readByte ( ) ; } if ( start == buffer . getReaderIndex ( ) ) { throw new SipParseException ( start , "Expected digit" ) ; } return buffer . slice ( start , buffer . getReaderIndex ( ) ) ; } catch ( final IndexOutOfBoundsException e ) { throw new SipParseException ( start , "Expected digit but no more bytes to read" ) ; } catch ( final IOException e ) { throw new SipParseException ( start , "Expected digit unable to read from underlying stream" ) ; } }
Will expect at least 1 digit and will continue consuming bytes until a
non-digit is encountered

@param buffer
the buffer to consume the digits from
@return the buffer containing digits only
@throws SipParseException
in case there is not one digit at the first position in the
buffer (where the current reader index is pointing to)
@throws IOException
@throws IndexOutOfBoundsException