Package com.iizix.server.user
Class UserProfileImageRequest
- java.lang.Object
- com.iizix.server.user.UserProfileImageRequest
- All Implemented Interfaces:
IUserProfileImageRequest,java.lang.Cloneable
public class UserProfileImageRequest extends java.lang.Object implements IUserProfileImageRequest
The request class for a User Profile Image.This class is NOT thread-safe when building the request, but is once the profile image is being retrieved. This is done by design to keep garbage collection down.
- Author:
- Christopher Mindus
Field Summary
Fields Modifier and Type Field Description static double[]COMMON_DPRS_EMPTYCOMMON_DPRS_EMPTY: An emptydouble arrayused to create images with DPR's of the common values: 1.0d, 1.5d, 2.0d, 3.0d, 4.0d.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UserProfileImageRequestappSessionGyro(IAppSessionGyro appGyro)Assigns the App Session Gyro to use.UserProfileImageRequestcircle()Specifies that a circle should be used, if thewidthandheightare equal, otherwise it will become an ellipse.UserProfileImageRequestcircle(int size)Specifies that a circle should be used in the set logical pixel size.UserProfileImageRequestclientSessionGyro(IClientSessionGyro clientGyro)Assigns the Client Session Gyro to use.UserProfileImageRequestclone()Clones the instance.UserProfileImageRequestcorners(int corners)The corner size of the image in pixels with DPR = 1.0d.UserProfileImageRequestcreateDefault(boolean doCreateDefault)Returns if creation of a default user profile image if none is found for a user ID or user Name should be performed or not.UserProfileImageRequestcurrentAppSessionGyro()Assigns the App Session Gyro to use.UserProfileImageRequestcurrentClientSessionGyro()Assigns the current Client Session Gyro to use.booleandoCreateDefault()Returns if creation of a default user profile image if none is found for a user ID or user Name should be performed or not.UserProfileImageRequestDRPs(double[] dprs)Sets the DRP's to use.AppSessionGyrogetAppSessionGyro()Gets the application session gyro.ClientSessionGyrogetClientSessionGyro()Gets the client session gyro.intgetCorners()Gets the corner size of the image in pixels with DPR = 1.0d.double[]getDPRs()Gets the DPR's requested.intgetHeight()The height requested of the image, always greater than zero.intgetQuality()Gets the image quality.AuthenticatedUsergetUser()Gets the user.longgetUserID()Gets the user ID.java.lang.StringgetUserName()Gets the user name.intgetWidth()Gets the width requested of the image, always greater than zero.booleanisCircle()Checks if it's a circle or oval (in case of differentwidthandheight)UserProfileImageRequestquality(int quality)Sets the image quality.UserProfileImageRequestsize(int size)Specifies the size of the image.UserProfileImageRequestsize(int width, int height)Specifies the size of the image.UserProfileImageRequestuser(long userID)Specifies the user to use.UserProfileImageRequestuser(java.lang.String userName)Specifies the user name.
Method Detail
clone
public UserProfileImageRequest clone()
Clones the instance.- Specified by:
clonein interfaceIUserProfileImageRequest- Overrides:
clonein classjava.lang.Object- Returns:
- A new UserProfileImageRequest cloned instance.
currentClientSessionGyro
public UserProfileImageRequest currentClientSessionGyro()
Assigns the current Client Session Gyro to use. The current thread is used to get it, and will also set the App Session Gyro if not already set.- Specified by:
currentClientSessionGyroin interfaceIUserProfileImageRequest- Returns:
- The UserProfileImageRequest "this" instance.
- Throws:
NotFoundException- If currentclientGyrois not found.
currentAppSessionGyro
public UserProfileImageRequest currentAppSessionGyro()
Assigns the App Session Gyro to use. If this method is not called, an attempt to locate the current App Session Gyro from the current thread might be done. The user ID or user Name will be initialized from this app session if not set to another value.- Specified by:
currentAppSessionGyroin interfaceIUserProfileImageRequest- Returns:
- The UserProfileImageRequest "this" instance.
- Throws:
NotFoundException- IfappGyrois not found.
appSessionGyro
public UserProfileImageRequest appSessionGyro(IAppSessionGyro appGyro)
Assigns the App Session Gyro to use. If this method is not called, an attempt to locate the current App Session Gyro from the current thread might be done. The user ID or user Name will be initialized from this app session if not set to another value.- Specified by:
appSessionGyroin interfaceIUserProfileImageRequest- Parameters:
appGyro- The application session gyro to use.- Returns:
- The UserProfileImageRequest "this" instance.
- Throws:
java.lang.NullPointerException- IfappGyroisnull.
clientSessionGyro
public UserProfileImageRequest clientSessionGyro(IClientSessionGyro clientGyro)
Assigns the Client Session Gyro to use. If this method is not called, an attempt to locate the current Client Session Gyro from the current thread might be done. Setting theclientGyrowill enable the DPR's to be read for the current client session.- Specified by:
clientSessionGyroin interfaceIUserProfileImageRequest- Parameters:
clientGyro- The client session gyro to use.- Returns:
- The UserProfileImageRequest "this" instance.
user
public UserProfileImageRequest user(long userID) throws NotFoundException
Specifies the user to use.If an existing
userNamehas been set, this call will reset it tonull.- Specified by:
userin interfaceIUserProfileImageRequest- Parameters:
userID- Requested user ID, or a negative value to use the current user, determined from the current Client or Application session.- Returns:
- The UserProfileImageRequest "this" instance.
- Throws:
NotFoundException- If the user ID is not found.java.lang.IllegalArgumentException- If the user ID is invalid (zero or negative value).
user
public UserProfileImageRequest user(java.lang.String userName)
Specifies the user name.- Specified by:
userin interfaceIUserProfileImageRequest- Parameters:
userName- The user name.- Throws:
NotFoundException- If the user name is not found.java.lang.NullPointerException- IfuserNameisnull.
size
public UserProfileImageRequest size(int size)
Specifies the size of the image.- Specified by:
sizein interfaceIUserProfileImageRequest- Parameters:
size- The size of width in logical pixels in the range of 16 to 400.- Returns:
- The UserProfileImageRequest "this" instance.
- Throws:
java.lang.IllegalArgumentException- Ifsizeis not in the range of 16 to 400.
size
public UserProfileImageRequest size(int width, int height)
Specifies the size of the image.- Specified by:
sizein interfaceIUserProfileImageRequest- Parameters:
width- The width in logical pixels in the range of 16 to 400.height- The height in logical pixels in the range of 16 to 400.- Returns:
- The UserProfileImageRequest "this" instance.
- Throws:
java.lang.IllegalArgumentException- Ifwidthorheightis not in the range of 16 to 400.
quality
public UserProfileImageRequest quality(int quality)
Sets the image quality.- Specified by:
qualityin interfaceIUserProfileImageRequest- Parameters:
quality- Zero for .PNG format loss-less with transparency support (default value), otherwise a value between 1 (worst possible quality) and 100 (loss-less) in .JPG format.- Throws:
java.lang.IllegalArgumentException- Ifqualityis not in the range of 0 to 100.
circle
public UserProfileImageRequest circle()
Specifies that a circle should be used, if thewidthandheightare equal, otherwise it will become an ellipse.- Specified by:
circlein interfaceIUserProfileImageRequest- Returns:
- The UserProfileImageRequest "this" instance.
circle
public UserProfileImageRequest circle(int size)
Specifies that a circle should be used in the set logical pixel size. The image width and height will be set to the size specified.- Specified by:
circlein interfaceIUserProfileImageRequest- Parameters:
size- The size of width in logical pixels in the range of 16 to 400. The width and height will be set to the specified size.- Returns:
- The UserProfileImageRequest "this" instance.
- Throws:
java.lang.IllegalArgumentException- Ifsizeis not in the range of 16 to 400.
corners
public UserProfileImageRequest corners(int corners)
The corner size of the image in pixels with DPR = 1.0d. The corner size is multiplied with the DPR for high resolution images.A value of
zeroindicates rectangular corners, i.e. no rounding.A negative value will use the corners of half the
widthand half theheight.- Specified by:
cornersin interfaceIUserProfileImageRequest- Returns:
- The UserProfileImageRequest "this" instance.
DRPs
public UserProfileImageRequest DRPs(double[] dprs)
Sets the DRP's to use.- Specified by:
DRPsin interfaceIUserProfileImageRequest- Parameters:
dprs- The DPR's to use. The first value MUST ALWAYs be 1.0d. Set to{@link #COMMON_DPRS_EMPTY}if you wish to use the default DPR's values 1.0d, 1.5d, 2.0d, 3.0d and 4.0d. Set tonullif the array should be build from the Client Session (must be non-null}, otherwise the single DPR 1.0d will be used.- Throws:
java.lang.IllegalArgumentException- If the array is invalid or has invalid values.
createDefault
public UserProfileImageRequest createDefault(boolean doCreateDefault)
Returns if creation of a default user profile image if none is found for a user ID or user Name should be performed or not.- Specified by:
createDefaultin interfaceIUserProfileImageRequest- Parameters:
doCreateDefault- The create default flag,falseby default.- Returns:
- The UserProfileImageRequest "this" instance.
getAppSessionGyro
public AppSessionGyro getAppSessionGyro()
Gets the application session gyro.- Specified by:
getAppSessionGyroin interfaceIUserProfileImageRequest- Returns:
- The App Session Gyro, or
nullif not set.
getClientSessionGyro
public ClientSessionGyro getClientSessionGyro()
Gets the client session gyro.- Specified by:
getClientSessionGyroin interfaceIUserProfileImageRequest- Returns:
- The Client Session Gyro, or
nullif not set.
getUser
public AuthenticatedUser getUser()
Gets the user.- Returns:
- The authenticated user, or
nullfor none.
getUserID
public long getUserID()
Gets the user ID.- Specified by:
getUserIDin interfaceIUserProfileImageRequest- Returns:
- The user ID that has been set, or
-1Lif the session is still unauthenticated or not yet set, orzeroif an undefined user "@undefined" is signed in.
getUserName
public java.lang.String getUserName()
Gets the user name.- Specified by:
getUserNamein interfaceIUserProfileImageRequest- Returns:
- The user name, or
nullif unauthenticated or not yet set, or "@undefined" if an undefined user is signed in.
getWidth
public int getWidth()
Gets the width requested of the image, always greater than zero.- Specified by:
getWidthin interfaceIUserProfileImageRequest- Returns:
- The width in logical pixels, zero if not yet set, otherwise in the range of 16 to 400.
getHeight
public int getHeight()
The height requested of the image, always greater than zero.- Specified by:
getHeightin interfaceIUserProfileImageRequest- Returns:
- The height in logical pixels, zero if not yet set, otherwise in the range of 16 to 400.
getQuality
public int getQuality()
Gets the image quality.- Specified by:
getQualityin interfaceIUserProfileImageRequest- Returns:
- The Image quality: zero for .PNG format loss-less with transparency support (default value), otherwise a value between 1 (worst possible quality) and 100 (loss-less) in .JPG format.
getCorners
public int getCorners()
Gets the corner size of the image in pixels with DPR = 1.0d. The corner size is multiplied with the DPR for high resolution images.- Specified by:
getCornersin interfaceIUserProfileImageRequest- Returns:
- The corner logical pixel value,
zerofor square corners (or rectangular, i.e. not rounded),-1for circle or oval (in case of differentwidthandheight).A value of
zeroindicates rectangular corners, i.e. no rounding.A negative value will use the corners of half the
widthand half theheight.
isCircle
public boolean isCircle()
Checks if it's a circle or oval (in case of differentwidthandheight)- Specified by:
isCirclein interfaceIUserProfileImageRequest- Returns:
- Flag indicating if a circle or oval image will be the result.
doCreateDefault
public boolean doCreateDefault()
Returns if creation of a default user profile image if none is found for a user ID or user Name should be performed or not.- Specified by:
doCreateDefaultin interfaceIUserProfileImageRequest- Returns:
- The create default flag,
falseby default.
getDPRs
public double[] getDPRs()
Gets the DPR's requested.- Specified by:
getDPRsin interfaceIUserProfileImageRequest- Returns:
- A cloned array of the requested DPR's.