Package org.htmlunit.util
Class KeyDataPair
java.lang.Object
org.htmlunit.util.NameValuePair
org.htmlunit.util.KeyDataPair
- All Implemented Interfaces:
Serializable
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
A holder for a key/value pair that represents a file to upload.
A holder for a key/value pair that represents a file to upload.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanGets the charset encoding for this file upload.byte[]getData()Gets in-memory data assigned to file value.getFile()Gets the MIME type for this file upload.inthashCode()INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
convert null values to empty stringprivate voidvoidsetData(byte[] data) Sets file value data.private voidMethods inherited from class org.htmlunit.util.NameValuePair
getName, getValue, toString
-
Field Details
-
fileObject_
-
fileName_
-
mimeType_
-
charset_
-
data_
private byte[] data_
-
-
Constructor Details
-
KeyDataPair
Creates an instance.- Parameters:
key- the keyfile- the filefileName- the name of the filemimeType- the MIME typecharset- the charset encoding
-
KeyDataPair
Creates an instance.- Parameters:
key- the keyfile- the filefileName- the name of the filemimeType- the MIME typecharset- the charset encoding
-
KeyDataPair
private KeyDataPair(String name, String value, File file, String fileName, String mimeType, Charset charset, byte[] data) Private constructor setting plain properties.- Parameters:
name- will passed as name to the super constructorvalue- will be passed as value to the super constructorfile- the file, may be nullfileName- , the filename, may be nullmimeType- , the mimetype, may be nullcharset- , the charset, may be null
-
-
Method Details
-
equals
- Overrides:
equalsin classNameValuePair
-
hashCode
public int hashCode()- Overrides:
hashCodein classNameValuePair
-
getFile
- Returns:
- the
Fileobject if the file exists, elsenull
-
getFileName
- Returns:
- the fileName
-
getCharset
Gets the charset encoding for this file upload.- Returns:
- the charset
-
getMimeType
Gets the MIME type for this file upload.- Returns:
- the MIME type
-
getData
public byte[] getData()Gets in-memory data assigned to file value.- Returns:
nullif the file content should be used.
-
setData
public void setData(byte[] data) Sets file value data. If nothing is set, the file content will be used.- Parameters:
data- byte array with file data.
-
writeObject
- Throws:
IOException
-
readObject
- Throws:
ClassNotFoundExceptionIOException
-
normalized
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
convert null values to empty string Specialization of inherited method which will copy all fields and make sure that the value in the base class is not null, by calling the constructor with the current value- Overrides:
normalizedin classNameValuePair- Returns:
- a normalized copy of the
NameValuePair
-