public class TLcdCompositeMetadataDecoder extends Object implements ILcdMetadataDecoder, ILcdInputStreamFactoryCapable
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.
ILcdMetadataDecoder
instances, you can use:
ILcdMetadataDecoder metadataDecoder =
new TLcdCompositeMetadataDecoder(TLcdServiceLoader.getInstance(ILcdMetadataDecoder.class));
This will use all metadata decoders annotated with the @LcdService
annotation.ILcdMetadataDecoder.MetadataWithSource
Constructor and Description |
---|
TLcdCompositeMetadataDecoder()
Creates 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.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canDecodeMetadata(String aSourceName)
Tells whether this metadata decoder can likely decode metadata for a given source name.
|
TLcdISO19115Metadata |
decodeMetadata(String aSourceName)
Decode the given metadata source through a suitable delegate metadata decoder.
|
ILcdMetadataDecoder.MetadataWithSource |
findAndDecodeMetadata(String aSourceName)
Finds and decode additional metadata for the given data source through a suitable delegate metadata decoder.
|
ILcdInputStreamFactory |
getInputStreamFactory()
Returns the input stream factory that is used.
|
List<ILcdMetadataDecoder> |
getMetadataDecoders()
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.
|
public TLcdCompositeMetadataDecoder()
model decoder list
.public TLcdCompositeMetadataDecoder(Iterable<? extends ILcdMetadataDecoder> aMetadataDecoders)
aMetadataDecoders
- an Iterable
of metadata decoderspublic TLcdCompositeMetadataDecoder(ILcdMetadataDecoder... aMetadataDecoders)
aMetadataDecoders
- delegate decoders to be added to the compositepublic List<ILcdMetadataDecoder> getMetadataDecoders()
public boolean canDecodeMetadata(String aSourceName)
ILcdMetadataDecoder
true
, it is likely that ILcdMetadataDecoder.decodeMetadata(String)
will return a non-null TLcdISO19115Metadata
object,
but it is not a guarantee. The result is optimistic.
false
, it is guaranteed that ILcdMetadataDecoder.decodeMetadata(String)
will throw an exception or return null
.
canDecodeMetadata
in interface ILcdMetadataDecoder
aSourceName
- the source name to decode metadata fortrue
if this metadata decoder can decode metadata for the given source name, false
otherwisepublic TLcdISO19115Metadata decodeMetadata(String aSourceName) throws IOException
can decode
the source, in order.
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.
decodeMetadata
in interface ILcdMetadataDecoder
aSourceName
- the source for which metadata should be createdIOException
- IOException
and no other delegate metadata decoder returns a non-null value, an IOException
will be thrown containing every suppressed exception.InterruptedIOException
, the decoding stops and that exception is re-thrown.public ILcdMetadataDecoder.MetadataWithSource findAndDecodeMetadata(String aSourceName) throws IOException
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.
findAndDecodeMetadata
in interface ILcdMetadataDecoder
aSourceName
- the data source for which additional metadata files should be searched and decodedIOException
- IOException
and no other delegate metadata decoder returns a non-null value, an IOException
will be thrown containing every suppressed exception.InterruptedIOException
, the decoding stops and that exception is re-thrown.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