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.
ILcdModelReferenceDecoder
instances, you can use:
ILcdModelReferenceDecoder referenceDecoder =
new TLcdCompositeModelReferenceDecoder(TLcdServiceLoader.getInstance(ILcdModelReferenceDecoder.class));
This will use all model reference decoders annotated with the @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.ILcdModelReferenceDecoder.ModelReferenceWithSource
Constructor and Description |
---|
TLcdCompositeModelReferenceDecoder()
Creates a new, empty composite model reference decoder.
|
TLcdCompositeModelReferenceDecoder(ILcdModelReferenceDecoder... aModelReferenceDecoders)
Creates a new composite model reference decoder containing the supplied delegates
|
TLcdCompositeModelReferenceDecoder(Iterable<? extends ILcdModelReferenceDecoder> aModelReferenceDecoders)
Creates a new composite model reference decoder that lazily uses the given
Iterable to delegate to. |
Modifier and Type | Method and Description |
---|---|
ILcdModelReference |
decodeModelReference(String aDataSourceName)
Returns the model reference, associated with the specified data source.
|
ILcdModelReferenceDecoder.ModelReferenceWithSource |
findAndDecodeModelReference(String aDataSourceName)
Finds and decodes the model reference file, associated with the specified data source.
|
ILcdInputStreamFactory |
getInputStreamFactory()
Returns the input stream factory that is used.
|
List<ILcdModelReferenceDecoder> |
getModelReferenceDecoders()
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.
|
public TLcdCompositeModelReferenceDecoder()
model reference decoders list
.public TLcdCompositeModelReferenceDecoder(Iterable<? extends ILcdModelReferenceDecoder> aModelReferenceDecoders)
Iterable
to delegate to.aModelReferenceDecoders
- an Iterable
of model reference decoderspublic TLcdCompositeModelReferenceDecoder(ILcdModelReferenceDecoder... aModelReferenceDecoders)
aModelReferenceDecoders
- delegate model reference decoders to be added to the compositepublic List<ILcdModelReferenceDecoder> getModelReferenceDecoders()
Iterable
, the returned list is unmodifiable.
If not, delegates can be added or removed by modifying this list.public ILcdModelReference decodeModelReference(String aDataSourceName) throws IOException
IOException
is thrown.InterruptedIOException
, the decoding stops and that error is re-thrown.decodeModelReference
in interface ILcdModelReferenceDecoder
aDataSourceName
- a data source for which to return the model reference; typically a file name or a URL.ILcdModelReference
associated with the data source. While null
is allowed,
implementors are advised to throw an error instead.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.public ILcdModelReferenceDecoder.ModelReferenceWithSource findAndDecodeModelReference(String aDataSourceName) throws IOException
ILcdModelReferenceDecoder.decodeModelReference(java.lang.String)
and returns the resulting model reference, paired with a null
source, indicating that the source is unknown or does not exist.
Notes:
IOException
is thrown.InterruptedIOException
, the decoding stops and that error is re-thrown.findAndDecodeModelReference
in interface ILcdModelReferenceDecoder
aDataSourceName
- a data source for which to return the model reference; typically a file name or a URL.ILcdModelReference
and the location of the reference file. Never null
.IOException
- if no model reference file is found, or 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.public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
setInputStreamFactory
in interface ILcdInputStreamFactoryCapable
aInputStreamFactory
- the input stream factory to be used.public ILcdInputStreamFactory getInputStreamFactory()
ILcdInputStreamFactoryCapable
getInputStreamFactory
in interface ILcdInputStreamFactoryCapable