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 org.xml.sax.SAXException;
  30 import org.xml.sax.Attributes;
  31 import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
  32 import com.sun.xml.internal.bind.WhiteSpaceProcessor;
  33 
  34 import com.sun.xml.internal.xsom.*;
  35 import com.sun.xml.internal.xsom.parser.*;
  36 import com.sun.xml.internal.xsom.impl.*;
  37 import com.sun.xml.internal.xsom.impl.parser.*;
  38 import org.xml.sax.Locator;
  39 import java.util.*;
  40 
  41 
  42 
  43 class SimpleType_Restriction extends NGCCHandler {
  44     private Locator locator;
  45     private AnnotationImpl annotation;
  46     private String name;
  47     private UName baseTypeName;
  48     private Set finalSet;
  49     private ForeignAttributesImpl fa;
  50     private XSFacet facet;
  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 SimpleType_Restriction(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie, AnnotationImpl _annotation, Locator _locator, ForeignAttributesImpl _fa, String _name, Set _finalSet) {
  62         super(source, parent, cookie);
  63         $runtime = runtime;
  64         this.annotation = _annotation;
  65         this.locator = _locator;
  66         this.fa = _fa;
  67         this.name = _name;
  68         this.finalSet = _finalSet;
  69         $_ngcc_current_state = 13;
  70     }
  71 
  72     public SimpleType_Restriction(NGCCRuntimeEx runtime, AnnotationImpl _annotation, Locator _locator, ForeignAttributesImpl _fa, String _name, Set _finalSet) {
  73         this(null, runtime, runtime, -1, _annotation, _locator, _fa, _name, _finalSet);
  74     }
  75 
  76     private void action0()throws SAXException {
  77 
  78                 result.addFacet(facet);
  79 
  80 }
  81 
  82     private void action1()throws SAXException {
  83 
  84         result = new RestrictionSimpleTypeImpl(
  85                                         $runtime.document, annotation, locator, fa, name, name==null, finalSet, baseType );
  86 
  87 }
  88 
  89     private void action2()throws SAXException {
  90 
  91             baseType = new DelayedRef.SimpleType(
  92               $runtime, rloc, $runtime.currentSchema, baseTypeName );
  93 
  94 }
  95 
  96     private void action3()throws SAXException {
  97         rloc=$runtime.copyLocator();
  98 }
  99 
 100     public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
 101         int $ai;
 102         $uri = $__uri;
 103         $localName = $__local;
 104         $qname = $__qname;
 105         switch($_ngcc_current_state) {
 106         case 12:
 107             {
 108                 if((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation")) || ((($ai = $runtime.getAttributeIndex("","base"))>=0 && ((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("simpleType")) || (((((((((((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("minExclusive")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("maxExclusive"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("minInclusive"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("maxInclusive"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("totalDigits"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("fractionDigits"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("length"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("maxLength"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("minLength"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("enumeration"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("whiteSpace"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("pattern")))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation")))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("simpleType"))))) {
 109                     NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 166, fa);
 110                     spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 111                 }
 112                 else {
 113                     unexpectedEnterElement($__qname);
 114                 }
 115             }
 116             break;
 117         case 10:
 118             {
 119                 if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
 120                     NGCCHandler h = new annotation(this, super._source, $runtime, 164, annotation,AnnotationContext.SIMPLETYPE_DECL);
 121                     spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 122                 }
 123                 else {
 124                     $_ngcc_current_state = 5;
 125                     $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
 126                 }
 127             }
 128             break;
 129         case 4:
 130             {
 131                 action1();
 132                 $_ngcc_current_state = 2;
 133                 $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
 134             }
 135             break;
 136         case 0:
 137             {
 138                 revertToParentFromEnterElement(result, super._cookie, $__uri, $__local, $__qname, $attrs);
 139             }
 140             break;
 141         case 5:
 142             {
 143                 if(($ai = $runtime.getAttributeIndex("","base"))>=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, 158);
 150                         spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 151                     }
 152                     else {
 153                         unexpectedEnterElement($__qname);
 154                     }
 155                 }
 156             }
 157             break;
 158         case 1:
 159             {
 160                 if((((((((((((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("minExclusive")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("maxExclusive"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("minInclusive"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("maxInclusive"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("totalDigits"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("fractionDigits"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("length"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("maxLength"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("minLength"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("enumeration"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("whiteSpace"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("pattern")))) {
 161                     NGCCHandler h = new facet(this, super._source, $runtime, 153);
 162                     spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 163                 }
 164                 else {
 165                     unexpectedEnterElement($__qname);
 166                 }
 167             }
 168             break;
 169         case 2:
 170             {
 171                 if((((((((((((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("minExclusive")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("maxExclusive"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("minInclusive"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("maxInclusive"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("totalDigits"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("fractionDigits"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("length"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("maxLength"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("minLength"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("enumeration"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("whiteSpace"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("pattern")))) {
 172                     NGCCHandler h = new facet(this, super._source, $runtime, 154);
 173                     spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 174                 }
 175                 else {
 176                     $_ngcc_current_state = 1;
 177                     $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
 178                 }
 179             }
 180             break;
 181         case 13:
 182             {
 183                 if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("restriction"))) {
 184                     $runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
 185                     action3();
 186                     $_ngcc_current_state = 12;
 187                 }
 188                 else {
 189                     unexpectedEnterElement($__qname);
 190                 }
 191             }
 192             break;
 193         default:
 194             {
 195                 unexpectedEnterElement($__qname);
 196             }
 197             break;
 198         }
 199     }
 200 
 201     public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
 202         int $ai;
 203         $uri = $__uri;
 204         $localName = $__local;
 205         $qname = $__qname;
 206         switch($_ngcc_current_state) {
 207         case 12:
 208             {
 209                 if((($ai = $runtime.getAttributeIndex("","base"))>=0 && ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("restriction")))) {
 210                     NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 166, fa);
 211                     spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
 212                 }
 213                 else {
 214                     unexpectedLeaveElement($__qname);
 215                 }
 216             }
 217             break;
 218         case 10:
 219             {
 220                 $_ngcc_current_state = 5;
 221                 $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
 222             }
 223             break;
 224         case 4:
 225             {
 226                 action1();
 227                 $_ngcc_current_state = 2;
 228                 $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
 229             }
 230             break;
 231         case 0:
 232             {
 233                 revertToParentFromLeaveElement(result, super._cookie, $__uri, $__local, $__qname);
 234             }
 235             break;
 236         case 5:
 237             {
 238                 if(($ai = $runtime.getAttributeIndex("","base"))>=0) {
 239                     $runtime.consumeAttribute($ai);
 240                     $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
 241                 }
 242                 else {
 243                     unexpectedLeaveElement($__qname);
 244                 }
 245             }
 246             break;
 247         case 1:
 248             {
 249                 if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("restriction"))) {
 250                     $runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
 251                     $_ngcc_current_state = 0;
 252                 }
 253                 else {
 254                     unexpectedLeaveElement($__qname);
 255                 }
 256             }
 257             break;
 258         case 2:
 259             {
 260                 $_ngcc_current_state = 1;
 261                 $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
 262             }
 263             break;
 264         default:
 265             {
 266                 unexpectedLeaveElement($__qname);
 267             }
 268             break;
 269         }
 270     }
 271 
 272     public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
 273         int $ai;
 274         $uri = $__uri;
 275         $localName = $__local;
 276         $qname = $__qname;
 277         switch($_ngcc_current_state) {
 278         case 12:
 279             {
 280                 if(($__uri.equals("") && $__local.equals("base"))) {
 281                     NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 166, fa);
 282                     spawnChildFromEnterAttribute(h, $__uri, $__local, $__qname);
 283                 }
 284                 else {
 285                     unexpectedEnterAttribute($__qname);
 286                 }
 287             }
 288             break;
 289         case 10:
 290             {
 291                 $_ngcc_current_state = 5;
 292                 $runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
 293             }
 294             break;
 295         case 4:
 296             {
 297                 action1();
 298                 $_ngcc_current_state = 2;
 299                 $runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
 300             }
 301             break;
 302         case 0:
 303             {
 304                 revertToParentFromEnterAttribute(result, super._cookie, $__uri, $__local, $__qname);
 305             }
 306             break;
 307         case 5:
 308             {
 309                 if(($__uri.equals("") && $__local.equals("base"))) {
 310                     $_ngcc_current_state = 8;
 311                 }
 312                 else {
 313                     unexpectedEnterAttribute($__qname);
 314                 }
 315             }
 316             break;
 317         case 2:
 318             {
 319                 $_ngcc_current_state = 1;
 320                 $runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
 321             }
 322             break;
 323         default:
 324             {
 325                 unexpectedEnterAttribute($__qname);
 326             }
 327             break;
 328         }
 329     }
 330 
 331     public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
 332         int $ai;
 333         $uri = $__uri;
 334         $localName = $__local;
 335         $qname = $__qname;
 336         switch($_ngcc_current_state) {
 337         case 7:
 338             {
 339                 if(($__uri.equals("") && $__local.equals("base"))) {
 340                     $_ngcc_current_state = 4;
 341                 }
 342                 else {
 343                     unexpectedLeaveAttribute($__qname);
 344                 }
 345             }
 346             break;
 347         case 10:
 348             {
 349                 $_ngcc_current_state = 5;
 350                 $runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
 351             }
 352             break;
 353         case 4:
 354             {
 355                 action1();
 356                 $_ngcc_current_state = 2;
 357                 $runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
 358             }
 359             break;
 360         case 0:
 361             {
 362                 revertToParentFromLeaveAttribute(result, super._cookie, $__uri, $__local, $__qname);
 363             }
 364             break;
 365         case 2:
 366             {
 367                 $_ngcc_current_state = 1;
 368                 $runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
 369             }
 370             break;
 371         default:
 372             {
 373                 unexpectedLeaveAttribute($__qname);
 374             }
 375             break;
 376         }
 377     }
 378 
 379     public void text(String $value) throws SAXException {
 380         int $ai;
 381         switch($_ngcc_current_state) {
 382         case 8:
 383             {
 384                 // <xs:simpleType> -> <xs:restriction> with attribute 'base' = $value
 385                 NGCCHandler h = new qname(this, super._source, $runtime, 160);
 386                 spawnChildFromText(h, WhiteSpaceProcessor.collapse($value));
 387             }
 388             break;
 389         case 12:
 390             {
 391                 if(($ai = $runtime.getAttributeIndex("","base"))>=0) {
 392                     NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 166, fa);
 393                     spawnChildFromText(h, $value);
 394                 }
 395             }
 396             break;
 397         case 10:
 398             {
 399                 $_ngcc_current_state = 5;
 400                 $runtime.sendText(super._cookie, $value);
 401             }
 402             break;
 403         case 4:
 404             {
 405                 action1();
 406                 $_ngcc_current_state = 2;
 407                 $runtime.sendText(super._cookie, $value);
 408             }
 409             break;
 410         case 0:
 411             {
 412                 revertToParentFromText(result, super._cookie, $value);
 413             }
 414             break;
 415         case 5:
 416             {
 417                 if(($ai = $runtime.getAttributeIndex("","base"))>=0) {
 418                     $runtime.consumeAttribute($ai);
 419                     $runtime.sendText(super._cookie, $value);
 420                 }
 421             }
 422             break;
 423         case 2:
 424             {
 425                 $_ngcc_current_state = 1;
 426                 $runtime.sendText(super._cookie, $value);
 427             }
 428             break;
 429         }
 430     }
 431 
 432     public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
 433         switch($__cookie__) {
 434         case 160:
 435             {
 436                 baseTypeName = ((UName)$__result__);
 437                 action2();
 438                 $_ngcc_current_state = 7;
 439             }
 440             break;
 441         case 164:
 442             {
 443                 annotation = ((AnnotationImpl)$__result__);
 444                 $_ngcc_current_state = 5;
 445             }
 446             break;
 447         case 154:
 448             {
 449                 facet = ((XSFacet)$__result__);
 450                 action0();
 451                 $_ngcc_current_state = 1;
 452             }
 453             break;
 454         case 166:
 455             {
 456                 fa = ((ForeignAttributesImpl)$__result__);
 457                 $_ngcc_current_state = 10;
 458             }
 459             break;
 460         case 158:
 461             {
 462                 baseType = ((SimpleTypeImpl)$__result__);
 463                 $_ngcc_current_state = 4;
 464             }
 465             break;
 466         case 153:
 467             {
 468                 facet = ((XSFacet)$__result__);
 469                 action0();
 470                 $_ngcc_current_state = 1;
 471             }
 472             break;
 473         }
 474     }
 475 
 476     public boolean accepted() {
 477         return(($_ngcc_current_state == 0));
 478     }
 479 
 480 
 481                 /** computed simple type object */
 482                 private RestrictionSimpleTypeImpl result;
 483 
 484                 // reference to the base type
 485                 private Ref.SimpleType baseType;
 486 
 487                 // location of restriction
 488                 private Locator rloc;
 489 
 490 }