biz.c24.io.api.data
Class DomainConstraintManager

java.lang.Object
  extended by java.util.Observable
      extended by biz.c24.io.api.data.DomainConstraintManager

public final class DomainConstraintManager
extends Observable

A static utility class used to store run-time mappings between identifiers and validators.
To map a domain constraint, a validator should be created and registered via the register(String, Validator) method to a unique identifier. All domain constraint validation rules from that point on will check this class for registered validators.

The Validator or Enumeration interface can be implemented directly or the DefaultEnumeration class provides some useful static methods for creating valdiators from other complex data objects which may have been populated from XML files, RDBMS via Hibernate or from flat files.

See Also:
DomainConstraint, Validator, Enumeration, DefaultEnumeration

Field Summary
 boolean passWithNoIdentifier
          Indicates validation should pass if no identifier can be found by selector (defaults to true).
 boolean passWithNoValidator
          Indicates validation should pass if no registered validator can be found for a given identifier (defaults to true).
 
Method Summary
 void clear()
          Clears all registered validators.
 String getIdentifier(int index)
          Returns the identifier at index.
static DomainConstraintManager getInstance()
          Returns the singleton instance of this class.
 Validator getValidator(int index)
          Returns the validator at index.
 int getValidatorCount()
          Returns the number of validators registerd.
 boolean isEmpty()
          Returns whether any validators are currently registered.
 boolean isRegistered(String identifier)
          Returns whether the specified identifier is registered.
 void register(String identifier, Validator validator)
          Registers validator against the specified identifier, overwriting any previous mappings present.
 void unregister(String identifier)
          Unregisters the validator with the specified identifier.
 Validator validator(String identifier)
          Attempts to find a validator for identifier among the registered mappings.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

passWithNoIdentifier

public boolean passWithNoIdentifier
Indicates validation should pass if no identifier can be found by selector (defaults to true).


passWithNoValidator

public boolean passWithNoValidator
Indicates validation should pass if no registered validator can be found for a given identifier (defaults to true).

Method Detail

getInstance

public static DomainConstraintManager getInstance()
Returns the singleton instance of this class.

Returns:
The singleton instance.

register

public void register(String identifier,
                     Validator validator)
Registers validator against the specified identifier, overwriting any previous mappings present.

Parameters:
identifier - The identifer to register.
validator - The validator to be mapped to.
Throws:
NullPointerException - If either argument is null.

unregister

public void unregister(String identifier)
Unregisters the validator with the specified identifier.

Parameters:
identifier - The identifier to be unregistered.
Throws:
NullPointerException - If argument is null.

clear

public void clear()
Clears all registered validators.


isRegistered

public boolean isRegistered(String identifier)
Returns whether the specified identifier is registered.

Parameters:
identifier - The identifier to test for.
Returns:
Whether it is registered.

isEmpty

public boolean isEmpty()
Returns whether any validators are currently registered.

Returns:
Whether there are any registered validators.

validator

public Validator validator(String identifier)
Attempts to find a validator for identifier among the registered mappings.

Parameters:
identifier - The identifier to look up.
Returns:
The validator if one is registered against the sepecified identifier otherwise null.

getValidatorCount

public int getValidatorCount()
Returns the number of validators registerd.

Returns:
The number of validators registered.

getValidator

public Validator getValidator(int index)
Returns the validator at index.

Parameters:
index - The index.
Returns:
The validator.

getIdentifier

public String getIdentifier(int index)
Returns the identifier at index.

Parameters:
index - The index.
Returns:
The validator.


C24 Technologies © 2002-2012: All Rights Reserved.