org.nakedobjects.applib
Interface DomainObjectContainer


public interface DomainObjectContainer

Represents a container that the domain objects work within. It provides access to the persistence mechanism and user interface.


Method Summary
<T> java.util.List<T>
allInstances(java.lang.Class<T> ofType)
          Returns all the instances of the specified type (including subtypes).
<T> java.util.List<T>
allMatches(java.lang.Class<T> ofType, Filter<T> filter)
          Returns all the instances of the specified type (including subtypes) that the filter object accepts.
<T> java.util.List<T>
allMatches(java.lang.Class<T> ofType, java.lang.String title)
          Returns all the instances of the specified type (including subtypes) that have the given title.
<T> java.util.List<T>
allMatches(java.lang.Class<T> ofType, T pattern)
          Returns all the instances of the specified type (including subtypes) that match the given object: where any property that is set will be tested and properties that are not set will be ignored.
<T> java.util.List<T>
allMatches(Query<T> query)
          Returns all the instances that match the given Query.
 void commit()
          Commit all changes to the object store.
<T> T
firstMatch(java.lang.Class<T> ofType, Filter<T> filter)
          Returns the first instance of the specified type (including subtypes) that matches the supplied Filter, or null if none.
<T> T
firstMatch(java.lang.Class<T> ofType, java.lang.String title)
          Returns the first instance of the specified type (including subtypes) that matches the supplied title, or null if none.
<T> T
firstMatch(java.lang.Class<T> ofType, T pattern)
          Returns the first instance of the specified type (including subtypes) that matches the supplied object as a pattern, or null if none.
<T> T
firstMatch(Query<T> query)
          Returns the first instance that matches the supplied query, or null if none.
 boolean flush()
          Flush all changes to the object store.
 UserMemento getUser()
          Get the details about the current user.
 void informUser(java.lang.String message)
          Make the specified message available to the user.
 boolean isPersistent(java.lang.Object domainObject)
          Determines if the specified object is persistent (that it is stored permanently outside of the virtual machine).
 boolean isValid(java.lang.Object domainObject)
          Whether the object is in a valid state, that is that none of the validation of properties, collections and object-level is vetoing.
<T> T
newInstance(java.lang.Class<T> ofType, java.lang.Object object)
          Returns a new instance of the specified class that has the sane persisted state as the specified object.
<T> T
newPersistentInstance(java.lang.Class<T> ofType)
          Returns a new instance of the specified class that will have been persisted.
<T> T
newTransientInstance(java.lang.Class<T> ofType)
          Create a new instance of the specified class, but do not persist it.
 void objectChanged(java.lang.Object domainObject)
          Flags that the specified object's state has changed and its changes need to be saved.
 void persist(java.lang.Object transientDomainObject)
          Make the specified transient object persistent.
 void persistIfNotAlready(java.lang.Object domainObject)
          Make the specified object persistent if not already.
 void raiseError(java.lang.String message)
          Notify the user of an application error with the specified message.
 void remove(java.lang.Object persistentDomainObject)
          Removes (deletes) the persisted object.
 void resolve(java.lang.Object domainObject)
          Ensure that the specified object is completely loaded into memory.
 void resolve(java.lang.Object domainObject, java.lang.Object field)
          Ensure that the specified object is completely loaded into memory, though only if the supplied field reference is null.
<T> T
uniqueMatch(java.lang.Class<T> ofType, Filter<T> filter)
          Find the only instance of the specified type (including subtypes) that has the specified title.
<T> T
uniqueMatch(java.lang.Class<T> ofType, java.lang.String title)
          Find the only instance of the specified type (including subtypes) that has the specified title.
<T> T
uniqueMatch(java.lang.Class<T> ofType, T pattern)
          Find the only instance of the patterned object type (including subtypes) that matches the set fields in the pattern object: where any property that is set will be tested and properties that are not set will be ignored.
<T> T
uniqueMatch(Query<T> query)
          Find the only instance that matches the provided query.
 java.lang.String validate(java.lang.Object domainObject)
          The reason, if any why the object is in a invalid state
 void warnUser(java.lang.String message)
          Warn the user about a situation with the specified message.
 

Method Detail

resolve

void resolve(java.lang.Object domainObject)
Ensure that the specified object is completely loaded into memory.

This forces the lazy loading mechanism to load the object if it is not already loaded.


resolve

void resolve(java.lang.Object domainObject,
             java.lang.Object field)
Ensure that the specified object is completely loaded into memory, though only if the supplied field reference is null.

This forces the lazy loading mechanism to load the object if it is not already loaded.


objectChanged

void objectChanged(java.lang.Object domainObject)
Flags that the specified object's state has changed and its changes need to be saved.


flush

boolean flush()
Flush all changes to the object store.

Typically only for use by tests.

Returns:
true

commit

void commit()
Commit all changes to the object store.

Typically only for use by tests.


newTransientInstance

<T> T newTransientInstance(java.lang.Class<T> ofType)
Create a new instance of the specified class, but do not persist it.

See Also:
newPersistentInstance(Class)

newPersistentInstance

<T> T newPersistentInstance(java.lang.Class<T> ofType)
Returns a new instance of the specified class that will have been persisted.


newInstance

<T> T newInstance(java.lang.Class<T> ofType,
                  java.lang.Object object)
Returns a new instance of the specified class that has the sane persisted state as the specified object.


isValid

boolean isValid(java.lang.Object domainObject)
Whether the object is in a valid state, that is that none of the validation of properties, collections and object-level is vetoing.

See Also:
validate(Object)

validate

java.lang.String validate(java.lang.Object domainObject)
The reason, if any why the object is in a invalid state

Checks the validation of all of the properties, collections and object-level.

See Also:
isValid(Object)

isPersistent

boolean isPersistent(java.lang.Object domainObject)
Determines if the specified object is persistent (that it is stored permanently outside of the virtual machine).


persist

void persist(java.lang.Object transientDomainObject)
Make the specified transient object persistent.

Throws an exception if object is already persistent.

See Also:
isPersistent(Object), persistIfNotAlready(Object)

persistIfNotAlready

void persistIfNotAlready(java.lang.Object domainObject)
Make the specified object persistent if not already.

Does nothing otherwise.

See Also:
isPersistent(Object), persist(Object)

remove

void remove(java.lang.Object persistentDomainObject)
Removes (deletes) the persisted object.

Parameters:
persistentDomainObject -

informUser

void informUser(java.lang.String message)
Make the specified message available to the user. Note this will probably be displayed in transitory fashion, so is only suitable for useful but optional information.

See Also:
warnUser(String), raiseError(String)

warnUser

void warnUser(java.lang.String message)
Warn the user about a situation with the specified message. The container should guarantee to display this warning to the user.

See Also:
raiseError(String), informUser(String)

raiseError

void raiseError(java.lang.String message)
Notify the user of an application error with the specified message. Note this will probably be displayed in an alarming fashion, so is only suitable for errors

See Also:
warnUser(String), informUser(String)

getUser

UserMemento getUser()
Get the details about the current user.


allInstances

<T> java.util.List<T> allInstances(java.lang.Class<T> ofType)
Returns all the instances of the specified type (including subtypes).

If there are no instances the list will be empty. This method creates a new List object each time it is called so the caller is free to use or modify the returned List, but the changes will not be reflected back to the repository.

This method should only be called where the number of instances is known to be relatively low.


allMatches

<T> java.util.List<T> allMatches(java.lang.Class<T> ofType,
                                 Filter<T> filter)
Returns all the instances of the specified type (including subtypes) that the filter object accepts.

If there are no instances the list will be empty. This method creates a new List object each time it is called so the caller is free to use or modify the returned List, but the changes will not be reflected back to the repository.

This method is useful during exploration/prototyping, but you may want to use allMatches(Query) for production code.


allMatches

<T> java.util.List<T> allMatches(java.lang.Class<T> ofType,
                                 java.lang.String title)
Returns all the instances of the specified type (including subtypes) that have the given title.

If there are no instances the list will be empty. This method creates a new List object each time it is called so the caller is free to use or modify the returned List, but the changes will not be reflected back to the repository.

This method is useful during exploration/prototyping, but you may want to use allMatches(Query) for production code.


allMatches

<T> java.util.List<T> allMatches(java.lang.Class<T> ofType,
                                 T pattern)
Returns all the instances of the specified type (including subtypes) that match the given object: where any property that is set will be tested and properties that are not set will be ignored.

If there are no instances the list will be empty. This method creates a new List object each time it is called so the caller is free to use or modify the returned List, but the changes will not be reflected back to the repository.

This method is useful during exploration/prototyping, but you may want to use allMatches(Query) for production code.


allMatches

<T> java.util.List<T> allMatches(Query<T> query)
Returns all the instances that match the given Query.

If there are no instances the list will be empty. This method creates a new List object each time it is called so the caller is free to use or modify the returned List, but the changes will not be reflected back to the repository.


firstMatch

<T> T firstMatch(java.lang.Class<T> ofType,
                 Filter<T> filter)
Returns the first instance of the specified type (including subtypes) that matches the supplied Filter, or null if none.

This method is useful during exploration/prototyping, but you may want to use firstMatch(Query) for production code.


firstMatch

<T> T firstMatch(java.lang.Class<T> ofType,
                 java.lang.String title)
Returns the first instance of the specified type (including subtypes) that matches the supplied title, or null if none.

This method is useful during exploration/prototyping, but you may want to use firstMatch(Query) for production code.


firstMatch

<T> T firstMatch(java.lang.Class<T> ofType,
                 T pattern)
Returns the first instance of the specified type (including subtypes) that matches the supplied object as a pattern, or null if none.

This method is useful during exploration/prototyping, but you may want to use firstMatch(Query) for production code.


firstMatch

<T> T firstMatch(Query<T> query)
Returns the first instance that matches the supplied query, or null if none.


uniqueMatch

<T> T uniqueMatch(java.lang.Class<T> ofType,
                  Filter<T> filter)
Find the only instance of the specified type (including subtypes) that has the specified title.

If no instance is found then null will be return, while if there is more that one instances a run-time exception will be thrown.

This method is useful during exploration/prototyping, but you may want to use uniqueMatch(Query) for production code.


uniqueMatch

<T> T uniqueMatch(java.lang.Class<T> ofType,
                  java.lang.String title)
Find the only instance of the specified type (including subtypes) that has the specified title.

If no instance is found then null will be returned, while if there is more that one instances a run-time exception will be thrown.

This method is useful during exploration/prototyping, but you may want to use uniqueMatch(Query) for production code.


uniqueMatch

<T> T uniqueMatch(java.lang.Class<T> ofType,
                  T pattern)
Find the only instance of the patterned object type (including subtypes) that matches the set fields in the pattern object: where any property that is set will be tested and properties that are not set will be ignored.

If no instance is found then null will be return, while if there is more that one instances a run-time exception will be thrown.

This method is useful during exploration/prototyping, but you may want to use uniqueMatch(Query) for production code.


uniqueMatch

<T> T uniqueMatch(Query<T> query)
Find the only instance that matches the provided query.

If no instance is found then null will be return, while if there is more that one instances a run-time exception will be thrown.



Copyright © 2001-2009 Naked Objects Group Ltd.. All Rights Reserved.