Class Part

java.lang.Object
com.blackrook.small.multipart.Part

public class Part extends Object
Multipart part that is part of a multiform request.
Author:
Matthew Tropiano
  • Constructor Details

    • Part

      public Part()
  • Method Details

    • getName

      public String getName()
      Returns:
      the name of this part (parameter name).
    • isFile

      public boolean isFile()
      Returns if this part refers to a file.
      Returns:
      true if so, false if not.
    • getFileName

      public String getFileName()
      Returns:
      the original file name of the file, or null if not a file.
      See Also:
    • getFile

      public File getFile()
      Returns a handle to this file, or null if not a file.

      NOTE: You cannot guarantee that this file handle will be valid after the handled request, as it may be deleted after the controller processes the POST!

      If you need to keep this file around, it should be copied to another file!

      Returns:
      the file on this part, or null if not a file.
      See Also:
    • getLength

      public long getLength()
      Returns the length of this part. If file, this is the file length in bytes. If value, this is the value length in characters.
      Returns:
      the length.
    • getContentType

      public String getContentType()
      Returns:
      the content type of the uploaded file, or null if not a file.
      See Also:
    • getValue

      public String getValue()
      Returns:
      this part's value, if it is not a file.
    • setName

      public void setName(String name)
      Sets the name of this Part.
      Parameters:
      name - the name.
    • setFileName

      public void setFileName(String fileName)
      Sets the file name of this Part.
      Parameters:
      fileName - the file name.
    • setFile

      public void setFile(File file)
      Sets the file on this part.
      Parameters:
      file - the file descriptor.
    • setContentType

      public void setContentType(String contentType)
      Sets the content type on this part.
      Parameters:
      contentType - the content type (MIME type)
    • setValue

      public void setValue(String value)
      Sets the value of this part, if not a file.
      Parameters:
      value - the parameter value.