Example usage for java.util Properties remove

List of usage examples for java.util Properties remove

Introduction

In this page you can find the example usage for java.util Properties remove.

Prototype

@Override
    public synchronized Object remove(Object key) 

Source Link

Usage

From source file:org.eclipse.gemini.blueprint.test.internal.util.PropertiesUtil.java

/**
 * Filter/Eliminate keys that have a value that starts with the given prefix.
 * //w  w w .j a va  2  s .  c  o  m
 * @param properties
 * @param prefix
 * @return
 */
public static Properties filterValuesStartingWith(Properties properties, String prefix) {
    if (!StringUtils.hasText(prefix))
        return EMPTY_PROPERTIES;

    Assert.notNull(properties);
    Properties excluded = (properties instanceof OrderedProperties ? new OrderedProperties()
            : new Properties());

    for (Enumeration enm = properties.keys(); enm.hasMoreElements();) {
        String key = (String) enm.nextElement();
        String value = properties.getProperty(key);
        if (value.startsWith(prefix)) {
            excluded.put(key, value);
        }
    }

    for (Enumeration enm = excluded.keys(); enm.hasMoreElements();) {
        properties.remove(enm.nextElement());
    }
    return excluded;
}

From source file:org.sonar.batch.scan.DefaultProjectBootstrapper.java

/**
 * Replaces the deprecated properties by the new ones, and logs a message to warn the users.
 *//*from   www . j  a  v  a 2  s  .com*/
@VisibleForTesting
protected static void replaceDeprecatedProperties(Properties props) {
    for (Entry<String, String> entry : DEPRECATED_PROPS_TO_NEW_PROPS.entrySet()) {
        String key = entry.getKey();
        if (props.containsKey(key)) {
            String newKey = entry.getValue();
            LOG.warn(
                    "/!\\ The '{}' property is deprecated and is replaced by '{}'. Don't forget to update your files.",
                    key, newKey);
            String value = props.getProperty(key);
            props.remove(key);
            props.put(newKey, value);
        }
    }

}

From source file:org.ambraproject.configuration.OverrideTest.java

protected void tearDown() {
    // Make an attempt to remove the system property for other test classes
    Properties p = System.getProperties();
    p.remove(ConfigurationStore.OVERRIDES_URL);
    p.remove("conf.test");
    System.setProperties(p);/*from  w ww  .j a v  a2 s. co  m*/
}

From source file:com.asakusafw.yaess.bootstrap.Yaess.java

static Configuration parseConfiguration(String[] args) throws ParseException {
    assert args != null;
    LOG.debug("Analyzing YAESS bootstrap arguments: {}", Arrays.toString(args));

    ArgumentList argList = ArgumentList.parse(args);
    LOG.debug("Argument List: {}", argList);

    CommandLineParser parser = new BasicParser();
    CommandLine cmd = parser.parse(OPTIONS, argList.getStandardAsArray());

    String profile = cmd.getOptionValue(OPT_PROFILE.getOpt());
    LOG.debug("Profile: {}", profile);
    String script = cmd.getOptionValue(OPT_SCRIPT.getOpt());
    LOG.debug("Script: {}", script);
    String batchId = cmd.getOptionValue(OPT_BATCH_ID.getOpt());
    LOG.debug("Batch ID: {}", batchId);
    String flowId = cmd.getOptionValue(OPT_FLOW_ID.getOpt());
    LOG.debug("Flow ID: {}", flowId);
    String executionId = cmd.getOptionValue(OPT_EXECUTION_ID.getOpt());
    LOG.debug("Execution ID: {}", executionId);
    String phaseName = cmd.getOptionValue(OPT_PHASE_NAME.getOpt());
    LOG.debug("Phase name: {}", phaseName);
    String plugins = cmd.getOptionValue(OPT_PLUGIN.getOpt());
    LOG.debug("Plug-ins: {}", plugins);
    Properties arguments = cmd.getOptionProperties(OPT_ARGUMENT.getOpt());
    LOG.debug("Execution arguments: {}", arguments);
    Properties variables = cmd.getOptionProperties(OPT_ENVIRONMENT_VARIABLE.getOpt());
    LOG.debug("Environment variables: {}", variables);
    Properties definitions = cmd.getOptionProperties(OPT_DEFINITION.getOpt());
    LOG.debug("YAESS feature definitions: {}", definitions);

    LOG.debug("Loading plugins: {}", plugins);
    List<File> pluginFiles = CommandLineUtil.parseFileList(plugins);
    ClassLoader loader = CommandLineUtil.buildPluginLoader(Yaess.class.getClassLoader(), pluginFiles);

    Configuration result = new Configuration();
    result.mode = computeMode(flowId, executionId, phaseName);

    LOG.debug("Loading profile: {}", profile);
    File file = new File(profile);
    file = findCustomProfile(file, definitions.getProperty(KEY_CUSTOM_PROFILE));
    try {/*from   w w  w  . j a  va  2s .  co m*/
        definitions.remove(KEY_CUSTOM_PROFILE);
        Map<String, String> env = new HashMap<>();
        env.putAll(System.getenv());
        env.putAll(toMap(variables));
        result.context = new ProfileContext(loader, new VariableResolver(env));
        Properties properties = CommandLineUtil.loadProperties(file);
        result.profile = YaessProfile.load(properties, result.context);
    } catch (Exception e) {
        YSLOG.error(e, "E01001", file.getPath());
        throw new IllegalArgumentException(MessageFormat.format("Invalid profile \"{0}\".", file), e);
    }

    LOG.debug("Loading script: {}", script);
    try {
        Properties properties = CommandLineUtil.loadProperties(new File(script));
        result.script = properties;
    } catch (Exception e) {
        YSLOG.error(e, "E01002", script);
        throw new IllegalArgumentException(MessageFormat.format("Invalid script \"{0}\".", script), e);
    }

    result.batchId = batchId;
    result.flowId = flowId;
    result.executionId = executionId;
    if (phaseName != null) {
        result.phase = ExecutionPhase.findFromSymbol(phaseName);
        if (result.phase == null) {
            throw new IllegalArgumentException(MessageFormat.format("Unknown phase name \"{0}\".", phaseName));
        }
    }

    result.arguments = toMap(arguments);
    result.definitions = toMap(definitions);
    result.extensions = CommandLineUtil.loadExtensions(loader, argList.getExtended());

    LOG.debug("Analyzed YAESS bootstrap arguments");
    return result;
}

From source file:org.apache.openaz.xacml.std.pap.StdEngine.java

public static void removeGroupProperties(String id, Properties properties) {
    for (Object key : properties.keySet()) {
        if (key.toString().startsWith(id + ".")) {
            properties.remove(key);
        }//from  w w w.ja v  a2s  .c  o m
    }
}

From source file:com.adito.input.validators.ListValidator.java

public void validate(PropertyDefinition definition, String value, Properties properties) throws CodedException {
    PropertyList pl = new PropertyList(value);
    String className = properties.getProperty("className");
    Properties p = new Properties(properties);
    p.remove("className");
    try {// w ww  .j ava  2s.c  om
        Class clazz = getClass().forName(className);
        PropertyValidator pv = (PropertyValidator) clazz.newInstance();
        for (String item : pl) {
            pv.validate(definition, item, p);
        }
    } catch (CoreException ce) {
        throw ce;
    } catch (Exception e) {
        log.error("Invalid or missing class name", e);
        throw new CoreException(ErrorConstants.ERR_INTERNAL_ERROR, ErrorConstants.CATEGORY_NAME,
                ErrorConstants.BUNDLE_NAME, null, value);
    }
}

From source file:com.norconex.commons.lang.map.PropertiesTest.java

@Test
public void testRemoveNonExistentKey() throws Exception {
    Properties properties = new Properties();
    assertNull(properties.remove("key"));
}

From source file:com.norconex.commons.lang.map.PropertiesTest.java

@Test
public void testRemoveNonExistentKeyCaseInsensitive() throws Exception {
    Properties properties = new Properties(true);
    assertNull(properties.remove("key"));
}

From source file:org.mule.api.registry.AbstractServiceDescriptor.java

protected String removeProperty(String name, Properties properties) {
    String temp = (String) properties.remove(name);
    if (StringUtils.isEmpty(StringUtils.trim(temp))) {
        return null;
    } else {//from  w w  w  . j a  v  a2 s.  c  o m
        return temp;
    }
}

From source file:org.jajuk.util.UtilString.java

/**
 * Gets the anonymized jajuk properties.
 *
 * @return Anonymized Jajuk properties (for log or quality agent)
 *///from w  w  w.j a va  2  s.c  om
public static Properties getAnonymizedJajukProperties() {
    final Properties properties = (Properties) Conf.getProperties().clone();
    // We remove sensible data from logs
    properties.remove("jajuk.network.proxy_login");
    properties.remove("jajuk.network.proxy_port");
    properties.remove("jajuk.network.proxy_hostname");
    properties.remove("jajuk.options.p2p.password");
    return properties;
}