Class KeyDataPair

java.lang.Object
org.htmlunit.util.NameValuePair
org.htmlunit.util.KeyDataPair
All Implemented Interfaces:
Serializable

public class KeyDataPair extends NameValuePair
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.
See Also:
  • Field Details

    • fileObject_

      private final File fileObject_
    • fileName_

      private final String fileName_
    • mimeType_

      private final String mimeType_
    • charset_

      private transient Charset charset_
    • data_

      private byte[] data_
  • Constructor Details

    • KeyDataPair

      public KeyDataPair(String key, File file, String fileName, String mimeType, String charset)
      Creates an instance.
      Parameters:
      key - the key
      file - the file
      fileName - the name of the file
      mimeType - the MIME type
      charset - the charset encoding
    • KeyDataPair

      public KeyDataPair(String key, File file, String fileName, String mimeType, Charset charset)
      Creates an instance.
      Parameters:
      key - the key
      file - the file
      fileName - the name of the file
      mimeType - the MIME type
      charset - 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 constructor
      value - will be passed as value to the super constructor
      file - the file, may be null
      fileName - , the filename, may be null
      mimeType - , the mimetype, may be null
      charset - , the charset, may be null
  • Method Details

    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class NameValuePair
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class NameValuePair
    • getFile

      public File getFile()
      Returns:
      the File object if the file exists, else null
    • getFileName

      public String getFileName()
      Returns:
      the fileName
    • getCharset

      public Charset getCharset()
      Gets the charset encoding for this file upload.
      Returns:
      the charset
    • getMimeType

      public String 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:
      null if 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

      private void writeObject(ObjectOutputStream oos) throws IOException
      Throws:
      IOException
    • readObject

      private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException
      Throws:
      ClassNotFoundException
      IOException
    • normalized

      public KeyDataPair 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:
      normalized in class NameValuePair
      Returns:
      a normalized copy of the NameValuePair