// Decompiled by DJ v2.6.6.51 Copyright 2000 Atanas Neshkov  Date: 10/2/2001 11:01:03
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   com/macromedia/generator/utils/Tokenizer

package com.macromedia.generator.utils;


public class Tokenizer
{

    public Tokenizer(String s)
    {
        _fld0291 = false;
        _fld028D = s;
        if(s != null)
            _fld028F = s.length();
        _fld028E = 0;
        _fld0108 = ',';
        _fld0290 = '\\';
        _fld0291 = false;
    }

    public boolean EOS()
    {
        return _fld028E >= _fld028F;
    }

    private char _mth028D(int i)
    {
        if(i < 0 || i >= _fld028F)
            return '\n';
        else
            return _fld028D.charAt(i);
    }

    public void cullEmptyTokens(boolean flag)
    {
        _fld0291 = flag;
    }

    private char _mth028E()
    {
        char c = _fld028D.charAt(_fld028E);
        if(c == _fld0290)
            if(_fld028E < _fld028F - 1)
                c = _fld028D.charAt(_fld028E + 1);
            else
                c = ' ';
        return c;
    }

    private void _mth028F()
    {
        if(_mth028D(_fld028E) == _fld0290)
            _fld028E += 2;
        else
            _fld028E++;
    }

    private boolean _mth0290()
    {
        boolean flag = false;
        char c = _fld028D.charAt(_fld028E);
        if(c == _fld0108)
        {
            int i = _fld028E - 1;
            int j = 0;
            for(; _mth028D(i) == _fld0290; i--)
                j++;

            if(j % 2 == 0)
                flag = true;
        }
        return flag;
    }

    public String nextToken()
    {
        String s = "";
        if(EOS())
            return null;
        if(_fld0291)
            for(; !EOS() && _mth0290(); _mth028F());
        for(; !EOS() && !_mth0290(); _mth028F())
        {
            char c = _mth028E();
            s = s + c;
        }

        _mth028F();
        s = s.trim();
        return s;
    }

    public void reset()
    {
        _fld028E = 0;
    }

    public void setDelimiter(char c)
    {
        _fld0108 = c;
    }

    public void setEscape(char c)
    {
        _fld0290 = c;
    }

    private String _fld028D;
    private int _fld028E;
    private int _fld028F;
    private char _fld0108;
    private char _fld0290;
    private boolean _fld0291;
}