1 /*
   2  * Copyright (c) 1997, 2016, 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 
  29 import com.sun.xml.internal.xsom.impl.*;
  30 import com.sun.xml.internal.xsom.impl.parser.*;
  31 import com.sun.xml.internal.xsom.parser.*;
  32 
  33 import org.xml.sax.Attributes;
  34 import org.xml.sax.Locator;
  35 import org.xml.sax.SAXException;
  36 
  37 
  38 
  39 class attributeDeclBody extends NGCCHandler {
  40     private String name;
  41     private ForeignAttributesImpl fa;
  42     private AnnotationImpl annotation;
  43     private Locator locator;
  44     private boolean isLocal;
  45     private String defaultValue;
  46     private UName typeName;
  47     private String fixedValue;
  48     protected final NGCCRuntimeEx $runtime;
  49     private int $_ngcc_current_state;
  50     protected String $uri;
  51     protected String $localName;
  52     protected String $qname;
  53 
  54     public final NGCCRuntime getRuntime() {
  55         return($runtime);
  56     }
  57 
  58     public attributeDeclBody(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie, Locator _locator, boolean _isLocal, String _defaultValue, String _fixedValue) {
  59         super(source, parent, cookie);
  60         $runtime = runtime;
  61         this.locator = _locator;
  62         this.isLocal = _isLocal;
  63         this.defaultValue = _defaultValue;
  64         this.fixedValue = _fixedValue;
  65         $_ngcc_current_state = 13;
  66     }
  67 
  68     public attributeDeclBody(NGCCRuntimeEx runtime, Locator _locator, boolean _isLocal, String _defaultValue, String _fixedValue) {
  69         this(null, runtime, runtime, -1, _locator, _isLocal, _defaultValue, _fixedValue);
  70     }
  71 
  72     private void action0()throws SAXException {
  73 
  74           type = new DelayedRef.SimpleType(
  75             $runtime, locator, $runtime.currentSchema, typeName );
  76 
  77 }
  78 
  79     private void action1()throws SAXException {
  80         formSpecified = true;
  81 }
  82 
  83     public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
  84         int $ai;
  85         $uri = $__uri;
  86         $localName = $__local;
  87         $qname = $__qname;
  88         switch($_ngcc_current_state) {
  89         case 0:
  90             {
  91                 revertToParentFromEnterElement(makeResult(), super._cookie, $__uri, $__local, $__qname, $attrs);
  92             }
  93             break;
  94         case 12:
  95             {
  96                 if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
  97                     $runtime.consumeAttribute($ai);
  98                     $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
  99                 }
 100                 else {
 101                     unexpectedEnterElement($__qname);
 102                 }
 103             }
 104             break;
 105         case 7:
 106             {
 107                 if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
 108                     NGCCHandler h = new annotation(this, super._source, $runtime, 388, null,AnnotationContext.ATTRIBUTE_DECL);
 109                     spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 110                 }
 111                 else {
 112                     $_ngcc_current_state = 1;
 113                     $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
 114                 }
 115             }
 116             break;
 117         case 9:
 118             {
 119                 if((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation")) || ((($ai = $runtime.getAttributeIndex("","type"))>=0 && (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("simpleType")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation")))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("simpleType"))))) {
 120                     NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 390, fa);
 121                     spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 122                 }
 123                 else {
 124                     NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 390, fa);
 125                     spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 126                 }
 127             }
 128             break;
 129         case 13:
 130             {
 131                 if(($ai = $runtime.getAttributeIndex("","form"))>=0) {
 132                     $runtime.consumeAttribute($ai);
 133                     $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
 134                 }
 135                 else {
 136                     $_ngcc_current_state = 12;
 137                     $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
 138                 }
 139             }
 140             break;
 141         case 1:
 142             {
 143                 if(($ai = $runtime.getAttributeIndex("","type"))>=0) {
 144                     $runtime.consumeAttribute($ai);
 145                     $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
 146                 }
 147                 else {
 148                     if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("simpleType"))) {
 149                         NGCCHandler h = new simpleType(this, super._source, $runtime, 379);
 150                         spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 151                     }
 152                     else {
 153                         $_ngcc_current_state = 0;
 154                         $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
 155                     }
 156                 }
 157             }
 158             break;
 159         default:
 160             {
 161                 unexpectedEnterElement($__qname);
 162             }
 163             break;
 164         }
 165     }
 166 
 167     public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
 168         int $ai;
 169         $uri = $__uri;
 170         $localName = $__local;
 171         $qname = $__qname;
 172         switch($_ngcc_current_state) {
 173         case 0:
 174             {
 175                 revertToParentFromLeaveElement(makeResult(), super._cookie, $__uri, $__local, $__qname);
 176             }
 177             break;
 178         case 12:
 179             {
 180                 if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
 181                     $runtime.consumeAttribute($ai);
 182                     $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
 183                 }
 184                 else {
 185                     unexpectedLeaveElement($__qname);
 186                 }
 187             }
 188             break;
 189         case 7:
 190             {
 191                 $_ngcc_current_state = 1;
 192                 $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
 193             }
 194             break;
 195         case 9:
 196             {
 197                 if(($ai = $runtime.getAttributeIndex("","type"))>=0) {
 198                     NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 390, fa);
 199                     spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
 200                 }
 201                 else {
 202                     NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 390, fa);
 203                     spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
 204                 }
 205             }
 206             break;
 207         case 13:
 208             {
 209                 if(($ai = $runtime.getAttributeIndex("","form"))>=0) {
 210                     $runtime.consumeAttribute($ai);
 211                     $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
 212                 }
 213                 else {
 214                     $_ngcc_current_state = 12;
 215                     $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
 216                 }
 217             }
 218             break;
 219         case 1:
 220             {
 221                 if(($ai = $runtime.getAttributeIndex("","type"))>=0) {
 222                     $runtime.consumeAttribute($ai);
 223                     $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
 224                 }
 225                 else {
 226                     $_ngcc_current_state = 0;
 227                     $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
 228                 }
 229             }
 230             break;
 231         default:
 232             {
 233                 unexpectedLeaveElement($__qname);
 234             }
 235             break;
 236         }
 237     }
 238 
 239     public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
 240         int $ai;
 241         $uri = $__uri;
 242         $localName = $__local;
 243         $qname = $__qname;
 244         switch($_ngcc_current_state) {
 245         case 0:
 246             {
 247                 revertToParentFromEnterAttribute(makeResult(), super._cookie, $__uri, $__local, $__qname);
 248             }
 249             break;
 250         case 12:
 251             {
 252                 if(($__uri.equals("") && $__local.equals("name"))) {
 253                     $_ngcc_current_state = 11;
 254                 }
 255                 else {
 256                     unexpectedEnterAttribute($__qname);
 257                 }
 258             }
 259             break;
 260         case 7:
 261             {
 262                 $_ngcc_current_state = 1;
 263                 $runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
 264             }
 265             break;
 266         case 9:
 267             {
 268                 if(($__uri.equals("") && $__local.equals("type"))) {
 269                     NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 390, fa);
 270                     spawnChildFromEnterAttribute(h, $__uri, $__local, $__qname);
 271                 }
 272                 else {
 273                     NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 390, fa);
 274                     spawnChildFromEnterAttribute(h, $__uri, $__local, $__qname);
 275                 }
 276             }
 277             break;
 278         case 13:
 279             {
 280                 if(($__uri.equals("") && $__local.equals("form"))) {
 281                     $_ngcc_current_state = 15;
 282                 }
 283                 else {
 284                     $_ngcc_current_state = 12;
 285                     $runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
 286                 }
 287             }
 288             break;
 289         case 1:
 290             {
 291                 if(($__uri.equals("") && $__local.equals("type"))) {
 292                     $_ngcc_current_state = 5;
 293                 }
 294                 else {
 295                     $_ngcc_current_state = 0;
 296                     $runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
 297                 }
 298             }
 299             break;
 300         default:
 301             {
 302                 unexpectedEnterAttribute($__qname);
 303             }
 304             break;
 305         }
 306     }
 307 
 308     public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
 309         int $ai;
 310         $uri = $__uri;
 311         $localName = $__local;
 312         $qname = $__qname;
 313         switch($_ngcc_current_state) {
 314         case 0:
 315             {
 316                 revertToParentFromLeaveAttribute(makeResult(), super._cookie, $__uri, $__local, $__qname);
 317             }
 318             break;
 319         case 14:
 320             {
 321                 if(($__uri.equals("") && $__local.equals("form"))) {
 322                     $_ngcc_current_state = 12;
 323                 }
 324                 else {
 325                     unexpectedLeaveAttribute($__qname);
 326                 }
 327             }
 328             break;
 329         case 7:
 330             {
 331                 $_ngcc_current_state = 1;
 332                 $runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
 333             }
 334             break;
 335         case 10:
 336             {
 337                 if(($__uri.equals("") && $__local.equals("name"))) {
 338                     $_ngcc_current_state = 9;
 339                 }
 340                 else {
 341                     unexpectedLeaveAttribute($__qname);
 342                 }
 343             }
 344             break;
 345         case 9:
 346             {
 347                 NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 390, fa);
 348                 spawnChildFromLeaveAttribute(h, $__uri, $__local, $__qname);
 349             }
 350             break;
 351         case 13:
 352             {
 353                 $_ngcc_current_state = 12;
 354                 $runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
 355             }
 356             break;
 357         case 1:
 358             {
 359                 $_ngcc_current_state = 0;
 360                 $runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
 361             }
 362             break;
 363         case 4:
 364             {
 365                 if(($__uri.equals("") && $__local.equals("type"))) {
 366                     $_ngcc_current_state = 0;
 367                 }
 368                 else {
 369                     unexpectedLeaveAttribute($__qname);
 370                 }
 371             }
 372             break;
 373         default:
 374             {
 375                 unexpectedLeaveAttribute($__qname);
 376             }
 377             break;
 378         }
 379     }
 380 
 381     public void text(String $value) throws SAXException {
 382         int $ai;
 383         switch($_ngcc_current_state) {
 384         case 0:
 385             {
 386                 revertToParentFromText(makeResult(), super._cookie, $value);
 387             }
 388             break;
 389         case 12:
 390             {
 391                 if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
 392                     $runtime.consumeAttribute($ai);
 393                     $runtime.sendText(super._cookie, $value);
 394                 }
 395             }
 396             break;
 397         case 7:
 398             {
 399                 $_ngcc_current_state = 1;
 400                 $runtime.sendText(super._cookie, $value);
 401             }
 402             break;
 403         case 9:
 404             {
 405                 if(($ai = $runtime.getAttributeIndex("","type"))>=0) {
 406                     NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 390, fa);
 407                     spawnChildFromText(h, $value);
 408                 }
 409                 else {
 410                     NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 390, fa);
 411                     spawnChildFromText(h, $value);
 412                 }
 413             }
 414             break;
 415         case 13:
 416             {
 417                 if(($ai = $runtime.getAttributeIndex("","form"))>=0) {
 418                     $runtime.consumeAttribute($ai);
 419                     $runtime.sendText(super._cookie, $value);
 420                 }
 421                 else {
 422                     $_ngcc_current_state = 12;
 423                     $runtime.sendText(super._cookie, $value);
 424                 }
 425             }
 426             break;
 427         case 15:
 428             {
 429                 if($value.equals("unqualified")) {
 430                     NGCCHandler h = new qualification(this, super._source, $runtime, 395);
 431                     spawnChildFromText(h, $value);
 432                 }
 433                 else {
 434                     if($value.equals("qualified")) {
 435                         NGCCHandler h = new qualification(this, super._source, $runtime, 395);
 436                         spawnChildFromText(h, $value);
 437                     }
 438                 }
 439             }
 440             break;
 441         case 1:
 442             {
 443                 if(($ai = $runtime.getAttributeIndex("","type"))>=0) {
 444                     $runtime.consumeAttribute($ai);
 445                     $runtime.sendText(super._cookie, $value);
 446                 }
 447                 else {
 448                     $_ngcc_current_state = 0;
 449                     $runtime.sendText(super._cookie, $value);
 450                 }
 451             }
 452             break;
 453         case 11:
 454             {
 455                 name = $runtime.collapse($value);
 456                 $_ngcc_current_state = 10;
 457             }
 458             break;
 459         case 5:
 460             {
 461                 NGCCHandler h = new qname(this, super._source, $runtime, 381);
 462                 spawnChildFromText(h, $value);
 463             }
 464             break;
 465         }
 466     }
 467 
 468     public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
 469         switch($__cookie__) {
 470         case 388:
 471             {
 472                 annotation = ((AnnotationImpl)$__result__);
 473                 $_ngcc_current_state = 1;
 474             }
 475             break;
 476         case 379:
 477             {
 478                 type = ((SimpleTypeImpl)$__result__);
 479                 $_ngcc_current_state = 0;
 480             }
 481             break;
 482         case 390:
 483             {
 484                 fa = ((ForeignAttributesImpl)$__result__);
 485                 $_ngcc_current_state = 7;
 486             }
 487             break;
 488         case 395:
 489             {
 490                 form = ((Boolean)$__result__).booleanValue();
 491                 action1();
 492                 $_ngcc_current_state = 14;
 493             }
 494             break;
 495         case 381:
 496             {
 497                 typeName = ((UName)$__result__);
 498                 action0();
 499                 $_ngcc_current_state = 4;
 500             }
 501             break;
 502         }
 503     }
 504 
 505     public boolean accepted() {
 506         return((($_ngcc_current_state == 0) || (($_ngcc_current_state == 1) || ($_ngcc_current_state == 7))));
 507     }
 508 
 509 
 510       private boolean form;
 511       private boolean formSpecified = false;
 512 
 513       private AttributeDeclImpl makeResult() {
 514 
 515         if(type==null)
 516           // type defaults to anySimpleType
 517           type = $runtime.parser.schemaSet.anySimpleType;
 518 
 519         if(!formSpecified) form = $runtime.attributeFormDefault;
 520           // global attributes are always qualified
 521           if(!isLocal)       form = true;
 522 
 523         String tns;
 524         if(form==true)  tns = $runtime.currentSchema.getTargetNamespace();
 525         else            tns = "";
 526 
 527         // proper handling of anonymous types
 528         return new AttributeDeclImpl( $runtime.document, tns, name,
 529           annotation, locator, fa, isLocal,
 530           $runtime.createXmlString(defaultValue),
 531           $runtime.createXmlString(fixedValue),
 532           type );
 533       }
 534       private Ref.SimpleType type;
 535 
 536 }