Class PartBase

java.lang.Object
com.ning.http.client.multipart.PartBase
All Implemented Interfaces:
Part
Direct Known Subclasses:
AbstractFilePart, StringPart

public abstract class PartBase extends Object implements Part
  • Field Details

  • Constructor Details

    • PartBase

      public PartBase(String name, String contentType, Charset charset, String contentId)
    • PartBase

      public PartBase(String name, String contentType, Charset charset, String contentId, String transferEncoding)
      Constructor.
      Parameters:
      name - The name of the part, or null
      contentType - The content type, or null
      charset - The character encoding, or null
      contentId - The content id, or null
      transferEncoding - The transfer encoding, or null
  • Method Details

    • visitStart

      protected void visitStart(PartVisitor visitor, byte[] boundary) throws IOException
      Throws:
      IOException
    • visitDispositionHeader

      protected void visitDispositionHeader(PartVisitor visitor) throws IOException
      Throws:
      IOException
    • visitContentTypeHeader

      protected void visitContentTypeHeader(PartVisitor visitor) throws IOException
      Throws:
      IOException
    • visitTransferEncodingHeader

      protected void visitTransferEncodingHeader(PartVisitor visitor) throws IOException
      Throws:
      IOException
    • visitContentIdHeader

      protected void visitContentIdHeader(PartVisitor visitor) throws IOException
      Throws:
      IOException
    • visitCustomHeaders

      protected void visitCustomHeaders(PartVisitor visitor) throws IOException
      Throws:
      IOException
    • visitEndOfHeaders

      protected void visitEndOfHeaders(PartVisitor visitor) throws IOException
      Throws:
      IOException
    • visitEnd

      protected void visitEnd(PartVisitor visitor) throws IOException
      Throws:
      IOException
    • getDataLength

      protected abstract long getDataLength()
    • sendData

      protected abstract void sendData(OutputStream out) throws IOException
      Throws:
      IOException
    • write

      public void write(OutputStream out, byte[] boundary) throws IOException
      Write all the data to the output stream. If you override this method make sure to override #length() as well
      Specified by:
      write in interface Part
      Parameters:
      out - The output stream
      boundary - the boundary
      Throws:
      IOException - If an IO problem occurs.
    • length

      public long length(byte[] boundary)
      Return the full length of all the data. If you override this method make sure to override #send(OutputStream) as well
      Specified by:
      length in interface Part
      Returns:
      long The length.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getName

      public String getName()
      Description copied from interface: Part
      Return the name of this part.
      Specified by:
      getName in interface Part
      Returns:
      The name.
    • getContentType

      public String getContentType()
      Description copied from interface: Part
      Returns the content type of this part.
      Specified by:
      getContentType in interface Part
      Returns:
      the content type, or null to exclude the content type header
    • getCharset

      public Charset getCharset()
      Description copied from interface: Part
      Return the character encoding of this part.
      Specified by:
      getCharset in interface Part
      Returns:
      the character encoding, or null to exclude the character encoding header
    • getTransferEncoding

      public String getTransferEncoding()
      Description copied from interface: Part
      Return the transfer encoding of this part.
      Specified by:
      getTransferEncoding in interface Part
      Returns:
      the transfer encoding, or null to exclude the transfer encoding header
    • getContentId

      public String getContentId()
      Description copied from interface: Part
      Return the content ID of this part.
      Specified by:
      getContentId in interface Part
      Returns:
      the content ID, or null to exclude the content ID header
    • getDispositionType

      public String getDispositionType()
      Description copied from interface: Part
      Gets the disposition-type to be used in Content-Disposition header
      Specified by:
      getDispositionType in interface Part
      Returns:
      the disposition-type
    • setDispositionType

      public void setDispositionType(String dispositionType)
    • addCustomHeader

      public void addCustomHeader(String name, String value)
    • setCustomHeaders

      public void setCustomHeaders(List<Param> customHeaders)