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