Package com.luciad.format.metadata.model
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
This will use all metadata decoders annotated with the
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 availableILcdMetadataDecoder
instances, you can use:
ILcdMetadataDecoder metadataDecoder =
new TLcdCompositeMetadataDecoder(TLcdServiceLoader.getInstance(ILcdMetadataDecoder.class));
@LcdService
annotation.- Since:
- 2022.1
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.luciad.format.metadata.model.ILcdMetadataDecoder
ILcdMetadataDecoder.MetadataWithSource
-
Constructor Summary
ConstructorDescriptionCreates a new, empty composite metadata decoder.TLcdCompositeMetadataDecoder
(ILcdMetadataDecoder... aMetadataDecoders) Creates a new composite metadata decoder containing the supplied delegate decoders.TLcdCompositeMetadataDecoder
(Iterable<? extends ILcdMetadataDecoder> aMetadataDecoders) Creates a new composite metadata decoder that lazily uses the given Iterable to delegate to. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canDecodeMetadata
(String aSourceName) Tells whether this metadata decoder can likely decode metadata for a given source name.decodeMetadata
(String aSourceName) Decode the given metadata source through a suitable delegate metadata decoder.findAndDecodeMetadata
(String aSourceName) Finds and decode additional metadata for the given data source through a suitable delegate metadata decoder.Returns the input stream factory that is used.Returns the list of delegate metadata decoders contained in this composite.void
setInputStreamFactory
(ILcdInputStreamFactory aInputStreamFactory) If not null, overrides the input stream factory of the contained metadata decoders with the given factory.
-
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 themodel decoder list
. -
TLcdCompositeMetadataDecoder
Creates a new composite metadata decoder that lazily uses the given Iterable to delegate to.- Parameters:
aMetadataDecoders
- anIterable
of metadata decoders
-
TLcdCompositeMetadataDecoder
Creates a new composite metadata decoder containing the supplied delegate decoders.- Parameters:
aMetadataDecoders
- delegate decoders to be added to the composite
-
-
Method Details
-
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
Description copied from interface:ILcdMetadataDecoder
Tells whether this metadata decoder can likely decode metadata for a given source name.-
If
true
, it is likely thatILcdMetadataDecoder.decodeMetadata(String)
will return a non-nullTLcdISO19115Metadata
object, but it is not a guarantee. The result is optimistic. -
If
false
, it is guaranteed thatILcdMetadataDecoder.decodeMetadata(String)
will throw an exception or returnnull
.
- Specified by:
canDecodeMetadata
in interfaceILcdMetadataDecoder
- 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
-
If
-
decodeMetadata
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.
Note that even if
ILcdMetadataDecoder.canDecodeMetadata(String)
returnstrue
, this method may yet not be able to decode the given source name. While returningnull
is allowed when this decoder couldn't decode the given source name, implementors are advised to throw an error instead.- Specified by:
decodeMetadata
in interfaceILcdMetadataDecoder
- 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, anIOException
will be thrown containing every suppressed exception. - If a delegate decoder throws an
InterruptedIOException
, the decoding stops and that exception is re-thrown.
- If one or more delegate metadata decoders throw an
- Tries all delegate decoders that
-
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.
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 theTLcdISO19115Metadata
object. If notnull
, the decoded metadata should be the result of calling theILcdMetadataDecoder.decodeMetadata(String)
method, passing one of these dedicated metadata files.The default implementation returns null.
- Specified by:
findAndDecodeMetadata
in interfaceILcdMetadataDecoder
- 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, anIOException
will be thrown containing every suppressed exception. - If a delegate decoder throws an
InterruptedIOException
, the decoding stops and that exception is re-thrown.
- If one or more delegate metadata decoders throw an
-
setInputStreamFactory
If not null, overrides the input stream factory of the contained metadata 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.
-