本文整理了Java中java.util.Properties.remove()
方法的一些代码示例,展示了Properties.remove()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Properties.remove()
方法的具体详情如下:
包路径:java.util.Properties
类名称:Properties
方法名:remove
暂无
代码示例来源:origin: spring-projects/spring-framework
/**
* Programmatically set a local property, overriding an entry in the
* {@code spring.properties} file (if any).
* @param key the property key
* @param value the associated property value, or {@code null} to reset it
*/
public static void setProperty(String key, @Nullable String value) {
if (value != null) {
localProperties.setProperty(key, value);
}
else {
localProperties.remove(key);
}
}
代码示例来源:origin: com.h2database/h2
/**
* Add or change a setting to the properties. This call does not save the
* file.
*
* @param key the key
* @param value the value
*/
public void setProperty(String key, String value) {
if (value == null) {
properties.remove(key);
} else {
properties.put(key, value);
}
}
代码示例来源:origin: quartz-scheduler/quartz
private void populateProviderWithExtraProps(PoolingConnectionProvider cp, Properties props) throws Exception {
Properties copyProps = new Properties();
copyProps.putAll(props);
// Remove all the default properties first (they don't always match to setter name, and they are already
// been set!)
copyProps.remove(PoolingConnectionProvider.DB_DRIVER);
copyProps.remove(PoolingConnectionProvider.DB_URL);
copyProps.remove(PoolingConnectionProvider.DB_USER);
copyProps.remove(PoolingConnectionProvider.DB_PASSWORD);
copyProps.remove(PoolingConnectionProvider.DB_MAX_CONNECTIONS);
copyProps.remove(PoolingConnectionProvider.DB_VALIDATION_QUERY);
copyProps.remove(PoolingConnectionProvider.POOLING_PROVIDER);
if (cp instanceof C3p0PoolingConnectionProvider) {
copyProps.remove(C3p0PoolingConnectionProvider.DB_MAX_CACHED_STATEMENTS_PER_CONNECTION);
copyProps.remove(C3p0PoolingConnectionProvider.DB_VALIDATE_ON_CHECKOUT);
copyProps.remove(C3p0PoolingConnectionProvider.DB_IDLE_VALIDATION_SECONDS);
copyProps.remove(C3p0PoolingConnectionProvider.DB_DISCARD_IDLE_CONNECTIONS_SECONDS);
}
setBeanProps(cp.getDataSource(), copyProps);
}
代码示例来源:origin: org.apache.logging.log4j/log4j-api
/**
* Extracts properties that start with or are equals to the specific prefix and returns them in a new Properties
* object with the prefix removed.
*
* @param properties The Properties to evaluate.
* @param prefix The prefix to extract.
* @return The subset of properties.
*/
public static Properties extractSubset(final Properties properties, final String prefix) {
final Properties subset = new Properties();
if (prefix == null || prefix.length() == 0) {
return subset;
}
final String prefixToMatch = prefix.charAt(prefix.length() - 1) != '.' ? prefix + '.' : prefix;
final List<String> keys = new ArrayList<>();
for (final String key : properties.stringPropertyNames()) {
if (key.startsWith(prefixToMatch)) {
subset.setProperty(key.substring(prefixToMatch.length()), properties.getProperty(key));
keys.add(key);
}
}
for (final String key : keys) {
properties.remove(key);
}
return subset;
}
代码示例来源:origin: spring-projects/spring-batch
private void switchPropertyNames(Properties properties, String oldName, String newName) {
String value = properties.getProperty(oldName);
properties.remove(oldName);
properties.setProperty(newName, value);
}
代码示例来源:origin: jooby-project/jooby
private Properties properties(final Config config) {
Properties props = new Properties();
// dump
config.getConfig("freemarker").entrySet().forEach(e -> {
String name = e.getKey();
String value = e.getValue().unwrapped().toString();
log.debug(" freemarker.{} = {}", name, value);
props.setProperty(name, value);
});
// this is a jooby option
props.remove("cache");
return props;
}
代码示例来源:origin: apache/geode
protected Properties createDistributedSystemProperties() {
Properties properties = new Properties();
// Add any additional gemfire properties
for (Map.Entry<String, String> entry : this.gemfireProperties.entrySet()) {
properties.put(entry.getKey(), entry.getValue());
}
// Replace the cache xml file in the properties
File cacheXmlFile = getCacheXmlFile();
String absoluteCacheXmlFileName = cacheXmlFile.getAbsolutePath();
// If the file doesn't exist and the name is the default, set cache-xml-file
// to the GemFire default. This is for the case where only the jars have been
// installed and no default cache.xml exists in the conf directory.
if (getCacheXmlFileName().equals(getDefaultCacheXmlFileName()) && !cacheXmlFile.exists()) {
absoluteCacheXmlFileName = DistributionConfig.DEFAULT_CACHE_XML_FILE.getName();
}
properties.put(CACHE_XML_FILE, absoluteCacheXmlFileName);
// Replace the log file in the properties
properties.put(LOG_FILE, getLogFile().getAbsolutePath());
// Replace the statistics archive file in the properties
File statisticArchiveFile = getStatisticArchiveFile();
if (statisticArchiveFile == null) {
// Remove the statistics archive file name since statistic sampling is disabled
properties.remove(STATISTIC_ARCHIVE_FILE);
properties.remove(STATISTIC_SAMPLING_ENABLED);
} else {
properties.put(STATISTIC_ARCHIVE_FILE, statisticArchiveFile.getAbsolutePath());
}
getLogger().info("Creating distributed system from: " + properties);
return properties;
}
代码示例来源:origin: debezium/debezium
private static String findAndReplace(String url, String name, Properties props) {
if (name != null && url.contains("${" + name + "}")) {
// Otherwise, we have to remove it from the properties ...
String value = props.getProperty(name);
if (value != null) {
props.remove(name);
// And replace the variable ...
url = url.replaceAll("\\$\\{" + name + "\\}", value);
}
}
return url;
}
代码示例来源:origin: pentaho/pentaho-kettle
@Override
public void setConnectionPoolingProperties( Properties properties ) {
// Clear our the previous set of pool parameters
for ( Iterator<Object> iter = attributes.keySet().iterator(); iter.hasNext(); ) {
String key = (String) iter.next();
if ( key.startsWith( ATTRIBUTE_POOLING_PARAMETER_PREFIX ) ) {
attributes.remove( key );
}
}
for ( Iterator<Object> iter = properties.keySet().iterator(); iter.hasNext(); ) {
String element = (String) iter.next();
String value = properties.getProperty( element );
if ( !Utils.isEmpty( element ) && !Utils.isEmpty( value ) ) {
attributes.put( ATTRIBUTE_POOLING_PARAMETER_PREFIX + element, value );
}
}
}
代码示例来源:origin: pentaho/pentaho-kettle
@Test
public void runMapTests() throws IOException {
Properties p = new Properties();
ConcurrentMapProperties c = new ConcurrentMapProperties();
p.put( unique, unique );
c.put( unique, unique );
p.remove( rmKey );
Assert.assertEquals( p.getProperty( property ), c.getProperty( property ) );
代码示例来源:origin: org.apache.ant/ant
out.println("None available");
} else {
Properties props = new Properties();
try {
props.load(is);
for (String key : props.stringPropertyNames()) {
String classname = props.getProperty(key);
try {
Class.forName(classname);
props.remove(key);
} catch (ClassNotFoundException e) {
out.println(key + " : Not Available "
代码示例来源:origin: apache/kylin
/**
* get extra calcite props from jdbc client
*/
public static Properties getJdbcDriverClientCalciteProps() {
Properties props = new Properties();
String propsStr = getString(JDBC_CLIENT_CALCITE_PROPS);
if (propsStr == null) {
return props;
}
try {
props.load(new StringReader(propsStr));
} catch (IOException ignored) {
// ignored
}
final Set<String> allowedPropsNames = Sets.newHashSet(
"caseSensitive",
"unquotedCasing",
"quoting",
"conformance"
);
// remove un-allowed props
for (String key : props.stringPropertyNames()) {
if (!allowedPropsNames.contains(key)) {
props.remove(key);
}
}
return props;
}
代码示例来源:origin: stanfordnlp/CoreNLP
runProps.remove(s);
runProps.setProperty("stopWordsPatternFiles",stopWordsFile);
runProps.setProperty("englishWordsFiles", stopWordsFile);
runProps.setProperty("commonWordsPatternFiles", stopWordsFile);
代码示例来源:origin: apache/geode
configProps.put(DistributionConfig.DS_RECONNECTING_NAME, Boolean.TRUE);
if (quorumChecker != null) {
configProps.put(DistributionConfig.DS_QUORUM_CHECKER_NAME, quorumChecker);
} finally {
if (this.locatorDMTypeForced) {
System.getProperties().remove(InternalLocator.FORCE_LOCATOR_DM_TYPE);
attemptingToReconnect = false;
if (appendToLogFile == null) {
System.getProperties().remove(APPEND_TO_LOG_FILE);
} else {
System.setProperty(APPEND_TO_LOG_FILE, appendToLogFile);
System.getProperties().remove(InternalLocator.INHIBIT_DM_BANNER);
} else {
System.setProperty(InternalLocator.INHIBIT_DM_BANNER, inhibitBanner);
代码示例来源:origin: stanfordnlp/CoreNLP
Properties result = new Properties();
List<String> remainingArgs = new ArrayList<>();
for (int i = 0; i < args.length; i++) {
result.setProperty(PROPERTIES, value);
} else {
result.setProperty(key, value);
result.setProperty("", join(remainingArgs, " "));
String file = result.getProperty(PROPERTIES);
result.remove(PROPERTIES);
Properties toAdd = new Properties();
BufferedReader reader = null;
try {
String newVal = toAdd.getProperty(propKey);
toAdd.setProperty(propKey, newVal.trim());
String val = toAdd.getProperty(key);
if ( ! result.containsKey(key)) {
result.setProperty(key, val);
代码示例来源:origin: apache/incubator-gobblin
public static Properties convertDeprecatedProperties(Properties props) {
if (props.containsKey(DEPRECATED_WATERMARK_REGEX_KEY)) {
log.info(String.format("Found deprecated key %s. Replacing it with %s", DEPRECATED_WATERMARK_REGEX_KEY,
org.apache.gobblin.data.management.version.finder.WatermarkDatasetVersionFinder.WATERMARK_REGEX_KEY));
props.setProperty(org.apache.gobblin.data.management.version.finder.WatermarkDatasetVersionFinder.WATERMARK_REGEX_KEY,
props.getProperty(DEPRECATED_WATERMARK_REGEX_KEY));
props.remove(DEPRECATED_WATERMARK_REGEX_KEY);
}
return props;
}
}
代码示例来源:origin: pmd/pmd
public static void setSystemProperties(CPDConfiguration configuration) {
Properties properties = new Properties();
if (configuration.isIgnoreLiterals()) {
properties.setProperty(Tokenizer.IGNORE_LITERALS, "true");
} else {
properties.remove(Tokenizer.IGNORE_LITERALS);
}
if (configuration.isIgnoreIdentifiers()) {
properties.setProperty(Tokenizer.IGNORE_IDENTIFIERS, "true");
} else {
properties.remove(Tokenizer.IGNORE_IDENTIFIERS);
}
if (configuration.isIgnoreAnnotations()) {
properties.setProperty(Tokenizer.IGNORE_ANNOTATIONS, "true");
} else {
properties.remove(Tokenizer.IGNORE_ANNOTATIONS);
}
if (configuration.isIgnoreUsings()) {
properties.setProperty(Tokenizer.IGNORE_USINGS, "true");
} else {
properties.remove(Tokenizer.IGNORE_USINGS);
}
properties.setProperty(Tokenizer.OPTION_SKIP_BLOCKS, Boolean.toString(!configuration.isNoSkipBlocks()));
properties.setProperty(Tokenizer.OPTION_SKIP_BLOCKS_PATTERN, configuration.getSkipBlocksPattern());
configuration.getLanguage().setProperties(properties);
}
代码示例来源:origin: org.apache.logging.log4j/log4j-api
@Test
public void testNonStringSystemProperties() {
Object key1 = "1";
Object key2 = new Object();
System.getProperties().put(key1, new Object());
System.getProperties().put(key2, "value-2");
try {
final PropertiesUtil util = new PropertiesUtil(new Properties());
assertNull(util.getStringProperty("1"));
} finally {
System.getProperties().remove(key1);
System.getProperties().remove(key2);
}
}
}
代码示例来源:origin: quartz-scheduler/quartz
private void populateProviderWithExtraProps(PoolingConnectionProvider cp, Properties props) throws Exception {
Properties copyProps = new Properties();
copyProps.putAll(props);
// Remove all the default properties first (they don't always match to setter name, and they are already
// been set!)
copyProps.remove(PoolingConnectionProvider.DB_DRIVER);
copyProps.remove(PoolingConnectionProvider.DB_URL);
copyProps.remove(PoolingConnectionProvider.DB_USER);
copyProps.remove(PoolingConnectionProvider.DB_PASSWORD);
copyProps.remove(PoolingConnectionProvider.DB_MAX_CONNECTIONS);
copyProps.remove(PoolingConnectionProvider.DB_VALIDATION_QUERY);
copyProps.remove(PoolingConnectionProvider.POOLING_PROVIDER);
if (cp instanceof C3p0PoolingConnectionProvider) {
copyProps.remove(C3p0PoolingConnectionProvider.DB_MAX_CACHED_STATEMENTS_PER_CONNECTION);
copyProps.remove(C3p0PoolingConnectionProvider.DB_VALIDATE_ON_CHECKOUT);
copyProps.remove(C3p0PoolingConnectionProvider.DB_IDLE_VALIDATION_SECONDS);
copyProps.remove(C3p0PoolingConnectionProvider.DB_DISCARD_IDLE_CONNECTIONS_SECONDS);
}
setBeanProps(cp.getDataSource(), copyProps);
}
代码示例来源:origin: stanfordnlp/CoreNLP
private static Dataset getDatasetClass(Properties dsParams) {
Dataset ds = null;
String dsType = dsParams.getProperty(ConfigParser.paramType);
dsParams.remove(ConfigParser.paramType);
try {
if(dsType == null)
ds = new ATBArabicDataset();
else {
Class c = ClassLoader.getSystemClassLoader().loadClass(dsType);
ds = (Dataset) c.newInstance();
}
} catch (ClassNotFoundException e) {
System.err.printf("Dataset type %s does not exist%n", dsType);
} catch (InstantiationException e) {
System.err.printf("Unable to instantiate dataset type %s%n", dsType);
} catch (IllegalAccessException e) {
System.err.printf("Unable to access dataset type %s%n", dsType);
}
return ds;
}
内容来源于网络,如有侵权,请联系作者删除!