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
-
-
Constructor Summary
Constructors Constructor Description Part()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static java.lang.String
getBoundary()
Deprecated.uses a constant string.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 boundarystatic 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.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.void
send(java.io.OutputStream out)
Write all the data 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.java.lang.String
toString()
Return a string representation of this object.
-
-
-
Method Detail
-
getBoundary
public static java.lang.String getBoundary()
Deprecated.uses a constant string. Rather usegetPartBoundary()
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
-
isRepeatable
public boolean isRepeatable()
Tests if this part can be sent more than once.- Returns:
true
ifsendData(OutputStream)
can be successfully called more than once.- Since:
- 3.0
-
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 classjava.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
-
-