- 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.
Also supports case-insensitive keys.
- See Also:
-
Field Summary
Fields inherited from class java.util.Properties
defaults -
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty property list.EncryptedProperties(int initialCapacity) Creates an empty property list with an initial size. -
Method Summary
Modifier and TypeMethodDescriptionclone()getKeyIgnoreCase(String key) Gets the case-sensitive key.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.Searches for the property with the specified key case insensitively.
ThrowsTentackleRuntimeException, if duplicate case-mapped keys found.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. -
EncryptedProperties
public EncryptedProperties(int initialCapacity) Creates an empty property list with an initial size.- Parameters:
initialCapacity- theEncryptedPropertieswill be sized to accommodate this many elements- Throws:
IllegalArgumentException- if the initial capacity is less than zero.
-
-
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
-
getPropertyIgnoreCase
Searches for the property with the specified key case insensitively.
ThrowsTentackleRuntimeException, if duplicate case-mapped keys found.- Parameters:
key- the property key in any case combination- Returns:
- the value, null if none
-
getKeyIgnoreCase
Gets the case-sensitive key.- Parameters:
key- the case-insensitive key- Returns:
- the original case-sensitive key
-
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
-