Arch4J 1.1

org.arch4j.domain
Class Domain

java.lang.Object
  |
  +--org.arch4j.domain.Domain
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
BigDecimalDomain, DateTimeDomain, IntegerDomain, StringDomain

public abstract class Domain
extends Object
implements Serializable

This is the abstract base class for all domain classes. It provides a common interface to get and set the single Object value represented by this domain value container. The Class type of any specified Object value for setting is automatically validated against what the implementation class specifies as the expected Class type in getValueClass. Additional validation specific to bounds checking or business rules is coded in the implementation class's validate method.

Version:
1.0
Author:
David Colwell
See Also:
Serialized Form

Constructor Summary
Domain()
          Constructs the domain and sets its value to null.
Domain(Object aValue)
          Constructs the domain and sets its value to the specified value.
 
Method Summary
 Object getValue()
          Retrieve the value contained by this domain.
protected abstract  String getValueClass()
          Placeholder for the implementation class to specify the String representation of the class name expected for this domain's value.
 void setValue(Object aValue)
          Sets the value contained by this domain.
 String toString()
          Returns a String representation of this domain's value.
protected abstract  void validate(Object aValue)
          Placeholder for any bounds checking and business rule validation.
protected  void validateType(Object aValue)
          Validates the Class type of aValue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Domain

public Domain()
Constructs the domain and sets its value to null.


Domain

public Domain(Object aValue)
       throws DomainValidationException
Constructs the domain and sets its value to the specified value.

Method Detail

getValue

public Object getValue()
Retrieve the value contained by this domain.

Returns:
the value contained by this domain.

setValue

public void setValue(Object aValue)
              throws DomainValidationException
Sets the value contained by this domain. Validation of the Class type and any additional business validation is automatically performed. If the specified value is null, then validation is skipped.

Throws:
DomainValidationException - if bounds or business rule validation is not met.

validateType

protected void validateType(Object aValue)
Validates the Class type of aValue.


validate

protected abstract void validate(Object aValue)
                          throws DomainValidationException
Placeholder for any bounds checking and business rule validation.

Throws:
DomainValidationException - if any bounds checks or business rule validations fail.

getValueClass

protected abstract String getValueClass()
Placeholder for the implementation class to specify the String representation of the class name expected for this domain's value. This method will be used both in runtime value type checking and in automating persistence from the database.


toString

public String toString()
Returns a String representation of this domain's value. If the value is null then return an empty string.

Overrides:
toString in class Object

Arch4J 1.1

Copyright © 2000-2004 SpiderLogic, a service of Wipfli Ullrich Bertelson LLP.