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
ImplementsDataOutputover 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[]bufprotected booleangrow_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.ByteBufferbyteBuffer()intcapacity()protected intcheckBounds(int pos)protected voidensureCapacity(int bytes)Grows the buffer; whether it grow linearly or exponentially depends on grow_exponentiallyByteArraygetBuffer()booleangrowExponentially()ByteArrayDataOutputStreamgrowExponentially(boolean b)java.lang.StringtoString()voidwrite(byte[] b)voidwrite(byte[] b, int off, int len)voidwrite(int b)voidwriteChar(int v)voidwriteInt(int v)voidwriteLong(long v)voidwriteShort(int v)-
Methods inherited from class org.jgroups.util.BaseDataOutputStream
position, position, writeBoolean, writeByte, writeBytes, writeChars, writeDouble, writeFloat, 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)
-
writeChar
public void writeChar(int v)
- Specified by:
writeCharin interfacejava.io.DataOutput- Overrides:
writeCharin classBaseDataOutputStream
-
writeInt
public void writeInt(int v)
- Specified by:
writeIntin interfacejava.io.DataOutput- Overrides:
writeIntin classBaseDataOutputStream
-
writeLong
public void writeLong(long v)
- Specified by:
writeLongin interfacejava.io.DataOutput- Overrides:
writeLongin classBaseDataOutputStream
-
writeShort
public void writeShort(int v)
- Specified by:
writeShortin interfacejava.io.DataOutput- Overrides:
writeShortin classBaseDataOutputStream
-
write
public void write(int b)
- Specified by:
writein interfacejava.io.DataOutput- Specified by:
writein classBaseDataOutputStream
-
write
public void write(byte[] b)
- Specified by:
writein interfacejava.io.DataOutput- Overrides:
writein classBaseDataOutputStream
-
write
public void write(byte[] b, int off, int len)- Specified by:
writein interfacejava.io.DataOutput- Specified by:
writein classBaseDataOutputStream
-
toString
public java.lang.String toString()
- Overrides:
toStringin classBaseDataOutputStream
-
checkBounds
protected int checkBounds(int pos)
- Overrides:
checkBoundsin classBaseDataOutputStream
-
ensureCapacity
protected void ensureCapacity(int bytes)
Grows the buffer; whether it grow linearly or exponentially depends on grow_exponentially- Specified by:
ensureCapacityin classBaseDataOutputStream
-
-