Class TLcyCompositeGXYLayerEncoder

All Implemented Interfaces:
ILcdGXYLayerEncoder, Iterable<TLcyGXYLayerEncoderHolder>

public class TLcyCompositeGXYLayerEncoder extends TLcyGenericComposite<TLcyGXYLayerEncoderHolder> implements ILcdGXYLayerEncoder

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

When creating a new TLcyCompositeGXYLayerEncoder using the default constructor (see TLcyCompositeGXYLayerEncoder(), the created instance will only work on/with the ILcdGXYLayerEncoders registered on this composite instance (see addGXYLayerEncoder(com.luciad.view.gxy.ILcdGXYLayerEncoder, com.luciad.lucy.model.ALcyFileTypeDescriptor) and removeGXYLayerEncoder(com.luciad.view.gxy.ILcdGXYLayerEncoder).

When creating a new TLcyCompositeGXYLayerEncoder using the constructor specifying an ILcyLucyEnv instance (see TLcyCompositeGXYLayerEncoder(com.luciad.lucy.ILcyLucyEnv), the created instance will work on the Lucy back-end services. It will use all registered ILcdGXYLayerEncoder instances of the Lucy back-end, adding and/or removing an ILcdGXYLayerEncoder will add/remove the ILcdGXYLayerEncoder 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
 TLcyCompositeGXYLayerEncoder encoder = new TLcyCompositeGXYLayerEncoder( aLucyEnv );
 if ( encoder.canEncodeGXYLayer( aGXYLayer, aDestinationName ) ){
   try{
     encoder.encodeGXYLayer( aGXYLayer, aDestinationName )
   } catch ( IOException aIOException ){
     //IOException during encoding
   }
 }
 //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
 encoder = null;
 

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

See Also: