src/share/jaxws_classes/com/sun/xml/internal/ws/message/EmptyMessageImpl.java

Thu, 31 Aug 2017 15:18:52 +0800

author
aoqi
date
Thu, 31 Aug 2017 15:18:52 +0800
changeset 637
9c07ef4934dd
parent 368
0989ad8c0860
parent 0
373ffda63c9a
permissions
-rw-r--r--

merge

     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  */
    26 package com.sun.xml.internal.ws.message;
    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;
    35 import org.xml.sax.ContentHandler;
    36 import org.xml.sax.ErrorHandler;
    37 import org.xml.sax.SAXException;
    39 import javax.xml.stream.XMLStreamException;
    40 import javax.xml.stream.XMLStreamReader;
    41 import javax.xml.stream.XMLStreamWriter;
    42 import javax.xml.transform.Source;
    44 /**
    45  * {@link Message} that has no body.
    46  *
    47  * @author Kohsuke Kawaguchi
    48  */
    49 public class EmptyMessageImpl extends AbstractMessageImpl {
    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;
    58     public EmptyMessageImpl(SOAPVersion version) {
    59         super(version);
    60         this.headers = new HeaderList(version);
    61         this.attachmentSet = new AttachmentSetImpl();
    62     }
    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     }
    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     }
    81     public boolean hasHeaders() {
    82         return headers.hasHeaders();
    83     }
    85     public MessageHeaders getHeaders() {
    86         return headers;
    87     }
    89     public String getPayloadLocalPart() {
    90         return null;
    91     }
    93     public String getPayloadNamespaceURI() {
    94         return null;
    95     }
    97     public boolean hasPayload() {
    98         return false;
    99     }
   101     public Source readPayloadAsSource() {
   102         return null;
   103     }
   105     public XMLStreamReader readPayload() throws XMLStreamException {
   106         return null;
   107     }
   109     public void writePayloadTo(XMLStreamWriter sw) throws XMLStreamException {
   110         // noop
   111     }
   113     public void writePayloadTo(ContentHandler contentHandler, ErrorHandler errorHandler, boolean fragment) throws SAXException {
   114         // noop
   115     }
   117     public Message copy() {
   118         return new EmptyMessageImpl(this);
   119     }
   121 }

mercurial