Package com.iizix.user
Class ProfilePictureInfo
- java.lang.Object
- com.iizix.user.ProfilePictureInfo
 
- public class ProfilePictureInfo extends java.lang.ObjectClass holding profile picture information either in a URL or as- InputStreamin case of OAuth 2.0 requirements to load the URL in an authenticated session.
- Field Summary- Fields - Modifier and Type - Field - Description - static java.util.Comparator<ProfilePictureInfo>- LARGEST_FIRSTSort instance to get the largest images first.
 - Constructor Summary- Constructors - Constructor - Description - ProfilePictureInfo(java.io.InputStream in, java.lang.String mediaType)Constructor for image when size is unknown.- ProfilePictureInfo(java.lang.String url, java.lang.String mediaType)Constructor for image when size is unknown.- ProfilePictureInfo(java.lang.String url, java.lang.String mediaType, int width, int height)Constructor.- ProfilePictureInfo(java.net.URL url, java.lang.String mediaType, int width, int height)Constructor.
 - Method Summary- All Methods Static Methods Instance Methods Concrete Methods - Modifier and Type - Method - Description - void- close()Closes a potentially open input stream of the image data.- boolean- equals(java.lang.Object obj)Checks if two objects are equal.- int- getHeight()Gets the height of the profile picture.- java.io.InputStream- getImageData(java.lang.StringBuilder mediaType)The image input stream, either from the- url, or if the URL cannot be loaded without OAuth signatures.- ImageType- getImageType()Gets the image type from the media type.- java.lang.String- getMediaType()Gets the media type, e.g.- java.net.URL- 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.- java.lang.String- toString()Gets a String.
 
- Field Detail- LARGEST_FIRST- public static java.util.Comparator<ProfilePictureInfo> LARGEST_FIRST Sort instance to get the largest images first. Images without size are always last.
 
 - Constructor Detail- ProfilePictureInfo- public ProfilePictureInfo(java.lang.String url, java.lang.String mediaType) throws java.net.MalformedURLExceptionConstructor for image when size is unknown.- Parameters:
- url- The URL to the profile picture.
- mediaType- The media type, e.g. 'image/jpeg'.
- Throws:
- java.lang.NullPointerException- If- urlor- mediaTypeis- null.
- java.net.MalformedURLException- If the- urlis malformed.
 
 - ProfilePictureInfo- public ProfilePictureInfo(java.lang.String url, java.lang.String mediaType, int width, int height) throws java.net.MalformedURLExceptionConstructor.- 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:
- java.lang.NullPointerException- If- urlor- mediaTypeis- null.
- java.net.MalformedURLException- If the- urlis malformed.
 
 - ProfilePictureInfo- public ProfilePictureInfo(java.net.URL url, java.lang.String mediaType, int width, int height)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:
- java.lang.NullPointerException- If- urlor- mediaTypeis- null.
 
 - ProfilePictureInfo- public ProfilePictureInfo(java.io.InputStream in, java.lang.String mediaType)Constructor for image when size is unknown.- Parameters:
- in- The input stream.
- mediaType- The media type, e.g. 'image/jpeg'.
- Throws:
- java.lang.NullPointerException- If- urlor- mediaTypeis- null.
 
 
 - Method Detail- sortLargestFirst- public static ProfilePictureInfo[] sortLargestFirst(ProfilePictureInfo[] images) Sorts 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.
 
 - getURL- public java.net.URL getURL() Gets 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).
 
 - getImageData- public java.io.InputStream getImageData(java.lang.StringBuilder mediaType) throws java.io.IOExceptionThe 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:
- java.io.IOException- If the input stream cannot be opened from the- URL(see- getURL().
- java.net.UnknownServiceException- If the protocol does not support input.
 
 - getMediaType- public java.lang.String getMediaType() Gets the media type, e.g. 'image/jpeg'.- Returns:
- The media type, never null.
 
 - getImageType- public ImageType getImageType() Gets 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.
 
 - getWidth- public 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).
 
 - getHeight- public 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).
 
 - hashCode- public int hashCode() Gets the hash code of this instance.- Overrides:
- hashCodein class- java.lang.Object
- Returns:
- The hash code.
 
 - equals- public boolean equals(java.lang.Object obj) Checks if two objects are equal.- Overrides:
- equalsin class- java.lang.Object
- Parameters:
- obj- The other object to compare with.
- Returns:
- The equality flag.
 
 - toString- public java.lang.String toString() Gets a String.- Overrides:
- toStringin class- java.lang.Object
- Returns:
- The string as "[[width x height,]mediaType,url]" or "[[width x height,]mediaType,<inputStream>]"
 
 - close- public void close() Closes a potentially open input stream of the image data.