cz.cuni.jagrlib
Class DefaultProperty

java.lang.Object
  extended by cz.cuni.jagrlib.DefaultProperty
All Implemented Interfaces:
Property
Direct Known Subclasses:
DefaultBrepIterator, Piece

public abstract class DefaultProperty
extends java.lang.Object
implements Property

Default implementation of Property interface. Implements several handy helper functions.

Since:
0.24
See Also:
DefaultProperty.java

Field Summary
 
Fields inherited from interface cz.cuni.jagrlib.iface.Property
LOGGING, STATISTICS, TEXT_DESCRIPTION
 
Constructor Summary
DefaultProperty()
           
 
Method Summary
static boolean booleanProperty(java.lang.Object value, boolean def)
          Retrieves boolean property from general object instance.
static boolean booleanProperty(Property object, java.lang.String name, boolean def)
          Reads boolean parameter (property) from the given instance.
static double[] colorDoubleProperty(java.lang.Object value, double[] def)
          Retrieves double[] property from general object instance.
static java.awt.Color colorProperty(java.lang.Object value, java.awt.Color def)
          Retrieves Color property from general object instance.
 void commit()
          Commits all previous changes to the internal object state.
static double doubleProperty(java.lang.Object value, double def)
          Retrieves double property from general object instance.
static double doubleProperty(java.lang.Object value, double def, double minVal, double maxVal)
          Retrieves double property from general object instance, does check value bounds.
static double doubleProperty(Property object, java.lang.String name, double def)
          Reads double parameter (property) from the given instance.
static
<T extends java.lang.Enum<T>>
T
enumProperty(java.lang.Object value, T def)
          Retrieves enum property from general object instance.
static float floatProperty(java.lang.Object value, float def)
          Retrieves float property from general object instance.
static float floatProperty(java.lang.Object value, float def, float minVal, float maxVal)
          Retrieves float property from general object instance, does check value bounds.
static float floatProperty(Property object, java.lang.String name, float def)
          Reads float parameter (property) from the given instance.
 java.lang.Object get(java.lang.String key)
          Gets the given property.
static int intProperty(java.lang.Object value, int def)
          Retrieves integer property from general object instance.
static int intProperty(java.lang.Object value, int def, int minVal, int maxVal)
          Retrieves integer property from general object instance, does check value bounds.
static int intProperty(Property object, java.lang.String name, int def)
          Reads integer parameter (property) from the given instance.
static long longProperty(java.lang.Object value, long def)
          Retrieves long property from general object instance.
static long longProperty(java.lang.Object value, long def, long minVal, long maxVal)
          Retrieves long property from general object instance, does check value bounds.
static long longProperty(Property object, java.lang.String name, long def)
          Reads long parameter (property) from the given instance.
 void set(java.util.Map<java.lang.String,java.lang.Object> pairs)
          Sets all properties from the given map.
 void set(java.lang.String key, java.lang.Object value)
          Sets the given property.
static java.lang.String stringProperty(java.lang.Object value, java.lang.String def)
          Retrieves string property from general object instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultProperty

public DefaultProperty()
Method Detail

set

public void set(java.lang.String key,
                java.lang.Object value)
Sets the given property.

Specified by:
set in interface Property
Parameters:
key - Key string.
value - The new value.
See Also:
Property.commit()

get

public java.lang.Object get(java.lang.String key)
Gets the given property.

Specified by:
get in interface Property
Parameters:
key - Key string.
Returns:
The actual value or null.

commit

public void commit()
Commits all previous changes to the internal object state. Non-mandatory.

Specified by:
commit in interface Property

set

public void set(java.util.Map<java.lang.String,java.lang.Object> pairs)
Sets all properties from the given map.

Parameters:
pairs - Dictionary of [key,value] pairs.

intProperty

public static int intProperty(java.lang.Object value,
                              int def)
Retrieves integer property from general object instance.

Parameters:
value - Object instance containing the value.
def - Default property value.
Returns:
New value of the property.

longProperty

public static long longProperty(java.lang.Object value,
                                long def)
Retrieves long property from general object instance.

Parameters:
value - Object instance containing the value.
def - Default property value.
Returns:
New value of the property.

enumProperty

public static <T extends java.lang.Enum<T>> T enumProperty(java.lang.Object value,
                                                           T def)
Retrieves enum property from general object instance.

Parameters:
value - Object instance containing the value.
def - Default property value.
Returns:
New value of the property.

stringProperty

public static java.lang.String stringProperty(java.lang.Object value,
                                              java.lang.String def)
Retrieves string property from general object instance.

Parameters:
value - Object instance containing the value.
def - Default property value.
Returns:
New value of the property.

intProperty

public static int intProperty(java.lang.Object value,
                              int def,
                              int minVal,
                              int maxVal)
Retrieves integer property from general object instance, does check value bounds.

Parameters:
value - Object instance containing the value.
def - Default property value.
minVal - Minimal allowed value.
maxVal - Maximal allowed value.
Returns:
New value of the property.

longProperty

public static long longProperty(java.lang.Object value,
                                long def,
                                long minVal,
                                long maxVal)
Retrieves long property from general object instance, does check value bounds.

Parameters:
value - Object instance containing the value.
def - Default property value.
minVal - Minimal allowed value.
maxVal - Maximal allowed value.
Returns:
New value of the property.

doubleProperty

public static double doubleProperty(java.lang.Object value,
                                    double def)
Retrieves double property from general object instance.

Parameters:
value - Object instance containing the value.
def - Default property value.
Returns:
New value of the property.

doubleProperty

public static double doubleProperty(java.lang.Object value,
                                    double def,
                                    double minVal,
                                    double maxVal)
Retrieves double property from general object instance, does check value bounds.

Parameters:
value - Object instance containing the value.
def - Default property value.
minVal - Minimal allowed value.
maxVal - Maximal allowed value.
Returns:
New value of the property.

floatProperty

public static float floatProperty(java.lang.Object value,
                                  float def)
Retrieves float property from general object instance.

Parameters:
value - Object instance containing the value.
def - Default property value.
Returns:
New value of the property.

floatProperty

public static float floatProperty(java.lang.Object value,
                                  float def,
                                  float minVal,
                                  float maxVal)
Retrieves float property from general object instance, does check value bounds.

Parameters:
value - Object instance containing the value.
def - Default property value.
minVal - Minimal allowed value.
maxVal - Maximal allowed value.
Returns:
New value of the property.

booleanProperty

public static boolean booleanProperty(java.lang.Object value,
                                      boolean def)
Retrieves boolean property from general object instance.

Parameters:
value - Object instance containing the value.
def - Default property value.
Returns:
New value of the property.

colorProperty

public static java.awt.Color colorProperty(java.lang.Object value,
                                           java.awt.Color def)
Retrieves Color property from general object instance.

Parameters:
value - Object instance containing the value.
def - Default property value.
Returns:
New value of the property.

colorDoubleProperty

public static double[] colorDoubleProperty(java.lang.Object value,
                                           double[] def)
Retrieves double[] property from general object instance.

Parameters:
value - Object instance containing the value.
def - Default property value.
Returns:
New value of the property.

intProperty

public static int intProperty(Property object,
                              java.lang.String name,
                              int def)
Reads integer parameter (property) from the given instance.

Parameters:
object - Object instance to be asked.
name - Property identifier.
def - Default property value.

longProperty

public static long longProperty(Property object,
                                java.lang.String name,
                                long def)
Reads long parameter (property) from the given instance.

Parameters:
object - Object instance to be asked.
name - Property identifier.
def - Default property value.

doubleProperty

public static double doubleProperty(Property object,
                                    java.lang.String name,
                                    double def)
Reads double parameter (property) from the given instance.

Parameters:
object - Object instance to be asked.
name - Property identifier.
def - Default property value.

floatProperty

public static float floatProperty(Property object,
                                  java.lang.String name,
                                  float def)
Reads float parameter (property) from the given instance.

Parameters:
object - Object instance to be asked.
name - Property identifier.
def - Default property value.

booleanProperty

public static boolean booleanProperty(Property object,
                                      java.lang.String name,
                                      boolean def)
Reads boolean parameter (property) from the given instance.

Parameters:
object - Object instance to be asked.
name - Property identifier.
def - Default property value.