1/*
2 * Copyright (c) 1997, 2016, 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 */
27package com.sun.xml.internal.xsom.impl.parser.state;
28
29import com.sun.xml.internal.xsom.*;
30import com.sun.xml.internal.xsom.impl.*;
31import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
32import com.sun.xml.internal.xsom.parser.*;
33import java.util.*;
34
35import org.xml.sax.Attributes;
36import org.xml.sax.Locator;
37import org.xml.sax.SAXException;
38
39
40class simpleType extends NGCCHandler {
41    private AnnotationImpl annotation;
42    private String name;
43    private ForeignAttributesImpl fa;
44    private String finalValue;
45    protected final NGCCRuntimeEx $runtime;
46    private int $_ngcc_current_state;
47    protected String $uri;
48    protected String $localName;
49    protected String $qname;
50
51    public final NGCCRuntime getRuntime() {
52        return($runtime);
53    }
54
55    public simpleType(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie) {
56        super(source, parent, cookie);
57        $runtime = runtime;
58        $_ngcc_current_state = 19;
59    }
60
61    public simpleType(NGCCRuntimeEx runtime) {
62        this(null, runtime, runtime, -1);
63    }
64
65    private void action0()throws SAXException {
66        finalSet = makeFinalSet(finalValue);
67}
68
69    private void action1()throws SAXException {
70        locator=$runtime.copyLocator();
71}
72
73    public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
74        int $ai;
75        $uri = $__uri;
76        $localName = $__local;
77        $qname = $__qname;
78        switch($_ngcc_current_state) {
79        case 15:
80            {
81                if(($ai = $runtime.getAttributeIndex("","final"))>=0) {
82                    $runtime.consumeAttribute($ai);
83                    $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
84                }
85                else {
86                    $_ngcc_current_state = 11;
87                    $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
88                }
89            }
90            break;
91        case 11:
92            {
93                if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
94                    $runtime.consumeAttribute($ai);
95                    $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
96                }
97                else {
98                    $_ngcc_current_state = 10;
99                    $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
100                }
101            }
102            break;
103        case 19:
104            {
105                if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("simpleType"))) {
106                    $runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
107                    action1();
108                    $_ngcc_current_state = 15;
109                }
110                else {
111                    unexpectedEnterElement($__qname);
112                }
113            }
114            break;
115        case 8:
116            {
117                if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation"))) {
118                    NGCCHandler h = new annotation(this, super._source, $runtime, 89, null,AnnotationContext.SIMPLETYPE_DECL);
119                    spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
120                }
121                else {
122                    $_ngcc_current_state = 7;
123                    $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
124                }
125            }
126            break;
127        case 10:
128            {
129                if((($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("annotation")) || (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("restriction")) || (($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("union")) || ($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("list")))))) {
130                    NGCCHandler h = new foreignAttributes(this, super._source, $runtime, 91, fa);
131                    spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
132                }
133                else {
134                    unexpectedEnterElement($__qname);
135                }
136            }
137            break;
138        case 7:
139            {
140                action0();
141                $_ngcc_current_state = 2;
142                $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
143            }
144            break;
145        case 0:
146            {
147                revertToParentFromEnterElement(result, super._cookie, $__uri, $__local, $__qname, $attrs);
148            }
149            break;
150        case 2:
151            {
152                if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("restriction"))) {
153                    NGCCHandler h = new SimpleType_Restriction(this, super._source, $runtime, 85, annotation,locator,fa,name,finalSet);
154                    spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
155                }
156                else {
157                    if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("list"))) {
158                        NGCCHandler h = new SimpleType_List(this, super._source, $runtime, 86, annotation,locator,fa,name,finalSet);
159                        spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
160                    }
161                    else {
162                        if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("union"))) {
163                            NGCCHandler h = new SimpleType_Union(this, super._source, $runtime, 80, annotation,locator,fa,name,finalSet);
164                            spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
165                        }
166                        else {
167                            unexpectedEnterElement($__qname);
168                        }
169                    }
170                }
171            }
172            break;
173        default:
174            {
175                unexpectedEnterElement($__qname);
176            }
177            break;
178        }
179    }
180
181    public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
182        int $ai;
183        $uri = $__uri;
184        $localName = $__local;
185        $qname = $__qname;
186        switch($_ngcc_current_state) {
187        case 15:
188            {
189                if(($ai = $runtime.getAttributeIndex("","final"))>=0) {
190                    $runtime.consumeAttribute($ai);
191                    $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
192                }
193                else {
194                    $_ngcc_current_state = 11;
195                    $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
196                }
197            }
198            break;
199        case 11:
200            {
201                if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
202                    $runtime.consumeAttribute($ai);
203                    $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
204                }
205                else {
206                    $_ngcc_current_state = 10;
207                    $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
208                }
209            }
210            break;
211        case 8:
212            {
213                $_ngcc_current_state = 7;
214                $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
215            }
216            break;
217        case 7:
218            {
219                action0();
220                $_ngcc_current_state = 2;
221                $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
222            }
223            break;
224        case 1:
225            {
226                if(($__uri.equals("http://www.w3.org/2001/XMLSchema") && $__local.equals("simpleType"))) {
227                    $runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
228                    $_ngcc_current_state = 0;
229                }
230                else {
231                    unexpectedLeaveElement($__qname);
232                }
233            }
234            break;
235        case 0:
236            {
237                revertToParentFromLeaveElement(result, super._cookie, $__uri, $__local, $__qname);
238            }
239            break;
240        default:
241            {
242                unexpectedLeaveElement($__qname);
243            }
244            break;
245        }
246    }
247
248    public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
249        int $ai;
250        $uri = $__uri;
251        $localName = $__local;
252        $qname = $__qname;
253        switch($_ngcc_current_state) {
254        case 15:
255            {
256                if(($__uri.equals("") && $__local.equals("final"))) {
257                    $_ngcc_current_state = 17;
258                }
259                else {
260                    $_ngcc_current_state = 11;
261                    $runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
262                }
263            }
264            break;
265        case 11:
266            {
267                if(($__uri.equals("") && $__local.equals("name"))) {
268                    $_ngcc_current_state = 13;
269                }
270                else {
271                    $_ngcc_current_state = 10;
272                    $runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
273                }
274            }
275            break;
276        case 8:
277            {
278                $_ngcc_current_state = 7;
279                $runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
280            }
281            break;
282        case 7:
283            {
284                action0();
285                $_ngcc_current_state = 2;
286                $runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
287            }
288            break;
289        case 0:
290            {
291                revertToParentFromEnterAttribute(result, super._cookie, $__uri, $__local, $__qname);
292            }
293            break;
294        default:
295            {
296                unexpectedEnterAttribute($__qname);
297            }
298            break;
299        }
300    }
301
302    public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
303        int $ai;
304        $uri = $__uri;
305        $localName = $__local;
306        $qname = $__qname;
307        switch($_ngcc_current_state) {
308        case 15:
309            {
310                $_ngcc_current_state = 11;
311                $runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
312            }
313            break;
314        case 11:
315            {
316                $_ngcc_current_state = 10;
317                $runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
318            }
319            break;
320        case 8:
321            {
322                $_ngcc_current_state = 7;
323                $runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
324            }
325            break;
326        case 7:
327            {
328                action0();
329                $_ngcc_current_state = 2;
330                $runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
331            }
332            break;
333        case 12:
334            {
335                if(($__uri.equals("") && $__local.equals("name"))) {
336                    $_ngcc_current_state = 10;
337                }
338                else {
339                    unexpectedLeaveAttribute($__qname);
340                }
341            }
342            break;
343        case 16:
344            {
345                if(($__uri.equals("") && $__local.equals("final"))) {
346                    $_ngcc_current_state = 11;
347                }
348                else {
349                    unexpectedLeaveAttribute($__qname);
350                }
351            }
352            break;
353        case 0:
354            {
355                revertToParentFromLeaveAttribute(result, super._cookie, $__uri, $__local, $__qname);
356            }
357            break;
358        default:
359            {
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 13:
370            {
371                name = $runtime.collapse($value);
372                $_ngcc_current_state = 12;
373            }
374            break;
375        case 15:
376            {
377                if(($ai = $runtime.getAttributeIndex("","final"))>=0) {
378                    $runtime.consumeAttribute($ai);
379                    $runtime.sendText(super._cookie, $value);
380                }
381                else {
382                    $_ngcc_current_state = 11;
383                    $runtime.sendText(super._cookie, $value);
384                }
385            }
386            break;
387        case 11:
388            {
389                if(($ai = $runtime.getAttributeIndex("","name"))>=0) {
390                    $runtime.consumeAttribute($ai);
391                    $runtime.sendText(super._cookie, $value);
392                }
393                else {
394                    $_ngcc_current_state = 10;
395                    $runtime.sendText(super._cookie, $value);
396                }
397            }
398            break;
399        case 8:
400            {
401                $_ngcc_current_state = 7;
402                $runtime.sendText(super._cookie, $value);
403            }
404            break;
405        case 7:
406            {
407                action0();
408                $_ngcc_current_state = 2;
409                $runtime.sendText(super._cookie, $value);
410            }
411            break;
412        case 17:
413            {
414                finalValue = $value;
415                $_ngcc_current_state = 16;
416            }
417            break;
418        case 0:
419            {
420                revertToParentFromText(result, super._cookie, $value);
421            }
422            break;
423        }
424    }
425
426    public void onChildCompleted(Object $__result__, int $__cookie__, boolean $__needAttCheck__)throws SAXException {
427        switch($__cookie__) {
428        case 89:
429            {
430                annotation = ((AnnotationImpl)$__result__);
431                $_ngcc_current_state = 7;
432            }
433            break;
434        case 91:
435            {
436                fa = ((ForeignAttributesImpl)$__result__);
437                $_ngcc_current_state = 8;
438            }
439            break;
440        case 85:
441            {
442                result = ((RestrictionSimpleTypeImpl)$__result__);
443                $_ngcc_current_state = 1;
444            }
445            break;
446        case 86:
447            {
448                result = ((ListSimpleTypeImpl)$__result__);
449                $_ngcc_current_state = 1;
450            }
451            break;
452        case 80:
453            {
454                result = ((UnionSimpleTypeImpl)$__result__);
455                $_ngcc_current_state = 1;
456            }
457            break;
458        }
459    }
460
461    public boolean accepted() {
462        return(($_ngcc_current_state == 0));
463    }
464
465
466                /** computed simple type object */
467                private SimpleTypeImpl result;
468
469                private Locator locator;
470
471      private Set finalSet;
472
473      private Set makeFinalSet(String finalValue) {
474        if(finalValue==null)
475          return Collections.EMPTY_SET;
476
477        Set s = new HashSet();
478        StringTokenizer tokens = new StringTokenizer(finalValue);
479        while(tokens.hasMoreTokens()) {
480          String token = tokens.nextToken();
481          if(token.equals("#all")) {
482            s.add(XSVariety.ATOMIC);
483            s.add(XSVariety.UNION);
484            s.add(XSVariety.LIST);
485          }
486          if(token.equals("list")) {
487            s.add(XSVariety.LIST);
488          }
489          if(token.equals("union")) {
490            s.add(XSVariety.UNION);
491          }
492          if(token.equals("restriction")) {
493            s.add(XSVariety.ATOMIC);
494          }
495        }
496        return s;
497      }
498
499}
500