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

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

    private void action0()throws SAXException {
        
          nc = new NsNameClass($runtime, $runtime.getTargetNamespace(),child);
        
}

    private void action1()throws SAXException {
        
          nc = new AnyNameClass($runtime, child);
        
}

    private void action2()throws SAXException {
        
          nc = $runtime.parseSimpleName(name,false);
        
}

    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(nc, super._cookie, $__uri, $__local, $__qname, $attrs);
            }
            break;
        case 1:
            {
                if(($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("name"))) {
                    $runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
                    $_ngcc_current_state = 14;
                }
                else {
                    if(($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("anyName"))) {
                        $runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
                        $_ngcc_current_state = 11;
                    }
                    else {
                        if(($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("nsName"))) {
                            $runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
                            $_ngcc_current_state = 7;
                        }
                        else {
                            if(($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("choice"))) {
                                $runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
                                $_ngcc_current_state = 3;
                            }
                            else {
                                unexpectedEnterElement($__qname);
                            }
                        }
                    }
                }
            }
            break;
        case 11:
            {
                if(($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("except"))) {
                    NGCCHandler h = new ExceptNameClass(this, super._source, $runtime, 473);
                    spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
                }
                else {
                    unexpectedEnterElement($__qname);
                }
            }
            break;
        case 7:
            {
                if(($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("except"))) {
                    NGCCHandler h = new ExceptNameClass(this, super._source, $runtime, 469);
                    spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
                }
                else {
                    unexpectedEnterElement($__qname);
                }
            }
            break;
        case 3:
            {
                if((($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("choice")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("anyName")) || (($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("name")) || ($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("nsName")))))) {
                    NGCCHandler h = new NameClasses(this, super._source, $runtime, 465);
                    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 6:
            {
                if(($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("nsName"))) {
                    $runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
                    $_ngcc_current_state = 0;
                }
                else {
                    unexpectedLeaveElement($__qname);
                }
            }
            break;
        case 10:
            {
                if(($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("anyName"))) {
                    $runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
                    $_ngcc_current_state = 0;
                }
                else {
                    unexpectedLeaveElement($__qname);
                }
            }
            break;
        case 0:
            {
                revertToParentFromLeaveElement(nc, super._cookie, $__uri, $__local, $__qname);
            }
            break;
        case 11:
            {
                if(($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("anyName"))) {
                    NGCCHandler h = new ExceptNameClass(this, super._source, $runtime, 473);
                    spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
                }
                else {
                    unexpectedLeaveElement($__qname);
                }
            }
            break;
        case 7:
            {
                if(($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("nsName"))) {
                    NGCCHandler h = new ExceptNameClass(this, super._source, $runtime, 469);
                    spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
                }
                else {
                    unexpectedLeaveElement($__qname);
                }
            }
            break;
        case 13:
            {
                if(($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("name"))) {
                    $runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
                    $_ngcc_current_state = 0;
                }
                else {
                    unexpectedLeaveElement($__qname);
                }
            }
            break;
        case 2:
            {
                if(($__uri.equals("http://relaxng.org/ns/structure/1.0") && $__local.equals("choice"))) {
                    $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(nc, 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(nc, 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(nc, super._cookie, $value);
            }
            break;
        case 14:
            {
                name = $value;
                $_ngcc_current_state = 13;
                action2();
            }
            break;
        }
    }

    public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
        switch($__cookie__) {
        case 469:
            {
                child = ((NameClass)$__result__);
                action0();
                $_ngcc_current_state = 6;
            }
            break;
        case 473:
            {
                child = ((NameClass)$__result__);
                action1();
                $_ngcc_current_state = 10;
            }
            break;
        case 465:
            {
                nc = ((NameClass)$__result__);
                $_ngcc_current_state = 2;
            }
            break;
        }
    }

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

    
      private NameClass nc;
    
}

