Thu, 31 Aug 2017 15:18:52 +0800
merge
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.xml.internal.ws.spi.db; |
aoqi@0 | 27 | |
aoqi@0 | 28 | import java.io.InputStream; |
aoqi@0 | 29 | import java.io.OutputStream; |
aoqi@0 | 30 | |
aoqi@0 | 31 | import javax.xml.bind.JAXBException; |
aoqi@0 | 32 | import javax.xml.bind.attachment.AttachmentMarshaller; |
aoqi@0 | 33 | import javax.xml.bind.attachment.AttachmentUnmarshaller; |
aoqi@0 | 34 | import javax.xml.namespace.NamespaceContext; |
aoqi@0 | 35 | import javax.xml.stream.XMLStreamReader; |
aoqi@0 | 36 | import javax.xml.stream.XMLStreamWriter; |
aoqi@0 | 37 | import javax.xml.transform.Result; |
aoqi@0 | 38 | import javax.xml.transform.Source; |
aoqi@0 | 39 | |
aoqi@0 | 40 | import com.sun.istack.internal.NotNull; |
aoqi@0 | 41 | import com.sun.istack.internal.Nullable; |
aoqi@0 | 42 | import org.w3c.dom.Node; |
aoqi@0 | 43 | import org.xml.sax.ContentHandler; |
aoqi@0 | 44 | |
aoqi@0 | 45 | /** |
aoqi@0 | 46 | * The XMLBridge is a Glassfish JAXWS side of Glassfish JAXB Bridge. |
aoqi@0 | 47 | * |
aoqi@0 | 48 | * Mini-marshaller/unmarshaller that is specialized for a particular |
aoqi@0 | 49 | * element name and a type. |
aoqi@0 | 50 | * |
aoqi@0 | 51 | * <p> |
aoqi@0 | 52 | * Instances of this class is stateless and multi-thread safe. |
aoqi@0 | 53 | * They are reentrant. |
aoqi@0 | 54 | * |
aoqi@0 | 55 | * <p> |
aoqi@0 | 56 | * All the marshal operation generates fragments. |
aoqi@0 | 57 | * |
aoqi@0 | 58 | * <p> |
aoqi@0 | 59 | * <b>Subject to change without notice</b>. |
aoqi@0 | 60 | * |
aoqi@0 | 61 | * @since JAXB 2.0 EA1 |
aoqi@0 | 62 | * @author Kohsuke Kawaguchi |
aoqi@0 | 63 | * @author shih-chang.chen@oracle.com |
aoqi@0 | 64 | */ |
aoqi@0 | 65 | public interface XMLBridge<T> { |
aoqi@0 | 66 | /** |
aoqi@0 | 67 | * Gets the {@link BindingContext} to which this object belongs. |
aoqi@0 | 68 | * |
aoqi@0 | 69 | * @since 2.1 |
aoqi@0 | 70 | */ |
aoqi@0 | 71 | public @NotNull BindingContext context(); |
aoqi@0 | 72 | |
aoqi@0 | 73 | /** |
aoqi@0 | 74 | * |
aoqi@0 | 75 | * @throws JAXBException |
aoqi@0 | 76 | * if there was an error while marshalling. |
aoqi@0 | 77 | * |
aoqi@0 | 78 | * @since 2.0 EA1 |
aoqi@0 | 79 | */ |
aoqi@0 | 80 | // public void marshal(T object,XMLStreamWriter output) throws JAXBException; |
aoqi@0 | 81 | |
aoqi@0 | 82 | public void marshal(T object,XMLStreamWriter output, AttachmentMarshaller am) throws JAXBException; |
aoqi@0 | 83 | |
aoqi@0 | 84 | /** |
aoqi@0 | 85 | * Marshals the specified type object with the implicit element name |
aoqi@0 | 86 | * associated with this instance of {@link Bond}. |
aoqi@0 | 87 | * |
aoqi@0 | 88 | * @param nsContext |
aoqi@0 | 89 | * if this marshalling is done to marshal a subelement, this {@link NamespaceContext} |
aoqi@0 | 90 | * represents in-scope namespace bindings available for that element. Can be null, |
aoqi@0 | 91 | * in which case JAXB assumes no in-scope namespaces. |
aoqi@0 | 92 | * @throws JAXBException |
aoqi@0 | 93 | * if there was an error while marshalling. |
aoqi@0 | 94 | * |
aoqi@0 | 95 | * @since 2.0 EA1 |
aoqi@0 | 96 | */ |
aoqi@0 | 97 | // public void marshal(T object,OutputStream output, NamespaceContext nsContext) throws JAXBException; |
aoqi@0 | 98 | |
aoqi@0 | 99 | /** |
aoqi@0 | 100 | * @since 2.0.2 |
aoqi@0 | 101 | */ |
aoqi@0 | 102 | public void marshal(T object,OutputStream output, NamespaceContext nsContext, AttachmentMarshaller am) throws JAXBException ; |
aoqi@0 | 103 | // |
aoqi@0 | 104 | //// public void marshal(@NotNull BridgeContext context,T object,OutputStream output, NamespaceContext nsContext) throws JAXBException; |
aoqi@0 | 105 | // |
aoqi@0 | 106 | // public void marshal(@NotNull Marshaller m,T object,OutputStream output, NamespaceContext nsContext) throws JAXBException; |
aoqi@0 | 107 | |
aoqi@0 | 108 | |
aoqi@0 | 109 | public void marshal(T object,Node output) throws JAXBException ; |
aoqi@0 | 110 | // |
aoqi@0 | 111 | //// public void marshal(@NotNull BridgeContext context,T object,Node output) throws JAXBException ; |
aoqi@0 | 112 | // |
aoqi@0 | 113 | // public void marshal(@NotNull Marshaller m,T object,Node output) throws JAXBException; |
aoqi@0 | 114 | |
aoqi@0 | 115 | |
aoqi@0 | 116 | /** |
aoqi@0 | 117 | * @since 2.0 EA4 |
aoqi@0 | 118 | */ |
aoqi@0 | 119 | // public void marshal(T object, ContentHandler contentHandler) throws JAXBException; |
aoqi@0 | 120 | /** |
aoqi@0 | 121 | * @since 2.0.2 |
aoqi@0 | 122 | */ |
aoqi@0 | 123 | public void marshal(T object, ContentHandler contentHandler, AttachmentMarshaller am) throws JAXBException ; |
aoqi@0 | 124 | |
aoqi@0 | 125 | //// public void marshal(@NotNull BridgeContext context,T object, ContentHandler contentHandler) throws JAXBException; |
aoqi@0 | 126 | // |
aoqi@0 | 127 | // public void marshal(@NotNull Marshaller m,T object, ContentHandler contentHandler) throws JAXBException; |
aoqi@0 | 128 | |
aoqi@0 | 129 | /** |
aoqi@0 | 130 | * @since 2.0 EA4 |
aoqi@0 | 131 | */ |
aoqi@0 | 132 | public void marshal(T object, Result result) throws JAXBException; |
aoqi@0 | 133 | |
aoqi@0 | 134 | //// public void marshal(@NotNull BridgeContext context,T object, Result result) throws JAXBException; |
aoqi@0 | 135 | // public void marshal(@NotNull Marshaller m,T object, Result result) throws JAXBException; |
aoqi@0 | 136 | |
aoqi@0 | 137 | |
aoqi@0 | 138 | |
aoqi@0 | 139 | /** |
aoqi@0 | 140 | * Unmarshals the specified type object. |
aoqi@0 | 141 | * |
aoqi@0 | 142 | * @param in |
aoqi@0 | 143 | * the parser must be pointing at a start tag |
aoqi@0 | 144 | * that encloses the XML type that this {@link Bond} is |
aoqi@0 | 145 | * instanciated for. |
aoqi@0 | 146 | * |
aoqi@0 | 147 | * @return |
aoqi@0 | 148 | * never null. |
aoqi@0 | 149 | * |
aoqi@0 | 150 | * @throws JAXBException |
aoqi@0 | 151 | * if there was an error while unmarshalling. |
aoqi@0 | 152 | * |
aoqi@0 | 153 | * @since 2.0 EA1 |
aoqi@0 | 154 | */ |
aoqi@0 | 155 | // public @NotNull T unmarshal(@NotNull XMLStreamReader in) throws JAXBException ; |
aoqi@0 | 156 | /** |
aoqi@0 | 157 | * @since 2.0.3 |
aoqi@0 | 158 | */ |
aoqi@0 | 159 | public @NotNull T unmarshal(@NotNull XMLStreamReader in, @Nullable AttachmentUnmarshaller au) throws JAXBException; |
aoqi@0 | 160 | // public @NotNull T unmarshal(@NotNull BridgeContext context, @NotNull XMLStreamReader in) throws JAXBException ; |
aoqi@0 | 161 | // public @NotNull T unmarshal(@NotNull Unmarshaller u, @NotNull XMLStreamReader in) throws JAXBException; |
aoqi@0 | 162 | |
aoqi@0 | 163 | /** |
aoqi@0 | 164 | * Unmarshals the specified type object. |
aoqi@0 | 165 | * |
aoqi@0 | 166 | * @param in |
aoqi@0 | 167 | * the parser must be pointing at a start tag |
aoqi@0 | 168 | * that encloses the XML type that this {@link Bond} is |
aoqi@0 | 169 | * instanciated for. |
aoqi@0 | 170 | * |
aoqi@0 | 171 | * @return |
aoqi@0 | 172 | * never null. |
aoqi@0 | 173 | * |
aoqi@0 | 174 | * @throws JAXBException |
aoqi@0 | 175 | * if there was an error while unmarshalling. |
aoqi@0 | 176 | * |
aoqi@0 | 177 | * @since 2.0 EA1 |
aoqi@0 | 178 | */ |
aoqi@0 | 179 | // public @NotNull T unmarshal(@NotNull Source in) throws JAXBException ; |
aoqi@0 | 180 | /** |
aoqi@0 | 181 | * @since 2.0.3 |
aoqi@0 | 182 | */ |
aoqi@0 | 183 | public @NotNull T unmarshal(@NotNull Source in, @Nullable AttachmentUnmarshaller au) throws JAXBException; |
aoqi@0 | 184 | // public @NotNull T unmarshal(@NotNull BridgeContext context, @NotNull Source in) throws JAXBException; |
aoqi@0 | 185 | // public @NotNull T unmarshal(@NotNull Unmarshaller u, @NotNull Source in) throws JAXBException; |
aoqi@0 | 186 | |
aoqi@0 | 187 | /** |
aoqi@0 | 188 | * Unmarshals the specified type object. |
aoqi@0 | 189 | * |
aoqi@0 | 190 | * @param in |
aoqi@0 | 191 | * the parser must be pointing at a start tag |
aoqi@0 | 192 | * that encloses the XML type that this {@link XMLBridge} is |
aoqi@0 | 193 | * instanciated for. |
aoqi@0 | 194 | * |
aoqi@0 | 195 | * @return |
aoqi@0 | 196 | * never null. |
aoqi@0 | 197 | * |
aoqi@0 | 198 | * @throws JAXBException |
aoqi@0 | 199 | * if there was an error while unmarshalling. |
aoqi@0 | 200 | * |
aoqi@0 | 201 | * @since 2.0 EA1 |
aoqi@0 | 202 | */ |
aoqi@0 | 203 | public @NotNull T unmarshal(@NotNull InputStream in) throws JAXBException ; |
aoqi@0 | 204 | |
aoqi@0 | 205 | // public @NotNull T unmarshal(@NotNull BridgeContext context, @NotNull InputStream in) throws JAXBException ; |
aoqi@0 | 206 | |
aoqi@0 | 207 | // public @NotNull T unmarshal(@NotNull Unmarshaller u, @NotNull InputStream in) throws JAXBException; |
aoqi@0 | 208 | |
aoqi@0 | 209 | /** |
aoqi@0 | 210 | * Unmarshals the specified type object. |
aoqi@0 | 211 | * |
aoqi@0 | 212 | * @param n |
aoqi@0 | 213 | * Node to be unmarshalled. |
aoqi@0 | 214 | * |
aoqi@0 | 215 | * @return |
aoqi@0 | 216 | * never null. |
aoqi@0 | 217 | * |
aoqi@0 | 218 | * @throws JAXBException |
aoqi@0 | 219 | * if there was an error while unmarshalling. |
aoqi@0 | 220 | * |
aoqi@0 | 221 | * @since 2.0 FCS |
aoqi@0 | 222 | */ |
aoqi@0 | 223 | // public @NotNull T unmarshal(@NotNull Node n) throws JAXBException ; |
aoqi@0 | 224 | /** |
aoqi@0 | 225 | * @since 2.0.3 |
aoqi@0 | 226 | */ |
aoqi@0 | 227 | public @NotNull T unmarshal(@NotNull Node n, @Nullable AttachmentUnmarshaller au) throws JAXBException; |
aoqi@0 | 228 | // public @NotNull T unmarshal(@NotNull BridgeContext context, @NotNull Node n) throws JAXBException; |
aoqi@0 | 229 | // public @NotNull T unmarshal(@NotNull Unmarshaller context, @NotNull Node n) throws JAXBException; |
aoqi@0 | 230 | |
aoqi@0 | 231 | /** |
aoqi@0 | 232 | * Gets the {@link TypeInfo} from which this bridge was created. |
aoqi@0 | 233 | */ |
aoqi@0 | 234 | public TypeInfo getTypeInfo(); |
aoqi@0 | 235 | |
aoqi@0 | 236 | /** |
aoqi@0 | 237 | * This can be used to determine whether XMLStreamWriter or OutputStream is |
aoqi@0 | 238 | * prefered by the implementation. |
aoqi@0 | 239 | * |
aoqi@0 | 240 | * @return true if marshall to OutputStream is supported in the |
aoqi@0 | 241 | * implementation. |
aoqi@0 | 242 | */ |
aoqi@0 | 243 | public boolean supportOutputStream(); |
aoqi@0 | 244 | } |