/* 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 GrammarContent extends NGCCHandler {
    private String href;
    private String value;
    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 GrammarContent(NGCCHandler parent, NGCCEventSource source, ParserRuntime runtime, int cookie) {
        super(source, parent, cookie);
        $runtime = runtime;
        $_ngcc_current_state = 1;
    }

    public GrammarContent(ParserRuntime runtime) {
        this(null, runtime, runtime, -1);
    }

    private void action0()throws SAXException {
        
            $runtime.processInclude(href);
          
}

    private void action1()throws SAXException {
        
            $runtime.getRootRuntime().appendGlobalBody(value);
          
}

    private void action2()throws SAXException {
        
            $runtime.getRootRuntime().appendGlobalImport(value);
          
}

    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:
            {
                if(($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("start"))) {
                    NGCCHandler h = new StartElement(this, super._source, $runtime, 447);
                    spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
                }
                else {
                    if(($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("define"))) {
                        NGCCHandler h = new DefineElement(this, super._source, $runtime, 448);
                        spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
                    }
                    else {
                        if(($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("div"))) {
                            $runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
                            $_ngcc_current_state = 19;
                        }
                        else {
                            if(($__uri.equals("http://www.xml.gr.jp/xmlns/relaxngcc") && $__local.equals("java-import"))) {
                                $runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
                                $_ngcc_current_state = 15;
                            }
                            else {
                                if(($__uri.equals("http://www.xml.gr.jp/xmlns/relaxngcc") && $__local.equals("java-body"))) {
                                    $runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
                                    $_ngcc_current_state = 11;
                                }
                                else {
                                    if(($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("include"))) {
                                        $runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
                                        $_ngcc_current_state = 7;
                                    }
                                    else {
                                        revertToParentFromEnterElement(this, super._cookie, $__uri, $__local, $__qname, $attrs);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            break;
        case 7:
            {
                if(($ai = $runtime.getAttributeIndex("","href"))>=0) {
                    $runtime.consumeAttribute($ai);
                    $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
                }
                else {
                    unexpectedEnterElement($__qname);
                }
            }
            break;
        case 4:
            {
                if((($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("define")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("div")) || ($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("start"))))) {
                    NGCCHandler h = new IncludeContent(this, super._source, $runtime, 411);
                    spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
                }
                else {
                    unexpectedEnterElement($__qname);
                }
            }
            break;
        case 1:
            {
                if(($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("start"))) {
                    NGCCHandler h = new StartElement(this, super._source, $runtime, 453);
                    spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
                }
                else {
                    if(($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("define"))) {
                        NGCCHandler h = new DefineElement(this, super._source, $runtime, 454);
                        spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
                    }
                    else {
                        if(($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("div"))) {
                            $runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
                            $_ngcc_current_state = 19;
                        }
                        else {
                            if(($__uri.equals("http://www.xml.gr.jp/xmlns/relaxngcc") && $__local.equals("java-import"))) {
                                $runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
                                $_ngcc_current_state = 15;
                            }
                            else {
                                if(($__uri.equals("http://www.xml.gr.jp/xmlns/relaxngcc") && $__local.equals("java-body"))) {
                                    $runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
                                    $_ngcc_current_state = 11;
                                }
                                else {
                                    if(($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("include"))) {
                                        $runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
                                        $_ngcc_current_state = 7;
                                    }
                                    else {
                                        $_ngcc_current_state = 0;
                                        $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            break;
        case 19:
            {
                if((($__uri.equals("http://www.xml.gr.jp/xmlns/relaxngcc") && $__local.equals("java-import")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("define")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("include")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("start")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("div")) || ($__uri.equals("http://www.xml.gr.jp/xmlns/relaxngcc") && $__local.equals("java-body")))))))) {
                    NGCCHandler h = new GrammarContent(this, super._source, $runtime, 426);
                    spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
                }
                else {
                    unexpectedEnterElement($__qname);
                }
            }
            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 3:
            {
                if(($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("include"))) {
                    $runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
                    $_ngcc_current_state = 0;
                }
                else {
                    unexpectedLeaveElement($__qname);
                }
            }
            break;
        case 0:
            {
                revertToParentFromLeaveElement(this, super._cookie, $__uri, $__local, $__qname);
            }
            break;
        case 14:
            {
                if(($__uri.equals("http://www.xml.gr.jp/xmlns/relaxngcc") && $__local.equals("java-import"))) {
                    $runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
                    $_ngcc_current_state = 0;
                }
                else {
                    unexpectedLeaveElement($__qname);
                }
            }
            break;
        case 10:
            {
                if(($__uri.equals("http://www.xml.gr.jp/xmlns/relaxngcc") && $__local.equals("java-body"))) {
                    $runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
                    $_ngcc_current_state = 0;
                }
                else {
                    unexpectedLeaveElement($__qname);
                }
            }
            break;
        case 7:
            {
                if(($ai = $runtime.getAttributeIndex("","href"))>=0) {
                    $runtime.consumeAttribute($ai);
                    $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
                }
                else {
                    unexpectedLeaveElement($__qname);
                }
            }
            break;
        case 4:
            {
                if(($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("include"))) {
                    NGCCHandler h = new IncludeContent(this, super._source, $runtime, 411);
                    spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
                }
                else {
                    unexpectedLeaveElement($__qname);
                }
            }
            break;
        case 1:
            {
                $_ngcc_current_state = 0;
                $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
            }
            break;
        case 19:
            {
                if(($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("div"))) {
                    NGCCHandler h = new GrammarContent(this, super._source, $runtime, 426);
                    spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
                }
                else {
                    unexpectedLeaveElement($__qname);
                }
            }
            break;
        case 18:
            {
                if(($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("div"))) {
                    $runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
                    $_ngcc_current_state = 0;
                }
                else {
                    unexpectedLeaveElement($__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(this, super._cookie, $__uri, $__local, $__qname);
            }
            break;
        case 7:
            {
                if(($__uri.equals("") && $__local.equals("href"))) {
                    $_ngcc_current_state = 6;
                }
                else {
                    unexpectedEnterAttribute($__qname);
                }
            }
            break;
        case 1:
            {
                $_ngcc_current_state = 0;
                $runtime.sendEnterAttribute(super._cookie, $__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(this, super._cookie, $__uri, $__local, $__qname);
            }
            break;
        case 1:
            {
                $_ngcc_current_state = 0;
                $runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
            }
            break;
        case 5:
            {
                if(($__uri.equals("") && $__local.equals("href"))) {
                    $_ngcc_current_state = 4;
                    action0();
                }
                else {
                    unexpectedLeaveAttribute($__qname);
                }
            }
            break;
        default:
            {
                unexpectedLeaveAttribute($__qname);
            }
            break;
        }
    }

    public void text(String $value) throws SAXException {
        int $ai;
        switch($_ngcc_current_state) {
        case 0:
            {
                revertToParentFromText(this, super._cookie, $value);
            }
            break;
        case 7:
            {
                if(($ai = $runtime.getAttributeIndex("","href"))>=0) {
                    $runtime.consumeAttribute($ai);
                    $runtime.sendText(super._cookie, $value);
                }
            }
            break;
        case 15:
            {
                value = $value;
                $_ngcc_current_state = 14;
                action2();
            }
            break;
        case 1:
            {
                $_ngcc_current_state = 0;
                $runtime.sendText(super._cookie, $value);
            }
            break;
        case 11:
            {
                value = $value;
                $_ngcc_current_state = 10;
                action1();
            }
            break;
        case 6:
            {
                href = $value;
                $_ngcc_current_state = 5;
            }
            break;
        }
    }

    public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
        switch($__cookie__) {
        case 411:
            {
                $_ngcc_current_state = 3;
            }
            break;
        case 426:
            {
                $_ngcc_current_state = 18;
            }
            break;
        case 447:
            {
                $_ngcc_current_state = 0;
            }
            break;
        case 448:
            {
                $_ngcc_current_state = 0;
            }
            break;
        case 453:
            {
                $_ngcc_current_state = 0;
            }
            break;
        case 454:
            {
                $_ngcc_current_state = 0;
            }
            break;
        }
    }

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


}

