Package com.iizix.license
Class ProfilePicture
- java.lang.Object
- com.iizix.license.ProfilePicture
 
- All Implemented Interfaces:
- java.io.Serializable,- java.lang.Cloneable
 - public final class ProfilePicture extends java.lang.Object implements java.io.Serializable, java.lang.CloneableClass for profile picture.- Author:
- Christopher Mindus
- See Also:
- Serialized Form
 
- Constructor Summary- Constructors - Constructor - Description - ProfilePicture(java.io.File file)Constructs the profile picture from a file, assuming it is the "DETAIL_UploadedProfileImage" file.- ProfilePicture(java.io.File file, java.lang.String type)Constructs the profile picture from a file, assuming it is the "DETAIL_UploadedProfileImage" file.- ProfilePicture(java.lang.String type, java.lang.String name, byte[] data)Constructor of the file when only data and type and filename is present.
 - Method Summary- All Methods Instance Methods Concrete Methods - Modifier and Type - Method - Description - ProfilePicture- clone()Clones the instance.- boolean- deleteTemporaries()Cleans up any temporary files or directories created.- boolean- equals(java.lang.Object o)Checks if equal with another.- protected void- finalize()Finalized: delete temporaries.- java.io.File- getFile()Gets the file for the profile image.- java.io.File- getFile(java.io.File dir, boolean isTemporary)Gets the file for the profile image.- int- getImageDataSize()Gets the size of the image byte data.- java.lang.String- getImageExtension()Gets the image extension without ".".- java.io.ByteArrayInputStream- getImageInputStream()Gets the image array as an input stream.- java.lang.String- getName()Returns the (file) name of the profile picture.- java.lang.String- getType()Gets the profile image details type string.- int- hashCode()Hash code of the instance.- java.lang.String- toString()A string representation.
 
- Constructor Detail- ProfilePicture- public ProfilePicture(java.io.File file) throws java.io.IOExceptionConstructs the profile picture from a file, assuming it is the "DETAIL_UploadedProfileImage" file.- Parameters:
- file- The profile picture.
- Throws:
- java.io.IOException- If the file data cannot be loaded, the size is too large, the file extension is not ".png", ".jpg" or ".jpeg".
 
 - ProfilePicture- public ProfilePicture(java.io.File file, java.lang.String type) throws java.io.IOExceptionConstructs 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; or- IBasicUserInfoDetailNames.DETAIL_ThumbnailProfileImage.
- Throws:
- java.io.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".
- java.lang.IllegalArgumentException- If- typeis not- IBasicUserInfoDetailNames.DETAIL_UploadedProfileImageor- null,- IBasicUserInfoDetailNames.DETAIL_LargeProfileImage; or- IBasicUserInfoDetailNames.DETAIL_ThumbnailProfileImage.
 
 - ProfilePicture- public ProfilePicture(java.lang.String type, java.lang.String name, byte[] data)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:
- java.lang.IllegalArgumentException- If- typeis not- IBasicUserInfoDetailNames.DETAIL_UploadedProfileImageor- null,- IBasicUserInfoDetailNames.DETAIL_LargeProfileImage; or- IBasicUserInfoDetailNames.DETAIL_ThumbnailProfileImage.
 
 
 - Method Detail- clone- public ProfilePicture clone() Clones the instance.- Overrides:
- clonein class- java.lang.Object
- Returns:
- A cloned instance where temporary files are not cloned in, i.e. it's a fresh copy without temporary directory and/or file.
 
 - getType- public java.lang.String getType() Gets the profile image details type string.
 - getName- public java.lang.String getName() Returns the (file) name of the profile picture.- Returns:
- The (file) name, without path.
 
 - getImageInputStream- public java.io.ByteArrayInputStream 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- public java.lang.String 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- public java.io.File getFile(java.io.File dir, boolean isTemporary) throws java.io.IOExceptionGets 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 - isTemporaryflag.- Parameters:
- dir- Directory where to place the temporary file. If the- dirparameter is- nullthen 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 isTemporaryparameter.Use the method deleteTemporaries()to clean-up.
- Throws:
- java.io.IOException- For I/O errors.
 
 - getFile- public java.io.File getFile() throws java.io.IOExceptionGets 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:
- java.io.IOException- For I/O errors.
 
 - toString- public java.lang.String toString() A string representation.- Overrides:
- toStringin class- java.lang.Object
- Returns:
- String as "className[fileName,type]".
 
 - equals- public boolean equals(java.lang.Object o) Checks if equal with another.- Overrides:
- equalsin class- java.lang.Object
- Returns:
- true if name, type matched and contents are the same, false otherwise.
 
 - hashCode- public int hashCode() Hash code of the instance.- Overrides:
- hashCodein class- java.lang.Object
- Returns:
- Hash code of name, type and data.
 
 - finalize- protected void finalize() throws java.lang.ThrowableFinalized: delete temporaries.- Overrides:
- finalizein class- java.lang.Object
- Throws:
- java.lang.Throwable