List of usage examples for org.apache.commons.configuration Configuration getList
List getList(String key);
From source file:com.tulskiy.musique.system.configuration.PlaylistConfiguration.java
public static List<String> getTabBounds() { Configuration config = Application.getInstance().getConfiguration(); return (List<String>) config.getList(getTabBoundKey()); }
From source file:com.tulskiy.musique.system.configuration.PlaylistConfiguration.java
@Deprecated public static List<PlaylistColumn> getColumns() { Configuration config = Application.getInstance().getConfiguration(); List<String> columnsRaw = (List<String>) config.getList(getColumnKey()); ArrayList<PlaylistColumn> columns = new ArrayList<PlaylistColumn>(); if (!CollectionUtils.isEmpty(columnsRaw)) { for (String columnRaw : columnsRaw) { columns.add(new PlaylistColumn(columnRaw)); }/*w w w . java 2 s . c o m*/ } return columns; }
From source file:com.opentable.config.Config.java
/** * Loads the configuration. The no-args method uses system properties to determine which configurations * to load.//from w w w . j a v a 2 s. c o m * * -Dot.config=x/y/z defines a hierarchy of configurations from general * to detail. * * The ot.config.location variable must be set. * If the ot.config variable is unset, the default value "default" is used. * * @throws IllegalStateException If the ot.config.location variable is not set. */ public static Config getConfig() { final Configuration systemConfig = new SystemConfiguration(); final String configName = StringUtils.join(systemConfig.getList(CONFIG_PROPERTY_NAME), ','); final String configLocation = systemConfig.getString(CONFIG_LOCATION_PROPERTY_NAME); Preconditions.checkState(configLocation != null, "Config location must be set!"); final ConfigFactory configFactory = new ConfigFactory(URI.create(configLocation), configName); return new Config(configFactory.load()); }
From source file:gobblin.metastore.util.DatabaseJobHistoryStoreSchemaManager.java
private static Properties getProperties(Configuration config) { Properties props = new Properties(); char delimiter = (config instanceof AbstractConfiguration) ? ((AbstractConfiguration) config).getListDelimiter() : ','; Iterator keys = config.getKeys(); while (keys.hasNext()) { String key = (String) keys.next(); List list = config.getList(key); props.setProperty("flyway." + key, StringUtils.join(list.iterator(), delimiter)); }//from www .j av a 2s . co m return props; }
From source file:ffx.autoparm.Keyword_poltype.java
/** * This method sets up configuration properties in the following precedence * order: 1.) Java system properties a.) -Dkey=value from the Java command * line b.) System.setProperty("key","value") within Java code. * * 2.) Structure specific properties (for example pdbname.properties) * * 3.) User specific properties (~/.ffx/ffx.properties) * * 4.) System wide properties (file defined by environment variable * FFX_PROPERTIES)//from w w w . j a v a 2 s.c o m * * 5.) Internal force field definition. * * @since 1.0 * @param file a {@link java.io.File} object. * @return a {@link org.apache.commons.configuration.CompositeConfiguration} * object. */ public static CompositeConfiguration loadProperties(File file) { /** * Command line options take precedences. */ CompositeConfiguration properties = new CompositeConfiguration(); properties.addConfiguration(new SystemConfiguration()); /** * Structure specific options are 2nd. */ if (file != null && file.exists() && file.canRead()) { try { BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file))); String prmfilename = br.readLine().split(" +")[1]; File prmfile = new File(prmfilename); if (prmfile.exists() && prmfile.canRead()) { properties.addConfiguration(new PropertiesConfiguration(prmfile)); properties.addProperty("propertyFile", prmfile.getCanonicalPath()); } } catch (Exception e1) { e1.printStackTrace(); } } // /** // * User specific options are 3rd. // */ // String filename = System.getProperty("user.home") + File.separator // + ".ffx/ffx.properties"; // File userPropFile = new File(filename); // if (userPropFile.exists() && userPropFile.canRead()) { // try { // properties.addConfiguration(new PropertiesConfiguration( // userPropFile)); // } catch (Exception e) { // logger.info("Error loading " + filename + "."); // } // } // // /** // * System wide options are 2nd to last. // */ // filename = System.getenv("FFX_PROPERTIES"); // if (filename != null) { // File systemPropFile = new File(filename); // if (systemPropFile.exists() && systemPropFile.canRead()) { // try { // properties.addConfiguration(new PropertiesConfiguration( // systemPropFile)); // } catch (Exception e) { // logger.info("Error loading " + filename + "."); // } // } // } /** * Echo the interpolated configuration. */ if (logger.isLoggable(Level.FINE)) { Configuration config = properties.interpolatedConfiguration(); Iterator<String> i = config.getKeys(); while (i.hasNext()) { String s = i.next(); logger.fine("Key: " + s + ", Value: " + Arrays.toString(config.getList(s).toArray())); } } return properties; }
From source file:com.qmetry.qaf.automation.testng.pro.DataProviderUtil.java
public static List<Object[]> getDataSetAsMap(String key) { Configuration config = ConfigurationManager.getBundle().subset(key); ArrayList<Object[]> dataset = new ArrayList<Object[]>(); if (config.isEmpty()) { logger.error("Missing data with key [" + key + "]. "); throw new DataProviderException("Not test data found with key:" + key); }//from w ww.ja va2 s . c o m int size = config.getList(config.getKeys().next().toString()).size(); for (int i = 0; i < size; i++) { Map<String, String> map = new LinkedHashMap<String, String>(); Iterator<?> iter = config.getKeys(); while (iter.hasNext()) { String dataKey = String.valueOf(iter.next()); try { map.put(dataKey, config.getStringArray(dataKey)[i]); } catch (ArrayIndexOutOfBoundsException e) { logger.error( "Missing entry for property " + dataKey + ". Provide value for each property (or blank) in each data set in data file.", e); throw e; } } dataset.add(new Object[] { map }); } return dataset; }
From source file:dk.dma.ais.abnormal.analyzer.AbnormalAnalyzerAppModule.java
/** * Initialize internal data structures required to accept/reject track updates based on black list mechanism. * @param configuration/*from w w w.ja va 2 s. c om*/ * @return */ private static int[] initVesselBlackList(Configuration configuration) { ArrayList<Integer> blacklistedMmsis = new ArrayList<>(); try { List blacklistedMmsisConfig = configuration.getList("blacklist.mmsi"); blacklistedMmsisConfig.forEach(blacklistedMmsi -> { try { Integer blacklistedMmsiBoxed = Integer.valueOf(blacklistedMmsi.toString()); if (blacklistedMmsiBoxed > 0 && blacklistedMmsiBoxed < 1000000000) { blacklistedMmsis.add(blacklistedMmsiBoxed); } else if (blacklistedMmsiBoxed != -1) { LOG.warn("Black listed MMSI no. out of range: " + blacklistedMmsiBoxed + "."); } } catch (NumberFormatException e) { LOG.warn("Black listed MMSI no. \"" + blacklistedMmsi + "\" cannot be cast to integer."); } }); } catch (ConversionException e) { LOG.warn(e.getMessage(), e); } if (blacklistedMmsis.size() > 0) { LOG.info("The following " + blacklistedMmsis.size() + " MMSI numbers are black listed and will not be tracked."); LOG.info(Arrays.toString(blacklistedMmsis.toArray())); } int[] array = new int[blacklistedMmsis.size()]; for (int i = 0; i < blacklistedMmsis.size(); i++) { array[i] = blacklistedMmsis.get(i); } return array; }
From source file:de.tudarmstadt.ukp.dariah.pipeline.RunPipeline.java
/** * Parses a parameter string that can be found in the .properties files. * The parameterString is of the format parameterName1,parameterType1,parameterValue2,parameterName2,parameterType2,parameterValue2 * @param config /*from ww w . j av a 2 s. c o m*/ * * @param parametersString * @return Mapped paramaterString to an Object[] array that can be inputted to UIMA components */ private static Object[] parseParameters(Configuration config, String parameterName) throws ConfigurationException { LinkedList<Object> parameters = new LinkedList<>(); List<Object> parameterList = config.getList(parameterName); if (parameterList.size() % 3 != 0) { throw new ConfigurationException( "Parameter String must be a multiple of 3 in the format: name, type, value. " + parameterName); } for (int i = 0; i < parameterList.size(); i += 3) { String name = (String) parameterList.get(i + 0); String type = ((String) parameterList.get(i + 1)).toLowerCase(); String value = (String) parameterList.get(i + 2); Object obj; switch (type) { case "bool": case "boolean": obj = Boolean.valueOf(value); break; case "int": case "integer": obj = Integer.valueOf(value); break; default: obj = value; } parameters.add(name); parameters.add(obj); } return parameters.toArray(new Object[0]); }
From source file:com.cloudera.whirr.cm.CmServerClusterInstance.java
@SuppressWarnings("unchecked") public static SortedSet<String> getMounts(ClusterSpec specification, Set<Instance> instances) throws IOException { Configuration configuration = getConfiguration(specification); SortedSet<String> mounts = new TreeSet<String>(); Set<String> deviceMappings = CmServerClusterInstance.getDeviceMappings(specification, instances).keySet(); if (!configuration.getList(CONFIG_WHIRR_DATA_DIRS_ROOT).isEmpty()) { mounts.addAll(configuration.getList(CONFIG_WHIRR_DATA_DIRS_ROOT)); } else if (!deviceMappings.isEmpty()) { mounts.addAll(deviceMappings);/*from www. j ava 2 s . c o m*/ } else { mounts.add(configuration.getString(CONFIG_WHIRR_INTERNAL_DATA_DIRS_DEFAULT)); } return mounts; }
From source file:com.appeligo.channelfeed.SendCaptionFiles.java
@Override protected void openSources(Configuration provider) { int fileCount = provider.getList("files.file[@name]").size(); for (int j = 0; j < fileCount; j++) { String fileName = provider.getString("files.file(" + j + ")[@name]"); String callsign = provider.getString("files.file(" + j + ")[@callsign]"); String loop = provider.getString("files.file(" + j + ")[@loop]"); String autoAdvance = provider.getString("files.file(" + j + ")[@autoAdvance]"); String advanceSeconds = provider.getString("files.file(" + j + ")[@advanceSeconds]"); if ((autoAdvance != null) && (advanceSeconds != null)) { log.error("autoAdvance and advanceSeconds are mutually exclusive"); continue; }/* w ww . j a va2s . c om*/ log.info("fileName=" + fileName + ", callsign=" + callsign + ", advanceSeconds=" + advanceSeconds); if (fileName == null || callsign == null) { //TODO: change to a logging call log.error("Invalid configuration in: " + identifyMe()); log.error(" fileName=" + fileName + ", callsign=" + callsign); continue; } try { FileReaderThread fileThread = new FileReaderThread( "File Captions " + getLineupID() + ", callsign " + callsign); fileThread.setEpgService(getEpgService()); fileThread.setCcDocumentRoot(getCaptionDocumentRoot()); fileThread.setCaptionFileName(fileName); if (advanceSeconds != null) { fileThread.setAdvanceSeconds(Integer.parseInt(advanceSeconds)); } else if (autoAdvance != null) { fileThread.setAutoAdvance(Boolean.parseBoolean(autoAdvance)); } if (loop != null) { fileThread.setLoop(Boolean.parseBoolean(loop)); } Destinations destinations = setupDestinations(); destinations.setCallsign(callsign); destinations.setSendXDS(false); destinations.setSendITV(false); destinations.setFileWriter(null); fileThread.setDestinations(destinations); destinations.connect(); fileThread.start(); } catch (MalformedURLException e1) { log.error("Exception on a channel", e1); } catch (NumberFormatException e1) { log.error("Exception on a channel", e1); } catch (IOException e1) { log.error("Exception on a channel", e1); } } }