- All Implemented Interfaces:
Serializable,Cloneable,Map<Object,Object>
Encrypted
If a value starts with a
Properties.If a value starts with a
~ (tilde), the remainder of the string is considered to be
encrypted by the application-specific Cryptor.
If an unencrypted value starts with a ~, it must be escaped with a backslash.- See Also:
-
Field Summary
Fields inherited from class java.util.Properties
defaults -
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty property list with no default values.EncryptedProperties(int initialCapacity) Creates an empty property list with no default values, and with an initial size accommodating the specified number of elements without the need to dynamically resize.EncryptedProperties(Properties defaults) Creates an empty property list with the specified defaults. -
Method Summary
Modifier and TypeMethodDescriptionclone()Gets the key prefix.getName()Gets the optional name of the properties.getProperty(String key) Searches for the property with the specified key in this property list.
If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked.char[]getPropertyAsChars(String key) Gets the property as a character array.
Same asgetProperty(String), but returns an array.char[]getPropertyAsChars(String key, char[] defaults) Gets the property as a character array with a default value.getPropertyBlunt(String key) Gets the original value of the property.
If the value is encrypted, the encrypted value will be returned.voidsetEncryptedProperty(String key, char[] value) Sets the property char array and stores it encrypted, if a Cryptor is available.voidsetEncryptedProperty(String key, String value) Sets the property string and stores it encrypted, if a Cryptor is available.voidsetKeyPrefix(String keyPrefix) Sets a key prefix.
The prefix is prepended to the key forgetProperty(String)and alike.voidSets the optional name of the properties.
The name can be used to express the source, for example the name of a properties file.setProperty(String key, String value) Same asProperties.stringPropertyNames()but returns only those keys that belong to thekeyPrefixspace, if set.Methods inherited from class java.util.Properties
clear, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, getProperty, hashCode, isEmpty, keys, keySet, list, list, load, load, loadFromXML, merge, propertyNames, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, save, size, store, store, storeToXML, storeToXML, storeToXML, toString, values
-
Constructor Details
-
EncryptedProperties
public EncryptedProperties()Creates an empty property list with no default values. -
EncryptedProperties
public EncryptedProperties(int initialCapacity) Creates an empty property list with no default values, and with an initial size accommodating the specified number of elements without the need to dynamically resize.- Parameters:
initialCapacity- theEncryptedPropertieswill be sized to accommodate this many elements- Throws:
IllegalArgumentException- if the initial capacity is less than zero.
-
EncryptedProperties
Creates an empty property list with the specified defaults.- Parameters:
defaults- the defaults.
-
-
Method Details
-
clone
- Overrides:
clonein classProperties
-
getName
Gets the optional name of the properties.- Returns:
- the name
-
setName
Sets the optional name of the properties.
The name can be used to express the source, for example the name of a properties file.- Parameters:
name- the name
-
getKeyPrefix
Gets the key prefix.- Returns:
- the prefix, null if none (default)
-
setKeyPrefix
Sets a key prefix.
The prefix is prepended to the key forgetProperty(String)and alike. This allows merging the properties with others (such as spring's application.properties) and avoid duplicates.
Notice that all low-level methods ofHashtabledealing with objects rather than strings ignore the prefix.- Parameters:
keyPrefix- the prefix, null if none
-
getProperty
Searches for the property with the specified key in this property list.
If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returnsnullif the property is not found.If the property is encrypted, it will be returned decrypted.
- Overrides:
getPropertyin classProperties- Parameters:
key- the property key- Returns:
- the value in this property list with the specified key value
- See Also:
-
setProperty
- Overrides:
setPropertyin classProperties
-
stringPropertyNames
Same asProperties.stringPropertyNames()but returns only those keys that belong to thekeyPrefixspace, if set.- Overrides:
stringPropertyNamesin classProperties- Returns:
- unmodifiable set of keys
-
getPropertyBlunt
Gets the original value of the property.
If the value is encrypted, the encrypted value will be returned.- Parameters:
key- the property key- Returns:
- the value, null if no such key
-
getPropertyAsChars
Gets the property as a character array.
Same asgetProperty(String), but returns an array. In case the value was encrypted, the decrypted array can be erased by the application after use.- Parameters:
key- the property key- Returns:
- the value as a character array or null if no such key
-
getPropertyAsChars
Gets the property as a character array with a default value.- Parameters:
key- the property keydefaults- the default value- Returns:
- the value as a character array or null if no such key
-
setEncryptedProperty
Sets the property string and stores it encrypted, if a Cryptor is available.- Parameters:
key- the property keyvalue- the unencrypted value
-
setEncryptedProperty
Sets the property char array and stores it encrypted, if a Cryptor is available.- Parameters:
key- the property keyvalue- the unencrypted value
-