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 identityConstraint extends NGCCHandler {
  46     private String name;
  47     private UName ref;
  48     private ForeignAttributesImpl fa;
  49     private AnnotationImpl ann;
  50     private XPathImpl field;
  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 identityConstraint(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie) {
  62         super(source, parent, cookie);
  63         $runtime = runtime;
  64         $_ngcc_current_state = 18;
  65     }
  66 
  67     public identityConstraint(NGCCRuntimeEx runtime) {
  68         this(null, runtime, runtime, -1);
  69     }
  70 
  71     private void action0()throws SAXException {
  72         fields.add(field);
  73 }
  74 
  75     private void action1()throws SAXException {
  76 
  77             refer = new DelayedRef.IdentityConstraint(
  78               $runtime, $runtime.copyLocator(), $runtime.currentSchema, ref );
  79 
  80 }
  81 
  82     private void action2()throws SAXException {
  83         if($localName.equals("key"))
  84         category = XSIdentityConstraint.KEY;
  85       else
  86       if($localName.equals("keyref"))
  87         category = XSIdentityConstraint.KEYREF;
  88       else
  89       if($localName.equals("unique"))
  90         category = XSIdentityConstraint.UNIQUE;
  91 }
  92 
  93     public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
  94         int $ai;
  95         $uri = $__uri;
  96         $localName = $__local;
  97         $qname = $__qname;
  98         switch($_ngcc_current_state) {
  99         case 16:
 100             {
 101                 if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
 102                     $runtime.consumeAttribute($ai);
 103                     $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
 104                 }
 105                 else {
 106                     unexpectedEnterElement($__qname);
 107                 }
 108             }
 109             break;
 110         case 1:
 111             {
 112                 if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("field"))) {
 113                     $runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
 114                     $_ngcc_current_state = 3;
 115                 }
 116                 else {
 117                     unexpectedEnterElement($__qname);
 118                 }
 119             }
 120             break;
 121         case 0:
 122             {
 123                 revertToParentFromEnterElement(makeResult(), super._cookie, $__uri, $__local, $__qname, $attrs);
 124             }
 125             break;
 126         case 17:
 127             {
 128                 if((($ai = $runtime.getAttributeIndex("","name"))>=0 && (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("selector")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))))) {
 129                     NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 287, null);
 130                     spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 131                 }
 132                 else {
 133                     unexpectedEnterElement($__qname);
 134                 }
 135             }
 136             break;
 137         case 7:
 138             {
 139                 if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("selector"))) {
 140                     $runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
 141                     $_ngcc_current_state = 6;
 142                 }
 143                 else {
 144                     unexpectedEnterElement($__qname);
 145                 }
 146             }
 147             break;
 148         case 18:
 149             {
 150                 if(((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("key")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("keyref"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("unique")))) {
 151                     $runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
 152                     action2();
 153                     $_ngcc_current_state = 17;
 154                 }
 155                 else {
 156                     unexpectedEnterElement($__qname);
 157                 }
 158             }
 159             break;
 160         case 3:
 161             {
 162                 if(($ai = $runtime.getAttributeIndex("","xpath"))>=0) {
 163                     NGCCHandler h = new xpath(this, super._source, $runtime, 270);
 164                     spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 165                 }
 166                 else {
 167                     unexpectedEnterElement($__qname);
 168                 }
 169             }
 170             break;
 171         case 4:
 172             {
 173                 if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("field"))) {
 174                     $runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
 175                     $_ngcc_current_state = 3;
 176                 }
 177                 else {
 178                     unexpectedEnterElement($__qname);
 179                 }
 180             }
 181             break;
 182         case 8:
 183             {
 184                 if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
 185                     NGCCHandler h = new annotation(this, super._source, $runtime, 277, null,AnnotationContext.IDENTITY_CONSTRAINT);
 186                     spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 187                 }
 188                 else {
 189                     $_ngcc_current_state = 7;
 190                     $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
 191                 }
 192             }
 193             break;
 194         case 10:
 195             {
 196                 if(($ai = $runtime.getAttributeIndex("","refer"))>=0) {
 197                     $runtime.consumeAttribute($ai);
 198                     $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
 199                 }
 200                 else {
 201                     $_ngcc_current_state = 8;
 202                     $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
 203                 }
 204             }
 205             break;
 206         case 6:
 207             {
 208                 if(($ai = $runtime.getAttributeIndex("","xpath"))>=0) {
 209                     NGCCHandler h = new xpath(this, super._source, $runtime, 274);
 210                     spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 211                 }
 212                 else {
 213                     unexpectedEnterElement($__qname);
 214                 }
 215             }
 216             break;
 217         default:
 218             {
 219                 unexpectedEnterElement($__qname);
 220             }
 221             break;
 222         }
 223     }
 224 
 225     public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
 226         int $ai;
 227         $uri = $__uri;
 228         $localName = $__local;
 229         $qname = $__qname;
 230         switch($_ngcc_current_state) {
 231         case 5:
 232             {
 233                 if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("selector"))) {
 234                     $runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
 235                     $_ngcc_current_state = 4;
 236                 }
 237                 else {
 238                     unexpectedLeaveElement($__qname);
 239                 }
 240             }
 241             break;
 242         case 16:
 243             {
 244                 if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
 245                     $runtime.consumeAttribute($ai);
 246                     $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
 247                 }
 248                 else {
 249                     unexpectedLeaveElement($__qname);
 250                 }
 251             }
 252             break;
 253         case 1:
 254             {
 255                 if(((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("key")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("keyref"))) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("unique")))) {
 256                     $runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
 257                     $_ngcc_current_state = 0;
 258                 }
 259                 else {
 260                     unexpectedLeaveElement($__qname);
 261                 }
 262             }
 263             break;
 264         case 2:
 265             {
 266                 if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("field"))) {
 267                     $runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
 268                     $_ngcc_current_state = 1;
 269                 }
 270                 else {
 271                     unexpectedLeaveElement($__qname);
 272                 }
 273             }
 274             break;
 275         case 0:
 276             {
 277                 revertToParentFromLeaveElement(makeResult(), super._cookie, $__uri, $__local, $__qname);
 278             }
 279             break;
 280         case 17:
 281             {
 282                 if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
 283                     NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 287, null);
 284                     spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
 285                 }
 286                 else {
 287                     unexpectedLeaveElement($__qname);
 288                 }
 289             }
 290             break;
 291         case 3:
 292             {
 293                 if((($ai = $runtime.getAttributeIndex("","xpath"))>=0 && ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("field")))) {
 294                     NGCCHandler h = new xpath(this, super._source, $runtime, 270);
 295                     spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
 296                 }
 297                 else {
 298                     unexpectedLeaveElement($__qname);
 299                 }
 300             }
 301             break;
 302         case 8:
 303             {
 304                 $_ngcc_current_state = 7;
 305                 $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
 306             }
 307             break;
 308         case 10:
 309             {
 310                 if(($ai = $runtime.getAttributeIndex("","refer"))>=0) {
 311                     $runtime.consumeAttribute($ai);
 312                     $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
 313                 }
 314                 else {
 315                     $_ngcc_current_state = 8;
 316                     $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
 317                 }
 318             }
 319             break;
 320         case 6:
 321             {
 322                 if((($ai = $runtime.getAttributeIndex("","xpath"))>=0 && ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("selector")))) {
 323                     NGCCHandler h = new xpath(this, super._source, $runtime, 274);
 324                     spawnChildFromLeaveElement(h, $__uri, $__local, $__qname);
 325                 }
 326                 else {
 327                     unexpectedLeaveElement($__qname);
 328                 }
 329             }
 330             break;
 331         default:
 332             {
 333                 unexpectedLeaveElement($__qname);
 334             }
 335             break;
 336         }
 337     }
 338 
 339     public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
 340         int $ai;
 341         $uri = $__uri;
 342         $localName = $__local;
 343         $qname = $__qname;
 344         switch($_ngcc_current_state) {
 345         case 16:
 346             {
 347                 if(($__uri.equals("") && $__local.equals("name"))) {
 348                     $_ngcc_current_state = 15;
 349                 }
 350                 else {
 351                     unexpectedEnterAttribute($__qname);
 352                 }
 353             }
 354             break;
 355         case 0:
 356             {
 357                 revertToParentFromEnterAttribute(makeResult(), super._cookie, $__uri, $__local, $__qname);
 358             }
 359             break;
 360         case 17:
 361             {
 362                 if(($__uri.equals("") && $__local.equals("name"))) {
 363                     NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 287, null);
 364                     spawnChildFromEnterAttribute(h, $__uri, $__local, $__qname);
 365                 }
 366                 else {
 367                     unexpectedEnterAttribute($__qname);
 368                 }
 369             }
 370             break;
 371         case 3:
 372             {
 373                 if(($__uri.equals("") && $__local.equals("xpath"))) {
 374                     NGCCHandler h = new xpath(this, super._source, $runtime, 270);
 375                     spawnChildFromEnterAttribute(h, $__uri, $__local, $__qname);
 376                 }
 377                 else {
 378                     unexpectedEnterAttribute($__qname);
 379                 }
 380             }
 381             break;
 382         case 8:
 383             {
 384                 $_ngcc_current_state = 7;
 385                 $runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
 386             }
 387             break;
 388         case 10:
 389             {
 390                 if(($__uri.equals("") && $__local.equals("refer"))) {
 391                     $_ngcc_current_state = 12;
 392                 }
 393                 else {
 394                     $_ngcc_current_state = 8;
 395                     $runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
 396                 }
 397             }
 398             break;
 399         case 6:
 400             {
 401                 if(($__uri.equals("") && $__local.equals("xpath"))) {
 402                     NGCCHandler h = new xpath(this, super._source, $runtime, 274);
 403                     spawnChildFromEnterAttribute(h, $__uri, $__local, $__qname);
 404                 }
 405                 else {
 406                     unexpectedEnterAttribute($__qname);
 407                 }
 408             }
 409             break;
 410         default:
 411             {
 412                 unexpectedEnterAttribute($__qname);
 413             }
 414             break;
 415         }
 416     }
 417 
 418     public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
 419         int $ai;
 420         $uri = $__uri;
 421         $localName = $__local;
 422         $qname = $__qname;
 423         switch($_ngcc_current_state) {
 424         case 0:
 425             {
 426                 revertToParentFromLeaveAttribute(makeResult(), super._cookie, $__uri, $__local, $__qname);
 427             }
 428             break;
 429         case 14:
 430             {
 431                 if(($__uri.equals("") && $__local.equals("name"))) {
 432                     $_ngcc_current_state = 10;
 433                 }
 434                 else {
 435                     unexpectedLeaveAttribute($__qname);
 436                 }
 437             }
 438             break;
 439         case 8:
 440             {
 441                 $_ngcc_current_state = 7;
 442                 $runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
 443             }
 444             break;
 445         case 10:
 446             {
 447                 $_ngcc_current_state = 8;
 448                 $runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
 449             }
 450             break;
 451         case 11:
 452             {
 453                 if(($__uri.equals("") && $__local.equals("refer"))) {
 454                     $_ngcc_current_state = 8;
 455                 }
 456                 else {
 457                     unexpectedLeaveAttribute($__qname);
 458                 }
 459             }
 460             break;
 461         default:
 462             {
 463                 unexpectedLeaveAttribute($__qname);
 464             }
 465             break;
 466         }
 467     }
 468 
 469     public void text(String $value) throws SAXException {
 470         int $ai;
 471         switch($_ngcc_current_state) {
 472         case 15:
 473             {
 474                 name = $value;
 475                 $_ngcc_current_state = 14;
 476             }
 477             break;
 478         case 16:
 479             {
 480                 if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
 481                     $runtime.consumeAttribute($ai);
 482                     $runtime.sendText(super._cookie, $value);
 483                 }
 484             }
 485             break;
 486         case 0:
 487             {
 488                 revertToParentFromText(makeResult(), super._cookie, $value);
 489             }
 490             break;
 491         case 12:
 492             {
 493                 NGCCHandler h = new qname(this, super._source, $runtime, 280);
 494                 spawnChildFromText(h, $value);
 495             }
 496             break;
 497         case 17:
 498             {
 499                 if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
 500                     NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 287, null);
 501                     spawnChildFromText(h, $value);
 502                 }
 503             }
 504             break;
 505         case 3:
 506             {
 507                 if(($ai = $runtime.getAttributeIndex("","xpath"))>=0) {
 508                     NGCCHandler h = new xpath(this, super._source, $runtime, 270);
 509                     spawnChildFromText(h, $value);
 510                 }
 511             }
 512             break;
 513         case 8:
 514             {
 515                 $_ngcc_current_state = 7;
 516                 $runtime.sendText(super._cookie, $value);
 517             }
 518             break;
 519         case 10:
 520             {
 521                 if(($ai = $runtime.getAttributeIndex("","refer"))>=0) {
 522                     $runtime.consumeAttribute($ai);
 523                     $runtime.sendText(super._cookie, $value);
 524                 }
 525                 else {
 526                     $_ngcc_current_state = 8;
 527                     $runtime.sendText(super._cookie, $value);
 528                 }
 529             }
 530             break;
 531         case 6:
 532             {
 533                 if(($ai = $runtime.getAttributeIndex("","xpath"))>=0) {
 534                     NGCCHandler h = new xpath(this, super._source, $runtime, 274);
 535                     spawnChildFromText(h, $value);
 536                 }
 537             }
 538             break;
 539         }
 540     }
 541 
 542     public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
 543         switch($__cookie__) {
 544         case 270:
 545             {
 546                 field = ((XPathImpl)$__result__);
 547                 action0();
 548                 $_ngcc_current_state = 2;
 549             }
 550             break;
 551         case 287:
 552             {
 553                 fa = ((ForeignAttributesImpl)$__result__);
 554                 $_ngcc_current_state = 16;
 555             }
 556             break;
 557         case 280:
 558             {
 559                 ref = ((UName)$__result__);
 560                 action1();
 561                 $_ngcc_current_state = 11;
 562             }
 563             break;
 564         case 277:
 565             {
 566                 ann = ((AnnotationImpl)$__result__);
 567                 $_ngcc_current_state = 7;
 568             }
 569             break;
 570         case 274:
 571             {
 572                 selector = ((XPathImpl)$__result__);
 573                 $_ngcc_current_state = 5;
 574             }
 575             break;
 576         }
 577     }
 578 
 579     public boolean accepted() {
 580         return(($_ngcc_current_state == 0));
 581     }
 582 
 583 
 584       private short category;
 585       private List fields = new ArrayList();
 586       private XPathImpl selector;
 587       private DelayedRef.IdentityConstraint refer = null;
 588 
 589       private IdentityConstraintImpl makeResult() {
 590         return new IdentityConstraintImpl($runtime.document,ann,$runtime.copyLocator(),fa,
 591           category,name,selector,fields,refer);
 592       }
 593 
 594 }