public boolean hasMoreTokens()
    {
        // Already found a token
        if (_hasToken)
            return true;
        
        _lastStart=_i;
        
        int state=0;
        boolean escape=false;
        while (_i<_string.length())
        {
            char c=_string.charAt(_i++);
            
            switch (state)
            {
              case 0: // Start
                  if(_delim.indexOf(c)>=0)
                  {
                      if (_returnTokens)
                      {
                          _token.append(c);
                          return _hasToken=true;
                      }
                  }
                  else if (c=='\'' && _single)
                  {
                      if (_returnQuotes)
                          _token.append(c);
                      state=2;
                  }
                  else if (c=='\"' && _double)
                  {
                      if (_returnQuotes)
                          _token.append(c);
                      state=3;
                  }
                  else
                  {
                      _token.append(c);
                      _hasToken=true;
                      state=1;
                  }
                  continue;
                  
              case 1: // Token
                  _hasToken=true;
                  if(_delim.indexOf(c)>=0)
                  {
                      if (_returnTokens)
                          _i--;
                      return _hasToken;
                  }
                  else if (c=='\'' && _single)
                  {
                      if (_returnQuotes)
                          _token.append(c);
                      state=2;
                  }
                  else if (c=='\"' && _double)
                  {
                      if (_returnQuotes)
                          _token.append(c);
                      state=3;
                  }
                  else
                      _token.append(c);
                  continue;

                  
              case 2: // Single Quote
                  _hasToken=true;
                  if (escape)
                  {
                      escape=false;
                      _token.append(c);
                  }
                  else if (c=='\'')
                  {
                      if (_returnQuotes)
                          _token.append(c);
                      state=1;
                  }
                  else if (c=='\\')
                  {
                      if (_returnQuotes)
                          _token.append(c);
                      escape=true;
                  }
                  else
                      _token.append(c);
                  continue;

                  
              case 3: // Double Quote
                  _hasToken=true;
                  if (escape)
                  {
                      escape=false;
                      _token.append(c);
                  }
                  else if (c=='\"' )
                  {
                      if (_returnQuotes)
                          _token.append(c);
                      state=1;
                  }
                  else if (c=='\\')
                  {
                      if (_returnQuotes)
                          _token.append(c);
                      escape=true;
                  }
                  else
                      _token.append(c);
                  continue;
            }
        }

        return _hasToken;
    }
public boolean hasMoreTokens ( ) { if ( _hasToken ) return true ; _lastStart = _i ; int state = 0 ; boolean escape = false ; while ( _i < _string . length ( ) ) { char c = _string . charAt ( _i ++ ) ; switch ( state ) { case 0 : if ( _delim . indexOf ( c ) >= 0 ) { if ( _returnTokens ) { _token . append ( c ) ; return _hasToken = true ; } } else if ( c == '\'' && _single ) { if ( _returnQuotes ) _token . append ( c ) ; state = 2 ; } else if ( c == '\"' && _double ) { if ( _returnQuotes ) _token . append ( c ) ; state = 3 ; } else { _token . append ( c ) ; _hasToken = true ; state = 1 ; } continue ; case 1 : _hasToken = true ; if ( _delim . indexOf ( c ) >= 0 ) { if ( _returnTokens ) _i -- ; return _hasToken ; } else if ( c == '\'' && _single ) { if ( _returnQuotes ) _token . append ( c ) ; state = 2 ; } else if ( c == '\"' && _double ) { if ( _returnQuotes ) _token . append ( c ) ; state = 3 ; } else _token . append ( c ) ; continue ; case 2 : _hasToken = true ; if ( escape ) { escape = false ; _token . append ( c ) ; } else if ( c == '\'' ) { if ( _returnQuotes ) _token . append ( c ) ; state = 1 ; } else if ( c == '\\' ) { if ( _returnQuotes ) _token . append ( c ) ; escape = true ; } else _token . append ( c ) ; continue ; case 3 : _hasToken = true ; if ( escape ) { escape = false ; _token . append ( c ) ; } else if ( c == '\"' ) { if ( _returnQuotes ) _token . append ( c ) ; state = 1 ; } else if ( c == '\\' ) { if ( _returnQuotes ) _token . append ( c ) ; escape = true ; } else _token . append ( c ) ; continue ; } } return _hasToken ; }
/* ------------------------------------------------------------