Class FormUtils


  • public class FormUtils
    extends java.lang.Object
    Representation of a Web form containing submitted parameters.
    Author:
    Jerome Louvel
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.restlet.data.Parameter create​(java.lang.CharSequence name, java.lang.CharSequence value, boolean decode, org.restlet.data.CharacterSet characterSet)
      Creates a parameter.
      static org.restlet.data.Parameter getFirstParameter​(java.lang.String query, java.lang.String name, org.restlet.data.CharacterSet characterSet, char separator, boolean decode)
      Reads the first parameter with the given name.
      static org.restlet.data.Parameter getFirstParameter​(org.restlet.representation.Representation post, java.lang.String name)
      Reads the first parameter with the given name.
      static java.lang.Object getParameter​(java.lang.String query, java.lang.String name, org.restlet.data.CharacterSet characterSet, char separator, boolean decode)
      Reads the parameters with the given name.
      If multiple values are found, a list is returned created.
      static java.lang.Object getParameter​(org.restlet.representation.Representation form, java.lang.String name)
      Reads the parameters with the given name.
      If multiple values are found, a list is returned created.
      static void getParameters​(java.lang.String parametersString, java.util.Map<java.lang.String,​java.lang.Object> parameters, org.restlet.data.CharacterSet characterSet, char separator, boolean decode)
      Reads the parameters whose name is a key in the given map.
      If a matching parameter is found, its value is put in the map.
      If multiple values are found, a list is created and set in the map.
      static void getParameters​(org.restlet.representation.Representation post, java.util.Map<java.lang.String,​java.lang.Object> parameters)
      Reads the parameters whose name is a key in the given map.
      If a matching parameter is found, its value is put in the map.
      If multiple values are found, a list is created and set in the map.
      static boolean isParameterFound​(org.restlet.data.Parameter searchedParam, org.restlet.data.MediaType mediaRange)
      Indicates if the searched parameter is specified in the given media range.
      static void parse​(org.restlet.data.Form form, java.lang.String parametersString, org.restlet.data.CharacterSet characterSet, boolean decode, char separator)
      Parses a parameters string into a given form.
      static void parse​(org.restlet.data.Form form, org.restlet.representation.Representation post, boolean decode)
      Parses a post into a given form.
      • Methods inherited from class java.lang.Object

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

      • create

        public static org.restlet.data.Parameter create​(java.lang.CharSequence name,
                                                        java.lang.CharSequence value,
                                                        boolean decode,
                                                        org.restlet.data.CharacterSet characterSet)
        Creates a parameter.
        Parameters:
        name - The parameter name buffer.
        value - The parameter value buffer (can be null).
        decode - If true, the name and values are decoded with the given CharacterSet, if false, than nothing is decoded.
        characterSet - The supported character encoding.
        Returns:
        The created parameter.
      • getFirstParameter

        public static org.restlet.data.Parameter getFirstParameter​(org.restlet.representation.Representation post,
                                                                   java.lang.String name)
                                                            throws java.io.IOException
        Reads the first parameter with the given name.
        Parameters:
        post - The web form representation.
        name - The parameter name to match.
        Returns:
        The parameter.
        Throws:
        java.io.IOException
      • getFirstParameter

        public static org.restlet.data.Parameter getFirstParameter​(java.lang.String query,
                                                                   java.lang.String name,
                                                                   org.restlet.data.CharacterSet characterSet,
                                                                   char separator,
                                                                   boolean decode)
                                                            throws java.io.IOException
        Reads the first parameter with the given name.
        Parameters:
        query - The query string.
        name - The parameter name to match.
        characterSet - The supported character encoding.
        separator - The separator character to append between parameters.
        decode - Indicates if the parameters should be decoded using the given character set.
        Returns:
        The parameter.
        Throws:
        java.io.IOException
      • getParameter

        public static java.lang.Object getParameter​(org.restlet.representation.Representation form,
                                                    java.lang.String name)
                                             throws java.io.IOException
        Reads the parameters with the given name.
        If multiple values are found, a list is returned created.
        Parameters:
        form - The web form representation.
        name - The parameter name to match.
        Returns:
        The parameter value or list of values.
        Throws:
        java.io.IOException - If the parameters could not be read.
      • getParameter

        public static java.lang.Object getParameter​(java.lang.String query,
                                                    java.lang.String name,
                                                    org.restlet.data.CharacterSet characterSet,
                                                    char separator,
                                                    boolean decode)
                                             throws java.io.IOException
        Reads the parameters with the given name.
        If multiple values are found, a list is returned created.
        Parameters:
        query - The query string.
        name - The parameter name to match.
        characterSet - The supported character encoding.
        separator - The separator character to append between parameters.
        decode - Indicates if the parameters should be decoded using the given character set. s * @return The parameter value or list of values.
        Throws:
        java.io.IOException - If the parameters could not be read.
      • getParameters

        public static void getParameters​(org.restlet.representation.Representation post,
                                         java.util.Map<java.lang.String,​java.lang.Object> parameters)
                                  throws java.io.IOException
        Reads the parameters whose name is a key in the given map.
        If a matching parameter is found, its value is put in the map.
        If multiple values are found, a list is created and set in the map.
        Parameters:
        post - The web form representation.
        parameters - The parameters map controlling the reading.
        Throws:
        java.io.IOException - If the parameters could not be read.
      • getParameters

        public static void getParameters​(java.lang.String parametersString,
                                         java.util.Map<java.lang.String,​java.lang.Object> parameters,
                                         org.restlet.data.CharacterSet characterSet,
                                         char separator,
                                         boolean decode)
                                  throws java.io.IOException
        Reads the parameters whose name is a key in the given map.
        If a matching parameter is found, its value is put in the map.
        If multiple values are found, a list is created and set in the map.
        Parameters:
        parametersString - The query string.
        parameters - The parameters map controlling the reading.
        characterSet - The supported character encoding.
        separator - The separator character to append between parameters.
        decode - Indicates if the parameters should be decoded using the given character set.
        Throws:
        java.io.IOException - If the parameters could not be read.
      • isParameterFound

        public static boolean isParameterFound​(org.restlet.data.Parameter searchedParam,
                                               org.restlet.data.MediaType mediaRange)
        Indicates if the searched parameter is specified in the given media range.
        Parameters:
        searchedParam - The searched parameter.
        mediaRange - The media range to inspect.
        Returns:
        True if the searched parameter is specified in the given media range.
      • parse

        public static void parse​(org.restlet.data.Form form,
                                 org.restlet.representation.Representation post,
                                 boolean decode)
        Parses a post into a given form.
        Parameters:
        form - The target form.
        post - The posted form.
        decode - Indicates if the parameters should be decoded.
      • parse

        public static void parse​(org.restlet.data.Form form,
                                 java.lang.String parametersString,
                                 org.restlet.data.CharacterSet characterSet,
                                 boolean decode,
                                 char separator)
        Parses a parameters string into a given form.
        Parameters:
        form - The target form.
        parametersString - The parameters string.
        characterSet - The supported character encoding.
        decode - Indicates if the parameters should be decoded using the given character set.
        separator - The separator character to append between parameters.