Class TLcdCompositeMetadataDecoder

java.lang.Object
com.luciad.format.metadata.model.TLcdCompositeMetadataDecoder
All Implemented Interfaces:
ILcdMetadataDecoder, ILcdInputStreamFactoryCapable

public class TLcdCompositeMetadataDecoder extends Object implements ILcdMetadataDecoder, ILcdInputStreamFactoryCapable
Composite implementation of ILcdMetadataDecoder.

Any number of metadata decoders can be added to this composite.

The decodeMetadata(java.lang.String) delegates, in order, to the decoders in the list who can decode the source. See decodeMetadata(String) for details.

Example usage:

To create a composite instance which uses all default available ILcdMetadataDecoder instances, you can use:
    ILcdMetadataDecoder metadataDecoder =
        new TLcdCompositeMetadataDecoder(TLcdServiceLoader.getInstance(ILcdMetadataDecoder.class));
This will use all metadata decoders annotated with the @LcdService annotation.
Since:
2022.1
  • Constructor Details

    • TLcdCompositeMetadataDecoder

      public TLcdCompositeMetadataDecoder()
      Creates a new, empty composite metadata decoder. This decoder will not be able to create metadata until delegate metadata decoders are added to the model decoder list.
    • TLcdCompositeMetadataDecoder

      public TLcdCompositeMetadataDecoder(Iterable<? extends ILcdMetadataDecoder> aMetadataDecoders)
      Creates a new composite metadata decoder that lazily uses the given Iterable to delegate to.
      Parameters:
      aMetadataDecoders - an Iterable of metadata decoders
    • TLcdCompositeMetadataDecoder

      public TLcdCompositeMetadataDecoder(ILcdMetadataDecoder... aMetadataDecoders)
      Creates a new composite metadata decoder containing the supplied delegate decoders.
      Parameters:
      aMetadataDecoders - delegate decoders to be added to the composite
  • Method Details

    • getMetadataDecoders

      public List<ILcdMetadataDecoder> getMetadataDecoders()
      Returns the list of delegate metadata decoders contained in this composite. If the factory does not use an Iterable, delegates can be added or removed by modifying this list.
      Returns:
      the list of delegate metadata decoders in this composite
    • canDecodeMetadata

      public boolean canDecodeMetadata(String aSourceName)
      Description copied from interface: ILcdMetadataDecoder
      Tells whether this metadata decoder can likely decode metadata for a given source name.
      Specified by:
      canDecodeMetadata in interface ILcdMetadataDecoder
      Parameters:
      aSourceName - the source name to decode metadata for
      Returns:
      true if this metadata decoder can decode metadata for the given source name, false otherwise
    • decodeMetadata

      public TLcdISO19115Metadata decodeMetadata(String aSourceName) throws IOException
      Decode the given metadata source through a suitable delegate metadata decoder.

      Notes:

      • Tries all delegate decoders that can decode the source, in order.
      • The first successfully created non-null metadata is returned.

      Decodes the metadata from a given source name as an ISO-19115 metadata object.

      Note that even if ILcdMetadataDecoder.canDecodeMetadata(String) returns true, this method may yet not be able to decode the given source name. While returning null is allowed when this decoder couldn't decode the given source name, implementors are advised to throw an error instead.

      Specified by:
      decodeMetadata in interface ILcdMetadataDecoder
      Parameters:
      aSourceName - the source for which metadata should be created
      Returns:
      metadata created by the selected delegate decoder
      Throws:
      IOException -
      • If one or more delegate metadata decoders throw an IOException and no other delegate metadata decoder returns a non-null value, an IOException will be thrown containing every suppressed exception.
      • If a delegate decoder throws an InterruptedIOException, the decoding stops and that exception is re-thrown.
    • findAndDecodeMetadata

      public ILcdMetadataDecoder.MetadataWithSource findAndDecodeMetadata(String aSourceName) throws IOException
      Finds and decode additional metadata for the given data source through a suitable delegate metadata decoder.

      Notes:

      • Tries all delegate decoders, in order.
      • The first successfully created non-null metadata is returned.

      Searches metadata files for a given source name and decodes them as an ISO-19115 metadata object. The given source name points to a data set, not to a dedicated metadata file. A return value of null indicates that this decoder could not find dedicated metadata files for the given source name.

      This method returns a ILcdMetadataDecoder.MetadataWithSource, which combines the decoded metadata together with the names of the dedicated metadata files which were used for decoding the TLcdISO19115Metadata object. If not null, the decoded metadata should be the result of calling the ILcdMetadataDecoder.decodeMetadata(String) method, passing one of these dedicated metadata files.

      The default implementation returns null.

      Specified by:
      findAndDecodeMetadata in interface ILcdMetadataDecoder
      Parameters:
      aSourceName - the data source for which additional metadata files should be searched and decoded
      Returns:
      metadata created by the selected delegate decoder
      Throws:
      IOException -
      • If one or more delegate metadata decoders throw an IOException and no other delegate metadata decoder returns a non-null value, an IOException will be thrown containing every suppressed exception.
      • If a delegate decoder throws an InterruptedIOException, the decoding stops and that exception is re-thrown.
    • setInputStreamFactory

      public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
      If not null, overrides the input stream factory of the contained metadata 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.