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