1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/dtdparser/DTDEventListener.java Wed Apr 27 01:27:09 2016 +0800 1.3 @@ -0,0 +1,344 @@ 1.4 +/* 1.5 + * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Oracle designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Oracle in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 + * or visit www.oracle.com if you need additional information or have any 1.26 + * questions. 1.27 + */ 1.28 + 1.29 +package com.sun.xml.internal.dtdparser; 1.30 + 1.31 +import org.xml.sax.Locator; 1.32 +import org.xml.sax.SAXException; 1.33 +import org.xml.sax.SAXParseException; 1.34 + 1.35 +import java.util.EventListener; 1.36 + 1.37 +/** 1.38 + * All DTD parsing events are signaled through this interface. 1.39 + */ 1.40 +public interface DTDEventListener extends EventListener { 1.41 + 1.42 + public void setDocumentLocator(Locator loc); 1.43 + 1.44 + /** 1.45 + * Receive notification of a Processing Instruction. 1.46 + * Processing instructions contain information meaningful 1.47 + * to the application. 1.48 + * 1.49 + * @param target The target of the proceessing instruction 1.50 + * which should have meaning to the application. 1.51 + * @param data The instruction itself which should contain 1.52 + * valid XML characters. 1.53 + * @throws SAXException 1.54 + */ 1.55 + public void processingInstruction(String target, String data) 1.56 + throws SAXException; 1.57 + 1.58 + /** 1.59 + * Receive notification of a Notation Declaration. 1.60 + * Notation declarations are used by elements and entities 1.61 + * for identifying embedded non-XML data. 1.62 + * 1.63 + * @param name The notation name, referred to by entities and 1.64 + * elements. 1.65 + * @param publicId The public identifier 1.66 + * @param systemId The system identifier 1.67 + */ 1.68 + public void notationDecl(String name, String publicId, String systemId) 1.69 + throws SAXException; 1.70 + 1.71 + /** 1.72 + * Receive notification of an unparsed entity declaration. 1.73 + * Unparsed entities are non-XML data. 1.74 + * 1.75 + * @param name The name of the unparsed entity. 1.76 + * @param publicId The public identifier 1.77 + * @param systemId The system identifier 1.78 + * @param notationName The associated notation 1.79 + */ 1.80 + public void unparsedEntityDecl(String name, String publicId, 1.81 + String systemId, String notationName) 1.82 + throws SAXException; 1.83 + 1.84 + /** 1.85 + * Receive notification of a internal general entity declaration event. 1.86 + * 1.87 + * @param name The internal general entity name. 1.88 + * @param value The value of the entity, which may include unexpanded 1.89 + * entity references. Character references will have been 1.90 + * expanded. 1.91 + * @throws SAXException 1.92 + * @see #externalGeneralEntityDecl(String, String, String) 1.93 + */ 1.94 + public void internalGeneralEntityDecl(String name, String value) 1.95 + throws SAXException; 1.96 + 1.97 + /** 1.98 + * Receive notification of an external parsed general entity 1.99 + * declaration event. 1.100 + * <p/> 1.101 + * <p>If a system identifier is present, and it is a relative URL, the 1.102 + * parser will have resolved it fully before passing it through this 1.103 + * method to a listener.</p> 1.104 + * 1.105 + * @param name The entity name. 1.106 + * @param publicId The entity's public identifier, or null if 1.107 + * none was given. 1.108 + * @param systemId The entity's system identifier. 1.109 + * @throws SAXException 1.110 + * @see #unparsedEntityDecl(String, String, String, String) 1.111 + */ 1.112 + public void externalGeneralEntityDecl(String name, String publicId, 1.113 + String systemId) 1.114 + throws SAXException; 1.115 + 1.116 + /** 1.117 + * Receive notification of a internal parameter entity declaration 1.118 + * event. 1.119 + * 1.120 + * @param name The internal parameter entity name. 1.121 + * @param value The value of the entity, which may include unexpanded 1.122 + * entity references. Character references will have been 1.123 + * expanded. 1.124 + * @throws SAXException 1.125 + * @see #externalParameterEntityDecl(String, String, String) 1.126 + */ 1.127 + public void internalParameterEntityDecl(String name, String value) 1.128 + throws SAXException; 1.129 + 1.130 + /** 1.131 + * Receive notification of an external parameter entity declaration 1.132 + * event. 1.133 + * <p/> 1.134 + * <p>If a system identifier is present, and it is a relative URL, the 1.135 + * parser will have resolved it fully before passing it through this 1.136 + * method to a listener.</p> 1.137 + * 1.138 + * @param name The parameter entity name. 1.139 + * @param publicId The entity's public identifier, or null if 1.140 + * none was given. 1.141 + * @param systemId The entity's system identifier. 1.142 + * @throws SAXException 1.143 + * @see #unparsedEntityDecl(String, String, String, String) 1.144 + */ 1.145 + public void externalParameterEntityDecl(String name, String publicId, 1.146 + String systemId) 1.147 + throws SAXException; 1.148 + 1.149 + /** 1.150 + * Receive notification of the beginning of the DTD. 1.151 + * 1.152 + * @param in Current input entity. 1.153 + * @see #endDTD() 1.154 + */ 1.155 + public void startDTD(InputEntity in) 1.156 + throws SAXException; 1.157 + 1.158 + /** 1.159 + * Receive notification of the end of a DTD. The parser will invoke 1.160 + * this method only once. 1.161 + * 1.162 + * @throws SAXException 1.163 + * @see #startDTD(InputEntity) 1.164 + */ 1.165 + public void endDTD() 1.166 + throws SAXException; 1.167 + 1.168 + /** 1.169 + * Receive notification that a comment has been read. 1.170 + * <p/> 1.171 + * <P> Note that processing instructions are the mechanism designed 1.172 + * to hold information for consumption by applications, not comments. 1.173 + * XML systems may rely on applications being able to access information 1.174 + * found in processing instructions; this is not true of comments, which 1.175 + * are typically discarded. 1.176 + * 1.177 + * @param text the text within the comment delimiters. 1.178 + * @throws SAXException 1.179 + */ 1.180 + public void comment(String text) 1.181 + throws SAXException; 1.182 + 1.183 + /** 1.184 + * Receive notification of character data. 1.185 + * <p/> 1.186 + * <p>The Parser will call this method to report each chunk of 1.187 + * character data. SAX parsers may return all contiguous character 1.188 + * data in a single chunk, or they may split it into several 1.189 + * chunks; however, all of the characters in any single event 1.190 + * must come from the same external entity, so that the Locator 1.191 + * provides useful information.</p> 1.192 + * <p/> 1.193 + * <p>The application must not attempt to read from the array 1.194 + * outside of the specified range.</p> 1.195 + * <p/> 1.196 + * <p>Note that some parsers will report whitespace using the 1.197 + * ignorableWhitespace() method rather than this one (validating 1.198 + * parsers must do so).</p> 1.199 + * 1.200 + * @param ch The characters from the DTD. 1.201 + * @param start The start position in the array. 1.202 + * @param length The number of characters to read from the array. 1.203 + * @throws SAXException 1.204 + * @see #ignorableWhitespace(char[], int, int) 1.205 + */ 1.206 + public void characters(char ch[], int start, int length) 1.207 + throws SAXException; 1.208 + 1.209 + 1.210 + /** 1.211 + * Receive notification of ignorable whitespace in element content. 1.212 + * <p/> 1.213 + * <p>Validating Parsers must use this method to report each chunk 1.214 + * of ignorable whitespace (see the W3C XML 1.0 recommendation, 1.215 + * section 2.10): non-validating parsers may also use this method 1.216 + * if they are capable of parsing and using content models.</p> 1.217 + * <p/> 1.218 + * <p>SAX parsers may return all contiguous whitespace in a single 1.219 + * chunk, or they may split it into several chunks; however, all of 1.220 + * the characters in any single event must come from the same 1.221 + * external entity, so that the Locator provides useful 1.222 + * information.</p> 1.223 + * <p/> 1.224 + * <p>The application must not attempt to read from the array 1.225 + * outside of the specified range.</p> 1.226 + * 1.227 + * @param ch The characters from the DTD. 1.228 + * @param start The start position in the array. 1.229 + * @param length The number of characters to read from the array. 1.230 + * @throws SAXException 1.231 + * @see #characters(char[], int, int) 1.232 + */ 1.233 + public void ignorableWhitespace(char ch[], int start, int length) 1.234 + throws SAXException; 1.235 + 1.236 + /** 1.237 + * Receive notification that a CDATA section is beginning. Data in a 1.238 + * CDATA section is is reported through the appropriate event, either 1.239 + * <em>characters()</em> or <em>ignorableWhitespace</em>. 1.240 + * 1.241 + * @throws SAXException 1.242 + * @see #endCDATA() 1.243 + */ 1.244 + public void startCDATA() throws SAXException; 1.245 + 1.246 + 1.247 + /** 1.248 + * Receive notification that the CDATA section finished. 1.249 + * 1.250 + * @throws SAXException 1.251 + * @see #startCDATA() 1.252 + */ 1.253 + public void endCDATA() throws SAXException; 1.254 + 1.255 + 1.256 + public void fatalError(SAXParseException e) 1.257 + throws SAXException; 1.258 + 1.259 + public void error(SAXParseException e) throws SAXException; 1.260 + 1.261 + public void warning(SAXParseException err) throws SAXException; 1.262 + 1.263 + public final short CONTENT_MODEL_EMPTY = 0; 1.264 + public final short CONTENT_MODEL_ANY = 1; 1.265 + public final short CONTENT_MODEL_MIXED = 2; 1.266 + public final short CONTENT_MODEL_CHILDREN = 3; 1.267 + 1.268 + /** 1.269 + * receives notification that parsing of content model is beginning. 1.270 + * 1.271 + * @param elementName name of the element whose content model is going to be defined. 1.272 + * @param contentModelType {@link #CONTENT_MODEL_EMPTY} 1.273 + * this element has EMPTY content model. This notification 1.274 + * will be immediately followed by the corresponding endContentModel. 1.275 + * {@link #CONTENT_MODEL_ANY} 1.276 + * this element has ANY content model. This notification 1.277 + * will be immediately followed by the corresponding endContentModel. 1.278 + * {@link #CONTENT_MODEL_MIXED} 1.279 + * this element has mixed content model. #PCDATA will not be reported. 1.280 + * each child element will be reported by mixedElement method. 1.281 + * {@link #CONTENT_MODEL_CHILDREN} 1.282 + * this elemen has child content model. The actual content model will 1.283 + * be reported by childElement, startModelGroup, endModelGroup, and 1.284 + * connector methods. Possible call sequences are: 1.285 + * <p/> 1.286 + * START := MODEL_GROUP 1.287 + * MODEL_GROUP := startModelGroup TOKEN (connector TOKEN)* endModelGroup 1.288 + * TOKEN := childElement 1.289 + * | MODEL_GROUP 1.290 + */ 1.291 + public void startContentModel(String elementName, short contentModelType) throws SAXException; 1.292 + 1.293 + /** 1.294 + * receives notification that parsing of content model is finished. 1.295 + */ 1.296 + public void endContentModel(String elementName, short contentModelType) throws SAXException; 1.297 + 1.298 + public final short USE_NORMAL = 0; 1.299 + public final short USE_IMPLIED = 1; 1.300 + public final short USE_FIXED = 2; 1.301 + public final short USE_REQUIRED = 3; 1.302 + 1.303 + /** 1.304 + * For each entry in an ATTLIST declaration, 1.305 + * this event will be fired. 1.306 + * <p/> 1.307 + * <p/> 1.308 + * DTD allows the same attributes to be declared more than 1.309 + * once, and in that case the first one wins. I think 1.310 + * this method will be only fired for the first one, 1.311 + * but I need to check. 1.312 + */ 1.313 + public void attributeDecl(String elementName, String attributeName, String attributeType, 1.314 + String[] enumeration, short attributeUse, String defaultValue) throws SAXException; 1.315 + 1.316 + public void childElement(String elementName, short occurence) throws SAXException; 1.317 + 1.318 + /** 1.319 + * receives notification of child element of mixed content model. 1.320 + * this method is called for each child element. 1.321 + * 1.322 + * @see #startContentModel(String, short) 1.323 + */ 1.324 + public void mixedElement(String elementName) throws SAXException; 1.325 + 1.326 + public void startModelGroup() throws SAXException; 1.327 + 1.328 + public void endModelGroup(short occurence) throws SAXException; 1.329 + 1.330 + public final short CHOICE = 0; 1.331 + public final short SEQUENCE = 1; 1.332 + 1.333 + /** 1.334 + * Connectors in one model group is guaranteed to be the same. 1.335 + * <p/> 1.336 + * <p/> 1.337 + * IOW, you'll never see an event sequence like (a|b,c) 1.338 + * 1.339 + * @return {@link #CHOICE} or {@link #SEQUENCE}. 1.340 + */ 1.341 + public void connector(short connectorType) throws SAXException; 1.342 + 1.343 + public final short OCCURENCE_ZERO_OR_MORE = 0; 1.344 + public final short OCCURENCE_ONE_OR_MORE = 1; 1.345 + public final short OCCURENCE_ZERO_OR_ONE = 2; 1.346 + public final short OCCURENCE_ONCE = 3; 1.347 +}