001: /*
002: * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: /* this file is generated by RelaxNGCC */
027: package com.sun.xml.internal.xsom.impl.parser.state;
028:
029: import org.xml.sax.SAXException;
030: import org.xml.sax.XMLReader;
031: import org.xml.sax.Attributes;
032: import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
033:
034: import com.sun.xml.internal.xsom.*;
035: import com.sun.xml.internal.xsom.parser.*;
036: import com.sun.xml.internal.xsom.impl.*;
037: import com.sun.xml.internal.xsom.impl.parser.*;
038: import org.xml.sax.Locator;
039: import org.xml.sax.ContentHandler;
040: import org.xml.sax.helpers.*;
041: import java.util.*;
042:
043: class simpleType extends NGCCHandler {
044: private AnnotationImpl annotation;
045: private String name;
046: private ForeignAttributesImpl fa;
047: private String finalValue;
048: protected final NGCCRuntimeEx $runtime;
049: private int $_ngcc_current_state;
050: protected String $uri;
051: protected String $localName;
052: protected String $qname;
053:
054: public final NGCCRuntime getRuntime() {
055: return ($runtime);
056: }
057:
058: public simpleType(NGCCHandler parent, NGCCEventSource source,
059: NGCCRuntimeEx runtime, int cookie) {
060: super (source, parent, cookie);
061: $runtime = runtime;
062: $_ngcc_current_state = 19;
063: }
064:
065: public simpleType(NGCCRuntimeEx runtime) {
066: this (null, runtime, runtime, -1);
067: }
068:
069: private void action0() throws SAXException {
070: finalSet = makeFinalSet(finalValue);
071: }
072:
073: private void action1() throws SAXException {
074: locator = $runtime.copyLocator();
075: }
076:
077: public void enterElement(String $__uri, String $__local,
078: String $__qname, Attributes $attrs) throws SAXException {
079: int $ai;
080: $uri = $__uri;
081: $localName = $__local;
082: $qname = $__qname;
083: switch ($_ngcc_current_state) {
084: case 11: {
085: if (($ai = $runtime.getAttributeIndex("", "name")) >= 0) {
086: $runtime.consumeAttribute($ai);
087: $runtime.sendEnterElement(super ._cookie, $__uri,
088: $__local, $__qname, $attrs);
089: } else {
090: $_ngcc_current_state = 10;
091: $runtime.sendEnterElement(super ._cookie, $__uri,
092: $__local, $__qname, $attrs);
093: }
094: }
095: break;
096: case 0: {
097: revertToParentFromEnterElement(result, super ._cookie,
098: $__uri, $__local, $__qname, $attrs);
099: }
100: break;
101: case 15: {
102: if (($ai = $runtime.getAttributeIndex("", "final")) >= 0) {
103: $runtime.consumeAttribute($ai);
104: $runtime.sendEnterElement(super ._cookie, $__uri,
105: $__local, $__qname, $attrs);
106: } else {
107: $_ngcc_current_state = 11;
108: $runtime.sendEnterElement(super ._cookie, $__uri,
109: $__local, $__qname, $attrs);
110: }
111: }
112: break;
113: case 19: {
114: if (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local
115: .equals("simpleType"))) {
116: $runtime.onEnterElementConsumed($__uri, $__local,
117: $__qname, $attrs);
118: action1();
119: $_ngcc_current_state = 15;
120: } else {
121: unexpectedEnterElement($__qname);
122: }
123: }
124: break;
125: case 2: {
126: if (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local
127: .equals("restriction"))) {
128: NGCCHandler h = new SimpleType_Restriction(this ,
129: super ._source, $runtime, 379, annotation,
130: locator, fa, name, finalSet);
131: spawnChildFromEnterElement(h, $__uri, $__local,
132: $__qname, $attrs);
133: } else {
134: if (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local
135: .equals("list"))) {
136: NGCCHandler h = new SimpleType_List(this ,
137: super ._source, $runtime, 380, annotation,
138: locator, fa, name, finalSet);
139: spawnChildFromEnterElement(h, $__uri, $__local,
140: $__qname, $attrs);
141: } else {
142: if (($__uri
143: .equals("http://www.w3.org/2001/XMLSchema") && $__local
144: .equals("union"))) {
145: NGCCHandler h = new SimpleType_Union(this ,
146: super ._source, $runtime, 374,
147: annotation, locator, fa, name, finalSet);
148: spawnChildFromEnterElement(h, $__uri, $__local,
149: $__qname, $attrs);
150: } else {
151: unexpectedEnterElement($__qname);
152: }
153: }
154: }
155: }
156: break;
157: case 10: {
158: if ((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local
159: .equals("annotation")) || (($__uri
160: .equals("http://www.w3.org/2001/XMLSchema") && $__local
161: .equals("union")) || (($__uri
162: .equals("http://www.w3.org/2001/XMLSchema") && $__local
163: .equals("restriction")) || ($__uri
164: .equals("http://www.w3.org/2001/XMLSchema") && $__local
165: .equals("list")))))) {
166: NGCCHandler h = new foreignAttributes(this ,
167: super ._source, $runtime, 385, fa);
168: spawnChildFromEnterElement(h, $__uri, $__local,
169: $__qname, $attrs);
170: } else {
171: unexpectedEnterElement($__qname);
172: }
173: }
174: break;
175: case 8: {
176: if (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local
177: .equals("annotation"))) {
178: NGCCHandler h = new annotation(this , super ._source,
179: $runtime, 383, null,
180: AnnotationContext.SIMPLETYPE_DECL);
181: spawnChildFromEnterElement(h, $__uri, $__local,
182: $__qname, $attrs);
183: } else {
184: $_ngcc_current_state = 7;
185: $runtime.sendEnterElement(super ._cookie, $__uri,
186: $__local, $__qname, $attrs);
187: }
188: }
189: break;
190: case 7: {
191: action0();
192: $_ngcc_current_state = 2;
193: $runtime.sendEnterElement(super ._cookie, $__uri, $__local,
194: $__qname, $attrs);
195: }
196: break;
197: default: {
198: unexpectedEnterElement($__qname);
199: }
200: break;
201: }
202: }
203:
204: public void leaveElement(String $__uri, String $__local,
205: String $__qname) throws SAXException {
206: int $ai;
207: $uri = $__uri;
208: $localName = $__local;
209: $qname = $__qname;
210: switch ($_ngcc_current_state) {
211: case 11: {
212: if (($ai = $runtime.getAttributeIndex("", "name")) >= 0) {
213: $runtime.consumeAttribute($ai);
214: $runtime.sendLeaveElement(super ._cookie, $__uri,
215: $__local, $__qname);
216: } else {
217: $_ngcc_current_state = 10;
218: $runtime.sendLeaveElement(super ._cookie, $__uri,
219: $__local, $__qname);
220: }
221: }
222: break;
223: case 0: {
224: revertToParentFromLeaveElement(result, super ._cookie,
225: $__uri, $__local, $__qname);
226: }
227: break;
228: case 15: {
229: if (($ai = $runtime.getAttributeIndex("", "final")) >= 0) {
230: $runtime.consumeAttribute($ai);
231: $runtime.sendLeaveElement(super ._cookie, $__uri,
232: $__local, $__qname);
233: } else {
234: $_ngcc_current_state = 11;
235: $runtime.sendLeaveElement(super ._cookie, $__uri,
236: $__local, $__qname);
237: }
238: }
239: break;
240: case 1: {
241: if (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local
242: .equals("simpleType"))) {
243: $runtime.onLeaveElementConsumed($__uri, $__local,
244: $__qname);
245: $_ngcc_current_state = 0;
246: } else {
247: unexpectedLeaveElement($__qname);
248: }
249: }
250: break;
251: case 8: {
252: $_ngcc_current_state = 7;
253: $runtime.sendLeaveElement(super ._cookie, $__uri, $__local,
254: $__qname);
255: }
256: break;
257: case 7: {
258: action0();
259: $_ngcc_current_state = 2;
260: $runtime.sendLeaveElement(super ._cookie, $__uri, $__local,
261: $__qname);
262: }
263: break;
264: default: {
265: unexpectedLeaveElement($__qname);
266: }
267: break;
268: }
269: }
270:
271: public void enterAttribute(String $__uri, String $__local,
272: String $__qname) throws SAXException {
273: int $ai;
274: $uri = $__uri;
275: $localName = $__local;
276: $qname = $__qname;
277: switch ($_ngcc_current_state) {
278: case 11: {
279: if (($__uri.equals("") && $__local.equals("name"))) {
280: $_ngcc_current_state = 13;
281: } else {
282: $_ngcc_current_state = 10;
283: $runtime.sendEnterAttribute(super ._cookie, $__uri,
284: $__local, $__qname);
285: }
286: }
287: break;
288: case 0: {
289: revertToParentFromEnterAttribute(result, super ._cookie,
290: $__uri, $__local, $__qname);
291: }
292: break;
293: case 15: {
294: if (($__uri.equals("") && $__local.equals("final"))) {
295: $_ngcc_current_state = 17;
296: } else {
297: $_ngcc_current_state = 11;
298: $runtime.sendEnterAttribute(super ._cookie, $__uri,
299: $__local, $__qname);
300: }
301: }
302: break;
303: case 8: {
304: $_ngcc_current_state = 7;
305: $runtime.sendEnterAttribute(super ._cookie, $__uri,
306: $__local, $__qname);
307: }
308: break;
309: case 7: {
310: action0();
311: $_ngcc_current_state = 2;
312: $runtime.sendEnterAttribute(super ._cookie, $__uri,
313: $__local, $__qname);
314: }
315: break;
316: default: {
317: unexpectedEnterAttribute($__qname);
318: }
319: break;
320: }
321: }
322:
323: public void leaveAttribute(String $__uri, String $__local,
324: String $__qname) throws SAXException {
325: int $ai;
326: $uri = $__uri;
327: $localName = $__local;
328: $qname = $__qname;
329: switch ($_ngcc_current_state) {
330: case 12: {
331: if (($__uri.equals("") && $__local.equals("name"))) {
332: $_ngcc_current_state = 10;
333: } else {
334: unexpectedLeaveAttribute($__qname);
335: }
336: }
337: break;
338: case 11: {
339: $_ngcc_current_state = 10;
340: $runtime.sendLeaveAttribute(super ._cookie, $__uri,
341: $__local, $__qname);
342: }
343: break;
344: case 0: {
345: revertToParentFromLeaveAttribute(result, super ._cookie,
346: $__uri, $__local, $__qname);
347: }
348: break;
349: case 15: {
350: $_ngcc_current_state = 11;
351: $runtime.sendLeaveAttribute(super ._cookie, $__uri,
352: $__local, $__qname);
353: }
354: break;
355: case 8: {
356: $_ngcc_current_state = 7;
357: $runtime.sendLeaveAttribute(super ._cookie, $__uri,
358: $__local, $__qname);
359: }
360: break;
361: case 16: {
362: if (($__uri.equals("") && $__local.equals("final"))) {
363: $_ngcc_current_state = 11;
364: } else {
365: unexpectedLeaveAttribute($__qname);
366: }
367: }
368: break;
369: case 7: {
370: action0();
371: $_ngcc_current_state = 2;
372: $runtime.sendLeaveAttribute(super ._cookie, $__uri,
373: $__local, $__qname);
374: }
375: break;
376: default: {
377: unexpectedLeaveAttribute($__qname);
378: }
379: break;
380: }
381: }
382:
383: public void text(String $value) throws SAXException {
384: int $ai;
385: switch ($_ngcc_current_state) {
386: case 13: {
387: name = $value;
388: $_ngcc_current_state = 12;
389: }
390: break;
391: case 17: {
392: finalValue = $value;
393: $_ngcc_current_state = 16;
394: }
395: break;
396: case 11: {
397: if (($ai = $runtime.getAttributeIndex("", "name")) >= 0) {
398: $runtime.consumeAttribute($ai);
399: $runtime.sendText(super ._cookie, $value);
400: } else {
401: $_ngcc_current_state = 10;
402: $runtime.sendText(super ._cookie, $value);
403: }
404: }
405: break;
406: case 0: {
407: revertToParentFromText(result, super ._cookie, $value);
408: }
409: break;
410: case 15: {
411: if (($ai = $runtime.getAttributeIndex("", "final")) >= 0) {
412: $runtime.consumeAttribute($ai);
413: $runtime.sendText(super ._cookie, $value);
414: } else {
415: $_ngcc_current_state = 11;
416: $runtime.sendText(super ._cookie, $value);
417: }
418: }
419: break;
420: case 8: {
421: $_ngcc_current_state = 7;
422: $runtime.sendText(super ._cookie, $value);
423: }
424: break;
425: case 7: {
426: action0();
427: $_ngcc_current_state = 2;
428: $runtime.sendText(super ._cookie, $value);
429: }
430: break;
431: }
432: }
433:
434: public void onChildCompleted(Object $__result__, int $__cookie__,
435: boolean $__needAttCheck__) throws SAXException {
436: switch ($__cookie__) {
437: case 383: {
438: annotation = ((AnnotationImpl) $__result__);
439: $_ngcc_current_state = 7;
440: }
441: break;
442: case 379: {
443: result = ((RestrictionSimpleTypeImpl) $__result__);
444: $_ngcc_current_state = 1;
445: }
446: break;
447: case 380: {
448: result = ((ListSimpleTypeImpl) $__result__);
449: $_ngcc_current_state = 1;
450: }
451: break;
452: case 374: {
453: result = ((UnionSimpleTypeImpl) $__result__);
454: $_ngcc_current_state = 1;
455: }
456: break;
457: case 385: {
458: fa = ((ForeignAttributesImpl) $__result__);
459: $_ngcc_current_state = 8;
460: }
461: break;
462: }
463: }
464:
465: public boolean accepted() {
466: return (($_ngcc_current_state == 0));
467: }
468:
469: /** computed simple type object */
470: private SimpleTypeImpl result;
471:
472: private Locator locator;
473:
474: private Set finalSet;
475:
476: private Set makeFinalSet(String finalValue) {
477: if (finalValue == null)
478: return Collections.EMPTY_SET;
479:
480: Set s = new HashSet();
481: StringTokenizer tokens = new StringTokenizer(finalValue);
482: while (tokens.hasMoreTokens()) {
483: String token = tokens.nextToken();
484: if (token.equals("#all")) {
485: s.add(XSVariety.ATOMIC);
486: s.add(XSVariety.UNION);
487: s.add(XSVariety.LIST);
488: }
489: if (token.equals("list")) {
490: s.add(XSVariety.LIST);
491: }
492: if (token.equals("union")) {
493: s.add(XSVariety.UNION);
494: }
495: if (token.equals("restriction")) {
496: s.add(XSVariety.ATOMIC);
497: }
498: }
499: return s;
500: }
501:
502: }
|