Part (HttpClient Library (Version 3.1))
Date: 2016-03-09

org.apache.commons.httpclient.methods.multipart

## Class Part

- java.lang.Object
- - org.apache.commons.httpclient.methods.multipart.Part

- Direct Known Subclasses:
    PartBase

      public abstract class Part
      extends java.lang.Object

  Abstract class for one Part of a multipart post object.
  Since:
    2.0
  Author:
    Matthew Albright, Jeff Dever, Adrian Sutton, Mike Bowler, Oleg Kalnichevski

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static java.lang.String` | `BOUNDARY` Deprecated. use `HttpMethodParams.MULTIPART_BOUNDARY`
    `protected static byte[]` | `BOUNDARY_BYTES` Deprecated.
    `protected static java.lang.String` | `CHARSET` Content charset
    `protected static byte[]` | `CHARSET_BYTES` Content charset as a byte array
    `protected static java.lang.String` | `CONTENT_DISPOSITION` Content dispostion characters
    `protected static byte[]` | `CONTENT_DISPOSITION_BYTES` Content dispostion as a byte array
    `protected static java.lang.String` | `CONTENT_TRANSFER_ENCODING` Content type header
    `protected static byte[]` | `CONTENT_TRANSFER_ENCODING_BYTES` Content type header as a byte array
    `protected static java.lang.String` | `CONTENT_TYPE` Content type header
    `protected static byte[]` | `CONTENT_TYPE_BYTES` Content type header as a byte array
    `protected static java.lang.String` | `CRLF` Carriage return/linefeed
    `protected static byte[]` | `CRLF_BYTES` Carriage return/linefeed as a byte array
    `protected static java.lang.String` | `EXTRA` Extra characters
    `protected static byte[]` | `EXTRA_BYTES` Extra characters as a byte array
    `protected static java.lang.String` | `QUOTE` Content dispostion characters
    `protected static byte[]` | `QUOTE_BYTES` Content dispostion as a byte array

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Part()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.lang.String` | `getBoundary()` Deprecated. uses a constant string. Rather use `getPartBoundary()`
    `abstract java.lang.String` | `getCharSet()` Return the character encoding of this part.
    `abstract java.lang.String` | `getContentType()` Returns the content type of this part.
    `static long` | `getLengthOfParts(Part[] parts)` Return the total sum of all parts and that of the last boundary
    `static long` | `getLengthOfParts(Part[] parts, byte[] partBoundary)` Gets the length of the multipart message including the given parts.
    `abstract java.lang.String` | `getName()` Return the name of this part.
    `protected byte[]` | `getPartBoundary()` Gets the part boundary to be used.
    `abstract java.lang.String` | `getTransferEncoding()` Return the transfer encoding of this part.
    `boolean` | `isRepeatable()` Tests if this part can be sent more than once.
    `long` | `length()` Return the full length of all the data.
    `protected abstract long` | `lengthOfData()` Return the length of the main content
    `void` | `send(java.io.OutputStream out)` Write all the data to the output stream.
    `protected void` | `sendContentTypeHeader(java.io.OutputStream out)` Write the content type header to the specified output stream
    `protected abstract void` | `sendData(java.io.OutputStream out)` Write the data to the specified output stream
    `protected void` | `sendDispositionHeader(java.io.OutputStream out)` Write the content disposition header to the specified output stream
    `protected void` | `sendEnd(java.io.OutputStream out)` Write the end data to the output stream.
    `protected void` | `sendEndOfHeader(java.io.OutputStream out)` Write the end of the header to the output stream
    `static void` | `sendParts(java.io.OutputStream out, Part[] parts)` Write all parts and the last boundary to the specified output stream.
    `static void` | `sendParts(java.io.OutputStream out, Part[] parts, byte[] partBoundary)` Write all parts and the last boundary to the specified output stream.
    `protected void` | `sendStart(java.io.OutputStream out)` Write the start to the specified output stream
    `protected void` | `sendTransferEncodingHeader(java.io.OutputStream out)` Write the content transfer encoding header to the specified output stream
    `java.lang.String` | `toString()` Return a string representation of this object.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### BOUNDARY

          protected static final java.lang.String BOUNDARY

      Deprecated. use `HttpMethodParams.MULTIPART_BOUNDARY`
      The boundary
      See Also:
        Constant Field Values

    - #### BOUNDARY_BYTES

          protected static final byte[] BOUNDARY_BYTES

      Deprecated.
      The boundary as a byte array.

    - #### CRLF

          protected static final java.lang.String CRLF

      Carriage return/linefeed
      See Also:
        Constant Field Values

    - #### CRLF_BYTES

          protected static final byte[] CRLF_BYTES

      Carriage return/linefeed as a byte array

    - #### QUOTE

          protected static final java.lang.String QUOTE

      Content dispostion characters
      See Also:
        Constant Field Values

    - #### QUOTE_BYTES

          protected static final byte[] QUOTE_BYTES

      Content dispostion as a byte array

    - #### EXTRA

          protected static final java.lang.String EXTRA

      Extra characters
      See Also:
        Constant Field Values

    - #### EXTRA_BYTES

          protected static final byte[] EXTRA_BYTES

      Extra characters as a byte array

    - #### CONTENT_DISPOSITION

          protected static final java.lang.String CONTENT_DISPOSITION

      Content dispostion characters
      See Also:
        Constant Field Values

    - #### CONTENT_DISPOSITION_BYTES

          protected static final byte[] CONTENT_DISPOSITION_BYTES

      Content dispostion as a byte array

    - #### CONTENT_TYPE

          protected static final java.lang.String CONTENT_TYPE

      Content type header
      See Also:
        Constant Field Values

    - #### CONTENT_TYPE_BYTES

          protected static final byte[] CONTENT_TYPE_BYTES

      Content type header as a byte array

    - #### CHARSET

          protected static final java.lang.String CHARSET

      Content charset
      See Also:
        Constant Field Values

    - #### CHARSET_BYTES

          protected static final byte[] CHARSET_BYTES

      Content charset as a byte array

    - #### CONTENT_TRANSFER_ENCODING

          protected static final java.lang.String CONTENT_TRANSFER_ENCODING

      Content type header
      See Also:
        Constant Field Values

    - #### CONTENT_TRANSFER_ENCODING_BYTES

          protected static final byte[] CONTENT_TRANSFER_ENCODING_BYTES

      Content type header as a byte array

  - ### Constructor Detail

    - #### Part

          public Part()

  - ### Method Detail

    - #### getBoundary

          public static java.lang.String getBoundary()

      Deprecated. uses a constant string. Rather use `getPartBoundary()`
      Return the boundary string.
      Returns:
        the boundary string

    - #### getName

          public abstract java.lang.String getName()

      Return the name of this part.
      Returns:
        The name.

    - #### getContentType

          public abstract java.lang.String getContentType()

      Returns the content type of this part.
      Returns:
        the content type, or `null` to exclude the content type header

    - #### getCharSet

          public abstract java.lang.String getCharSet()

      Return the character encoding of this part.
      Returns:
        the character encoding, or `null` to exclude the character encoding header

    - #### getTransferEncoding

          public abstract java.lang.String getTransferEncoding()

      Return the transfer encoding of this part.
      Returns:
        the transfer encoding, or `null` to exclude the transfer encoding header

    - #### getPartBoundary

          protected byte[] getPartBoundary()

      Gets the part boundary to be used.
      Returns:
        the part boundary as an array of bytes.
      Since:
        3.0

    - #### isRepeatable

          public boolean isRepeatable()

      Tests if this part can be sent more than once.
      Returns:
        `true` if `sendData(OutputStream)` can be successfully called more than once.
      Since:
        3.0

    - #### sendStart

          protected void sendStart(java.io.OutputStream out)
                            throws java.io.IOException

      Write the start to the specified output stream
      Parameters:
        `out` - The output stream
      Throws:
        `java.io.IOException` - If an IO problem occurs.

    - #### sendDispositionHeader

          protected void sendDispositionHeader(java.io.OutputStream out)
                                        throws java.io.IOException

      Write the content disposition header to the specified output stream
      Parameters:
        `out` - The output stream
      Throws:
        `java.io.IOException` - If an IO problem occurs.

    - #### sendContentTypeHeader

          protected void sendContentTypeHeader(java.io.OutputStream out)
                                        throws java.io.IOException

      Write the content type header to the specified output stream
      Parameters:
        `out` - The output stream
      Throws:
        `java.io.IOException` - If an IO problem occurs.

    - #### sendTransferEncodingHeader

          protected void sendTransferEncodingHeader(java.io.OutputStream out)
                                             throws java.io.IOException

      Write the content transfer encoding header to the specified output stream
      Parameters:
        `out` - The output stream
      Throws:
        `java.io.IOException` - If an IO problem occurs.

    - #### sendEndOfHeader

          protected void sendEndOfHeader(java.io.OutputStream out)
                                  throws java.io.IOException

      Write the end of the header to the output stream
      Parameters:
        `out` - The output stream
      Throws:
        `java.io.IOException` - If an IO problem occurs.

    - #### sendData

          protected abstract void sendData(java.io.OutputStream out)
                                    throws java.io.IOException

      Write the data to the specified output stream
      Parameters:
        `out` - The output stream
      Throws:
        `java.io.IOException` - If an IO problem occurs.

    - #### lengthOfData

          protected abstract long lengthOfData()
                                        throws java.io.IOException

      Return the length of the main content
      Returns:
        long The length.
      Throws:
        `java.io.IOException` - If an IO problem occurs

    - #### sendEnd

          protected void sendEnd(java.io.OutputStream out)
                          throws java.io.IOException

      Write the end data to the output stream.
      Parameters:
        `out` - The output stream
      Throws:
        `java.io.IOException` - If an IO problem occurs.

    - #### send

          public void send(java.io.OutputStream out)
                    throws java.io.IOException

      Write all the data to the output stream. If you override this method make sure to override #length() as well
      Parameters:
        `out` - The output stream
      Throws:
        `java.io.IOException` - If an IO problem occurs.

    - #### length

          public long length()
                      throws java.io.IOException

      Return the full length of all the data. If you override this method make sure to override #send(OutputStream) as well
      Returns:
        long The length.
      Throws:
        `java.io.IOException` - If an IO problem occurs

    - #### toString

          public java.lang.String toString()

      Return a string representation of this object.
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        A string representation of this object.
      See Also:
        `Object.toString()`

    - #### sendParts

          public static void sendParts(java.io.OutputStream out,
                       Part[] parts)
                                throws java.io.IOException

      Write all parts and the last boundary to the specified output stream.
      Parameters:
        `out` - The stream to write to.
        `parts` - The parts to write.
      Throws:
        `java.io.IOException` - If an I/O error occurs while writing the parts.

    - #### sendParts

          public static void sendParts(java.io.OutputStream out,
                       Part[] parts,
                       byte[] partBoundary)
                                throws java.io.IOException

      Write all parts and the last boundary to the specified output stream.
      Parameters:
        `out` - The stream to write to.
        `parts` - The parts to write.
        `partBoundary` - The ASCII bytes to use as the part boundary.
      Throws:
        `java.io.IOException` - If an I/O error occurs while writing the parts.
      Since:
        3.0

    - #### getLengthOfParts

          public static long getLengthOfParts(Part[] parts)
                                       throws java.io.IOException

      Return the total sum of all parts and that of the last boundary
      Parameters:
        `parts` - The parts.
      Returns:
        The total length
      Throws:
        `java.io.IOException` - If an I/O error occurs while writing the parts.

    - #### getLengthOfParts

          public static long getLengthOfParts(Part[] parts,
                              byte[] partBoundary)
                                       throws java.io.IOException

      Gets the length of the multipart message including the given parts.
      Parameters:
        `parts` - The parts.
        `partBoundary` - The ASCII bytes to use as the part boundary.
      Returns:
        The total length
      Throws:
        `java.io.IOException` - If an I/O error occurs while writing the parts.
      Since:
        3.0

Copyright (c) 1999-2005 - Apache Software Foundation