src/share/jaxws_classes/com/sun/xml/internal/dtdparser/DTDEventListener.java

Thu, 31 Aug 2017 15:18:52 +0800

author
aoqi
date
Thu, 31 Aug 2017 15:18:52 +0800
changeset 637
9c07ef4934dd
parent 397
b99d7e355d4b
parent 0
373ffda63c9a
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2009, 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.xml.internal.dtdparser;
aoqi@0 27
aoqi@0 28 import org.xml.sax.Locator;
aoqi@0 29 import org.xml.sax.SAXException;
aoqi@0 30 import org.xml.sax.SAXParseException;
aoqi@0 31
aoqi@0 32 import java.util.EventListener;
aoqi@0 33
aoqi@0 34 /**
aoqi@0 35 * All DTD parsing events are signaled through this interface.
aoqi@0 36 */
aoqi@0 37 public interface DTDEventListener extends EventListener {
aoqi@0 38
aoqi@0 39 public void setDocumentLocator(Locator loc);
aoqi@0 40
aoqi@0 41 /**
aoqi@0 42 * Receive notification of a Processing Instruction.
aoqi@0 43 * Processing instructions contain information meaningful
aoqi@0 44 * to the application.
aoqi@0 45 *
aoqi@0 46 * @param target The target of the proceessing instruction
aoqi@0 47 * which should have meaning to the application.
aoqi@0 48 * @param data The instruction itself which should contain
aoqi@0 49 * valid XML characters.
aoqi@0 50 * @throws SAXException
aoqi@0 51 */
aoqi@0 52 public void processingInstruction(String target, String data)
aoqi@0 53 throws SAXException;
aoqi@0 54
aoqi@0 55 /**
aoqi@0 56 * Receive notification of a Notation Declaration.
aoqi@0 57 * Notation declarations are used by elements and entities
aoqi@0 58 * for identifying embedded non-XML data.
aoqi@0 59 *
aoqi@0 60 * @param name The notation name, referred to by entities and
aoqi@0 61 * elements.
aoqi@0 62 * @param publicId The public identifier
aoqi@0 63 * @param systemId The system identifier
aoqi@0 64 */
aoqi@0 65 public void notationDecl(String name, String publicId, String systemId)
aoqi@0 66 throws SAXException;
aoqi@0 67
aoqi@0 68 /**
aoqi@0 69 * Receive notification of an unparsed entity declaration.
aoqi@0 70 * Unparsed entities are non-XML data.
aoqi@0 71 *
aoqi@0 72 * @param name The name of the unparsed entity.
aoqi@0 73 * @param publicId The public identifier
aoqi@0 74 * @param systemId The system identifier
aoqi@0 75 * @param notationName The associated notation
aoqi@0 76 */
aoqi@0 77 public void unparsedEntityDecl(String name, String publicId,
aoqi@0 78 String systemId, String notationName)
aoqi@0 79 throws SAXException;
aoqi@0 80
aoqi@0 81 /**
aoqi@0 82 * Receive notification of a internal general entity declaration event.
aoqi@0 83 *
aoqi@0 84 * @param name The internal general entity name.
aoqi@0 85 * @param value The value of the entity, which may include unexpanded
aoqi@0 86 * entity references. Character references will have been
aoqi@0 87 * expanded.
aoqi@0 88 * @throws SAXException
aoqi@0 89 * @see #externalGeneralEntityDecl(String, String, String)
aoqi@0 90 */
aoqi@0 91 public void internalGeneralEntityDecl(String name, String value)
aoqi@0 92 throws SAXException;
aoqi@0 93
aoqi@0 94 /**
aoqi@0 95 * Receive notification of an external parsed general entity
aoqi@0 96 * declaration event.
aoqi@0 97 * <p/>
aoqi@0 98 * <p>If a system identifier is present, and it is a relative URL, the
aoqi@0 99 * parser will have resolved it fully before passing it through this
aoqi@0 100 * method to a listener.</p>
aoqi@0 101 *
aoqi@0 102 * @param name The entity name.
aoqi@0 103 * @param publicId The entity's public identifier, or null if
aoqi@0 104 * none was given.
aoqi@0 105 * @param systemId The entity's system identifier.
aoqi@0 106 * @throws SAXException
aoqi@0 107 * @see #unparsedEntityDecl(String, String, String, String)
aoqi@0 108 */
aoqi@0 109 public void externalGeneralEntityDecl(String name, String publicId,
aoqi@0 110 String systemId)
aoqi@0 111 throws SAXException;
aoqi@0 112
aoqi@0 113 /**
aoqi@0 114 * Receive notification of a internal parameter entity declaration
aoqi@0 115 * event.
aoqi@0 116 *
aoqi@0 117 * @param name The internal parameter entity name.
aoqi@0 118 * @param value The value of the entity, which may include unexpanded
aoqi@0 119 * entity references. Character references will have been
aoqi@0 120 * expanded.
aoqi@0 121 * @throws SAXException
aoqi@0 122 * @see #externalParameterEntityDecl(String, String, String)
aoqi@0 123 */
aoqi@0 124 public void internalParameterEntityDecl(String name, String value)
aoqi@0 125 throws SAXException;
aoqi@0 126
aoqi@0 127 /**
aoqi@0 128 * Receive notification of an external parameter entity declaration
aoqi@0 129 * event.
aoqi@0 130 * <p/>
aoqi@0 131 * <p>If a system identifier is present, and it is a relative URL, the
aoqi@0 132 * parser will have resolved it fully before passing it through this
aoqi@0 133 * method to a listener.</p>
aoqi@0 134 *
aoqi@0 135 * @param name The parameter entity name.
aoqi@0 136 * @param publicId The entity's public identifier, or null if
aoqi@0 137 * none was given.
aoqi@0 138 * @param systemId The entity's system identifier.
aoqi@0 139 * @throws SAXException
aoqi@0 140 * @see #unparsedEntityDecl(String, String, String, String)
aoqi@0 141 */
aoqi@0 142 public void externalParameterEntityDecl(String name, String publicId,
aoqi@0 143 String systemId)
aoqi@0 144 throws SAXException;
aoqi@0 145
aoqi@0 146 /**
aoqi@0 147 * Receive notification of the beginning of the DTD.
aoqi@0 148 *
aoqi@0 149 * @param in Current input entity.
aoqi@0 150 * @see #endDTD()
aoqi@0 151 */
aoqi@0 152 public void startDTD(InputEntity in)
aoqi@0 153 throws SAXException;
aoqi@0 154
aoqi@0 155 /**
aoqi@0 156 * Receive notification of the end of a DTD. The parser will invoke
aoqi@0 157 * this method only once.
aoqi@0 158 *
aoqi@0 159 * @throws SAXException
aoqi@0 160 * @see #startDTD(InputEntity)
aoqi@0 161 */
aoqi@0 162 public void endDTD()
aoqi@0 163 throws SAXException;
aoqi@0 164
aoqi@0 165 /**
aoqi@0 166 * Receive notification that a comment has been read.
aoqi@0 167 * <p/>
aoqi@0 168 * <P> Note that processing instructions are the mechanism designed
aoqi@0 169 * to hold information for consumption by applications, not comments.
aoqi@0 170 * XML systems may rely on applications being able to access information
aoqi@0 171 * found in processing instructions; this is not true of comments, which
aoqi@0 172 * are typically discarded.
aoqi@0 173 *
aoqi@0 174 * @param text the text within the comment delimiters.
aoqi@0 175 * @throws SAXException
aoqi@0 176 */
aoqi@0 177 public void comment(String text)
aoqi@0 178 throws SAXException;
aoqi@0 179
aoqi@0 180 /**
aoqi@0 181 * Receive notification of character data.
aoqi@0 182 * <p/>
aoqi@0 183 * <p>The Parser will call this method to report each chunk of
aoqi@0 184 * character data. SAX parsers may return all contiguous character
aoqi@0 185 * data in a single chunk, or they may split it into several
aoqi@0 186 * chunks; however, all of the characters in any single event
aoqi@0 187 * must come from the same external entity, so that the Locator
aoqi@0 188 * provides useful information.</p>
aoqi@0 189 * <p/>
aoqi@0 190 * <p>The application must not attempt to read from the array
aoqi@0 191 * outside of the specified range.</p>
aoqi@0 192 * <p/>
aoqi@0 193 * <p>Note that some parsers will report whitespace using the
aoqi@0 194 * ignorableWhitespace() method rather than this one (validating
aoqi@0 195 * parsers must do so).</p>
aoqi@0 196 *
aoqi@0 197 * @param ch The characters from the DTD.
aoqi@0 198 * @param start The start position in the array.
aoqi@0 199 * @param length The number of characters to read from the array.
aoqi@0 200 * @throws SAXException
aoqi@0 201 * @see #ignorableWhitespace(char[], int, int)
aoqi@0 202 */
aoqi@0 203 public void characters(char ch[], int start, int length)
aoqi@0 204 throws SAXException;
aoqi@0 205
aoqi@0 206
aoqi@0 207 /**
aoqi@0 208 * Receive notification of ignorable whitespace in element content.
aoqi@0 209 * <p/>
aoqi@0 210 * <p>Validating Parsers must use this method to report each chunk
aoqi@0 211 * of ignorable whitespace (see the W3C XML 1.0 recommendation,
aoqi@0 212 * section 2.10): non-validating parsers may also use this method
aoqi@0 213 * if they are capable of parsing and using content models.</p>
aoqi@0 214 * <p/>
aoqi@0 215 * <p>SAX parsers may return all contiguous whitespace in a single
aoqi@0 216 * chunk, or they may split it into several chunks; however, all of
aoqi@0 217 * the characters in any single event must come from the same
aoqi@0 218 * external entity, so that the Locator provides useful
aoqi@0 219 * information.</p>
aoqi@0 220 * <p/>
aoqi@0 221 * <p>The application must not attempt to read from the array
aoqi@0 222 * outside of the specified range.</p>
aoqi@0 223 *
aoqi@0 224 * @param ch The characters from the DTD.
aoqi@0 225 * @param start The start position in the array.
aoqi@0 226 * @param length The number of characters to read from the array.
aoqi@0 227 * @throws SAXException
aoqi@0 228 * @see #characters(char[], int, int)
aoqi@0 229 */
aoqi@0 230 public void ignorableWhitespace(char ch[], int start, int length)
aoqi@0 231 throws SAXException;
aoqi@0 232
aoqi@0 233 /**
aoqi@0 234 * Receive notification that a CDATA section is beginning. Data in a
aoqi@0 235 * CDATA section is is reported through the appropriate event, either
aoqi@0 236 * <em>characters()</em> or <em>ignorableWhitespace</em>.
aoqi@0 237 *
aoqi@0 238 * @throws SAXException
aoqi@0 239 * @see #endCDATA()
aoqi@0 240 */
aoqi@0 241 public void startCDATA() throws SAXException;
aoqi@0 242
aoqi@0 243
aoqi@0 244 /**
aoqi@0 245 * Receive notification that the CDATA section finished.
aoqi@0 246 *
aoqi@0 247 * @throws SAXException
aoqi@0 248 * @see #startCDATA()
aoqi@0 249 */
aoqi@0 250 public void endCDATA() throws SAXException;
aoqi@0 251
aoqi@0 252
aoqi@0 253 public void fatalError(SAXParseException e)
aoqi@0 254 throws SAXException;
aoqi@0 255
aoqi@0 256 public void error(SAXParseException e) throws SAXException;
aoqi@0 257
aoqi@0 258 public void warning(SAXParseException err) throws SAXException;
aoqi@0 259
aoqi@0 260 public final short CONTENT_MODEL_EMPTY = 0;
aoqi@0 261 public final short CONTENT_MODEL_ANY = 1;
aoqi@0 262 public final short CONTENT_MODEL_MIXED = 2;
aoqi@0 263 public final short CONTENT_MODEL_CHILDREN = 3;
aoqi@0 264
aoqi@0 265 /**
aoqi@0 266 * receives notification that parsing of content model is beginning.
aoqi@0 267 *
aoqi@0 268 * @param elementName name of the element whose content model is going to be defined.
aoqi@0 269 * @param contentModelType {@link #CONTENT_MODEL_EMPTY}
aoqi@0 270 * this element has EMPTY content model. This notification
aoqi@0 271 * will be immediately followed by the corresponding endContentModel.
aoqi@0 272 * {@link #CONTENT_MODEL_ANY}
aoqi@0 273 * this element has ANY content model. This notification
aoqi@0 274 * will be immediately followed by the corresponding endContentModel.
aoqi@0 275 * {@link #CONTENT_MODEL_MIXED}
aoqi@0 276 * this element has mixed content model. #PCDATA will not be reported.
aoqi@0 277 * each child element will be reported by mixedElement method.
aoqi@0 278 * {@link #CONTENT_MODEL_CHILDREN}
aoqi@0 279 * this elemen has child content model. The actual content model will
aoqi@0 280 * be reported by childElement, startModelGroup, endModelGroup, and
aoqi@0 281 * connector methods. Possible call sequences are:
aoqi@0 282 * <p/>
aoqi@0 283 * START := MODEL_GROUP
aoqi@0 284 * MODEL_GROUP := startModelGroup TOKEN (connector TOKEN)* endModelGroup
aoqi@0 285 * TOKEN := childElement
aoqi@0 286 * | MODEL_GROUP
aoqi@0 287 */
aoqi@0 288 public void startContentModel(String elementName, short contentModelType) throws SAXException;
aoqi@0 289
aoqi@0 290 /**
aoqi@0 291 * receives notification that parsing of content model is finished.
aoqi@0 292 */
aoqi@0 293 public void endContentModel(String elementName, short contentModelType) throws SAXException;
aoqi@0 294
aoqi@0 295 public final short USE_NORMAL = 0;
aoqi@0 296 public final short USE_IMPLIED = 1;
aoqi@0 297 public final short USE_FIXED = 2;
aoqi@0 298 public final short USE_REQUIRED = 3;
aoqi@0 299
aoqi@0 300 /**
aoqi@0 301 * For each entry in an ATTLIST declaration,
aoqi@0 302 * this event will be fired.
aoqi@0 303 * <p/>
aoqi@0 304 * <p/>
aoqi@0 305 * DTD allows the same attributes to be declared more than
aoqi@0 306 * once, and in that case the first one wins. I think
aoqi@0 307 * this method will be only fired for the first one,
aoqi@0 308 * but I need to check.
aoqi@0 309 */
aoqi@0 310 public void attributeDecl(String elementName, String attributeName, String attributeType,
aoqi@0 311 String[] enumeration, short attributeUse, String defaultValue) throws SAXException;
aoqi@0 312
aoqi@0 313 public void childElement(String elementName, short occurence) throws SAXException;
aoqi@0 314
aoqi@0 315 /**
aoqi@0 316 * receives notification of child element of mixed content model.
aoqi@0 317 * this method is called for each child element.
aoqi@0 318 *
aoqi@0 319 * @see #startContentModel(String, short)
aoqi@0 320 */
aoqi@0 321 public void mixedElement(String elementName) throws SAXException;
aoqi@0 322
aoqi@0 323 public void startModelGroup() throws SAXException;
aoqi@0 324
aoqi@0 325 public void endModelGroup(short occurence) throws SAXException;
aoqi@0 326
aoqi@0 327 public final short CHOICE = 0;
aoqi@0 328 public final short SEQUENCE = 1;
aoqi@0 329
aoqi@0 330 /**
aoqi@0 331 * Connectors in one model group is guaranteed to be the same.
aoqi@0 332 * <p/>
aoqi@0 333 * <p/>
aoqi@0 334 * IOW, you'll never see an event sequence like (a|b,c)
aoqi@0 335 *
aoqi@0 336 * @return {@link #CHOICE} or {@link #SEQUENCE}.
aoqi@0 337 */
aoqi@0 338 public void connector(short connectorType) throws SAXException;
aoqi@0 339
aoqi@0 340 public final short OCCURENCE_ZERO_OR_MORE = 0;
aoqi@0 341 public final short OCCURENCE_ONE_OR_MORE = 1;
aoqi@0 342 public final short OCCURENCE_ZERO_OR_ONE = 2;
aoqi@0 343 public final short OCCURENCE_ONCE = 3;
aoqi@0 344 }

mercurial