1 /*
   2  * Copyright (c) 1997, 2012, 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 */
  27 package com.sun.tools.internal.jxc.gen.config;
  28 import org.xml.sax.SAXException;
  29 import org.xml.sax.XMLReader;
  30 import org.xml.sax.Attributes;
  31 import com.sun.tools.internal.jxc.NGCCRuntimeEx;
  32 import javax.xml.parsers.SAXParserFactory;
  33 import org.xml.sax.XMLReader;
  34 
  35 import java.util.List;
  36     import java.util.ArrayList;
  37     import java.io.File;
  38 
  39 
  40 public class Config extends NGCCHandler {
  41     private String bd;
  42     private Schema _schema;
  43     protected final NGCCRuntimeEx $runtime;
  44     private int $_ngcc_current_state;
  45     protected String $uri;
  46     protected String $localName;
  47     protected String $qname;
  48 
  49     public final NGCCRuntime getRuntime() {
  50         return($runtime);
  51     }
  52 
  53     public Config(NGCCHandler parent, NGCCEventSource source, NGCCRuntimeEx runtime, int cookie) {
  54         super(source, parent, cookie);
  55         $runtime = runtime;
  56         $_ngcc_current_state = 8;
  57     }
  58 
  59     public Config(NGCCRuntimeEx runtime) {
  60         this(null, runtime, runtime, -1);
  61     }
  62 
  63     private void action0()throws SAXException {
  64         this.schema.add (_schema);
  65 }
  66 
  67     private void action1()throws SAXException {
  68         baseDir = $runtime.getBaseDir(bd);
  69 }
  70 
  71     public void enterElement(String $__uri, String $__local, String $__qname, Attributes $attrs) throws SAXException {
  72         int $ai;
  73         $uri = $__uri;
  74         $localName = $__local;
  75         $qname = $__qname;
  76         switch($_ngcc_current_state) {
  77         case 1:
  78             {
  79                 if(($__uri.equals("") && $__local.equals("schema"))) {
  80                     NGCCHandler h = new Schema(this, super._source, $runtime, 31, baseDir);
  81                     spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
  82                 }
  83                 else {
  84                     unexpectedEnterElement($__qname);
  85                 }
  86             }
  87             break;
  88         case 0:
  89             {
  90                 revertToParentFromEnterElement(this, super._cookie, $__uri, $__local, $__qname, $attrs);
  91             }
  92             break;
  93         case 7:
  94             {
  95                 if(($ai = $runtime.getAttributeIndex("","baseDir"))>=0) {
  96                     $runtime.consumeAttribute($ai);
  97                     $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
  98                 }
  99                 else {
 100                     unexpectedEnterElement($__qname);
 101                 }
 102             }
 103             break;
 104         case 8:
 105             {
 106                 if(($__uri.equals("") && $__local.equals("config"))) {
 107                     $runtime.onEnterElementConsumed($__uri, $__local, $__qname, $attrs);
 108                     $_ngcc_current_state = 7;
 109                 }
 110                 else {
 111                     unexpectedEnterElement($__qname);
 112                 }
 113             }
 114             break;
 115         case 2:
 116             {
 117                 if(($__uri.equals("") && $__local.equals("schema"))) {
 118                     NGCCHandler h = new Schema(this, super._source, $runtime, 32, baseDir);
 119                     spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 120                 }
 121                 else {
 122                     $_ngcc_current_state = 1;
 123                     $runtime.sendEnterElement(super._cookie, $__uri, $__local, $__qname, $attrs);
 124                 }
 125             }
 126             break;
 127         case 4:
 128             {
 129                 if(($__uri.equals("") && $__local.equals("classes"))) {
 130                     NGCCHandler h = new Classes(this, super._source, $runtime, 34);
 131                     spawnChildFromEnterElement(h, $__uri, $__local, $__qname, $attrs);
 132                 }
 133                 else {
 134                     unexpectedEnterElement($__qname);
 135                 }
 136             }
 137             break;
 138         default:
 139             {
 140                 unexpectedEnterElement($__qname);
 141             }
 142             break;
 143         }
 144     }
 145 
 146     public void leaveElement(String $__uri, String $__local, String $__qname) throws SAXException {
 147         int $ai;
 148         $uri = $__uri;
 149         $localName = $__local;
 150         $qname = $__qname;
 151         switch($_ngcc_current_state) {
 152         case 1:
 153             {
 154                 if(($__uri.equals("") && $__local.equals("config"))) {
 155                     $runtime.onLeaveElementConsumed($__uri, $__local, $__qname);
 156                     $_ngcc_current_state = 0;
 157                 }
 158                 else {
 159                     unexpectedLeaveElement($__qname);
 160                 }
 161             }
 162             break;
 163         case 0:
 164             {
 165                 revertToParentFromLeaveElement(this, super._cookie, $__uri, $__local, $__qname);
 166             }
 167             break;
 168         case 7:
 169             {
 170                 if(($ai = $runtime.getAttributeIndex("","baseDir"))>=0) {
 171                     $runtime.consumeAttribute($ai);
 172                     $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
 173                 }
 174                 else {
 175                     unexpectedLeaveElement($__qname);
 176                 }
 177             }
 178             break;
 179         case 2:
 180             {
 181                 $_ngcc_current_state = 1;
 182                 $runtime.sendLeaveElement(super._cookie, $__uri, $__local, $__qname);
 183             }
 184             break;
 185         default:
 186             {
 187                 unexpectedLeaveElement($__qname);
 188             }
 189             break;
 190         }
 191     }
 192 
 193     public void enterAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
 194         int $ai;
 195         $uri = $__uri;
 196         $localName = $__local;
 197         $qname = $__qname;
 198         switch($_ngcc_current_state) {
 199         case 0:
 200             {
 201                 revertToParentFromEnterAttribute(this, super._cookie, $__uri, $__local, $__qname);
 202             }
 203             break;
 204         case 7:
 205             {
 206                 if(($__uri.equals("") && $__local.equals("baseDir"))) {
 207                     $_ngcc_current_state = 6;
 208                 }
 209                 else {
 210                     unexpectedEnterAttribute($__qname);
 211                 }
 212             }
 213             break;
 214         case 2:
 215             {
 216                 $_ngcc_current_state = 1;
 217                 $runtime.sendEnterAttribute(super._cookie, $__uri, $__local, $__qname);
 218             }
 219             break;
 220         default:
 221             {
 222                 unexpectedEnterAttribute($__qname);
 223             }
 224             break;
 225         }
 226     }
 227 
 228     public void leaveAttribute(String $__uri, String $__local, String $__qname) throws SAXException {
 229         int $ai;
 230         $uri = $__uri;
 231         $localName = $__local;
 232         $qname = $__qname;
 233         switch($_ngcc_current_state) {
 234         case 0:
 235             {
 236                 revertToParentFromLeaveAttribute(this, super._cookie, $__uri, $__local, $__qname);
 237             }
 238             break;
 239         case 2:
 240             {
 241                 $_ngcc_current_state = 1;
 242                 $runtime.sendLeaveAttribute(super._cookie, $__uri, $__local, $__qname);
 243             }
 244             break;
 245         case 5:
 246             {
 247                 if(($__uri.equals("") && $__local.equals("baseDir"))) {
 248                     $_ngcc_current_state = 4;
 249                 }
 250                 else {
 251                     unexpectedLeaveAttribute($__qname);
 252                 }
 253             }
 254             break;
 255         default:
 256             {
 257                 unexpectedLeaveAttribute($__qname);
 258             }
 259             break;
 260         }
 261     }
 262 
 263     public void text(String $value) throws SAXException {
 264         int $ai;
 265         switch($_ngcc_current_state) {
 266         case 0:
 267             {
 268                 revertToParentFromText(this, super._cookie, $value);
 269             }
 270             break;
 271         case 6:
 272             {
 273                 bd = $value;
 274                 $_ngcc_current_state = 5;
 275                 action1();
 276             }
 277             break;
 278         case 7:
 279             {
 280                 if(($ai = $runtime.getAttributeIndex("","baseDir"))>=0) {
 281                     $runtime.consumeAttribute($ai);
 282                     $runtime.sendText(super._cookie, $value);
 283                 }
 284             }
 285             break;
 286         case 2:
 287             {
 288                 $_ngcc_current_state = 1;
 289                 $runtime.sendText(super._cookie, $value);
 290             }
 291             break;
 292         }
 293     }
 294 
 295     public void onChildCompleted(Object result, int cookie, boolean needAttCheck)throws SAXException {
 296         switch(cookie) {
 297         case 31:
 298             {
 299                 this._schema = ((Schema)result);
 300                 action0();
 301                 $_ngcc_current_state = 1;
 302             }
 303             break;
 304         case 34:
 305             {
 306                 this.classes = ((Classes)result);
 307                 $_ngcc_current_state = 2;
 308             }
 309             break;
 310         case 32:
 311             {
 312                 this._schema = ((Schema)result);
 313                 action0();
 314                 $_ngcc_current_state = 1;
 315             }
 316             break;
 317         }
 318     }
 319 
 320     public boolean accepted() {
 321         return(($_ngcc_current_state == 0));
 322     }
 323 
 324 
 325    private File baseDir;
 326    private Classes classes;
 327    private List schema = new ArrayList();
 328    public Classes getClasses() { return this.classes;}
 329    public File getBaseDir() { return baseDir;}
 330    public List getSchema() { return this.schema;}
 331 
 332 }