public final class WitsmlWriter extends Object implements Closeable
Typical usage:
If there is to much data to keep in memory, it is possible to write in a streaming manner by adding curve data and appending the output file alternately, seeWitsmlLog log = new WitsmlLog(); : // Write to file, human readable with 2 space indentation WitsmlWriter writer = new WitsmlWriter(new File("path/to/file.xml"), true, 2); writer.write(log); writer.close();
append(no.petroware.logio.witsml.WitsmlLog)
.Constructor and Description |
---|
WitsmlWriter(File file,
WitsmlVersion witsmlVersion,
boolean isPretty,
int indentation)
Create a WITSML log writer for the specified disk file.
|
WitsmlWriter(OutputStream outputStream,
WitsmlVersion witsmlVersion,
boolean isPretty,
int indentation)
Create a WITSML log writer for the specified stream.
|
Modifier and Type | Method and Description |
---|---|
void |
append(WitsmlLog witsmlLog)
Append the curve data of the specified log.
|
void |
close()
Append the final tags to the XML stream and close the writer.
|
static String |
toString(List<WitsmlLog> logs,
WitsmlVersion witsmlVersion,
boolean isPretty,
int indentation)
Convenience method for returning a string representation of the specified logs.
|
static String |
toString(WitsmlLog log,
WitsmlVersion witsmlVersion)
Convenience method for returning a pretty printed string representation
of the specified log.
|
static String |
toString(WitsmlLog log,
WitsmlVersion witsmlVersion,
boolean isPretty,
int indentation)
Convenience method for returning a string representation of the specified log.
|
void |
write(WitsmlLog witsmlLog)
Write the specified log instances.
|
public WitsmlWriter(OutputStream outputStream, WitsmlVersion witsmlVersion, boolean isPretty, int indentation)
outputStream
- Stream to write. Non-null.witsmlVersion
- WITSML version to write. Non-null.isPretty
- True to write in human readable pretty format, false
to write as dense as possible.indentation
- The white space indentation used in pretty print mode. [0,>.
If isPretty is false, this setting has no effect.IllegalArgumentException
- If outputStream or witsmlVersion is null or
indentation is out of bounds.public WitsmlWriter(File file, WitsmlVersion witsmlVersion, boolean isPretty, int indentation)
file
- Disk file to write. Non-null.witsmlVersion
- WITSML version to write. Non-null.isPretty
- True to write in human readable pretty format, false
to write as dense as possible.indentation
- The white space indentation used in pretty print mode. [0,>.
If isPretty is false, this setting has no effect.IllegalArgumentException
- If file or witsmlVersion is null
or indentation is out of bounds.public void write(WitsmlLog witsmlLog) throws IOException
Multiple logs can be written in sequence to the same stream.
Additional data can be appended to the last one by append(no.petroware.logio.witsml.WitsmlLog)
.
When writing is done the writer must be closed with close()
.
witsmlLog
- Log to write. Non-null.IllegalArgumentException
- If log is null.IOException
- If the write operation fails for some reason.public void append(WitsmlLog witsmlLog) throws IOException
This feature can be used to stream data to a WITSML destination. By repeatedly clearing and populating the log curves with new data there is no need for the client to keep the full volume in memory at any point in time.
NOTE: This method must be called after the WITSML log metadata
has been written (see write(no.petroware.logio.witsml.WitsmlLog)
), and the WITSML log must be compatible
with this.
When writing is done, close the stream with close()
.
witsmlLog
- Log to append to stream. Non-null.IllegalArgumentException
- If log is null.IllegalStateException
- If the writer is not open for writing.IOException
- If the write operation fails for some reason.public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public static String toString(List<WitsmlLog> logs, WitsmlVersion witsmlVersion, boolean isPretty, int indentation)
logs
- Logs to write. Non-null.witsmlVersion
- WITSML version to write. Non-null.isPretty
- True to write in human readable pretty format, false
to write as dense as possible.indentation
- The white space indentation used in pretty print mode. [0,>.
If isPretty is false, this setting has no effect.IllegalArgumentException
- If logs or witsmlVersion is null or
indentation is out of bounds.public static String toString(WitsmlLog log, WitsmlVersion witsmlVersion, boolean isPretty, int indentation)
log
- Log to get as a WITSML string. Non-null.witsmlVersion
- WITSML version to write. Non-null.isPretty
- True to write in human readable pretty format, false
to write as dense as possible.indentation
- The white space indentation used in pretty print mode. [0,>.
If isPretty is false, this setting has no effect.IllegalArgumentException
- If log or witsmlVersion is null or
indentation is out of bounds.public static String toString(WitsmlLog log, WitsmlVersion witsmlVersion)
log
- Log to write. Non-null.witsmlVersion
- WITSML version to write. Non-null.IllegalArgumentException
- If log or witsmlVersion is null.Copyright © 2024 Petroware AS - https://petroware.no