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