List of usage examples for java.util Properties size
@Override public int size()
From source file:adalid.commons.properties.PropertiesHandler.java
public static Properties getResourceAsProperties(String resource) { if (StringUtils.isBlank(resource)) { return null; }/*from w w w .j av a 2 s. c om*/ Properties properties = new Properties(); try (InputStream stream = PropertiesHandler.class.getResourceAsStream(resource)) { if (stream == null) { logger.error("resource " + resource + " is missing"); } else { properties.load(stream); logger.info("resource " + resource + " loaded (" + properties.size() + " properties)"); } } catch (Exception ex) { logger.fatal(ex); } return properties; }
From source file:com.senseidb.svc.impl.HttpRestSenseiServiceImpl.java
private static String convertSelectionProperties(Properties props) { List<String> propList = new ArrayList<String>(props.size()); final String format = "%s:%s"; Set<Entry<Object, Object>> entries = props.entrySet(); for (Entry<Object, Object> entry : entries) { propList.add(String.format(format, entry.getKey(), entry.getValue())); }// w w w.j ava2 s. c om return join(propList, ","); }
From source file:com.jkoolcloud.tnt4j.streams.utils.LoggerUtils.java
private static void setLog4jConfig(byte[] data, EventSink logger) { Properties loggerProps = new Properties(); InputStream is = new ByteArrayInputStream(data); try {//from w w w. jav a 2 s. c om loggerProps.load(is); } catch (Exception exc) { logger.log(OpLevel.ERROR, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME, "LoggerUtils.log4j.load.error"), exc); } finally { Utils.close(is); } if (MapUtils.isEmpty(loggerProps)) { logger.log(OpLevel.INFO, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME, "LoggerUtils.log4j.empty.configuration")); } else { logger.log(OpLevel.DEBUG, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME, "LoggerUtils.log4j.reconfiguring"), loggerProps.size()); try { // org.apache.log4j.PropertyConfigurator.configure(loggerProps); invoke("org.apache.log4j.PropertyConfigurator", "configure", new Class[] { Properties.class }, // NON-NLS loggerProps); } catch (Exception exc) { logger.log(OpLevel.ERROR, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME, "LoggerUtils.log4j.reconfiguring.fail"), exc); } logger.log(OpLevel.DEBUG, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME, "LoggerUtils.log4j.reconfiguring.end")); } }
From source file:org.guzz.util.PropertyUtil.java
/** * JDK Properties?Key??. <BR>/*ww w . j a va 2 s . co m*/ * JDK PropertiestoString()key??, ?, ??. * @param props JDK Properties * @param keyPrefix key? * @return Properties?Key???. */ public static String toString(Properties props, String keyPrefix) { if (props == null || keyPrefix == null) { return "null! keyPrefix=" + keyPrefix; } final String delit = ", "; final int delitLen = delit.length(); StringBuffer sb = new StringBuffer(64); sb.append('{'); // ??()Key?. JDK // Hashtable(Properties)toString. synchronized (props) { int max = props.size() - 1; Iterator it = props.entrySet().iterator(); for (int i = 0; i <= max; i++) { Map.Entry e = (Map.Entry) (it.next()); String key = (String) e.getKey(); if (key.startsWith(keyPrefix)) { sb.append(key).append('=').append(e.getValue()); sb.append(delit); } } } sb.delete((sb.length() > delitLen) ? (sb.length() - delitLen) : 1, sb.length()); sb.append('}'); return sb.toString(); }
From source file:org.wso2.carbon.cep.admin.internal.CEPAdminUtils.java
/** * This method maps CEP Core module input topic list to CEP Admin module InputDTO array * * @param providerConfiguration/*from w w w .j av a 2s .c o m*/ */ public static CEPEngineProviderConfigPropertyDTO[] adaptEngineProviderConfigs( Properties providerConfiguration) { CEPEngineProviderConfigPropertyDTO[] cepEngineProviderPropertyDTO = null; if (providerConfiguration != null) { cepEngineProviderPropertyDTO = new CEPEngineProviderConfigPropertyDTO[providerConfiguration.size()]; int i = 0; for (Map.Entry<Object, Object> entry : providerConfiguration.entrySet()) { cepEngineProviderPropertyDTO[i] = new CEPEngineProviderConfigPropertyDTO(); cepEngineProviderPropertyDTO[i].setNames(entry.getKey().toString()); if (entry.getValue() instanceof String) { cepEngineProviderPropertyDTO[i].setValues((String) entry.getValue()); } else { cepEngineProviderPropertyDTO[i].setValues((String) ((List) entry.getValue()).get(0)); } i++; } return cepEngineProviderPropertyDTO; } else { return new CEPEngineProviderConfigPropertyDTO[] {}; } }
From source file:backtype.storm.utils.Utils.java
private static Map loadProperty(String prop) { Map ret = new HashMap<Object, Object>(); Properties properties = new Properties(); try {/*from www.j a v a 2 s. c o m*/ InputStream stream = new FileInputStream(prop); properties.load(stream); if (properties.size() == 0) { System.out.println("WARN: Config file is empty"); return null; } else { ret.putAll(properties); } } catch (FileNotFoundException e) { System.out.println("No such file " + prop); throw new RuntimeException(e.getMessage()); } catch (Exception e1) { e1.printStackTrace(); throw new RuntimeException(e1.getMessage()); } return ret; }
From source file:org.springforpro.chptr5.pe.PropertyEditorBean.java
public void setProperties(Properties properties) { System.out.println("Loaded : " + properties.size() + " properties"); this.properties = properties; }
From source file:adalid.util.i18n.Merger.java
public static void merge(String project) { logger.info(project);/*from w w w . j a v a2s . c o m*/ Mapper mapper = Mapper.map(project); // mapper.info(); String name, locale, tag, filename; List<File> list; File baseBundle; Properties baseProperties, localeProperties, mergedProperties; Map<String, List<File>> map = mapper.getMap(); Set<String> keySet = map.keySet(); for (String key : keySet) { logger.info(key); list = map.get(key); baseBundle = null; for (File bundle : list) { name = bundle.getName(); locale = locale(name); if (locale == null) { baseBundle = bundle; } } if (baseBundle == null) { continue; } baseProperties = PropertiesHandler.loadProperties(baseBundle, true); tag = baseProperties.getProperty(LOCALE_LANGUAGE_TAG); if (tag == null) { continue; } baseProperties.remove(LOCALE_LANGUAGE_TAG); logger.debug("\t" + baseBundle.getName() + " " + baseProperties.size()); for (File bundle : list) { name = bundle.getName(); locale = locale(name); if (locale != null) { localeProperties = PropertiesHandler.loadProperties(bundle, true); logger.debug("\t" + bundle.getName() + " " + localeProperties.size()); filename = TEST_DIR + locale + FILE_SEPARATOR + key + "_" + locale + ".properties"; if (locale.equals(tag)) { mergedProperties = baseProperties; } else { mergedProperties = merge(bundle, baseProperties, localeProperties); } PropertiesHandler.storeProperties(mergedProperties, filename); } } } }
From source file:org.codice.ddf.admin.insecure.defaults.service.PaxWebCfgFileValidator.java
@Override public List<Alert> validate() { resetAlerts();//from www .ja v a 2s. co m Properties properties = readFile(); if (properties != null && properties.size() > 0) { validateHttpIsDisabled(properties); } for (Alert alert : alerts) { LOGGER.debug("Alert: {}, {}", alert.getLevel(), alert.getMessage()); } return alerts; }
From source file:org.codice.ddf.admin.insecure.defaults.service.EncryptionPropertiesFileValidator.java
public List<Alert> validate() { resetAlerts();/*from ww w . j a va 2 s . c o m*/ Properties properties = readFile(); if (properties != null && properties.size() > 0) { validateKeystorePassword(properties); validatePrivateKeyPassword(properties); validateAlias(properties); } for (Alert alert : alerts) { LOGGER.debug("Alert: {}, {}", alert.getLevel(), alert.getMessage()); } return alerts; }