Tue, 09 Apr 2013 14:51:13 +0100
8010393: Update JAX-WS RI to 2.2.9-b12941
Reviewed-by: alanb, erikj
Contributed-by: miroslav.kos@oracle.com, martin.grebac@oracle.com
ohair@286 | 1 | /* |
ohair@286 | 2 | * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
ohair@286 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ohair@286 | 4 | * |
ohair@286 | 5 | * This code is free software; you can redistribute it and/or modify it |
ohair@286 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ohair@286 | 7 | * published by the Free Software Foundation. Oracle designates this |
ohair@286 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohair@286 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
ohair@286 | 10 | * |
ohair@286 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
ohair@286 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ohair@286 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ohair@286 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
ohair@286 | 15 | * accompanied this code). |
ohair@286 | 16 | * |
ohair@286 | 17 | * You should have received a copy of the GNU General Public License version |
ohair@286 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
ohair@286 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ohair@286 | 20 | * |
ohair@286 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@286 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohair@286 | 23 | * questions. |
ohair@286 | 24 | */ |
ohair@286 | 25 | |
ohair@286 | 26 | package com.sun.xml.internal.org.jvnet.staxex; |
ohair@286 | 27 | |
ohair@286 | 28 | import javax.activation.DataHandler; |
ohair@286 | 29 | import javax.xml.stream.XMLStreamException; |
ohair@286 | 30 | import javax.xml.stream.XMLStreamWriter; |
ohair@286 | 31 | import java.io.OutputStream; |
ohair@286 | 32 | |
ohair@286 | 33 | /** |
ohair@286 | 34 | * {@link XMLStreamWriter} extended to support XOP. |
ohair@286 | 35 | * |
ohair@286 | 36 | * <p> |
ohair@286 | 37 | * Some infoset serializer (such as XOP encoder, FastInfoset) uses a format |
ohair@286 | 38 | * that can represent binary data more efficiently than base64 encoding. |
ohair@286 | 39 | * Such infoset serializer may choose to implement this interface, to allow |
ohair@286 | 40 | * the caller to pass in binary data more efficiently without first converting |
ohair@286 | 41 | * it to binary data. |
ohair@286 | 42 | * |
ohair@286 | 43 | * <p> |
ohair@286 | 44 | * Callers capable of using this interface can see if the serializer supports |
ohair@286 | 45 | * it by simply downcasting {@link XMLStreamWriter} to {@link XMLStreamWriterEx}. |
ohair@286 | 46 | * |
ohair@286 | 47 | * <h2>TODO</h2> |
ohair@286 | 48 | * <ol> |
ohair@286 | 49 | * <li> |
ohair@286 | 50 | * Add methods to write other primitive types, such as hex and integers |
ohair@286 | 51 | * (and arrays of). |
ohair@286 | 52 | * A textual implementation would write characters in accordance |
ohair@286 | 53 | * to the canonical lexical definitions specified in W3C XML Schema: datatypes. |
ohair@286 | 54 | * A MTOM implementation would write characters except for the case where octets |
ohair@286 | 55 | * that would otherwise be base64 encoded when using the textual implementation. |
ohair@286 | 56 | * A Fast Infoset implementation would encoded binary data the primitive types in |
ohair@286 | 57 | * binary form. |
ohair@286 | 58 | * <li> |
ohair@286 | 59 | * Consider renaming writeBinary to writeBytesAsBase64 to be consistent with |
ohair@286 | 60 | * infoset abstraction. |
ohair@286 | 61 | * <li> |
ohair@286 | 62 | * Add the ability to writeStart and writeEnd on attributes so that the same |
ohair@286 | 63 | * methods for writing primitive types (and characters, which will require new methods) |
ohair@286 | 64 | * can be used for writing attribute values as well as element content. |
ohair@286 | 65 | * </ol> |
ohair@286 | 66 | * |
ohair@286 | 67 | * @see XMLStreamReaderEx |
ohair@286 | 68 | * @author Kohsuke Kawaguchi |
ohair@286 | 69 | * @author Paul Sandoz |
ohair@286 | 70 | */ |
ohair@286 | 71 | public interface XMLStreamWriterEx extends XMLStreamWriter { |
ohair@286 | 72 | |
ohair@286 | 73 | /** |
ohair@286 | 74 | * Write the binary data. |
ohair@286 | 75 | * |
ohair@286 | 76 | * <p> |
ohair@286 | 77 | * Conceptually (infoset-wise), this produces the base64-encoded binary data on the |
ohair@286 | 78 | * output. But this allows implementations like FastInfoset or XOP to do the smart |
ohair@286 | 79 | * thing. |
ohair@286 | 80 | * |
ohair@286 | 81 | * <p> |
ohair@286 | 82 | * The use of this method has some restriction to support XOP. Namely, this method |
ohair@286 | 83 | * must be invoked as a sole content of an element. |
ohair@286 | 84 | * |
ohair@286 | 85 | * <p> |
ohair@286 | 86 | * (data,start,len) triplet identifies the binary data to be written. |
ohair@286 | 87 | * After the method invocation, the callee owns the buffer. |
ohair@286 | 88 | * |
ohair@286 | 89 | * @param contentType |
ohair@286 | 90 | * this mandatory parameter identifies the MIME type of the binary data. |
ohair@286 | 91 | * If the MIME type isn't known by the caller, "application/octet-stream" can |
ohair@286 | 92 | * be always used to indicate "I don't know." Never null. |
ohair@286 | 93 | */ |
ohair@286 | 94 | void writeBinary(byte[] data, int start, int len, String contentType) throws XMLStreamException; |
ohair@286 | 95 | |
ohair@286 | 96 | /** |
ohair@286 | 97 | * Writes the binary data. |
ohair@286 | 98 | * |
ohair@286 | 99 | * <p> |
ohair@286 | 100 | * This method works like the {@link #writeBinary(byte[], int, int, String)} method, |
ohair@286 | 101 | * except that it takes the binary data in the form of {@link DataHandler}, which |
ohair@286 | 102 | * contains a MIME type ({@link DataHandler#getContentType()} as well as the payload |
ohair@286 | 103 | * {@link DataHandler#getInputStream()}. |
ohair@286 | 104 | * |
ohair@286 | 105 | * @param data |
ohair@286 | 106 | * always non-null. After this method call, the callee owns the data handler. |
ohair@286 | 107 | */ |
ohair@286 | 108 | void writeBinary(DataHandler data) throws XMLStreamException; |
ohair@286 | 109 | |
ohair@286 | 110 | /** |
ohair@286 | 111 | * Writes the binary data. |
ohair@286 | 112 | * |
ohair@286 | 113 | * <p> |
ohair@286 | 114 | * This version of the writeBinary method allows the caller to produce |
ohair@286 | 115 | * the binary data by writing it to {@link OutputStream}. |
ohair@286 | 116 | * |
ohair@286 | 117 | * <p> |
ohair@286 | 118 | * It is the caller's responsibility to write and close |
ohair@286 | 119 | * a stream before it invokes any other methods on {@link XMLStreamWriter}. |
ohair@286 | 120 | * |
ohair@286 | 121 | * TODO: experimental. appreciate feedback |
ohair@286 | 122 | * @param contentType |
ohair@286 | 123 | * See the content-type parameter of |
ohair@286 | 124 | * {@link #writeBinary(byte[], int, int, String)}. Must not be null. |
ohair@286 | 125 | * |
ohair@286 | 126 | * @return |
ohair@286 | 127 | * always return a non-null {@link OutputStream}. |
ohair@286 | 128 | */ |
ohair@286 | 129 | OutputStream writeBinary(String contentType) throws XMLStreamException; |
ohair@286 | 130 | |
ohair@286 | 131 | /** |
ohair@286 | 132 | * Writes like {@link #writeCharacters(String)} but hides |
ohair@286 | 133 | * actual data format. |
ohair@286 | 134 | * |
ohair@286 | 135 | * @param data |
ohair@286 | 136 | * The {@link CharSequence} that represents the |
ohair@286 | 137 | * character infoset items to be written. |
ohair@286 | 138 | * |
ohair@286 | 139 | * <p> |
ohair@286 | 140 | * The {@link CharSequence} is normally a {@link String}, |
ohair@286 | 141 | * but can be any other {@link CharSequence} implementation. |
ohair@286 | 142 | * For binary data, however, use of {@link Base64Data} is |
ohair@286 | 143 | * recommended (so that the consumer interested in seeing it |
ohair@286 | 144 | * as binary data may take advantage of mor efficient |
ohair@286 | 145 | * data representation.) |
ohair@286 | 146 | * |
ohair@286 | 147 | */ |
ohair@286 | 148 | void writePCDATA(CharSequence data) throws XMLStreamException; |
ohair@286 | 149 | |
ohair@286 | 150 | /** |
ohair@286 | 151 | * {@inheritDoc} |
ohair@286 | 152 | */ |
ohair@286 | 153 | NamespaceContextEx getNamespaceContext(); |
ohair@286 | 154 | } |