public class TLcyCompositeModelReferenceDecoder extends TLcyGenericComposite<ILcdModelReferenceDecoder> implements 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;
ILcdModelReferenceDecoder.ModelReferenceWithSource
PRIORITY_DEFAULT, PRIORITY_FALLBACK
Constructor and Description |
---|
TLcyCompositeModelReferenceDecoder()
Default constructor.
|
TLcyCompositeModelReferenceDecoder(ILcyLucyEnv aLucyEnv)
Construct a
TLcyCompositeModelReferenceDecoder working on the Lucy back-end |
Modifier and Type | Method and Description |
---|---|
void |
addModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
Adds the given model reference decoder to the list of model reference decoders.
|
ILcdModelReference |
decodeModelReference(String aSourceName)
Implementation of ILcdModelReferenceDecoder.decodeModelReference.
|
ILcdModelReferenceDecoder |
getModelReferenceDecoder(int aIndex)
Returns the model reference decoder at the given index.
|
int |
getModelReferenceDecoderCount()
Returns the number of model reference decoders currently in this container.
|
void |
removeModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
Removes the given model reference decoder from the list.
|
add, add, getList, getPriority, iterator, remove
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
findAndDecodeModelReference
forEach, spliterator
public TLcyCompositeModelReferenceDecoder()
Default constructor.
The created instance will only work on the ILcdModelReferenceDecoder
instances
registered to it. If you want to use all registered ILcdModelReferenceDecoder
instances of the Lucy back-end, use TLcyCompositeModelReferenceDecoder(com.luciad.lucy.ILcyLucyEnv)
instead.
public TLcyCompositeModelReferenceDecoder(ILcyLucyEnv aLucyEnv)
Construct a TLcyCompositeModelReferenceDecoder
working on the Lucy back-end
It will use all ILcdModelReferenceDecoder
instances registered to the back-end,
and adding and/or removing ILcdModelReferenceDecoder
s to/from this
TLcyCompositeModelReferenceDecoder
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, use TLcyCompositeModelReferenceDecoder()
instead.
aLucyEnv
- The Lucy back-end.TLcyCompositeModelReferenceDecoder()
,
ILcyLucyEnv.addService(Object, int)
,
ILcyLucyEnv.removeService(Object)
public void addModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
Adds the given model reference decoder to the list of model reference decoders.
If the constructor specifying an ILcyLucyEnv
is used, the
ILcdModelReferenceDecoder
will be registered as a service on the Lucy back-end
(see ILcyLucyEnv.addService(Object, int)
). When calling ILcyLucyEnv.getServices(Class)
afterwards, aModelReferenceDecoder
will only be included in the returned list when the requested class was
ILcdModelReferenceDecoder.class
.
Note: if you want to remove the registered ILcdModelReferenceDecoder
afterwards, use removeModelReferenceDecoder(com.luciad.model.ILcdModelReferenceDecoder)
and not ILcyLucyEnv.removeService(Object)
.
aModelReferenceDecoder
- The model reference decoder to add.removeModelReferenceDecoder(com.luciad.model.ILcdModelReferenceDecoder)
public void removeModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
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, the
ILcdModelReferenceDecoder
will be removed as service from the Lucy back-end (see
ILcyLucyEnv.removeService(Object)
).
Note: it is only possible to remove ILcdModelReferenceDecoder
instances which
were registered using the addModelReferenceDecoder(com.luciad.model.ILcdModelReferenceDecoder)
method.
aModelReferenceDecoder
- The model reference decoder to remove.addModelReferenceDecoder(com.luciad.model.ILcdModelReferenceDecoder)
public int getModelReferenceDecoderCount()
getModelReferenceDecoder(int)
public ILcdModelReferenceDecoder getModelReferenceDecoder(int aIndex)
aIndex
- The index of the asked model reference decoder. Make sure 0 <= aIndex <
getModelReferenceDecoderCount()getModelReferenceDecoderCount()
public ILcdModelReference decodeModelReference(String aSourceName) throws IOException
ILcdModelReferenceDecoder
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.decodeModelReference
in interface ILcdModelReferenceDecoder
aSourceName
- The source name to decode a model reference for.ILcdModelReferenceDecoder
,IOException
- if the ILcdModelReference
cannot be decoded.
InterruptedIOException
.
This same exception can also be used if the decoder shows UI to the user, and the user cancels the decoding
through the UI.