- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<String,List<String>>
-
- org.refcodes.web.AbstractHttpFields<FormFields>
-
- org.refcodes.web.FormFields
-
- All Implemented Interfaces:
Serializable,Cloneable,Map<String,List<String>>,HttpFields<FormFields>
public class FormFields extends AbstractHttpFields<FormFields> implements HttpFields<FormFields>
TheFormFieldsrepresent the URL's Query-String by the notation originally used by the GET request of the ancient web forms (see "https://en.wikipedia.org/wiki/Query_string#Web_forms"). Therefore the nameFormFields, as them web forms provided fields with values (see "https://en.wikipedia.org/wiki/Form_(HTML)")- See Also:
- "https://en.wikipedia.org/wiki/Query_string", Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Constructor Summary
Constructors Constructor Description FormFields()Instantiates a new form fields impl.FormFields(String aHttpFormFields)Initializes the instance with the fields provided by the given HTTP Form-Fields (HTTP Query-String).FormFields(Map<String,List<String>> aHttpFields)Initializes the instance with the fields provided by the givenMap.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfromBodyFormFields(String aHttpFormFields)Processes the HTTP Form-Fields bodyStringand retrieves the therein defined Form-Fields and adds them to theFormFieldsinstance.voidfromUrl(String aUrl)Extracts the HTTP Query-String from the provided URL by identifying the first question mark ("?")voidfromUrlQueryString(String aQueryString)Processes the HTTP Query-String and retrieves the therein defined Form-Fields and adds them to theFormFieldsinstance.StringtoBodyFormFields()Produces an HTTP Form-Fields bodyStringform the herein contain HTTP query fields.inttoContentLength()Calculates the length (number of characters) of theFormFieldswhen used for a HTTP-Body as oftoBodyFormFields().StringtoUrlQueryString()Produces an HTTP Query-String form the herein contain HTTP query fields.-
Methods inherited from class org.refcodes.web.AbstractHttpFields
copyHttpFields
-
Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.refcodes.web.HttpFields
addTo, addTo, addTo, addTo, addTo, addTo, getFirst, getFirst, put, put, put, put, toField, toField, withAddTo, withAddTo, withAddTo, withAddTo, withAddTo, withAddTo, withPut, withPut, withPut, withPut, withPut, withPut
-
Methods inherited from interface java.util.Map
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
-
-
-
Constructor Detail
-
FormFields
public FormFields()
Instantiates a new form fields impl.
-
FormFields
public FormFields(Map<String,List<String>> aHttpFields)
Initializes the instance with the fields provided by the givenMap.- Parameters:
aHttpFields- TheMapfrom which to get the keys and values for initializing this instance.
-
-
Method Detail
-
fromUrlQueryString
public void fromUrlQueryString(String aQueryString)
Processes the HTTP Query-String and retrieves the therein defined Form-Fields and adds them to theFormFieldsinstance.- Parameters:
aQueryString- The HTTP Query-String from which to extract the form being added to theFormFieldsinstance.
-
fromBodyFormFields
public void fromBodyFormFields(String aHttpFormFields)
Processes the HTTP Form-Fields bodyStringand retrieves the therein defined Form-Fields and adds them to theFormFieldsinstance.- Parameters:
aHttpFormFields- The HTTP Form-FieldsStringfrom which to extract the form being added to theFormFieldsinstance.
-
toUrlQueryString
public String toUrlQueryString()
Produces an HTTP Query-String form the herein contain HTTP query fields.- Returns:
- The HTTP Query-String representation of this
FormFieldsinstance or null if this instance is empty.
-
toBodyFormFields
public String toBodyFormFields()
Produces an HTTP Form-Fields bodyStringform the herein contain HTTP query fields.- Returns:
- The HTTP Form-Fields
Stringrepresentation of thisFormFieldsinstance or null if this instance is empty.
-
toContentLength
public int toContentLength()
Calculates the length (number of characters) of theFormFieldswhen used for a HTTP-Body as oftoBodyFormFields().- Returns:
- The length of the HTTP-Body representation of the content of
these
FormFields.
-
fromUrl
public void fromUrl(String aUrl)
Extracts the HTTP Query-String from the provided URL by identifying the first question mark ("?") and retrieves the therein defined Form-Fields and adds them to theFormFieldsinstance.- Parameters:
aUrl- The URL from which to extract the HTTP Query-String which's Form-Fields are to be added to theFormFieldsinstance.
-
-