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