Class TLcyCompositeModelFactory

java.lang.Object
com.luciad.lucy.util.TLcyGenericComposite<ILcdModelFactory>
com.luciad.lucy.model.TLcyCompositeModelFactory
All Implemented Interfaces:
ILcdModelFactory, Iterable<ILcdModelFactory>

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;
 
Since:
10.0
  • Constructor Details

  • Method Details

    • addModelFactory

      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).

      Parameters:
      aModelFactory - The model factory to add. Must not be null.
      See Also:
    • removeModelFactory

      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.

      Parameters:
      aModelFactory - The model factory to remove. Must not be null.
      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

      public ILcdModelFactory getModelFactory(int aIndex)
      Returns the model factory at the given index.
      Parameters:
      aIndex - The index to retrieve the model factory for. Note that 0 <= 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 registered ILcdModelFactorys 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.
      Specified by:
      createModel in interface ILcdModelFactory
      Parameters:
      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).
      Returns:
      The newly created ILcdModel, never null.
      Throws:
      IllegalArgumentException - If no ILcdModel can be created for the given parameters, for example because the ILcdModelDescriptor is of the incorrect type.