java.lang.Object
com.zeroc.Ice.Properties
Represents a set of properties used to configure Ice and Ice-based applications. A property is a key/value pair,
where both the key and the value are strings. By convention, property keys should have the form
application-name[.category[.sub-category]].name.
This class is thread-safe: multiple threads can safely read and write the properties.-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty property set.Properties(String[] args) Constructs a property set, loads the configuration files specified by theIce.Configproperty or theICE_CONFIGenvironment variable, and then parses Ice properties fromargs.Properties(String[] args, Properties defaults) Constructs a property set, loads the configuration files specified by theIce.Configproperty or theICE_CONFIGenvironment variable, and then parses Ice properties fromargs.Properties(String[] args, Properties defaults, List<String> remainingArgs) Constructs a property set, loads the configuration files specified by theIce.Configproperty or theICE_CONFIGenvironment variable, and then parses Ice properties fromargs.Properties(String[] args, List<String> remainingArgs) Constructs a property set, loads the configuration files specified by theIce.Configproperty or theICE_CONFIGenvironment variable, and then parses Ice properties fromargs. -
Method Summary
Modifier and TypeMethodDescription_clone()Creates a copy of this property set.String[]Gets a sequence of command-line options that is equivalent to this property set.getIceProperty(String key) Gets an Ice property by key.intGets an Ice property as an integer.String[]Gets an Ice property as a list of strings.getPropertiesForPrefix(String prefix) Gets all properties whose keys begin withprefix.getProperty(String key) Gets a property by key.intgetPropertyAsInt(String key) Gets a property as an integer.intgetPropertyAsIntWithDefault(String key, int value) Gets a property as an integer.String[]getPropertyAsList(String key) Gets a property as a list of strings.String[]getPropertyAsListWithDefault(String key, String[] value) Gets a property as a list of strings.getPropertyWithDefault(String key, String value) Gets a property by key.Gets the properties that were never read.voidLoads properties from a file.String[]parseCommandLineOptions(String prefix, String[] options) Converts a sequence of command-line options into properties.String[]parseIceCommandLineOptions(String[] options) Converts a sequence of command-line options into properties.voidsetProperty(String key, String value) Sets a property.
-
Constructor Details
-
Properties
public Properties()Constructs an empty property set. -
Properties
Constructs a property set, loads the configuration files specified by theIce.Configproperty or theICE_CONFIGenvironment variable, and then parses Ice properties fromargs.This constructor loads properties from files specified by the
ICE_CONFIGenvironment variable when there is no--Ice.Configcommand-line argument.- Parameters:
args- the command-line arguments. This constructor parses arguments starting with--and one of the reserved prefixes (Ice, IceSSL, etc.) as properties. If there is an argument starting with--Ice.Config, this constructor loads the specified configuration file. When the same property is set in a configuration file and through a command-line argument, the command-line setting takes precedence.
-
Properties
Constructs a property set, loads the configuration files specified by theIce.Configproperty or theICE_CONFIGenvironment variable, and then parses Ice properties fromargs.This constructor loads properties from files specified by the
ICE_CONFIGenvironment variable when there is no--Ice.Configcommand-line argument.- Parameters:
args- the command-line arguments. This constructor parses arguments starting with--and one of the reserved prefixes (Ice, IceSSL, etc.) as properties. If there is an argument starting with--Ice.Config, this constructor loads the specified configuration file. When the same property is set in a configuration file and through a command-line argument, the command-line setting takes precedence.remainingArgs- if non-null, this list will be cleared and filled with any command-line arguments that were not used to set properties.
-
Properties
Constructs a property set, loads the configuration files specified by theIce.Configproperty or theICE_CONFIGenvironment variable, and then parses Ice properties fromargs.This constructor loads properties from files specified by the
ICE_CONFIGenvironment variable when there is no--Ice.Configcommand-line argument.- Parameters:
args- the command-line arguments. This constructor parses arguments starting with--and one of the reserved prefixes (Ice, IceSSL, etc.) as properties. If there is an argument starting with--Ice.Config, this constructor loads the specified configuration file. When the same property is set in a configuration file and through a command-line argument, the command-line setting takes precedence.defaults- default values for the newPropertiesobject. Settings in configuration files andargsoverride these defaults.
-
Properties
Constructs a property set, loads the configuration files specified by theIce.Configproperty or theICE_CONFIGenvironment variable, and then parses Ice properties fromargs.This constructor loads properties from files specified by the
ICE_CONFIGenvironment variable when there is no--Ice.Configcommand-line argument.- Parameters:
args- the command-line arguments. This constructor parses arguments starting with--and one of the reserved prefixes (Ice, IceSSL, etc.) as properties. If there is an argument starting with--Ice.Config, this constructor loads the specified configuration file. When the same property is set in a configuration file and through a command-line argument, the command-line setting takes precedence.defaults- default values for the newPropertiesobject. Settings in configuration files andargsoverride these defaults.remainingArgs- if non-null, this list will be cleared and filled with any command-line arguments that were not used to set properties.
-
-
Method Details
-
getProperty
Gets a property by key.- Parameters:
key- the property key- Returns:
- the property value, or the empty string if the property is not set
- See Also:
-
getIceProperty
Gets an Ice property by key.- Parameters:
key- the property key- Returns:
- the property value, or the default value for this property if the property is not set
- Throws:
PropertyException- if the property is not a known Ice property- See Also:
-
getPropertyWithDefault
Gets a property by key.- Parameters:
key- the property keyvalue- the default value to return if the property is not set- Returns:
- the property value or the default value if the property is not set
- See Also:
-
getPropertyAsInt
Gets a property as an integer.- Parameters:
key- the property key- Returns:
- the property value interpreted as an integer, or
0if the property is not set - Throws:
PropertyException- if the property value is not a valid integer- See Also:
-
getIcePropertyAsInt
Gets an Ice property as an integer.- Parameters:
key- the property key- Returns:
- the property value interpreted as an integer, or the default value if the property is not set
- Throws:
PropertyException- if the property is not a known Ice property or its value is not a valid integer- See Also:
-
getPropertyAsIntWithDefault
Gets a property as an integer.- Parameters:
key- the property keyvalue- the default value to return if the property does not exist- Returns:
- the property value interpreted as an integer, or the default value if the property is not set
- Throws:
PropertyException- if the property value is not a valid integer- See Also:
-
getPropertyAsList
Gets a property as a list of strings. The strings must be separated by whitespace or comma. The strings in the list can contain whitespace and commas if they are enclosed in single or double quotes. If quotes are mismatched, an empty list is returned. Within single quotes or double quotes, you can escape the quote in question with a backslash, e.g. O'Reilly can be written asO'Reilly,"O'Reilly"or'O\'Reilly'.- Parameters:
key- the property key- Returns:
- the property value interpreted as a list of strings, or an empty list if the property is not set
- See Also:
-
getIcePropertyAsList
Gets an Ice property as a list of strings. The strings must be separated by whitespace or comma. The strings in the list can contain whitespace and commas if they are enclosed in single or double quotes. If quotes are mismatched, the default list is returned. Within single quotes or double quotes, you can escape the quote in question with a backslash, e.g. O'Reilly can be written asO'Reilly,"O'Reilly"or'O\'Reilly'.- Parameters:
key- the property key- Returns:
- the property value interpreted as a list of strings, or the default value if the property is not set
- Throws:
PropertyException- if the property is not a known Ice property- See Also:
-
getPropertyAsListWithDefault
Gets a property as a list of strings. The strings must be separated by whitespace or comma. The strings in the list can contain whitespace and commas if they are enclosed in single or double quotes. If quotes are mismatched, the default list is returned. Within single quotes or double quotes, you can escape the quote in question with a backslash, e.g. O'Reilly can be written asO'Reilly,"O'Reilly"or'O\'Reilly'.- Parameters:
key- the property keyvalue- the default value to return if the property is not set- Returns:
- the property value interpreted as a list of strings, or the default value if the property is not set
- See Also:
-
getPropertiesForPrefix
Gets all properties whose keys begin withprefix. Ifprefixis the empty string, then all properties are returned.- Parameters:
prefix- the prefix to search for- Returns:
- the matching property set
-
setProperty
Sets a property. To unset a property, set it to the empty string.- Parameters:
key- the property keyvalue- the property value- See Also:
-
getCommandLineOptions
Gets a sequence of command-line options that is equivalent to this property set. Each element of the returned sequence is a command-line option of the form--key=value.- Returns:
- the command line options for this property set
-
parseCommandLineOptions
Converts a sequence of command-line options into properties. All options that start with--prefix.are converted into properties. If the prefix is empty, all options that begin with--are converted to properties.- Parameters:
prefix- the property prefix, or the empty string to convert all options starting with--options- the command-line options- Returns:
- the command-line options that do not start with the specified prefix, in their original order
-
parseIceCommandLineOptions
Converts a sequence of command-line options into properties. All options that start with one of the reserved Ice prefixes (--Ice,--IceSSL, etc.) are converted into properties.- Parameters:
options- the command-line options- Returns:
- the command-line options that do not start with one of the reserved prefixes, in their original order
-
load
Loads properties from a file.- Parameters:
file- the property file
-
_clone
Creates a copy of this property set.- Returns:
- a copy of this property set
-
getUnusedProperties
Gets the properties that were never read.- Returns:
- a list of unused properties
-