public class PropertyHelper extends Object
Constructor and Description |
---|
PropertyHelper() |
Modifier and Type | Method and Description |
---|---|
static boolean |
canFind(String resource)
Affirm if the given resource is available either as a resource in the current thread's context classpath
or as a file.
|
static Map<String,Object> |
filter(Map<String,Object> props,
String name,
boolean prefix,
boolean includeArrays)
Filter the properties by the given name.
|
static Map<String,List<Object>> |
filterArrayKeys(Map<String,Object> props,
String name,
boolean prefix)
Select only those property keys which ends with an array marker such as
openjpa.DataCache[1] . |
static double |
getDouble(Map<String,Object> props,
String key,
double def) |
static int |
getInteger(Map<String,Object> props,
String key,
int def) |
static Map<String,String> |
getMap(Map<String,Object> props,
String key) |
static Map<String,String> |
getMap(Map<String,Object> props,
String key,
Map<String,String> def) |
static String |
getPrefix(String s) |
static Map<String,Object> |
getSection(Map<String,Object> props,
String section)
Get the portion of the given map whose key has the given section at prefix.
|
static Map<String,Object> |
getSection(Map<String,Object> props,
String section,
boolean retain)
Get the portion of the given map whose key has the given section at prefix.
|
static String |
getString(Map<String,Object> props,
String key,
String def) |
static List<String> |
getStringList(Map<String,Object> props,
String key) |
static List<String> |
getStringList(Map<String,Object> props,
String key,
List<String> def) |
static Set<String> |
getSubsectionKeys(Set<String> keys,
String section) |
static Map<String,Object> |
load(String resource)
Load properties from the given name resource.
|
static Map<String,Object> |
overwriteWithSystemProperties(Map<String,Object> original)
Overwrites any key-value pair in the given map for which a System property is available
|
static Map<String,Object> |
toMap(Properties p) |
public static Map<String,Object> filter(Map<String,Object> props, String name, boolean prefix, boolean includeArrays)
name
- a part of the keyprefix
- if true, property key must begin with the given name. Otherwise, the key merely contains the
name to qualify.public static Map<String,List<Object>> filterArrayKeys(Map<String,Object> props, String name, boolean prefix)
openjpa.DataCache[1]
.
The multiple values of the property is inserted into the resultant map as a List of object against the
original key.
openjpa.DataCache[1]=true
openjpa.DataCache[2]=false
openjpa.DataCache[3]=default
openjpa.DataCache
with a value as a List of three elements namely {true, false, default}
. The array index values
are not significant other than they must all be different for the same base key.name
- part of the property keyprefix
- does the name must appear as a prefix?public static Map<String,Object> load(String resource)
resource
- name a of resource.public static boolean canFind(String resource)
public static Map<String,Object> toMap(Properties p)
public static Map<String,Object> overwriteWithSystemProperties(Map<String,Object> original)
original
- properties to be overwrittenpublic static List<String> getStringList(Map<String,Object> props, String key, List<String> def)
public static Map<String,String> getMap(Map<String,Object> props, String key, Map<String,String> def)
public static Map<String,Object> getSection(Map<String,Object> props, String section)
props
- a set of name-value pairsection
- a string representing section of a keypublic static Map<String,Object> getSection(Map<String,Object> props, String section, boolean retain)
props
- a set of name-value pairsection
- a string representing section of a keyretain
- if true the key of resultant map is same as the original map. Otherwise
the resultant map keys are without the section prefix.Copyright © 2006–2018 Apache Software Foundation. All rights reserved.