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 available 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.
Since:
2018.0
  • 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 the model reference decoders list.
    • TLcdCompositeModelReferenceDecoder

      public TLcdCompositeModelReferenceDecoder(Iterable<? extends ILcdModelReferenceDecoder> aModelReferenceDecoders)
      Creates a new composite model reference decoder that lazily uses the given Iterable to delegate to.
      Parameters:
      aModelReferenceDecoders - an Iterable of model reference decoders
    • TLcdCompositeModelReferenceDecoder

      public TLcdCompositeModelReferenceDecoder(ILcdModelReferenceDecoder... aModelReferenceDecoders)
      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

      public List<ILcdModelReferenceDecoder> getModelReferenceDecoders()
      Returns the list of delegate model reference decoders contained in this composite. If this instance was constructed using an Iterable, 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

      public ILcdModelReference decodeModelReference(String aDataSourceName) throws IOException
      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 interface ILcdModelReferenceDecoder
      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. While null is allowed, implementors are advised to throw an error instead.
      Throws:
      IOException - if the ILcdModelReference cannot be decoded.
      When the thread on which this method is called is interrupted, it is recommended to stop the decoding and throw an 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.
    • 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 to 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:

      • 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 interface ILcdModelReferenceDecoder
      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. Never null.
      Throws:
      IOException - if no model reference file is found, or the ILcdModelReference cannot be decoded.
      When the thread on which this method is called is interrupted, it is recommended to stop the decoding and throw an 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.
    • setInputStreamFactory

      public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
      If not null, overrides the input stream factory of the contained model decoders with the given factory.
      Specified by:
      setInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Parameters:
      aInputStreamFactory - the input stream factory to be used.
    • getInputStreamFactory

      public ILcdInputStreamFactory getInputStreamFactory()
      Description copied from interface: ILcdInputStreamFactoryCapable
      Returns the input stream factory that is used.
      Specified by:
      getInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Returns:
      the input stream factory that is used.