public class TLcyCompositeGXYLayerDecoder extends TLcyGenericComposite<TLcyGXYLayerDecoderHolder> implements ILcdGXYLayerDecoder
Composite implementation (see composite design pattern) of ILcdGXYLayerDecoder
. It
keeps a list of associated ILcdGXYLayerDecoder
s. When it is asked to create a layer,
it loops over its associated ILcdGXYLayerDecoder
s 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 ILcdGXYLayerDecoder
s 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 .
TLcyGXYLayerDecoderHolder
PRIORITY_DEFAULT, PRIORITY_FALLBACK
Constructor and Description |
---|
TLcyCompositeGXYLayerDecoder()
Default constructor.
|
TLcyCompositeGXYLayerDecoder(ILcyLucyEnv aLucyEnv)
Construct a
TLcyCompositeGXYLayerDecoder working on the Lucy back-end. |
Modifier and Type | Method and Description |
---|---|
void |
addGXYLayerDecoder(ILcdGXYLayerDecoder aGXYLayerDecoder,
ALcyFileTypeDescriptor aFileTypeDescriptor)
Adds the given
ILcdGXYLayerDecoder to the list of associated
ILcdGXYLayerDecoder s. |
boolean |
canDecodeGXYLayer(ILcdModel aModel,
String aSourceName)
Loops over its list of associated
ILcdGXYLayerDecoder s to find a suitable
ILcdGXYLayerDecoder . |
ILcdGXYLayer |
decodeGXYLayer(ILcdModel aModel,
String aSourceName)
Loops over its associated list of
ILcdGXYLayerDecoder s to find a suitable
ILcdGXYLayerDecoder . |
String |
getDisplayName()
Returns the display name of this encoder.
|
ALcyFileTypeDescriptor |
getFileTypeDescriptor(int aIndex)
Retrieves the layer decoder file type descriptor at the given index.
|
ILcdGXYLayerDecoder |
getGXYLayerDecoder(int aIndex)
Returns the
ILcdGXYLayerDecoder at the given index. |
int |
getGXYLayerDecoderCount()
Returns the number of
ILcdGXYLayerDecoder s. |
void |
removeGXYLayerDecoder(ILcdGXYLayerDecoder aGXYLayerDecoder)
Removes the given
ILcdGXYLayerDecoder from the list of associated
ILcdGXYLayerDecoder s. |
void |
setDisplayName(String aDisplayName)
Sets the display name of this decoder.
|
add, add, getList, getPriority, iterator, remove
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public TLcyCompositeGXYLayerDecoder()
Default constructor. No ILcdGXYLayerDecoder
s are associated.
The created instance will only work on the ILcdGXYLayerDecoder
instances
registered to it. If you want to use all registered ILcdGXYLayerDecoder
instances
of the Lucy back-end, use TLcyCompositeGXYLayerDecoder(com.luciad.lucy.ILcyLucyEnv)
instead.
public TLcyCompositeGXYLayerDecoder(ILcyLucyEnv aLucyEnv)
Construct a TLcyCompositeGXYLayerDecoder
working on the Lucy back-end.
It will use all ILcdGXYLayerDecoder
instances registered to the back-end, and
adding and/or removing ILcdGXYLayerDecoder
s to/from this
TLcyCompositeGXYLayerDecoder
will respectively add/remove it as service from the
back-end.
If you want to create a TLcyCompositeGXYLayerDecoder
which does not use the
back-end, use TLcyCompositeGXYLayerDecoder()
instead.
aLucyEnv
- The Lucy back-end.TLcyCompositeGXYLayerDecoder()
,
ILcyLucyEnv.addService(Object, int)
,
ILcyLucyEnv.removeService(Object)
public void addGXYLayerDecoder(ILcdGXYLayerDecoder aGXYLayerDecoder, ALcyFileTypeDescriptor aFileTypeDescriptor)
Adds the given ILcdGXYLayerDecoder
to the list of associated
ILcdGXYLayerDecoder
s.
If the constructor specifying an ILcyLucyEnv
is used, the
ALcyFileTypeDescriptor
and its associated ILcdGXYLayerDecoder
will be
registered on the Lucy back-end (see ILcyLucyEnv.addService(Object,
int)
by using an TLcyGXYLayerDecoderHolder
. When calling ILcyLucyEnv.getServices(Class)
afterwards, the holder objects will only be
returned when the requested class was TLcyGXYLayerDecoderHolder.class
.
Note: if you want to remove the registered ALcyFileTypeDescriptor
and its
associated ILcdGXYLayerDecoder
, use removeGXYLayerDecoder(com.luciad.view.gxy.ILcdGXYLayerDecoder)
and not ILcyLucyEnv.removeService(Object)
.
aGXYLayerDecoder
- The ILcdGXYLayerDecoder
to addaFileTypeDescriptor
- The file type descriptor describing which files this decoder can
handle.removeGXYLayerDecoder(com.luciad.view.gxy.ILcdGXYLayerDecoder)
public void removeGXYLayerDecoder(ILcdGXYLayerDecoder aGXYLayerDecoder)
Removes the given ILcdGXYLayerDecoder
from the list of associated
ILcdGXYLayerDecoder
s. Has no effect if the given ILcdGXYLayerDecoder
was never added. The corresponding ALcyFileTypeDescriptor
is also removed.
If the constructor specifying an ILcyLucyEnv
is used, the
TLcyGXYLayerDecoderHolder
object containing the ILcdGXYLayerDecoder
aGXYLayerDecoder
will be removed as service from the Lucy back-end (see ILcyLucyEnv.removeService(Object)
).
Note: it is only possible to remove TLcyGXYLayerDecoderHolder
instances
which were registered using the addGXYLayerDecoder(com.luciad.view.gxy.ILcdGXYLayerDecoder,
com.luciad.lucy.model.ALcyFileTypeDescriptor)
method.
aGXYLayerDecoder
- The ILcdGXYLayerDecoder
to remove.addGXYLayerDecoder(com.luciad.view.gxy.ILcdGXYLayerDecoder, com.luciad.lucy.model.ALcyFileTypeDescriptor)
public int getGXYLayerDecoderCount()
ILcdGXYLayerDecoder
s.ILcdGXYLayerDecoder
s.getGXYLayerDecoder(int)
public ILcdGXYLayerDecoder getGXYLayerDecoder(int aIndex)
ILcdGXYLayerDecoder
at the given index.aIndex
- The index to retrieve the ILcdGXYLayerDecoder
at. 0 <= aIndex
< getGXYLayerDecoderCount()
ILcdGXYLayerDecoder
at the given index.getGXYLayerDecoderCount()
public ALcyFileTypeDescriptor getFileTypeDescriptor(int aIndex)
aIndex
- The index to retrieve the layer decoder file type descriptor for.getGXYLayerDecoderCount()
public String getDisplayName()
ILcdGXYLayerDecoder
getDisplayName
in interface ILcdGXYLayerDecoder
public void setDisplayName(String aDisplayName)
aDisplayName
- The new display name.getDisplayName()
public boolean canDecodeGXYLayer(ILcdModel aModel, String aSourceName)
ILcdGXYLayerDecoder
s to find a suitable
ILcdGXYLayerDecoder
. Suitable means that canDecodeSource returns true. This method
returns true if it can find such a suitable ILcdGXYLayerDecoder
, false otherwise.canDecodeGXYLayer
in interface ILcdGXYLayerDecoder
aModel
- The model for the decoded layer.aSourceName
- The name of the source to decode.ILcdGXYLayerDecoder
could be found, false otherwise.ILcdGXYLayerDecoder.decodeGXYLayer(com.luciad.model.ILcdModel, java.lang.String)
public ILcdGXYLayer decodeGXYLayer(ILcdModel aModel, String aSourceName) throws IOException
ILcdGXYLayerDecoder
s to find a suitable
ILcdGXYLayerDecoder
. Suitable means that canDecodeGXYLayer returns true.
The first suitable ILcdGXYLayerDecoder
is used to decode the given source.
decodeGXYLayer
in interface ILcdGXYLayerDecoder
aModel
- The model for the decoded layer.aSourceName
- The name of the source to decode.ILcdGXYLayerDecoder
, or null if no
suitable decoder could be found or if the user aborted the operation.IOException
- In case of io failure.ILcdGXYLayerDecoder.canDecodeGXYLayer(com.luciad.model.ILcdModel, java.lang.String)