Thu, 31 Aug 2017 15:18:52 +0800
merge
1 /*
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
26 package com.sun.xml.internal.ws.db.glassfish;
28 import java.io.InputStream;
29 import java.io.OutputStream;
31 import javax.xml.bind.JAXBException;
32 import javax.xml.bind.Marshaller;
33 import javax.xml.bind.Unmarshaller;
34 import javax.xml.bind.attachment.AttachmentMarshaller;
35 import javax.xml.bind.attachment.AttachmentUnmarshaller;
36 import javax.xml.namespace.NamespaceContext;
37 import javax.xml.stream.XMLStreamReader;
38 import javax.xml.stream.XMLStreamWriter;
39 import javax.xml.transform.Result;
40 import javax.xml.transform.Source;
42 import org.w3c.dom.Node;
43 import org.xml.sax.ContentHandler;
45 import com.sun.xml.internal.bind.api.JAXBRIContext;
46 import com.sun.xml.internal.ws.spi.db.BindingContext;
47 import com.sun.xml.internal.ws.spi.db.XMLBridge;
48 import com.sun.xml.internal.ws.spi.db.DatabindingException;
49 import com.sun.xml.internal.ws.spi.db.TypeInfo;
51 public class BridgeWrapper<T> implements XMLBridge<T> {
53 private JAXBRIContextWrapper parent;
54 private com.sun.xml.internal.bind.api.Bridge<T> bridge;
56 public BridgeWrapper(JAXBRIContextWrapper p, com.sun.xml.internal.bind.api.Bridge<T> b) {
57 parent = p;
58 bridge = b;
59 }
61 @Override
62 public BindingContext context() {
63 return parent;
64 }
66 com.sun.xml.internal.bind.api.Bridge getBridge() {
67 return bridge;
68 }
70 @Override
71 public boolean equals(Object obj) {
72 return bridge.equals(obj);
73 }
75 public JAXBRIContext getContext() {
76 return bridge.getContext();
77 }
79 @Override
80 public TypeInfo getTypeInfo() {
81 return parent.typeInfo(bridge.getTypeReference());
82 }
84 @Override
85 public int hashCode() {
86 return bridge.hashCode();
87 }
89 // public final void marshal(BridgeContext context, T object, ContentHandler contentHandler) throws JAXBException {
90 // bridge.marshal(context, object, contentHandler);
91 // }
92 //
93 // public final void marshal(BridgeContext context, T object, Node output) throws JAXBException {
94 // bridge.marshal(context, object, output);
95 // }
96 //
97 // public final void marshal(BridgeContext context, T object, OutputStream output, NamespaceContext nsContext) throws JAXBException {
98 // bridge.marshal(context, object, output, nsContext);
99 // }
100 //
101 // public final void marshal(BridgeContext context, T object, Result result) throws JAXBException {
102 // bridge.marshal(context, object, result);
103 // }
104 //
105 // public final void marshal(BridgeContext context, T object, XMLStreamWriter output) throws JAXBException {
106 // bridge.marshal(context, object, output);
107 // }
108 public void marshal(Marshaller m, T object, ContentHandler contentHandler) throws JAXBException {
109 bridge.marshal(m, object, contentHandler);
110 }
112 public void marshal(Marshaller m, T object, Node output) throws JAXBException {
113 bridge.marshal(m, object, output);
114 }
116 public void marshal(Marshaller m, T object, OutputStream output, NamespaceContext nsContext) throws JAXBException {
117 bridge.marshal(m, object, output, nsContext);
118 }
120 public void marshal(Marshaller m, T object, Result result) throws JAXBException {
121 bridge.marshal(m, object, result);
122 }
124 public void marshal(Marshaller m, T object, XMLStreamWriter output) throws JAXBException {
125 bridge.marshal(m, object, output);
126 // bridge.marshal(m, (T) convert(object), output);
127 }
129 @Override
130 public final void marshal(T object, ContentHandler contentHandler, AttachmentMarshaller am) throws JAXBException {
131 // bridge.marshal((T) convert(object), contentHandler, am);
132 bridge.marshal(object, contentHandler, am);
133 }
135 // Object convert(Object o) {
136 // return (o instanceof WrapperComposite)? convertWrapper((WrapperComposite)o) : o;
137 // }
138 //
139 // static CompositeStructure convertWrapper(WrapperComposite w) {
140 // CompositeStructure cs = new CompositeStructure();
141 // cs.values = w.values;
142 // cs.bridges = new Bridge[w.bridges.length];
143 // for (int i = 0; i < cs.bridges.length; i++)
144 // cs.bridges[i] = ((BridgeWrapper)w.bridges[i]).getBridge();
145 // return cs;
146 // }
147 public void marshal(T object, ContentHandler contentHandler) throws JAXBException {
148 bridge.marshal(object, contentHandler);
149 // bridge.marshal((T) convert(object), contentHandler);
150 }
152 @Override
153 public void marshal(T object, Node output) throws JAXBException {
154 bridge.marshal(object, output);
155 // bridge.marshal((T) convert(object), output);
156 }
158 @Override
159 public void marshal(T object, OutputStream output, NamespaceContext nsContext, AttachmentMarshaller am) throws JAXBException {
160 // bridge.marshal((T) convert(object), output, nsContext, am);
161 bridge.marshal(object, output, nsContext, am);
162 }
164 public void marshal(T object, OutputStream output, NamespaceContext nsContext) throws JAXBException {
165 bridge.marshal(object, output, nsContext);
166 // bridge.marshal((T) convert(object), output, nsContext);
167 }
169 @Override
170 public final void marshal(T object, Result result) throws JAXBException {
171 bridge.marshal(object, result);
172 }
174 @Override
175 public final void marshal(T object, XMLStreamWriter output,
176 AttachmentMarshaller am) throws JAXBException {
177 bridge.marshal(object, output, am);
178 }
180 public final void marshal(T object, XMLStreamWriter output)
181 throws JAXBException {
182 bridge.marshal(object, output);
183 }
185 @Override
186 public String toString() {
187 return BridgeWrapper.class.getName() + " : " + bridge.toString();
188 }
190 // public final T unmarshal(BridgeContext context, InputStream in)
191 // throws JAXBException {
192 // return bridge.unmarshal(context, in);
193 // }
194 //
195 // public final T unmarshal(BridgeContext context, Node n)
196 // throws JAXBException {
197 // return bridge.unmarshal(context, n);
198 // }
199 //
200 // public final T unmarshal(BridgeContext context, Source in)
201 // throws JAXBException {
202 // return bridge.unmarshal(context, in);
203 // }
204 //
205 // public final T unmarshal(BridgeContext context, XMLStreamReader in)
206 // throws JAXBException {
207 // return bridge.unmarshal(context, in);
208 // }
209 @Override
210 public final T unmarshal(InputStream in) throws JAXBException {
211 return bridge.unmarshal(in);
212 }
214 @Override
215 public final T unmarshal(Node n, AttachmentUnmarshaller au)
216 throws JAXBException {
217 return bridge.unmarshal(n, au);
218 }
220 public final T unmarshal(Node n) throws JAXBException {
221 return bridge.unmarshal(n);
222 }
224 @Override
225 public final T unmarshal(Source in, AttachmentUnmarshaller au)
226 throws JAXBException {
227 return bridge.unmarshal(in, au);
228 }
230 public final T unmarshal(Source in) throws DatabindingException {
231 try {
232 return bridge.unmarshal(in);
233 } catch (JAXBException e) {
234 throw new DatabindingException(e);
235 }
236 }
238 public T unmarshal(Unmarshaller u, InputStream in) throws JAXBException {
239 return bridge.unmarshal(u, in);
240 }
242 public T unmarshal(Unmarshaller context, Node n) throws JAXBException {
243 return bridge.unmarshal(context, n);
244 }
246 public T unmarshal(Unmarshaller u, Source in) throws JAXBException {
247 return bridge.unmarshal(u, in);
248 }
250 public T unmarshal(Unmarshaller u, XMLStreamReader in) throws JAXBException {
251 return bridge.unmarshal(u, in);
252 }
254 @Override
255 public final T unmarshal(XMLStreamReader in, AttachmentUnmarshaller au)
256 throws JAXBException {
257 return bridge.unmarshal(in, au);
258 }
260 public final T unmarshal(XMLStreamReader in) throws JAXBException {
261 return bridge.unmarshal(in);
262 }
264 @Override
265 public boolean supportOutputStream() {
266 return true;
267 }
268 }