/* this file is generated by RelaxNGCC */
package relaxngcc.parser.state;
import org.xml.sax.SAXException;
import org.xml.sax.Attributes;
import relaxngcc.parser.ParserRuntime;

    import relaxngcc.grammar.*;
    import relaxngcc.datatype.Datatype;
    import org.xml.sax.Locator;
  


class NGCCLocalClass extends NGCCHandler {
    private NGCCCallParam cparam;
    private String name;
    private Pattern p;
    private Locator loc;
    private NGCCDefineParam dparam;
    protected final ParserRuntime $runtime;
    private int $_ngcc_current_state;
    protected String $uri;
    protected String $localName;
    protected String $qname;

    public final NGCCRuntime getRuntime() {
        return($runtime);
    }

    public NGCCLocalClass(NGCCHandler parent, NGCCEventSource source, ParserRuntime runtime, int cookie, Pattern _p, Locator _loc) {
        super(source, parent, cookie);
        $runtime = runtime;
        this.p = _p;
        this.loc = _loc;
        $_ngcc_current_state = 1;
    }

    public NGCCLocalClass(ParserRuntime runtime, Pattern _p, Locator _loc) {
        this(null, runtime, runtime, -1, _p, _loc);
    }

    private void action0()throws SAXException {
        // wrap it by Scope. Scope will then be turned into a class
      Scope sc = new Scope($runtime, name);
      sc.append(p,null);
      sc.setParam(dparam);
      
      // further wrap it by RefPattern
      p = new RefPattern($runtime, loc, sc, cparam );
}

    public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
        int $ai;
        $uri = $__uri;
        $localName = $__local;
        $qname = $__qname;
        switch($_ngcc_current_state) {
        case 0:
            {
                revertToParentFromEnterElement(p, super._cookie, $__uri, $__local, $__qname, $attrs);
            }
            break;
        case 1:
            {
                if(($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","class"))>=0) {
                    $runtime.consumeAttribute($ai);
                    $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
                }
                else {
                    $_ngcc_current_state = 0;
                    $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
                }
            }
            break;
        case 3:
            {
                if((($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","alias"))>=0 || (($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","return-type"))>=0 || (($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","params"))>=0 || (($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","return-value"))>=0 || (($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","access"))>=0 || ($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","with-params"))>=0)))))) {
                    NGCCHandler h = new NGCCcall(this, super._source, $runtime, 8);
                    spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
                }
                else {
                    NGCCHandler h = new NGCCcall(this, super._source, $runtime, 8);
                    spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
                }
            }
            break;
        case 2:
            {
                if((($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","return-type"))>=0 || (($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","params"))>=0 || (($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","return-value"))>=0 || ($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","access"))>=0)))) {
                    NGCCHandler h = new NGCCDefineParamState(this, super._source, $runtime, 7, name);
                    spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
                }
                else {
                    NGCCHandler h = new NGCCDefineParamState(this, super._source, $runtime, 7, name);
                    spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
                }
            }
            break;
        default:
            {
                unexpectedEnterElement($__qname);
            }
            break;
        }
    }

    public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
        int $ai;
        $uri = $__uri;
        $localName = $__local;
        $qname = $__qname;
        switch($_ngcc_current_state) {
        case 0:
            {
                revertToParentFromLeaveElement(p, super._cookie, $__uri, $__local, $__qname);
            }
            break;
        case 1:
            {
                if(($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","class"))>=0) {
                    $runtime.consumeAttribute($ai);
                    $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
                }
                else {
                    $_ngcc_current_state = 0;
                    $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
                }
            }
            break;
        case 3:
            {
                if((($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","alias"))>=0 || (($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","return-type"))>=0 || (($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","params"))>=0 || (($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","return-value"))>=0 || (($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","access"))>=0 || ($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","with-params"))>=0)))))) {
                    NGCCHandler h = new NGCCcall(this, super._source, $runtime, 8);
                    spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
                }
                else {
                    NGCCHandler h = new NGCCcall(this, super._source, $runtime, 8);
                    spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
                }
            }
            break;
        case 2:
            {
                if((($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","return-type"))>=0 || (($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","params"))>=0 || (($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","return-value"))>=0 || ($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","access"))>=0)))) {
                    NGCCHandler h = new NGCCDefineParamState(this, super._source, $runtime, 7, name);
                    spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
                }
                else {
                    NGCCHandler h = new NGCCDefineParamState(this, super._source, $runtime, 7, name);
                    spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
                }
            }
            break;
        default:
            {
                unexpectedLeaveElement($__qname);
            }
            break;
        }
    }

    public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
        int $ai;
        $uri = $__uri;
        $localName = $__local;
        $qname = $__qname;
        switch($_ngcc_current_state) {
        case 0:
            {
                revertToParentFromEnterAttribute(p, super._cookie, $__uri, $__local, $__qname);
            }
            break;
        case 1:
            {
                if(($__uri.equals("http://www.xml.gr.jp/xmlns/relaxngcc") && $__local.equals("class"))) {
                    $_ngcc_current_state = 5;
                }
                else {
                    $_ngcc_current_state = 0;
                    $runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
                }
            }
            break;
        case 3:
            {
                if((($__uri.equals("http://www.xml.gr.jp/xmlns/relaxngcc") && $__local.equals("alias")) || (($__uri.equals("http://www.xml.gr.jp/xmlns/relaxngcc") && $__local.equals("return-type")) || (($__uri.equals("http://www.xml.gr.jp/xmlns/relaxngcc") && $__local.equals("params")) || (($__uri.equals("http://www.xml.gr.jp/xmlns/relaxngcc") && $__local.equals("return-value")) || (($__uri.equals("http://www.xml.gr.jp/xmlns/relaxngcc") && $__local.equals("access")) || ($__uri.equals("http://www.xml.gr.jp/xmlns/relaxngcc") && $__local.equals("with-params")))))))) {
                    NGCCHandler h = new NGCCcall(this, super._source, $runtime, 8);
                    spawnChildFromEnterAttribute(h, $__uri, $__local, $__qname);
                }
                else {
                    NGCCHandler h = new NGCCcall(this, super._source, $runtime, 8);
                    spawnChildFromEnterAttribute(h, $__uri, $__local, $__qname);
                }
            }
            break;
        case 2:
            {
                if((($__uri.equals("http://www.xml.gr.jp/xmlns/relaxngcc") && $__local.equals("return-type")) || (($__uri.equals("http://www.xml.gr.jp/xmlns/relaxngcc") && $__local.equals("params")) || (($__uri.equals("http://www.xml.gr.jp/xmlns/relaxngcc") && $__local.equals("return-value")) || ($__uri.equals("http://www.xml.gr.jp/xmlns/relaxngcc") && $__local.equals("access")))))) {
                    NGCCHandler h = new NGCCDefineParamState(this, super._source, $runtime, 7, name);
                    spawnChildFromEnterAttribute(h, $__uri, $__local, $__qname);
                }
                else {
                    NGCCHandler h = new NGCCDefineParamState(this, super._source, $runtime, 7, name);
                    spawnChildFromEnterAttribute(h, $__uri, $__local, $__qname);
                }
            }
            break;
        default:
            {
                unexpectedEnterAttribute($__qname);
            }
            break;
        }
    }

    public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
        int $ai;
        $uri = $__uri;
        $localName = $__local;
        $qname = $__qname;
        switch($_ngcc_current_state) {
        case 0:
            {
                revertToParentFromLeaveAttribute(p, super._cookie, $__uri, $__local, $__qname);
            }
            break;
        case 1:
            {
                $_ngcc_current_state = 0;
                $runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
            }
            break;
        case 4:
            {
                if(($__uri.equals("http://www.xml.gr.jp/xmlns/relaxngcc") && $__local.equals("class"))) {
                    $_ngcc_current_state = 3;
                }
                else {
                    unexpectedLeaveAttribute($__qname);
                }
            }
            break;
        case 3:
            {
                NGCCHandler h = new NGCCcall(this, super._source, $runtime, 8);
                spawnChildFromLeaveAttribute(h, $__uri, $__local, $__qname);
            }
            break;
        case 2:
            {
                NGCCHandler h = new NGCCDefineParamState(this, super._source, $runtime, 7, name);
                spawnChildFromLeaveAttribute(h, $__uri, $__local, $__qname);
            }
            break;
        default:
            {
                unexpectedLeaveAttribute($__qname);
            }
            break;
        }
    }

    public void text(String $value) throws SAXException {
        int $ai;
        switch($_ngcc_current_state) {
        case 0:
            {
                revertToParentFromText(p, super._cookie, $value);
            }
            break;
        case 1:
            {
                if(($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","class"))>=0) {
                    $runtime.consumeAttribute($ai);
                    $runtime.sendText(super._cookie, $value);
                }
                else {
                    $_ngcc_current_state = 0;
                    $runtime.sendText(super._cookie, $value);
                }
            }
            break;
        case 3:
            {
                if(($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","with-params"))>=0) {
                    NGCCHandler h = new NGCCcall(this, super._source, $runtime, 8);
                    spawnChildFromText(h, $value);
                }
                else {
                    if(($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","access"))>=0) {
                        NGCCHandler h = new NGCCcall(this, super._source, $runtime, 8);
                        spawnChildFromText(h, $value);
                    }
                    else {
                        if(($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","return-value"))>=0) {
                            NGCCHandler h = new NGCCcall(this, super._source, $runtime, 8);
                            spawnChildFromText(h, $value);
                        }
                        else {
                            if(($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","params"))>=0) {
                                NGCCHandler h = new NGCCcall(this, super._source, $runtime, 8);
                                spawnChildFromText(h, $value);
                            }
                            else {
                                if(($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","return-type"))>=0) {
                                    NGCCHandler h = new NGCCcall(this, super._source, $runtime, 8);
                                    spawnChildFromText(h, $value);
                                }
                                else {
                                    if(($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","alias"))>=0) {
                                        NGCCHandler h = new NGCCcall(this, super._source, $runtime, 8);
                                        spawnChildFromText(h, $value);
                                    }
                                    else {
                                        NGCCHandler h = new NGCCcall(this, super._source, $runtime, 8);
                                        spawnChildFromText(h, $value);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            break;
        case 5:
            {
                name = $value;
                $_ngcc_current_state = 4;
            }
            break;
        case 2:
            {
                if(($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","access"))>=0) {
                    NGCCHandler h = new NGCCDefineParamState(this, super._source, $runtime, 7, name);
                    spawnChildFromText(h, $value);
                }
                else {
                    if(($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","return-value"))>=0) {
                        NGCCHandler h = new NGCCDefineParamState(this, super._source, $runtime, 7, name);
                        spawnChildFromText(h, $value);
                    }
                    else {
                        if(($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","params"))>=0) {
                            NGCCHandler h = new NGCCDefineParamState(this, super._source, $runtime, 7, name);
                            spawnChildFromText(h, $value);
                        }
                        else {
                            if(($ai = $runtime.getAttributeIndex("http://www.xml.gr.jp/xmlns/relaxngcc","return-type"))>=0) {
                                NGCCHandler h = new NGCCDefineParamState(this, super._source, $runtime, 7, name);
                                spawnChildFromText(h, $value);
                            }
                            else {
                                NGCCHandler h = new NGCCDefineParamState(this, super._source, $runtime, 7, name);
                                spawnChildFromText(h, $value);
                            }
                        }
                    }
                }
            }
            break;
        }
    }

    public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
        switch($__cookie__) {
        case 8:
            {
                cparam = ((NGCCCallParam)$__result__);
                $_ngcc_current_state = 2;
            }
            break;
        case 7:
            {
                dparam = ((NGCCDefineParam)$__result__);
                action0();
                $_ngcc_current_state = 0;
            }
            break;
        }
    }

    public boolean accepted() {
        return((($_ngcc_current_state == 0) || ($_ngcc_current_state == 1)));
    }


}

