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