1 /* 2 * Copyright (c) 1997, 2013, 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 package com.sun.tools.internal.jxc.gen.config; 27 28 import org.xml.sax.Attributes; 29 import org.xml.sax.SAXException; 30 31 /** 32 * <p><b> 33 * Auto-generated, do not edit. 34 * </b></p> 35 * 36 * @version $Id: NGCCHandler.java,v 1.9 2002/09/29 02:55:48 okajima Exp $ 37 * @author Kohsuke Kawaguchi (kk@kohsuke.org) 38 */ 39 public abstract class NGCCHandler implements NGCCEventReceiver { 40 protected NGCCHandler( NGCCEventSource source, NGCCHandler parent, int parentCookie ) { 41 42 _parent = parent; 43 _source = source; 44 _cookie = parentCookie; 45 } 46 47 /** 48 * Parent NGCCHandler, if any. 49 * If this is the root handler, this field will be null. 50 */ 51 protected final NGCCHandler _parent; 52 53 /** 54 * Event source. 55 */ 56 protected final NGCCEventSource _source; 57 58 /** 59 * This method will be implemented by the generated code 60 * and returns a reference to the current runtime. 61 */ 62 protected abstract NGCCRuntime getRuntime(); 63 64 /** 65 * Cookie assigned by the parent. 66 * 67 * This value will be passed to the onChildCompleted handler 68 * of the parent. 69 */ 70 protected final int _cookie; 71 72 // used to copy parameters to (enter|leave)(Element|Attribute) events. 73 //protected String localName,uri,qname; 74 75 76 /** 77 * Notifies the completion of a child object. 78 * 79 * @param result 80 * The parsing result of the child state. 81 * @param cookie 82 * The cookie value passed to the child object 83 * when it is created. 84 * @param needAttCheck 85 * This flag is true when the callee needs to call the 86 * processAttribute method to check attribute transitions. 87 * This flag is set to false when this method is triggered by 88 * attribute transition. 89 */ 90 protected abstract void onChildCompleted( Object result, int cookie, boolean needAttCheck ) throws SAXException; 91 92 // 93 // 94 // spawns a new child object from event handlers. 95 // 96 // 97 public void spawnChildFromEnterElement( NGCCEventReceiver child, 98 String uri, String localname, String qname, Attributes atts) throws SAXException { 99 100 int id = _source.replace(this,child); 101 _source.sendEnterElement(id,uri,localname,qname,atts); 102 } 103 public void spawnChildFromEnterAttribute( NGCCEventReceiver child, 104 String uri, String localname, String qname) throws SAXException { 105 106 int id = _source.replace(this,child); 107 _source.sendEnterAttribute(id,uri,localname,qname); 108 } 109 public void spawnChildFromLeaveElement( NGCCEventReceiver child, 110 String uri, String localname, String qname) throws SAXException { 111 112 int id = _source.replace(this,child); 113 _source.sendLeaveElement(id,uri,localname,qname); 114 } 115 public void spawnChildFromLeaveAttribute( NGCCEventReceiver child, 116 String uri, String localname, String qname) throws SAXException { 117 118 int id = _source.replace(this,child); 119 _source.sendLeaveAttribute(id,uri,localname,qname); 120 } 121 public void spawnChildFromText( NGCCEventReceiver child, 122 String value) throws SAXException { 123 124 int id = _source.replace(this,child); 125 _source.sendText(id,value); 126 } 127 128 // 129 // 130 // reverts to the parent object from the child handler 131 // 132 // 133 public void revertToParentFromEnterElement( Object result, int cookie, 134 String uri,String local,String qname, Attributes atts ) throws SAXException { 135 136 int id = _source.replace(this,_parent); 137 _parent.onChildCompleted(result,cookie,true); 138 _source.sendEnterElement(id,uri,local,qname,atts); 139 } 140 public void revertToParentFromLeaveElement( Object result, int cookie, 141 String uri,String local,String qname ) throws SAXException { 142 143 if(uri==NGCCRuntime.IMPOSSIBLE && uri==local && uri==qname && _parent==null ) 144 // all the handlers are properly finalized. 145 // quit now, because we don't have any more NGCCHandler. 146 // see the endDocument handler for detail 147 return; 148 149 int id = _source.replace(this,_parent); 150 _parent.onChildCompleted(result,cookie,true); 151 _source.sendLeaveElement(id,uri,local,qname); 152 } 153 public void revertToParentFromEnterAttribute( Object result, int cookie, 154 String uri,String local,String qname ) throws SAXException { 155 156 int id = _source.replace(this,_parent); 157 _parent.onChildCompleted(result,cookie,true); 158 _source.sendEnterAttribute(id,uri,local,qname); 159 } 160 public void revertToParentFromLeaveAttribute( Object result, int cookie, 161 String uri,String local,String qname ) throws SAXException { 162 163 int id = _source.replace(this,_parent); 164 _parent.onChildCompleted(result,cookie,true); 165 _source.sendLeaveAttribute(id,uri,local,qname); 166 } 167 public void revertToParentFromText( Object result, int cookie, 168 String text ) throws SAXException { 169 170 int id = _source.replace(this,_parent); 171 _parent.onChildCompleted(result,cookie,true); 172 _source.sendText(id,text); 173 } 174 175 176 // 177 // 178 // error handler 179 // 180 // 181 public void unexpectedEnterElement(String qname) throws SAXException { 182 getRuntime().unexpectedX('<'+qname+'>'); 183 } 184 public void unexpectedLeaveElement(String qname) throws SAXException { 185 getRuntime().unexpectedX("</"+qname+'>'); 186 } 187 public void unexpectedEnterAttribute(String qname) throws SAXException { 188 getRuntime().unexpectedX('@'+qname); 189 } 190 public void unexpectedLeaveAttribute(String qname) throws SAXException { 191 getRuntime().unexpectedX("/@"+qname); 192 } 193 }