protected TokenCodes findCRLFTokenLength(WsByteBuffer buff) throws MalformedMessageException {

        TokenCodes rc = TokenCodes.TOKEN_RC_MOREDATA;

        if (null == buff) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Null buffer provided");
            }
            return rc;
        }

        // start with any pre-existing data
        int length = this.parsedTokenLength;
        byte b;
        while (true) {
            if (this.bytePosition >= this.byteLimit) {
                if (!fillByteCache(buff)) {
                    // no more data
                    break;
                }
            }
            b = this.byteCache[this.bytePosition++];

            // check for a CRLF
            if (BNFHeaders.CR == b) {
                rc = TokenCodes.TOKEN_RC_DELIM;
                if (HeaderStorage.NOTSET != this.headerChangeLimit) {
                    this.lastCRLFPosition = findCurrentBufferPosition(buff) - 1;
                    this.lastCRLFBufferIndex = this.parseIndex;
                    this.lastCRLFisCR = true;
                }
                break; // out of while
            } else if (BNFHeaders.LF == b) {
                // update counter if linefeed found
                rc = TokenCodes.TOKEN_RC_DELIM;
                this.numCRLFs = 1;
                if (HeaderStorage.NOTSET != this.headerChangeLimit) {
                    this.lastCRLFPosition = findCurrentBufferPosition(buff) - 1;
                    this.lastCRLFBufferIndex = this.parseIndex;
                    this.lastCRLFisCR = false;
                }
                break; // out of while
            }

            length++;
            // check the limit on a token size
            if (length > this.limitTokenSize) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "findCRLFTokenLength: length is too big: " + length);
                }
                throw new MalformedMessageException("Token length: " + length);
            }
        } // end of the while

        this.parsedTokenLength = length;
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "findCRLFTokenLength returning " + rc.getName() + "; len=" + length);
        }
        return rc;
    }
protected TokenCodes findCRLFTokenLength ( WsByteBuffer buff ) throws MalformedMessageException { TokenCodes rc = TokenCodes . TOKEN_RC_MOREDATA ; if ( null == buff ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Null buffer provided" ) ; } return rc ; } int length = this . parsedTokenLength ; byte b ; while ( true ) { if ( this . bytePosition >= this . byteLimit ) { if ( ! fillByteCache ( buff ) ) { break ; } } b = this . byteCache [ this . bytePosition ++ ] ; if ( BNFHeaders . CR == b ) { rc = TokenCodes . TOKEN_RC_DELIM ; if ( HeaderStorage . NOTSET != this . headerChangeLimit ) { this . lastCRLFPosition = findCurrentBufferPosition ( buff ) - 1 ; this . lastCRLFBufferIndex = this . parseIndex ; this . lastCRLFisCR = true ; } break ; } else if ( BNFHeaders . LF == b ) { rc = TokenCodes . TOKEN_RC_DELIM ; this . numCRLFs = 1 ; if ( HeaderStorage . NOTSET != this . headerChangeLimit ) { this . lastCRLFPosition = findCurrentBufferPosition ( buff ) - 1 ; this . lastCRLFBufferIndex = this . parseIndex ; this . lastCRLFisCR = false ; } break ; } length ++ ; if ( length > this . limitTokenSize ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "findCRLFTokenLength: length is too big: " + length ) ; } throw new MalformedMessageException ( "Token length: " + length ) ; } } this . parsedTokenLength = length ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "findCRLFTokenLength returning " + rc . getName ( ) + "; len=" + length ) ; } return rc ; }
Parse a CRLF delimited token and return the length of the token.

@param buff
@return TokenCodes (global length variable is set to parsed length)
@throws MalformedMessageException