Class Form

All Implemented Interfaces:
Serializable

public class Form extends Validator
Author:
svenkubiak
See Also:
  • Constructor Details

    • Form

      public Form()
  • Method Details

    • getString

      public Optional<String> getString(String key)
      Retrieves an optional string value corresponding to the name of the form element
      Parameters:
      key - The name of the form element
      Returns:
      Optional of String
    • getValue

      public String getValue(String key)
      Retrieves a string value corresponding to the name of the form element
      Parameters:
      key - The name of the form element
      Returns:
      String with the value of the form element or an empty value if blank
    • getBoolean

      public Optional<Boolean> getBoolean(String key)
      Retrieves an optional boolean value corresponding to the name of the form element 0 maps to false 1 maps to true "true" maps to true "false" maps to false
      Parameters:
      key - The name of the form element
      Returns:
      Optional of Boolean
    • getInteger

      public Optional<Integer> getInteger(String key)
      Retrieves an optional integer value corresponding to the name of the form element
      Parameters:
      key - The name of the form element
      Returns:
      Optional of Integer
    • getDouble

      public Optional<Double> getDouble(String key)
      Retrieves an optional double value corresponding to the name of the form element
      Parameters:
      key - The name of the form element
      Returns:
      Optional of Double
    • getFloat

      public Optional<Float> getFloat(String key)
      Retrieves an optional float value corresponding to the name of the form element
      Parameters:
      key - The name of the form element
      Returns:
      Optional of Float
    • getFiles

      public List<InputStream> getFiles()
      Retrieves all attachment files of the form
      Returns:
      List of files or an empty list
    • getFile

      public Optional<InputStream> getFile()
      Retrieves a single file of the form. If the form has multiple files, the first will be returned
      Returns:
      File or null if no file is present
    • getValues

      public Map<String,String> getValues()
      Retrieves all form submitted values where the key of the map corresponds to the name of the form element and the value is the value of the form element
      Returns:
      Map with Key-Value elements or empty map
    • addFile

      public void addFile(InputStream inputStream)
      Adds a file as an InputStream to the form
      Parameters:
      inputStream - The InputStream to add
    • keep

      public void keep()
      Adds the form values to the flash scope
    • addValueList

      public void addValueList(String key, String value)
      Adds an item to the value list
      Parameters:
      key - The name of the form element
      value - The value to store
    • getValueList

      public List<String> getValueList(String key)
      Retrieves the value list for a given key
      Parameters:
      key - The name of the form element
      Returns:
      A value list with elements
    • isKept

      public boolean isKept()
      Checks if the form values are to put in the flash scope
      Returns:
      True if form values should be put into flash scope, false otherwise
    • discard

      public void discard()
      Discards the complete form
    • toObject

      public <T> T toObject(Class<?> clazz)
      Converts the current form into a given object class
      Type Parameters:
      T - Ignored
      Parameters:
      clazz - The class to convert to
      Returns:
      The converted object or null if conversion fails
    • isSubmitted

      public boolean isSubmitted()
    • setSubmitted

      public void setSubmitted(boolean submitted)