Class FormItem

java.lang.Object
org.javalite.activeweb.FormItem
Direct Known Subclasses:
FileItem

public class FormItem extends Object
Represents an form item from a multi-part form.
Author:
Igor Polevoy
  • Constructor Details

    • FormItem

      public FormItem(String name, String fieldName, boolean isFile, String contentType, byte[] content)
      This constructor is used for testing.
      Parameters:
      name - name of a file.
      fieldName - name of a field.
      isFile - true if this is a file, false if not.
      contentType - content type for this file.
      content - content in bytes.
  • Method Details

    • getName

      public String getName()
      File name.
      Returns:
      file name.
    • getFileName

      public String getFileName()
      File name.
      Returns:
      file name.
    • getFieldName

      public String getFieldName()
      Form field name.
      Returns:
      form field name
    • isFile

      public boolean isFile()
      Returns true if this is a file, false if not.
      Returns:
      true if this is a file, false if not.
    • getContentType

      public String getContentType()
      Content type of this form field.
      Returns:
      content type of this form field.
    • isFormField

      public boolean isFormField()
      returns true if this is a form field, false if not.
      Returns:
      true if this is a form field, false if not.
    • getInputStream

      public InputStream getInputStream()
      Returns input stream to read uploaded file contents from.
      Returns:
      input stream to read uploaded file contents from.
    • getStreamAsString

      public String getStreamAsString()
      Converts entire content of this item to String.
      Returns:
      content streamed from this field as string.
    • getBytes

      public byte[] getBytes()
      Reads contents of a file into a byte array at once.
      Returns:
      contents of a file as byte array.
    • saveTo

      public void saveTo(String path) throws IOException
      Saves content of this item to a file.
      Parameters:
      path - to file
      Throws:
      IOException