|
1 /* |
|
2 * Copyright (c) 1997, 2013, 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 */ |
|
25 |
|
26 package com.sun.xml.internal.ws.message; |
|
27 |
|
28 import com.sun.istack.internal.NotNull; |
|
29 import com.sun.xml.internal.ws.api.SOAPVersion; |
|
30 import com.sun.xml.internal.ws.api.message.AttachmentSet; |
|
31 import com.sun.xml.internal.ws.api.message.HeaderList; |
|
32 import com.sun.xml.internal.ws.api.message.Message; |
|
33 import com.sun.xml.internal.ws.api.message.MessageHeaders; |
|
34 |
|
35 import org.xml.sax.ContentHandler; |
|
36 import org.xml.sax.ErrorHandler; |
|
37 import org.xml.sax.SAXException; |
|
38 |
|
39 import javax.xml.stream.XMLStreamException; |
|
40 import javax.xml.stream.XMLStreamReader; |
|
41 import javax.xml.stream.XMLStreamWriter; |
|
42 import javax.xml.transform.Source; |
|
43 |
|
44 /** |
|
45 * {@link Message} that has no body. |
|
46 * |
|
47 * @author Kohsuke Kawaguchi |
|
48 */ |
|
49 public class EmptyMessageImpl extends AbstractMessageImpl { |
|
50 |
|
51 /** |
|
52 * If a message has no payload, it's more likely to have |
|
53 * some header, so we create it eagerly here. |
|
54 */ |
|
55 private final MessageHeaders headers; |
|
56 private final AttachmentSet attachmentSet; |
|
57 |
|
58 public EmptyMessageImpl(SOAPVersion version) { |
|
59 super(version); |
|
60 this.headers = new HeaderList(version); |
|
61 this.attachmentSet = new AttachmentSetImpl(); |
|
62 } |
|
63 |
|
64 public EmptyMessageImpl(MessageHeaders headers, @NotNull AttachmentSet attachmentSet, SOAPVersion version){ |
|
65 super(version); |
|
66 if(headers==null) |
|
67 headers = new HeaderList(version); |
|
68 this.attachmentSet = attachmentSet; |
|
69 this.headers = headers; |
|
70 } |
|
71 |
|
72 /** |
|
73 * Copy constructor. |
|
74 */ |
|
75 private EmptyMessageImpl(EmptyMessageImpl that) { |
|
76 super(that); |
|
77 this.headers = new HeaderList(that.headers); |
|
78 this.attachmentSet = that.attachmentSet; |
|
79 } |
|
80 |
|
81 public boolean hasHeaders() { |
|
82 return headers.hasHeaders(); |
|
83 } |
|
84 |
|
85 public MessageHeaders getHeaders() { |
|
86 return headers; |
|
87 } |
|
88 |
|
89 public String getPayloadLocalPart() { |
|
90 return null; |
|
91 } |
|
92 |
|
93 public String getPayloadNamespaceURI() { |
|
94 return null; |
|
95 } |
|
96 |
|
97 public boolean hasPayload() { |
|
98 return false; |
|
99 } |
|
100 |
|
101 public Source readPayloadAsSource() { |
|
102 return null; |
|
103 } |
|
104 |
|
105 public XMLStreamReader readPayload() throws XMLStreamException { |
|
106 return null; |
|
107 } |
|
108 |
|
109 public void writePayloadTo(XMLStreamWriter sw) throws XMLStreamException { |
|
110 // noop |
|
111 } |
|
112 |
|
113 public void writePayloadTo(ContentHandler contentHandler, ErrorHandler errorHandler, boolean fragment) throws SAXException { |
|
114 // noop |
|
115 } |
|
116 |
|
117 public Message copy() { |
|
118 return new EmptyMessageImpl(this); |
|
119 } |
|
120 |
|
121 } |