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.oracle.webservices.internal.api.message;
  27 
  28 //TODO Do we want to remove this implementation dependency?
  29 import com.sun.xml.internal.ws.encoding.ContentTypeImpl;
  30 
  31 /**
  32  * A Content-Type transport header that will be returned by {@link MessageContext#write(java.io.OutputStream)}.
  33  * It will provide the Content-Type header and also take care of SOAP 1.1 SOAPAction header.
  34  *
  35  * @author Vivek Pandey
  36  */
  37 public interface ContentType {
  38 
  39     /**
  40      * Gives non-null Content-Type header value.
  41      */
  42     public String getContentType();
  43 
  44     /**
  45      * Gives SOAPAction transport header value. It will be non-null only for SOAP 1.1 messages. In other cases
  46      * it MUST be null. The SOAPAction transport header should be written out only when its non-null.
  47      *
  48      * @return It can be null, in that case SOAPAction header should be written.
  49      */
  50     public String getSOAPActionHeader();
  51 
  52     /**
  53      * Controls the Accept transport header, if the transport supports it.
  54      * Returning null means the transport need not add any new header.
  55      *
  56      * <p>
  57      * We realize that this is not an elegant abstraction, but
  58      * this would do for now. If another person comes and asks for
  59      * a similar functionality, we'll define a real abstraction.
  60      */
  61     public String getAcceptHeader();
  62 
  63     static public class Builder {
  64         private String contentType;
  65         private String soapAction;
  66         private String accept;
  67         private String charset;
  68 
  69         public Builder contentType(String s) {contentType = s; return this; }
  70         public Builder soapAction (String s) {soapAction = s;  return this; }
  71         public Builder accept     (String s) {accept = s;      return this; }
  72         public Builder charset    (String s) {charset = s;     return this; }
  73         public ContentType build() {
  74             //TODO Do we want to remove this implementation dependency?
  75             return new ContentTypeImpl(contentType, soapAction, accept, charset);
  76         }
  77     }
  78 }