Class TLcyCompositeModelReferenceDecoder
- All Implemented Interfaces:
ILcdModelReferenceDecoder
,Iterable<ILcdModelReferenceDecoder>
Composite implementation (see composite design pattern) of ILcdModelReferenceDecoder
.
It keeps a list of associated ILcdModelReferenceDecoder
s. When it is asked to decode
a model reference, it loops over its associated ILcdModelReferenceDecoder
s to find
one that does not return null, or that does not throw an exception. The model reference provided
by that decoder is then returned.
When creating a new TLcyCompositeModelReferenceDecoder
using the default
constructor (see TLcyCompositeModelReferenceDecoder()
), the created instance will
only work on/with the ILcdModelReferenceDecoders registered
on this composite instance (see addModelReferenceDecoder(com.luciad.model.ILcdModelReferenceDecoder)
and removeModelReferenceDecoder(com.luciad.model.ILcdModelReferenceDecoder)
).
When creating a new TLcyCompositeModelReferenceDecoder
using the constructor
specifying an ILcyLucyEnv
instance (see TLcyCompositeModelReferenceDecoder(com.luciad.lucy.ILcyLucyEnv)
, the created instance will
work on the Lucy back-end services. It will use
all registered ILcdModelReferenceDecoder instances of the
Lucy back-end, adding and/or removing an ILcdModelReferenceDecoder
will
add/remove the ILcdModelReferenceDecoder
as service from Lucy, ... .
Decoding an ILcdModelReference
for a source name 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.
TLcyCompositeModelReferenceDecoder decoder = new TLcyCompositeModelReferenceDecoder( aLucyEnv );
try{
ILcdModelReference modelReference = decoder.decodeModelReference( aSourceName );
} catch ( IOException aException ){
//exception occurred during the 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
provider = null;
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.luciad.model.ILcdModelReferenceDecoder
ILcdModelReferenceDecoder.ModelReferenceWithSource
-
Field Summary
Fields inherited from class com.luciad.lucy.util.TLcyGenericComposite
PRIORITY_DEFAULT, PRIORITY_FALLBACK
-
Constructor Summary
ConstructorDescriptionDefault constructor.Construct aTLcyCompositeModelReferenceDecoder
working on the Lucy back-end -
Method Summary
Modifier and TypeMethodDescriptionvoid
addModelReferenceDecoder
(ILcdModelReferenceDecoder aModelReferenceDecoder) Adds the given model reference decoder to the list of model reference decoders.decodeModelReference
(String aSourceName) Implementation of ILcdModelReferenceDecoder.decodeModelReference.getModelReferenceDecoder
(int aIndex) Returns the model reference decoder at the given index.int
Returns the number of model reference decoders currently in this container.void
removeModelReferenceDecoder
(ILcdModelReferenceDecoder aModelReferenceDecoder) Removes the given model reference decoder from the list.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 com.luciad.model.ILcdModelReferenceDecoder
findAndDecodeModelReference
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
TLcyCompositeModelReferenceDecoder
public TLcyCompositeModelReferenceDecoder()Default constructor.
The created instance will only work on the
ILcdModelReferenceDecoder
instances registered to it. If you want to use all registeredILcdModelReferenceDecoder
instances of the Lucy back-end, useTLcyCompositeModelReferenceDecoder(com.luciad.lucy.ILcyLucyEnv)
instead.- See Also:
-
TLcyCompositeModelReferenceDecoder
Construct a
TLcyCompositeModelReferenceDecoder
working on the Lucy back-endIt will use all
ILcdModelReferenceDecoder
instances registered to the back-end, and adding and/or removingILcdModelReferenceDecoder
s to/from thisTLcyCompositeModelReferenceDecoder
will respectively add/remove it as service from the back-end.If you want to create a
TLcyCompositeModelReferenceDecoder
which does not use the back-end, useTLcyCompositeModelReferenceDecoder()
instead.- Parameters:
aLucyEnv
- The Lucy back-end.- See Also:
-
-
Method Details
-
addModelReferenceDecoder
Adds the given model reference decoder to the list of model reference decoders.
If the constructor specifying an
ILcyLucyEnv
is used, theILcdModelReferenceDecoder
will be registered as a service on the Lucy back-end (seeILcyLucyEnv.addService(Object, int)
). When callingILcyLucyEnv.getServices(Class)
afterwards,aModelReferenceDecoder
will only be included in the returned list when the requested class wasILcdModelReferenceDecoder.class
.
Note: if you want to remove the registeredILcdModelReferenceDecoder
afterwards, useremoveModelReferenceDecoder(com.luciad.model.ILcdModelReferenceDecoder)
and notILcyLucyEnv.removeService(Object)
.- Parameters:
aModelReferenceDecoder
- The model reference decoder to add.- See Also:
-
removeModelReferenceDecoder
Removes the given model reference decoder from the list. Does nothing if the given decoder is not in this list.
If the constructor specifying an
ILcyLucyEnv
is used, theILcdModelReferenceDecoder
will be removed as service from the Lucy back-end (seeILcyLucyEnv.removeService(Object)
).
Note: it is only possible to removeILcdModelReferenceDecoder
instances which were registered using theaddModelReferenceDecoder(com.luciad.model.ILcdModelReferenceDecoder)
method.- Parameters:
aModelReferenceDecoder
- The model reference decoder to remove.- See Also:
-
getModelReferenceDecoderCount
public int getModelReferenceDecoderCount()Returns the number of model reference decoders currently in this container.- Returns:
- the number of model reference decoders currently in this container.
- See Also:
-
getModelReferenceDecoder
Returns the model reference decoder at the given index.- Parameters:
aIndex
- The index of the asked model reference decoder. Make sure 0 <= aIndex < getModelReferenceDecoderCount()- Returns:
- The model reference decoder at the given index.
- See Also:
-
decodeModelReference
Implementation of ILcdModelReferenceDecoder.decodeModelReference. It loops over all addedILcdModelReferenceDecoder
s and tries to decode a model reference. The model reference decoded by the first decoder that does not return null and does not throw an IOException is returned.- Specified by:
decodeModelReference
in interfaceILcdModelReferenceDecoder
- Parameters:
aSourceName
- The source name to decode a model reference for.- Returns:
- The model reference decoded by the first suitable
ILcdModelReferenceDecoder
, - Throws:
IOException
- if theILcdModelReference
cannot be decoded.
When the thread on which this method is called is interrupted, it is recommended to stop the decoding and throw anInterruptedIOException
. This same exception can also be used if the decoder shows UI to the user, and the user cancels the decoding through the UI.
-