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

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

    private void action0()throws SAXException {
        
        if(p==null)  p = child;
        else         p = new GroupPattern($runtime, p, child);
      
}

    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("optional")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("list")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("notAllowed")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("ref")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("interleave")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("attribute")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("text")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("mixed")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("oneOrMore")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("choice")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("empty")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("data")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("parentRef")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("element")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("group")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("value")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("zeroOrMore")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("grammar")) || ($__uri.equals("http://www.xml.gr.jp/xmlns/relaxngcc") && $__local.equals("java"))))))))))))))))))))) {
                    NGCCHandler h = new PatternState(this, super._source, $runtime, 77);
                    spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
                }
                else {
                    revertToParentFromEnterElement(p, super._cookie, $__uri, $__local, $__qname, $attrs);
                }
            }
            break;
        case 1:
            {
                if((($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("optional")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("list")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("notAllowed")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("ref")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("interleave")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("attribute")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("text")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("mixed")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("oneOrMore")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("choice")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("empty")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("data")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("parentRef")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("element")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("group")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("value")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("zeroOrMore")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("grammar")) || ($__uri.equals("http://www.xml.gr.jp/xmlns/relaxngcc") && $__local.equals("java"))))))))))))))))))))) {
                    NGCCHandler h = new PatternState(this, super._source, $runtime, 76);
                    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 0:
            {
                revertToParentFromLeaveElement(p, super._cookie, $__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;
        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;
        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;
        }
    }

    public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
        switch($__cookie__) {
        case 77:
            {
                child = ((Pattern)$__result__);
                action0();
                $_ngcc_current_state = 0;
            }
            break;
        case 76:
            {
                child = ((Pattern)$__result__);
                action0();
                $_ngcc_current_state = 0;
            }
            break;
        }
    }

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

    
      private Pattern p=null;
    
}

