當前位置: 首頁>>代碼示例>>Java>>正文


Java XMLConfiguration.getStringArray方法代碼示例

本文整理匯總了Java中org.apache.commons.configuration.XMLConfiguration.getStringArray方法的典型用法代碼示例。如果您正苦於以下問題:Java XMLConfiguration.getStringArray方法的具體用法?Java XMLConfiguration.getStringArray怎麽用?Java XMLConfiguration.getStringArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.configuration.XMLConfiguration的用法示例。


在下文中一共展示了XMLConfiguration.getStringArray方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadRegexAlerts

import org.apache.commons.configuration.XMLConfiguration; //導入方法依賴的package包/類
public static Map<String, JSONObject> loadRegexAlerts(String config_path)
		throws ConfigurationException, ParseException {
	XMLConfiguration alert_rules = new XMLConfiguration();
	alert_rules.setDelimiterParsingDisabled(true);
	alert_rules.load(config_path);

	//int number_of_rules = alert_rules.getList("rule.pattern").size();

	String[] patterns = alert_rules.getStringArray("rule.pattern");
	String[] alerts = alert_rules.getStringArray("rule.alert");

	JSONParser pr = new JSONParser();
	Map<String, JSONObject> rules = new HashMap<String, JSONObject>();

	for (int i = 0; i < patterns.length; i++)
		rules.put(patterns[i], (JSONObject) pr.parse(alerts[i]));

	return rules;
}
 
開發者ID:apache,項目名稱:metron,代碼行數:20,代碼來源:SettingsLoader.java

示例2: getParameterValue

import org.apache.commons.configuration.XMLConfiguration; //導入方法依賴的package包/類
public static Object getParameterValue(XMLConfiguration config, int currentRule, int currentParameter, String parameterType) throws Exception {
		String key = "AccessControlRules.AccessControlRule(" + 
			currentRule + ").Parameters.Parameter(" + currentParameter + ")[@value]";
		Object parameterValue;
		if("String".equalsIgnoreCase(parameterType)) {
			parameterValue = config.getString(key);
		} else if("StringArray".equalsIgnoreCase(parameterType)) {
			parameterValue = config.getStringArray(key);
		} else if("Boolean".equalsIgnoreCase(parameterType)){ 
			parameterValue = config.getBoolean(key);
		} else if("Byte".equalsIgnoreCase(parameterType)){ 
			parameterValue = config.getByte(key);
		} else if("Int".equalsIgnoreCase(parameterType)){ 
			parameterValue = config.getInt(key);
		} else if("Long".equalsIgnoreCase(parameterType)){ 
			parameterValue = config.getLong(key);
		} else if("Float".equalsIgnoreCase(parameterType)){ 
			parameterValue = config.getFloat(key);
		} else if("Double".equalsIgnoreCase(parameterType)){ 
			parameterValue = config.getDouble(key);
		} else if("BigDecimal".equalsIgnoreCase(parameterType)){ 
			parameterValue = config.getBigDecimal(key);
		} else if("BigInteger".equalsIgnoreCase(parameterType)){ 
			parameterValue = config.getBigInteger(key);
		} else if("Date".equalsIgnoreCase(parameterType)){
			parameterValue = java.text.DateFormat.getDateInstance().parse(config.getString(key));
		} else if("Time".equalsIgnoreCase(parameterType)){
			java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("h:mm a");
			parameterValue = sdf.parseObject(config.getString(key)); 
//			parameterValue = java.text.DateFormat.getTimeInstance().parse(config.getString(key));
		}		
		//add timestamp. check for other stuff.
		else {
			throw new IllegalArgumentException("Unable to load the key \"" + key 
					+ "\", because " + "the type \"" + parameterType + 
					"\" was not recognized." );
		}
		return parameterValue;
	}
 
開發者ID:abimael93,項目名稱:owasp-esapi-java,代碼行數:40,代碼來源:ACRParameterLoaderHelper.java


注:本文中的org.apache.commons.configuration.XMLConfiguration.getStringArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。