【fix sonar】 I18nUtil.java文件
This commit is contained in:
+17
-7
@@ -20,6 +20,9 @@ import java.util.Properties;
|
|||||||
* @author xuxueli 2018-01-17 20:39:06
|
* @author xuxueli 2018-01-17 20:39:06
|
||||||
*/
|
*/
|
||||||
public class I18nUtil {
|
public class I18nUtil {
|
||||||
|
private I18nUtil() {
|
||||||
|
}
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(I18nUtil.class);
|
private static Logger logger = LoggerFactory.getLogger(I18nUtil.class);
|
||||||
|
|
||||||
private static Properties prop = null;
|
private static Properties prop = null;
|
||||||
@@ -49,7 +52,11 @@ public class I18nUtil {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String getString(String key) {
|
public static String getString(String key) {
|
||||||
return loadI18nProp().getProperty(key);
|
Properties properties = loadI18nProp();
|
||||||
|
if(properties!=null&&properties.getProperty(key)!=null){
|
||||||
|
return properties.getProperty(key);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,21 +66,24 @@ public class I18nUtil {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String getMultString(String... keys) {
|
public static String getMultString(String... keys) {
|
||||||
Map<String, String> map = new HashMap<String, String>();
|
Map<String, String> map = new HashMap<>();
|
||||||
|
|
||||||
Properties prop = loadI18nProp();
|
Properties prop = loadI18nProp();
|
||||||
if (keys!=null && keys.length>0) {
|
if (keys!=null && keys.length>0) {
|
||||||
for (String key: keys) {
|
for (String key: keys) {
|
||||||
map.put(key, prop.getProperty(key));
|
if(prop!=null) {
|
||||||
|
map.put(key, prop.getProperty(key));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (String key: prop.stringPropertyNames()) {
|
if(prop!=null){
|
||||||
map.put(key, prop.getProperty(key));
|
for (String key : prop.stringPropertyNames()) {
|
||||||
|
map.put(key, prop.getProperty(key));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String json = JacksonUtil.writeValueAsString(map);
|
return JacksonUtil.writeValueAsString(map);
|
||||||
return json;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user