Source code: org/apache/commons/httpclient/methods/multipart/PartBase.java
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: 155418 $
4 * $Date: 2005-02-26 08:01:52 -0500 (Sat, 26 Feb 2005) $
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 */
29
30 package org.apache.commons.httpclient.methods.multipart;
31
32
33 /**
34 * Provides setters and getters for the basic Part properties.
35 *
36 * @author Michael Becke
37 */
38 public abstract class PartBase extends Part {
39
40 /** Name of the file part. */
41 private String name;
42
43 /** Content type of the file part. */
44 private String contentType;
45
46 /** Content encoding of the file part. */
47 private String charSet;
48
49 /** The transfer encoding. */
50 private String transferEncoding;
51
52 /**
53 * Constructor.
54 *
55 * @param name The name of the part
56 * @param contentType The content type, or <code>null</code>
57 * @param charSet The character encoding, or <code>null</code>
58 * @param transferEncoding The transfer encoding, or <code>null</code>
59 */
60 public PartBase(String name, String contentType, String charSet, String transferEncoding) {
61
62 if (name == null) {
63 throw new IllegalArgumentException("Name must not be null");
64 }
65 this.name = name;
66 this.contentType = contentType;
67 this.charSet = charSet;
68 this.transferEncoding = transferEncoding;
69 }
70
71 /**
72 * Returns the name.
73 * @return The name.
74 * @see org.apache.commons.httpclient.methods.multipart.Part#getName()
75 */
76 public String getName() {
77 return this.name;
78 }
79
80 /**
81 * Returns the content type of this part.
82 * @return String The name.
83 */
84 public String getContentType() {
85 return this.contentType;
86 }
87
88 /**
89 * Return the character encoding of this part.
90 * @return String The name.
91 */
92 public String getCharSet() {
93 return this.charSet;
94 }
95
96 /**
97 * Returns the transfer encoding of this part.
98 * @return String The name.
99 */
100 public String getTransferEncoding() {
101 return transferEncoding;
102 }
103
104 /**
105 * Sets the character encoding.
106 *
107 * @param charSet the character encoding, or <code>null</code> to exclude the character
108 * encoding header
109 */
110 public void setCharSet(String charSet) {
111 this.charSet = charSet;
112 }
113
114 /**
115 * Sets the content type.
116 *
117 * @param contentType the content type, or <code>null</code> to exclude the content type header
118 */
119 public void setContentType(String contentType) {
120 this.contentType = contentType;
121 }
122
123 /**
124 * Sets the part name.
125 *
126 * @param name
127 */
128 public void setName(String name) {
129 if (name == null) {
130 throw new IllegalArgumentException("Name must not be null");
131 }
132 this.name = name;
133 }
134
135 /**
136 * Sets the transfer encoding.
137 *
138 * @param transferEncoding the transfer encoding, or <code>null</code> to exclude the
139 * transfer encoding header
140 */
141 public void setTransferEncoding(String transferEncoding) {
142 this.transferEncoding = transferEncoding;
143 }
144
145 }