Package com.luciad.model
Class TLcdCompositeModelReferenceDecoder
java.lang.Object
com.luciad.model.TLcdCompositeModelReferenceDecoder
- All Implemented Interfaces:
ILcdInputStreamFactoryCapable
,ILcdModelReferenceDecoder
public final class TLcdCompositeModelReferenceDecoder
extends Object
implements ILcdModelReferenceDecoder, ILcdInputStreamFactoryCapable
Composite implementation of ILcdModelReferenceDecoder
.
Any number of model reference decoders can be added to this composite.
The decodeModelReference(String)
delegates, in order, to the decoders in the list.
See the decodeModelReference(String)
for details.
Example usage:
To create a composite instance which uses all default availableILcdModelReferenceDecoder
instances, you can use:
ILcdModelReferenceDecoder referenceDecoder =
new TLcdCompositeModelReferenceDecoder(TLcdServiceLoader.getInstance(ILcdModelReferenceDecoder.class));
@LcdService
annotation.
As this is the case for the default available reference decoders,
you end up with a decoder which can decode *.epsg
, *.prj
, *_rpc.txt
and *.ref
files.- Since:
- 2018.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.luciad.model.ILcdModelReferenceDecoder
ILcdModelReferenceDecoder.ModelReferenceWithSource
-
Constructor Summary
ConstructorDescriptionCreates a new, empty composite model reference decoder.TLcdCompositeModelReferenceDecoder
(ILcdModelReferenceDecoder... aModelReferenceDecoders) Creates a new composite model reference decoder containing the supplied delegatesTLcdCompositeModelReferenceDecoder
(Iterable<? extends ILcdModelReferenceDecoder> aModelReferenceDecoders) Creates a new composite model reference decoder that lazily uses the givenIterable
to delegate to. -
Method Summary
Modifier and TypeMethodDescriptiondecodeModelReference
(String aDataSourceName) Returns the model reference, associated with the specified data source.findAndDecodeModelReference
(String aDataSourceName) Finds and decodes the model reference file, associated with the specified data source.Returns the input stream factory that is used.Returns the list of delegate model reference decoders contained in this composite.void
setInputStreamFactory
(ILcdInputStreamFactory aInputStreamFactory) If not null, overrides the input stream factory of the contained model decoders with the given factory.
-
Constructor Details
-
TLcdCompositeModelReferenceDecoder
public TLcdCompositeModelReferenceDecoder()Creates a new, empty composite model reference decoder. This decoder will not be able to decode any model references until delegate model reference decoders are added to themodel reference decoders list
. -
TLcdCompositeModelReferenceDecoder
public TLcdCompositeModelReferenceDecoder(Iterable<? extends ILcdModelReferenceDecoder> aModelReferenceDecoders) Creates a new composite model reference decoder that lazily uses the givenIterable
to delegate to.- Parameters:
aModelReferenceDecoders
- anIterable
of model reference decoders
-
TLcdCompositeModelReferenceDecoder
Creates a new composite model reference decoder containing the supplied delegates- Parameters:
aModelReferenceDecoders
- delegate model reference decoders to be added to the composite
-
-
Method Details
-
getModelReferenceDecoders
Returns the list of delegate model reference decoders contained in this composite. If this instance was constructed using anIterable
, the returned list is unmodifiable. If not, delegates can be added or removed by modifying this list.- Returns:
- the list of the delegate model reference decoders in this composite
-
decodeModelReference
Returns the model reference, associated with the specified data source. Notes:- Tries all delegate decoders in order
- The first successfully created non-null model reference is returned.
- If no decoder can decode the reference,an
IOException
is thrown. - If a delegate decoder throws a
InterruptedIOException
, the decoding stops and that error is re-thrown.
- Specified by:
decodeModelReference
in interfaceILcdModelReferenceDecoder
- Parameters:
aDataSourceName
- a data source for which to return the model reference; typically a file name or a URL.- Returns:
- the
ILcdModelReference
associated with the data source. Whilenull
is allowed, implementors are advised to throw an error instead. - 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.
-
findAndDecodeModelReference
public ILcdModelReferenceDecoder.ModelReferenceWithSource findAndDecodeModelReference(String aDataSourceName) throws IOException Finds and decodes the model reference file, associated with the specified data source. The default implementation delegates toILcdModelReferenceDecoder.decodeModelReference(java.lang.String)
and returns the resulting model reference, paired with anull
source, indicating that the source is unknown or does not exist. Notes:- Tries all delegate decoders in order
- The first successfully created non-null model reference is returned.
- If no decoder can decode the reference,an
IOException
is thrown. - If a delegate decoder throws a
InterruptedIOException
, the decoding stops and that error is re-thrown.
- Specified by:
findAndDecodeModelReference
in interfaceILcdModelReferenceDecoder
- Parameters:
aDataSourceName
- a data source for which to return the model reference; typically a file name or a URL.- Returns:
- the decoded
ILcdModelReference
and the location of the reference file. Nevernull
. - Throws:
IOException
- if no model reference file is found, or 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.
-
setInputStreamFactory
If not null, overrides the input stream factory of the contained model decoders with the given factory.- Specified by:
setInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- Parameters:
aInputStreamFactory
- the input stream factory to be used.
-
getInputStreamFactory
Description copied from interface:ILcdInputStreamFactoryCapable
Returns the input stream factory that is used.- Specified by:
getInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- Returns:
- the input stream factory that is used.
-