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
ConstructorsConstructorDescriptionDefault constructor.TLcyCompositeModelFactory(ILcyLucyEnv aLucyEnv) Construct aTLcyCompositeModelFactoryworking on the Lucy back-end. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddModelFactory(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.intReturns the number of currently registered model factories.voidremoveModelFactory(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, removeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
TLcyCompositeModelFactory
public TLcyCompositeModelFactory()Default constructor.
The created instance will only work on the
ILcdModelFactoryinstances registered to it. If you want to use all registeredILcdModelFactoryinstances of the Lucy back-end, useTLcyCompositeModelFactory(com.luciad.lucy.ILcyLucyEnv)instead.- See Also:
-
TLcyCompositeModelFactory
Construct a
TLcyCompositeModelFactoryworking on the Lucy back-end.It will use all
ILcdModelFactoryinstances registered to the back-end, and adding and/or removingILcdModelFactorys to/from thisTLcyCompositeModelFactorywill respectively add/remove it as service from the back-end.If you want to create a
TLcyCompositeModelFactorywhich 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
ILcyLucyEnvis used, theILcdModelFactorywill be registered as a service on the Lucy back-end (seeILcyLucyEnv.addService(Object, int)). When callingILcyLucyEnv.getServices(Class)afterwards,aModelFactorywill only be included in the returned list when the requested class wasILcdModelFactory.class.
Note: if you want to remove the registeredILcdModelFactoryafterwards, 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
ILcyLucyEnvis used, theILcdModelFactorywill be removed as service from the Lucy back-end (seeILcyLucyEnv.removeService(Object)).
Note: it is only possible to removeILcdModelFactoryinstances 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 registeredILcdModelFactorys and tries to find a suitableILcdModelFactory. Suitable means that theILcdModelFactorydoes not throw anIllegalArgumentException. TheILcdModelof the first suitableILcdModelFactoryis returned, or anIllegalArgumentExceptionis thrown when no suitableILcdModelFactorycould be found.- Specified by:
createModelin interfaceILcdModelFactory- Parameters:
aModelDescriptor- The model descriptor.aModelReference- The model reference. This parameter can be leftnullto get a default model reference (for example WGS84, but it depends on the implementation).- Returns:
- The newly created
ILcdModel, nevernull. - Throws:
IllegalArgumentException- If noILcdModelcan be created for the given parameters, for example because theILcdModelDescriptoris of the incorrect type.
-