Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.commons.httpclient.methods.multipart
Class Part  view Part download Part.java

java.lang.Object
  extended byorg.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

Field Summary
protected static java.lang.String BOUNDARY
          Deprecated. use HttpMethodParams.MULTIPART_BOUNDARY>HttpMethodParams.MULTIPART_BOUNDARY 55
protected static byte[] BOUNDARY_BYTES
          Deprecated.  
private  byte[] boundaryBytes
          The ASCII bytes to use as the multipart boundary.
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
private static byte[] DEFAULT_BOUNDARY_BYTES
          The default boundary to be used if {@link #setBoundaryBytes(byte[])) has not been called.
protected static java.lang.String EXTRA
          Extra characters
protected static byte[] EXTRA_BYTES
          Extra characters as a byte array
private static org.apache.commons.logging.Log LOG
          Log object for this class.
protected static java.lang.String QUOTE
          Content dispostion characters
protected static byte[] QUOTE_BYTES
          Content dispostion as a byte array
 
Constructor Summary
Part()
           
 
Method Summary
static java.lang.String getBoundary()
          Deprecated.  
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
(package private)  void setPartBoundary(byte[] boundaryBytes)
          Sets the part boundary.
 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

LOG

private static final org.apache.commons.logging.Log LOG
Log object for this class.


BOUNDARY

protected static final java.lang.String BOUNDARY
Deprecated. use HttpMethodParams.MULTIPART_BOUNDARY>HttpMethodParams.MULTIPART_BOUNDARY 55

The boundary

See Also:
Constant Field Values

BOUNDARY_BYTES

protected static final byte[] BOUNDARY_BYTES
Deprecated.  

The boundary as a byte array.


DEFAULT_BOUNDARY_BYTES

private static final byte[] DEFAULT_BOUNDARY_BYTES
The default boundary to be used if {@link #setBoundaryBytes(byte[])) has not been called.


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


boundaryBytes

private byte[] boundaryBytes
The ASCII bytes to use as the multipart boundary.

Constructor Detail

Part

public Part()
Method Detail

getBoundary

public static java.lang.String getBoundary()
Deprecated.  

Return the boundary string.


getName

public abstract java.lang.String getName()
Return the name of this part.


getContentType

public abstract java.lang.String getContentType()
Returns the content type of this part.


getCharSet

public abstract java.lang.String getCharSet()
Return the character encoding of this part.


getTransferEncoding

public abstract java.lang.String getTransferEncoding()
Return the transfer encoding of this part.


getPartBoundary

protected byte[] getPartBoundary()
Gets the part boundary to be used.

Since:
3.0

setPartBoundary

void setPartBoundary(byte[] boundaryBytes)
Sets the part boundary. Only meant to be used by sendParts(OutputStream, Part[], byte[]) 55 and getLengthOfParts(Part[], byte[]) 55

Since:
3.0

isRepeatable

public boolean isRepeatable()
Tests if this part can be sent 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


sendDispositionHeader

protected void sendDispositionHeader(java.io.OutputStream out)
                              throws java.io.IOException
Write the content disposition header to the specified output stream


sendContentTypeHeader

protected void sendContentTypeHeader(java.io.OutputStream out)
                              throws java.io.IOException
Write the content type header to the specified output stream


sendTransferEncodingHeader

protected void sendTransferEncodingHeader(java.io.OutputStream out)
                                   throws java.io.IOException
Write the content transfer encoding header to the specified output stream


sendEndOfHeader

protected void sendEndOfHeader(java.io.OutputStream out)
                        throws java.io.IOException
Write the end of the header to the output stream


sendData

protected abstract void sendData(java.io.OutputStream out)
                          throws java.io.IOException
Write the data to the specified output stream


lengthOfData

protected abstract long lengthOfData()
                              throws java.io.IOException
Return the length of the main content


sendEnd

protected void sendEnd(java.io.OutputStream out)
                throws java.io.IOException
Write the end data to the output stream.


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


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


toString

public java.lang.String toString()
Return a string representation of this object.


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.


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.

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


getLengthOfParts

public static long getLengthOfParts(Part[] parts,
                                    byte[] partBoundary)
                             throws java.io.IOException
Gets the length of the multipart message including the given parts.

Since:
3.0