List of usage examples for org.apache.commons.configuration Configuration getList
List getList(String key, List defaultValue);
From source file:com.appeligo.search.actions.account.BaseAccountAction.java
@SuppressWarnings("unchecked") protected void prepareStateList(Configuration config) { List<String> stateList = config.getList("stateList.state", new ArrayList()); states = renderAsOgnlList(stateList); }
From source file:com.appeligo.search.actions.account.BaseAccountAction.java
@SuppressWarnings("unchecked") protected void prepareMonthList(Configuration config) { List<String> monthList = config.getList("months.month", new ArrayList()); months = renderAsOgnlList(monthList); }
From source file:com.appeligo.search.actions.account.BaseAccountAction.java
@SuppressWarnings("unchecked") protected void prepareGenderList(Configuration config) { ArrayList<String> temp = new ArrayList<String>(); temp.add("F"); temp.add("M"); List<String> genderList = config.getList("genderList.gender", temp); genders = renderAsOgnlList(genderList); }
From source file:com.germinus.easyconf.ComponentProperties.java
protected static Object getTypedPropertyWithDefault(String key, Class theClass, Configuration properties, Object defaultValue) {//w w w . j a v a 2s . c om if (theClass.equals(Float.class)) { return properties.getFloat(key, (Float) defaultValue); } else if (theClass.equals(Integer.class)) { return properties.getInteger(key, (Integer) defaultValue); } else if (theClass.equals(String.class)) { return properties.getString(key, (String) defaultValue); } else if (theClass.equals(Double.class)) { return properties.getDouble(key, (Double) defaultValue); } else if (theClass.equals(Long.class)) { return properties.getLong(key, (Long) defaultValue); } else if (theClass.equals(Boolean.class)) { return properties.getBoolean(key, (Boolean) defaultValue); } else if (theClass.equals(List.class)) { return properties.getList(key, (List) defaultValue); } else if (theClass.equals(BigInteger.class)) { return properties.getBigInteger(key, (BigInteger) defaultValue); } else if (theClass.equals(BigDecimal.class)) { return properties.getBigDecimal(key, (BigDecimal) defaultValue); } else if (theClass.equals(Byte.class)) { return properties.getByte(key, (Byte) defaultValue); } else if (theClass.equals(Short.class)) { return properties.getShort(key, (Short) defaultValue); } throw new IllegalArgumentException("Class " + theClass + " is not" + "supported for properties"); }
From source file:com.yahoo.bard.webservice.config.ConfigurationGraph.java
/** * Take a configuration and if it is a valid module, load it into the moduleConfigurations map and load it's * dependency moduleDependencies./* w w w . java 2 s.com*/ * * @param configuration A configuration which may be a module * @param configName The resource name for that configuration * @param nameValidator A function which throws exceptions on module names which are not valid. */ @SuppressWarnings("unchecked") private void addVertex(Configuration configuration, String configName, Consumer<String> nameValidator) { if (!configuration.containsKey(MODULE_NAME_KEY)) { // This may be the result of another library using one of our configuration names LOG.warn(MODULE_NAME_MISSING.logFormat(configName)); return; } String moduleName = configuration.getString(MODULE_NAME_KEY); nameValidator.accept(moduleName); LOG.debug(MODULE_FOUND_MESSAGE.logFormat(moduleName, configName)); if (moduleConfigurations.containsKey(moduleName)) { LOG.error(MODULE_NAME_DUPLICATION.format(configName, moduleName)); throw new SystemConfigException(MODULE_NAME_DUPLICATION.format(configName, moduleName)); } moduleConfigurations.put(moduleName, configuration); List<String> dependencies = new ArrayList<>( configuration.getList(DEPENDENT_MODULE_KEY, Collections.<String>emptyList())); // later dependencies have higher precedence. Store moduleDependencies in precedence order descending Collections.reverse(dependencies); moduleDependencies.put(moduleName, dependencies); }
From source file:com.knowbout.epg.processor.Parser.java
@SuppressWarnings("unchecked") public Parser(Configuration config, File headendFile, File lineupFile, File stationFile, File programFile, File scheduleFile) {// ww w .j a v a 2 s .c o m this.headendFile = headendFile; this.lineupFile = lineupFile; this.stationFile = stationFile; this.programFile = programFile; this.scheduleFile = scheduleFile; this.config = config; //Get the transaction count. This can affect the performance a lot Configuration transactions = config.subset("transactions"); headendTransaction = transactions.getInt("headends"); lineupTransaction = transactions.getInt("lineups"); stationTransaction = transactions.getInt("stations"); programTransaction = transactions.getInt("programs"); stationNames = new HashMap<String, String>(); List<String> names = config.getList("stationNames.station", new ArrayList<String>()); List<String> callSigns = config.getList("stationNames.station[@callSign]", new ArrayList<String>()); for (int i = 0; i < callSigns.size() && i < names.size(); i++) { stationNames.put(callSigns.get(i), names.get(i)); } }
From source file:org.apache.bookkeeper.common.conf.ConfigKey.java
/** * Retrieve the setting from the configuration <tt>conf</tt> as a {@link Class} value. * * @param conf configuration to retrieve the setting * @return the value as list of values/*from w w w.jav a 2 s . c o m*/ */ @SuppressWarnings("unchecked") public List<Object> getList(Configuration conf) { checkArgument(type() == Type.LIST, "'" + name() + "' is NOT a LIST setting"); List<Object> list = (List<Object>) defaultValue(); if (null == list) { list = Collections.emptyList(); } return conf.getList(name(), list); }
From source file:org.apache.marmotta.platform.core.util.FallbackConfiguration.java
@Override public List<Object> getList(String key, List<?> defaultValue) { final Configuration mem = getInMemoryConfiguration(); if (mem.containsKey(key)) return mem.getList(key, defaultValue); else//from w ww. j ava 2s. co m return super.getList(key, defaultValue); }
From source file:org.apache.tinkerpop.gremlin.hadoop.structure.io.HadoopPools.java
public synchronized static void initialize(final Configuration configuration) { if (!INITIALIZED) { INITIALIZED = true;//from www . j a v a 2 s . c om GRYO_POOL = GryoPool.build().poolSize(configuration.getInt(GryoPool.CONFIG_IO_GRYO_POOL_SIZE, 256)) .ioRegistries(configuration.getList(GryoPool.CONFIG_IO_REGISTRY, Collections.emptyList())) .create(); } }
From source file:org.apache.tinkerpop.gremlin.structure.io.gryo.GryoPoolTest.java
@Test public void shouldDoWithReaderWriterMethods() throws Exception { final Configuration conf = new BaseConfiguration(); final GryoPool pool = GryoPool.build() .ioRegistries(conf.getList(GryoPool.CONFIG_IO_REGISTRY, Collections.emptyList())).create(); try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) { pool.doWithWriter(writer -> writer.writeObject(os, 1)); os.flush();/*www .j a va2s.com*/ try (final ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray())) { assertEquals(1, pool.<Integer>doWithReader( FunctionUtils.wrapFunction(reader -> reader.readObject(is, Integer.class))) .intValue()); } } assertReaderWriter(pool.takeWriter(), pool.takeReader(), 1, Integer.class); }