public final class ProfilePicture extends Object implements Serializable, Cloneable
Constructor and Description |
---|
ProfilePicture(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.
|
Modifier and Type | Method and Description |
---|---|
ProfilePicture |
clone()
Clones the instance.
|
boolean |
deleteTemporaries()
Cleans up any temporary files or directories created.
|
boolean |
equals(Object o)
Checks if equal with another.
|
protected void |
finalize()
Finalized: delete temporaries.
|
File |
getFile()
Gets the file for the profile image.
|
File |
getFile(File dir,
boolean isTemporary)
Gets the file for the profile image.
|
int |
getImageDataSize()
Gets the size of the image byte data.
|
String |
getImageExtension()
Gets the image extension without ".".
|
ByteArrayInputStream |
getImageInputStream()
Gets the image array as an input stream.
|
String |
getName()
Returns the (file) name of the profile picture.
|
String |
getType()
Gets the profile image details type string.
|
int |
hashCode()
Hash code of the instance.
|
String |
toString()
A string representation.
|
public ProfilePicture(File file) throws IOException
file
- The profile picture.IOException
- If the file data cannot be loaded, the size is too
large, the file extension is not ".png", ".jpg" or
".jpeg".public ProfilePicture(File file, String type) throws IOException
file
- The profile picture.type
- The image type for database details:
IBasicUserInfoDetailNames.DETAIL_UploadedProfileImage
,
IBasicUserInfoDetailNames.DETAIL_LargeProfileImage
; or
IBasicUserInfoDetailNames.DETAIL_ThumbnailProfileImage
.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
- If type
is not
IBasicUserInfoDetailNames.DETAIL_UploadedProfileImage
or null
,
IBasicUserInfoDetailNames.DETAIL_LargeProfileImage
; or
IBasicUserInfoDetailNames.DETAIL_ThumbnailProfileImage
.public ProfilePicture(String type, String name, byte[] data)
type
- The type.name
- The file name of the profile picture.data
- The byte data of the file.IllegalArgumentException
- If type
is not
IBasicUserInfoDetailNames.DETAIL_UploadedProfileImage
or null
,
IBasicUserInfoDetailNames.DETAIL_LargeProfileImage
; or
IBasicUserInfoDetailNames.DETAIL_ThumbnailProfileImage
.public ProfilePicture clone()
public String getType()
public String getName()
public ByteArrayInputStream getImageInputStream()
public int getImageDataSize()
public String getImageExtension()
public boolean deleteTemporaries()
Errors during deleting of files is logged.
public File getFile(File dir, boolean isTemporary) throws IOException
If this method is called with previous temporary files and/or directories,
those are deleted prior to returning, depending on the isTemporary
flag.
dir
- Directory where to place the temporary file. If the dir
parameter is null
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.isTemporary
parameter.
Use the method deleteTemporaries()
to
clean-up.
IOException
- For I/O errors.public File getFile() throws IOException
If this method is called with previous temporary files and/or directories, those are deleted prior to returning.
Use the method deleteTemporaries()
to
clean-up.
IOException
- For I/O errors.public String toString()
public boolean equals(Object o)
public int hashCode()
iizi® is a registered trademark of Mindus SARL. © Copyright Mindus SARL, 2020. All rights reserved.