com.planetalia.dynject.injection
Class DataHandlerSupport

java.lang.Object
  extended by com.planetalia.dynject.injection.DataHandlerSupport
All Implemented Interfaces:
IDataHandler
Direct Known Subclasses:
EuropeanVATImpl, FileSpecImpl, ISBNImpl, IsBooleanImpl, IsDateImpl, IsNumericImpl, IsURLImpl, LengthImpl, MaxDigitsImpl, MaxExclusiveImpl, MaxFractionDigitsImpl, MaxInclusiveImpl, MinDigitsImpl, MinExclusiveImpl, MinInclusiveImpl, NormalizedImpl, PatternImpl, RequiredImpl, ValueConstraintImpl

public abstract class DataHandlerSupport
extends java.lang.Object
implements IDataHandler

Provides a convenience ancestor for IDataHandler implementations

Author:
Alexander Hristov

Constructor Summary
DataHandlerSupport()
           
 
Method Summary
protected  void addError(Configuration cfg, java.lang.String name, ErrorMap errors, java.lang.Object instance, java.lang.Object data, java.lang.Class<? extends java.lang.annotation.Annotation> triggeringAnnotation, java.lang.Object... params)
          Adds an error to the map of errors, automatically retrieving the message and message key from the configuration.
protected  boolean find(java.lang.String[] array, java.lang.Object data)
          Locates a piece of data within a string array.
protected  boolean findIgnoreCase(java.lang.String[] array, java.lang.Object data)
          Locates a piece of data within a string array, ignoring capitalization.
static java.util.List<java.lang.String> getEnumValues(java.lang.Class clazz)
          Returns a list containing the names of all the members of an enumeration
protected  java.lang.Object nullAs(java.lang.Class clazz)
          Represents the null value as some non-null, presumably "neutral" value of the specified class> If the class is CharSequence (i.e.
protected  java.lang.Object valueAs(java.lang.String value, java.lang.Class clazz)
          Tries to represent a string as a value of a specific class or a class compatible with it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.planetalia.dynject.injection.IDataHandler
process
 

Constructor Detail

DataHandlerSupport

public DataHandlerSupport()
Method Detail

addError

protected void addError(Configuration cfg,
                        java.lang.String name,
                        ErrorMap errors,
                        java.lang.Object instance,
                        java.lang.Object data,
                        java.lang.Class<? extends java.lang.annotation.Annotation> triggeringAnnotation,
                        java.lang.Object... params)
Adds an error to the map of errors, automatically retrieving the message and message key from the configuration.

Parameters:
cfg - Current configuration
name - Property name to which the error is linked
errors - Error map to which the error is added
instance - Instance holding the property
data - Data that caused the error
triggeringAnnotation - Annotation type that triggered the error
params - Message parameters to add.

nullAs

protected java.lang.Object nullAs(java.lang.Class clazz)
Represents the null value as some non-null, presumably "neutral" value of the specified class>

Parameters:
clazz - Target class
Returns:
Transformed value, or null if no transformation was not successful

valueAs

protected java.lang.Object valueAs(java.lang.String value,
                                   java.lang.Class clazz)
Tries to represent a string as a value of a specific class or a class compatible with it. If it fails, returns the original string

Parameters:
value - Value to convert. Cannot be null. If you need to convert the null value to a target nonnull value, use nullAs(Class) instead
clazz - Target class
Returns:
Converted value, if possible

find

protected boolean find(java.lang.String[] array,
                       java.lang.Object data)
Locates a piece of data within a string array. Performs a linear search

Parameters:
array - Array where to perform the search
data - Value to search
Returns:
True if found, false if not.

findIgnoreCase

protected boolean findIgnoreCase(java.lang.String[] array,
                                 java.lang.Object data)
Locates a piece of data within a string array, ignoring capitalization. Performs a linear search

Parameters:
array - Array where to perform the search
data - Value to search
Returns:
True if found, false if not.

getEnumValues

public static java.util.List<java.lang.String> getEnumValues(java.lang.Class clazz)
Returns a list containing the names of all the members of an enumeration

Parameters:
clazz - Enumeration class to check
Returns:
List of member values