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