Class TLcyCompositeModelFactory
- All Implemented Interfaces:
ILcdModelFactory
,Iterable<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;
- Since:
- 10.0
-
Field Summary
Fields inherited from class com.luciad.lucy.util.TLcyGenericComposite
PRIORITY_DEFAULT, PRIORITY_FALLBACK
-
Constructor Summary
ConstructorDescriptionDefault constructor.TLcyCompositeModelFactory
(ILcyLucyEnv aLucyEnv) Construct aTLcyCompositeModelFactory
working on the Lucy back-end. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addModelFactory
(ILcdModelFactory aModelFactory) Adds the given model content type provider to the list of registered content type providers.createModel
(ILcdModelDescriptor aModelDescriptor, ILcdModelReference aModelReference) Implementation of ILcdModelFactory#createModel.getModelFactory
(int aIndex) Returns the model factory at the given index.int
Returns the number of currently registered model factories.void
removeModelFactory
(ILcdModelFactory aModelFactory) Removes the given model factory from the list of registered model factories.Methods inherited from class com.luciad.lucy.util.TLcyGenericComposite
add, add, getList, getPriority, iterator, remove
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
TLcyCompositeModelFactory
public TLcyCompositeModelFactory()Default constructor.
The created instance will only work on the
ILcdModelFactory
instances registered to it. If you want to use all registeredILcdModelFactory
instances of the Lucy back-end, useTLcyCompositeModelFactory(com.luciad.lucy.ILcyLucyEnv)
instead.- See Also:
-
TLcyCompositeModelFactory
Construct a
TLcyCompositeModelFactory
working on the Lucy back-end.It will use all
ILcdModelFactory
instances registered to the back-end, and adding and/or removingILcdModelFactory
s to/from thisTLcyCompositeModelFactory
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, useTLcyCompositeModelFactory()
instead.- Parameters:
aLucyEnv
- The Lucy back-end- See Also:
-
-
Method Details
-
addModelFactory
Adds the given model content type provider to the list of registered content type providers.
If the constructor specifying an
ILcyLucyEnv
is used, theILcdModelFactory
will be registered as a service on the Lucy back-end (seeILcyLucyEnv.addService(Object, int)
). When callingILcyLucyEnv.getServices(Class)
afterwards,aModelFactory
will only be included in the returned list when the requested class wasILcdModelFactory.class
.
Note: if you want to remove the registeredILcdModelFactory
afterwards, useremoveModelFactory(com.luciad.model.ILcdModelFactory)
and notILcyLucyEnv.removeService(Object)
.- Parameters:
aModelFactory
- The model factory to add. Must not benull
.- See Also:
-
removeModelFactory
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, theILcdModelFactory
will be removed as service from the Lucy back-end (seeILcyLucyEnv.removeService(Object)
).
Note: it is only possible to removeILcdModelFactory
instances which were registered using theaddModelFactory(com.luciad.model.ILcdModelFactory)
method.- Parameters:
aModelFactory
- The model factory to remove. Must not benull
.- See Also:
-
getModelFactoryCount
public int getModelFactoryCount()Returns the number of currently registered model factories.
- Returns:
- the number of currently registered model factories.
- See Also:
-
getModelFactory
Returns the model factory at the given index.- Parameters:
aIndex
- The index to retrieve the model factory for. Note that0 <= aIndex < getModelFactoryCount()
- Returns:
- The model factory at the given index.
- See Also:
-
createModel
public ILcdModel createModel(ILcdModelDescriptor aModelDescriptor, ILcdModelReference aModelReference) throws IllegalArgumentException Implementation of ILcdModelFactory#createModel. It loops over all registeredILcdModelFactory
s and tries to find a suitableILcdModelFactory
. Suitable means that theILcdModelFactory
does not throw anIllegalArgumentException
. TheILcdModel
of the first suitableILcdModelFactory
is returned, or anIllegalArgumentException
is thrown when no suitableILcdModelFactory
could be found.- Specified by:
createModel
in interfaceILcdModelFactory
- Parameters:
aModelDescriptor
- The model descriptor.aModelReference
- The model reference. This parameter can be leftnull
to get a default model reference (for example WGS84, but it depends on the implementation).- Returns:
- The newly created
ILcdModel
, nevernull
. - Throws:
IllegalArgumentException
- If noILcdModel
can be created for the given parameters, for example because theILcdModelDescriptor
is of the incorrect type.
-