Class PropertyMgr
java.lang.Object
fc.util.PropertyMgr
- Direct Known Subclasses:
FilePropertyMgr, ServletPropertyMgr
Implementations help load and manage properties from various
sources including java property files, databases, custom
file formats etc. Regardless of where the properties are
loaded from, each property consists of a pair of name
and value strings.
- Version:
- 1.0 12/30/2001
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract StringReturns the property associated with the specified key or null if the property was not found.Returns the property associated with the specified key.booleangetBoolean(String name, boolean backup) Returns the property associated with the specified key as a boolean value.intReturns the property associated with the specified key as a integer value.getRequired(String name) Returns the value corresponding to the specified key.booleangetRequiredBoolean(String name) intgetRequiredInt(String name) abstract voidsave()Saves any properties that were set previously.abstract StringSets the property associated with the specified key.voidSpecify program usage information to be output when an error occurs.
-
Constructor Details
-
PropertyMgr
public PropertyMgr()Constructs a new PropertyMgr.
-
-
Method Details
-
get
-
get
-
getBoolean
Returns the property associated with the specified key as a boolean value. If the property is present, then the corresponding boolean value is true if the property value is any of the following (case-insensitive):yes, 1, trueelse false is returned.
- Parameters:
name- the property keybackup- value to return if the property for the specified property is not present- Returns:
- value of specified key or backup string
-
getInt
Returns the property associated with the specified key as a integer value. If the property is present but cannot be converted into an integer (via a invalid input: '{@link Integer.parseInt(String)'} call), the backup value will be returned.- Parameters:
name- the property keybackup- value to return if the property for the specified property is not present- Returns:
- value of specified key or backup string
-
getRequired
Returns the value corresponding to the specified key. If the property value is not found, thehandleError(String)method is called, which by default prints a stack trace and exits the application.If the handleError method is overriden to not exit the application, then this method will return null if the specified key is not found.
- Parameters:
name- the property key
-
getRequiredBoolean
-
getRequiredInt
-
set
-
save
Saves any properties that were set previously. This method does not need to be called if properties were only read, however if any property was modified or added, it is essential to call this method to save any such changes.- Throws:
IOException
-
setUsage
-