org.umber.catalan.process.properties
Class BaseWorkProperties

java.lang.Object
  extended byorg.umber.catalan.process.properties.BaseWorkProperties
All Implemented Interfaces:
IWorkProperties
Direct Known Subclasses:
ChainedProperties, EmptyProperties, MapProperties, XmlProperties

public abstract class BaseWorkProperties
extends java.lang.Object
implements IWorkProperties

Base class helper for IWorkProperties implementations.

Author:
jsheets

Constructor Summary
BaseWorkProperties()
           
 
Method Summary
 java.util.Map asMap()
          Adapts this property set into a Map instance.
static java.util.Map asMap(IWorkProperties props)
          Adapts a property set into a Map instance.
 boolean getPropertyAsBoolean(java.lang.String name, boolean defaultValue)
          Retrieves the named property as a boolean; if the property exists but cannot be converted into a boolean, returns the default.
 Datum getPropertyAsDatum(java.lang.String name, Datum defaultValue)
          Retrieves the named property as a Datum; if the property cannot be converted into a Datum, returns the default.
 java.util.Map getPropertyAsMap(java.lang.String name, java.util.Map defaultValue)
          Retrieves the named property as a Map; if the property cannot be converted into a Map, returns the default.
 java.lang.Number getPropertyAsNumber(java.lang.String name, java.lang.Number defaultValue)
          Retrieves the named property as an Number; if the property exists but cannot be converted into an Number, returns the default.
 java.lang.String getPropertyAsString(java.lang.String name, java.lang.String defaultValue)
          Retrieves the named property as a String; if the property is not already a String, calls toString() on it before returning it.
 java.lang.String toString()
          Converts object to String form.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.umber.catalan.process.properties.IWorkProperties
getProperty, getPropertyNames
 

Constructor Detail

BaseWorkProperties

public BaseWorkProperties()
Method Detail

getPropertyAsString

public java.lang.String getPropertyAsString(java.lang.String name,
                                            java.lang.String defaultValue)
Retrieves the named property as a String; if the property is not already a String, calls toString() on it before returning it.

Specified by:
getPropertyAsString in interface IWorkProperties
Parameters:
name - the name of the property
defaultValue - value to return if property not found
Returns:
the String value of the property, or default if property not set

getPropertyAsNumber

public java.lang.Number getPropertyAsNumber(java.lang.String name,
                                            java.lang.Number defaultValue)
Retrieves the named property as an Number; if the property exists but cannot be converted into an Number, returns the default. The returned value can be any implementation of Number; which subclass it returns is up to the implementation of IWorkProperties.

This implementation always converts String values into Double objects for better flexibility.

Specified by:
getPropertyAsNumber in interface IWorkProperties
Parameters:
name - the name of the property
defaultValue - value to return if property not found
Returns:
the Number value of the property, or default if property not set or cannot be coerced into a Number

getPropertyAsBoolean

public boolean getPropertyAsBoolean(java.lang.String name,
                                    boolean defaultValue)
Retrieves the named property as a boolean; if the property exists but cannot be converted into a boolean, returns the default. The property value can be a Boolean object, or an arbitrary Object whose toString() method resolves to "true" or "yes" for true, or to "false" or "no" for false.

Specified by:
getPropertyAsBoolean in interface IWorkProperties
Parameters:
name - the name of the property
defaultValue - value to return if property not found
Returns:
the Boolean value of the property, or default if property not set or cannot be coerced into a Boolean

getPropertyAsMap

public java.util.Map getPropertyAsMap(java.lang.String name,
                                      java.util.Map defaultValue)
Retrieves the named property as a Map; if the property cannot be converted into a Map, returns the default.

Specified by:
getPropertyAsMap in interface IWorkProperties
Parameters:
name - the name of the property
defaultValue - value to return if property not found
Returns:
the Map value of the property, or default if property not set or cannot be coerced into a Map

getPropertyAsDatum

public Datum getPropertyAsDatum(java.lang.String name,
                                Datum defaultValue)
Retrieves the named property as a Datum; if the property cannot be converted into a Datum, returns the default.

Specified by:
getPropertyAsDatum in interface IWorkProperties
Parameters:
name - the name of the property
defaultValue - value to return if property not found
Returns:
the Datum value of the property, or default if property not set or cannot be coerced into a Datum

asMap

public java.util.Map asMap()
Adapts this property set into a Map instance.

Returns:
property set in Map form

asMap

public static java.util.Map asMap(IWorkProperties props)
Adapts a property set into a Map instance.

Parameters:
props - property set
Returns:
property set in Map form

toString

public java.lang.String toString()
Converts object to String form.

Returns:
object as String