1 /*
   2  * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 /* this file is generated by RelaxNGCC */
  27 package com.sun.xml.internal.xsom.impl.parser.state;
  28 import org.xml.sax.SAXException;
  29 import org.xml.sax.XMLReader;
  30 import org.xml.sax.Attributes;
  31 import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
  32 
  33     import com.sun.xml.internal.xsom.*;
  34     import com.sun.xml.internal.xsom.parser.*;
  35     import com.sun.xml.internal.xsom.impl.*;
  36     import com.sun.xml.internal.xsom.impl.parser.*;
  37     import org.xml.sax.Locator;
  38     import org.xml.sax.ContentHandler;
  39     import org.xml.sax.helpers.*;
  40     import java.util.*;
  41     import java.math.BigInteger;
  42 
  43 
  44 
  45 class redefine extends NGCCHandler {
  46     private String schemaLocation;
  47     private ModelGroupDeclImpl newGrp;
  48     private AttGroupDeclImpl newAg;
  49     private SimpleTypeImpl newSt;
  50     private ComplexTypeImpl newCt;
  51     protected final NGCCRuntimeEx $runtime;
  52     private int $_ngcc_current_state;
  53     protected String $uri;
  54     protected String $localName;
  55     protected String $qname;
  56 
  57     public final NGCCRuntime getRuntime() {
  58         return($runtime);
  59     }
  60 
  61     public redefine(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie) {
  62         super(source, parent, cookie);
  63         $runtime = runtime;
  64         $_ngcc_current_state = 15;
  65     }
  66 
  67     public redefine(NGCCRuntimeEx runtime) {
  68         this(null, runtime, runtime, -1);
  69     }
  70 
  71     private void action0()throws SAXException {
  72         XSAttGroupDecl oldAg = $runtime.currentSchema.getAttGroupDecl(newAg.getName());
  73             if(oldAg==null) {
  74               $runtime.reportError( Messages.format(Messages.ERR_UNDEFINED_ATTRIBUTEGROUP,newAg.getName()) );
  75             } else {
  76               newAg.redefine((AttGroupDeclImpl)oldAg);
  77               $runtime.currentSchema.addAttGroupDecl(newAg,true);
  78             }
  79 }
  80 
  81     private void action1()throws SAXException {
  82         XSModelGroupDecl oldGrp = $runtime.currentSchema.getModelGroupDecl(newGrp.getName());
  83             if(oldGrp==null) {
  84               $runtime.reportError( Messages.format(Messages.ERR_UNDEFINED_MODELGROUP,newGrp.getName()) );
  85             } else {
  86               newGrp.redefine((ModelGroupDeclImpl)oldGrp);
  87               $runtime.currentSchema.addModelGroupDecl(newGrp,true);
  88             }
  89 }
  90 
  91     private void action2()throws SAXException {
  92         XSComplexType oldCt = $runtime.currentSchema.getComplexType(newCt.getName());
  93             if(oldCt==null) {
  94               $runtime.reportError( Messages.format(Messages.ERR_UNDEFINED_COMPLEXTYPE,newCt.getName()) );
  95             } else {
  96               newCt.redefine((ComplexTypeImpl)oldCt);
  97               $runtime.currentSchema.addComplexType(newCt,true);
  98             }
  99 }
 100 
 101     private void action3()throws SAXException {
 102         XSSimpleType oldSt = $runtime.currentSchema.getSimpleType(newSt.getName());
 103             if(oldSt==null) {
 104               $runtime.reportError( Messages.format(Messages.ERR_UNDEFINED_SIMPLETYPE,newSt.getName()) );
 105             } else {
 106               newSt.redefine((SimpleTypeImpl)oldSt);
 107               $runtime.currentSchema.addSimpleType(newSt,true);
 108             }
 109 }
 110 
 111     private void action4()throws SAXException {
 112         $runtime.includeSchema( schemaLocation );
 113 }
 114 
 115     public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
 116         int $ai;
 117         $uri = $__uri;
 118         $localName = $__local;
 119         $qname = $__qname;
 120         switch($_ngcc_current_state) {
 121         case 2:
 122             {
 123                 if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
 124                     NGCCHandler h = new annotation(this, super._source, $runtime, 581, null,AnnotationContext.SCHEMA);
 125                     spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 126                 }
 127                 else {
 128                     if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("simpleType"))) {
 129                         NGCCHandler h = new simpleType(this, super._source, $runtime, 582);
 130                         spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 131                     }
 132                     else {
 133                         if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("complexType"))) {
 134                             NGCCHandler h = new complexType(this, super._source, $runtime, 583);
 135                             spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 136                         }
 137                         else {
 138                             if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("group"))) {
 139                                 NGCCHandler h = new group(this, super._source, $runtime, 584);
 140                                 spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 141                             }
 142                             else {
 143                                 if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("attributeGroup"))) {
 144                                     NGCCHandler h = new attributeGroupDecl(this, super._source, $runtime, 585);
 145                                     spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 146                                 }
 147                                 else {
 148                                     $_ngcc_current_state = 1;
 149                                     $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
 150                                 }
 151                             }
 152                         }
 153                     }
 154                 }
 155             }
 156             break;
 157         case 15:
 158             {
 159                 if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("redefine"))) {
 160                     $runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
 161                     $_ngcc_current_state = 14;
 162                 }
 163                 else {
 164                     unexpectedEnterElement($__qname);
 165                 }
 166             }
 167             break;
 168         case 0:
 169             {
 170                 revertToParentFromEnterElement(this, super._cookie, $__uri, $__local, $__qname, $attrs);
 171             }
 172             break;
 173         case 14:
 174             {
 175                 if(($ai = $runtime.getAttributeIndex("","schemaLocation"))>=0) {
 176                     $runtime.consumeAttribute($ai);
 177                     $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
 178                 }
 179                 else {
 180                     unexpectedEnterElement($__qname);
 181                 }
 182             }
 183             break;
 184         case 1:
 185             {
 186                 if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
 187                     NGCCHandler h = new annotation(this, super._source, $runtime, 576, null,AnnotationContext.SCHEMA);
 188                     spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 189                 }
 190                 else {
 191                     if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("simpleType"))) {
 192                         NGCCHandler h = new simpleType(this, super._source, $runtime, 577);
 193                         spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 194                     }
 195                     else {
 196                         if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("complexType"))) {
 197                             NGCCHandler h = new complexType(this, super._source, $runtime, 578);
 198                             spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 199                         }
 200                         else {
 201                             if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("group"))) {
 202                                 NGCCHandler h = new group(this, super._source, $runtime, 579);
 203                                 spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 204                             }
 205                             else {
 206                                 if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("attributeGroup"))) {
 207                                     NGCCHandler h = new attributeGroupDecl(this, super._source, $runtime, 580);
 208                                     spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 209                                 }
 210                                 else {
 211                                     unexpectedEnterElement($__qname);
 212                                 }
 213                             }
 214                         }
 215                     }
 216                 }
 217             }
 218             break;
 219         default:
 220             {
 221                 unexpectedEnterElement($__qname);
 222             }
 223             break;
 224         }
 225     }
 226 
 227     public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
 228         int $ai;
 229         $uri = $__uri;
 230         $localName = $__local;
 231         $qname = $__qname;
 232         switch($_ngcc_current_state) {
 233         case 2:
 234             {
 235                 $_ngcc_current_state = 1;
 236                 $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
 237             }
 238             break;
 239         case 0:
 240             {
 241                 revertToParentFromLeaveElement(this, super._cookie, $__uri, $__local, $__qname);
 242             }
 243             break;
 244         case 14:
 245             {
 246                 if(($ai = $runtime.getAttributeIndex("","schemaLocation"))>=0) {
 247                     $runtime.consumeAttribute($ai);
 248                     $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
 249                 }
 250                 else {
 251                     unexpectedLeaveElement($__qname);
 252                 }
 253             }
 254             break;
 255         case 1:
 256             {
 257                 if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("redefine"))) {
 258                     $runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
 259                     $_ngcc_current_state = 0;
 260                 }
 261                 else {
 262                     unexpectedLeaveElement($__qname);
 263                 }
 264             }
 265             break;
 266         default:
 267             {
 268                 unexpectedLeaveElement($__qname);
 269             }
 270             break;
 271         }
 272     }
 273 
 274     public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
 275         int $ai;
 276         $uri = $__uri;
 277         $localName = $__local;
 278         $qname = $__qname;
 279         switch($_ngcc_current_state) {
 280         case 2:
 281             {
 282                 $_ngcc_current_state = 1;
 283                 $runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
 284             }
 285             break;
 286         case 0:
 287             {
 288                 revertToParentFromEnterAttribute(this, super._cookie, $__uri, $__local, $__qname);
 289             }
 290             break;
 291         case 14:
 292             {
 293                 if(($__uri.equals("") && $__local.equals("schemaLocation"))) {
 294                     $_ngcc_current_state = 13;
 295                 }
 296                 else {
 297                     unexpectedEnterAttribute($__qname);
 298                 }
 299             }
 300             break;
 301         default:
 302             {
 303                 unexpectedEnterAttribute($__qname);
 304             }
 305             break;
 306         }
 307     }
 308 
 309     public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
 310         int $ai;
 311         $uri = $__uri;
 312         $localName = $__local;
 313         $qname = $__qname;
 314         switch($_ngcc_current_state) {
 315         case 2:
 316             {
 317                 $_ngcc_current_state = 1;
 318                 $runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
 319             }
 320             break;
 321         case 12:
 322             {
 323                 if(($__uri.equals("") && $__local.equals("schemaLocation"))) {
 324                     $_ngcc_current_state = 2;
 325                 }
 326                 else {
 327                     unexpectedLeaveAttribute($__qname);
 328                 }
 329             }
 330             break;
 331         case 0:
 332             {
 333                 revertToParentFromLeaveAttribute(this, super._cookie, $__uri, $__local, $__qname);
 334             }
 335             break;
 336         default:
 337             {
 338                 unexpectedLeaveAttribute($__qname);
 339             }
 340             break;
 341         }
 342     }
 343 
 344     public void text(String $value) throws SAXException {
 345         int $ai;
 346         switch($_ngcc_current_state) {
 347         case 2:
 348             {
 349                 $_ngcc_current_state = 1;
 350                 $runtime.sendText(super._cookie, $value);
 351             }
 352             break;
 353         case 13:
 354             {
 355                 schemaLocation = $value;
 356                 $_ngcc_current_state = 12;
 357                 action4();
 358             }
 359             break;
 360         case 0:
 361             {
 362                 revertToParentFromText(this, super._cookie, $value);
 363             }
 364             break;
 365         case 14:
 366             {
 367                 if(($ai = $runtime.getAttributeIndex("","schemaLocation"))>=0) {
 368                     $runtime.consumeAttribute($ai);
 369                     $runtime.sendText(super._cookie, $value);
 370                 }
 371             }
 372             break;
 373         }
 374     }
 375 
 376     public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
 377         switch($__cookie__) {
 378         case 581:
 379             {
 380                 $_ngcc_current_state = 1;
 381             }
 382             break;
 383         case 582:
 384             {
 385                 newSt = ((SimpleTypeImpl)$__result__);
 386                 action3();
 387                 $_ngcc_current_state = 1;
 388             }
 389             break;
 390         case 583:
 391             {
 392                 newCt = ((ComplexTypeImpl)$__result__);
 393                 action2();
 394                 $_ngcc_current_state = 1;
 395             }
 396             break;
 397         case 584:
 398             {
 399                 newGrp = ((ModelGroupDeclImpl)$__result__);
 400                 action1();
 401                 $_ngcc_current_state = 1;
 402             }
 403             break;
 404         case 585:
 405             {
 406                 newAg = ((AttGroupDeclImpl)$__result__);
 407                 action0();
 408                 $_ngcc_current_state = 1;
 409             }
 410             break;
 411         case 576:
 412             {
 413                 $_ngcc_current_state = 1;
 414             }
 415             break;
 416         case 577:
 417             {
 418                 newSt = ((SimpleTypeImpl)$__result__);
 419                 action3();
 420                 $_ngcc_current_state = 1;
 421             }
 422             break;
 423         case 578:
 424             {
 425                 newCt = ((ComplexTypeImpl)$__result__);
 426                 action2();
 427                 $_ngcc_current_state = 1;
 428             }
 429             break;
 430         case 579:
 431             {
 432                 newGrp = ((ModelGroupDeclImpl)$__result__);
 433                 action1();
 434                 $_ngcc_current_state = 1;
 435             }
 436             break;
 437         case 580:
 438             {
 439                 newAg = ((AttGroupDeclImpl)$__result__);
 440                 action0();
 441                 $_ngcc_current_state = 1;
 442             }
 443             break;
 444         }
 445     }
 446 
 447     public boolean accepted() {
 448         return(($_ngcc_current_state == 0));
 449     }
 450 
 451 
 452 }