Home | History | Annotate | Download | only in multipart
      1 /*
      2  * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/methods/multipart/PartBase.java,v 1.5 2004/04/18 23:51:37 jsdever Exp $
      3  * $Revision: 480424 $
      4  * $Date: 2006-11-29 06:56:49 +0100 (Wed, 29 Nov 2006) $
      5  *
      6  * ====================================================================
      7  *
      8  *  Licensed to the Apache Software Foundation (ASF) under one or more
      9  *  contributor license agreements.  See the NOTICE file distributed with
     10  *  this work for additional information regarding copyright ownership.
     11  *  The ASF licenses this file to You under the Apache License, Version 2.0
     12  *  (the "License"); you may not use this file except in compliance with
     13  *  the License.  You may obtain a copy of the License at
     14  *
     15  *      http://www.apache.org/licenses/LICENSE-2.0
     16  *
     17  *  Unless required by applicable law or agreed to in writing, software
     18  *  distributed under the License is distributed on an "AS IS" BASIS,
     19  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     20  *  See the License for the specific language governing permissions and
     21  *  limitations under the License.
     22  * ====================================================================
     23  *
     24  * This software consists of voluntary contributions made by many
     25  * individuals on behalf of the Apache Software Foundation.  For more
     26  * information on the Apache Software Foundation, please see
     27  * <http://www.apache.org/>.
     28  *
     29  */
     30 
     31 package com.android.internal.http.multipart;
     32 
     33 
     34 /**
     35  * Provides setters and getters for the basic Part properties.
     36  *
     37  * @author Michael Becke
     38  */
     39 public abstract class PartBase extends Part {
     40 
     41     /** Name of the file part. */
     42     private String name;
     43 
     44     /** Content type of the file part. */
     45     private String contentType;
     46 
     47     /** Content encoding of the file part. */
     48     private String charSet;
     49 
     50     /** The transfer encoding. */
     51     private String transferEncoding;
     52 
     53     /**
     54      * Constructor.
     55      *
     56      * @param name The name of the part
     57      * @param contentType The content type, or <code>null</code>
     58      * @param charSet The character encoding, or <code>null</code>
     59      * @param transferEncoding The transfer encoding, or <code>null</code>
     60      */
     61     public PartBase(String name, String contentType, String charSet, String transferEncoding) {
     62 
     63         if (name == null) {
     64             throw new IllegalArgumentException("Name must not be null");
     65         }
     66         this.name = name;
     67         this.contentType = contentType;
     68         this.charSet = charSet;
     69         this.transferEncoding = transferEncoding;
     70     }
     71 
     72     /**
     73      * Returns the name.
     74      * @return The name.
     75      * @see Part#getName()
     76      */
     77     @Override
     78     public String getName() {
     79         return this.name;
     80     }
     81 
     82     /**
     83      * Returns the content type of this part.
     84      * @return String The name.
     85      */
     86     @Override
     87     public String getContentType() {
     88         return this.contentType;
     89     }
     90 
     91     /**
     92      * Return the character encoding of this part.
     93      * @return String The name.
     94      */
     95     @Override
     96     public String getCharSet() {
     97         return this.charSet;
     98     }
     99 
    100     /**
    101      * Returns the transfer encoding of this part.
    102      * @return String The name.
    103      */
    104     @Override
    105     public String getTransferEncoding() {
    106         return transferEncoding;
    107     }
    108 
    109     /**
    110      * Sets the character encoding.
    111      *
    112      * @param charSet the character encoding, or <code>null</code> to exclude the character
    113      * encoding header
    114      */
    115     public void setCharSet(String charSet) {
    116         this.charSet = charSet;
    117     }
    118 
    119     /**
    120      * Sets the content type.
    121      *
    122      * @param contentType the content type, or <code>null</code> to exclude the content type header
    123      */
    124     public void setContentType(String contentType) {
    125         this.contentType = contentType;
    126     }
    127 
    128     /**
    129      * Sets the part name.
    130      *
    131      * @param name
    132      */
    133     public void setName(String name) {
    134         if (name == null) {
    135             throw new IllegalArgumentException("Name must not be null");
    136         }
    137         this.name = name;
    138     }
    139 
    140     /**
    141      * Sets the transfer encoding.
    142      *
    143      * @param transferEncoding the transfer encoding, or <code>null</code> to exclude the
    144      * transfer encoding header
    145      */
    146     public void setTransferEncoding(String transferEncoding) {
    147         this.transferEncoding = transferEncoding;
    148     }
    149 
    150 }
    151