Class FastByteArrayOutputStream
java.lang.Object
java.io.OutputStream
com.espertech.esper.common.internal.serde.serdeset.builtin.FastByteArrayOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
Output on fast byte array output stream.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Buffer increase size, zero means double.static final int
Buffer initial size. -
Constructor Summary
ConstructorDescriptionCtor.FastByteArrayOutputStream
(byte[] buffer) Ctor.FastByteArrayOutputStream
(byte[] buffer, int increase) Ctor.FastByteArrayOutputStream
(int initialSize) Ctor.FastByteArrayOutputStream
(int initialSize, int increaseSize) Ctor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSize
(int sizeAdded) Add number of bytes to size.byte[]
Returns the buffer itself.int
Returns the length.int
Returns the offset, always zero.byte[]
Fast getter checking if the byte array matches the requested length and returnin the buffer itself if it does.byte[]
Returns the byte array.void
makeSpace
(int sizeNeeded) Increase buffer size.void
reset()
Reset buffer.int
size()
Returns buffer size.toString()
Outputs contents.void
write
(byte[] fromBuf) void
write
(byte[] fromBuf, int offset, int length) void
write
(int b) Write byte.final void
writeFast
(byte[] fromBuf) Fast write.final void
writeFast
(byte[] fromBuf, int offset, int length) Fast write.final void
writeFast
(int b) Fast write.void
writeTo
(OutputStream out) Write bytes to another stream.Methods inherited from class java.io.OutputStream
close, flush, nullOutputStream
-
Field Details
-
DEFAULT_INITIAL_SIZE
public static final int DEFAULT_INITIAL_SIZEBuffer initial size.- See Also:
-
DEFAULT_INCREASE_SIZE
public static final int DEFAULT_INCREASE_SIZEBuffer increase size, zero means double.- See Also:
-
-
Constructor Details
-
FastByteArrayOutputStream
public FastByteArrayOutputStream(byte[] buffer) Ctor.- Parameters:
buffer
- to write
-
FastByteArrayOutputStream
public FastByteArrayOutputStream(byte[] buffer, int increase) Ctor.- Parameters:
buffer
- to writeincrease
- zero for
-
FastByteArrayOutputStream
public FastByteArrayOutputStream()Ctor. -
FastByteArrayOutputStream
public FastByteArrayOutputStream(int initialSize) Ctor.- Parameters:
initialSize
- initial size
-
FastByteArrayOutputStream
public FastByteArrayOutputStream(int initialSize, int increaseSize) Ctor.- Parameters:
initialSize
- initial sizeincreaseSize
- increase size
-
-
Method Details
-
size
public int size()Returns buffer size.- Returns:
- size
-
reset
public void reset()Reset buffer. -
write
Write byte.- Specified by:
write
in classOutputStream
- Parameters:
b
- byte to write- Throws:
IOException
- for io errors
-
write
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
writeTo
Write bytes to another stream.- Parameters:
out
- other stream- Throws:
IOException
- if a write exception occurs
-
toString
-
toString
Outputs contents.- Parameters:
encoding
- to use- Returns:
- contents
- Throws:
UnsupportedEncodingException
- when encoding is not supported
-
getByteArrayWithCopy
public byte[] getByteArrayWithCopy()Returns the byte array.- Returns:
- byte array
-
getByteArrayFast
public byte[] getByteArrayFast()Fast getter checking if the byte array matches the requested length and returnin the buffer itself if it does.- Returns:
- byte array without offset
-
writeFast
public final void writeFast(int b) Fast write.- Parameters:
b
- byte to write
-
writeFast
public final void writeFast(byte[] fromBuf) Fast write.- Parameters:
fromBuf
- to write
-
writeFast
public final void writeFast(byte[] fromBuf, int offset, int length) Fast write.- Parameters:
fromBuf
- buffer to writeoffset
- offset of write fromlength
- length to write
-
getBufferBytes
public byte[] getBufferBytes()Returns the buffer itself.- Returns:
- buffer
-
getBufferOffset
public int getBufferOffset()Returns the offset, always zero.- Returns:
- offset
-
getBufferLength
public int getBufferLength()Returns the length.- Returns:
- length
-
makeSpace
public void makeSpace(int sizeNeeded) Increase buffer size.- Parameters:
sizeNeeded
- bytes needed.
-
addSize
public void addSize(int sizeAdded) Add number of bytes to size.- Parameters:
sizeAdded
- to be added
-