public class JImplicitFactory extends JComponent implements Factory, MultiFactory, Initializer
MultiFactory
: holds a set of implementation alternatives
(given at the object's creation) and instantiates one of them, according
to a given chosen alternative ID.int_value, reference, type, value
Constructor and Description |
---|
JImplicitFactory(java.util.List _alternatives)
Creates a new implicit factory whose implementation alternatives
are listed in _alternatives as JAlternatives.
|
Modifier and Type | Method and Description |
---|---|
Component |
duplicate()
Creates a new implicit factory holding the same implementation
alternatives.
|
void |
initialize(java.lang.Object _obj,
Context _c,
int _alternative)
Implementation of the Initializer interface's initialize method.
|
java.lang.Object |
newObject(Context _c)
From Factory interface.
|
java.lang.Object |
newObject(Context _c,
int _alternative,
Instanciable _instance)
Returns a new instance of the implicit factory's implementation
alternative whose ID is
_alternative . |
java.lang.String |
toString() |
fork, getComponent, getElement, getFactoryValue, getIntValue, getReference, getType, getValue, getValue, internalFork, reset, setReference
public JImplicitFactory(java.util.List _alternatives)
public Component duplicate()
duplicate
in class JComponent
public java.lang.Object newObject(Context _c) throws JonathanException
_c
is the local Context
containing the required instanciation parameters.newObject
in interface Factory
_c
- contains the instanciation parameterJonathanException
- if something goes wrong.public java.lang.Object newObject(Context _c, int _alternative, Instanciable _instance) throws JonathanException
_alternative
. In the single implementation
alternative case, it works only if the single alternative's ID is the
given one (although newObject(Context)
would do it anyway).newObject
in interface MultiFactory
_c
- where the instanciation parameters are found_alternative
- the alternative to instantiate_instance
- the method's caller._alternative
's instanceJonathanException
- if something goes wrong.public void initialize(java.lang.Object _obj, Context _c, int _alternative) throws JonathanException
_alternative
by calling its
setters. In the single implementation
alternative case, it works only if the single alternative's ID is the
given one (although initialize(Object,Context)
would do it
anyway).initialize
in interface Initializer
_obj
- the object to initialize_c
- where the initialisation parameters are found_alternative
- the alternative to instantiateJonathanException
- if something goes wrong.public java.lang.String toString()
toString
in class JComponent