|
MOEA Framework 2.12 API Specification |
|||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.moeaframework.util.TypedProperties
public class TypedProperties
Wrapper for Properties
providing getters for reading specific
primitive types. For primitive arrays, either the default "," separator or a
custom separator is used for splitting the string into individual components;
the formatting of this separator is defined in String.split(java.lang.String, int)
. In
addition, whitespace surrounding each array entry is trimmed.
Field Summary | |
---|---|
static String |
DEFAULT_SEPARATOR
The default separator for arrays. |
Constructor Summary | |
---|---|
TypedProperties()
Decorates an empty Properties object to provide type-safe access
using the default "," separator for arrays. |
|
TypedProperties(Properties properties)
Decorates a Properties object to provide type-safe access using
the default "," separator for arrays. |
|
TypedProperties(Properties properties,
String separator)
Decorates a Properties object using the specified separator for
arrays. |
Method Summary | |
---|---|
void |
addAll(Properties properties)
Adds all properties from the specified properties object. |
void |
addAll(TypedProperties properties)
Adds all properties from the specified properties object. |
void |
clear()
Clears all properties. |
boolean |
contains(String key)
Returns true if the specified key is contained in this
properties object; false otherwise. |
boolean |
getBoolean(String key,
boolean defaultValue)
Returns the value of the property with the specified name as a boolean ; or defaultValue if no property with the
specified name exists. |
byte |
getByte(String key,
byte defaultValue)
Returns the value of the property with the specified name as a byte ; or defaultValue if no property with the specified
name exists. |
byte[] |
getByteArray(String key,
byte[] defaultValues)
Returns the value of the property with the specified name as a byte array; or defaultValues if no property with the
specified name exists. |
double |
getDouble(String key,
double defaultValue)
Returns the value of the property with the specified name as a double ; or defaultValue if no property with the specified
name exists. |
double[] |
getDoubleArray(String key,
double[] defaultValues)
Returns the value of the property with the specified name as a double array; or defaultValues if no property with the
specified name exists. |
float |
getFloat(String key,
float defaultValue)
Returns the value of the property with the specified name as a float ; or defaultValue if no property with the specified
name exists. |
float[] |
getFloatArray(String key,
float[] defaultValues)
Returns the value of the property with the specified name as a float array; or defaultValues if no property with the
specified name exists. |
int |
getInt(String key,
int defaultValue)
Returns the value of the property with the specified name as an int ; or defaultValue if no property with the specified
name exists. |
int[] |
getIntArray(String key,
int[] defaultValues)
Returns the value of the property with the specified name as an int array; or defaultValues if no property with the
specified name exists. |
long |
getLong(String key,
long defaultValue)
Returns the value of the property with the specified name as a long ; or defaultValue if no property with the specified
name exists. |
long[] |
getLongArray(String key,
long[] defaultValues)
Returns the value of the property with the specified name as a long array; or defaultValues if no property with the
specified name exists. |
Properties |
getProperties()
Returns the internal Properties object storing the actual
key/value pairs. |
short |
getShort(String key,
short defaultValue)
Returns the value of the property with the specified name as a short ; or defaultValue if no property with the specified
name exists. |
short[] |
getShortArray(String key,
short[] defaultValues)
Returns the value of the property with the specified name as a short array; or defaultValues if no property with the
specified name exists. |
String |
getString(String key,
String defaultValue)
Returns the value of the property with the specified name as a string; or defaultValue if no property with the specified name exists. |
String[] |
getStringArray(String key,
String[] defaultValues)
Returns the value of the property with the specified name as a String array; or defaultValues if no property with the
specified name exists. |
void |
remove(String key)
Removes the property with the specified name. |
void |
setBoolean(String key,
boolean value)
Sets the value of the property with the specified name as a boolean . |
void |
setByte(String key,
byte value)
Sets the value of the property with the specified name as a byte . |
void |
setByteArray(String key,
byte[] values)
Sets the value of the property with the specified name as a byte array. |
void |
setDouble(String key,
double value)
Sets the value of the property with the specified name as a double . |
void |
setDoubleArray(String key,
double[] values)
Sets the value of the property with the specified name as a double array. |
void |
setFloat(String key,
float value)
Sets the value of the property with the specified name as a float . |
void |
setFloatArray(String key,
float[] values)
Sets the value of the property with the specified name as a float array. |
void |
setInt(String key,
int value)
Sets the value of the property with the specified name as an int . |
void |
setIntArray(String key,
int[] values)
Sets the value of the property with the specified name as a int array. |
void |
setLong(String key,
long value)
Sets the value of the property with the specified name as a long . |
void |
setLongArray(String key,
long[] values)
Sets the value of the property with the specified name as a long array. |
void |
setShort(String key,
short value)
Sets the value of the property with the specified name as a short . |
void |
setShortArray(String key,
short[] values)
Sets the value of the property with the specified name as a short array. |
void |
setString(String key,
String value)
Sets the value of the property with the specified name as a String . |
void |
setStringArray(String key,
String[] values)
Sets the value of the property with the specified name as a String array. |
static TypedProperties |
withProperty(String key,
String value)
Convenience method to quickly construct a typed properties instance with a single key-value pair. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DEFAULT_SEPARATOR
Constructor Detail |
---|
public TypedProperties()
Properties
object to provide type-safe access
using the default "," separator for arrays.
public TypedProperties(Properties properties)
Properties
object to provide type-safe access using
the default "," separator for arrays.
properties
- the existing Properties
objectpublic TypedProperties(Properties properties, String separator)
Properties
object using the specified separator for
arrays.
properties
- the existing Properties
objectseparator
- the separator for arraysMethod Detail |
---|
public static TypedProperties withProperty(String key, String value)
TypedProperties.withProperty("epsilon",
commandLine.getOptionValue("epsilon")).getDoubleArray("epsilon", null);
key
- the keyvalue
- the value assigned to the key
public boolean contains(String key)
true
if the specified key is contained in this
properties object; false
otherwise.
key
- the property name
true
if the specified key is contained in this
properties object; false
otherwisepublic Properties getProperties()
Properties
object storing the actual
key/value pairs.
Properties
object storing the actual
key/value pairspublic String getString(String key, String defaultValue)
defaultValue
if no property with the specified name exists.
key
- the property namedefaultValue
- the default value
defaultValue
if no property with the specified name
existspublic double getDouble(String key, double defaultValue)
double
; or defaultValue
if no property with the specified
name exists.
key
- the property namedefaultValue
- the default value
double
; or defaultValue
if no property with the
specified name exists
NumberFormatException
- if the property value is not a parseable
double
public float getFloat(String key, float defaultValue)
float
; or defaultValue
if no property with the specified
name exists.
key
- the property namedefaultValue
- the default value
float
; or defaultValue
if no property with the
specified name exists
NumberFormatException
- if the property value is not a parseable
float
public long getLong(String key, long defaultValue)
long
; or defaultValue
if no property with the specified
name exists.
key
- the property namedefaultValue
- the default value
long
; or defaultValue
if no property with the
specified name exists
NumberFormatException
- if the property value is not a parseable
long
public int getInt(String key, int defaultValue)
int
; or defaultValue
if no property with the specified
name exists.
key
- the property namedefaultValue
- the default value
int
; or defaultValue
if no property with the
specified name exists
NumberFormatException
- if the property value is not a parseable
integerpublic short getShort(String key, short defaultValue)
short
; or defaultValue
if no property with the specified
name exists.
key
- the property namedefaultValue
- the default value
short
; or defaultValue
if no property with the
specified name exists
NumberFormatException
- if the property value is not a parseable
short
public byte getByte(String key, byte defaultValue)
byte
; or defaultValue
if no property with the specified
name exists.
key
- the property namedefaultValue
- the default value
byte
; or defaultValue
if no property with the
specified name exists
NumberFormatException
- if the property value is not a parseable
byte
public boolean getBoolean(String key, boolean defaultValue)
boolean
; or defaultValue
if no property with the
specified name exists.
key
- the property namedefaultValue
- the default value
boolean
; or defaultValue
if no property with the
specified name existspublic String[] getStringArray(String key, String[] defaultValues)
String
array; or defaultValues
if no property with the
specified name exists.
key
- the property namedefaultValues
- the default values
String
array; or defaultValues
if no property
with the specified name existspublic double[] getDoubleArray(String key, double[] defaultValues)
double
array; or defaultValues
if no property with the
specified name exists.
key
- the property namedefaultValues
- the default values
double
array; or defaultValues
if no property
with the specified name existspublic float[] getFloatArray(String key, float[] defaultValues)
float
array; or defaultValues
if no property with the
specified name exists.
key
- the property namedefaultValues
- the default values
float
array; or defaultValues
if no property with
the specified name existspublic long[] getLongArray(String key, long[] defaultValues)
long
array; or defaultValues
if no property with the
specified name exists.
key
- the property namedefaultValues
- the default values
long
array; or defaultValues
if no property with
the specified name existspublic int[] getIntArray(String key, int[] defaultValues)
int
array; or defaultValues
if no property with the
specified name exists.
key
- the property namedefaultValues
- the default values
int
array; or defaultValues
if no property with
the specified name existspublic short[] getShortArray(String key, short[] defaultValues)
short
array; or defaultValues
if no property with the
specified name exists.
key
- the property namedefaultValues
- the default values
short
array; or defaultValues
if no property with
the specified name existspublic byte[] getByteArray(String key, byte[] defaultValues)
byte
array; or defaultValues
if no property with the
specified name exists.
key
- the property namedefaultValues
- the default values
byte
array; or defaultValues
if no property with
the specified name existspublic void setString(String key, String value)
String
.
key
- the property namevalue
- the property valuepublic void setFloat(String key, float value)
float
.
key
- the property namevalue
- the property valuepublic void setDouble(String key, double value)
double
.
key
- the property namevalue
- the property valuepublic void setByte(String key, byte value)
byte
.
key
- the property namevalue
- the property valuepublic void setShort(String key, short value)
short
.
key
- the property namevalue
- the property valuepublic void setInt(String key, int value)
int
.
key
- the property namevalue
- the property valuepublic void setLong(String key, long value)
long
.
key
- the property namevalue
- the property valuepublic void setBoolean(String key, boolean value)
boolean
.
key
- the property namevalue
- the property valuepublic void setStringArray(String key, String[] values)
String
array.
key
- the property namevalues
- the property valuepublic void setFloatArray(String key, float[] values)
float
array.
key
- the property namevalues
- the property valuepublic void setDoubleArray(String key, double[] values)
double
array.
key
- the property namevalues
- the property valuepublic void setByteArray(String key, byte[] values)
byte
array.
key
- the property namevalues
- the property valuepublic void setShortArray(String key, short[] values)
short
array.
key
- the property namevalues
- the property valuepublic void setIntArray(String key, int[] values)
int
array.
key
- the property namevalues
- the property valuepublic void setLongArray(String key, long[] values)
long
array.
key
- the property namevalues
- the property valuepublic void clear()
public void remove(String key)
key
- the property namepublic void addAll(Properties properties)
properties
- the propertiespublic void addAll(TypedProperties properties)
properties
- the properties
|
MOEA Framework 2.12 API Specification |
|||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |