Class KeyDataPair

  • All Implemented Interfaces:
    java.io.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:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.nio.charset.Charset charset_  
      private byte[] data_  
      private java.lang.String fileName_  
      private java.io.File fileObject_  
      private java.lang.String mimeType_  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        KeyDataPair​(java.lang.String key, java.io.File file, java.lang.String fileName, java.lang.String mimeType, java.lang.String charset)
      Creates an instance.
        KeyDataPair​(java.lang.String key, java.io.File file, java.lang.String fileName, java.lang.String mimeType, java.nio.charset.Charset charset)
      Creates an instance.
      private KeyDataPair​(java.lang.String name, java.lang.String value, java.io.File file, java.lang.String fileName, java.lang.String mimeType, java.nio.charset.Charset charset, byte[] data)
      Private constructor setting plain properties.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object object)
      java.nio.charset.Charset getCharset()
      Gets the charset encoding for this file upload.
      byte[] getData()
      Gets in-memory data assigned to file value.
      java.io.File getFile()  
      java.lang.String getFileName()  
      java.lang.String getMimeType()
      Gets the MIME type for this file upload.
      int hashCode()
      KeyDataPair normalized()
      INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
      convert null values to empty string
      private void readObject​(java.io.ObjectInputStream ois)  
      void setData​(byte[] data)
      Sets file value data.
      private void writeObject​(java.io.ObjectOutputStream oos)  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • fileObject_

        private final java.io.File fileObject_
      • fileName_

        private final java.lang.String fileName_
      • mimeType_

        private final java.lang.String mimeType_
      • charset_

        private transient java.nio.charset.Charset charset_
      • data_

        private byte[] data_
    • Constructor Detail

      • KeyDataPair

        public KeyDataPair​(java.lang.String key,
                           java.io.File file,
                           java.lang.String fileName,
                           java.lang.String mimeType,
                           java.lang.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​(java.lang.String key,
                           java.io.File file,
                           java.lang.String fileName,
                           java.lang.String mimeType,
                           java.nio.charset.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​(java.lang.String name,
                            java.lang.String value,
                            java.io.File file,
                            java.lang.String fileName,
                            java.lang.String mimeType,
                            java.nio.charset.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 Detail

      • equals

        public boolean equals​(java.lang.Object object)
        Overrides:
        equals in class NameValuePair
      • getFile

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

        public java.lang.String getFileName()
        Returns:
        the fileName
      • getCharset

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

        public java.lang.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​(java.io.ObjectOutputStream oos)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • readObject

        private void readObject​(java.io.ObjectInputStream ois)
                         throws java.lang.ClassNotFoundException,
                                java.io.IOException
        Throws:
        java.lang.ClassNotFoundException
        java.io.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