List of usage examples for java.util Dictionary get
public abstract V get(Object key);
From source file:com.whizzosoftware.hobson.bootstrap.api.hub.OSGIHubManager.java
@Override public String getHubName(String userId, String hubId) { Configuration config = getConfiguration(); Dictionary props = getConfigurationProperties(config); return (String) props.get(HUB_NAME); }
From source file:org.openhab.action.openwebif.internal.OpenWebIfActionService.java
/** * {@inheritDoc}//from w w w . j av a2s . c o m */ @Override public void updated(Dictionary<String, ?> properties) throws ConfigurationException { if (properties != null) { Enumeration<String> keys = properties.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); String value = StringUtils.trimToNull((String) properties.get(key)); if (StringUtils.startsWithIgnoreCase(key, "receiver")) { parseConfig(key, value); } } for (OpenWebIfConfig config : OpenWebIf.getConfigs().values()) { if (!config.isValid()) { throw new ConfigurationException("openwebif", "Invalid OpenWebIf receiver configuration: " + config.toString()); } logger.info("{}", config.toString()); } } }
From source file:org.openhab.binding.followmemusic.internal.FollowMeMusicBinding.java
/** * @{inheritDoc}//from w w w .j a v a2 s . c o m */ @Override public void updated(Dictionary<String, ?> config) throws ConfigurationException { if (config != null) { // to override the default refresh interval one has to add a // parameter to openhab.cfg like <bindingName>:refresh=<intervalInMs> String refreshIntervalString = (String) config.get("refresh"); if (StringUtils.isNotBlank(refreshIntervalString)) { refreshInterval = Long.parseLong(refreshIntervalString); } // read further config parameters here ... setProperlyConfigured(true); } }
From source file:org.openhab.binding.withings.internal.api.WithingsAuthenticator.java
@Override public void updated(Dictionary<String, ?> config) throws ConfigurationException { if (config != null) { String redirectUrl = (String) config.get("redirectUrl"); if (StringUtils.isNotBlank(redirectUrl)) { this.redirectUrl = redirectUrl; }/*from w w w .ja va 2 s . c o m*/ String consumerKeyString = (String) config.get("consumerkey"); if (StringUtils.isNotBlank(consumerKeyString)) { this.consumerKey = consumerKeyString; } String consumerSecretString = (String) config.get("consumersecret"); if (StringUtils.isNotBlank(consumerSecretString)) { this.consumerSecret = consumerSecretString; } Enumeration<String> configKeys = config.keys(); while (configKeys.hasMoreElements()) { String configKey = (String) configKeys.nextElement(); // the config-key enumeration contains additional keys that we // don't want to process here ... if ("redirectUrl".equals(configKey) || "consumerkey".equals(configKey) || "consumersecret".equals(configKey) || "service.pid".equals(configKey)) { continue; } String accountId; String configKeyTail; if (configKey.contains(".")) { String[] keyElements = configKey.split("\\."); accountId = keyElements[0]; configKeyTail = keyElements[1]; } else { accountId = DEFAULT_ACCOUNT_ID; configKeyTail = configKey; } WithingsAccount account = accountsCache.get(accountId); if (account == null) { account = new WithingsAccount(accountId, consumerKey, consumerSecret); accountsCache.put(accountId, account); } String value = (String) config.get(configKeyTail); if ("userid".equals(configKeyTail)) { account.userId = value; } else if ("token".equals(configKeyTail)) { account.token = value; } else if ("tokensecret".equals(configKeyTail)) { account.tokenSecret = value; } else { throw new ConfigurationException(configKey, "The given configuration key is unknown!"); } } registerAccounts(); } }
From source file:org.openhab.binding.dsmr.internal.DSMRBinding.java
/** * Read the dsmr:port and dsmr:<metertype>.channel properties *//*from www . ja v a 2 s. c o m*/ @Override public void updated(Dictionary<String, ?> config) throws ConfigurationException { logger.debug("updated() is called!"); if (config != null) { // Read port string String portString = (String) config.get("port"); logger.debug("dsmr:port=" + portString); if (StringUtils.isNotBlank(portString)) { port = portString; } else { logger.warn("dsmr:port setting is empty"); } /* * Read the channel configuration */ dsmrMeters.clear(); for (DSMRMeterType meterType : DSMRMeterType.values()) { String channelConfigValue = (String) config.get(meterType.channelConfigKey); logger.debug("dsmr:" + meterType.channelConfigKey + "=" + channelConfigValue); if (StringUtils.isNotBlank(channelConfigValue)) { try { dsmrMeters.add(new DSMRMeter(meterType, Integer.parseInt(channelConfigValue))); } catch (NumberFormatException nfe) { logger.warn("Invalid value " + channelConfigValue + " for dsmr:" + meterType.channelConfigKey + ". Ignore mapping!", nfe); } } else { switch (meterType) { case NA: break; // Filter special DSMRMeterType case ELECTRICITY: break; // Always channel 0, configuration not needed default: logger.info("dsmr:" + meterType.channelConfigKey + " setting is empty"); } } } // Validate minimal configuration if (port.length() > 0) { logger.debug("Configuration succeeded"); setProperlyConfigured(true); } else { logger.debug("Configuration failed"); setProperlyConfigured(false); } } }
From source file:org.codice.ddf.configuration.persistence.felix.FelixCfgPersistenceStrategy.java
@Override public void write(OutputStream out, Dictionary<String, Object> properties) throws IOException { Validate.notNull(out, "invalid null output stream"); Validate.notNull(properties, "invalid null properties"); final Properties props = new Properties(); final Enumeration<String> keys = properties.keys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); props.put(key, (String) properties.get(key)); }//from ww w . j a va 2 s.c o m props.save(out); }
From source file:org.openhab.binding.ekozefir.internal.EkozefirBinding.java
/** * @{inheritDoc}//from w w w . j ava2s .c o m */ @Override public void updated(Dictionary<String, ?> config) throws ConfigurationException { Objects.requireNonNull(config); for (String configKey : Collections.list(config.keys())) { parseConfig(clearAndCheckConfig(configKey, (String) config.get(configKey))); } setProperlyConfigured(true); }
From source file:io.wcm.wcm.parsys.componentinfo.impl.OsgiParsysConfigProvider.java
@Activate private void activate(ComponentContext componentContext) { @SuppressWarnings("unchecked") final Dictionary<String, Object> props = componentContext.getProperties(); // read config properties this.pageComponentPath = PropertiesUtil.toString(props.get(PROPERTY_PAGE_COMPONENT_PATH), null); String path = PropertiesUtil.toString(props.get(PROPERTY_PATH), null); String patternString = PropertiesUtil.toString(props.get(PROPERTY_PATH_PATTERN), null); String[] allowedChildrenArray = PropertiesUtil.toStringArray(props.get(PROPERTY_ALLOWED_CHILDREN), null); String[] deniedChildrenArray = PropertiesUtil.toStringArray(props.get(PROPERTY_DENIED_CHILDREN), null); String[] allowedParentsArray = PropertiesUtil.toStringArray(props.get(PROPERTY_ALLOWED_PARENTS), null); this.parentAncestorLevel = PropertiesUtil.toInteger(props.get(PROPERTY_PARENT_ANCESTOR_LEVEL), DEFAULT_PARENT_ANCESTOR_LEVEL); // set path pattern if any if (StringUtils.isNotEmpty(patternString)) { this.pathPattern = Pattern.compile(patternString); }// w ww.j a v a 2 s .co m // alternative: use path to build a pattern else if (StringUtils.isNotBlank(path)) { // path may also contain a simple node name if (!StringUtils.startsWith(path, JcrConstants.JCR_CONTENT + "/")) { path = JcrConstants.JCR_CONTENT + "/" + path; //NOPMD } this.pathPattern = Pattern.compile("^" + Pattern.quote(path) + "$"); } // set allowed children Set<String> allowedChildrenSet = new HashSet<>(); if (allowedChildrenArray != null) { for (String resourceType : allowedChildrenArray) { if (StringUtils.isNotBlank(resourceType)) { allowedChildrenSet.add(resourceType); } } } this.allowedChildren = ImmutableSet.copyOf(allowedChildrenSet); // set denied children Set<String> deniedChildrenSet = new HashSet<>(); if (deniedChildrenArray != null) { for (String resourceType : deniedChildrenArray) { if (StringUtils.isNotBlank(resourceType)) { deniedChildrenSet.add(resourceType); } } } this.deniedChildren = ImmutableSet.copyOf(deniedChildrenSet); // set allowed parents Set<String> allowedParentsSet = new HashSet<>(); if (allowedParentsArray != null) { for (String resourceType : allowedParentsArray) { if (StringUtils.isNotBlank(resourceType)) { allowedParentsSet.add(resourceType); } } } this.allowedParents = ImmutableSet.copyOf(allowedParentsSet); if (log.isDebugEnabled()) { log.debug( getClass().getSimpleName() + ": " + PROPERTY_PAGE_COMPONENT_PATH + "={}, " + PROPERTY_PATH + "={}, " + PROPERTY_PATH_PATTERN + "={}, " + PROPERTY_ALLOWED_CHILDREN + "={}, " + PROPERTY_DENIED_CHILDREN + "={}, " + PROPERTY_ALLOWED_PARENTS + "={}, " + PROPERTY_PARENT_ANCESTOR_LEVEL + "={}", new Object[] { this.pageComponentPath, path, this.pathPattern, this.allowedChildren, this.deniedChildren, this.allowedParents, this.parentAncestorLevel }); } // validation messages if (StringUtils.isBlank(this.pageComponentPath)) { log.warn( PROPERTY_PAGE_COMPONENT_PATH + " cannot be null or empty. This configuration will be ignored."); } if (this.pathPattern == null) { log.warn("Path pattern cannot be null. Please set the property " + PROPERTY_PATH_PATTERN + " or " + PROPERTY_PATH); } }
From source file:org.codice.ddf.platform.io.CfgStrategy.java
@Override public void write(OutputStream out, Dictionary<String, Object> inputDictionary) throws IOException { notNull(out, "Output stream cannot be null"); notNull(inputDictionary, "Properties cannot be null"); final Properties props = new Properties(); final Enumeration<String> keys = inputDictionary.keys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); props.put(key, inputDictionary.get(key).toString()); }/*from ww w .ja v a2 s .co m*/ props.save(out); }
From source file:org.openhab.core.drools.internal.RuleService.java
/** * {@inheritDoc}/*from w ww .j a v a2s . c om*/ */ @SuppressWarnings("rawtypes") public void updated(Dictionary config) throws ConfigurationException { if (config != null) { String evalIntervalString = (String) config.get("evalInterval"); if (StringUtils.isNotBlank(evalIntervalString)) { refreshInterval = Long.parseLong(evalIntervalString); } } }