User's Manual

110 Chapter 10. Kernel Tutorial
* DataObject.
*
* @see AuditedACSObject#AuditedACSObject(OID)
* @see com.arsdigita.persistence.DataObject
* @see com.arsdigita.persistence.OID
*
* @exception DataObjectNotFoundException Thrown if we cannot
* retrieve a data object for the specified OID
*
**/ (4)
public Note(OID oid) throws DataObjectNotFoundException {
super(oid);
}
...
}
(1) The empty constructor is used to construct a new Note with its default data object type. This is
the common case for constructing a new Note, where a specific subtype of domain object is not
needed and an existing Note is not being retrieved.
(2) The typeName specified in this constructor must be a String that names an object type. This
does the same thing as the constructor that takes an object type, but is more convenient, because
you only need to specify a String with the type name.
(3) This constructor takes an ObjectType that matches the base object type, in this case,
com.arsdigita.notes.Note or a subtype. The constructor requiring an ObjectType can
be used to specify a specific subtype of the Notes data object. This is useful if the data object
may be used with different domain objects that have different methods.
In most cases, the empty constructor, which defaults to the base object type, is sufficient, and
any reason to use the other constructors should be specified. Even if the Note domain object will
not be used with multiple object types, it is necessary to have these constructors for a subclass to
provide this functionality. Without providing the constructors on every class, a subclass cannot
rely on the constructor chain to reach the constructors on ACSObject and DomainObject.
(4) This constructor is used to construct a Notes domain object with a Notes domain object that
has already been created. The OID is used to retrieve an instance of the correct domain object.
The retrieved data object can then be accessed using the set/get methods and all other methods
defined.
Example 10-2. Domain Object Constructors
The role of each constructor can be clarified by examining how the constructors are implemented in
DomainObject, the root base class for all domain objects.
public abstract class DomainObject {
private final DataObject m_dataObject;
/**
* Constructor. The contained DataObject is
* initialized with a new DataObject with an
* ObjectType specified by the string
* typeName.
*
* @param typeName The name of the ObjectType of the