List of usage examples for org.apache.commons.configuration Configuration getStringArray
String[] getStringArray(String key);
From source file:common.ConfigTest.java
public static void main(String[] args) { URL configURL = ConfigTest.class.getResource("config.xml"); DefaultConfigurationBuilder db = new DefaultConfigurationBuilder(); db.setConfigurationBasePath(configURL.getPath()); Configuration configuration = null; try {//w w w . j a v a2 s. c o m configuration = db.getConfiguration(); } catch (ConfigurationException ex) { } if (configuration != null) { String[] fileNames = configuration.getStringArray("fileName"); for (String fileName : fileNames) { System.out.println(fileName); } } }
From source file:com.manydesigns.elements.configuration.CommonsConfigurationFunctions.java
public static String[] getStringArray(Configuration configuration, String key) { return configuration.getStringArray(key); }
From source file:com.feedzai.fos.common.validation.ValidationUtils.java
/** * Gets a <code>String[]</code> from the given configuration. * * @param configuration the configuration where the parameter lies * @param parameterName the name of the parameter * @return the <code>String[]</code> * @throws IllegalArgumentException if the parameter is empty *///from w ww.ja va 2 s . co m @NotEmpty public static String[] getStringArrayNotEmpty(Configuration configuration, @NotBlank String parameterName) { return Validate.notEmpty(configuration.getStringArray(parameterName), NOT_EMPTY, parameterName); }
From source file:cz.cas.lib.proarc.common.export.Kramerius4ExportOptions.java
public static Kramerius4ExportOptions from(Configuration config) { Kramerius4ExportOptions options = new Kramerius4ExportOptions(); String[] excludeIds = config.getStringArray(PROP_EXCLUDE_DATASTREAM_ID); options.setExcludeDatastreams(new HashSet<String>(Arrays.asList(excludeIds))); Configuration renames = config.subset(PROP_RENAME_PREFIX); HashMap<String, String> dsIdMap = new HashMap<String, String>(); // use RAW if FULL ds is not available dsIdMap.put(BinaryEditor.RAW_ID, "IMG_FULL"); for (Iterator<String> it = renames.getKeys(); it.hasNext();) { String dsId = it.next();/* w w w .j a v a2 s .co m*/ String newDsId = renames.getString(dsId); dsIdMap.put(dsId, newDsId); } options.setDsIdMap(dsIdMap); String policy = config.getString(PROP_POLICY); if (policy != null && !policy.isEmpty()) { options.setPolicy(policy); } return options; }
From source file:eu.planetdata.srbench.oracle.Utility.java
public static TimestampedRelation importRelation(String filename, Logger logger) { try {//from w w w . j av a 2 s . c om TimestampedRelation ret; Configuration relationImporter = new PropertiesConfiguration(filename); ret = new TimestampedRelation(); ret.setComputationTimestamp(relationImporter.getLong("timestamp")); for (String s : relationImporter.getStringArray("sensor")) { TimestampedRelationElement tre = new TimestampedRelationElement(); tre.add("sensor", new URIImpl(s)); //FIXME: should import the element timestamp! tre.setTimestamp(relationImporter.getLong("timestamp")); ret.addElement(tre); } return ret; } catch (ConfigurationException e) { logger.error("Error while reading the configuration file", e); fail(); } return null; }
From source file:edu.berkeley.sparrow.daemon.util.ConfigUtil.java
/** * Parses the list of backends from a {@link Configuration}. * * Returns a map of address of backends to a {@link TResourceVector} describing the * total resource capacity for that backend. */// www . ja va 2 s. c o m public static Set<InetSocketAddress> parseBackends(Configuration conf) { if (!conf.containsKey(SparrowConf.STATIC_NODE_MONITORS)) { throw new RuntimeException("Missing configuration node monitor list"); } Set<InetSocketAddress> backends = new HashSet<InetSocketAddress>(); for (String node : conf.getStringArray(SparrowConf.STATIC_NODE_MONITORS)) { Optional<InetSocketAddress> addr = Serialization.strToSocket(node); if (!addr.isPresent()) { LOG.warn("Bad backend address: " + node); continue; } backends.add(addr.get()); } return backends; }
From source file:ch.epfl.eagle.daemon.util.ConfigUtil.java
/** * Parses the list of backends from a {@link Configuration}. * * Returns a map of address of backends to a {@link TResourceVector} describing the * total resource capacity for that backend. *//*ww w.ja va 2 s . c o m*/ public static Set<InetSocketAddress> parseBackends(Configuration conf) { if (!conf.containsKey(EagleConf.STATIC_NODE_MONITORS)) { throw new RuntimeException("Missing configuration node monitor list"); } Set<InetSocketAddress> backends = new HashSet<InetSocketAddress>(); for (String node : conf.getStringArray(EagleConf.STATIC_NODE_MONITORS)) { Optional<InetSocketAddress> addr = Serialization.strToSocket(node); if (!addr.isPresent()) { LOG.warn("Bad backend address: " + node); continue; } backends.add(addr.get()); } return backends; }
From source file:com.linkedin.pinot.common.metrics.MetricsHelper.java
/** * Initializes the metrics system by initializing the registry registration listeners present in the configuration. * * @param configuration The subset of the configuration containing the metrics-related keys *///from w w w . j av a2 s .c om public static void initializeMetrics(Configuration configuration) { synchronized (MetricsHelper.class) { String[] listenerClassNames = configuration.getStringArray("metricsRegistryRegistrationListeners"); if (listenerClassNames.length < 1) { listenerClassNames = new String[] { JmxReporterMetricsRegistryRegistrationListener.class.getName() }; } // Build each listener using their default constructor and add them for (String listenerClassName : listenerClassNames) { try { Class<? extends MetricsRegistryRegistrationListener> clazz = (Class<? extends MetricsRegistryRegistrationListener>) Class .forName(listenerClassName); Constructor<? extends MetricsRegistryRegistrationListener> defaultConstructor = clazz .getDeclaredConstructor(); MetricsRegistryRegistrationListener listener = defaultConstructor.newInstance(); addMetricsRegistryRegistrationListener(listener); } catch (Exception e) { LOGGER.warn("Caught exception while initializing MetricsRegistryRegistrationListener " + listenerClassName, e); } } } }
From source file:gaffer.gafferpop.GafferPopGraph.java
private static Graph createGraph(final Configuration configuration) { final Path storeProps = Paths.get(configuration.getString(STORE_PROPERTIES)); final Schema schema = new Schema(); for (String schemaPath : configuration.getStringArray(SCHEMAS)) { schema.merge(Schema.fromJson(Paths.get(schemaPath))); }/*from w w w .j a v a 2 s . c o m*/ return new Graph.Builder().storeProperties(storeProps).addSchema(schema).build(); }
From source file:com.netflix.client.config.DefaultClientConfigImpl.java
/** * This is to workaround the issue that {@link AbstractConfiguration} by default * automatically convert comma delimited string to array *///from www.ja v a 2 s . c o m protected static String getStringValue(Configuration config, String key) { try { String values[] = config.getStringArray(key); if (values == null) { return null; } if (values.length == 0) { return config.getString(key); } else if (values.length == 1) { return values[0]; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < values.length; i++) { sb.append(values[i]); if (i != values.length - 1) { sb.append(","); } } return sb.toString(); } catch (Exception e) { Object v = config.getProperty(key); if (v != null) { return String.valueOf(v); } else { return null; } } }