1 /* 2 * Copyright (c) 1997, 2017, 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.bind.WhiteSpaceProcessor; 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 34 import org.xml.sax.Attributes; 35 import org.xml.sax.Locator; 36 import org.xml.sax.SAXException; 37 38 class attributeDeclBody extends NGCCHandler { 39 private String name; 40 private ForeignAttributesImpl fa; 41 private AnnotationImpl annotation; 42 private Locator locator; 43 private boolean isLocal; 44 private String defaultValue; 45 private UName typeName; 46 private String fixedValue; 47 protected final NGCCRuntimeEx $runtime; 48 private int $_ngcc_current_state; 49 protected String $uri; 50 protected String $localName; 51 protected String $qname; 52 getRuntime()53 public final NGCCRuntime getRuntime() { 54 return($runtime); 55 } 56 attributeDeclBody(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie, Locator _locator, boolean _isLocal, String _defaultValue, String _fixedValue)57 public attributeDeclBody(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie, Locator _locator, boolean _isLocal, String _defaultValue, String _fixedValue) { 58 super(source, parent, cookie); 59 $runtime = runtime; 60 this.locator = _locator; 61 this.isLocal = _isLocal; 62 this.defaultValue = _defaultValue; 63 this.fixedValue = _fixedValue; 64 $_ngcc_current_state = 13; 65 } 66 attributeDeclBody(NGCCRuntimeEx runtime, Locator _locator, boolean _isLocal, String _defaultValue, String _fixedValue)67 public attributeDeclBody(NGCCRuntimeEx runtime, Locator _locator, boolean _isLocal, String _defaultValue, String _fixedValue) { 68 this(null, runtime, runtime, -1, _locator, _isLocal, _defaultValue, _fixedValue); 69 } 70 action0()71 private void action0()throws SAXException { 72 73 type = new DelayedRef.SimpleType( 74 $runtime, locator, $runtime.currentSchema, typeName ); 75 76 } 77 action1()78 private void action1()throws SAXException { 79 formSpecified = true; 80 } 81 enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs)82 public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException { 83 int $ai; 84 $uri = $__uri; 85 $localName = $__local; 86 $qname = $__qname; 87 switch($_ngcc_current_state) { 88 case 0: 89 { 90 revertToParentFromEnterElement(makeResult(), super._cookie, $__uri, $__local, $__qname, $attrs); 91 } 92 break; 93 case 12: 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 7: 105 { 106 if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) { 107 NGCCHandler h = new annotation(this, super._source, $runtime, 388, null,AnnotationContext.ATTRIBUTE_DECL); 108 spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs); 109 } 110 else { 111 $_ngcc_current_state = 1; 112 $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs); 113 } 114 } 115 break; 116 case 9: 117 { 118 if((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation")) || ((($ai = $runtime.getAttributeIndex("","type"))>=0 && (($__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("simpleType"))))) { 119 NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 390, fa); 120 spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs); 121 } 122 else { 123 NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 390, fa); 124 spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs); 125 } 126 } 127 break; 128 case 13: 129 { 130 if(($ai = $runtime.getAttributeIndex("","form"))>=0) { 131 $runtime.consumeAttribute($ai); 132 $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs); 133 } 134 else { 135 $_ngcc_current_state = 12; 136 $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs); 137 } 138 } 139 break; 140 case 1: 141 { 142 if(($ai = $runtime.getAttributeIndex("","type"))>=0) { 143 $runtime.consumeAttribute($ai); 144 $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs); 145 } 146 else { 147 if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("simpleType"))) { 148 NGCCHandler h = new simpleType(this, super._source, $runtime, 379); 149 spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs); 150 } 151 else { 152 $_ngcc_current_state = 0; 153 $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs); 154 } 155 } 156 } 157 break; 158 default: 159 { 160 unexpectedEnterElement($__qname); 161 } 162 break; 163 } 164 } 165 leaveElement(String $__uri, String $__local, String $__qname)166 public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException { 167 int $ai; 168 $uri = $__uri; 169 $localName = $__local; 170 $qname = $__qname; 171 switch($_ngcc_current_state) { 172 case 0: 173 { 174 revertToParentFromLeaveElement(makeResult(), super._cookie, $__uri, $__local, $__qname); 175 } 176 break; 177 case 12: 178 { 179 if(($ai = $runtime.getAttributeIndex("","name"))>=0) { 180 $runtime.consumeAttribute($ai); 181 $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname); 182 } 183 else { 184 unexpectedLeaveElement($__qname); 185 } 186 } 187 break; 188 case 7: 189 { 190 $_ngcc_current_state = 1; 191 $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname); 192 } 193 break; 194 case 9: 195 { 196 if(($ai = $runtime.getAttributeIndex("","type"))>=0) { 197 NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 390, fa); 198 spawnChildFromLeaveElement(h, $__uri, $__local, $__qname); 199 } 200 else { 201 NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 390, fa); 202 spawnChildFromLeaveElement(h, $__uri, $__local, $__qname); 203 } 204 } 205 break; 206 case 13: 207 { 208 if(($ai = $runtime.getAttributeIndex("","form"))>=0) { 209 $runtime.consumeAttribute($ai); 210 $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname); 211 } 212 else { 213 $_ngcc_current_state = 12; 214 $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname); 215 } 216 } 217 break; 218 case 1: 219 { 220 if(($ai = $runtime.getAttributeIndex("","type"))>=0) { 221 $runtime.consumeAttribute($ai); 222 $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname); 223 } 224 else { 225 $_ngcc_current_state = 0; 226 $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname); 227 } 228 } 229 break; 230 default: 231 { 232 unexpectedLeaveElement($__qname); 233 } 234 break; 235 } 236 } 237 enterAttribute(String $__uri, String $__local, String $__qname)238 public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException { 239 int $ai; 240 $uri = $__uri; 241 $localName = $__local; 242 $qname = $__qname; 243 switch($_ngcc_current_state) { 244 case 0: 245 { 246 revertToParentFromEnterAttribute(makeResult(), super._cookie, $__uri, $__local, $__qname); 247 } 248 break; 249 case 12: 250 { 251 if(($__uri.equals("") && $__local.equals("name"))) { 252 $_ngcc_current_state = 11; 253 } 254 else { 255 unexpectedEnterAttribute($__qname); 256 } 257 } 258 break; 259 case 7: 260 { 261 $_ngcc_current_state = 1; 262 $runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname); 263 } 264 break; 265 case 9: 266 { 267 if(($__uri.equals("") && $__local.equals("type"))) { 268 NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 390, fa); 269 spawnChildFromEnterAttribute(h, $__uri, $__local, $__qname); 270 } 271 else { 272 NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 390, fa); 273 spawnChildFromEnterAttribute(h, $__uri, $__local, $__qname); 274 } 275 } 276 break; 277 case 13: 278 { 279 if(($__uri.equals("") && $__local.equals("form"))) { 280 $_ngcc_current_state = 15; 281 } 282 else { 283 $_ngcc_current_state = 12; 284 $runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname); 285 } 286 } 287 break; 288 case 1: 289 { 290 if(($__uri.equals("") && $__local.equals("type"))) { 291 $_ngcc_current_state = 5; 292 } 293 else { 294 $_ngcc_current_state = 0; 295 $runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname); 296 } 297 } 298 break; 299 default: 300 { 301 unexpectedEnterAttribute($__qname); 302 } 303 break; 304 } 305 } 306 leaveAttribute(String $__uri, String $__local, String $__qname)307 public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException { 308 int $ai; 309 $uri = $__uri; 310 $localName = $__local; 311 $qname = $__qname; 312 switch($_ngcc_current_state) { 313 case 0: 314 { 315 revertToParentFromLeaveAttribute(makeResult(), super._cookie, $__uri, $__local, $__qname); 316 } 317 break; 318 case 14: 319 { 320 if(($__uri.equals("") && $__local.equals("form"))) { 321 $_ngcc_current_state = 12; 322 } 323 else { 324 unexpectedLeaveAttribute($__qname); 325 } 326 } 327 break; 328 case 7: 329 { 330 $_ngcc_current_state = 1; 331 $runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname); 332 } 333 break; 334 case 10: 335 { 336 if(($__uri.equals("") && $__local.equals("name"))) { 337 $_ngcc_current_state = 9; 338 } 339 else { 340 unexpectedLeaveAttribute($__qname); 341 } 342 } 343 break; 344 case 9: 345 { 346 NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 390, fa); 347 spawnChildFromLeaveAttribute(h, $__uri, $__local, $__qname); 348 } 349 break; 350 case 13: 351 { 352 $_ngcc_current_state = 12; 353 $runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname); 354 } 355 break; 356 case 1: 357 { 358 $_ngcc_current_state = 0; 359 $runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname); 360 } 361 break; 362 case 4: 363 { 364 if(($__uri.equals("") && $__local.equals("type"))) { 365 $_ngcc_current_state = 0; 366 } 367 else { 368 unexpectedLeaveAttribute($__qname); 369 } 370 } 371 break; 372 default: 373 { 374 unexpectedLeaveAttribute($__qname); 375 } 376 break; 377 } 378 } 379 text(String $value)380 public void text(String $value) throws SAXException { 381 int $ai; 382 switch($_ngcc_current_state) { 383 case 0: 384 { 385 revertToParentFromText(makeResult(), super._cookie, $value); 386 } 387 break; 388 case 12: 389 { 390 if(($ai = $runtime.getAttributeIndex("","name"))>=0) { 391 $runtime.consumeAttribute($ai); 392 $runtime.sendText(super._cookie, $value); 393 } 394 } 395 break; 396 case 7: 397 { 398 $_ngcc_current_state = 1; 399 $runtime.sendText(super._cookie, $value); 400 } 401 break; 402 case 9: 403 { 404 if(($ai = $runtime.getAttributeIndex("","type"))>=0) { 405 NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 390, fa); 406 spawnChildFromText(h, $value); 407 } 408 else { 409 NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 390, fa); 410 spawnChildFromText(h, $value); 411 } 412 } 413 break; 414 case 13: 415 { 416 if(($ai = $runtime.getAttributeIndex("","form"))>=0) { 417 $runtime.consumeAttribute($ai); 418 $runtime.sendText(super._cookie, $value); 419 } 420 else { 421 $_ngcc_current_state = 12; 422 $runtime.sendText(super._cookie, $value); 423 } 424 } 425 break; 426 case 15: 427 { 428 if($value.equals("unqualified")) { 429 NGCCHandler h = new qualification(this, super._source, $runtime, 395); 430 spawnChildFromText(h, $value); 431 } 432 else { 433 if($value.equals("qualified")) { 434 NGCCHandler h = new qualification(this, super._source, $runtime, 395); 435 spawnChildFromText(h, $value); 436 } 437 } 438 } 439 break; 440 case 1: 441 { 442 if(($ai = $runtime.getAttributeIndex("","type"))>=0) { 443 $runtime.consumeAttribute($ai); 444 $runtime.sendText(super._cookie, $value); 445 } 446 else { 447 $_ngcc_current_state = 0; 448 $runtime.sendText(super._cookie, $value); 449 } 450 } 451 break; 452 case 11: 453 { 454 name = WhiteSpaceProcessor.collapse($value); 455 $_ngcc_current_state = 10; 456 } 457 break; 458 case 5: 459 { 460 NGCCHandler h = new qname(this, super._source, $runtime, 381); 461 spawnChildFromText(h, $value); 462 } 463 break; 464 } 465 } 466 onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)467 public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException { 468 switch($__cookie__) { 469 case 388: 470 { 471 annotation = ((AnnotationImpl)$__result__); 472 $_ngcc_current_state = 1; 473 } 474 break; 475 case 379: 476 { 477 type = ((SimpleTypeImpl)$__result__); 478 $_ngcc_current_state = 0; 479 } 480 break; 481 case 390: 482 { 483 fa = ((ForeignAttributesImpl)$__result__); 484 $_ngcc_current_state = 7; 485 } 486 break; 487 case 395: 488 { 489 form = ((Boolean)$__result__).booleanValue(); 490 action1(); 491 $_ngcc_current_state = 14; 492 } 493 break; 494 case 381: 495 { 496 typeName = ((UName)$__result__); 497 action0(); 498 $_ngcc_current_state = 4; 499 } 500 break; 501 } 502 } 503 accepted()504 public boolean accepted() { 505 return((($_ngcc_current_state == 0) || (($_ngcc_current_state == 1) || ($_ngcc_current_state == 7)))); 506 } 507 508 509 private boolean form; 510 private boolean formSpecified = false; 511 makeResult()512 private AttributeDeclImpl makeResult() { 513 514 if(type==null) 515 // type defaults to anySimpleType 516 type = $runtime.parser.schemaSet.anySimpleType; 517 518 if(!formSpecified) form = $runtime.attributeFormDefault; 519 // global attributes are always qualified 520 if(!isLocal) form = true; 521 522 String tns; 523 if(form==true) tns = $runtime.currentSchema.getTargetNamespace(); 524 else tns = ""; 525 526 // proper handling of anonymous types 527 return new AttributeDeclImpl( $runtime.document, tns, name, 528 annotation, locator, fa, isLocal, 529 $runtime.createXmlString(defaultValue), 530 $runtime.createXmlString(fixedValue), 531 type ); 532 } 533 private Ref.SimpleType type; 534 535 } 536