Package com.iizix.license
Class ProfilePicture
java.lang.Object
com.iizix.license.ProfilePicture
- All Implemented Interfaces:
Serializable
,Cloneable
Class for profile picture.
- Author:
- Christopher Mindus
- See Also:
Constructor Summary
ConstructorDescriptionProfilePicture
(File file) Constructs the profile picture from a file, assuming it is the "DETAIL_UploadedProfileImage" file.ProfilePicture
(File file, String type) Constructs the profile picture from a file, assuming it is the "DETAIL_UploadedProfileImage" file.ProfilePicture
(String type, String name, byte[] data) Constructor of the file when only data and type and filename is present.Method Summary
Modifier and TypeMethodDescriptionclone()
Clones the instance.boolean
Cleans up any temporary files or directories created.boolean
Checks if equal with another.protected void
finalize()
Finalized: delete temporaries.getFile()
Gets the file for the profile image.Gets the file for the profile image.int
Gets the size of the image byte data.Gets the image extension without ".".Gets the image array as an input stream.getName()
Returns the (file) name of the profile picture.getType()
Gets the profile image details type string.int
hashCode()
Hash code of the instance.toString()
A string representation.
Constructor Details
ProfilePicture
Constructs the profile picture from a file, assuming it is the "DETAIL_UploadedProfileImage" file.- Parameters:
file
- The profile picture.- Throws:
IOException
- If the file data cannot be loaded, the size is too large, the file extension is not ".png", ".jpg" or ".jpeg".
ProfilePicture
Constructs the profile picture from a file, assuming it is the "DETAIL_UploadedProfileImage" file.- Parameters:
file
- The profile picture.type
- The image type for database details:IBasicUserInfoDetailNames.DETAIL_UploadedProfileImage
,IBasicUserInfoDetailNames.DETAIL_LargeProfileImage
; orIBasicUserInfoDetailNames.DETAIL_ThumbnailProfileImage
.- Throws:
IOException
- If the file data cannot be loaded, the size is too large (larger than 1 MB), the file extension is not ".png", ".jpg" or ".jpeg".IllegalArgumentException
- Iftype
is notIBasicUserInfoDetailNames.DETAIL_UploadedProfileImage
ornull
,IBasicUserInfoDetailNames.DETAIL_LargeProfileImage
; orIBasicUserInfoDetailNames.DETAIL_ThumbnailProfileImage
.
ProfilePicture
Constructor of the file when only data and type and filename is present.- Parameters:
type
- The type.name
- The file name of the profile picture.data
- The byte data of the file.- Throws:
IllegalArgumentException
- Iftype
is notIBasicUserInfoDetailNames.DETAIL_UploadedProfileImage
ornull
,IBasicUserInfoDetailNames.DETAIL_LargeProfileImage
; orIBasicUserInfoDetailNames.DETAIL_ThumbnailProfileImage
.
Method Details
clone
Clones the instance.getType
Gets the profile image details type string.getName
Returns the (file) name of the profile picture.- Returns:
- The (file) name, without path.
getImageInputStream
Gets the image array as an input stream.- Returns:
- Image input stream.
getImageDataSize
public int getImageDataSize()Gets the size of the image byte data.- Returns:
- The byte count of the image data, i.e. the file size on disk in bytes.
getImageExtension
Gets the image extension without ".".- Returns:
- The image extension, "png" or "jpg".
deleteTemporaries
public boolean deleteTemporaries()Cleans up any temporary files or directories created. If this method is called and there are temporary file(s), nothing will be performed.Errors during deleting of files is logged.
- Returns:
- true if temporary file(s) where deleted.
getFile
Gets the file for the profile image.If this method is called with previous temporary files and/or directories, those are deleted prior to returning, depending on the
isTemporary
flag.- Parameters:
dir
- Directory where to place the temporary file. If thedir
parameter isnull
then a temporary directory will be created and the profile picture file placed inside. The creation of the temporary file and/or directory is only done once.isTemporary
- If the file that is created should be considered as temporary or not. If not temporary, the created file (if created) will not be deleted.- Returns:
- file The file, a potentially temporary file when created depending on the
isTemporary
parameter.Use the method
deleteTemporaries()
to clean-up. - Throws:
IOException
- For I/O errors.
getFile
Gets the file for the profile image.If this method is called with previous temporary files and/or directories, those are deleted prior to returning.
- Returns:
- file A temporary file created.
Use the method
deleteTemporaries()
to clean-up. - Throws:
IOException
- For I/O errors.
toString
A string representation.equals
Checks if equal with another.hashCode
public int hashCode()Hash code of the instance.finalize
Finalized: delete temporaries.