001: /*
002: * $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 $
003: * $Revision: 480424 $
004: * $Date: 2006-11-29 06:56:49 +0100 (Wed, 29 Nov 2006) $
005: *
006: * ====================================================================
007: *
008: * Licensed to the Apache Software Foundation (ASF) under one or more
009: * contributor license agreements. See the NOTICE file distributed with
010: * this work for additional information regarding copyright ownership.
011: * The ASF licenses this file to You under the Apache License, Version 2.0
012: * (the "License"); you may not use this file except in compliance with
013: * the License. You may obtain a copy of the License at
014: *
015: * http://www.apache.org/licenses/LICENSE-2.0
016: *
017: * Unless required by applicable law or agreed to in writing, software
018: * distributed under the License is distributed on an "AS IS" BASIS,
019: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
020: * See the License for the specific language governing permissions and
021: * limitations under the License.
022: * ====================================================================
023: *
024: * This software consists of voluntary contributions made by many
025: * individuals on behalf of the Apache Software Foundation. For more
026: * information on the Apache Software Foundation, please see
027: * <http://www.apache.org/>.
028: *
029: */
030:
031: package org.apache.commons.httpclient.methods.multipart;
032:
033: /**
034: * Provides setters and getters for the basic Part properties.
035: *
036: * @author Michael Becke
037: */
038: public abstract class PartBase extends Part {
039:
040: /** Name of the file part. */
041: private String name;
042:
043: /** Content type of the file part. */
044: private String contentType;
045:
046: /** Content encoding of the file part. */
047: private String charSet;
048:
049: /** The transfer encoding. */
050: private String transferEncoding;
051:
052: /**
053: * Constructor.
054: *
055: * @param name The name of the part
056: * @param contentType The content type, or <code>null</code>
057: * @param charSet The character encoding, or <code>null</code>
058: * @param transferEncoding The transfer encoding, or <code>null</code>
059: */
060: public PartBase(String name, String contentType, String charSet,
061: String transferEncoding) {
062:
063: if (name == null) {
064: throw new IllegalArgumentException("Name must not be null");
065: }
066: this .name = name;
067: this .contentType = contentType;
068: this .charSet = charSet;
069: this .transferEncoding = transferEncoding;
070: }
071:
072: /**
073: * Returns the name.
074: * @return The name.
075: * @see org.apache.commons.httpclient.methods.multipart.Part#getName()
076: */
077: public String getName() {
078: return this .name;
079: }
080:
081: /**
082: * Returns the content type of this part.
083: * @return String The name.
084: */
085: public String getContentType() {
086: return this .contentType;
087: }
088:
089: /**
090: * Return the character encoding of this part.
091: * @return String The name.
092: */
093: public String getCharSet() {
094: return this .charSet;
095: }
096:
097: /**
098: * Returns the transfer encoding of this part.
099: * @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: }
|