org.iscreen
Class ValidationFactoryConfig

java.lang.Object
  extended by org.iscreen.ValidationFactoryConfig

public class ValidationFactoryConfig
extends java.lang.Object

This JavaBean is purely for configuration. It's used to retrieve an instance of the ValidationFactory via a getter, as opposed to getting/building one directly by calling the ValidationFactory.buildFactory() method. Either use the appropriate constructor, or call the appropriate setters, and then retrieve the factory by calling the getFactory() method. Note that the default factory is the default XML one (so, you don't need to set that if you plan to use the XML factory). The location of the configuration file is required, so if it's not set, an exception will be thrown. Since services are optional, they do not need to be set.

Author:
Shellman, Dan

Field Summary
protected  java.lang.String configLocation
           
protected  java.util.Locale defaultLocale
           
protected  ValidationFactory factory
           
protected  java.lang.String factoryId
           
protected  java.util.Map services
           
 
Constructor Summary
ValidationFactoryConfig()
          Default constructor.
ValidationFactoryConfig(java.lang.String theConfigurationLocation)
          Constructor that defines only the configuration file.
ValidationFactoryConfig(java.lang.String theConfigurationLocation, java.util.Locale locale)
          Constructor that defines only the configuration file.
ValidationFactoryConfig(java.lang.String theConfigurationLocation, java.util.Map theServices)
          Constructor that defines only the configuration file.
ValidationFactoryConfig(java.lang.String theFactoryId, java.lang.String theConfigurationLocation)
          Constructor that defines all available config properties except services.
ValidationFactoryConfig(java.lang.String theFactoryId, java.lang.String theConfigurationLocation, java.util.Locale locale, java.util.Map theServices)
          Constructor that defines all available config properties.
 
Method Summary
 void addService(java.lang.String serviceId, java.lang.Object value)
          Adds a service to those already defined for the factory.
 ValidationFactory getFactory()
          Builds and returns the factory based upon the configuration defined within this configuration.
 void setConfigurationLocation(java.lang.String location)
          Defines the location of the configuration file.
 void setDefaultLocale(java.util.Locale locale)
          Sets the default locale for this factory.
 void setFactoryId(java.lang.String theFactoryId)
          Sets the factory id.
 void setServices(java.util.Map theServices)
          Sets the services the factory will use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

factoryId

protected java.lang.String factoryId

configLocation

protected java.lang.String configLocation

defaultLocale

protected java.util.Locale defaultLocale

services

protected java.util.Map services

factory

protected ValidationFactory factory
Constructor Detail

ValidationFactoryConfig

public ValidationFactoryConfig()
Default constructor.


ValidationFactoryConfig

public ValidationFactoryConfig(java.lang.String theFactoryId,
                               java.lang.String theConfigurationLocation,
                               java.util.Locale locale,
                               java.util.Map theServices)
Constructor that defines all available config properties.

Parameters:
theFactoryId - The id of the factory to use (it must have been previously registered.
theConfigurationLocation - The location of the configuration file.
locale - The default locale.
theServices - The set of services the factory requires.

ValidationFactoryConfig

public ValidationFactoryConfig(java.lang.String theFactoryId,
                               java.lang.String theConfigurationLocation)
Constructor that defines all available config properties except services.

Parameters:
theFactoryId - The id of the factory to use (it must have been previously registered.
theConfigurationLocation - The location of the configuration file.

ValidationFactoryConfig

public ValidationFactoryConfig(java.lang.String theConfigurationLocation)
Constructor that defines only the configuration file. The factory will be the default XML one, and no services will be defined.

Parameters:
theConfigurationLocation - The location of the configuration file.

ValidationFactoryConfig

public ValidationFactoryConfig(java.lang.String theConfigurationLocation,
                               java.util.Locale locale)
Constructor that defines only the configuration file. The factory will be the default XML one, and no services will be defined.

Parameters:
theConfigurationLocation - The location of the configuration file.
locale - The default locale.

ValidationFactoryConfig

public ValidationFactoryConfig(java.lang.String theConfigurationLocation,
                               java.util.Map theServices)
Constructor that defines only the configuration file. The factory will be the default XML one, and no services will be defined.

Parameters:
theConfigurationLocation - The location of the configuration file.
theServices - The set of services the factory requires.
Method Detail

setConfigurationLocation

public void setConfigurationLocation(java.lang.String location)
Defines the location of the configuration file. This will override the configuration location defined in the constructor (if it was).

Parameters:
location - The location of the configuration file.

setFactoryId

public void setFactoryId(java.lang.String theFactoryId)
Sets the factory id. This will override the factory id defined in the constructor (if it was).

Parameters:
theFactoryId - The id of the factory to use.

setDefaultLocale

public void setDefaultLocale(java.util.Locale locale)
Sets the default locale for this factory.

Parameters:
locale - The default locale.

setServices

public void setServices(java.util.Map theServices)
Sets the services the factory will use. This will remove any prior defined services and replace them with those passed in.

Parameters:
theServices - The services the factory requires.

addService

public void addService(java.lang.String serviceId,
                       java.lang.Object value)
Adds a service to those already defined for the factory.

Parameters:
serviceId - The id of the individual service.
value - The service object, itself.

getFactory

public ValidationFactory getFactory()
Builds and returns the factory based upon the configuration defined within this configuration. If some of the configuration is invalid or missing (such as no configuration location), no exception will be thrown, so ensure that all configuration has been set properly.

If this method is called multiple times, a new factory is NOT constructed. The same factory returned on the first call will be returned on subsequent calls.

Returns:
Returns a built factory.