Class TLcyCompositeGXYLayerDecoder
- All Implemented Interfaces:
ILcdGXYLayerDecoder
,Iterable<TLcyGXYLayerDecoderHolder>
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 .
- See Also:
-
Field Summary
Fields inherited from class com.luciad.lucy.util.TLcyGenericComposite
PRIORITY_DEFAULT, PRIORITY_FALLBACK
-
Constructor Summary
ConstructorDescriptionDefault constructor.TLcyCompositeGXYLayerDecoder
(ILcyLucyEnv aLucyEnv) Construct aTLcyCompositeGXYLayerDecoder
working on the Lucy back-end. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addGXYLayerDecoder
(ILcdGXYLayerDecoder aGXYLayerDecoder, ALcyFileTypeDescriptor aFileTypeDescriptor) Adds the givenILcdGXYLayerDecoder
to the list of associatedILcdGXYLayerDecoder
s.boolean
canDecodeGXYLayer
(ILcdModel aModel, String aSourceName) Loops over its list of associatedILcdGXYLayerDecoder
s to find a suitableILcdGXYLayerDecoder
.decodeGXYLayer
(ILcdModel aModel, String aSourceName) Loops over its associated list ofILcdGXYLayerDecoder
s to find a suitableILcdGXYLayerDecoder
.Returns the display name of this encoder.getFileTypeDescriptor
(int aIndex) Retrieves the layer decoder file type descriptor at the given index.getGXYLayerDecoder
(int aIndex) Returns theILcdGXYLayerDecoder
at the given index.int
Returns the number ofILcdGXYLayerDecoder
s.void
removeGXYLayerDecoder
(ILcdGXYLayerDecoder aGXYLayerDecoder) Removes the givenILcdGXYLayerDecoder
from the list of associatedILcdGXYLayerDecoder
s.void
setDisplayName
(String aDisplayName) Sets the display name of this decoder.Methods inherited from class com.luciad.lucy.util.TLcyGenericComposite
add, add, getList, getPriority, iterator, remove
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
TLcyCompositeGXYLayerDecoder
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 registeredILcdGXYLayerDecoder
instances of the Lucy back-end, useTLcyCompositeGXYLayerDecoder(com.luciad.lucy.ILcyLucyEnv)
instead. -
TLcyCompositeGXYLayerDecoder
Construct a
TLcyCompositeGXYLayerDecoder
working on the Lucy back-end.It will use all
ILcdGXYLayerDecoder
instances registered to the back-end, and adding and/or removingILcdGXYLayerDecoder
s to/from thisTLcyCompositeGXYLayerDecoder
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, useTLcyCompositeGXYLayerDecoder()
instead.- Parameters:
aLucyEnv
- The Lucy back-end.- See Also:
-
-
Method Details
-
addGXYLayerDecoder
public void addGXYLayerDecoder(ILcdGXYLayerDecoder aGXYLayerDecoder, ALcyFileTypeDescriptor aFileTypeDescriptor) Adds the given
ILcdGXYLayerDecoder
to the list of associatedILcdGXYLayerDecoder
s.If the constructor specifying an
ILcyLucyEnv
is used, theALcyFileTypeDescriptor
and its associatedILcdGXYLayerDecoder
will be registered on the Lucy back-end (seeILcyLucyEnv.addService(Object, int)
by using anTLcyGXYLayerDecoderHolder
. When callingILcyLucyEnv.getServices(Class)
afterwards, the holder objects will only be returned when the requested class wasTLcyGXYLayerDecoderHolder.class
.
Note: if you want to remove the registeredALcyFileTypeDescriptor
and its associatedILcdGXYLayerDecoder
, useremoveGXYLayerDecoder(com.luciad.view.gxy.ILcdGXYLayerDecoder)
and notILcyLucyEnv.removeService(Object)
.- Parameters:
aGXYLayerDecoder
- TheILcdGXYLayerDecoder
to addaFileTypeDescriptor
- The file type descriptor describing which files this decoder can handle.- See Also:
-
removeGXYLayerDecoder
Removes the given
ILcdGXYLayerDecoder
from the list of associatedILcdGXYLayerDecoder
s. Has no effect if the givenILcdGXYLayerDecoder
was never added. The correspondingALcyFileTypeDescriptor
is also removed.If the constructor specifying an
ILcyLucyEnv
is used, theTLcyGXYLayerDecoderHolder
object containing theILcdGXYLayerDecoder
aGXYLayerDecoder
will be removed as service from the Lucy back-end (seeILcyLucyEnv.removeService(Object)
).
Note: it is only possible to removeTLcyGXYLayerDecoderHolder
instances which were registered using theaddGXYLayerDecoder(com.luciad.view.gxy.ILcdGXYLayerDecoder, com.luciad.lucy.model.ALcyFileTypeDescriptor)
method.- Parameters:
aGXYLayerDecoder
- TheILcdGXYLayerDecoder
to remove.- See Also:
-
getGXYLayerDecoderCount
public int getGXYLayerDecoderCount()Returns the number ofILcdGXYLayerDecoder
s.- Returns:
- the number of
ILcdGXYLayerDecoder
s. - See Also:
-
getGXYLayerDecoder
Returns theILcdGXYLayerDecoder
at the given index.- Parameters:
aIndex
- The index to retrieve theILcdGXYLayerDecoder
at. 0 <= aIndex <getGXYLayerDecoderCount()
- Returns:
- the
ILcdGXYLayerDecoder
at the given index. - See Also:
-
getFileTypeDescriptor
Retrieves the layer decoder file type descriptor at the given index. This descriptor is null if the decoder was added with null as a descriptor.- Parameters:
aIndex
- The index to retrieve the layer decoder file type descriptor for.- Returns:
- the layer decoder file type descriptor at the given index.
- See Also:
-
getDisplayName
Description copied from interface:ILcdGXYLayerDecoder
Returns the display name of this encoder.- Specified by:
getDisplayName
in interfaceILcdGXYLayerDecoder
- Returns:
- the display name of this encoder.
-
setDisplayName
Sets the display name of this decoder.- Parameters:
aDisplayName
- The new display name.- See Also:
-
canDecodeGXYLayer
Loops over its list of associatedILcdGXYLayerDecoder
s to find a suitableILcdGXYLayerDecoder
. Suitable means that canDecodeSource returns true. This method returns true if it can find such a suitableILcdGXYLayerDecoder
, false otherwise.- Specified by:
canDecodeGXYLayer
in interfaceILcdGXYLayerDecoder
- Parameters:
aModel
- The model for the decoded layer.aSourceName
- The name of the source to decode.- Returns:
- True if a suitable
ILcdGXYLayerDecoder
could be found, false otherwise. - See Also:
-
decodeGXYLayer
Loops over its associated list ofILcdGXYLayerDecoder
s to find a suitableILcdGXYLayerDecoder
. Suitable means that canDecodeGXYLayer returns true.The first suitable
ILcdGXYLayerDecoder
is used to decode the given source.- Specified by:
decodeGXYLayer
in interfaceILcdGXYLayerDecoder
- Parameters:
aModel
- The model for the decoded layer.aSourceName
- The name of the source to decode.- Returns:
- The layer decoded by the first suitable
ILcdGXYLayerDecoder
, or null if no suitable decoder could be found or if the user aborted the operation. - Throws:
IOException
- In case of io failure.- See Also:
-