View Javadoc

    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 org.apache.commons.httpclient.methods.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 org.apache.commons.httpclient.methods.multipart.Part#getName()
    76       */
    77      public String getName() {
    78          return this.name;
    79      }
    80
    81      /**
    82       * Returns the content type of this part.
    83       * @return String The name.
    84       */
    85      public String getContentType() {
    86          return this.contentType;
    87      }
    88
    89      /**
    90       * Return the character encoding of this part.
    91       * @return String The name.
    92       */
    93      public String getCharSet() {
    94          return this.charSet;
    95      }
    96
    97      /**
    98       * Returns the transfer encoding of this part.
    99       * @return String The name.
    100      */
    101     public String getTransferEncoding() {
    102         return transferEncoding;
    103     }
    104
    105     /**
    106      * Sets the character encoding.
    107      *
    108      * @param charSet the character encoding, or <code>null</code> to exclude the character
    109      * encoding header
    110      */
    111     public void setCharSet(String charSet) {
    112         this.charSet = charSet;
    113     }
    114
    115     /**
    116      * Sets the content type.
    117      *
    118      * @param contentType the content type, or <code>null</code> to exclude the content type header
    119      */
    120     public void setContentType(String contentType) {
    121         this.contentType = contentType;
    122     }
    123
    124     /**
    125      * Sets the part name.
    126      *
    127      * @param name
    128      */
    129     public void setName(String name) {
    130         if (name == null) {
    131             throw new IllegalArgumentException("Name must not be null");
    132         }
    133         this.name = name;
    134     }
    135
    136     /**
    137      * Sets the transfer encoding.
    138      *
    139      * @param transferEncoding the transfer encoding, or <code>null</code> to exclude the
    140      * transfer encoding header
    141      */
    142     public void setTransferEncoding(String transferEncoding) {
    143         this.transferEncoding = transferEncoding;
    144     }
    145
    146 }