GNDMS 0.6.0
RESTful verison of GNDMS
Public Member Functions | Protected Member Functions | Private Attributes

de.zib.gndms.model.common.repository.TransientDao< K, M, D > Class Reference

Inheritance diagram for de.zib.gndms.model.common.repository.TransientDao< K, M, D >:
de.zib.gndms.model.common.repository.Dao< K, M, D >

List of all members.

Public Member Functions

create (D descriptor)
 Creates a fresh instance of M matching descriptor.
void add (M model, K key)
 Addes a model to the dao.
get (K key) throws NoSuchElementException
 Used to retrive an model object form the dao.
void deleteByKey (K key)
 Deletes a model matching the given key.
void delete (M model)
 This is expensive, so don't lose your key.

Protected Member Functions

cacheGet (K key)
Map< K, M > getModels ()
void setModels (Cache< K, M > models)

Private Attributes

Cache< K, M > models

Detailed Description

Author:
try ma ik jo rr a zib
Version:
$Id$

Date: 23.12.2010, Time: 12:32:07

Transient dao uses a hashmap to store key model associations.


Member Function Documentation

void de.zib.gndms.model.common.repository.TransientDao< K, M, D >.add ( model,
key 
)

Addes a model to the dao.

Parameters:
modelThe model to add, with the key to use.

Implements de.zib.gndms.model.common.repository.Dao< K, M, D >.

                                      {
        models.asMap().put( key, model );
    }
K de.zib.gndms.model.common.repository.TransientDao< K, M, D >.create ( descriptor)

Creates a fresh instance of M matching descriptor.

This can be used fine grained construction, i.e. if M is a base class.

Parameters:
descriptorThe descriptor of the object, i.e. class.
Returns:
The key of the new instance.

Implements de.zib.gndms.model.common.repository.Dao< K, M, D >.

                                    {
        return create( );
    }
void de.zib.gndms.model.common.repository.TransientDao< K, M, D >.delete ( model)

This is expensive, so don't lose your key.

Parameters:
modelThe model to delete.

Implements de.zib.gndms.model.common.repository.Dao< K, M, D >.

                                  {
        for ( K key: models.asMap().keySet() ) {
            try {
                if( models.get( key ).equals( model ) ) {
                    deleteByKey( key );
                    return;
                }
            } catch ( ExecutionException e ) {
                // intentionally
            }
        }
    }
void de.zib.gndms.model.common.repository.TransientDao< K, M, D >.deleteByKey ( key)

Deletes a model matching the given key.

Parameters:
keyThe key.

NOTE: Stupid type erasure.

Implements de.zib.gndms.model.common.repository.Dao< K, M, D >.

                                     {
        models.invalidate( key );
    }
M de.zib.gndms.model.common.repository.TransientDao< K, M, D >.get ( key) throws NoSuchElementException

Used to retrive an model object form the dao.

Parameters:
keyThe key of the object.
Returns:

Implements de.zib.gndms.model.common.repository.Dao< K, M, D >.

                                                        {

        if( models.asMap().containsKey( key ) )
            try {
                return models.get( key );
            } catch ( ExecutionException e ) {
                throw new NoSuchElementException( key.toString() );
            }

        throw new NoSuchElementException( key.toString() );
    }

The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables