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: import java.util.Vector;
044:
045: class SimpleType_Union extends NGCCHandler {
046: private Locator locator;
047: private AnnotationImpl annotation;
048: private String __text;
049: private UName memberTypeName;
050: private String name;
051: private Set finalSet;
052: private ForeignAttributesImpl fa;
053: private SimpleTypeImpl anonymousMemberType;
054: protected final NGCCRuntimeEx $runtime;
055: private int $_ngcc_current_state;
056: protected String $uri;
057: protected String $localName;
058: protected String $qname;
059:
060: public final NGCCRuntime getRuntime() {
061: return ($runtime);
062: }
063:
064: public SimpleType_Union(NGCCHandler parent, NGCCEventSource source,
065: NGCCRuntimeEx runtime, int cookie,
066: AnnotationImpl _annotation, Locator _locator,
067: ForeignAttributesImpl _fa, String _name, Set _finalSet) {
068: super (source, parent, cookie);
069: $runtime = runtime;
070: this .annotation = _annotation;
071: this .locator = _locator;
072: this .fa = _fa;
073: this .name = _name;
074: this .finalSet = _finalSet;
075: $_ngcc_current_state = 12;
076: }
077:
078: public SimpleType_Union(NGCCRuntimeEx runtime,
079: AnnotationImpl _annotation, Locator _locator,
080: ForeignAttributesImpl _fa, String _name, Set _finalSet) {
081: this (null, runtime, runtime, -1, _annotation, _locator, _fa,
082: _name, _finalSet);
083: }
084:
085: private void action0() throws SAXException {
086:
087: result = new UnionSimpleTypeImpl($runtime.document, annotation,
088: locator, fa, name, name == null, finalSet,
089: (Ref.SimpleType[]) members
090: .toArray(new Ref.SimpleType[members.size()]));
091:
092: }
093:
094: private void action1() throws SAXException {
095:
096: members.add(anonymousMemberType);
097:
098: }
099:
100: private void action2() throws SAXException {
101:
102: members.add(new DelayedRef.SimpleType($runtime, uloc,
103: $runtime.currentSchema, memberTypeName));
104:
105: }
106:
107: private void action3() throws SAXException {
108: $runtime.processList(__text);
109: }
110:
111: private void action4() throws SAXException {
112: uloc = $runtime.copyLocator();
113: }
114:
115: public void enterElement(String $__uri, String $__local,
116: String $__qname, Attributes $attrs) throws SAXException {
117: int $ai;
118: $uri = $__uri;
119: $localName = $__local;
120: $qname = $__qname;
121: switch ($_ngcc_current_state) {
122: case 0: {
123: revertToParentFromEnterElement(result, super ._cookie,
124: $__uri, $__local, $__qname, $attrs);
125: }
126: break;
127: case 1: {
128: if (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local
129: .equals("simpleType"))) {
130: NGCCHandler h = new simpleType(this , super ._source,
131: $runtime, 631);
132: spawnChildFromEnterElement(h, $__uri, $__local,
133: $__qname, $attrs);
134: } else {
135: unexpectedEnterElement($__qname);
136: }
137: }
138: break;
139: case 6: {
140: if ((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local
141: .equals("annotation")) || ($__uri
142: .equals("http://www.w3.org/2001/XMLSchema") && $__local
143: .equals("simpleType")))) {
144: NGCCHandler h = new foreignAttributes(this ,
145: super ._source, $runtime, 637, fa);
146: spawnChildFromEnterElement(h, $__uri, $__local,
147: $__qname, $attrs);
148: } else {
149: unexpectedEnterElement($__qname);
150: }
151: }
152: break;
153: case 7: {
154: if (($ai = $runtime.getAttributeIndex("", "memberTypes")) >= 0) {
155: $runtime.consumeAttribute($ai);
156: $runtime.sendEnterElement(super ._cookie, $__uri,
157: $__local, $__qname, $attrs);
158: } else {
159: $_ngcc_current_state = 6;
160: $runtime.sendEnterElement(super ._cookie, $__uri,
161: $__local, $__qname, $attrs);
162: }
163: }
164: break;
165: case 12: {
166: if (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local
167: .equals("union"))) {
168: $runtime.onEnterElementConsumed($__uri, $__local,
169: $__qname, $attrs);
170: action4();
171: $_ngcc_current_state = 7;
172: } else {
173: unexpectedEnterElement($__qname);
174: }
175: }
176: break;
177: case 2: {
178: if (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local
179: .equals("simpleType"))) {
180: NGCCHandler h = new simpleType(this , super ._source,
181: $runtime, 632);
182: spawnChildFromEnterElement(h, $__uri, $__local,
183: $__qname, $attrs);
184: } else {
185: $_ngcc_current_state = 1;
186: $runtime.sendEnterElement(super ._cookie, $__uri,
187: $__local, $__qname, $attrs);
188: }
189: }
190: break;
191: case 4: {
192: if (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local
193: .equals("annotation"))) {
194: NGCCHandler h = new annotation(this , super ._source,
195: $runtime, 635, annotation,
196: AnnotationContext.SIMPLETYPE_DECL);
197: spawnChildFromEnterElement(h, $__uri, $__local,
198: $__qname, $attrs);
199: } else {
200: $_ngcc_current_state = 2;
201: $runtime.sendEnterElement(super ._cookie, $__uri,
202: $__local, $__qname, $attrs);
203: }
204: }
205: break;
206: default: {
207: unexpectedEnterElement($__qname);
208: }
209: break;
210: }
211: }
212:
213: public void leaveElement(String $__uri, String $__local,
214: String $__qname) throws SAXException {
215: int $ai;
216: $uri = $__uri;
217: $localName = $__local;
218: $qname = $__qname;
219: switch ($_ngcc_current_state) {
220: case 0: {
221: revertToParentFromLeaveElement(result, super ._cookie,
222: $__uri, $__local, $__qname);
223: }
224: break;
225: case 1: {
226: if (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local
227: .equals("union"))) {
228: $runtime.onLeaveElementConsumed($__uri, $__local,
229: $__qname);
230: $_ngcc_current_state = 0;
231: action0();
232: } else {
233: unexpectedLeaveElement($__qname);
234: }
235: }
236: break;
237: case 6: {
238: if (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local
239: .equals("union"))) {
240: NGCCHandler h = new foreignAttributes(this ,
241: super ._source, $runtime, 637, fa);
242: spawnChildFromLeaveElement(h, $__uri, $__local,
243: $__qname);
244: } else {
245: unexpectedLeaveElement($__qname);
246: }
247: }
248: break;
249: case 7: {
250: if (($ai = $runtime.getAttributeIndex("", "memberTypes")) >= 0) {
251: $runtime.consumeAttribute($ai);
252: $runtime.sendLeaveElement(super ._cookie, $__uri,
253: $__local, $__qname);
254: } else {
255: $_ngcc_current_state = 6;
256: $runtime.sendLeaveElement(super ._cookie, $__uri,
257: $__local, $__qname);
258: }
259: }
260: break;
261: case 2: {
262: $_ngcc_current_state = 1;
263: $runtime.sendLeaveElement(super ._cookie, $__uri, $__local,
264: $__qname);
265: }
266: break;
267: case 4: {
268: $_ngcc_current_state = 2;
269: $runtime.sendLeaveElement(super ._cookie, $__uri, $__local,
270: $__qname);
271: }
272: break;
273: default: {
274: unexpectedLeaveElement($__qname);
275: }
276: break;
277: }
278: }
279:
280: public void enterAttribute(String $__uri, String $__local,
281: String $__qname) throws SAXException {
282: int $ai;
283: $uri = $__uri;
284: $localName = $__local;
285: $qname = $__qname;
286: switch ($_ngcc_current_state) {
287: case 0: {
288: revertToParentFromEnterAttribute(result, super ._cookie,
289: $__uri, $__local, $__qname);
290: }
291: break;
292: case 7: {
293: if (($__uri.equals("") && $__local.equals("memberTypes"))) {
294: $_ngcc_current_state = 10;
295: } else {
296: $_ngcc_current_state = 6;
297: $runtime.sendEnterAttribute(super ._cookie, $__uri,
298: $__local, $__qname);
299: }
300: }
301: break;
302: case 2: {
303: $_ngcc_current_state = 1;
304: $runtime.sendEnterAttribute(super ._cookie, $__uri,
305: $__local, $__qname);
306: }
307: break;
308: case 4: {
309: $_ngcc_current_state = 2;
310: $runtime.sendEnterAttribute(super ._cookie, $__uri,
311: $__local, $__qname);
312: }
313: break;
314: default: {
315: unexpectedEnterAttribute($__qname);
316: }
317: break;
318: }
319: }
320:
321: public void leaveAttribute(String $__uri, String $__local,
322: String $__qname) throws SAXException {
323: int $ai;
324: $uri = $__uri;
325: $localName = $__local;
326: $qname = $__qname;
327: switch ($_ngcc_current_state) {
328: case 0: {
329: revertToParentFromLeaveAttribute(result, super ._cookie,
330: $__uri, $__local, $__qname);
331: }
332: break;
333: case 8: {
334: if (($__uri.equals("") && $__local.equals("memberTypes"))) {
335: $_ngcc_current_state = 6;
336: } else {
337: unexpectedLeaveAttribute($__qname);
338: }
339: }
340: break;
341: case 7: {
342: $_ngcc_current_state = 6;
343: $runtime.sendLeaveAttribute(super ._cookie, $__uri,
344: $__local, $__qname);
345: }
346: break;
347: case 2: {
348: $_ngcc_current_state = 1;
349: $runtime.sendLeaveAttribute(super ._cookie, $__uri,
350: $__local, $__qname);
351: }
352: break;
353: case 4: {
354: $_ngcc_current_state = 2;
355: $runtime.sendLeaveAttribute(super ._cookie, $__uri,
356: $__local, $__qname);
357: }
358: break;
359: default: {
360: unexpectedLeaveAttribute($__qname);
361: }
362: break;
363: }
364: }
365:
366: public void text(String $value) throws SAXException {
367: int $ai;
368: switch ($_ngcc_current_state) {
369: case 0: {
370: revertToParentFromText(result, super ._cookie, $value);
371: }
372: break;
373: case 9: {
374: NGCCHandler h = new qname(this , super ._source, $runtime,
375: 639);
376: spawnChildFromText(h, $value);
377: }
378: break;
379: case 8: {
380: NGCCHandler h = new qname(this , super ._source, $runtime,
381: 640);
382: spawnChildFromText(h, $value);
383: }
384: break;
385: case 7: {
386: if (($ai = $runtime.getAttributeIndex("", "memberTypes")) >= 0) {
387: $runtime.consumeAttribute($ai);
388: $runtime.sendText(super ._cookie, $value);
389: } else {
390: $_ngcc_current_state = 6;
391: $runtime.sendText(super ._cookie, $value);
392: }
393: }
394: break;
395: case 2: {
396: $_ngcc_current_state = 1;
397: $runtime.sendText(super ._cookie, $value);
398: }
399: break;
400: case 4: {
401: $_ngcc_current_state = 2;
402: $runtime.sendText(super ._cookie, $value);
403: }
404: break;
405: case 10: {
406: __text = $value;
407: $_ngcc_current_state = 9;
408: action3();
409: }
410: break;
411: }
412: }
413:
414: public void onChildCompleted(Object $__result__, int $__cookie__,
415: boolean $__needAttCheck__) throws SAXException {
416: switch ($__cookie__) {
417: case 637: {
418: fa = ((ForeignAttributesImpl) $__result__);
419: $_ngcc_current_state = 4;
420: }
421: break;
422: case 640: {
423: memberTypeName = ((UName) $__result__);
424: action2();
425: $_ngcc_current_state = 8;
426: }
427: break;
428: case 631: {
429: anonymousMemberType = ((SimpleTypeImpl) $__result__);
430: action1();
431: $_ngcc_current_state = 1;
432: }
433: break;
434: case 639: {
435: memberTypeName = ((UName) $__result__);
436: action2();
437: $_ngcc_current_state = 8;
438: }
439: break;
440: case 632: {
441: anonymousMemberType = ((SimpleTypeImpl) $__result__);
442: action1();
443: $_ngcc_current_state = 1;
444: }
445: break;
446: case 635: {
447: annotation = ((AnnotationImpl) $__result__);
448: $_ngcc_current_state = 2;
449: }
450: break;
451: }
452: }
453:
454: public boolean accepted() {
455: return (($_ngcc_current_state == 0));
456: }
457:
458: /** computed simple type object */
459: private UnionSimpleTypeImpl result;
460:
461: // Vector of Ref.SimpleType
462: private final Vector members = new Vector();
463:
464: // locator of <union>
465: private Locator uloc;
466:
467: }
|