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