java.lang.Object
com.zeroc.Ice.Properties
A property set used to configure Ice and Ice applications. Properties are key/value pairs, with
both keys and values being strings. By convention, property keys should have the form
application-name[.category[.sub-category]].name.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty property set.Properties
(String[] args) Creates a property set initialized from an argument vector.Properties
(String[] args, Properties defaults) Creates a property set initialized from an argument vector.Properties
(String[] args, Properties defaults, List<String> remainingArgs) Creates a property set initialized from an argument vector and return the remaining arguments.Properties
(String[] args, List<String> remainingArgs) Creates a property set initialized from an argument vector and return the remaining arguments.Properties
(List<String> optInPrefixes) Creates a property set initialized with a list of opt-in prefixes. -
Method Summary
Modifier and TypeMethodDescription_clone()
Create a copy of this property set.String[]
Get a sequence of command-line options that is equivalent to this property set.getIceProperty
(String key) Get an Ice property by key.int
Get an Ice property as an integer.String[]
Get an Ice property as a list of strings.getPropertiesForPrefix
(String prefix) Get all properties whose keys begins with prefix.getProperty
(String key) Get a property by key.int
getPropertyAsInt
(String key) Get a property as an integer.int
getPropertyAsIntWithDefault
(String key, int value) Get a property as an integer.String[]
getPropertyAsList
(String key) Get a property as a list of strings.String[]
getPropertyAsListWithDefault
(String key, String[] value) Get a property as a list of strings.getPropertyWithDefault
(String key, String value) Get a property by key.Gets the properties that were never read.void
Load properties from a file.String[]
parseCommandLineOptions
(String prefix, String[] options) Convert a sequence of command-line options into properties.String[]
parseIceCommandLineOptions
(String[] options) Convert a sequence of command-line options into properties.void
setProperty
(String key, String value) Set a property.
-
Constructor Details
-
Properties
public Properties()Constructs an empty property set. -
Properties
Creates a property set initialized with a list of opt-in prefixes.- Parameters:
optInPrefixes
- A list of prefixes that are opt-in.
-
Properties
Creates a property set initialized from an argument vector.- Parameters:
args
- A command-line argument vector, possibly containing options to set properties. If the command-line options include a--Ice.Config
option, the corresponding configuration files are parsed. If the same property is set in a configuration file and in the argument vector, the argument vector takes precedence.
-
Properties
Creates a property set initialized from an argument vector and return the remaining arguments.- Parameters:
args
- A command-line argument vector, possibly containing options to set properties. If the command-line options include a--Ice.Config
option, the corresponding configuration files are parsed. If the same property is set in a configuration file and in the argument vector, the argument vector takes precedence.remainingArgs
- If non null, the given list will contain on return the command-line arguments that were not used to set properties.
-
Properties
Creates a property set initialized from an argument vector.- Parameters:
args
- A command-line argument vector, possibly containing options to set properties. If the command-line options include a--Ice.Config
option, the corresponding configuration files are parsed. If the same property is set in a configuration file and in the argument vector, the argument vector takes precedence.defaults
- Default values for the property set. Settings in configuration files andargs
override these defaults.
-
Properties
Creates a property set initialized from an argument vector and return the remaining arguments.- Parameters:
args
- A command-line argument vector, possibly containing options to set properties. If the command-line options include a--Ice.Config
option, the corresponding configuration files are parsed. If the same property is set in a configuration file and in the argument vector, the argument vector takes precedence.defaults
- Default values for the property set. Settings in configuration files andargs
override these defaults.remainingArgs
- If non null, the given list will contain on return the command-line arguments that were not used to set properties.
-
-
Method Details
-
getProperty
Get a property by key. If the property is not set, an empty string is returned.- Parameters:
key
- The property key.- Returns:
- The property value.
- See Also:
-
getIceProperty
Get an Ice property by key. If the property is not set, its default value is returned.- Parameters:
key
- The property key.- Returns:
- The property value or the default value.
- Throws:
PropertyException
- If the property is not a known Ice property.- See Also:
-
getPropertyWithDefault
Get a property by key. If the property is not set, the given default value is returned.- Parameters:
key
- The property key.value
- The default value to use if the property does not exist.- Returns:
- The property value or the default value.
- See Also:
-
getPropertyAsInt
Get a property as an integer. If the property is not set, 0 is returned.- Parameters:
key
- The property key.- Returns:
- The property value interpreted as an integer.
- Throws:
PropertyException
- If the property value is not a valid integer.- See Also:
-
getIcePropertyAsInt
Get an Ice property as an integer. If the property is not set, its default value is returned.- Parameters:
key
- The property key.- Returns:
- The property value interpreted as an integer, or the default value.
- Throws:
PropertyException
- If the property is not a known Ice property or the value is not a valid integer.- See Also:
-
getPropertyAsIntWithDefault
Get a property as an integer. If the property is not set, the given default value is returned.- Parameters:
key
- The property key.value
- The default value to use if the property does not exist.- Returns:
- The property value interpreted as an integer, or the default value.
- Throws:
PropertyException
- If the property value is not a valid integer.- See Also:
-
getPropertyAsList
Get a property as a list of strings. The strings must be separated by whitespace or comma. If the property is not set, an empty list is returned. 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 as O'Reilly, "O'Reilly" or 'O\'Reilly'.- Parameters:
key
- The property key.- Returns:
- The property value interpreted as a list of strings.
- See Also:
-
getIcePropertyAsList
Get an Ice property as a list of strings. The strings must be separated by whitespace or comma. If the property is not set, its default list is returned. 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 as O'Reilly, "O'Reilly" or 'O\'Reilly'.- Parameters:
key
- The property key.- Returns:
- The property value interpreted as list of strings, or the default value.
- Throws:
PropertyException
- If the property is not a known Ice property.- See Also:
-
getPropertyAsListWithDefault
Get a property as a list of strings. The strings must be separated by whitespace or comma. If the property is not set, the default list is returned. 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 as O'Reilly, "O'Reilly" or 'O\'Reilly'.- Parameters:
key
- The property key.value
- The default value to use if the property is not set.- Returns:
- The property value interpreted as list of strings, or the default value.
- See Also:
-
getPropertiesForPrefix
Get all properties whose keys begins with prefix. If prefix is an empty string, then all properties are returned.- Parameters:
prefix
- The prefix to search for (empty string if none).- Returns:
- The matching property set.
-
setProperty
Set a property. To unset a property, set it to the empty string.- Parameters:
key
- The property key.value
- The property value.- See Also:
-
getCommandLineOptions
Get 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
Convert a sequence of command-line options into properties. All options that begin 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 an 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
Convert a sequence of command-line options into properties. All options that begin with one of the following prefixes are converted into properties:--Ice
,--IceBox
,--IceGrid
,--Ice.SSL
,--IceStorm
, and--Glacier2
.- Parameters:
options
- The command-line options.- Returns:
- The command-line options that do not start with one of the listed prefixes, in their original order.
-
load
Load properties from a file.- Parameters:
file
- The property file.
-
_clone
Create 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
-