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