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