< prev index next >

jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/packaging/mime/internet/ContentDisposition.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2012, 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


  83         disposition = tk.getValue();
  84 
  85         // Then parameters ..
  86         String rem = h.getRemainder();
  87         if (rem != null)
  88             list = new ParameterList(rem);
  89     }
  90 
  91     /**
  92      * Return the disposition value.
  93      * @return the disposition
  94      * @since           JavaMail 1.2
  95      */
  96     public String getDisposition() {
  97         return disposition;
  98     }
  99 
 100     /**
 101      * Return the specified parameter value. Returns <code>null</code>
 102      * if this parameter is absent.

 103      * @return  parameter value
 104      * @since           JavaMail 1.2
 105      */
 106     public String getParameter(String name) {
 107         if (list == null)
 108             return null;
 109 
 110         return list.get(name);
 111     }
 112 
 113     /**
 114      * Return a ParameterList object that holds all the available
 115      * parameters. Returns null if no parameters are available.
 116      *
 117      * @return  ParameterList
 118      * @since           JavaMail 1.2
 119      */
 120     public ParameterList getParameterList() {
 121         return list;
 122     }
 123 
 124     /**
 125      * Set the primary type. Overrides existing primary type.
 126      * @param   primaryType     primary type
 127      * @since           JavaMail 1.2
 128      */
 129     public void setDisposition(String disposition) {
 130         this.disposition = disposition;
 131     }
 132 
 133     /**
 134      * Set the specified parameter. If this parameter already exists,
 135      * it is replaced by this new value.
 136      *
 137      * @param   name    parameter name
 138      * @param   value   parameter value
 139      * @since           JavaMail 1.2
 140      */
 141     public void setParameter(String name, String value) {
 142         if (list == null)
 143             list = new ParameterList();
 144 
 145         list.set(name, value);
 146     }
 147 
 148     /**
 149      * Set a new ParameterList.
 150      * @param   list    ParameterList
 151      * @since           JavaMail 1.2
 152      */
 153     public void setParameterList(ParameterList list) {
 154         this.list = list;
 155     }
 156 
 157     /**
 158      * Retrieve a RFC2045 style string representation of
 159      * this ContentDisposition. Returns <code>null</code> if
 160      * the conversion failed.
 161      *
 162      * @return  RFC2045 style string
 163      * @since           JavaMail 1.2
 164      */

 165     public String toString() {
 166         if (disposition == null)
 167             return null;
 168 
 169         if (list == null)
 170             return disposition;
 171 
 172         StringBuilder sb = new StringBuilder(disposition);
 173 
 174         // append the parameter list
 175         // use the length of the string buffer + the length of
 176         // the header name formatted as follows "Content-Disposition: "
 177         sb.append(list.toString(sb.length() + 21));
 178         return sb.toString();
 179     }
 180 }
   1 /*
   2  * Copyright (c) 1997, 2017, 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


  83         disposition = tk.getValue();
  84 
  85         // Then parameters ..
  86         String rem = h.getRemainder();
  87         if (rem != null)
  88             list = new ParameterList(rem);
  89     }
  90 
  91     /**
  92      * Return the disposition value.
  93      * @return the disposition
  94      * @since           JavaMail 1.2
  95      */
  96     public String getDisposition() {
  97         return disposition;
  98     }
  99 
 100     /**
 101      * Return the specified parameter value. Returns <code>null</code>
 102      * if this parameter is absent.
 103      * @param name parameter name.
 104      * @return  parameter value
 105      * @since           JavaMail 1.2
 106      */
 107     public String getParameter(String name) {
 108         if (list == null)
 109             return null;
 110 
 111         return list.get(name);
 112     }
 113 
 114     /**
 115      * Return a ParameterList object that holds all the available
 116      * parameters. Returns null if no parameters are available.
 117      *
 118      * @return  ParameterList
 119      * @since           JavaMail 1.2
 120      */
 121     public ParameterList getParameterList() {
 122         return list;
 123     }
 124 
 125     /**
 126      * Set the primary type. Overrides existing primary type.
 127      * @param   disposition disposition value
 128      * @since           JavaMail 1.2
 129      */
 130     public void setDisposition(String disposition) {
 131         this.disposition = disposition;
 132     }
 133 
 134     /**
 135      * Set the specified parameter. If this parameter already exists,
 136      * it is replaced by this new value.
 137      *
 138      * @param   name    parameter name
 139      * @param   value   parameter value
 140      * @since           JavaMail 1.2
 141      */
 142     public void setParameter(String name, String value) {
 143         if (list == null)
 144             list = new ParameterList();
 145 
 146         list.set(name, value);
 147     }
 148 
 149     /**
 150      * Set a new ParameterList.
 151      * @param   list    ParameterList
 152      * @since           JavaMail 1.2
 153      */
 154     public void setParameterList(ParameterList list) {
 155         this.list = list;
 156     }
 157 
 158     /**
 159      * Retrieve a RFC2045 style string representation of
 160      * this ContentDisposition. Returns <code>null</code> if
 161      * the conversion failed.
 162      *
 163      * @return  RFC2045 style string
 164      * @since           JavaMail 1.2
 165      */
 166     @Override
 167     public String toString() {
 168         if (disposition == null)
 169             return null;
 170 
 171         if (list == null)
 172             return disposition;
 173 
 174         StringBuilder sb = new StringBuilder(disposition);
 175 
 176         // append the parameter list
 177         // use the length of the string buffer + the length of
 178         // the header name formatted as follows "Content-Disposition: "
 179         sb.append(list.toString(sb.length() + 21));
 180         return sb.toString();
 181     }
 182 }
< prev index next >