public class PropertyUtils extends Object
Properties
especially as it relates to storing and loading. Properties
can be loaded from any url Spring resource loading can
understand. When storing and loading, locations ending in .xml
are automatically handled using storeToXML()
and loadFromXML()
,
respectively. Properties
are always stored in sorted order with the encoding
indicated via a comment.Modifier and Type | Field and Description |
---|---|
static String |
ADDITIONAL_LOCATIONS |
static String |
ADDITIONAL_LOCATIONS_ENCODING |
static Properties |
EMPTY |
static String |
ENV_PREFIX |
Constructor and Description |
---|
PropertyUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
addListComparisonProperties(Properties properties,
ComparisonResults listComparison,
List<String> propertyNames)
Set properties in the given Properties to CSV versions of the lists in the ComparisonResults
|
static void |
addOrOverrideProperty(Properties properties,
String key,
String newValue,
Mode propertyOverwriteMode)
Before setting the newValue, check to see if there is a conflict with an existing value.
|
static void |
addOrOverrideProperty(Properties properties,
String key,
String newValue,
Mode overrideMode,
int indent) |
static void |
appendToOrSetProperty(Properties properties,
String key,
String value) |
static Properties |
combine(List<Properties> properties) |
static Properties |
combine(Properties... properties) |
static Properties |
combine(Properties properties,
List<Properties> list) |
static void |
conceal(Properties properties)
A trivial way to conceal property values.
|
static boolean |
containsUnresolvedPlaceholder(String string) |
static boolean |
containsUnresolvedPlaceholder(String string,
String prefix,
String suffix) |
static Properties |
convert(Map<String,String> map)
Convert the
Map to a Properties object. |
static Map<String,String> |
convert(Properties properties)
Convert the
Properties to a Map object. |
static String |
convertToEnvironmentVariable(String key)
Replace periods with an underscore and convert to uppercase
|
static Properties |
convertToProperties(Map<String,String> map)
Convert the
Map to a Properties object. |
static void |
debug(Properties properties) |
static void |
decrypt(Properties properties)
Deprecated.
|
static void |
decrypt(Properties properties,
org.jasypt.util.text.TextEncryptor encryptor)
Decrypt any encrypted property values.
|
static void |
decrypt(Properties properties,
org.jasypt.util.text.TextEncryptor encryptor,
List<String> includes,
List<String> excludes)
Deprecated.
|
static String |
decryptPropertyValue(org.jasypt.util.text.TextEncryptor encryptor,
String value)
Return the decrypted version of the property value.
|
static Properties |
duplicate(Properties properties)
Return a new properties object that duplicates the properties passed in.
|
static void |
encrypt(Properties properties,
org.jasypt.util.text.TextEncryptor encryptor)
Encrypt all of the property values.
|
static void |
encrypt(Properties properties,
org.jasypt.util.text.TextEncryptor encryptor,
List<String> includes,
List<String> excludes)
Encrypt properties as dictated by
includes and excludes . |
static String |
encryptPropertyValue(org.jasypt.util.text.TextEncryptor encryptor,
String value)
Return the encrypted version of the property value.
|
static boolean |
equals(Properties one,
Properties two)
Return true if both contain an identical set of string keys and values, or both are
null , false otherwise. |
static Properties |
getAdditionalProperties(Properties properties) |
static Properties |
getAdditionalProperties(Properties properties,
String encoding) |
static boolean |
getBoolean(String key,
Properties properties,
boolean defaultValue) |
protected static String |
getCanonicalLocation(String location) |
static List<String> |
getEncryptedKeys(Properties properties)
Deprecated.
|
static Properties |
getEncryptedProperties(Properties properties)
Return a new
Properties object (never null) containing only those properties whose values are encrypted. |
static List<String> |
getEndsWithKeys(Properties properties,
String suffix)
Return a sorted
List of keys from properties that end with suffix . |
static Properties |
getEnvAsProperties()
Return a new properties object containing environment variables as properties prefixed with
env |
static Properties |
getEnvAsProperties(String prefix)
Return a new properties object containing environment variables as properties prefixed with
prefix |
static String |
getEnvironmentVariableKey(String key)
Replace periods with an underscore, convert to uppercase, and prefix with
env |
static boolean |
getGlobalBoolean(String key,
Properties properties)
Return true if the value for
key evaluates to the string true (ignoring case). |
static Properties |
getGlobalProperties()
Return a new properties object containing the properties from
getEnvAsProperties() and System.getProperties() . |
static Properties |
getGlobalProperties(Properties properties)
Return a new properties object containing the properties passed in, plus any properties returned by
getEnvAsProperties() and System.getProperties()
. |
static String |
getGlobalProperty(String key)
Examine both system properties and environment variables to get a value for
key . |
static String |
getGlobalProperty(String key,
String defaultValue)
Examine both system properties and environment variables to get a value for
key . |
static com.google.common.base.Optional<String> |
getOptionalString(Properties properties,
String key)
If there is no value for
key or the value is NULL or NONE, return Optional.absent(), otherwise return Optional.of(value) |
static Properties |
getPrefixedProperties(Properties properties,
String prefix)
Return a new
Properties object containing properties prefixed with prefix . |
static Properties |
getProperties(GlobalPropertiesMode mode)
Return a new properties object containing global properties as requested.
|
static Properties |
getProperties(Properties properties,
GlobalPropertiesMode mode)
Return a new properties object containing the properties passed in, plus any global properties as requested.
|
static Properties |
getProperties(Properties properties,
String include,
String exclude)
Return property keys that should be included as a sorted list.
|
static String |
getProperty(Properties properties,
String key,
String defaultValue) |
static String |
getProperty(String key,
GlobalPropertiesMode mode)
Search global properties to find a value for
key according to the mode passed in. |
static String |
getProperty(String key,
Properties properties,
GlobalPropertiesMode mode)
Search
properties plus global properties to find a value for key according to the mode passed in. |
static List<PropertyProcessor> |
getPropertyProcessors(GlobalPropertiesMode mode)
Return modifiers that add environment variables, system properties, or both, according to the mode passed in.
|
static String |
getRequiredResolvedProperty(Properties properties,
String key) |
static String |
getRequiredResolvedProperty(Properties properties,
String key,
String defaultValue) |
static Properties |
getResolvedProperties(Properties properties)
Return a new
Properties object containing only those properties where the resolved value is different from the original value. |
static Properties |
getResolvedProperties(Properties properties,
GlobalPropertiesMode globalPropertiesMode)
Return a new
Properties object containing only those properties where the resolved value is different from the original value. |
static Properties |
getResolvedProperties(Properties properties,
org.springframework.util.PropertyPlaceholderHelper helper)
Return a new
Properties object containing only those properties where the resolved value is different from the original value. |
static Properties |
getResolvedProperties(Properties properties,
org.springframework.util.PropertyPlaceholderHelper helper,
GlobalPropertiesMode globalPropertiesMode)
Return a new
Properties object containing only those properties where the resolved value is different from the original value. |
static String |
getRiceXML(Properties properties) |
static List<String> |
getSortedKeys(Properties properties)
Return the property keys as a sorted list.
|
static List<String> |
getSortedKeys(Properties properties,
List<String> includes,
List<String> excludes)
Return property keys that should be included as a sorted list.
|
static List<String> |
getSortedKeys(Properties properties,
String include,
String exclude)
Return property keys that should be included as a sorted list.
|
static List<String> |
getStartsWithKeys(Properties properties,
String prefix)
Return a sorted
List of keys from properties that start with prefix |
static com.google.common.base.Optional<String> |
getString(Properties properties,
String key,
com.google.common.base.Optional<String> provided) |
static List<String> |
getValues(Properties properties,
List<String> keys)
Return the property values from
keys |
static boolean |
include(String value,
List<String> includes,
List<String> excludes)
Return true if
value should be included, false otherwise.If excludes is not empty and matches value return false.If value has not been explicitly excluded, check the includes list.If includes is empty return true.If includes is not empty, return true if, and only if, value matches a pattern from the includes list.A single wildcard * is supported for includes and excludes . |
static void |
info(Properties properties) |
static boolean |
isEmpty(Properties properties) |
static boolean |
isEncryptedPropertyValue(String value)
Deprecated.
Use EncUtils.isEncrypted(value) instead
|
static boolean |
isRiceProperties(String location)
Return true if, and only if, location ends with
rice-properties.xml (case insensitive). |
static boolean |
isSingleUnresolvedPlaceholder(String string) |
static boolean |
isSingleUnresolvedPlaceholder(String string,
String prefix,
String suffix) |
static boolean |
isSingleWildcardMatch(String s,
List<String> patterns) |
static boolean |
isSingleWildcardMatch(String value,
String pattern)
Match
value against pattern where pattern can optionally contain a single wildcard * . |
static boolean |
isXml(String location)
Return true if, and only if, location ends with
.xml (case insensitive). |
static Properties |
load(File file)
Return a new
Properties object loaded from file . |
static Properties |
load(File file,
String encoding)
Return a new
Properties object loaded from file using the given encoding. |
static Properties |
load(List<ProjectProperties> pps)
Deprecated.
|
static Properties |
load(List<String> locations,
String encoding)
Return a new
Properties object loaded from locations using encoding . |
static Properties |
load(PropertiesContext context) |
static Properties |
load(String location)
Return a new
Properties object loaded from location . |
static Properties |
load(String location,
String encoding)
Return a new
Properties object loaded from location using encoding . |
static Properties |
load(String location,
String encoding,
PropertyFormat format)
Return a new
Properties object loaded from location using encoding . |
static Properties |
load(String location,
String encoding,
PropertyFormat format,
boolean silent)
Return a new
Properties object loaded from location using encoding . |
static Properties |
loadOrCreateSilently(String location)
If location exists, return a new
Properties object loaded from location , otherwise return a new Properties object |
static Properties |
loadRiceProperties(File file)
Deprecated.
use loadRiceProps() instead
|
static Properties |
loadRiceProperties(String location)
Deprecated.
use loadRiceProps() instead
|
static Properties |
loadRiceProps(File file) |
static Properties |
loadRiceProps(String location) |
static Properties |
loadSilently(File file)
Return a new
Properties object loaded from file . |
static Properties |
loadSilently(String location)
Return a new
Properties object loaded from file . |
static Map<String,String> |
newHashMap(Properties properties)
Convert the
Properties to a Map<String,String> object. |
static SortedMap<String,String> |
newTreeMap(Properties properties)
Convert the
Properties to a Map<String,String> object. |
protected static boolean |
obscure(String key) |
static void |
overrideWithGlobalValues(Properties properties,
GlobalPropertiesMode mode) |
static void |
prepareContextProperties(Properties properties)
Process the properties passed in so they are ready for use by a Spring context.
1 - Override with system/environment properties 2 - Decrypt any ENC(...) values 3 - Resolve all property values throwing an exception if any are unresolvable. |
static void |
prepareContextProperties(Properties properties,
String encoding)
Process the properties passed in so they are ready for use by a Spring context.
1 - Override with system/environment properties 2 - Decrypt any ENC(...) values 3 - Resolve all property values throwing an exception if any are unresolvable. |
static void |
process(Properties properties,
List<PropertyProcessor> processors) |
static void |
process(Properties properties,
PropertyProcessor processor) |
static Properties |
reformatKeysAsEnvVars(Properties properties)
Return a new properties object where the keys have been converted to upper case and periods have been replaced with an underscore.
|
static void |
removeSystemProperties(List<String> keys) |
static void |
removeSystemProperty(String key) |
static void |
resolve(Properties properties)
Deprecated.
|
static void |
resolve(Properties properties,
org.springframework.util.PropertyPlaceholderHelper helper) |
static void |
reveal(Properties properties)
Reveal property values that were concealed by the
conceal method |
static void |
store(Properties properties,
File file)
Store the properties to the indicated file using the platform default encoding.
|
static void |
store(Properties properties,
File file,
String encoding)
Store the properties to the indicated file using the indicated encoding.
|
static void |
store(Properties properties,
File file,
String encoding,
String comment)
Store the properties to the indicated file using the indicated encoding with the indicated comment appearing at the top of the file.
|
static void |
store(Properties properties,
File file,
String encoding,
String comment,
boolean silent)
Store the properties to the indicated file using the indicated encoding with the indicated comment appearing at the top of the file.
|
static void |
storeSilently(Properties properties,
File file)
Store the properties to the indicated file using the platform default encoding.
|
static Properties[] |
toArray(List<Properties> properties) |
static Properties |
toEmpty(Properties properties) |
static List<Properties> |
toImmutable(List<Properties> properties)
The list returned by this method is unmodifiable and contains only
ImmutableProperties |
static Properties |
toImmutable(Properties properties)
If the properties passed in are already immutable, just return them, otherwise, return a new ImmutableProperties object
|
static String |
toString(Properties properties) |
static void |
trim(Properties properties,
List<String> includes,
List<String> excludes)
Alter the
properties passed in to contain only the desired property values. |
static void |
trim(Properties properties,
String includesCSV,
String excludesCSV)
Alter the
properties passed in to contain only the desired property values. |
static String |
unwrapEncryptedValue(String encryptedValue)
Deprecated.
Use EncUtils.unwrap(value) instead
|
protected static void |
validateRiceProperties(String token,
String key)
Make sure they are just loading simple properties and are not using any of the unsupported "features".
|
static String |
wrapEncryptedPropertyValue(String encryptedValue)
Deprecated.
Use EncUtils.wrap(value) instead
|
public static final String ADDITIONAL_LOCATIONS
public static final String ADDITIONAL_LOCATIONS_ENCODING
public static final Properties EMPTY
public static final String ENV_PREFIX
public PropertyUtils()
public static com.google.common.base.Optional<String> getOptionalString(Properties properties, String key)
key
or the value is NULL or NONE, return Optional.absent(), otherwise return Optional.of(value)public static com.google.common.base.Optional<String> getString(Properties properties, String key, com.google.common.base.Optional<String> provided)
public static Properties toImmutable(Properties properties)
public static List<Properties> toImmutable(List<Properties> properties)
ImmutableProperties
public static boolean getGlobalBoolean(String key, Properties properties)
key
evaluates to the string true
(ignoring case). The properties passed in along with the system and environment
variables are all inspected with the value for system or environment variables "winning" over the value from the properties passed in.public static boolean getBoolean(String key, Properties properties, boolean defaultValue)
public static boolean equals(Properties one, Properties two)
null
, false otherwise.public static String getProperty(Properties properties, String key, String defaultValue)
public static boolean isEmpty(Properties properties)
public static String getRiceXML(Properties properties)
public static String getRequiredResolvedProperty(Properties properties, String key)
public static String getRequiredResolvedProperty(Properties properties, String key, String defaultValue)
public static void prepareContextProperties(Properties properties, String encoding)
public static void prepareContextProperties(Properties properties)
public static void resolve(Properties properties, org.springframework.util.PropertyPlaceholderHelper helper)
public static void removeSystemProperty(String key)
public static void removeSystemProperties(List<String> keys)
@Deprecated public static void resolve(Properties properties)
@Deprecated public static void decrypt(Properties properties)
public static Properties getAdditionalProperties(Properties properties)
public static Properties getAdditionalProperties(Properties properties, String encoding)
public static void appendToOrSetProperty(Properties properties, String key, String value)
@Deprecated public static Properties load(List<ProjectProperties> pps)
public static Properties load(PropertiesContext context)
public static void decrypt(Properties properties, org.jasypt.util.text.TextEncryptor encryptor)
my.value = ENC(DGA$S24FaIO)
public static Properties getEncryptedProperties(Properties properties)
Properties
object (never null) containing only those properties whose values are encrypted. Encrypted values are surrounded by ENC(...), like:
my.value = ENC(DGA$S24FaIO)
@Deprecated public static List<String> getEncryptedKeys(Properties properties)
my.value = ENC(DGA$S24FaIO)
@Deprecated public static void decrypt(Properties properties, org.jasypt.util.text.TextEncryptor encryptor, List<String> includes, List<String> excludes)
includes
, excludes
patterns. Encrypted values are surrounded by ENC(...).
my.value = ENC(DGA$S24FaIO)
@Deprecated public static boolean isEncryptedPropertyValue(String value)
ENC(
and ends with )
, false otherwise.public static void conceal(Properties properties)
A trivial way to conceal property values. Can be reversed using reveal()
. Do NOT use this method in an attempt to obscure sensitive data. The algorithm
is completely trivial and exceedingly simple to reverse engineer. Not to mention, the reveal()
method can reproduce the original string without requiring any
secret knowledge.
The use case here is to help prevent someone with otherwise mostly good intentions from altering a piece of information in a way they should not. This is NOT intended to defeat any serious attempt at discovering the original text.
Think a hungry sales or marketing rep who stumbles across a config file with the entry vending.machine.refill.day=wed
in it and tries to change that to
mon
in order to beat a case of the munchies. :)
If the entry says vending.machine.refill.day=cnc--jrq
instead of vending.machine.refill.day=wed
they are far more likely to ask around before they
change it OR just give up and head out to lunch instead.
reveal
public static void reveal(Properties properties)
conceal
method
foo=cnc--one.onm -> foo=bar.baz
public static void encrypt(Properties properties, org.jasypt.util.text.TextEncryptor encryptor)
my.value = ENC(DGA$S24FaIO)
public static void encrypt(Properties properties, org.jasypt.util.text.TextEncryptor encryptor, List<String> includes, List<String> excludes)
includes
and excludes
. Encrypted values are surrounded by ENC(...).
my.value = ENC(DGA$S24FaIO)
public static String decryptPropertyValue(org.jasypt.util.text.TextEncryptor encryptor, String value)
my.value = ENC(DGA$S24FaIO)
@Deprecated public static String unwrapEncryptedValue(String encryptedValue)
ENC(
prefix and the trailing )
from the encrypted value passed in.
ENC(DGA$S24FaIO) -> DGA$S24FaIO
public static String encryptPropertyValue(org.jasypt.util.text.TextEncryptor encryptor, String value)
my.value = ENC(DGA$S24FaIO)
@Deprecated public static String wrapEncryptedPropertyValue(String encryptedValue)
DGA$S24FaIO -> ENC(DGA$S24FaIO)
public static void overrideWithGlobalValues(Properties properties, GlobalPropertiesMode mode)
public static final Properties[] toArray(List<Properties> properties)
public static final Properties combine(Properties properties, List<Properties> list)
public static final Properties combine(List<Properties> properties)
public static final Properties combine(Properties... properties)
public static final void process(Properties properties, PropertyProcessor processor)
public static final void process(Properties properties, List<PropertyProcessor> processors)
public static final Properties toEmpty(Properties properties)
public static final boolean isSingleUnresolvedPlaceholder(String string)
public static final boolean isSingleUnresolvedPlaceholder(String string, String prefix, String suffix)
public static final boolean containsUnresolvedPlaceholder(String string)
public static final boolean containsUnresolvedPlaceholder(String string, String prefix, String suffix)
public static final Properties getResolvedProperties(Properties properties)
Properties
object containing only those properties where the resolved value is different from the original value. Using global properties to
perform property resolution as indicated by Constants.DEFAULT_GLOBAL_PROPERTIES_MODE
public static final Properties getResolvedProperties(Properties properties, GlobalPropertiesMode globalPropertiesMode)
Properties
object containing only those properties where the resolved value is different from the original value. Using global properties to
perform property resolution as indicated by globalPropertiesMode
public static final Properties getResolvedProperties(Properties properties, org.springframework.util.PropertyPlaceholderHelper helper)
Properties
object containing only those properties where the resolved value is different from the original value. Using global properties to
perform property resolution as indicated by Constants.DEFAULT_GLOBAL_PROPERTIES_MODE
public static final Properties getResolvedProperties(Properties properties, org.springframework.util.PropertyPlaceholderHelper helper, GlobalPropertiesMode globalPropertiesMode)
Properties
object containing only those properties where the resolved value is different from the original value. Using global properties to
perform property resolution as indicated by globalPropertiesMode
public static final List<String> getValues(Properties properties, List<String> keys)
keys
public static final List<String> getEndsWithKeys(Properties properties, String suffix)
List
of keys from properties
that end with suffix
.public static final void trim(Properties properties, String includesCSV, String excludesCSV)
properties
passed in to contain only the desired property values. includes
and excludes
are comma separated values.public static final void trim(Properties properties, List<String> includes, List<String> excludes)
properties
passed in to contain only the desired property values.public static final boolean include(String value, List<String> includes, List<String> excludes)
value
should be included, false otherwise.excludes
is not empty and matches value
return false.value
has not been explicitly excluded, check the includes
list.includes
is empty return true.includes
is not empty, return true if, and only if, value
matches a pattern from the includes
list.*
is supported for includes
and excludes
.public static final boolean isSingleWildcardMatch(String s, List<String> patterns)
public static final boolean isSingleWildcardMatch(String value, String pattern)
value
against pattern
where pattern
can optionally contain a single wildcard *
. If both are null
return true
. If one of
value
or pattern
is null
but the other isn't, return false
. Any pattern
containing more than a single wildcard throws
IllegalArgumentException
.
PropertyUtils.isSingleWildcardMatch(null, null) = true PropertyUtils.isSingleWildcardMatch(null, *) = false PropertyUtils.isSingleWildcardMatch(*, null) = false PropertyUtils.isSingleWildcardMatch(*, "*") = true PropertyUtils.isSingleWildcardMatch("abcdef", "bcd") = false PropertyUtils.isSingleWildcardMatch("abcdef", "*def") = true PropertyUtils.isSingleWildcardMatch("abcdef", "abc*") = true PropertyUtils.isSingleWildcardMatch("abcdef", "ab*ef") = true PropertyUtils.isSingleWildcardMatch("abcdef", "abc*def") = true PropertyUtils.isSingleWildcardMatch(*, "**") = IllegalArgumentException
public static final Properties getProperties(Properties properties, String include, String exclude)
public static final List<String> getSortedKeys(Properties properties, String include, String exclude)
public static final List<String> getSortedKeys(Properties properties, List<String> includes, List<String> excludes)
public static final List<String> getStartsWithKeys(Properties properties, String prefix)
List
of keys from properties
that start with prefix
public static final List<String> getSortedKeys(Properties properties)
public static final String toString(Properties properties)
public static final void info(Properties properties)
public static final void debug(Properties properties)
public static final void store(Properties properties, File file)
public static final void storeSilently(Properties properties, File file)
public static final void store(Properties properties, File file, String encoding)
public static final void store(Properties properties, File file, String encoding, String comment)
public static final void store(Properties properties, File file, String encoding, String comment, boolean silent)
public static final String getGlobalProperty(String key)
key
. Return null
if nothing is found.
foo.bar -> System property check for "foo.bar" foo.bar -> Environment check for "FOO_BAR"
public static final String getGlobalProperty(String key, String defaultValue)
key
. Return defaultValue
if nothing is found
foo.bar -> System property check for "foo.bar" foo.bar -> Environment check for "FOO_BAR"
public static final Properties getGlobalProperties()
getEnvAsProperties()
and System.getProperties()
. Properties from
System.getProperties()
override properties from getEnvAsProperties
if there are duplicates.public static final Properties getGlobalProperties(Properties properties)
getEnvAsProperties()
and System.getProperties()
. Properties from getEnvAsProperties()
override properties
and properties from System.getProperties()
override everything.public static final Properties getProperties(Properties properties, GlobalPropertiesMode mode)
mode
is NONE
the new properties are
a duplicate of the properties passed in. If mode
is ENVIRONMENT
the new properties contain the original properties plus any properties returned by
getEnvProperties()
. If mode
is SYSTEM
the new properties contain the original properties plus System.getProperties()
. If
mode
is BOTH
the new properties contain the original properties plus getEnvProperties()
and System.getProperties()
.public static final Properties getProperties(GlobalPropertiesMode mode)
mode
is NONE
the new properties are empty. If mode
is
ENVIRONMENT
the new properties contain the properties returned by getEnvProperties()
. If mode
is SYSTEM
the new
properties contain System.getProperties()
. If mode
is BOTH
the new properties contain getEnvProperties
plus
System.getProperties()
with system properties overriding environment variables if the same case sensitive property key is supplied in both places.public static final String getProperty(String key, GlobalPropertiesMode mode)
key
according to the mode passed in.public static final String getProperty(String key, Properties properties, GlobalPropertiesMode mode)
properties
plus global properties to find a value for key
according to the mode passed in. If the property is present in both, the value
from the global properties is returned.public static final List<PropertyProcessor> getPropertyProcessors(GlobalPropertiesMode mode)
public static final Properties convert(Map<String,String> map)
Map
to a Properties
object.public static final Properties convertToProperties(Map<String,String> map)
Map
to a Properties
object.public static Map<String,String> convert(Properties properties)
Properties
to a Map
object.public static Map<String,String> newHashMap(Properties properties)
Properties
to a Map<String,String>
object.public static SortedMap<String,String> newTreeMap(Properties properties)
Properties
to a Map<String,String>
object.public static final Properties duplicate(Properties properties)
public static Properties getEnvAsProperties()
env
public static Properties getEnvAsProperties(String prefix)
prefix
public static final boolean isXml(String location)
.xml
(case insensitive).public static final boolean isRiceProperties(String location)
rice-properties.xml
(case insensitive).public static final Properties loadRiceProps(File file)
public static final Properties loadRiceProps(String location)
@Deprecated public static final Properties loadRiceProperties(File file)
Properties
object loaded from file
where the properties are stored in Rice XML style syntax@Deprecated public static final Properties loadRiceProperties(String location)
Properties
object loaded from location
where the properties are stored in Rice XML style syntaxprotected static final void validateRiceProperties(String token, String key)
public static final Properties load(File file)
Properties
object loaded from file
.public static final Properties loadSilently(File file)
Properties
object loaded from file
.public static final Properties loadSilently(String location)
Properties
object loaded from file
.public static final Properties load(File file, String encoding)
Properties
object loaded from file
using the given encoding.public static final Properties load(String location)
Properties
object loaded from location
.public static final Properties loadOrCreateSilently(String location)
Properties
object loaded from location
, otherwise return a new Properties
objectpublic static final Properties load(List<String> locations, String encoding)
Properties
object loaded from locations
using encoding
.public static final Properties load(String location, String encoding)
Properties
object loaded from location
using encoding
.public static final Properties load(String location, String encoding, PropertyFormat format)
Properties
object loaded from location
using encoding
.public static final Properties load(String location, String encoding, PropertyFormat format, boolean silent)
Properties
object loaded from location
using encoding
.protected static String getCanonicalLocation(String location)
public static final Properties getPrefixedProperties(Properties properties, String prefix)
Properties
object containing properties prefixed with prefix
. If prefix
is blank, the new properties object duplicates
the properties passed in.public static final String convertToEnvironmentVariable(String key)
foo.bar -> FOO_BAR
public static final String getEnvironmentVariableKey(String key)
env
foo.bar -> env.FOO_BAR
public static final Properties reformatKeysAsEnvVars(Properties properties)
public static final void addOrOverrideProperty(Properties properties, String key, String newValue, Mode propertyOverwriteMode)
propertyOverwriteMode
to make sure we have permission to override the value.public static final void addOrOverrideProperty(Properties properties, String key, String newValue, Mode overrideMode, int indent)
public static final void addListComparisonProperties(Properties properties, ComparisonResults listComparison, List<String> propertyNames)
properties
- the Properties to populatelistComparison
- the ComparisonResults to use for datapropertyNames
- the list of property keys to set. Exactly 3 names are required, and the assumed order is: index 0: key for the ADDED list index 1: key for the SAME list index 2:
key for the DELETED listCopyright © 2010–2014 The Kuali Foundation. All rights reserved.