1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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 }