public final class PropertiesUtils extends Object
PropertiesHelper
is a utility class for manipulating and filtering property Maps.Modifier and Type | Method and Description |
---|---|
static List<Properties> |
discoverProperties(ClassLoader classLoader,
String resource)
Discovers properties files available on the given classloader.
|
static List<Properties> |
discoverProperties(String resource)
Discovers properties files available on the classloader that loaded
PropertiesUtils class |
static Properties |
getPropertiesFromQueryString(String query) |
static Properties |
getPropertiesFromString(String query,
char separator) |
static void |
getPropertiesWithPrefix(Map props,
String prefix,
Map newProps)
Will create a map of properties where the names have a prefix Allows the callee to supply the target map so a comparator can
be set
|
static Properties |
loadAllProperties(String fileName,
ClassLoader classLoader)
Load all properties files in the classpath with the given properties file name.
|
static Properties |
loadProperties(InputStream is) |
static Properties |
loadProperties(String fileName,
Class<?> callingClass)
Read in the properties from a properties file.
|
static Properties |
loadProperties(URL url) |
static String |
maskedPropertyValue(Map.Entry<?,?> property)
Returns the String representation of the property value or a masked String if the property key has been registered previously
via
registerMaskedPropertyName(String) . |
static void |
registerMaskedPropertyName(String name)
Register a property name for masking.
|
static String |
removeNamespacePrefix(String eleName) |
static Map |
removeNamespaces(Map properties) |
static String |
removeXmlNamespacePrefix(String eleName) |
public static void registerMaskedPropertyName(String name)
name
- the key of the property to be masked.IllegalArgumentException
- is name is null or empty.public static String maskedPropertyValue(Map.Entry<?,?> property)
registerMaskedPropertyName(String)
.property
- a key/value pairnull
if the property, its
key or its value is null
.public static Properties loadProperties(String fileName, Class<?> callingClass) throws IOException
fileName
- - The name of the properties filecallingClass
- - The Class which is calling this method. This is used to determine the classpath.IOException
public static Properties loadProperties(URL url) throws IOException
IOException
public static Properties loadAllProperties(String fileName, ClassLoader classLoader)
public static Properties loadProperties(InputStream is) throws IOException
IOException
public static void getPropertiesWithPrefix(Map props, String prefix, Map newProps)
props
- the source set of propertiesprefix
- the prefix to filter onnewProps
- return map containing the filtered list of properties or an empty map if no properties matched the prefixpublic static Properties getPropertiesFromQueryString(String query)
public static Properties getPropertiesFromString(String query, char separator)
public static List<Properties> discoverProperties(String resource) throws IOException
PropertiesUtils
classresource
- resource to find. Not emptyIOException
- when a property file cannot be processedpublic static List<Properties> discoverProperties(ClassLoader classLoader, String resource) throws IOException
classLoader
- classloader used to find properties resources. Not null.resource
- resource to find. Not emptyIOException
- when a property file cannot be processedCopyright © 2018. All rights reserved.