|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.sgs.impl.sharedutil.PropertiesWrapper
public class PropertiesWrapper
Wrapper around a Properties that provides convenience methods for
accessing primitives.
| Constructor Summary | |
|---|---|
PropertiesWrapper(Properties properties)
Creates an instance that delegates to the given Properties. |
|
| Method Summary | ||
|---|---|---|
boolean |
getBooleanProperty(String name,
boolean defaultValue)
Returns the value of a boolean property. |
|
|
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. |
|
|
getClassInstanceProperty(String name,
String defaultClass,
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. |
|
List<Class<?>> |
getClassListProperty(String name)
Returns a List of Class typed objects. |
|
|
getEnumListProperty(String name,
Class<T> enumType,
T defaultElement)
Returns a list of Enums of the type specified by
enumType. |
|
|
getEnumProperty(String name,
Class<T> enumType,
T defaultValue)
Returns the value of an Enum property. |
|
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. |
|
|
getListProperty(String name,
Class<T> type,
T defaultElement)
Returns a list of objects of the type specified by type. |
|
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. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PropertiesWrapper(Properties properties)
Properties.
properties - the Properties to wrap| Method Detail |
|---|
public Properties getProperties()
Properties.
Propertiespublic String getProperty(String name)
String, or
null if the property is not found.
name - the property name
null
public String getProperty(String name,
String defaultValue)
String, or the default
value if the property is not found.
name - the property namedefaultValue - the default value
public boolean getBooleanProperty(String name,
boolean defaultValue)
boolean property.
name - the property namedefaultValue - the default value
public int getIntProperty(String name,
int defaultValue)
int property.
name - the property namedefaultValue - the default value
NumberFormatException - if the value does not contain a parsable
intpublic int getRequiredIntProperty(String name)
int property.
name - the property name
IllegalArgumentException - if the value is not set
NumberFormatException - if the value does not contain a parsable
int
public 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 allow
IllegalArgumentException - if the value or defaultValue
is less than min or greater than max, or if
min is greater than max
NumberFormatException - if the value does not contain a parsable
int
public 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 allow
IllegalArgumentException - 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 set
NumberFormatException - if the value does not contain a parsable
int
public long getLongProperty(String name,
long defaultValue)
long property.
name - the property namedefaultValue - the default value
NumberFormatException - if the value does not contain a parsable
long
public 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 allow
IllegalArgumentException - if the value or defaultValue
is less than min or greater than max, or if
min is greater than max
NumberFormatException - if the value does not contain a parsable
long
public <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 constructor
null if the property is not
found
IllegalArgumentException - if the property is found and a problem
occurs creating the instance, or if the constructor throws
a checked exception
public <T> T getClassInstanceProperty(String name,
String defaultClass,
Class<T> type,
Class<?>[] paramTypes,
Object... args)
T - the type of the return valuename - the property namedefaultClass - the fully qualified class name to use if the
name property is not foundtype - the class which the return value should be an instance ofparamTypes - the constructor parameter typesargs - the arguments to pass to the constructor
null if the property is not
found and defaultClassName is null
IllegalArgumentException - if a problem occurs creating the
instance, or if the constructor throws a checked exception
public <T extends Enum<T>> T getEnumProperty(String name,
Class<T> enumType,
T defaultValue)
Enum property.
T - the enumeration typename - the property nameenumType - the enumeration typedefaultValue - the default value
IllegalArgumentException - if the value does not name a constant
of the enumeration type
public <T> List<T> getListProperty(String name,
Class<T> type,
T defaultElement)
type. The
objects are created from the property with the given name from
the backing set of properties. The property is assumed to be a colon
separated list of Strings, and each element in the list is
instantiated by calling the given type's Constructor with a
single String parameter.
If any of the Strings in the colon separated list is an empty
string,
the value of defaultElement will be used for that item in the
returned List. If the property with the given name is
not found, an empty list will be returned.
T - the type of the objects in the returned Listname - the property nametype - the class which each object in the returned List
should be an instance ofdefaultElement - the default value to use if an empty String
is one of the items in the list
IllegalArgumentException - if a problem occurs creating an instance
of the given class type, or the class type does not have a
constructor that takes a single String parameter
public <T extends Enum<T>> List<T> getEnumListProperty(String name,
Class<T> enumType,
T defaultElement)
Enums of the type specified by
enumType. The
objects are created from the property with the given name from
the backing set of properties. The property is assumed to be a colon
separated list of Strings, and each element in the list is
instantiated by calling the
Enum.valueOf
method on each respective String in the list.
If any of the Strings in the colon separated list is an empty
string,
the value of defaultElement will be used for that item in the
returned List. If the property with the given name is
not found, an empty list will be returned.
T - the Enum type of the objects in the returned
Listname - the property nameenumType - the Enum class which each object in the returned
List should be an instance ofdefaultElement - the default value to use if an empty String
is one of the items in the list
Enum objects of the given type represented by
the property with the given name
IllegalArgumentException - if any of the items in the list is
not a valid value for the given Enum typepublic List<Class<?>> getClassListProperty(String name)
List of Class typed objects. The objects
in the list are created from the property with the given name
from the backing set of properties. The property is assumed to be a
colon separated list of Strings, where each String is a fully qualified
class name of a class. Any empty String appearing in the list
will be added to the returned list as a null. If the property
with the given name is not found, an empty list will be returned.
name - the name of the property
Class objects represented by the property with
the given name
IllegalArgumentException - if a Class cannot be found for
any of the items in the list
|
Project Darkstar, Version 0.9.11.2 2013-07-29 21:50:09 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||