View Javadoc

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