Interface DataSource.Opener
-
- Enclosing class:
- DataSource
public static interface DataSource.Opener
Interface for lazy-opening data streams one time.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Reader
openReaderOnce()
Open a characters stream reader once.InputStream
openStreamOnce()
Open a bytes stream once.boolean
rawDataIsBinary()
Check if the raw data is binary.
-
-
-
Method Detail
-
rawDataIsBinary
boolean rawDataIsBinary()
Check if the raw data is binary.The raw data may be either binary or characters. In both cases, either
openStreamOnce()
oropenReaderOnce()
may be called, but one will be more efficient than the other as one will supply data as is and the other one will convert raw data before providing it. If conversion is needed, it will also be done usingUTF8 encoding
, which may not be suitable. This method helps the data consumer to either choose the more efficient method or avoid wrong encoding conversion.- Returns:
- true if raw data is binary, false if raw data is characters
-
openStreamOnce
InputStream openStreamOnce() throws IOException
Open a bytes stream once.Beware that this interface is only intended for lazy opening a stream, i.e. to delay this opening (or not open the stream at all). It is not intended to open the stream several times and not intended to open both the
binary stream
and thecharacters stream
separately (but opening the reader may be implemented by opening the binary stream or vice-versa). Implementations may fail if an attempt to open a stream several times is made. This is particularly true for network-based streams.- Returns:
- opened stream or null if there are no data streams at all
- Throws:
IOException
- if stream cannot be opened
-
openReaderOnce
Reader openReaderOnce() throws IOException
Open a characters stream reader once.Beware that this interface is only intended for lazy opening a stream, i.e. to delay this opening (or not open the stream at all). It is not intended to open the stream several times and not intended to open both the
binary stream
and thecharacters stream
separately (but opening the reader may be implemented by opening the binary stream or vice-versa). Implementations may fail if an attempt to open a stream several times is made. This is particularly true for network-based streams.- Returns:
- opened reader or null if there are no data streams at all
- Throws:
IOException
- if stream cannot be opened
-
-