Package io.deephaven.configuration
Class ParsedProperties
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<Object,
Object>
Class for reading in a customized properties file, applying only the locally-relevant properties and keeping track of
which properties may not be further modified. Maintains the ordering of the properties from the input file.
- See Also:
-
Field Summary
Fields inherited from class java.util.Properties
defaults
-
Constructor Summary
ConstructorDescriptionA constructor that starts with no existing scoped or final properties.ParsedProperties
(boolean ignoreScopes) A constructor that starts with no existing scoped or final properties. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
boolean
boolean
containsKey
(Object key) boolean
containsValue
(Object value) elements()
@NotNull Set
entrySet()
boolean
A mapping from each property name to the file and location where the property came from.getProperty
(String key) boolean
isEmpty()
keys()
@NotNull Set
keySet()
void
list
(PrintStream out) void
list
(PrintWriter out) void
load
(InputStream stream) Load the properties from the specified InputStream, ignoring any directives that do not match the current context.void
Load the properties from the specified file, ignoring any directives that do not match the current context.Determine whether a property is final or not, and only allow the update if it is not already final.void
Remove a non-final property from the collection.setProperty
(String key, String value) Determine whether a property is final or not, and only allow the update if it is not already final.int
size()
@NotNull Collection
values()
Methods inherited from class java.util.Properties
clone, compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, getProperty, hashCode, load, loadFromXML, merge, propertyNames, putIfAbsent, rehash, remove, replace, replace, replaceAll, save, store, store, storeToXML, storeToXML, storeToXML, stringPropertyNames, toString
-
Constructor Details
-
ParsedProperties
public ParsedProperties()A constructor that starts with no existing scoped or final properties. -
ParsedProperties
public ParsedProperties(boolean ignoreScopes) A constructor that starts with no existing scoped or final properties.- Parameters:
ignoreScopes
- True if this parser should ignore scope restrictions, false otherwise. Used by the PropertyInspector when checking whether required or disallowed properties are present.
-
-
Method Details
-
getLineNumbers
A mapping from each property name to the file and location where the property came from. This is public so that we can use this in a property inspector to get the full story about what properties exist and where those properties were defined.- Returns:
- The current map
-
putAll
-
clear
public void clear() -
contains
- Overrides:
contains
in classProperties
-
containsKey
- Specified by:
containsKey
in interfaceMap<Object,
Object> - Overrides:
containsKey
in classProperties
-
containsValue
- Specified by:
containsValue
in interfaceMap<Object,
Object> - Overrides:
containsValue
in classProperties
-
elements
- Overrides:
elements
in classProperties
-
entrySet
-
equals
-
get
-
getProperty
- Overrides:
getProperty
in classProperties
-
isEmpty
public boolean isEmpty() -
keys
- Overrides:
keys
in classProperties
-
keySet
-
list
- Overrides:
list
in classProperties
-
list
- Overrides:
list
in classProperties
-
size
public int size() -
values
-
load
Load the properties from the specified InputStream, ignoring any directives that do not match the current context. Automatically closes the stream when the last line has been processed.- Overrides:
load
in classProperties
- Parameters:
stream
- The open stream providing a view into the data to be parsed.- Throws:
IOException
- If the stream cannot be read at some point.
-
put
Determine whether a property is final or not, and only allow the update if it is not already final. -
remove
Remove a non-final property from the collection. Attempting to remove a final property will cause a ConfigurationException to be thrown. -
setProperty
Determine whether a property is final or not, and only allow the update if it is not already final. This should not be called from within the load operation for this class.- Overrides:
setProperty
in classProperties
- Parameters:
key
- The name of the property to set a value for.value
- The value of the property being set.- Returns:
- The previous value of the property being set, or null if it had no previous value.
-
load
Load the properties from the specified file, ignoring any directives that do not match the current context. Directories may be specified, including relative paths, but the '~' operator is not supported.Loads the fileName via
PropertyInputStreamLoader
.- Parameters:
fileName
- The resource or file to load.- Throws:
IOException
- if the property stream cannot be processedConfigurationException
- if the property stream cannot be opened
-