private static class SaxWriterImpl.MemptrOutputStream
extends java.io.OutputStream
Modifier and Type | Field and Description |
---|---|
private boolean |
isStarted
Lazy initialization flag.
|
private memptr |
mptr
A valid memptr
|
private java.util.concurrent.atomic.AtomicLong |
position
Current read cursor position, started from index 1.
|
private long |
totalSize
Lazy initialization flag.
|
Modifier | Constructor and Description |
---|---|
private |
MemptrOutputStream(memptr source)
Constructor accepting a memptr to write.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close current stream and reset state.
|
private void |
ensureCapacity(int len)
Check capacity of memptr, if capacity is less then needed, then increase capacity.
|
void |
write(byte[] b,
int off,
int len)
Wrap super method to ensure that memptr has enough length and reduce number of calls to
expand capacity.
|
void |
write(int b)
Write one byte into memptr.
|
private final memptr mptr
private final java.util.concurrent.atomic.AtomicLong position
private volatile boolean isStarted
private long totalSize
private MemptrOutputStream(memptr source)
source
- A valid memptr object.public void write(int b) throws java.io.IOException
write
in class java.io.OutputStream
b
- the data to write.java.io.IOException
- wrap any exception from memptr into IO exception.public void write(byte[] b, int off, int len) throws java.io.IOException
write
in class java.io.OutputStream
b
- the data.off
- the start offset in the data.len
- the number of bytes to write.java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.OutputStream
java.io.IOException
private void ensureCapacity(int len)
len
- Count of bytes to ensure capacity.