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 identityConstraint extends NGCCHandler {
044: private String name;
045: private UName ref;
046: private ForeignAttributesImpl fa;
047: private AnnotationImpl ann;
048: private XPathImpl field;
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 identityConstraint(NGCCHandler parent,
060: NGCCEventSource source, NGCCRuntimeEx runtime, int cookie) {
061: super (source, parent, cookie);
062: $runtime = runtime;
063: $_ngcc_current_state = 18;
064: }
065:
066: public identityConstraint(NGCCRuntimeEx runtime) {
067: this (null, runtime, runtime, -1);
068: }
069:
070: private void action0() throws SAXException {
071: fields.add(field);
072: }
073:
074: private void action1() throws SAXException {
075:
076: refer = new DelayedRef.IdentityConstraint($runtime, $runtime
077: .copyLocator(), $runtime.currentSchema, ref);
078:
079: }
080:
081: private void action2() throws SAXException {
082: if ($localName.equals("key"))
083: category = XSIdentityConstraint.KEY;
084: else if ($localName.equals("keyref"))
085: category = XSIdentityConstraint.KEYREF;
086: else if ($localName.equals("unique"))
087: category = XSIdentityConstraint.UNIQUE;
088: }
089:
090: public void enterElement(String $__uri, String $__local,
091: String $__qname, Attributes $attrs) throws SAXException {
092: int $ai;
093: $uri = $__uri;
094: $localName = $__local;
095: $qname = $__qname;
096: switch ($_ngcc_current_state) {
097: case 17: {
098: if ((($ai = $runtime.getAttributeIndex("", "name")) >= 0 && (($__uri
099: .equals("http://www.w3.org/2001/XMLSchema") && $__local
100: .equals("selector")) || ($__uri
101: .equals("http://www.w3.org/2001/XMLSchema") && $__local
102: .equals("annotation"))))) {
103: NGCCHandler h = new foreignAttributes(this ,
104: super ._source, $runtime, 665, null);
105: spawnChildFromEnterElement(h, $__uri, $__local,
106: $__qname, $attrs);
107: } else {
108: unexpectedEnterElement($__qname);
109: }
110: }
111: break;
112: case 10: {
113: if (($ai = $runtime.getAttributeIndex("", "refer")) >= 0) {
114: $runtime.consumeAttribute($ai);
115: $runtime.sendEnterElement(super ._cookie, $__uri,
116: $__local, $__qname, $attrs);
117: } else {
118: $_ngcc_current_state = 8;
119: $runtime.sendEnterElement(super ._cookie, $__uri,
120: $__local, $__qname, $attrs);
121: }
122: }
123: break;
124: case 1: {
125: if (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local
126: .equals("field"))) {
127: $runtime.onEnterElementConsumed($__uri, $__local,
128: $__qname, $attrs);
129: $_ngcc_current_state = 3;
130: } else {
131: unexpectedEnterElement($__qname);
132: }
133: }
134: break;
135: case 6: {
136: if (($ai = $runtime.getAttributeIndex("", "xpath")) >= 0) {
137: NGCCHandler h = new xpath(this , super ._source,
138: $runtime, 652);
139: spawnChildFromEnterElement(h, $__uri, $__local,
140: $__qname, $attrs);
141: } else {
142: unexpectedEnterElement($__qname);
143: }
144: }
145: break;
146: case 4: {
147: if (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local
148: .equals("field"))) {
149: $runtime.onEnterElementConsumed($__uri, $__local,
150: $__qname, $attrs);
151: $_ngcc_current_state = 3;
152: } else {
153: unexpectedEnterElement($__qname);
154: }
155: }
156: break;
157: case 8: {
158: if (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local
159: .equals("annotation"))) {
160: NGCCHandler h = new annotation(this , super ._source,
161: $runtime, 655, null,
162: AnnotationContext.IDENTITY_CONSTRAINT);
163: spawnChildFromEnterElement(h, $__uri, $__local,
164: $__qname, $attrs);
165: } else {
166: $_ngcc_current_state = 7;
167: $runtime.sendEnterElement(super ._cookie, $__uri,
168: $__local, $__qname, $attrs);
169: }
170: }
171: break;
172: case 3: {
173: if (($ai = $runtime.getAttributeIndex("", "xpath")) >= 0) {
174: NGCCHandler h = new xpath(this , super ._source,
175: $runtime, 648);
176: spawnChildFromEnterElement(h, $__uri, $__local,
177: $__qname, $attrs);
178: } else {
179: unexpectedEnterElement($__qname);
180: }
181: }
182: break;
183: case 0: {
184: revertToParentFromEnterElement(makeResult(), super ._cookie,
185: $__uri, $__local, $__qname, $attrs);
186: }
187: break;
188: case 16: {
189: if (($ai = $runtime.getAttributeIndex("", "name")) >= 0) {
190: $runtime.consumeAttribute($ai);
191: $runtime.sendEnterElement(super ._cookie, $__uri,
192: $__local, $__qname, $attrs);
193: } else {
194: unexpectedEnterElement($__qname);
195: }
196: }
197: break;
198: case 18: {
199: if (((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local
200: .equals("key")) || ($__uri
201: .equals("http://www.w3.org/2001/XMLSchema") && $__local
202: .equals("keyref"))) || ($__uri
203: .equals("http://www.w3.org/2001/XMLSchema") && $__local
204: .equals("unique")))) {
205: $runtime.onEnterElementConsumed($__uri, $__local,
206: $__qname, $attrs);
207: action2();
208: $_ngcc_current_state = 17;
209: } else {
210: unexpectedEnterElement($__qname);
211: }
212: }
213: break;
214: case 7: {
215: if (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local
216: .equals("selector"))) {
217: $runtime.onEnterElementConsumed($__uri, $__local,
218: $__qname, $attrs);
219: $_ngcc_current_state = 6;
220: } else {
221: unexpectedEnterElement($__qname);
222: }
223: }
224: break;
225: default: {
226: unexpectedEnterElement($__qname);
227: }
228: break;
229: }
230: }
231:
232: public void leaveElement(String $__uri, String $__local,
233: String $__qname) throws SAXException {
234: int $ai;
235: $uri = $__uri;
236: $localName = $__local;
237: $qname = $__qname;
238: switch ($_ngcc_current_state) {
239: case 17: {
240: if (($ai = $runtime.getAttributeIndex("", "name")) >= 0) {
241: NGCCHandler h = new foreignAttributes(this ,
242: super ._source, $runtime, 665, null);
243: spawnChildFromLeaveElement(h, $__uri, $__local,
244: $__qname);
245: } else {
246: unexpectedLeaveElement($__qname);
247: }
248: }
249: break;
250: case 10: {
251: if (($ai = $runtime.getAttributeIndex("", "refer")) >= 0) {
252: $runtime.consumeAttribute($ai);
253: $runtime.sendLeaveElement(super ._cookie, $__uri,
254: $__local, $__qname);
255: } else {
256: $_ngcc_current_state = 8;
257: $runtime.sendLeaveElement(super ._cookie, $__uri,
258: $__local, $__qname);
259: }
260: }
261: break;
262: case 1: {
263: if (((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local
264: .equals("key")) || ($__uri
265: .equals("http://www.w3.org/2001/XMLSchema") && $__local
266: .equals("keyref"))) || ($__uri
267: .equals("http://www.w3.org/2001/XMLSchema") && $__local
268: .equals("unique")))) {
269: $runtime.onLeaveElementConsumed($__uri, $__local,
270: $__qname);
271: $_ngcc_current_state = 0;
272: } else {
273: unexpectedLeaveElement($__qname);
274: }
275: }
276: break;
277: case 6: {
278: if ((($ai = $runtime.getAttributeIndex("", "xpath")) >= 0 && ($__uri
279: .equals("http://www.w3.org/2001/XMLSchema") && $__local
280: .equals("selector")))) {
281: NGCCHandler h = new xpath(this , super ._source,
282: $runtime, 652);
283: spawnChildFromLeaveElement(h, $__uri, $__local,
284: $__qname);
285: } else {
286: unexpectedLeaveElement($__qname);
287: }
288: }
289: break;
290: case 8: {
291: $_ngcc_current_state = 7;
292: $runtime.sendLeaveElement(super ._cookie, $__uri, $__local,
293: $__qname);
294: }
295: break;
296: case 3: {
297: if ((($ai = $runtime.getAttributeIndex("", "xpath")) >= 0 && ($__uri
298: .equals("http://www.w3.org/2001/XMLSchema") && $__local
299: .equals("field")))) {
300: NGCCHandler h = new xpath(this , super ._source,
301: $runtime, 648);
302: spawnChildFromLeaveElement(h, $__uri, $__local,
303: $__qname);
304: } else {
305: unexpectedLeaveElement($__qname);
306: }
307: }
308: break;
309: case 0: {
310: revertToParentFromLeaveElement(makeResult(), super ._cookie,
311: $__uri, $__local, $__qname);
312: }
313: break;
314: case 16: {
315: if (($ai = $runtime.getAttributeIndex("", "name")) >= 0) {
316: $runtime.consumeAttribute($ai);
317: $runtime.sendLeaveElement(super ._cookie, $__uri,
318: $__local, $__qname);
319: } else {
320: unexpectedLeaveElement($__qname);
321: }
322: }
323: break;
324: case 2: {
325: if (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local
326: .equals("field"))) {
327: $runtime.onLeaveElementConsumed($__uri, $__local,
328: $__qname);
329: $_ngcc_current_state = 1;
330: } else {
331: unexpectedLeaveElement($__qname);
332: }
333: }
334: break;
335: case 5: {
336: if (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local
337: .equals("selector"))) {
338: $runtime.onLeaveElementConsumed($__uri, $__local,
339: $__qname);
340: $_ngcc_current_state = 4;
341: } else {
342: unexpectedLeaveElement($__qname);
343: }
344: }
345: break;
346: default: {
347: unexpectedLeaveElement($__qname);
348: }
349: break;
350: }
351: }
352:
353: public void enterAttribute(String $__uri, String $__local,
354: String $__qname) throws SAXException {
355: int $ai;
356: $uri = $__uri;
357: $localName = $__local;
358: $qname = $__qname;
359: switch ($_ngcc_current_state) {
360: case 17: {
361: if (($__uri.equals("") && $__local.equals("name"))) {
362: NGCCHandler h = new foreignAttributes(this ,
363: super ._source, $runtime, 665, null);
364: spawnChildFromEnterAttribute(h, $__uri, $__local,
365: $__qname);
366: } else {
367: unexpectedEnterAttribute($__qname);
368: }
369: }
370: break;
371: case 10: {
372: if (($__uri.equals("") && $__local.equals("refer"))) {
373: $_ngcc_current_state = 12;
374: } else {
375: $_ngcc_current_state = 8;
376: $runtime.sendEnterAttribute(super ._cookie, $__uri,
377: $__local, $__qname);
378: }
379: }
380: break;
381: case 6: {
382: if (($__uri.equals("") && $__local.equals("xpath"))) {
383: NGCCHandler h = new xpath(this , super ._source,
384: $runtime, 652);
385: spawnChildFromEnterAttribute(h, $__uri, $__local,
386: $__qname);
387: } else {
388: unexpectedEnterAttribute($__qname);
389: }
390: }
391: break;
392: case 8: {
393: $_ngcc_current_state = 7;
394: $runtime.sendEnterAttribute(super ._cookie, $__uri,
395: $__local, $__qname);
396: }
397: break;
398: case 3: {
399: if (($__uri.equals("") && $__local.equals("xpath"))) {
400: NGCCHandler h = new xpath(this , super ._source,
401: $runtime, 648);
402: spawnChildFromEnterAttribute(h, $__uri, $__local,
403: $__qname);
404: } else {
405: unexpectedEnterAttribute($__qname);
406: }
407: }
408: break;
409: case 0: {
410: revertToParentFromEnterAttribute(makeResult(),
411: super ._cookie, $__uri, $__local, $__qname);
412: }
413: break;
414: case 16: {
415: if (($__uri.equals("") && $__local.equals("name"))) {
416: $_ngcc_current_state = 15;
417: } else {
418: unexpectedEnterAttribute($__qname);
419: }
420: }
421: break;
422: default: {
423: unexpectedEnterAttribute($__qname);
424: }
425: break;
426: }
427: }
428:
429: public void leaveAttribute(String $__uri, String $__local,
430: String $__qname) throws SAXException {
431: int $ai;
432: $uri = $__uri;
433: $localName = $__local;
434: $qname = $__qname;
435: switch ($_ngcc_current_state) {
436: case 10: {
437: $_ngcc_current_state = 8;
438: $runtime.sendLeaveAttribute(super ._cookie, $__uri,
439: $__local, $__qname);
440: }
441: break;
442: case 8: {
443: $_ngcc_current_state = 7;
444: $runtime.sendLeaveAttribute(super ._cookie, $__uri,
445: $__local, $__qname);
446: }
447: break;
448: case 0: {
449: revertToParentFromLeaveAttribute(makeResult(),
450: super ._cookie, $__uri, $__local, $__qname);
451: }
452: break;
453: case 14: {
454: if (($__uri.equals("") && $__local.equals("name"))) {
455: $_ngcc_current_state = 10;
456: } else {
457: unexpectedLeaveAttribute($__qname);
458: }
459: }
460: break;
461: case 11: {
462: if (($__uri.equals("") && $__local.equals("refer"))) {
463: $_ngcc_current_state = 8;
464: } else {
465: unexpectedLeaveAttribute($__qname);
466: }
467: }
468: break;
469: default: {
470: unexpectedLeaveAttribute($__qname);
471: }
472: break;
473: }
474: }
475:
476: public void text(String $value) throws SAXException {
477: int $ai;
478: switch ($_ngcc_current_state) {
479: case 17: {
480: if (($ai = $runtime.getAttributeIndex("", "name")) >= 0) {
481: NGCCHandler h = new foreignAttributes(this ,
482: super ._source, $runtime, 665, null);
483: spawnChildFromText(h, $value);
484: }
485: }
486: break;
487: case 10: {
488: if (($ai = $runtime.getAttributeIndex("", "refer")) >= 0) {
489: $runtime.consumeAttribute($ai);
490: $runtime.sendText(super ._cookie, $value);
491: } else {
492: $_ngcc_current_state = 8;
493: $runtime.sendText(super ._cookie, $value);
494: }
495: }
496: break;
497: case 12: {
498: NGCCHandler h = new qname(this , super ._source, $runtime,
499: 658);
500: spawnChildFromText(h, $value);
501: }
502: break;
503: case 6: {
504: if (($ai = $runtime.getAttributeIndex("", "xpath")) >= 0) {
505: NGCCHandler h = new xpath(this , super ._source,
506: $runtime, 652);
507: spawnChildFromText(h, $value);
508: }
509: }
510: break;
511: case 8: {
512: $_ngcc_current_state = 7;
513: $runtime.sendText(super ._cookie, $value);
514: }
515: break;
516: case 3: {
517: if (($ai = $runtime.getAttributeIndex("", "xpath")) >= 0) {
518: NGCCHandler h = new xpath(this , super ._source,
519: $runtime, 648);
520: spawnChildFromText(h, $value);
521: }
522: }
523: break;
524: case 0: {
525: revertToParentFromText(makeResult(), super ._cookie, $value);
526: }
527: break;
528: case 16: {
529: if (($ai = $runtime.getAttributeIndex("", "name")) >= 0) {
530: $runtime.consumeAttribute($ai);
531: $runtime.sendText(super ._cookie, $value);
532: }
533: }
534: break;
535: case 15: {
536: name = $value;
537: $_ngcc_current_state = 14;
538: }
539: break;
540: }
541: }
542:
543: public void onChildCompleted(Object $__result__, int $__cookie__,
544: boolean $__needAttCheck__) throws SAXException {
545: switch ($__cookie__) {
546: case 652: {
547: selector = ((XPathImpl) $__result__);
548: $_ngcc_current_state = 5;
549: }
550: break;
551: case 658: {
552: ref = ((UName) $__result__);
553: action1();
554: $_ngcc_current_state = 11;
555: }
556: break;
557: case 648: {
558: field = ((XPathImpl) $__result__);
559: action0();
560: $_ngcc_current_state = 2;
561: }
562: break;
563: case 665: {
564: fa = ((ForeignAttributesImpl) $__result__);
565: $_ngcc_current_state = 16;
566: }
567: break;
568: case 655: {
569: ann = ((AnnotationImpl) $__result__);
570: $_ngcc_current_state = 7;
571: }
572: break;
573: }
574: }
575:
576: public boolean accepted() {
577: return (($_ngcc_current_state == 0));
578: }
579:
580: private short category;
581: private List fields = new ArrayList();
582: private XPathImpl selector;
583: private DelayedRef.IdentityConstraint refer = null;
584:
585: private IdentityConstraintImpl makeResult() {
586: return new IdentityConstraintImpl($runtime.document, ann,
587: $runtime.copyLocator(), fa, category, name, selector,
588: fields, refer);
589: }
590:
591: }
|