Interface DataSource.Opener
- Enclosing class:
DataSource
-
Method Summary
Modifier and TypeMethodDescriptionOpen a characters stream reader once.Open a bytes stream once.booleanCheck if the raw data is binary.
-
Method Details
-
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
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 streamand thecharacters streamseparately (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
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 streamand thecharacters streamseparately (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
-