Package org.orekit.data
Class DataSource
java.lang.Object
org.orekit.data.DataSource
Container associating a name with a stream or reader that can be opened lazily.
This association and the lazy-opening are useful in different cases:
- when
crawlinga directory tree to select data to be loaded by aDataLoader, the files that are not meaningful for the loader can be ignored and not opened at all - when
data filteringis used, the raw stream can be opened by the filter only if the upper level filtered stream is opened - when opening a stream for loading the data it provides, the opening
and closing actions can be grouped in Orekit internal code using a
try with resourcesclause so closing is done properly even in case of exception - if some pre-reading of the first few bytes or characters are needed to decide how to
load data (as in
LexicalAnalyzerSelector), then the stream can be opened, buffered and rewound and a fake open method used to return the already open stream so atry with resourcesclause elsewhere works properly for closing the stream
Beware that the purpose of this class is only to delay this opening (or not open
the stream or reader at all), it is not intended to open the stream several
times and not intended to open both the binary stream and the characters reader.
Some implementations may fail if the opener's
openStreamOnce or openReaderOnce
methods are called several times or are both called separately. This is particularly
true for network-based streams.
- Since:
- 9.2
- Author:
- Luc Maisonobe
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface for lazy-opening data streams one time.static interfaceInterface for lazy-opening a characters stream one time.static interfaceInterface for lazy-opening a binary stream one time. -
Constructor Summary
ConstructorsConstructorDescriptionDataSource(File file) Build an instance from a file on the local file system.DataSource(String fileName) Build an instance from file name only.DataSource(String name, DataSource.ReaderOpener readerOpener) Complete constructor.DataSource(String name, DataSource.StreamOpener streamOpener) Complete constructor.DataSource(URI uri) Build an instance from URI only. -
Method Summary
Modifier and TypeMethodDescriptiongetName()Get the name of the data.Get the data stream opener.
-
Constructor Details
-
DataSource
Complete constructor.- Parameters:
name- data namestreamOpener- opener for the data stream
-
DataSource
Complete constructor.- Parameters:
name- data namereaderOpener- opener for characters reader
-
DataSource
Build an instance from file name only.- Parameters:
fileName- name of the file- Since:
- 11.0
-
DataSource
Build an instance from a file on the local file system.- Parameters:
file- file- Since:
- 11.0
-
DataSource
Build an instance from URI only.- Parameters:
uri- URI of the file- Since:
- 11.0
-
-
Method Details
-
getName
Get the name of the data.- Returns:
- name of the data
-
getOpener
Get the data stream opener.- Returns:
- data stream opener
-