com.planetalia.dynject.injection
Class DataStep

java.lang.Object
  extended by com.planetalia.dynject.injection.DataStep

public class DataStep
extends java.lang.Object

Represents a single processing step in the datapath. Each data step corresponds to one specific annotation, although that annotation might not have been specified in the annotated element (for example, class annotations are applied to all members)

Author:
Alexander Hristov

Field Summary
protected  java.lang.annotation.Annotation annotation
          Reference to the original annotation
protected  Configuration config
          Configuration of the annotation
protected  IDataHandler handler
          Data handler to use.
protected  ClassPreferences inputClasses
          List of compatible input classes for this data step
 
Constructor Summary
DataStep()
          Creates an empty data step
DataStep(java.lang.annotation.Annotation annotation)
          Parses an annotation and creates a DataStep for it.
DataStep(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType, Configuration cfg)
           
 
Method Summary
static java.lang.Object coerceToType(Configuration config, Environment runtimeEnvironment, ErrorMap errors, java.lang.String name, java.lang.Object instance, java.lang.Object sourceValue, ClassPreferences requiredClasses)
          Forces a data value to be of the specified type, generating an error if it is not no compatbile conversion can be found
 java.lang.Object execute(Environment runtimeEnvironment, ErrorMap errors, java.lang.String name, java.lang.Object instance, java.lang.Object sourceValue, ClassPreferences preferredOutputClasses)
          Executes (applies) the data step
 java.lang.annotation.Annotation getAnnotation()
          Returns the annotation to which this data step belongs
 Configuration getConfig()
          Returns the annotation configuration
 IDataHandler getHandler()
          Retrieves the data handler associated with this step
 ClassPreferences getInputClasses()
          Returns the input class preferences
 void setAnnotation(java.lang.annotation.Annotation annotation)
          Sets the annotation to which this data step belongs
 void setConfig(Configuration config)
          Sets the annotation configuration
 void setHandler(IDataHandler handler)
          Sets the data handler associated with this step
 void setInputClasses(ClassPreferences inputClasses)
          Sets the input class preferences
 void setInputClassesFrom(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
          Sets the list of input classes of this data step to match those of a specific annotation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

annotation

protected java.lang.annotation.Annotation annotation
Reference to the original annotation


inputClasses

protected ClassPreferences inputClasses
List of compatible input classes for this data step


config

protected Configuration config
Configuration of the annotation


handler

protected IDataHandler handler
Data handler to use. The value is extracted from the annotation, or it can be set directly.

Constructor Detail

DataStep

public DataStep()
Creates an empty data step


DataStep

public DataStep(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType,
                Configuration cfg)

DataStep

public DataStep(java.lang.annotation.Annotation annotation)
Parses an annotation and creates a DataStep for it. A DataStep holds the same information as the original annotation, but in a format more convenient and faster for processing

Parameters:
annotation - Annotation to read
Method Detail

coerceToType

public static java.lang.Object coerceToType(Configuration config,
                                            Environment runtimeEnvironment,
                                            ErrorMap errors,
                                            java.lang.String name,
                                            java.lang.Object instance,
                                            java.lang.Object sourceValue,
                                            ClassPreferences requiredClasses)
Forces a data value to be of the specified type, generating an error if it is not no compatbile conversion can be found

Parameters:
config - Configuration
errors - Map of errors where to store any processing/validation errors
name - Name of the property being processed
instance - Instance holding the property
runtimeEnvironment - Runtime environment of the annotation
sourceValue - Value to feed to the data step
requiredClasses - Specifies the list of preferred classes that the value must be covnerted to
Returns:
Processed value. Guaranteed to be of at least one of the types specified in the requiredClasses parameter

execute

public java.lang.Object execute(Environment runtimeEnvironment,
                                ErrorMap errors,
                                java.lang.String name,
                                java.lang.Object instance,
                                java.lang.Object sourceValue,
                                ClassPreferences preferredOutputClasses)
Executes (applies) the data step

Parameters:
errors - Map of errors where to store any processing/validation errors
name - Name of the property being processed
instance - Instance holding the property
runtimeEnvironment - Runtime environment of the annotation
sourceValue - Value to feed to the data step
preferredOutputClasses - Specifies the list of preferred classes that the next step would like to use. This preference MAY or MAY NOT be followed.
Returns:
Processed value.

getAnnotation

public java.lang.annotation.Annotation getAnnotation()
Returns the annotation to which this data step belongs

Returns:
annotation to which this data step belongs

setAnnotation

public void setAnnotation(java.lang.annotation.Annotation annotation)
Sets the annotation to which this data step belongs

Parameters:
annotation - annotation to which this data step belongs

getConfig

public Configuration getConfig()
Returns the annotation configuration

Returns:
Annotation Configuration

setConfig

public void setConfig(Configuration config)
Sets the annotation configuration

Parameters:
config - Annotation Configuration

getInputClasses

public ClassPreferences getInputClasses()
Returns the input class preferences

Returns:
input class preferences

setInputClasses

public void setInputClasses(ClassPreferences inputClasses)
Sets the input class preferences

Parameters:
inputClasses - input class preferences

getHandler

public IDataHandler getHandler()
Retrieves the data handler associated with this step

Returns:
Data handler to use

setHandler

public void setHandler(IDataHandler handler)
Sets the data handler associated with this step

Parameters:
handler - Data handler associated with this step

setInputClassesFrom

public void setInputClassesFrom(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Sets the list of input classes of this data step to match those of a specific annotation

Parameters:
annotationType - Annotation type