Class FormReader


  • public class FormReader
    extends java.lang.Object
    Form reader.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private CharacterSet characterSet
      The encoding to use, decoding is enabled, see decoding.
      private boolean decoding
      Indicates if the entries should be decoded.
      private char separator
      The separator character used between entries.
      private java.io.InputStream stream
      The form stream.
    • Constructor Summary

      Constructors 
      Constructor Description
      FormReader​(java.lang.String queryString, char separator)
      Constructor.
      FormReader​(java.lang.String queryString, CharacterSet characterSet, char separator)
      Constructor.
      FormReader​(Representation representation)
      Constructor.
      In case the representation does not define a character set, the UTF-8 character set is used.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addEntries​(Series<FormData> entries)
      Adds the entries into a given series.
      Series<FormData> read()
      Reads all the entries.
      void readEntries​(java.util.Map<java.lang.String,​java.lang.Object> entries)
      Reads the entries whose name is a key in the given map.
      java.lang.Object readEntry​(java.lang.String name)
      Reads the entries with the given name.
      FormData readFirstEntry​(java.lang.String name)
      Reads the first entry with the given name.
      FormData readNextEntry()
      Reads the next entry available or null.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • characterSet

        private volatile CharacterSet characterSet
        The encoding to use, decoding is enabled, see decoding.
      • decoding

        private volatile boolean decoding
        Indicates if the entries should be decoded.
      • separator

        private volatile char separator
        The separator character used between entries.
      • stream

        private volatile java.io.InputStream stream
        The form stream.
    • Constructor Detail

      • FormReader

        public FormReader​(Representation representation)
                   throws java.io.IOException
        Constructor.
        In case the representation does not define a character set, the UTF-8 character set is used.
        Parameters:
        representation - The web form content.
        Throws:
        java.io.IOException - if the stream of the representation could not be opened.
      • FormReader

        public FormReader​(java.lang.String queryString,
                          char separator)
        Constructor. Will leave the parsed data encoded.
        Parameters:
        queryString - The query string.
      • FormReader

        public FormReader​(java.lang.String queryString,
                          CharacterSet characterSet,
                          char separator)
        Constructor.
        Parameters:
        queryString - The query string.
        characterSet - The supported character encoding. Set to null to leave the data encoded.
    • Method Detail

      • addEntries

        public void addEntries​(Series<FormData> entries)
        Adds the entries into a given series.
        Parameters:
        entries - The target series of entries.
      • read

        public Series<FormData> read()
                              throws java.io.IOException
        Reads all the entries.
        Returns:
        The form read.
        Throws:
        java.io.IOException - If the entries could not be read.
      • readEntries

        public void readEntries​(java.util.Map<java.lang.String,​java.lang.Object> entries)
                         throws java.io.IOException
        Reads the entries whose name is a key in the given map. If a matching entry is found, its value is put in the map. If multiple values are found, a list is created and set in the map.
        Parameters:
        entries - The entries map controlling the reading.
        Throws:
        java.io.IOException - If the entries could not be read.
      • readEntry

        public java.lang.Object readEntry​(java.lang.String name)
                                   throws java.io.IOException
        Reads the entries with the given name. If multiple values are found, a list is returned created.
        Parameters:
        name - The entry name to match.
        Returns:
        The entry value or list of values.
        Throws:
        java.io.IOException - If the entry could not be read.
      • readFirstEntry

        public FormData readFirstEntry​(java.lang.String name)
                                throws java.io.IOException
        Reads the first entry with the given name.
        Parameters:
        name - The entry name to match.
        Returns:
        The entry value.
        Throws:
        java.io.IOException
      • readNextEntry

        public FormData readNextEntry()
                               throws java.io.IOException
        Reads the next entry available or null.
        Returns:
        The next entry available or null.
        Throws:
        java.io.IOException - If the next entry could not be read.