public interface ILcdInputStreamFactory
ILcdInputStreamFactory
creates an InputStream
from a given source.
This can be used in implementations of ILcdModelDecoder
to implement, e.g., ways of securely transferring data from the actual source to the actual decoder.
ILcdModelDecoder
Modifier and Type | Method and Description |
---|---|
default boolean |
canCreateInputStream(String aSource)
Checks whether this input stream factory can provide access to
aSource . |
InputStream |
createInputStream(String aSource)
Creates an
InputStream from aSource . |
default boolean canCreateInputStream(String aSource)
aSource
. It is acceptable for this method to
return true
for a source while createInputStream
throws an exception for that same source.
For performance reasons, we strongly recommend that implementations perform only a simple test.
For example: check the structure of aSource
to see if it is a URI with a specific scheme, but do not verify
that aSource
really is accessible.
The default implementation of this method returns true
.
Make sure to override this method if you can easily reject sources. This can help avoid pointless invocations of
createInputStream
which would have to throw exceptions for unsupported sources.
aSource
- the data source to be verified; typically a file name or a URL.true
if this input stream factory can likely access the source, false
otherwise.createInputStream(String)
InputStream createInputStream(String aSource) throws IOException
InputStream
from aSource
.aSource
- an accessible data source.InputStream
from the data source.IOException
- when aSource
is not accepted by canCreateInputStream
or is not accessible.canCreateInputStream(String)