📄 onlineuserimpl.java
字号:
public OnlineUserAction getOnlineUserAction() {
return onlineUserAction;
}
public java.util.Date convertGMTDate(java.util.Date gmtDate) {
return DateUtil.convertGMTDate(gmtDate, hourOffset);
}
public Timestamp convertGMTTimestamp(Timestamp gmtTimestamp) {
return DateUtil.convertGMTTimestamp(gmtTimestamp, hourOffset);
}
public String getGMTDateFormat(java.util.Date gmtDate) {
return getGMTDateFormat(gmtDate, true);
}
public synchronized String getGMTDateFormat(java.util.Date gmtDate, boolean adjustTimeZone) {
if (gmtDate == null) return "";
java.util.Date date = gmtDate;
if (adjustTimeZone) {
date = DateUtil.convertGMTDate(gmtDate, hourOffset);
}
return dateFormatter.format(date);
}
public String getGMTTimestampFormat(Timestamp gmtTimestamp) {
return getGMTTimestampFormat(gmtTimestamp, true);
}
public synchronized String getGMTTimestampFormat(Timestamp gmtTimestamp, boolean adjustTimeZone) {
if (gmtTimestamp == null) return "";
Timestamp timestamp = gmtTimestamp;
if (adjustTimeZone) {
timestamp = DateUtil.convertGMTTimestamp(gmtTimestamp, hourOffset);
}
return timestampFormatter.format(timestamp);
}
public String getLocaleName() {
return localeName;
}
public void setLocaleName(String localeName) {
if (localeName == null) {
localeName = "";
}
this.localeName = localeName;
if (localeName.length() == 0) {
this.localeName = MVNForumConfig.getDefaultLocaleName();
this.locale = MVNForumConfig.getDefaultLocale();
} else {
locale = MyUtil.getLocale(localeName);
}
// now init the 2 class variables
dateFormatter = DateFormat.getDateInstance(DateFormat.DEFAULT, locale);
timestampFormatter = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, locale);
}
public Locale getLocale() {
return locale;
}
public String getLastLogonIP() {
if (isGuest()) {
return "";
}
return lastLogonIP;
}
public Timestamp getLastLogonTimestamp() {
return lastLogonTimestamp;
}
/*
public boolean getGender() {
return gender;
}
*/
public int getPostsPerPage() {
return memberPostsPerPage;
}
public int getMessagesPerPage() {
return memberMessagesPerPage;
}
public int getNewMessageCount() {
return newMessageCount;
}
public String getCssPath() {
return memberCssPath;
}
public String getLogoPath() {
return memberLogoPath;
}
/**
* Build a new captcha, this method must be called before using some
* action that need captcha validation.
*/
public void buildNewCaptcha() {
destroyCurrentCaptcha();
// this line of code could throw Exception in case the captcha image
// is small to hold the whole captcha
imageCaptcha = MVNCaptchaService.getInstance().getNextImageCaptcha();
}
/**
* Destroy the current captcha, this method must be called after validate
* the captcha
*/
public void destroyCurrentCaptcha() {
imageCaptcha = null;
}
/**
* Get the captcha image to challenge the user
*
* @return BufferedImage the captcha image to challenge the user
*/
public BufferedImage getCurrentCaptchaImage() {
if (imageCaptcha == null) {
return null;
}
return (BufferedImage)(imageCaptcha.getChallenge());
}
/**
* Validate the anwser of the captcha from user
*
* @param anwser String the captcha anwser from user
* @return boolean true if the answer is valid, otherwise return false
*/
public boolean validateCaptchaResponse(String anwser) {
if (imageCaptcha == null) {
log.info("validateCaptchaResponse returned false due to imageCaptcha is null");
return false;
}
anwser = anwser.toUpperCase();//use upper case for easier usage
boolean result = (imageCaptcha.validateResponse(anwser)).booleanValue();
if (result == false) {
// minhnn: I comment the below code because cannot get private variable 'response' from class Gimpy
//log.info("validateCaptchaResponse returned false due to wrong answer. The input is '" + anwser + "' but expect '" + imageCaptcha.getQuestion() + "'");
}
return result;
}
/**
* Check to make sure that the captcha answer is correct
*
* @param answer String the captcha answer to check
* @throws BadInputException in case the captcha answer is not correct
*/
public void ensureCorrectCaptchaResponse(String answer)
throws BadInputException {
if (validateCaptchaResponse(answer) == false) {
throw new BadInputException(MVNForumResourceBundle.getString(locale, "mvncore.exception.BadInputException.wrong_captcha"));
}
}
/*****************************************************************
* Default-scope methods, only for internal package usage
*****************************************************************/
void setMemberID(int memberID) {
if (memberID == 0) {
this.memberID = MVNForumConstant.MEMBER_ID_OF_GUEST;
} else {
this.memberID = memberID;
}
onlineUserAction.setMemberID(this.memberID);
}
void setMemberName(String memberName) {
this.memberName = memberName;
onlineUserAction.setMemberName(memberName);
}
void setInvisible(boolean invisible) {
this.invisible = invisible;
onlineUserAction.setMemberInvisible(invisible);
}
void setAuthenticationType(int authType) {
authenticationType = authType;
}
/**
* NOTE: this method SHOULD ONLY BE CALLED from OnlineUserFactory
*/
void setPermission(MVNForumPermission permission) {
this.permission = permission;
}
void setTimeZone(double timeZone) {
if ( (timeZone >= -12) && (timeZone <= 12) ) {
this.hourOffset = timeZone;
}
}
void setLastLogonTimestamp(Timestamp lastLogon) {
lastLogonTimestamp = lastLogon;
}
void setLastLogonIP(String lastLogonIP) {
this.lastLogonIP = lastLogonIP;
}
void setGender(boolean gender) {
this.gender = gender;
}
void setPostsPerPage(int postsPerPage) {
if (postsPerPage < 5) {
postsPerPage = 5;
}
this.memberPostsPerPage = postsPerPage;
}
public void setCssPath(String cssPath) {
this.memberCssPath = cssPath;
}
public void setLogoPath(String logoPath) {
this.memberLogoPath = logoPath;
}
// add this method to remove eclipse's warning
public boolean getGender() {
return gender;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -