public int countTokens() 
    {
        int result = 0;
        if (hasMoreTokens()) {
            if (m_tokenOffset_ >= 0) {
                return m_tokenSize_ - m_tokenOffset_;
            }
            if (m_tokenStart_ == null) {
                m_tokenStart_ = new int[TOKEN_SIZE_];
                m_tokenLimit_ = new int[TOKEN_SIZE_];
            }
            do {
                if (m_tokenStart_.length == result) {
                    int temptokenindex[] = m_tokenStart_;
                    int temptokensize[] = m_tokenLimit_;
                    int originalsize = temptokenindex.length;
                    int newsize = originalsize + TOKEN_SIZE_;
                    m_tokenStart_ = new int[newsize];
                    m_tokenLimit_ = new int[newsize];
                    System.arraycopy(temptokenindex, 0, m_tokenStart_, 0, 
                                     originalsize);
                    System.arraycopy(temptokensize, 0, m_tokenLimit_, 0, 
                                     originalsize);
                }
                m_tokenStart_[result] = m_nextOffset_;
                if (m_returnDelimiters_) {
                    int c = UTF16.charAt(m_source_, m_nextOffset_);
                    boolean contains = delims == null 
                        ? m_delimiters_.contains(c) 
                        : c < delims.length && delims[c];
                    if (contains) {
                        if (m_coalesceDelimiters_) {
                            m_tokenLimit_[result] = getNextNonDelimiter(
                                                                m_nextOffset_);
                        } else {
                            int p = m_nextOffset_ + 1;
                            if (p == m_length_) {
                                p = -1;
                            }
                            m_tokenLimit_[result] = p;

                        }
                    }
                    else {
                        m_tokenLimit_[result] = getNextDelimiter(m_nextOffset_);
                    }
                    m_nextOffset_ = m_tokenLimit_[result];
                }
                else {
                    m_tokenLimit_[result] = getNextDelimiter(m_nextOffset_);
                    m_nextOffset_ = getNextNonDelimiter(m_tokenLimit_[result]);
                }
                result ++;
            } while (m_nextOffset_ >= 0);
            m_tokenOffset_ = 0;
            m_tokenSize_ = result;
            m_nextOffset_ = m_tokenStart_[0];
        }
        return result;
    }
public int countTokens ( ) { int result = 0 ; if ( hasMoreTokens ( ) ) { if ( m_tokenOffset_ >= 0 ) { return m_tokenSize_ - m_tokenOffset_ ; } if ( m_tokenStart_ == null ) { m_tokenStart_ = new int [ TOKEN_SIZE_ ] ; m_tokenLimit_ = new int [ TOKEN_SIZE_ ] ; } do { if ( m_tokenStart_ . length == result ) { int temptokenindex [ ] = m_tokenStart_ ; int temptokensize [ ] = m_tokenLimit_ ; int originalsize = temptokenindex . length ; int newsize = originalsize + TOKEN_SIZE_ ; m_tokenStart_ = new int [ newsize ] ; m_tokenLimit_ = new int [ newsize ] ; System . arraycopy ( temptokenindex , 0 , m_tokenStart_ , 0 , originalsize ) ; System . arraycopy ( temptokensize , 0 , m_tokenLimit_ , 0 , originalsize ) ; } m_tokenStart_ [ result ] = m_nextOffset_ ; if ( m_returnDelimiters_ ) { int c = UTF16 . charAt ( m_source_ , m_nextOffset_ ) ; boolean contains = delims == null ? m_delimiters_ . contains ( c ) : c < delims . length && delims [ c ] ; if ( contains ) { if ( m_coalesceDelimiters_ ) { m_tokenLimit_ [ result ] = getNextNonDelimiter ( m_nextOffset_ ) ; } else { int p = m_nextOffset_ + 1 ; if ( p == m_length_ ) { p = - 1 ; } m_tokenLimit_ [ result ] = p ; } } else { m_tokenLimit_ [ result ] = getNextDelimiter ( m_nextOffset_ ) ; } m_nextOffset_ = m_tokenLimit_ [ result ] ; } else { m_tokenLimit_ [ result ] = getNextDelimiter ( m_nextOffset_ ) ; m_nextOffset_ = getNextNonDelimiter ( m_tokenLimit_ [ result ] ) ; } result ++ ; } while ( m_nextOffset_ >= 0 ) ; m_tokenOffset_ = 0 ; m_tokenSize_ = result ; m_nextOffset_ = m_tokenStart_ [ 0 ] ; } return result ; }
Calculates the number of times that this tokenizer's
<code>nextToken</code> method can be called before it generates an
exception. The current position is not advanced.
@return the number of tokens remaining in the string using the
current delimiter set.
@see #nextToken()