Package net.bjmsw.hda.vs.model.mime
Class FormData
java.lang.Object
net.bjmsw.hda.vs.model.mime.FormData
- All Implemented Interfaces:
HttpBody
Represents HTTP form data objects.
This class is used to store form data in a key-value pair. This can be used for multipart/form-data and application/x-www-form-urlencoded.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all key-value pairs from the FormData object.booleanChecks if the FormData object contains a key-value pair with the given key.booleancontainsFile(String key) Checks if the FormData object contains a file with the given key.Retrieves the value associated with the given key from the FormData object.getAll()Retrieves all the key-value pairs stored in the FormData object.Retrieves all the files stored in the FormData object.Retrieves the file associated with the given key from the FormData object.booleanisEmpty()Checks if the FormData object is empty.intChecks if the FormData object is empty.voidRemoves the key-value pair associated with the given key from the FormData object.voidremoveFile(String key) Removes the file associated with the given key from the FormData object.voidAdds a key-value pair to the FormData object.voidsetFile(String key, FormDataFile value) Adds a file to the FormData object.intsize()Retrieves the number of key-value pairs stored in the FormData object.toString()Returns a string representation of the FormData object.
-
Field Details
-
data
-
files
-
-
Constructor Details
-
FormData
Constructs a FormData object with the given data.- Parameters:
data- a map containing the key-value pairs of the form data
-
FormData
public FormData()Represents a HTTP form data object.This class is used to store form data in a key-value pair. It can be used for multipart/form-data and application/x-www-form-urlencoded.
-
-
Method Details
-
get
Retrieves the value associated with the given key from the FormData object.- Parameters:
key- the key for which the value needs to be retrieved- Returns:
- the value associated with the key, or null if the key is not present
-
getAll
Retrieves all the key-value pairs stored in the FormData object.- Returns:
- a map containing all the key-value pairs
-
toString
Returns a string representation of the FormData object.This method constructs a string by iterating over the key-value pairs stored in the FormData object and appending them to a StringBuilder. The resulting string has the format "FormData(key1: value1; key2: value2; ...)".
Used for debugging purposes.
-
set
Adds a key-value pair to the FormData object.- Parameters:
key- the key to be addedvalue- the value to be added
-
remove
Removes the key-value pair associated with the given key from the FormData object.- Parameters:
key- the key to be removed
-
contains
Checks if the FormData object contains a key-value pair with the given key.- Parameters:
key- the key to be checked- Returns:
- true if the key is present, false otherwise
-
isEmpty
public boolean isEmpty()Checks if the FormData object is empty.- Returns:
- true if the FormData object is empty, false otherwise
-
size
public int size()Retrieves the number of key-value pairs stored in the FormData object.- Returns:
- the number of key-value pairs
-
clear
public void clear()Removes all key-value pairs from the FormData object. -
setFile
Adds a file to the FormData object.- Parameters:
key- the key to be addedvalue- the file to be added
-
getFile
Retrieves the file associated with the given key from the FormData object.- Parameters:
key- the key for which the file needs to be retrieved- Returns:
- the file associated with the key, or null if the key is not present
-
getAllFiles
Retrieves all the files stored in the FormData object.- Returns:
- a map containing all the files
-
removeFile
Removes the file associated with the given key from the FormData object.- Parameters:
key- the key to be removed
-
containsFile
Checks if the FormData object contains a file with the given key.- Parameters:
key- the key to be checked- Returns:
- true if the key is present, false otherwise
-
numOfFiles
public int numOfFiles()Checks if the FormData object is empty.- Returns:
- true if the FormData object is empty, false otherwise
-