java.util.Dictionary#remove ( )源码实例Demo

下面列出了java.util.Dictionary#remove ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: gemfirexd-oss   文件: PropertyConglomerate.java
void savePropertyDefault(TransactionController tc, String key, Serializable value)
	 throws StandardException
{
	if (saveServiceProperty(key,value)) return;

	Dictionary defaults = (Dictionary)readProperty(tc,AccessFactoryGlobals.DEFAULT_PROPERTY_NAME);
	if (defaults == null) defaults = new FormatableHashtable();
	if (value==null)
		defaults.remove(key);
	else
		defaults.put(key,value);
	if (defaults.size() == 0) defaults = null;
	saveProperty(tc,AccessFactoryGlobals.DEFAULT_PROPERTY_NAME,(Serializable)defaults);
}
 
源代码2 项目: openhab-core   文件: ConfigurationService.java
/**
 * Creates or updates a configuration for a config id.
 *
 * @param configId config id
 * @param newConfiguration the configuration
 * @param override if true, it overrides the old config completely. means it deletes all parameters even if they are
 *            not defined in the given configuration.
 * @return old config or null if no old config existed
 * @throws IOException if configuration can not be stored
 */
public Configuration update(String configId, Configuration newConfiguration, boolean override) throws IOException {
    org.osgi.service.cm.Configuration configuration = null;
    if (newConfiguration.containsKey(ConfigConstants.SERVICE_CONTEXT)) {
        try {
            configuration = getConfigurationWithContext(configId);
        } catch (InvalidSyntaxException e) {
            logger.error("Failed to lookup config for PID '{}'", configId);
        }
        if (configuration == null) {
            configuration = configurationAdmin.createFactoryConfiguration(configId, null);
        }
    } else {
        configuration = configurationAdmin.getConfiguration(configId, null);
    }

    Configuration oldConfiguration = toConfiguration(configuration.getProperties());
    Dictionary<String, Object> properties = getProperties(configuration);
    Set<Entry<String, Object>> configurationParameters = newConfiguration.getProperties().entrySet();
    if (override) {
        Set<String> keySet = oldConfiguration.keySet();
        for (String key : keySet) {
            properties.remove(key);
        }
    }
    for (Entry<String, Object> configurationParameter : configurationParameters) {
        Object value = configurationParameter.getValue();
        if (value == null) {
            properties.remove(configurationParameter.getKey());
        } else if (value instanceof String || value instanceof Integer || value instanceof Boolean
                || value instanceof Object[] || value instanceof Collection) {
            properties.put(configurationParameter.getKey(), value);
        } else {
            // the config admin does not support complex object types, so let's store the string representation
            properties.put(configurationParameter.getKey(), value.toString());
        }
    }
    configuration.update(properties);
    return oldConfiguration;
}
 
源代码3 项目: knopflerfish.org   文件: PrefsStorageFile.java
@Override
public void removeKey(final String path, final String key) {
  synchronized(lock) {
    try {
      final Dictionary<String, String> props = loadProps(path);
      props.remove(key);
      propsMap.put(path, props);
      dirtySet.add(path);
      //        saveProps(path, props);
    } catch (final Exception e) {
      logWarn("Failed to remove " + path + ", key=" + key, e);
    }
  }
}
 
源代码4 项目: knopflerfish.org   文件: CMCommands.java
public int cmdUnset(Dictionary<?, ?> opts,
                    Reader in,
                    PrintWriter out,
                    Session session)
{
  int retcode = 1; // 1 initially not set to 0 until end of try block
  try {
    if (getCurrent(session) == null) {
      throw new Exception("No configuration open currently");
    }
    final String p = (String) opts.get("property");
    final Dictionary<String, Object> dict = getEditingDict(session);
    final Object o = dict.remove(p);
    if (o == null) {
      throw new Exception("No property named " + p
                          + " in current configuration.");
    }
    retcode = 0; // Success!
  } catch (final Exception e) {
    out.print("Unset failed. Details:");
    final String reason = e.getMessage();
    out.println(reason == null ? "<unknown>" : reason);
  } finally {

  }

  return retcode;
}
 
源代码5 项目: gemfirexd-oss   文件: PropertyConglomerate.java
void savePropertyDefault(TransactionController tc, String key, Serializable value)
	 throws StandardException
{
	if (saveServiceProperty(key,value)) return;

	Dictionary defaults = (Dictionary)readProperty(tc,AccessFactoryGlobals.DEFAULT_PROPERTY_NAME);
	if (defaults == null) defaults = new FormatableHashtable();
	if (value==null)
		defaults.remove(key);
	else
		defaults.put(key,value);
	if (defaults.size() == 0) defaults = null;
	saveProperty(tc,AccessFactoryGlobals.DEFAULT_PROPERTY_NAME,(Serializable)defaults);
}
 
源代码6 项目: karaf-decanter   文件: EventFilterTest.java
@Test
public void propertyNameFilter() {
    Dictionary<String, Object> config = new Hashtable<>();
    config.put(EventFilter.PROPERTY_NAME_EXCLUDE_CONFIG, "key.*");
    // exclude
    Assert.assertFalse(EventFilter.match(prepareTestEvent(), config));
    // exclude first
    config.put(EventFilter.PROPERTY_NAME_INCLUDE_CONFIG, "other");
    Assert.assertFalse(EventFilter.match(prepareTestEvent(), config));
    // include
    config.remove(EventFilter.PROPERTY_NAME_EXCLUDE_CONFIG);
    Assert.assertTrue(EventFilter.match(prepareTestEvent(), config));
}
 
源代码7 项目: karaf-decanter   文件: EventFilterTest.java
@Test
public void propertyValueFilter() {
    Dictionary<String, Object> config = new Hashtable<>();
    config.put(EventFilter.PROPERTY_VALUE_EXCLUDE_CONFIG, "value.*");
    // exclude
    Assert.assertFalse(EventFilter.match(prepareTestEvent(), config));
    // exclude first
    config.put(EventFilter.PROPERTY_VALUE_INCLUDE_CONFIG, "other");
    Assert.assertFalse(EventFilter.match(prepareTestEvent(), config));
    // include
    config.remove(EventFilter.PROPERTY_VALUE_EXCLUDE_CONFIG);
    Assert.assertTrue(EventFilter.match(prepareTestEvent(), config));
}
 
源代码8 项目: smarthome   文件: ConfigurationService.java
/**
 * Creates or updates a configuration for a config id.
 *
 * @param configId config id
 * @param newConfiguration the configuration
 * @param override if true, it overrides the old config completely. means it deletes all parameters even if they are
 *            not defined in the given configuration.
 * @return old config or null if no old config existed
 * @throws IOException if configuration can not be stored
 */
public Configuration update(String configId, Configuration newConfiguration, boolean override) throws IOException {
    org.osgi.service.cm.Configuration configuration = null;
    if (newConfiguration.containsKey(ConfigConstants.SERVICE_CONTEXT)) {
        try {
            configuration = getConfigurationWithContext(configId);
        } catch (InvalidSyntaxException e) {
            logger.error("Failed to lookup config for PID '{}'", configId);
        }
        if (configuration == null) {
            configuration = configurationAdmin.createFactoryConfiguration(configId, null);
        }
    } else {
        configuration = configurationAdmin.getConfiguration(configId, null);
    }

    Configuration oldConfiguration = toConfiguration(configuration.getProperties());
    Dictionary<String, Object> properties = getProperties(configuration);
    Set<Entry<String, Object>> configurationParameters = newConfiguration.getProperties().entrySet();
    if (override) {
        Set<String> keySet = oldConfiguration.keySet();
        for (String key : keySet) {
            properties.remove(key);
        }
    }
    for (Entry<String, Object> configurationParameter : configurationParameters) {
        Object value = configurationParameter.getValue();
        if (value == null) {
            properties.remove(configurationParameter.getKey());
        } else if (value instanceof String || value instanceof Integer || value instanceof Boolean
                || value instanceof Object[] || value instanceof Collection) {
            properties.put(configurationParameter.getKey(), value);
        } else {
            // the config admin does not support complex object types, so let's store the string representation
            properties.put(configurationParameter.getKey(), value.toString());
        }
    }
    configuration.update(properties);
    return oldConfiguration;
}
 
源代码9 项目: fuchsia   文件: SetTimeAction.java
public Dictionary invoke(Dictionary args) throws Exception {
	Long newValue = (Long) args.get(NEW_TIME_VALUE);
       Long oldValue = (Long) ((TimeStateVariable) time).getCurrentValue();
	((TimeStateVariable) time).setCurrentTime(newValue.longValue());
       ClockDevice.notifier.propertyChange(new PropertyChangeEvent(time,"Time",oldValue,newValue));        
	args.remove(NEW_TIME_VALUE);
	args.put(NEW_RESULT_VALUE,((TimeStateVariable) time).getCurrentTime());
	return args;
}