public class TLcyCompositeModelFactory extends TLcyGenericComposite<ILcdModelFactory> implements ILcdModelFactory
A composite implementation of ILcdModelFactory
according to the composite design
pattern.
When creating a new TLcyCompositeModelFactory
using the default constructor (see
TLcyCompositeModelFactory()
), the created instance will only work on/with the
ILcdModelFactorys registered on this composite instance (see addModelFactory(com.luciad.model.ILcdModelFactory)
and removeModelFactory(com.luciad.model.ILcdModelFactory)
).
When creating a new TLcyCompositeModelFactory
using the constructor specifying an
ILcyLucyEnv
instance (see TLcyCompositeModelFactory(com.luciad.lucy.ILcyLucyEnv)
,
the created instance will work on the Lucy back-end services. It will use all registered ILcdModelFactory instances of the Lucy back-end, adding and/or removing an
ILcdModelFactory
will add/remove the ILcdModelFactory
as service from
Lucy, ... .
Creating an ILcdModel
using the back-end based implementation can be done by
creating a new instance of this class:
//Create a new instance whenever you need it.
TLcyCompositeModelFactory factory = new TLcyCompositeModelFactory( aLucyEnv );
try{
ILcdModel model = factory.createModel( aModelDescriptor, aModelReference );
} catch( IllegalArgumentException aException ){
//no suitable ILcdModelFactory was registered on the back-end
}
//There is no need to keep a reference to the composite instance, you can create a new one
//the next time you would need it
factory = null;
PRIORITY_DEFAULT, PRIORITY_FALLBACK
Constructor and Description |
---|
TLcyCompositeModelFactory()
Default constructor.
|
TLcyCompositeModelFactory(ILcyLucyEnv aLucyEnv)
Construct a
TLcyCompositeModelFactory working on the Lucy back-end. |
Modifier and Type | Method and Description |
---|---|
void |
addModelFactory(ILcdModelFactory aModelFactory)
Adds the given model content type provider to the list of registered content type
providers.
|
ILcdModel |
createModel(ILcdModelDescriptor aModelDescriptor,
ILcdModelReference aModelReference)
Implementation of ILcdModelFactory#createModel.
|
ILcdModelFactory |
getModelFactory(int aIndex)
Returns the model factory at the given index.
|
int |
getModelFactoryCount()
Returns the number of currently registered model factories.
|
void |
removeModelFactory(ILcdModelFactory aModelFactory)
Removes the given model factory from the list of registered model factories.
|
add, add, getList, getPriority, iterator, remove
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public TLcyCompositeModelFactory()
Default constructor.
The created instance will only work on the ILcdModelFactory
instances
registered to it. If you want to use all registered ILcdModelFactory
instances of
the Lucy back-end, use TLcyCompositeModelFactory(com.luciad.lucy.ILcyLucyEnv)
instead.
public TLcyCompositeModelFactory(ILcyLucyEnv aLucyEnv)
Construct a TLcyCompositeModelFactory
working on the Lucy back-end.
It will use all ILcdModelFactory
instances registered to the back-end, and
adding and/or removing ILcdModelFactory
s to/from this
TLcyCompositeModelFactory
will respectively add/remove it as service from the
back-end.
If you want to create a TLcyCompositeModelFactory
which does not use the
back-end, use TLcyCompositeModelFactory()
instead.
aLucyEnv
- The Lucy back-endTLcyCompositeModelFactory()
,
ILcyLucyEnv.addService(Object, int)
,
ILcyLucyEnv.removeService(Object)
public void addModelFactory(ILcdModelFactory aModelFactory)
Adds the given model content type provider to the list of registered content type providers.
If the constructor specifying an ILcyLucyEnv
is used, the
ILcdModelFactory
will be registered as a service on the Lucy back-end (see ILcyLucyEnv.addService(Object, int)
). When calling ILcyLucyEnv.getServices(Class)
afterwards, aModelFactory
will only
be included in the returned list when the requested class was ILcdModelFactory.class
.
Note: if you want to remove the registered ILcdModelFactory
afterwards, use
removeModelFactory(com.luciad.model.ILcdModelFactory)
and not ILcyLucyEnv.removeService(Object)
.
aModelFactory
- The model factory to add. Must not be null
.removeModelFactory(com.luciad.model.ILcdModelFactory)
public void removeModelFactory(ILcdModelFactory aModelFactory)
Removes the given model factory from the list of registered model factories. Nothing will happen if the given provider was never added before.
If the constructor specifying an ILcyLucyEnv
is used, the
ILcdModelFactory
will be removed as service from the Lucy back-end (see ILcyLucyEnv.removeService(Object)
).
Note: it is only possible to remove ILcdModelFactory
instances which were
registered using the addModelFactory(com.luciad.model.ILcdModelFactory)
method.
aModelFactory
- The model factory to remove. Must not be null
.addModelFactory(com.luciad.model.ILcdModelFactory)
public int getModelFactoryCount()
Returns the number of currently registered model factories.
getModelFactory(int)
public ILcdModelFactory getModelFactory(int aIndex)
aIndex
- The index to retrieve the model factory for. Note that 0 <= aIndex < getModelFactoryCount()
getModelFactoryCount()
public ILcdModel createModel(ILcdModelDescriptor aModelDescriptor, ILcdModelReference aModelReference) throws IllegalArgumentException
ILcdModelFactory
s and tries to find a suitable ILcdModelFactory
.
Suitable means that the ILcdModelFactory
does not throw an
IllegalArgumentException
. The ILcdModel
of the first suitable
ILcdModelFactory
is returned, or an IllegalArgumentException
is
thrown when no suitable ILcdModelFactory
could be found.createModel
in interface ILcdModelFactory
aModelDescriptor
- The model descriptor.aModelReference
- The model reference. This parameter can be left null
to get
a default model reference (for example WGS84, but it depends on the implementation).ILcdModel
, never null
.IllegalArgumentException
- If no ILcdModel
can be created for the given parameters,
for example because the ILcdModelDescriptor
is of the incorrect type.