Class TLcyCompositeGXYLayerDecoder

All Implemented Interfaces:
ILcdGXYLayerDecoder, Iterable<TLcyGXYLayerDecoderHolder>

public class TLcyCompositeGXYLayerDecoder extends TLcyGenericComposite<TLcyGXYLayerDecoderHolder> implements ILcdGXYLayerDecoder

Composite implementation (see composite design pattern) of ILcdGXYLayerDecoder. It keeps a list of associated ILcdGXYLayerDecoders. When it is asked to create a layer, it loops over its associated ILcdGXYLayerDecoders to find a suitable ILcdGXYLayerDecoder. That ILcdGXYLayerDecoder is asked to create a layer.

When creating a new TLcyCompositeGXYLayerDecoder using the default constructor (see TLcyCompositeGXYLayerDecoder(), the created instance will only work on/with the ILcdGXYLayerDecoders registered on this composite instance (see addGXYLayerDecoder(com.luciad.view.gxy.ILcdGXYLayerDecoder, com.luciad.lucy.model.ALcyFileTypeDescriptor) and removeGXYLayerDecoder(com.luciad.view.gxy.ILcdGXYLayerDecoder).

When creating a new TLcyCompositeGXYLayerDecoder using the constructor specifying an ILcyLucyEnv instance (see TLcyCompositeGXYLayerDecoder(com.luciad.lucy.ILcyLucyEnv), the created instance will work on the Lucy back-end services. It will use all registered ILcdGXYLayerDecoder instances of the Lucy back-end, adding and/or removing an ILcdGXYLayerDecoder will add/remove the ILcdGXYLayerDecoder as service from Lucy, ... .

Decoding an ILcdGXYlayer 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
 TLcyCompositeGXYLayerDecoder decoder = new TLcyCompositeGXYLayerDecoder( aLucyEnv );
 if ( decoder.canDecodeGXYLayer( aModel, aSourceName ) ){
   try{
     ILcdGXYLayer layer = decoder.decodeGXYLayer( aModel, aSourceName );
   } catch ( IOException aIOException ){
     //IOException during decoding
   }
 }
 //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
 decoder = null;
 

Note: the ILcdGXYLayerDecoders are not directly registered as service to Lucy, but wrapped with a holder object. This holder object allows to register the ILcdGXYLayerDecoder with some extra information like e.g. an ALcyFileTypeDescriptor. Using a back-end based TLcyCompositeGXYLayerDecoder will only use the registered TLcyGXYLayerDecoderHolder objects, and not for example an ILcdGXYLayerDecoder which was directly (=not wrapped) registered as a service .

See Also: