com.softwareag.centrasite.appl.framework.validation.impl
Class ValidatableFactory

java.lang.Object
  extended by com.softwareag.centrasite.appl.framework.validation.impl.ValidatableFactory

public class ValidatableFactory
extends java.lang.Object

A factory for instances of Validatable. The factory inspects the methods of a data bean and creates instances of Validatable, that allow to configure the data bean.


Nested Class Summary
static class ValidatableFactory.Context
          The per-thread context of the IOC provider.
 
Constructor Summary
ValidatableFactory()
          Creates a new default factory.
ValidatableFactory(ValidationDefaults pDefaults)
           Creates a new factory with the given context.
 
Method Summary
protected  void createConstraints(ValidatableFactory.Context pContext, Validatable pValidatable)
          Creates constraints for the given validatable.
protected  void createValidatables(ValidatableFactory.Context pContext, java.util.List<Validatable> pList)
          Creates a collection of validatables.
protected  ConditionFactory getConditionFactory(ValidatableFactory.Context pContext)
          Returns the condition factory.
protected  ConstraintFactory getConstraintFactory(ValidatableFactory.Context pContext)
          Returns the constraint factory.
protected  ErrorCodeFactory getErrorCodeFactory(ValidatableFactory.Context pContext)
          Returns the error code factory.
protected  ScopeFactory getScopeFactory(ValidatableFactory.Context pContext)
          Returns the scope factory.
protected  Validatable getValidatable(ValidatableFactory.Context pContext, java.lang.reflect.Method pMethod)
          Checks, whether a Validatable is being created for the given method.
protected  ValidatableClasses.ValidatableClass getValidatableClass(java.lang.String pId, Validatable pAnnotation)
          Searches for a matching instance of ValidatableClasses.ValidatableClass.
protected  java.lang.String getValidatableName(Validatable pValidatable)
          Returns the validatables name.
 java.util.Collection<Validatable> getValidatables(ValidatableFactory.Context pContext, java.util.Collection<?> pBeans)
          This method is used to create validatables.
 java.util.Collection<Validatable> getValidatables(ValidatableFactory.Context pContext, java.lang.Object pBean)
          This method is used to create validatables.
protected  ValidationDefaults getValidationDefaults()
          Returns the factories validation defaults.
protected  void initialize(ValidatableFactory.Context pContext, java.lang.Object pObject)
          Initializes the given object.
protected  ConditionFactory newConditionFactory(ValidatableFactory.Context pContext, ValidationDefaults.ConditionFactory ConditionFactoryDefaults)
          Creates a new instance of ConditionFactory.
protected  ConstraintFactory newConstraintFactory(ValidatableFactory.Context pContext, ValidationDefaults.ConstraintFactory ConstraintFactoryDefaults)
          Creates a new instance of ConstraintFactory.
protected  ErrorCodeFactory newErrorCodeFactory(ValidatableFactory.Context pContext, ValidationDefaults.ErrorCodeFactory errorCodeFactoryDefaults)
          Creates a new instance of ErrorCodeFactory.
protected  ScopeFactory newScopeFactory(ValidatableFactory.Context pContext, ValidationDefaults.ScopeFactory ScopeFactoryDefaults)
          Creates a new instance of ScopeFactory.
protected  Validatable newValidatable(ValidatableClasses.ValidatableClass pClass, ValidatableFactory.Context pContext)
          Creates a new instance of Validatable.
protected  ValidatableProperty newValidatableProperty(ValidatableClasses.ValidatableClass pClass, ValidatableFactory.Context pContext)
          Creates a new instance of ValidatableProperty.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValidatableFactory

public ValidatableFactory()
                   throws com.softwareag.centrasite.appl.framework.CSAppFrameworkException

Creates a new default factory. For performance reasons, it is suggested to reuse the factory, which by default is a thread safe object.

Throws:
com.softwareag.centrasite.appl.framework.CSAppFrameworkException

ValidatableFactory

public ValidatableFactory(ValidationDefaults pDefaults)

Creates a new factory with the given context. For performance reasons, it is suggested to reuse the factory, which by default is a thread safe object. The ValidatableFactory.Context is used to provide thread specific data.

Parameters:
pDefaults - The validation defaults.
Method Detail

getValidatables

public java.util.Collection<Validatable> getValidatables(ValidatableFactory.Context pContext,
                                                         java.util.Collection<?> pBeans)
                                                  throws com.softwareag.centrasite.appl.framework.CSAppFrameworkException
This method is used to create validatables.

Parameters:
pContext - The context to use for initializing values.
pBeans - The data beans, which are being validated.
Throws:
com.softwareag.centrasite.appl.framework.CSAppFrameworkException

getValidatables

public java.util.Collection<Validatable> getValidatables(ValidatableFactory.Context pContext,
                                                         java.lang.Object pBean)
                                                  throws com.softwareag.centrasite.appl.framework.CSAppFrameworkException
This method is used to create validatables.

Parameters:
pContext - The context to use for initializing values.
pBean - The data bean, which is being validated.
Throws:
com.softwareag.centrasite.appl.framework.CSAppFrameworkException

getValidatableClass

protected ValidatableClasses.ValidatableClass getValidatableClass(java.lang.String pId,
                                                                  Validatable pAnnotation)
Searches for a matching instance of ValidatableClasses.ValidatableClass.


newValidatable

protected Validatable newValidatable(ValidatableClasses.ValidatableClass pClass,
                                     ValidatableFactory.Context pContext)
                              throws com.softwareag.centrasite.appl.framework.CSAppFrameworkException
Creates a new instance of Validatable.

Throws:
com.softwareag.centrasite.appl.framework.CSAppFrameworkException

newValidatableProperty

protected ValidatableProperty newValidatableProperty(ValidatableClasses.ValidatableClass pClass,
                                                     ValidatableFactory.Context pContext)
                                              throws com.softwareag.centrasite.appl.framework.CSAppFrameworkException
Creates a new instance of ValidatableProperty.

Throws:
com.softwareag.centrasite.appl.framework.CSAppFrameworkException

getValidatableName

protected java.lang.String getValidatableName(Validatable pValidatable)
Returns the validatables name.


createValidatables

protected void createValidatables(ValidatableFactory.Context pContext,
                                  java.util.List<Validatable> pList)
                           throws com.softwareag.centrasite.appl.framework.CSAppFrameworkException
Creates a collection of validatables.

Parameters:
pContext - The thread context. It contains, in particular, the data bean, for which to create the validatable collection.
pList - The list, to which the created validatables are being added.
Throws:
com.softwareag.centrasite.appl.framework.CSAppFrameworkException

getValidatable

protected Validatable getValidatable(ValidatableFactory.Context pContext,
                                     java.lang.reflect.Method pMethod)
                              throws com.softwareag.centrasite.appl.framework.CSAppFrameworkException
Checks, whether a Validatable is being created for the given method. If so, creates one, and returns it. Otherwise, returns null.

Throws:
com.softwareag.centrasite.appl.framework.CSAppFrameworkException

initialize

protected void initialize(ValidatableFactory.Context pContext,
                          java.lang.Object pObject)
                   throws com.softwareag.centrasite.appl.framework.CSAppFrameworkException
Initializes the given object.

Throws:
com.softwareag.centrasite.appl.framework.CSAppFrameworkException

getConstraintFactory

protected ConstraintFactory getConstraintFactory(ValidatableFactory.Context pContext)
                                          throws com.softwareag.centrasite.appl.framework.CSAppFrameworkException
Returns the constraint factory.

Throws:
com.softwareag.centrasite.appl.framework.CSAppFrameworkException

getValidationDefaults

protected ValidationDefaults getValidationDefaults()
Returns the factories validation defaults.


getErrorCodeFactory

protected ErrorCodeFactory getErrorCodeFactory(ValidatableFactory.Context pContext)
                                        throws com.softwareag.centrasite.appl.framework.CSAppFrameworkException
Returns the error code factory.

Throws:
com.softwareag.centrasite.appl.framework.CSAppFrameworkException

newConstraintFactory

protected ConstraintFactory newConstraintFactory(ValidatableFactory.Context pContext,
                                                 ValidationDefaults.ConstraintFactory ConstraintFactoryDefaults)
                                          throws com.softwareag.centrasite.appl.framework.CSAppFrameworkException
Creates a new instance of ConstraintFactory.

Throws:
com.softwareag.centrasite.appl.framework.CSAppFrameworkException

newErrorCodeFactory

protected ErrorCodeFactory newErrorCodeFactory(ValidatableFactory.Context pContext,
                                               ValidationDefaults.ErrorCodeFactory errorCodeFactoryDefaults)
                                        throws com.softwareag.centrasite.appl.framework.CSAppFrameworkException
Creates a new instance of ErrorCodeFactory.

Throws:
com.softwareag.centrasite.appl.framework.CSAppFrameworkException

getConditionFactory

protected ConditionFactory getConditionFactory(ValidatableFactory.Context pContext)
                                        throws com.softwareag.centrasite.appl.framework.CSAppFrameworkException
Returns the condition factory.

Throws:
com.softwareag.centrasite.appl.framework.CSAppFrameworkException

newConditionFactory

protected ConditionFactory newConditionFactory(ValidatableFactory.Context pContext,
                                               ValidationDefaults.ConditionFactory ConditionFactoryDefaults)
                                        throws com.softwareag.centrasite.appl.framework.CSAppFrameworkException
Creates a new instance of ConditionFactory.

Throws:
com.softwareag.centrasite.appl.framework.CSAppFrameworkException

getScopeFactory

protected ScopeFactory getScopeFactory(ValidatableFactory.Context pContext)
                                throws com.softwareag.centrasite.appl.framework.CSAppFrameworkException
Returns the scope factory.

Throws:
com.softwareag.centrasite.appl.framework.CSAppFrameworkException

newScopeFactory

protected ScopeFactory newScopeFactory(ValidatableFactory.Context pContext,
                                       ValidationDefaults.ScopeFactory ScopeFactoryDefaults)
                                throws com.softwareag.centrasite.appl.framework.CSAppFrameworkException
Creates a new instance of ScopeFactory.

Throws:
com.softwareag.centrasite.appl.framework.CSAppFrameworkException

createConstraints

protected void createConstraints(ValidatableFactory.Context pContext,
                                 Validatable pValidatable)
                          throws com.softwareag.centrasite.appl.framework.CSAppFrameworkException
Creates constraints for the given validatable.

Throws:
com.softwareag.centrasite.appl.framework.CSAppFrameworkException