Package org.jgroups.util
Class ByteArrayDataOutputStream
- java.lang.Object
-
- org.jgroups.util.BaseDataOutputStream
-
- org.jgroups.util.ByteArrayDataOutputStream
-
- All Implemented Interfaces:
java.io.DataOutput
public class ByteArrayDataOutputStream extends BaseDataOutputStream
ImplementsDataOutput
over a byte[] buffer. The byte[] buffer expands when needed; however, it doesn't double but only expands minimally, to accommodate the additional data. It is therefore recommended to always size the buffer to the actual number of bytes needed. This class is not thread safe.- Since:
- 3.5
- Author:
- Bela Ban
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[]
buf
protected boolean
grow_exponentially
-
Fields inherited from class org.jgroups.util.BaseDataOutputStream
pos
-
-
Constructor Summary
Constructors Constructor Description ByteArrayDataOutputStream()
ByteArrayDataOutputStream(int capacity)
ByteArrayDataOutputStream(int capacity, boolean grow_exponentially)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
buffer()
java.nio.ByteBuffer
byteBuffer()
int
capacity()
protected int
checkBounds(int pos)
protected void
ensureCapacity(int bytes)
Grows the buffer; whether it grow linearly or exponentially depends on grow_exponentiallyByteArray
getBuffer()
boolean
growExponentially()
ByteArrayDataOutputStream
growExponentially(boolean b)
java.lang.String
toString()
void
write(byte[] b)
void
write(byte[] b, int off, int len)
void
write(int b)
-
Methods inherited from class org.jgroups.util.BaseDataOutputStream
position, position, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
-
-
-
-
Method Detail
-
buffer
public byte[] buffer()
-
getBuffer
public ByteArray getBuffer()
-
byteBuffer
public java.nio.ByteBuffer byteBuffer()
-
capacity
public int capacity()
-
growExponentially
public boolean growExponentially()
-
growExponentially
public ByteArrayDataOutputStream growExponentially(boolean b)
-
write
public void write(int b)
- Specified by:
write
in interfacejava.io.DataOutput
- Specified by:
write
in classBaseDataOutputStream
-
write
public void write(byte[] b)
- Specified by:
write
in interfacejava.io.DataOutput
- Overrides:
write
in classBaseDataOutputStream
-
write
public void write(byte[] b, int off, int len)
- Specified by:
write
in interfacejava.io.DataOutput
- Specified by:
write
in classBaseDataOutputStream
-
toString
public java.lang.String toString()
- Overrides:
toString
in classBaseDataOutputStream
-
checkBounds
protected int checkBounds(int pos)
- Overrides:
checkBounds
in classBaseDataOutputStream
-
ensureCapacity
protected void ensureCapacity(int bytes)
Grows the buffer; whether it grow linearly or exponentially depends on grow_exponentially- Specified by:
ensureCapacity
in classBaseDataOutputStream
-
-