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 0:
 122             {
 123                 revertToParentFromEnterElement(this, super._cookie, $__uri, $__local, $__qname, $attrs);
 124             }
 125             break;
 126         case 1:
 127             {
 128                 if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
 129                     NGCCHandler h = new annotation(this, super._source, $runtime, 684, null,AnnotationContext.SCHEMA);
 130                     spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 131                 }
 132                 else {
 133                     if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("simpleType"))) {
 134                         NGCCHandler h = new simpleType(this, super._source, $runtime, 685);
 135                         spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 136                     }
 137                     else {
 138                         if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("complexType"))) {
 139                             NGCCHandler h = new complexType(this, super._source, $runtime, 686);
 140                             spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 141                         }
 142                         else {
 143                             if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("group"))) {
 144                                 NGCCHandler h = new group(this, super._source, $runtime, 687);
 145                                 spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 146                             }
 147                             else {
 148                                 if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("attributeGroup"))) {
 149                                     NGCCHandler h = new attributeGroupDecl(this, super._source, $runtime, 688);
 150                                     spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 151                                 }
 152                                 else {
 153                                     unexpectedEnterElement($__qname);
 154                                 }
 155                             }
 156                         }
 157                     }
 158                 }
 159             }
 160             break;
 161         case 14:
 162             {
 163                 if(($ai = $runtime.getAttributeIndex("","schemaLocation"))>=0) {
 164                     $runtime.consumeAttribute($ai);
 165                     $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
 166                 }
 167                 else {
 168                     unexpectedEnterElement($__qname);
 169                 }
 170             }
 171             break;
 172         case 2:
 173             {
 174                 if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
 175                     NGCCHandler h = new annotation(this, super._source, $runtime, 689, null,AnnotationContext.SCHEMA);
 176                     spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 177                 }
 178                 else {
 179                     if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("simpleType"))) {
 180                         NGCCHandler h = new simpleType(this, super._source, $runtime, 690);
 181                         spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 182                     }
 183                     else {
 184                         if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("complexType"))) {
 185                             NGCCHandler h = new complexType(this, super._source, $runtime, 691);
 186                             spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 187                         }
 188                         else {
 189                             if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("group"))) {
 190                                 NGCCHandler h = new group(this, super._source, $runtime, 692);
 191                                 spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 192                             }
 193                             else {
 194                                 if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("attributeGroup"))) {
 195                                     NGCCHandler h = new attributeGroupDecl(this, super._source, $runtime, 693);
 196                                     spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 197                                 }
 198                                 else {
 199                                     $_ngcc_current_state = 1;
 200                                     $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
 201                                 }
 202                             }
 203                         }
 204                     }
 205                 }
 206             }
 207             break;
 208         case 15:
 209             {
 210                 if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("redefine"))) {
 211                     $runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
 212                     $_ngcc_current_state = 14;
 213                 }
 214                 else {
 215                     unexpectedEnterElement($__qname);
 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 0:
 234             {
 235                 revertToParentFromLeaveElement(this, super._cookie, $__uri, $__local, $__qname);
 236             }
 237             break;
 238         case 1:
 239             {
 240                 if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("redefine"))) {
 241                     $runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
 242                     $_ngcc_current_state = 0;
 243                 }
 244                 else {
 245                     unexpectedLeaveElement($__qname);
 246                 }
 247             }
 248             break;
 249         case 14:
 250             {
 251                 if(($ai = $runtime.getAttributeIndex("","schemaLocation"))>=0) {
 252                     $runtime.consumeAttribute($ai);
 253                     $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
 254                 }
 255                 else {
 256                     unexpectedLeaveElement($__qname);
 257                 }
 258             }
 259             break;
 260         case 2:
 261             {
 262                 $_ngcc_current_state = 1;
 263                 $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
 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 0:
 281             {
 282                 revertToParentFromEnterAttribute(this, super._cookie, $__uri, $__local, $__qname);
 283             }
 284             break;
 285         case 14:
 286             {
 287                 if(($__uri.equals("") && $__local.equals("schemaLocation"))) {
 288                     $_ngcc_current_state = 13;
 289                 }
 290                 else {
 291                     unexpectedEnterAttribute($__qname);
 292                 }
 293             }
 294             break;
 295         case 2:
 296             {
 297                 $_ngcc_current_state = 1;
 298                 $runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
 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 0:
 316             {
 317                 revertToParentFromLeaveAttribute(this, super._cookie, $__uri, $__local, $__qname);
 318             }
 319             break;
 320         case 12:
 321             {
 322                 if(($__uri.equals("") && $__local.equals("schemaLocation"))) {
 323                     $_ngcc_current_state = 2;
 324                 }
 325                 else {
 326                     unexpectedLeaveAttribute($__qname);
 327                 }
 328             }
 329             break;
 330         case 2:
 331             {
 332                 $_ngcc_current_state = 1;
 333                 $runtime.sendLeaveAttribute(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 0:
 348             {
 349                 revertToParentFromText(this, super._cookie, $value);
 350             }
 351             break;
 352         case 14:
 353             {
 354                 if(($ai = $runtime.getAttributeIndex("","schemaLocation"))>=0) {
 355                     $runtime.consumeAttribute($ai);
 356                     $runtime.sendText(super._cookie, $value);
 357                 }
 358             }
 359             break;
 360         case 2:
 361             {
 362                 $_ngcc_current_state = 1;
 363                 $runtime.sendText(super._cookie, $value);
 364             }
 365             break;
 366         case 13:
 367             {
 368                 schemaLocation = $value;
 369                 $_ngcc_current_state = 12;
 370                 action4();
 371             }
 372             break;
 373         }
 374     }
 375 
 376     public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
 377         switch($__cookie__) {
 378         case 689:
 379             {
 380                 $_ngcc_current_state = 1;
 381             }
 382             break;
 383         case 690:
 384             {
 385                 newSt = ((SimpleTypeImpl)$__result__);
 386                 action3();
 387                 $_ngcc_current_state = 1;
 388             }
 389             break;
 390         case 691:
 391             {
 392                 newCt = ((ComplexTypeImpl)$__result__);
 393                 action2();
 394                 $_ngcc_current_state = 1;
 395             }
 396             break;
 397         case 692:
 398             {
 399                 newGrp = ((ModelGroupDeclImpl)$__result__);
 400                 action1();
 401                 $_ngcc_current_state = 1;
 402             }
 403             break;
 404         case 693:
 405             {
 406                 newAg = ((AttGroupDeclImpl)$__result__);
 407                 action0();
 408                 $_ngcc_current_state = 1;
 409             }
 410             break;
 411         case 684:
 412             {
 413                 $_ngcc_current_state = 1;
 414             }
 415             break;
 416         case 685:
 417             {
 418                 newSt = ((SimpleTypeImpl)$__result__);
 419                 action3();
 420                 $_ngcc_current_state = 1;
 421             }
 422             break;
 423         case 686:
 424             {
 425                 newCt = ((ComplexTypeImpl)$__result__);
 426                 action2();
 427                 $_ngcc_current_state = 1;
 428             }
 429             break;
 430         case 687:
 431             {
 432                 newGrp = ((ModelGroupDeclImpl)$__result__);
 433                 action1();
 434                 $_ngcc_current_state = 1;
 435             }
 436             break;
 437         case 688:
 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 }