Properties class

The Properties class implementing all tools to load key-values from file both by name and path. Input files are supposed to be in UTF-8 format.

Constructors

Properties(String name)
Create a new properties instance by naming the source file using name.
Properties.fromFile(String path)
Create a new properties instance from file path.
Properties.fromJSON(String jsonMap)
Create a new properties instance using the input jsonMap to load the data from.
Properties.fromMap(Map<String, String?> map)
Create a new properties instance from the input map.
Properties.fromString(String value)
Create a new properties instance from String.

Properties

boolEvaluator BoolEvaluator
Getter for boolEvaluator instance.
getter/setter pair
enableEvents bool
Getter for enableEvents flag.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
isEmpty bool
Whether there is no key/value pair in the map.
no setter
isNotEmpty bool
Whether there is at least one key/value pair in the map.
no setter
keys List<String>
Rerturns the whole set of keys
no setter
onAdd Stream<AddEvent>
Get the stream instance for the "property added" event.
no setter
onChange Stream<PropertiesEvent>
Get the stream instance for the change event stream.
no setter
onUpdate Stream<UpdateEvent>
Get the stream instance for the "property updated" event.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
size int
Returns the current number of properties
no setter
values List<String?>
Returns the whole set of values
no setter

Methods

add(String key, String value, [bool overwriteExisting = true]) bool
Add a property to the instance having name key and value value. If the property already exists its value will be replaced. Returns true if the property was added successfully, false otherwise.
contains(String key) bool
Check whether the properties contains a property given its key
delete(String key) bool
Deletes the key property from the instance, if present.
every(bool k(String str), [bool v(String? val)?]) Properties?
Returns a Properties instance containg every property whose key satisifies the predicate k on the property key, and optionally the predicate v on the corresponding value. Returns null otherwise.
get(String key, {Object? defval, String? defkey}) String?
Loads the value of a property given its key. Use defval to set a default value in case of missing property. Use defkey to set a default key in case of missing property.
getBool(String key, {bool throwException = false, int? defval, String? defkey}) bool?
Loads the value of a property as a bool given its key. Boolean value evaluation can be customized using by setting a new BoolEvaluator instance. Use defval to set a default value in case of missing property. Use defkey to set a default key in case of missing property.
getDouble(String key, {bool throwException = false, double? defval, String? defkey}) double?
Loads the value of a property as a double given its key. Use defval to set a default value in case of missing property. Use defkey to set a default key in case of missing property.
getInt(String key, {bool throwException = false, int? defval, String? defkey}) int?
Loads the value of a property as an integer given its key. Use defval to set a default value in case of missing property. Use defkey to set a default key in case of missing property.
getList(String key) List<String>
Loads a list of strings for the input key. List elements must be comma separated.
merge(Properties properties, [bool overwriteExisting = true]) → void
Merge input properties content with the current instance's properties. By defatult already existing properties will be overwritten. Anyway user may decide how to manage existing thanks to the optional parameter overwriteExisting.
mergeJSON(String jsonMap, [bool overwriteExisting = true]) → void
Merge properties from the input jsonMap with the current instance's properties. By defatult already existing properties will be overwritten. Anyway user may decide how to manage existing thanks to the optional parameter overwriteExisting.
mergeMap(Map<String, String?> map, [bool overwriteExisting = true]) → void
Merge properties from the input map with the current instance's properties. By defatult already existing properties will be overwritten. Anyway user may decide how to manage existing thanks to the optional parameter overwriteExisting.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reload() → dynamic
Reloads the properties from file. Works for file sources only.
saveToFile(String path) → void
Synchronously dumps all properties to the specified file.
toFile(String path) → void
Write the content to the input file.
toJSON({String? prefix, String? suffix}) String
Export the content as a JSON map. If no input parameter is set, then the whole set of properties will be exporte as a JSON map. If the prefix parameter is set, then only the keys starting with prefix will be exported. If the suffix parameter is set, then only the keys starting with suffix will be exported. If both are set, then only the keys matching both will be exported.
toString() String
Returns the whole content as a String.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited
operator [](String key) String?
Returns the value for the given key or null if key is not in the map. No default will be applied.
operator []=(String key, String value) → void
Associates the key with the given value. This method adds a new property if the input one does not exists or updates the existing one.

Static Properties

BACKSLASH int
final
CR int
final
EQUAL int
final
NEWLINE int
final
SLASH int
final
SPACE int
final

Constants

ADD_PROPERTY_EVENTNAME → const String
The property added event name
DELETE_PROPERTY_EVENTNAME → const String
The property deleted event name
UPDATE_PROPERTY_EVENTNAME → const String
The property updated event name