Wed, 27 Apr 2016 01:27:09 +0800
Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/jaxws/
changeset: 657:d47a47f961ee
tag: jdk8u25-b17
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. Oracle designates this |
aoqi@0 | 8 | * particular file as subject to the "Classpath" exception as provided |
aoqi@0 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
aoqi@0 | 10 | * |
aoqi@0 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 15 | * accompanied this code). |
aoqi@0 | 16 | * |
aoqi@0 | 17 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 20 | * |
aoqi@0 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 22 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 23 | * questions. |
aoqi@0 | 24 | */ |
aoqi@0 | 25 | |
aoqi@0 | 26 | package com.sun.tools.internal.jxc.gen.config; |
aoqi@0 | 27 | |
aoqi@0 | 28 | import org.xml.sax.Attributes; |
aoqi@0 | 29 | import org.xml.sax.SAXException; |
aoqi@0 | 30 | |
aoqi@0 | 31 | /** |
aoqi@0 | 32 | * Dispatches incoming events into sub handlers appropriately |
aoqi@0 | 33 | * so that the interleaving semantics will be correctly realized. |
aoqi@0 | 34 | * |
aoqi@0 | 35 | * <p><b> |
aoqi@0 | 36 | * Auto-generated, do not edit. |
aoqi@0 | 37 | * </b></p> |
aoqi@0 | 38 | * @author Kohsuke Kawaguchi (kk@kohsuke.org) |
aoqi@0 | 39 | */ |
aoqi@0 | 40 | public abstract class NGCCInterleaveFilter implements NGCCEventSource, NGCCEventReceiver { |
aoqi@0 | 41 | protected NGCCInterleaveFilter( NGCCHandler parent, int cookie ) { |
aoqi@0 | 42 | this._parent = parent; |
aoqi@0 | 43 | this._cookie = cookie; |
aoqi@0 | 44 | } |
aoqi@0 | 45 | |
aoqi@0 | 46 | protected void setHandlers( NGCCEventReceiver[] receivers ) { |
aoqi@0 | 47 | this._receivers = receivers; |
aoqi@0 | 48 | } |
aoqi@0 | 49 | |
aoqi@0 | 50 | /** event receiverse. */ |
aoqi@0 | 51 | protected NGCCEventReceiver[] _receivers; |
aoqi@0 | 52 | |
aoqi@0 | 53 | public int replace(NGCCEventReceiver oldHandler, NGCCEventReceiver newHandler) { |
aoqi@0 | 54 | for( int i=0; i<_receivers.length; i++ ) |
aoqi@0 | 55 | if( _receivers[i]==oldHandler ) { |
aoqi@0 | 56 | _receivers[i]=newHandler; |
aoqi@0 | 57 | return i; |
aoqi@0 | 58 | } |
aoqi@0 | 59 | throw new InternalError(); // a bug in RelaxNGCC. |
aoqi@0 | 60 | } |
aoqi@0 | 61 | |
aoqi@0 | 62 | |
aoqi@0 | 63 | /** Parent handler. */ |
aoqi@0 | 64 | private final NGCCHandler _parent; |
aoqi@0 | 65 | /** Cookie given by the parent. */ |
aoqi@0 | 66 | private final int _cookie; |
aoqi@0 | 67 | |
aoqi@0 | 68 | |
aoqi@0 | 69 | |
aoqi@0 | 70 | // |
aoqi@0 | 71 | // |
aoqi@0 | 72 | // event handler |
aoqi@0 | 73 | // |
aoqi@0 | 74 | // |
aoqi@0 | 75 | /** |
aoqi@0 | 76 | * Receiver that is being locked and therefore receives all the events. |
aoqi@0 | 77 | * <pre><xmp> |
aoqi@0 | 78 | * <interleave> |
aoqi@0 | 79 | * <element name="foo"/> |
aoqi@0 | 80 | * <element name="bar"> |
aoqi@0 | 81 | * <element name="foo"/> |
aoqi@0 | 82 | * </element> |
aoqi@0 | 83 | * </interlaeve> |
aoqi@0 | 84 | * </xmp></pre> |
aoqi@0 | 85 | * When processing inside the bar element, this receiver is |
aoqi@0 | 86 | * "locked" so that it can correctly receive its child foo element. |
aoqi@0 | 87 | */ |
aoqi@0 | 88 | private int lockedReceiver; |
aoqi@0 | 89 | /** |
aoqi@0 | 90 | * Nest level. Lock will be release when the lockCount becomes 0. |
aoqi@0 | 91 | */ |
aoqi@0 | 92 | private int lockCount=0; |
aoqi@0 | 93 | |
aoqi@0 | 94 | public void enterElement( |
aoqi@0 | 95 | String uri, String localName, String qname,Attributes atts) throws SAXException { |
aoqi@0 | 96 | |
aoqi@0 | 97 | if(isJoining) return; // ignore any token if we are joining. See joinByXXXX. |
aoqi@0 | 98 | |
aoqi@0 | 99 | if(lockCount++==0) { |
aoqi@0 | 100 | lockedReceiver = findReceiverOfElement(uri,localName); |
aoqi@0 | 101 | if(lockedReceiver==-1) { |
aoqi@0 | 102 | // we can't process this token. join. |
aoqi@0 | 103 | joinByEnterElement(null,uri,localName,qname,atts); |
aoqi@0 | 104 | return; |
aoqi@0 | 105 | } |
aoqi@0 | 106 | } |
aoqi@0 | 107 | |
aoqi@0 | 108 | _receivers[lockedReceiver].enterElement(uri,localName,qname,atts); |
aoqi@0 | 109 | } |
aoqi@0 | 110 | public void leaveElement(String uri, String localName, String qname) throws SAXException { |
aoqi@0 | 111 | if(isJoining) return; // ignore any token if we are joining. See joinByXXXX. |
aoqi@0 | 112 | |
aoqi@0 | 113 | if( lockCount-- == 0 ) |
aoqi@0 | 114 | joinByLeaveElement(null,uri,localName,qname); |
aoqi@0 | 115 | else |
aoqi@0 | 116 | _receivers[lockedReceiver].leaveElement(uri,localName,qname); |
aoqi@0 | 117 | } |
aoqi@0 | 118 | public void enterAttribute(String uri, String localName, String qname) throws SAXException { |
aoqi@0 | 119 | if(isJoining) return; // ignore any token if we are joining. See joinByXXXX. |
aoqi@0 | 120 | |
aoqi@0 | 121 | if(lockCount++==0) { |
aoqi@0 | 122 | lockedReceiver = findReceiverOfAttribute(uri,localName); |
aoqi@0 | 123 | if(lockedReceiver==-1) { |
aoqi@0 | 124 | // we can't process this token. join. |
aoqi@0 | 125 | joinByEnterAttribute(null,uri,localName,qname); |
aoqi@0 | 126 | return; |
aoqi@0 | 127 | } |
aoqi@0 | 128 | } |
aoqi@0 | 129 | |
aoqi@0 | 130 | _receivers[lockedReceiver].enterAttribute(uri,localName,qname); |
aoqi@0 | 131 | } |
aoqi@0 | 132 | public void leaveAttribute(String uri, String localName, String qname) throws SAXException { |
aoqi@0 | 133 | if(isJoining) return; // ignore any token if we are joining. See joinByXXXX. |
aoqi@0 | 134 | |
aoqi@0 | 135 | if( lockCount-- == 0 ) |
aoqi@0 | 136 | joinByLeaveAttribute(null,uri,localName,qname); |
aoqi@0 | 137 | else |
aoqi@0 | 138 | _receivers[lockedReceiver].leaveAttribute(uri,localName,qname); |
aoqi@0 | 139 | } |
aoqi@0 | 140 | public void text(String value) throws SAXException { |
aoqi@0 | 141 | if(isJoining) return; // ignore any token if we are joining. See joinByXXXX. |
aoqi@0 | 142 | |
aoqi@0 | 143 | if(lockCount!=0) |
aoqi@0 | 144 | _receivers[lockedReceiver].text(value); |
aoqi@0 | 145 | else { |
aoqi@0 | 146 | int receiver = findReceiverOfText(); |
aoqi@0 | 147 | if(receiver!=-1) _receivers[receiver].text(value); |
aoqi@0 | 148 | else joinByText(null,value); |
aoqi@0 | 149 | } |
aoqi@0 | 150 | } |
aoqi@0 | 151 | |
aoqi@0 | 152 | |
aoqi@0 | 153 | |
aoqi@0 | 154 | /** |
aoqi@0 | 155 | * Implemented by the generated code to determine the handler |
aoqi@0 | 156 | * that can receive the given element. |
aoqi@0 | 157 | * |
aoqi@0 | 158 | * @return |
aoqi@0 | 159 | * Thread ID of the receiver that can handle this event, |
aoqi@0 | 160 | * or -1 if none. |
aoqi@0 | 161 | */ |
aoqi@0 | 162 | protected abstract int findReceiverOfElement( String uri, String local ); |
aoqi@0 | 163 | |
aoqi@0 | 164 | /** |
aoqi@0 | 165 | * Returns the handler that can receive the given attribute, or null. |
aoqi@0 | 166 | */ |
aoqi@0 | 167 | protected abstract int findReceiverOfAttribute( String uri, String local ); |
aoqi@0 | 168 | |
aoqi@0 | 169 | /** |
aoqi@0 | 170 | * Returns the handler that can receive text events, or null. |
aoqi@0 | 171 | */ |
aoqi@0 | 172 | protected abstract int findReceiverOfText(); |
aoqi@0 | 173 | |
aoqi@0 | 174 | |
aoqi@0 | 175 | |
aoqi@0 | 176 | |
aoqi@0 | 177 | // |
aoqi@0 | 178 | // |
aoqi@0 | 179 | // join method |
aoqi@0 | 180 | // |
aoqi@0 | 181 | // |
aoqi@0 | 182 | |
aoqi@0 | 183 | |
aoqi@0 | 184 | /** |
aoqi@0 | 185 | * Set to true when this handler is in the process of |
aoqi@0 | 186 | * joining all branches. |
aoqi@0 | 187 | */ |
aoqi@0 | 188 | private boolean isJoining = false; |
aoqi@0 | 189 | |
aoqi@0 | 190 | /** |
aoqi@0 | 191 | * Joins all the child receivers. |
aoqi@0 | 192 | * |
aoqi@0 | 193 | * <p> |
aoqi@0 | 194 | * This method is called by a child receiver when it sees |
aoqi@0 | 195 | * something that it cannot handle, or by this object itself |
aoqi@0 | 196 | * when it sees an event that it can't process. |
aoqi@0 | 197 | * |
aoqi@0 | 198 | * <p> |
aoqi@0 | 199 | * This method forces children to move to its final state, |
aoqi@0 | 200 | * then revert to the parent. |
aoqi@0 | 201 | * |
aoqi@0 | 202 | * @param source |
aoqi@0 | 203 | * If this method is called by one of the child receivers, |
aoqi@0 | 204 | * the receiver object. If this method is called by itself, |
aoqi@0 | 205 | * null. |
aoqi@0 | 206 | */ |
aoqi@0 | 207 | public void joinByEnterElement( NGCCEventReceiver source, |
aoqi@0 | 208 | String uri, String local, String qname, Attributes atts ) throws SAXException { |
aoqi@0 | 209 | |
aoqi@0 | 210 | if(isJoining) return; // we are already in the process of joining. ignore. |
aoqi@0 | 211 | isJoining = true; |
aoqi@0 | 212 | |
aoqi@0 | 213 | // send special token to the rest of the branches. |
aoqi@0 | 214 | // these branches don't understand this token, so they will |
aoqi@0 | 215 | // try to move to a final state and send the token back to us, |
aoqi@0 | 216 | // which this object will ignore (because isJoining==true) |
aoqi@0 | 217 | // Otherwise branches will find an error. |
aoqi@0 | 218 | for( int i=0; i<_receivers.length; i++ ) |
aoqi@0 | 219 | if( _receivers[i]!=source ) |
aoqi@0 | 220 | _receivers[i].enterElement(uri,local,qname,atts); |
aoqi@0 | 221 | |
aoqi@0 | 222 | // revert to the parent |
aoqi@0 | 223 | _parent._source.replace(this,_parent); |
aoqi@0 | 224 | _parent.onChildCompleted(null,_cookie,true); |
aoqi@0 | 225 | // send this event to the parent |
aoqi@0 | 226 | _parent.enterElement(uri,local,qname,atts); |
aoqi@0 | 227 | } |
aoqi@0 | 228 | |
aoqi@0 | 229 | public void joinByLeaveElement( NGCCEventReceiver source, |
aoqi@0 | 230 | String uri, String local, String qname ) throws SAXException { |
aoqi@0 | 231 | |
aoqi@0 | 232 | if(isJoining) return; // we are already in the process of joining. ignore. |
aoqi@0 | 233 | isJoining = true; |
aoqi@0 | 234 | |
aoqi@0 | 235 | // send special token to the rest of the branches. |
aoqi@0 | 236 | // these branches don't understand this token, so they will |
aoqi@0 | 237 | // try to move to a final state and send the token back to us, |
aoqi@0 | 238 | // which this object will ignore (because isJoining==true) |
aoqi@0 | 239 | // Otherwise branches will find an error. |
aoqi@0 | 240 | for( int i=0; i<_receivers.length; i++ ) |
aoqi@0 | 241 | if( _receivers[i]!=source ) |
aoqi@0 | 242 | _receivers[i].leaveElement(uri,local,qname); |
aoqi@0 | 243 | |
aoqi@0 | 244 | // revert to the parent |
aoqi@0 | 245 | _parent._source.replace(this,_parent); |
aoqi@0 | 246 | _parent.onChildCompleted(null,_cookie,true); |
aoqi@0 | 247 | // send this event to the parent |
aoqi@0 | 248 | _parent.leaveElement(uri,local,qname); |
aoqi@0 | 249 | } |
aoqi@0 | 250 | |
aoqi@0 | 251 | public void joinByEnterAttribute( NGCCEventReceiver source, |
aoqi@0 | 252 | String uri, String local, String qname ) throws SAXException { |
aoqi@0 | 253 | |
aoqi@0 | 254 | if(isJoining) return; // we are already in the process of joining. ignore. |
aoqi@0 | 255 | isJoining = true; |
aoqi@0 | 256 | |
aoqi@0 | 257 | // send special token to the rest of the branches. |
aoqi@0 | 258 | // these branches don't understand this token, so they will |
aoqi@0 | 259 | // try to move to a final state and send the token back to us, |
aoqi@0 | 260 | // which this object will ignore (because isJoining==true) |
aoqi@0 | 261 | // Otherwise branches will find an error. |
aoqi@0 | 262 | for( int i=0; i<_receivers.length; i++ ) |
aoqi@0 | 263 | if( _receivers[i]!=source ) |
aoqi@0 | 264 | _receivers[i].enterAttribute(uri,local,qname); |
aoqi@0 | 265 | |
aoqi@0 | 266 | // revert to the parent |
aoqi@0 | 267 | _parent._source.replace(this,_parent); |
aoqi@0 | 268 | _parent.onChildCompleted(null,_cookie,true); |
aoqi@0 | 269 | // send this event to the parent |
aoqi@0 | 270 | _parent.enterAttribute(uri,local,qname); |
aoqi@0 | 271 | } |
aoqi@0 | 272 | |
aoqi@0 | 273 | public void joinByLeaveAttribute( NGCCEventReceiver source, |
aoqi@0 | 274 | String uri, String local, String qname ) throws SAXException { |
aoqi@0 | 275 | |
aoqi@0 | 276 | if(isJoining) return; // we are already in the process of joining. ignore. |
aoqi@0 | 277 | isJoining = true; |
aoqi@0 | 278 | |
aoqi@0 | 279 | // send special token to the rest of the branches. |
aoqi@0 | 280 | // these branches don't understand this token, so they will |
aoqi@0 | 281 | // try to move to a final state and send the token back to us, |
aoqi@0 | 282 | // which this object will ignore (because isJoining==true) |
aoqi@0 | 283 | // Otherwise branches will find an error. |
aoqi@0 | 284 | for( int i=0; i<_receivers.length; i++ ) |
aoqi@0 | 285 | if( _receivers[i]!=source ) |
aoqi@0 | 286 | _receivers[i].leaveAttribute(uri,local,qname); |
aoqi@0 | 287 | |
aoqi@0 | 288 | // revert to the parent |
aoqi@0 | 289 | _parent._source.replace(this,_parent); |
aoqi@0 | 290 | _parent.onChildCompleted(null,_cookie,true); |
aoqi@0 | 291 | // send this event to the parent |
aoqi@0 | 292 | _parent.leaveAttribute(uri,local,qname); |
aoqi@0 | 293 | } |
aoqi@0 | 294 | |
aoqi@0 | 295 | public void joinByText( NGCCEventReceiver source, |
aoqi@0 | 296 | String value ) throws SAXException { |
aoqi@0 | 297 | |
aoqi@0 | 298 | if(isJoining) return; // we are already in the process of joining. ignore. |
aoqi@0 | 299 | isJoining = true; |
aoqi@0 | 300 | |
aoqi@0 | 301 | // send special token to the rest of the branches. |
aoqi@0 | 302 | // these branches don't understand this token, so they will |
aoqi@0 | 303 | // try to move to a final state and send the token back to us, |
aoqi@0 | 304 | // which this object will ignore (because isJoining==true) |
aoqi@0 | 305 | // Otherwise branches will find an error. |
aoqi@0 | 306 | for( int i=0; i<_receivers.length; i++ ) |
aoqi@0 | 307 | if( _receivers[i]!=source ) |
aoqi@0 | 308 | _receivers[i].text(value); |
aoqi@0 | 309 | |
aoqi@0 | 310 | // revert to the parent |
aoqi@0 | 311 | _parent._source.replace(this,_parent); |
aoqi@0 | 312 | _parent.onChildCompleted(null,_cookie,true); |
aoqi@0 | 313 | // send this event to the parent |
aoqi@0 | 314 | _parent.text(value); |
aoqi@0 | 315 | } |
aoqi@0 | 316 | |
aoqi@0 | 317 | |
aoqi@0 | 318 | |
aoqi@0 | 319 | // |
aoqi@0 | 320 | // |
aoqi@0 | 321 | // event dispatching methods |
aoqi@0 | 322 | // |
aoqi@0 | 323 | // |
aoqi@0 | 324 | |
aoqi@0 | 325 | public void sendEnterAttribute( int threadId, |
aoqi@0 | 326 | String uri, String local, String qname) throws SAXException { |
aoqi@0 | 327 | |
aoqi@0 | 328 | _receivers[threadId].enterAttribute(uri,local,qname); |
aoqi@0 | 329 | } |
aoqi@0 | 330 | |
aoqi@0 | 331 | public void sendEnterElement( int threadId, |
aoqi@0 | 332 | String uri, String local, String qname, Attributes atts) throws SAXException { |
aoqi@0 | 333 | |
aoqi@0 | 334 | _receivers[threadId].enterElement(uri,local,qname,atts); |
aoqi@0 | 335 | } |
aoqi@0 | 336 | |
aoqi@0 | 337 | public void sendLeaveAttribute( int threadId, |
aoqi@0 | 338 | String uri, String local, String qname) throws SAXException { |
aoqi@0 | 339 | |
aoqi@0 | 340 | _receivers[threadId].leaveAttribute(uri,local,qname); |
aoqi@0 | 341 | } |
aoqi@0 | 342 | |
aoqi@0 | 343 | public void sendLeaveElement( int threadId, |
aoqi@0 | 344 | String uri, String local, String qname) throws SAXException { |
aoqi@0 | 345 | |
aoqi@0 | 346 | _receivers[threadId].leaveElement(uri,local,qname); |
aoqi@0 | 347 | } |
aoqi@0 | 348 | |
aoqi@0 | 349 | public void sendText(int threadId, String value) throws SAXException { |
aoqi@0 | 350 | _receivers[threadId].text(value); |
aoqi@0 | 351 | } |
aoqi@0 | 352 | |
aoqi@0 | 353 | } |