Java Properties Get clearPrefixedSystemProperties(String prefix, Map targetPropertyMap)

Here you can find the source of clearPrefixedSystemProperties(String prefix, Map targetPropertyMap)

Description

clearPrefixedSystemProperties clears System Properties by writing null properties in the targetPropertyMap that match a prefix

License

Open Source License

Parameter

Parameter Description
prefix prefix
targetPropertyMap targetPropertyMap

Declaration

public static void clearPrefixedSystemProperties(String prefix, Map<String, String> targetPropertyMap) 

Method Source Code

//package com.java2s;
/*// w ww  .j  a v a  2 s  .c om
*  Copyright (c) 2005-2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
*  WSO2 Inc. licenses this file to you under the Apache License,
*  Version 2.0 (the "License"); you may not use this file except
*  in compliance with the License.
*  You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied.  See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import java.util.*;

public class Main {
    /**
     * clearPrefixedSystemProperties clears System Properties by writing null properties in
     * the targetPropertyMap that match a prefix
     *
     * @param prefix            prefix
     * @param targetPropertyMap targetPropertyMap
     */
    public static void clearPrefixedSystemProperties(String prefix, Map<String, String> targetPropertyMap) {
        for (Object o : System.getProperties().keySet()) {
            String propertyName = (String) o;
            if (propertyName.startsWith(prefix) && !targetPropertyMap.containsKey(propertyName)) {
                targetPropertyMap.put(propertyName, null);
            }
        }
    }
}

Related

  1. copyProperties(Hashtable src, Hashtable target)
  2. getBoolean(Properties props, String key)
  3. getBoolean(Properties props, String name, boolean defaultValue)
  4. getInt(Properties props, String name)