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

Print this page


   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


  63     }
  64 
  65     public DOMMessage(SOAPVersion ver, MessageHeaders headers, Element payload) {
  66         this(ver,headers,payload,null);
  67     }
  68 
  69     public DOMMessage(SOAPVersion ver, MessageHeaders headers, Element payload, AttachmentSet attachments) {
  70         super(ver);
  71         this.headers = headers;
  72         this.payload = payload;
  73         this.attachmentSet = attachments;
  74         assert payload!=null;
  75     }
  76     /**
  77      * This constructor is a convenience and called by the {@link #copy}
  78      */
  79     private DOMMessage(DOMMessage that) {
  80         super(that);
  81         this.headers = HeaderList.copy(that.headers);
  82         this.payload = that.payload;

  83     }
  84 
  85     public boolean hasHeaders() {
  86         return getHeaders().hasHeaders();
  87     }
  88 
  89     public MessageHeaders getHeaders() {
  90         if (headers == null)
  91             headers = new HeaderList(getSOAPVersion());
  92 
  93         return headers;
  94     }
  95 
  96     public String getPayloadLocalPart() {
  97         return payload.getLocalName();
  98     }
  99 
 100     public String getPayloadNamespaceURI() {
 101         return payload.getNamespaceURI();
 102     }


 133     }
 134 
 135     public void writePayloadTo(XMLStreamWriter sw) {
 136         try {
 137             if (payload != null)
 138                 DOMUtil.serializeNode(payload, sw);
 139         } catch (XMLStreamException e) {
 140             throw new WebServiceException(e);
 141         }
 142     }
 143 
 144     protected void writePayloadTo(ContentHandler contentHandler, ErrorHandler errorHandler, boolean fragment) throws SAXException {
 145         if(fragment)
 146             contentHandler = new FragmentContentHandler(contentHandler);
 147         DOMScanner ds = new DOMScanner();
 148         ds.setContentHandler(contentHandler);
 149         ds.scan(payload);
 150     }
 151 
 152     public Message copy() {
 153         return new DOMMessage(this);
 154     }
 155 
 156 }
   1 /*
   2  * Copyright (c) 1997, 2014, 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


  63     }
  64 
  65     public DOMMessage(SOAPVersion ver, MessageHeaders headers, Element payload) {
  66         this(ver,headers,payload,null);
  67     }
  68 
  69     public DOMMessage(SOAPVersion ver, MessageHeaders headers, Element payload, AttachmentSet attachments) {
  70         super(ver);
  71         this.headers = headers;
  72         this.payload = payload;
  73         this.attachmentSet = attachments;
  74         assert payload!=null;
  75     }
  76     /**
  77      * This constructor is a convenience and called by the {@link #copy}
  78      */
  79     private DOMMessage(DOMMessage that) {
  80         super(that);
  81         this.headers = HeaderList.copy(that.headers);
  82         this.payload = that.payload;
  83         this.copyFrom(that);
  84     }
  85 
  86     public boolean hasHeaders() {
  87         return getHeaders().hasHeaders();
  88     }
  89 
  90     public MessageHeaders getHeaders() {
  91         if (headers == null)
  92             headers = new HeaderList(getSOAPVersion());
  93 
  94         return headers;
  95     }
  96 
  97     public String getPayloadLocalPart() {
  98         return payload.getLocalName();
  99     }
 100 
 101     public String getPayloadNamespaceURI() {
 102         return payload.getNamespaceURI();
 103     }


 134     }
 135 
 136     public void writePayloadTo(XMLStreamWriter sw) {
 137         try {
 138             if (payload != null)
 139                 DOMUtil.serializeNode(payload, sw);
 140         } catch (XMLStreamException e) {
 141             throw new WebServiceException(e);
 142         }
 143     }
 144 
 145     protected void writePayloadTo(ContentHandler contentHandler, ErrorHandler errorHandler, boolean fragment) throws SAXException {
 146         if(fragment)
 147             contentHandler = new FragmentContentHandler(contentHandler);
 148         DOMScanner ds = new DOMScanner();
 149         ds.setContentHandler(contentHandler);
 150         ds.scan(payload);
 151     }
 152 
 153     public Message copy() {
 154         return new DOMMessage(this).copyFrom(this);
 155     }
 156 
 157 }