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