Package org.restlet.ext.html.internal
Class FormUtils
- java.lang.Object
-
- org.restlet.ext.html.internal.FormUtils
-
public class FormUtils extends java.lang.ObjectRepresentation of a Web form containing submitted entries.
-
-
Constructor Summary
Constructors Modifier Constructor Description privateFormUtils()Private constructor to ensure that the class acts as a true utility class i.e.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static FormDatacreate(java.lang.CharSequence name, java.lang.CharSequence value, boolean decode, CharacterSet characterSet)Creates a form data.static voidgetEntries(java.lang.String queryString, java.util.Map<java.lang.String,java.lang.Object> entries, CharacterSet characterSet, char separator)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.static voidgetEntries(Representation post, java.util.Map<java.lang.String,java.lang.Object> entries)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.static java.lang.ObjectgetEntry(java.lang.String query, java.lang.String name, CharacterSet characterSet, char separator)Reads the entries with the given name.
If multiple values are found, a list is returned created.static java.lang.ObjectgetEntry(Representation form, java.lang.String name)Reads the entries with the given name.
If multiple values are found, a list is returned created.static FormDatagetFirstEntry(java.lang.String query, java.lang.String name, CharacterSet characterSet, char separator)Reads the first entry with the given name.static FormDatagetFirstEntry(Representation post, java.lang.String name)Reads the first entry with the given name.static booleanisEntryFound(FormData searchedEntry, MediaType mediaRange)Indicates if the searched entry is specified in the given media range.static voidparse(Series<FormData> entriesSeries, java.lang.String queryString, CharacterSet characterSet, boolean decode, char separator)Parses a entries string into a given form.static voidparse(Series<FormData> entries, Representation post)Parses a post into a given entries series.
-
-
-
Method Detail
-
create
public static FormData create(java.lang.CharSequence name, java.lang.CharSequence value, boolean decode, CharacterSet characterSet)
Creates a form data.- Parameters:
name- The name buffer.value- The value buffer (can be null).decode- If true, the name and values are decoded with the givenCharacterSet, if false, than nothing is decoded.characterSet- The supported character encoding.- Returns:
- The created form data.
-
getEntries
public static void getEntries(Representation post, 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:
post- The web form representation.entries- The entries map controlling the reading.- Throws:
java.io.IOException- If the entries could not be read.
-
getEntries
public static void getEntries(java.lang.String queryString, java.util.Map<java.lang.String,java.lang.Object> entries, CharacterSet characterSet, char separator) throws java.io.IOExceptionReads 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:
queryString- The query string.entries- The entries map controlling the reading.characterSet- The supported character encoding.separator- The separator character to append between entries.- Throws:
java.io.IOException- If the entries could not be read.
-
getEntry
public static java.lang.Object getEntry(Representation form, 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:
form- The web form representation.name- The name to match.- Returns:
- The form data or list of values.
- Throws:
java.io.IOException- If the entries could not be read.
-
getEntry
public static java.lang.Object getEntry(java.lang.String query, java.lang.String name, CharacterSet characterSet, char separator) throws java.io.IOExceptionReads the entries with the given name.
If multiple values are found, a list is returned created.- Parameters:
query- The query string.name- The entry name to match.characterSet- The supported character encoding.separator- The separator character to append between entries.- Returns:
- The entry value or list of values.
- Throws:
java.io.IOException- If the entries could not be read.
-
getFirstEntry
public static FormData getFirstEntry(Representation post, java.lang.String name) throws java.io.IOException
Reads the first entry with the given name.- Parameters:
post- The web form representation.name- The name to match.- Returns:
- The form data entry.
- Throws:
java.io.IOException
-
getFirstEntry
public static FormData getFirstEntry(java.lang.String query, java.lang.String name, CharacterSet characterSet, char separator) throws java.io.IOException
Reads the first entry with the given name.- Parameters:
query- The query string.name- The name to match.characterSet- The supported character encoding.separator- The separator character to append between entries.- Returns:
- The form data entry.
- Throws:
java.io.IOException
-
isEntryFound
public static boolean isEntryFound(FormData searchedEntry, MediaType mediaRange)
Indicates if the searched entry is specified in the given media range.- Parameters:
searchedEntry- The searched entry.mediaRange- The media range to inspect.- Returns:
- True if the searched entry is specified in the given media range.
-
parse
public static void parse(Series<FormData> entries, Representation post)
Parses a post into a given entries series.- Parameters:
entries- The target entries series.post- The posted form.
-
parse
public static void parse(Series<FormData> entriesSeries, java.lang.String queryString, CharacterSet characterSet, boolean decode, char separator)
Parses a entries string into a given form.- Parameters:
entriesSeries- The target entries series.queryString- The query string.characterSet- The supported character encoding.decode- Indicates if the query string should be decoded using the given character set.separator- The separator character to append between entries.
-
-