01: /*
02: * Portions Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
03: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04: *
05: * This code is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU General Public License version 2 only, as
07: * published by the Free Software Foundation. Sun designates this
08: * particular file as subject to the "Classpath" exception as provided
09: * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22: * CA 95054 USA or visit www.sun.com if you need additional information or
23: * have any questions.
24: */
25: package com.sun.xml.internal.ws.encoding.xml;
26:
27: import java.nio.ByteBuffer;
28: import javax.xml.stream.XMLStreamWriter;
29:
30: import com.sun.xml.internal.ws.pept.encoding.Encoder;
31: import com.sun.xml.internal.ws.pept.ept.MessageInfo;
32: import com.sun.xml.internal.ws.encoding.jaxb.JAXBBeanInfo;
33: import com.sun.xml.internal.ws.encoding.jaxb.JAXBTypeSerializer;
34: import com.sun.xml.internal.ws.encoding.soap.internal.BodyBlock;
35: import com.sun.xml.internal.ws.encoding.soap.internal.InternalMessage;
36: import com.sun.xml.internal.ws.server.ServerRtException;
37:
38: /**
39: * @author WS Development Team
40: */
41: public class XMLEncoder implements Encoder {
42:
43: /*
44: * @see com.sun.pept.encoding.Encoder#encodeAndSend(com.sun.pept.ept.MessageInfo)
45: */
46: public void encodeAndSend(MessageInfo messageInfo) {
47: throw new UnsupportedOperationException();
48: }
49:
50: /*
51: * @see com.sun.pept.encoding.Encoder#encode(com.sun.pept.ept.MessageInfo)
52: */
53: public ByteBuffer encode(MessageInfo messageInfo) {
54: throw new UnsupportedOperationException();
55: }
56:
57: public InternalMessage toInternalMessage(MessageInfo messageInfo) {
58: return null;
59: }
60:
61: public XMLMessage toXMLMessage(InternalMessage internalMessage,
62: MessageInfo messageInfo) {
63: return null;
64: }
65:
66: /*
67: * Replace the body in SOAPMessage with the BodyBlock of InternalMessage
68: */
69: public XMLMessage toXMLMessage(InternalMessage internalMessage,
70: XMLMessage xmlMessage) {
71: try {
72: BodyBlock bodyBlock = internalMessage.getBody();
73: Object value = bodyBlock.getValue();
74: if (value == null) {
75: return xmlMessage;
76: }
77: if (value instanceof XMLMessage) {
78: return (XMLMessage) value;
79: } else {
80: throw new UnsupportedOperationException(
81: "Unknown object in BodyBlock:"
82: + value.getClass());
83: }
84: } catch (Exception e) {
85: throw new ServerRtException("xmlencoder.err",
86: new Object[] { e });
87: }
88: }
89:
90: }
|