public final class OsduWellLogReader extends Object
Typical usage:
// Read meta data OsduWellLogReader reader = new OsduWellLogReader(new File("path/to/record.json")); OsduWellLog log = reader.read(); // Read data reader.readData(new File("path/to/data1.json"), log, false, null); reader.readData(new File("path/to/data2.json"), log, false, null); :
Constructor and Description |
---|
OsduWellLogReader(File file)
Create an OSDU reader for the specified disk file.
|
OsduWellLogReader(InputStream inputStream)
Create an OSDU reader for the specified stream.
|
OsduWellLogReader(String text)
Create an OSDU reader for the specified text.
|
Modifier and Type | Method and Description |
---|---|
static double |
isOsduWellLogFile(File file,
byte[] content)
Get the probability that the specified file is a
OSDU Well Log file.
|
static void |
main(String[] arguments) |
OsduWellLog |
read()
Read OSDU well log meta-data from the content of this reader.
|
void |
readData(File file,
OsduWellLog log,
boolean shouldReadBulkData,
boolean shouldCaptureStatistics,
OsduDataListener dataListener)
Read OSDU well log data from the specified file and populate the given log accordingly.
|
void |
readData(InputStream inputStream,
OsduWellLog log,
boolean shouldReadBulkData,
boolean shouldCaptureStatistics,
OsduDataListener dataListener)
Read OSDU well log data from the specified stream and populate the given
log accordingly.
|
public OsduWellLogReader(InputStream inputStream)
inputStream
- Stream to read. Non-null.IllegalArgumentException
- If inputStream is null.public OsduWellLogReader(File file)
file
- Disk file to read. Non-null.IllegalArgumentException
- If file is null.public OsduWellLogReader(String text)
text
- Text to read. Non-null.IllegalArgumentException
- If file is null.public static double isOsduWellLogFile(File file, byte[] content)
The check can be done with or without considering the content of the file. In the latter case, only the file name (typically its extension) is considered. Note that as OSDU is JSON files, such a test will never actually confirm that this is a OSDU WellLog such. In the former case a portion from the start of the file is used to match for known patterns. By passing the portion as an argument, the client code can read this once and then pass it to different classifiers in order to determine its most likely type.
Getting a portion of a file can be done by:
File file = ...; BufferedInputStream stream = new BufferedInputStream(new FileInputStream(file)); byte[] content = new byte[2000]; stream.read(content, 0, content.length); stream.close();
file
- File to check. Null to classify on content only.content
- A number of bytes from the start of the file.
Null to classify on file name only.public void readData(InputStream inputStream, OsduWellLog log, boolean shouldReadBulkData, boolean shouldCaptureStatistics, OsduDataListener dataListener) throws IOException, OsduException, InterruptedException
inputStream
- Stream to read. Non-null.log
- Log to populate. Non-null.shouldReadBulkData
- True to read bulk data, false to capture statistics onle.shouldCaptureStatistics
- True to create statistics from the bulk data,
false otherwise.dataListener
- Listener that will be notified when new data has read.IOException
- If the read operation fails for some reason.OsduException
- If the JSON content is not according to the OSDU specification.InterruptedException
- If the operation was interupted through the dataListener.public void readData(File file, OsduWellLog log, boolean shouldReadBulkData, boolean shouldCaptureStatistics, OsduDataListener dataListener) throws IOException, OsduException, InterruptedException
file
- File to read. Non-null.log
- Log to populate. Non-null.shouldReadBulkData
- True to read bulk data, false to capture statistics onle.shouldCaptureStatistics
- True to create statistics from the bulk data,
false otherwise.dataListener
- Listener that will be notified when new data has read.IOException
- If the read operation fails for some reason.OsduException
- If the JSON content is not according to the OSDU specification.InterruptedException
- If the operation was interupted through the dataListener.public OsduWellLog read() throws IOException
IOException
- If the read operation fails for some reason.public static void main(String[] arguments)
Copyright © 2024 Petroware AS - https://petroware.no