be.ac.ulg.montefiore.run.totem.visualtopo.guiModules.topEdit.factory
Class DomainElementFactory<T>

java.lang.Object
  extended by be.ac.ulg.montefiore.run.totem.visualtopo.guiModules.topEdit.factory.DomainElementFactory<T>
Direct Known Subclasses:
DomainFactory, LinkFactory, NodeFactory

public abstract class DomainElementFactory<T>
extends java.lang.Object

This class is to be used to create objects of type T based on a given model. The implementation should provide the #createInstance(java.util.HashMap) method to build a first default instance and the cloneObject(Object) method to clone the T type. Model instances are identified by a name and can be added to the factory. The #createObject(String, java.util.HashMap) method returns a clone of the given model.

Note: The cloneObject(Object) method should not be abstract but implemented here as a way to clone JAXBObject.

Creation date: 3/10/2007

Author:
Gaƫl Monfort (monfort@run.montefiore.ulg.ac.be)

Field Summary
protected  java.util.HashMap<java.lang.String,T> defaultMap
           
 
Constructor Summary
protected DomainElementFactory()
          Common operations to all constructors
 
Method Summary
 void addInstance(java.lang.String name, T instance)
          Add the given model instance under the given name
 T clone(T instance)
          clone an instance of T
protected abstract  java.lang.Object cloneObject(java.lang.Object object)
          Clone an object of type T.
 T createDefaultObject(java.util.HashMap<java.lang.String,java.lang.String> params)
          Create an object by cloning the default model instance.
protected abstract  T createInstance(java.util.HashMap<java.lang.String,java.lang.String> params)
          Build an instance of type T, given T specific parameters.
 T createObject(java.lang.String model, java.util.HashMap<java.lang.String,java.lang.String> params)
          Create an object by cloning the model identified by model.
 java.util.Collection<java.lang.String> getAllInstanceName()
           
 T getDefaultModel()
          returns the default model instance.
 T getModel(java.lang.String name)
          return the model instance associated with name.
 T removeInstance(java.lang.String name)
          Remove the model instance identified by name.
 void setDefaultModel(java.lang.String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultMap

protected java.util.HashMap<java.lang.String,T> defaultMap
Constructor Detail

DomainElementFactory

protected DomainElementFactory()
Common operations to all constructors

Method Detail

createInstance

protected abstract T createInstance(java.util.HashMap<java.lang.String,java.lang.String> params)
Build an instance of type T, given T specific parameters.

Parameters:
params -
Returns:

addInstance

public void addInstance(java.lang.String name,
                        T instance)
                 throws AlreadyExistException
Add the given model instance under the given name

Parameters:
name -
instance -
Throws:
AlreadyExistException - If an instance associated with the id already exists

removeInstance

public T removeInstance(java.lang.String name)
Remove the model instance identified by name.

Parameters:
name -
Returns:

getAllInstanceName

public java.util.Collection<java.lang.String> getAllInstanceName()

createObject

public T createObject(java.lang.String model,
                      java.util.HashMap<java.lang.String,java.lang.String> params)
               throws NotFoundException
Create an object by cloning the model identified by model.

Parameters:
model -
params -
Returns:
Throws:
NotFoundException

createDefaultObject

public T createDefaultObject(java.util.HashMap<java.lang.String,java.lang.String> params)
Create an object by cloning the default model instance.

Parameters:
params -
Returns:

getModel

public T getModel(java.lang.String name)
return the model instance associated with name.

Parameters:
name -
Returns:

getDefaultModel

public T getDefaultModel()
returns the default model instance.

Returns:

setDefaultModel

public void setDefaultModel(java.lang.String name)
                     throws NotFoundException
Throws:
NotFoundException

clone

public T clone(T instance)
clone an instance of T

Parameters:
instance -
Returns:

cloneObject

protected abstract java.lang.Object cloneObject(java.lang.Object object)
Clone an object of type T.

Parameters:
object -
Returns:


Copyright © 2004-2007 Research Unit in Networking, All Rights Reserved.