本文整理汇总了Java中org.apache.commons.configuration.XMLConfiguration.getLong方法的典型用法代码示例。如果您正苦于以下问题:Java XMLConfiguration.getLong方法的具体用法?Java XMLConfiguration.getLong怎么用?Java XMLConfiguration.getLong使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.configuration.XMLConfiguration
的用法示例。
在下文中一共展示了XMLConfiguration.getLong方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initSimulator
import org.apache.commons.configuration.XMLConfiguration; //导入方法依赖的package包/类
/**
* initializes the fields and starts the simulator.
*
* @throws SimulatorException if the event input file could not be opened.
*/
private void initSimulator() throws SimulatorException {
// load properties from config file
XMLConfiguration config = new XMLConfiguration();
URL fileurl = ResourceLocator.getURL(configFile, defaultConfigFile,
this.getClass());
try {
config.load(fileurl);
} catch (ConfigurationException ce) {
throw new SimulatorException("Can not load config file '" + configFile + "'.");
}
// get properties
String file = config.getString("batchfile");
cycles = config.getLong("iterations");
// find batchfile
URL batchfileurl = ResourceLocator.getURL(file, file, this.getClass());
try {
eventFile = new File(batchfileurl.toURI());
} catch (URISyntaxException e1) {
throw new SimulatorException("Can not creat URI of batchfile '" + file + "'.");
}
rfidThread = null;
threadRunning = false;
stopRequested = false;
try {
// tries to open file
FileReader in = new FileReader(eventFile);
in.close();
// start simulator thread
start();
} catch (IOException e) {
throw new SimulatorException("Cannot open event file '"+file+"': "+e);
}
}
示例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;
}