public class PropertiesWrapper extends Object
Properties that provides convenience methods for
accessing primitives.| Constructor and Description |
|---|
PropertiesWrapper(Properties properties)
Creates an instance that delegates to the given
Properties. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
getBooleanProperty(String name,
boolean defaultValue)
Returns the value of a
boolean property. |
<T> T |
getClassInstanceProperty(String name,
Class<T> type,
Class<?>[] paramTypes,
Object... args)
Returns an instance of the class whose fully qualified class name is
specified by a property, and that has a constructor with the specified
parameters.
|
int |
getIntProperty(String name,
int defaultValue)
Returns the value of an
int property. |
int |
getIntProperty(String name,
int defaultValue,
int min,
int max)
Returns the value of an
int property within a bound range of
values. |
long |
getLongProperty(String name,
long defaultValue)
Returns the value of a
long property. |
long |
getLongProperty(String name,
long defaultValue,
long min,
long max)
Returns the value of a
long property within a bound range of
values. |
Properties |
getProperties()
Returns the associated
Properties. |
String |
getProperty(String name)
Returns the value of a property as a
String, or
null if the property is not found. |
String |
getProperty(String name,
String defaultValue)
Returns the value of a property as a
String, or the default
value if the property is not found. |
int |
getRequiredIntProperty(String name)
Returns the value of a required
int property. |
int |
getRequiredIntProperty(String name,
int min,
int max)
Returns the value of a required
int property within a bound
range of values. |
public PropertiesWrapper(Properties properties)
Properties.properties - the Properties to wrappublic Properties getProperties()
Properties.Propertiespublic String getProperty(String name)
String, or
null if the property is not found.name - the property namenullpublic String getProperty(String name, String defaultValue)
String, or the default
value if the property is not found.name - the property namedefaultValue - the default valuepublic boolean getBooleanProperty(String name, boolean defaultValue)
boolean property.name - the property namedefaultValue - the default valuepublic int getIntProperty(String name, int defaultValue)
int property.name - the property namedefaultValue - the default valueNumberFormatException - if the value does not contain a parsable
intpublic int getRequiredIntProperty(String name)
int property.name - the property nameIllegalArgumentException - if the value is not setNumberFormatException - if the value does not contain a parsable
intpublic int getIntProperty(String name, int defaultValue, int min, int max)
int property within a bound range of
values.name - the property namedefaultValue - the default valuemin - the minimum value to allowmax - the maximum value to allowIllegalArgumentException - if the value or defaultValue
is less than min or greater than max, or if
min is greater than maxNumberFormatException - if the value does not contain a parsable
intpublic int getRequiredIntProperty(String name, int min, int max)
int property within a bound
range of values.name - the property namemin - the minimum value to allowmax - the maximum value to allowIllegalArgumentException - if the value or defaultValue
is less than min or greater than max, or if
min is greater than max, or if the value
is not setNumberFormatException - if the value does not contain a parsable
intpublic long getLongProperty(String name, long defaultValue)
long property.name - the property namedefaultValue - the default valueNumberFormatException - if the value does not contain a parsable
longpublic long getLongProperty(String name, long defaultValue, long min, long max)
long property within a bound range of
values.name - the property namedefaultValue - the default valuemin - the minimum value to allowmax - the maximum value to allowIllegalArgumentException - if the value or defaultValue
is less than min or greater than max, or if
min is greater than maxNumberFormatException - if the value does not contain a parsable
longpublic <T> T getClassInstanceProperty(String name, Class<T> type, Class<?>[] paramTypes, Object... args)
T - the type of the return valuename - the property nametype - the class which the return value should be an instance ofparamTypes - the constructor parameter typesargs - the arguments to pass to the constructornull if the property is not
foundIllegalArgumentException - if the property is found and a problem
occurs creating the instance, or if the constructor throws a
checked exceptionCopyright © 2007-2013. All Rights Reserved.