1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/db/glassfish/BridgeWrapper.java Wed Apr 27 01:27:09 2016 +0800 1.3 @@ -0,0 +1,268 @@ 1.4 +/* 1.5 + * Copyright (c) 1997, 2012, 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.ws.db.glassfish; 1.30 + 1.31 +import java.io.InputStream; 1.32 +import java.io.OutputStream; 1.33 + 1.34 +import javax.xml.bind.JAXBException; 1.35 +import javax.xml.bind.Marshaller; 1.36 +import javax.xml.bind.Unmarshaller; 1.37 +import javax.xml.bind.attachment.AttachmentMarshaller; 1.38 +import javax.xml.bind.attachment.AttachmentUnmarshaller; 1.39 +import javax.xml.namespace.NamespaceContext; 1.40 +import javax.xml.stream.XMLStreamReader; 1.41 +import javax.xml.stream.XMLStreamWriter; 1.42 +import javax.xml.transform.Result; 1.43 +import javax.xml.transform.Source; 1.44 + 1.45 +import org.w3c.dom.Node; 1.46 +import org.xml.sax.ContentHandler; 1.47 + 1.48 +import com.sun.xml.internal.bind.api.JAXBRIContext; 1.49 +import com.sun.xml.internal.ws.spi.db.BindingContext; 1.50 +import com.sun.xml.internal.ws.spi.db.XMLBridge; 1.51 +import com.sun.xml.internal.ws.spi.db.DatabindingException; 1.52 +import com.sun.xml.internal.ws.spi.db.TypeInfo; 1.53 + 1.54 +public class BridgeWrapper<T> implements XMLBridge<T> { 1.55 + 1.56 + private JAXBRIContextWrapper parent; 1.57 + private com.sun.xml.internal.bind.api.Bridge<T> bridge; 1.58 + 1.59 + public BridgeWrapper(JAXBRIContextWrapper p, com.sun.xml.internal.bind.api.Bridge<T> b) { 1.60 + parent = p; 1.61 + bridge = b; 1.62 + } 1.63 + 1.64 + @Override 1.65 + public BindingContext context() { 1.66 + return parent; 1.67 + } 1.68 + 1.69 + com.sun.xml.internal.bind.api.Bridge getBridge() { 1.70 + return bridge; 1.71 + } 1.72 + 1.73 + @Override 1.74 + public boolean equals(Object obj) { 1.75 + return bridge.equals(obj); 1.76 + } 1.77 + 1.78 + public JAXBRIContext getContext() { 1.79 + return bridge.getContext(); 1.80 + } 1.81 + 1.82 + @Override 1.83 + public TypeInfo getTypeInfo() { 1.84 + return parent.typeInfo(bridge.getTypeReference()); 1.85 + } 1.86 + 1.87 + @Override 1.88 + public int hashCode() { 1.89 + return bridge.hashCode(); 1.90 + } 1.91 + 1.92 +// public final void marshal(BridgeContext context, T object, ContentHandler contentHandler) throws JAXBException { 1.93 +// bridge.marshal(context, object, contentHandler); 1.94 +// } 1.95 +// 1.96 +// public final void marshal(BridgeContext context, T object, Node output) throws JAXBException { 1.97 +// bridge.marshal(context, object, output); 1.98 +// } 1.99 +// 1.100 +// public final void marshal(BridgeContext context, T object, OutputStream output, NamespaceContext nsContext) throws JAXBException { 1.101 +// bridge.marshal(context, object, output, nsContext); 1.102 +// } 1.103 +// 1.104 +// public final void marshal(BridgeContext context, T object, Result result) throws JAXBException { 1.105 +// bridge.marshal(context, object, result); 1.106 +// } 1.107 +// 1.108 +// public final void marshal(BridgeContext context, T object, XMLStreamWriter output) throws JAXBException { 1.109 +// bridge.marshal(context, object, output); 1.110 +// } 1.111 + public void marshal(Marshaller m, T object, ContentHandler contentHandler) throws JAXBException { 1.112 + bridge.marshal(m, object, contentHandler); 1.113 + } 1.114 + 1.115 + public void marshal(Marshaller m, T object, Node output) throws JAXBException { 1.116 + bridge.marshal(m, object, output); 1.117 + } 1.118 + 1.119 + public void marshal(Marshaller m, T object, OutputStream output, NamespaceContext nsContext) throws JAXBException { 1.120 + bridge.marshal(m, object, output, nsContext); 1.121 + } 1.122 + 1.123 + public void marshal(Marshaller m, T object, Result result) throws JAXBException { 1.124 + bridge.marshal(m, object, result); 1.125 + } 1.126 + 1.127 + public void marshal(Marshaller m, T object, XMLStreamWriter output) throws JAXBException { 1.128 + bridge.marshal(m, object, output); 1.129 +// bridge.marshal(m, (T) convert(object), output); 1.130 + } 1.131 + 1.132 + @Override 1.133 + public final void marshal(T object, ContentHandler contentHandler, AttachmentMarshaller am) throws JAXBException { 1.134 +// bridge.marshal((T) convert(object), contentHandler, am); 1.135 + bridge.marshal(object, contentHandler, am); 1.136 + } 1.137 + 1.138 +// Object convert(Object o) { 1.139 +// return (o instanceof WrapperComposite)? convertWrapper((WrapperComposite)o) : o; 1.140 +// } 1.141 +// 1.142 +// static CompositeStructure convertWrapper(WrapperComposite w) { 1.143 +// CompositeStructure cs = new CompositeStructure(); 1.144 +// cs.values = w.values; 1.145 +// cs.bridges = new Bridge[w.bridges.length]; 1.146 +// for (int i = 0; i < cs.bridges.length; i++) 1.147 +// cs.bridges[i] = ((BridgeWrapper)w.bridges[i]).getBridge(); 1.148 +// return cs; 1.149 +// } 1.150 + public void marshal(T object, ContentHandler contentHandler) throws JAXBException { 1.151 + bridge.marshal(object, contentHandler); 1.152 +// bridge.marshal((T) convert(object), contentHandler); 1.153 + } 1.154 + 1.155 + @Override 1.156 + public void marshal(T object, Node output) throws JAXBException { 1.157 + bridge.marshal(object, output); 1.158 +// bridge.marshal((T) convert(object), output); 1.159 + } 1.160 + 1.161 + @Override 1.162 + public void marshal(T object, OutputStream output, NamespaceContext nsContext, AttachmentMarshaller am) throws JAXBException { 1.163 +// bridge.marshal((T) convert(object), output, nsContext, am); 1.164 + bridge.marshal(object, output, nsContext, am); 1.165 + } 1.166 + 1.167 + public void marshal(T object, OutputStream output, NamespaceContext nsContext) throws JAXBException { 1.168 + bridge.marshal(object, output, nsContext); 1.169 +// bridge.marshal((T) convert(object), output, nsContext); 1.170 + } 1.171 + 1.172 + @Override 1.173 + public final void marshal(T object, Result result) throws JAXBException { 1.174 + bridge.marshal(object, result); 1.175 + } 1.176 + 1.177 + @Override 1.178 + public final void marshal(T object, XMLStreamWriter output, 1.179 + AttachmentMarshaller am) throws JAXBException { 1.180 + bridge.marshal(object, output, am); 1.181 + } 1.182 + 1.183 + public final void marshal(T object, XMLStreamWriter output) 1.184 + throws JAXBException { 1.185 + bridge.marshal(object, output); 1.186 + } 1.187 + 1.188 + @Override 1.189 + public String toString() { 1.190 + return BridgeWrapper.class.getName() + " : " + bridge.toString(); 1.191 + } 1.192 + 1.193 +// public final T unmarshal(BridgeContext context, InputStream in) 1.194 +// throws JAXBException { 1.195 +// return bridge.unmarshal(context, in); 1.196 +// } 1.197 +// 1.198 +// public final T unmarshal(BridgeContext context, Node n) 1.199 +// throws JAXBException { 1.200 +// return bridge.unmarshal(context, n); 1.201 +// } 1.202 +// 1.203 +// public final T unmarshal(BridgeContext context, Source in) 1.204 +// throws JAXBException { 1.205 +// return bridge.unmarshal(context, in); 1.206 +// } 1.207 +// 1.208 +// public final T unmarshal(BridgeContext context, XMLStreamReader in) 1.209 +// throws JAXBException { 1.210 +// return bridge.unmarshal(context, in); 1.211 +// } 1.212 + @Override 1.213 + public final T unmarshal(InputStream in) throws JAXBException { 1.214 + return bridge.unmarshal(in); 1.215 + } 1.216 + 1.217 + @Override 1.218 + public final T unmarshal(Node n, AttachmentUnmarshaller au) 1.219 + throws JAXBException { 1.220 + return bridge.unmarshal(n, au); 1.221 + } 1.222 + 1.223 + public final T unmarshal(Node n) throws JAXBException { 1.224 + return bridge.unmarshal(n); 1.225 + } 1.226 + 1.227 + @Override 1.228 + public final T unmarshal(Source in, AttachmentUnmarshaller au) 1.229 + throws JAXBException { 1.230 + return bridge.unmarshal(in, au); 1.231 + } 1.232 + 1.233 + public final T unmarshal(Source in) throws DatabindingException { 1.234 + try { 1.235 + return bridge.unmarshal(in); 1.236 + } catch (JAXBException e) { 1.237 + throw new DatabindingException(e); 1.238 + } 1.239 + } 1.240 + 1.241 + public T unmarshal(Unmarshaller u, InputStream in) throws JAXBException { 1.242 + return bridge.unmarshal(u, in); 1.243 + } 1.244 + 1.245 + public T unmarshal(Unmarshaller context, Node n) throws JAXBException { 1.246 + return bridge.unmarshal(context, n); 1.247 + } 1.248 + 1.249 + public T unmarshal(Unmarshaller u, Source in) throws JAXBException { 1.250 + return bridge.unmarshal(u, in); 1.251 + } 1.252 + 1.253 + public T unmarshal(Unmarshaller u, XMLStreamReader in) throws JAXBException { 1.254 + return bridge.unmarshal(u, in); 1.255 + } 1.256 + 1.257 + @Override 1.258 + public final T unmarshal(XMLStreamReader in, AttachmentUnmarshaller au) 1.259 + throws JAXBException { 1.260 + return bridge.unmarshal(in, au); 1.261 + } 1.262 + 1.263 + public final T unmarshal(XMLStreamReader in) throws JAXBException { 1.264 + return bridge.unmarshal(in); 1.265 + } 1.266 + 1.267 + @Override 1.268 + public boolean supportOutputStream() { 1.269 + return true; 1.270 + } 1.271 +}