속성값 읽기 편의기능추가
This commit is contained in:
parent
3f0e36e0e1
commit
1ad7b18660
@ -10,6 +10,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import nlib.util.StringUtil;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* @Class Name : NlibProperty.java
|
||||
@ -109,4 +111,55 @@ public class NlibProperty {
|
||||
|
||||
return properties.getProperty(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* name 값을 키로하는 속성값을 문자열 형태로 리턴한다. (getProperty(..)와 동일)
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public static String getString(String name) {
|
||||
return getProperty(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* name 값을 키로하는 속성값을 정부형태로 리턴한다.
|
||||
* 만일 값이 부재이거나 정부값으로 적합하지 않을 경우, defaultValue를 리턴한다.
|
||||
*
|
||||
* @param name
|
||||
* @param defaultValue
|
||||
* @return
|
||||
*/
|
||||
public static int getInt(String name, int defaultValue) {
|
||||
try {
|
||||
return getInt(name);
|
||||
} catch(Exception e) {
|
||||
log.error("[속성값 읽기 오류] " + e.toString());
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* name 값을 키로하는 속성값을 정부형태로 리턴한다.
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static int getInt(String name) throws Exception {
|
||||
|
||||
if(StringUtil.isEmpty(name)) {
|
||||
throw new Exception("속성값의 명칭 정보가 부적합합니다.");
|
||||
}
|
||||
|
||||
String val = getProperty(name);
|
||||
|
||||
if(StringUtil.isEmpty(val)) {
|
||||
throw new Exception("해당 속성값이 존재하지 않습니다.");
|
||||
}
|
||||
|
||||
return Integer.parseInt(val.trim());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user