com.frameworkset.platform.util.I18nResource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pdp-system Show documentation
Show all versions of pdp-system Show documentation
bboss public development platform base on bboss.
package com.frameworkset.platform.util;
import java.util.Locale;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.frameworkset.web.servlet.support.RequestContextUtils;
public abstract class I18nResource implements java.io.Serializable{
protected Map localeNames;
protected Map localeDescriptions;
public Map getLocaleNames() {
return localeNames;
}
public void setLocaleNames(Map localeNames) {
this.localeNames = localeNames;
}
public Map getLocaleDescriptions() {
return localeDescriptions;
}
public void setLocaleDescriptions(Map localeDescriptions) {
this.localeDescriptions = localeDescriptions;
}
public String getName(HttpServletRequest request) {
// if(this.localeNames == null)
// return null;
// Locale locale = RequestContextUtils.getRequestContextLocal(request);
// String temp = this.localeNames.get(locale);
// if(temp == null)
// return null;
// return temp;
//
return getLocaleMessage(localeNames, request);
}
public String getDescription(HttpServletRequest request) {
// if(this.localeDescriptions == null)
// return null;
// Locale locale = RequestContextUtils.getRequestContextLocal(request);
// String temp = this.localeDescriptions.get(locale);
// if(temp == null)
// return null;
// return temp;
return getLocaleMessage(localeDescriptions, request);
}
private String getLocaleMessage(Map messages,HttpServletRequest request) {
if(messages == null)
return null;
Locale locale = RequestContextUtils.getRequestContextLocal(request);
String temp = messages.get(locale);
if(temp == null)
return null;
return temp;
}
}