com.planetalia.dynject.sources
Class ObjectSource

java.lang.Object
  extended by com.planetalia.dynject.sources.ObjectSource
All Implemented Interfaces:
IValueSource<java.lang.Object>

public class ObjectSource
extends java.lang.Object
implements IValueSource<java.lang.Object>

Retrieves property values from an object instance.

Author:
Alexander Hristov

Constructor Summary
ObjectSource(java.lang.Object instance)
          Creates an ObjectSource using the specified object as the underlying property holder
ObjectSource(java.lang.Object instance, PropertySelectionPolicy propertySelectionPolicy)
          Creates an ObjectSource using the specified object as the underlying property holder and with a specific access policy
 
Method Summary
 ClassPreferences getPropertyClass(java.lang.String propertyName)
          Returns the class preferences for a property
 java.util.Set<java.lang.String> getPropertyNames()
          Returns the set of all existing properties at the time of invocation.
 PropertySelectionPolicy getPropertySelectionPolicy()
           
 java.lang.Object getValue(java.lang.String propertyName)
          Provides the value of a specific property
 boolean propertyExists(java.lang.String propertyName)
          Checks whether a specific property exists.
 void setPropertySelectionPolicy(PropertySelectionPolicy propertySelectionPolicy)
           
 void setValue(java.lang.String propertyName, java.lang.Object value)
          Sets the value of a specific property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectSource

public ObjectSource(java.lang.Object instance)
Creates an ObjectSource using the specified object as the underlying property holder

Parameters:
instance - Object to use for extracting property values

ObjectSource

public ObjectSource(java.lang.Object instance,
                    PropertySelectionPolicy propertySelectionPolicy)
Creates an ObjectSource using the specified object as the underlying property holder and with a specific access policy

Parameters:
instance - Object to use for extracting property values
propertySelectionPolicy - selectionPolicy for reading properties
Method Detail

getPropertySelectionPolicy

public PropertySelectionPolicy getPropertySelectionPolicy()

setPropertySelectionPolicy

public void setPropertySelectionPolicy(PropertySelectionPolicy propertySelectionPolicy)

getValue

public java.lang.Object getValue(java.lang.String propertyName)
Description copied from interface: IValueSource
Provides the value of a specific property

Specified by:
getValue in interface IValueSource<java.lang.Object>
Parameters:
propertyName - Name of the requested property. Assumed to exist.
Returns:
Property value

propertyExists

public boolean propertyExists(java.lang.String propertyName)
Description copied from interface: IValueSource
Checks whether a specific property exists. Not that a nonexistant property and a proprerty with a null value are not the same situation

Specified by:
propertyExists in interface IValueSource<java.lang.Object>
Parameters:
propertyName - Name of the requested property
Returns:
True if the property exists, false otherwise

getPropertyClass

public ClassPreferences getPropertyClass(java.lang.String propertyName)
Description copied from interface: IValueSource
Returns the class preferences for a property

Specified by:
getPropertyClass in interface IValueSource<java.lang.Object>
Parameters:
propertyName - Name of the property
Returns:
List of class preferences for that property

getPropertyNames

public java.util.Set<java.lang.String> getPropertyNames()
Description copied from interface: IValueSource
Returns the set of all existing properties at the time of invocation.

Specified by:
getPropertyNames in interface IValueSource<java.lang.Object>
Returns:
Set of property names

setValue

public void setValue(java.lang.String propertyName,
                     java.lang.Object value)
Description copied from interface: IValueSource
Sets the value of a specific property. It's the callers responsability to provide a correct data type for that property. This is an optional operation. Some sources do not support writing properties to them

Specified by:
setValue in interface IValueSource<java.lang.Object>
Parameters:
propertyName - Name of the requested property.
value - Property value.