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) 2005, 2010, 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.txw2; |
aoqi@0 | 27 | |
aoqi@0 | 28 | import com.sun.xml.internal.txw2.annotation.XmlElement; |
aoqi@0 | 29 | import com.sun.xml.internal.txw2.output.XmlSerializer; |
aoqi@0 | 30 | |
aoqi@0 | 31 | import javax.xml.namespace.QName; |
aoqi@0 | 32 | |
aoqi@0 | 33 | /** |
aoqi@0 | 34 | * Defines common operations for all typed XML writers. |
aoqi@0 | 35 | * Root of all typed XML writer interfaces. |
aoqi@0 | 36 | * |
aoqi@0 | 37 | * <p> |
aoqi@0 | 38 | * This interface defines a series of methods to allow client applications |
aoqi@0 | 39 | * to write arbitrary well-formed documents. |
aoqi@0 | 40 | * |
aoqi@0 | 41 | * @author Kohsuke Kawaguchi |
aoqi@0 | 42 | */ |
aoqi@0 | 43 | public interface TypedXmlWriter { |
aoqi@0 | 44 | /** |
aoqi@0 | 45 | * Commits this element (and all its descendants) to the output. |
aoqi@0 | 46 | * |
aoqi@0 | 47 | * <p> |
aoqi@0 | 48 | * Short for <tt>_commit(true)</tt>. |
aoqi@0 | 49 | */ |
aoqi@0 | 50 | void commit(); |
aoqi@0 | 51 | |
aoqi@0 | 52 | /** |
aoqi@0 | 53 | * Commits this element (and all its descendants) to the output. |
aoqi@0 | 54 | * |
aoqi@0 | 55 | * <p> |
aoqi@0 | 56 | * Once a writer is committed, nothing can be added to it further. |
aoqi@0 | 57 | * Committing allows TXW to output a part of the document even |
aoqi@0 | 58 | * if the rest has not yet been written. |
aoqi@0 | 59 | * |
aoqi@0 | 60 | * @param includingAllPredecessors |
aoqi@0 | 61 | * if false, this operation will _commit this writer and all its |
aoqi@0 | 62 | * descendants writers. If true, in addition to those writers, |
aoqi@0 | 63 | * this operation will close all the writers before this writer |
aoqi@0 | 64 | * in the document order. |
aoqi@0 | 65 | */ |
aoqi@0 | 66 | void commit(boolean includingAllPredecessors); |
aoqi@0 | 67 | |
aoqi@0 | 68 | /** |
aoqi@0 | 69 | * Blocks the writing of the start tag so that |
aoqi@0 | 70 | * new attributes can be added even after child |
aoqi@0 | 71 | * elements are appended. |
aoqi@0 | 72 | * |
aoqi@0 | 73 | * <p> |
aoqi@0 | 74 | * This blocks the output at the token before the start tag until |
aoqi@0 | 75 | * the {@link #commit()} method is called to _commit this element. |
aoqi@0 | 76 | * |
aoqi@0 | 77 | * <p> |
aoqi@0 | 78 | * For more information, see the TXW documentation. |
aoqi@0 | 79 | */ |
aoqi@0 | 80 | void block(); |
aoqi@0 | 81 | |
aoqi@0 | 82 | /** |
aoqi@0 | 83 | * Gets the {@link Document} object that this writer is writing to. |
aoqi@0 | 84 | * |
aoqi@0 | 85 | * @return |
aoqi@0 | 86 | * always non-null. |
aoqi@0 | 87 | */ |
aoqi@0 | 88 | Document getDocument(); |
aoqi@0 | 89 | |
aoqi@0 | 90 | /** |
aoqi@0 | 91 | * Adds an attribute of the given name and the value. |
aoqi@0 | 92 | * |
aoqi@0 | 93 | * <p> |
aoqi@0 | 94 | * Short for <pre>_attribute("",localName,value);</pre> |
aoqi@0 | 95 | * |
aoqi@0 | 96 | * @see #_attribute(String, String, Object) |
aoqi@0 | 97 | */ |
aoqi@0 | 98 | void _attribute( String localName, Object value ); |
aoqi@0 | 99 | |
aoqi@0 | 100 | /** |
aoqi@0 | 101 | * Adds an attribute of the given name and the value. |
aoqi@0 | 102 | * |
aoqi@0 | 103 | * <p> |
aoqi@0 | 104 | * Short for <pre>_attribute(new QName(nsUri,localName),value);</pre> |
aoqi@0 | 105 | * |
aoqi@0 | 106 | * @see #_attribute(QName, Object) |
aoqi@0 | 107 | */ |
aoqi@0 | 108 | void _attribute( String nsUri, String localName, Object value ); |
aoqi@0 | 109 | |
aoqi@0 | 110 | /** |
aoqi@0 | 111 | * Adds an attribute of the given name and the value. |
aoqi@0 | 112 | * |
aoqi@0 | 113 | * @param attributeName |
aoqi@0 | 114 | * must not be null. |
aoqi@0 | 115 | * @param value |
aoqi@0 | 116 | * value of the attribute. |
aoqi@0 | 117 | * must not be null. |
aoqi@0 | 118 | * See the documentation for the conversion rules. |
aoqi@0 | 119 | */ |
aoqi@0 | 120 | void _attribute( QName attributeName, Object value ); |
aoqi@0 | 121 | |
aoqi@0 | 122 | /** |
aoqi@0 | 123 | * Declares a new namespace URI on this element. |
aoqi@0 | 124 | * |
aoqi@0 | 125 | * <p> |
aoqi@0 | 126 | * The runtime system will assign an unique prefix for the URI. |
aoqi@0 | 127 | * |
aoqi@0 | 128 | * @param uri |
aoqi@0 | 129 | * can be empty, but must not be null. |
aoqi@0 | 130 | */ |
aoqi@0 | 131 | void _namespace( String uri ); |
aoqi@0 | 132 | |
aoqi@0 | 133 | /** |
aoqi@0 | 134 | * Declares a new namespace URI on this element to |
aoqi@0 | 135 | * a specific prefix. |
aoqi@0 | 136 | * |
aoqi@0 | 137 | * @param uri |
aoqi@0 | 138 | * can be empty, but must not be null. |
aoqi@0 | 139 | * @param prefix |
aoqi@0 | 140 | * If non-empty, this prefix is bound to the URI |
aoqi@0 | 141 | * on this element. If empty, then the runtime will still try to |
aoqi@0 | 142 | * use the URI as the default namespace, but it may fail to do so |
aoqi@0 | 143 | * because of the constraints in the XML. |
aoqi@0 | 144 | * |
aoqi@0 | 145 | * @throws IllegalArgumentException |
aoqi@0 | 146 | * if the same prefix is already declared on this element. |
aoqi@0 | 147 | */ |
aoqi@0 | 148 | void _namespace( String uri, String prefix ); |
aoqi@0 | 149 | |
aoqi@0 | 150 | /** |
aoqi@0 | 151 | * Declares a new namespace URI on this element. |
aoqi@0 | 152 | * |
aoqi@0 | 153 | * <p> |
aoqi@0 | 154 | * The runtime system will assign an unique prefix for the URI. |
aoqi@0 | 155 | * |
aoqi@0 | 156 | * @param uri |
aoqi@0 | 157 | * can be empty, but must not be null. |
aoqi@0 | 158 | * @param requirePrefix |
aoqi@0 | 159 | * if false, this method behaves just like {@link #_namespace(String)}. |
aoqi@0 | 160 | * if true, this guarantees that the URI is bound to a non empty prefix. |
aoqi@0 | 161 | */ |
aoqi@0 | 162 | void _namespace( String uri, boolean requirePrefix ); |
aoqi@0 | 163 | |
aoqi@0 | 164 | /** |
aoqi@0 | 165 | * Appends text data. |
aoqi@0 | 166 | * |
aoqi@0 | 167 | * @param value |
aoqi@0 | 168 | * must not be null. |
aoqi@0 | 169 | * See the documentation for the conversion rules. |
aoqi@0 | 170 | */ |
aoqi@0 | 171 | void _pcdata( Object value ); |
aoqi@0 | 172 | |
aoqi@0 | 173 | /** |
aoqi@0 | 174 | * Appends CDATA section. |
aoqi@0 | 175 | * |
aoqi@0 | 176 | * @param value |
aoqi@0 | 177 | * must not be null. |
aoqi@0 | 178 | * See the documentation for the conversion rules. |
aoqi@0 | 179 | */ |
aoqi@0 | 180 | void _cdata( Object value ); |
aoqi@0 | 181 | |
aoqi@0 | 182 | /** |
aoqi@0 | 183 | * Appends a comment. |
aoqi@0 | 184 | * |
aoqi@0 | 185 | * @param value |
aoqi@0 | 186 | * must not be null. |
aoqi@0 | 187 | * See the documentation for the conversion rules. |
aoqi@0 | 188 | * |
aoqi@0 | 189 | * @throws UnsupportedOperationException |
aoqi@0 | 190 | * if the underlying {@link XmlSerializer} does not support |
aoqi@0 | 191 | * writing comments, this exception can be thrown. |
aoqi@0 | 192 | */ |
aoqi@0 | 193 | void _comment( Object value ) throws UnsupportedOperationException; |
aoqi@0 | 194 | |
aoqi@0 | 195 | /** |
aoqi@0 | 196 | * Appends a new child element. |
aoqi@0 | 197 | * |
aoqi@0 | 198 | * <p> |
aoqi@0 | 199 | * Short for <pre>_element(<i>URI of this element</i>,localName,contentModel);</pre> |
aoqi@0 | 200 | * |
aoqi@0 | 201 | * <p> |
aoqi@0 | 202 | * The namespace URI will be inherited from the parent element. |
aoqi@0 | 203 | * |
aoqi@0 | 204 | * @see #_element(String, String, Class) |
aoqi@0 | 205 | */ |
aoqi@0 | 206 | <T extends TypedXmlWriter> T _element( String localName, Class<T> contentModel ); |
aoqi@0 | 207 | |
aoqi@0 | 208 | /** |
aoqi@0 | 209 | * Appends a new child element. |
aoqi@0 | 210 | * |
aoqi@0 | 211 | * <p> |
aoqi@0 | 212 | * The newly created child element is appended at the end of the children. |
aoqi@0 | 213 | * |
aoqi@0 | 214 | * @param nsUri |
aoqi@0 | 215 | * The namespace URI of the newly created element. |
aoqi@0 | 216 | * @param localName |
aoqi@0 | 217 | * The local name of the newly created element. |
aoqi@0 | 218 | * @param contentModel |
aoqi@0 | 219 | * The typed XML writer interface used to write the children of |
aoqi@0 | 220 | * the new child element. |
aoqi@0 | 221 | * |
aoqi@0 | 222 | * @return |
aoqi@0 | 223 | * always return non-null {@link TypedXmlWriter} that can be used |
aoqi@0 | 224 | * to write the contents of the newly created child element. |
aoqi@0 | 225 | */ |
aoqi@0 | 226 | <T extends TypedXmlWriter> T _element( String nsUri, String localName, Class<T> contentModel ); |
aoqi@0 | 227 | |
aoqi@0 | 228 | /** |
aoqi@0 | 229 | * Appends a new child element. |
aoqi@0 | 230 | * |
aoqi@0 | 231 | * <p> |
aoqi@0 | 232 | * Short for <pre>_element(tagName.getNamespaceURI(),tagName.getLocalPart(),contentModel);</pre> |
aoqi@0 | 233 | * |
aoqi@0 | 234 | * @see #_element(String, String, Class) |
aoqi@0 | 235 | */ |
aoqi@0 | 236 | <T extends TypedXmlWriter> T _element( QName tagName, Class<T> contentModel ); |
aoqi@0 | 237 | |
aoqi@0 | 238 | /** |
aoqi@0 | 239 | * Appends a new child element. |
aoqi@0 | 240 | * |
aoqi@0 | 241 | * <p> |
aoqi@0 | 242 | * This version of the _element method requires the <i>T</i> class to be |
aoqi@0 | 243 | * annotated with {@link XmlElement} annotation. The element name will be |
aoqi@0 | 244 | * taken from there. |
aoqi@0 | 245 | * |
aoqi@0 | 246 | * @see #_element(String, String, Class) |
aoqi@0 | 247 | */ |
aoqi@0 | 248 | <T extends TypedXmlWriter> T _element( Class<T> contentModel ); |
aoqi@0 | 249 | |
aoqi@0 | 250 | /** |
aoqi@0 | 251 | * Returns a different interface for this typed XML Writer. |
aoqi@0 | 252 | * |
aoqi@0 | 253 | * <p> |
aoqi@0 | 254 | * Semantically, this operation is a 'cast' --- it returns the same underlying |
aoqi@0 | 255 | * writer in a different interface. The returned new writer and the current writer |
aoqi@0 | 256 | * will write to the same element. |
aoqi@0 | 257 | * |
aoqi@0 | 258 | * <p> |
aoqi@0 | 259 | * But this is different from Java's ordinary cast because the returned object |
aoqi@0 | 260 | * is not always the same as the current object. |
aoqi@0 | 261 | * |
aoqi@0 | 262 | * @return |
aoqi@0 | 263 | * always return non-null. |
aoqi@0 | 264 | */ |
aoqi@0 | 265 | <T extends TypedXmlWriter> T _cast( Class<T> targetInterface ); |
aoqi@0 | 266 | } |