Package com.iizix.user
Class ProfilePictureInfo
java.lang.Object
com.iizix.user.ProfilePictureInfo
Class holding profile picture information either in a URL or as 
InputStream in case of OAuth 2.0 requirements to load the URL in an authenticated session.- Field SummaryFieldsModifier and TypeFieldDescription- static Comparator<ProfilePictureInfo>Sort instance to get the largest images first.
- Constructor SummaryConstructorsConstructorDescription- ProfilePictureInfo- (InputStream in, String mediaType) Constructor for image when size is unknown.- ProfilePictureInfo- (String url, String mediaType) Constructor for image when size is unknown.- ProfilePictureInfo- (String url, String mediaType, int width, int height) Constructor.- ProfilePictureInfo- (URL url, String mediaType, int width, int height) Constructor.
- Method SummaryModifier and TypeMethodDescription- void- close()Closes a potentially open input stream of the image data.- booleanChecks if two objects are equal.- intGets the height of the profile picture.- getImageData- (StringBuilder mediaType) The image input stream, either from the- url, or if the URL cannot be loaded without OAuth signatures.Gets the image type from the media type.Gets the media type, e.g.- getURL()Gets the URL to the profile picture.- int- getWidth()Gets the width of the profile picture.- int- hashCode()Gets the hash code of this instance.- static ProfilePictureInfo[]- sortLargestFirst- (ProfilePictureInfo[] images) Sorts the array of ProfilePictureInfo's so that the largest ones comes first.- toString()Gets a String.
- Field Details- LARGEST_FIRSTSort instance to get the largest images first. Images without size are always last.
 
- Constructor Details- ProfilePictureInfoConstructor for image when size is unknown.- Parameters:
- url- The URL to the profile picture.
- mediaType- The media type, e.g. 'image/jpeg'.
- Throws:
- NullPointerException- If- urlor- mediaTypeis- null.
- MalformedURLException- If the- urlis malformed.
 
- ProfilePictureInfopublic ProfilePictureInfo- (String url, String mediaType, int width, int height) throws MalformedURLException Constructor.- Parameters:
- url- The URL to the profile picture.
- mediaType- The media type, e.g. 'image/jpeg'.
- width- The width of the image, zero/negative if unknown.
- height- The height of the image, zero/negative if unknown.
- Throws:
- NullPointerException- If- urlor- mediaTypeis- null.
- MalformedURLException- If the- urlis malformed.
 
- ProfilePictureInfoConstructor.- Parameters:
- url- The URL to the profile picture.
- mediaType- The media type, e.g. 'image/jpeg'.
- width- The width of the image, zero/negative if unknown.
- height- The height of the image, zero/negative if unknown.
- Throws:
- NullPointerException- If- urlor- mediaTypeis- null.
 
- ProfilePictureInfoConstructor for image when size is unknown.- Parameters:
- in- The input stream.
- mediaType- The media type, e.g. 'image/jpeg'.
- Throws:
- NullPointerException- If- urlor- mediaTypeis- null.
 
 
- Method Details- sortLargestFirstSorts the array of ProfilePictureInfo's so that the largest ones comes first. Images without size are always last.- Parameters:
- images- The array of ProfilePictureInfo's, if- null, sorting will not be done and a NullPointerException is NOT thrown.
- Returns:
- The SAME INSTANCE as the input, sorting is done in-place, nullifimagesisnull.
 
- getURLGets the URL to the profile picture.- Returns:
- The URL, e.g. "https://..cdn.com/dms/image/..?e=..", or nullifgetImageData(StringBuilder)should be used instead (i.e. URL can only be retrieved with OAuth).
 
- getImageDataThe image input stream, either from the- url, or if the URL cannot be loaded without OAuth signatures.- Note: the URL connection is configured for the proxy settings of the environment. - Returns:
- The image input stream.
- Throws:
- IOException- If the input stream cannot be opened from the- URL(see- getURL().
- UnknownServiceException- If the protocol does not support input.
 
- getMediaTypeGets the media type, e.g. 'image/jpeg'.- Returns:
- The media type, never null.
 
- getImageTypeGets the image type from the media type.- Returns:
- The image type or ImageType.ALL_IMAGESif the media type doesn't many any of the supportedImageType's.
 
- getWidthpublic int getWidth()Gets the width of the profile picture.- If either width or height is unknown, - -1is returned.- Returns:
- The width, or -1if unknown (never zero).
 
- getHeightpublic int getHeight()Gets the height of the profile picture.- If either width or height is unknown, - -1is returned.- Returns:
- The height, or -1if unknown (never zero).
 
- hashCodepublic int hashCode()Gets the hash code of this instance.
- equalsChecks if two objects are equal.
- toStringGets a String.
- closepublic void close()Closes a potentially open input stream of the image data.