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 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 }