📄 config.java
字号:
/*
* Copyright(C) 2008, NTT AT Co., Ltd.
* Project: AWGView
*
* Notes:
* N/A
*
* Record of change:
* Date Version Name Content
* 2008/12/15 1.0 TriNT First create
*/
package jp.co.ntt.awgview.server.common;
import java.util.Properties;
/**
* Class name : Config <BR>
* Package : jp.co.ntt_at.awgview.server.common <BR>
*
* Description : Utility function to store the config information <BR>
*
* @author : AI&T
* @version : 1.0
*/
public class Config {
private static Properties prop = null;
/**
* Empty constructor
*/
public Config() {
}
/**
* Loads the properties from the source .properties file specified and
* over-rides them with those found in the merge file.
*/
public static Properties loadFile(String fileName) {
prop = Utils.loadFile2Properties(fileName);
return prop;
}
/**
* Get parameter value by parameter name
*
* @param paramName
* @return paramValue from properties file
*/
public static String getParamConfig(String paramName) {
if (prop != null) {
String paramValue = prop.getProperty(paramName);
if (paramValue != null) {
if (!"".equalsIgnoreCase(paramValue.trim())) {
return paramValue.trim();
}
}
}
return null;
}
/**
* Get parameter is string
*
* @param paramName
* @return String
*/
public static String getString(String paramName) {
String val = null;
try {
val = getParamConfig(paramName);
} catch (Exception e) {
// handle exception
}
return val;
}
/**
* Get parameter is long
*
* @param paramName
* @return long
*/
public static long getLong(String paramName) {
long val = -1;
try {
String strValue = getParamConfig(paramName);
val = Long.valueOf(strValue);
} catch (Exception e) {
// handle exception
LogWriter.getSNMPLogger().error(e.toString());
}
return val;
}
/**
* Get parameter is Int.
*
* @param paramName
* @param defaultValue
* @return int
*/
public static int getInt(String paramName, int defaultValue) {
return Utils.parseInt(Config.getParamConfig(paramName), defaultValue);
}
/**
* Get parameter is boolean.
*
* @param paramName
* @param defaultValue
* @return boolean
*/
public static boolean getBoolean(String paramName, boolean defaultValue) {
boolean result = defaultValue;
String StringTemp = Config.getParamConfig(paramName);
if ((StringTemp != null) && (StringTemp.trim().length() > 0)) {
StringTemp = StringTemp.trim();
if ("true".equalsIgnoreCase(StringTemp)) {
result = true;
} else if ("false".equalsIgnoreCase(StringTemp)) {
result = false;
} else {
// todo nothing
}
}
return result;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -