public class RTPSByteBuffer extends Object
Constructor and Description |
---|
RTPSByteBuffer(byte[] bytes)
Constructs RTPSByteBuffer.
|
RTPSByteBuffer(ByteBuffer buffer)
Constructs RTPSByteBuffer.
|
RTPSByteBuffer(InputStream is)
Constructs RTPSByteBuffer.
|
Modifier and Type | Method and Description |
---|---|
int |
align(int byteBoundary)
Aligns this buffer to given byteBoundary.
|
ByteBuffer |
getBuffer()
Get the underlying ByteBuffer.
|
InputStream |
getInputStream()
Gets an InputStream reading from the backing ByteBuffer.
|
OutputStream |
getOutputStream()
Gets an OutputStream that writes to this RTPSByteBuffer.
|
int |
position()
Get the position in underlying buffer.
|
boolean |
read_boolean()
Reads a boolean from underlying buffer.
|
int |
read_long()
Reads a long (4 bytes) from underlying buffer
|
long |
read_longlong()
Reads a longlong (8 bytes) from underlying buffer
|
byte |
read_octet()
Reads an octet (1 byte) from underlying buffer.
|
int |
read_short()
Reads a short (2 bytes) from underlying buffer
|
String |
read_string()
Reads a String from underlying buffer
|
void |
read(byte[] bytes)
Reads in bytes(octets) from underlying buffer.
|
boolean |
readBoolean()
Reads a java primitive boolean.
|
byte |
readByte()
Reads a java primitive byte.
|
char |
readChar()
Reads a java primitive char.
|
double |
readDouble()
Reads a java primitive double.
|
float |
readFloat()
Reads a java primitive float.
|
int |
readInt()
Reads a java primitive int.
|
long |
readLong()
Reads a java primitive long.
|
short |
readShort()
Reads a java primitive short.
|
String |
readString()
Reads a String from the buffer.
|
String |
readString(String charsetName)
Reads a String from the buffer.
|
void |
setEndianess(boolean endianessFlag)
Sets the endianness used. see 9.4.5.1.2 flags
|
byte[] |
toArray()
Returns a byte array from the beginning of backing array to current position
|
void |
write_boolean(boolean b)
Writes a boolean to underlying buffer
|
void |
write_long(int a_long)
Writes a long (4 bytes) to underlying buffer
|
void |
write_longlong(long a_longlong)
Writes a longlong (8 bytes) to underlying buffer
|
void |
write_octet(byte an_octet)
Writes an octet (1 byte) to underlying buffer.
|
void |
write_short(int a_short)
Writes a short (2 bytes) to underlying buffer
|
void |
write_string(String s)
Writes a string to underlying buffer
|
void |
write(byte[] bytes)
Writes bytes(octets).
|
void |
writeBoolean(boolean b)
Writes a java primitive boolean.
|
void |
writeByte(byte b)
Writes a java primitive byte.
|
void |
writeChar(char c)
Writes a java primitive char.
|
void |
writeDouble(double d)
Writes a java primitive double.
|
void |
writeFloat(float f)
Writes a java primitive float.
|
void |
writeInt(int i)
Writes a java primitive int.
|
void |
writeLong(long l)
Writes a java primitive long.
|
void |
writeShort(short s)
Writes a java primitive short.
|
void |
writeString(String s)
Writes a String into this buffer.
|
void |
writeString(String s,
String charsetName)
Writes a String into this buffer with given charsetName. charsetName is used when getting the bytes of the
String.
|
public RTPSByteBuffer(byte[] bytes)
bytes
- An array of bytes to wrap into this RTPSByteBufferpublic RTPSByteBuffer(ByteBuffer buffer)
buffer
- Underlying ByteBufferByteBuffer
public RTPSByteBuffer(InputStream is) throws IOException
is
- InputStream used to read bytes fromIOException
- on IOExceptionInputStream
public int position()
public byte read_octet()
public void write_octet(byte an_octet)
an_octet
- An octet to writepublic int read_short()
public void write_short(int a_short)
a_short
- a short to writepublic int read_long()
public void write_long(int a_long)
a_long
- a long to writepublic long read_longlong()
public void write_longlong(long a_longlong)
a_longlong
- a longlong to writepublic boolean read_boolean()
public void write_boolean(boolean b)
b
- boolean to writepublic String read_string()
public void write_string(String s)
s
- string to writepublic int readInt()
public void writeInt(int i)
i
- int to writepublic short readShort()
public void writeShort(short s)
s
- a Java short to writepublic long readLong()
public void writeLong(long l)
l
- a Java long to writepublic float readFloat()
public void writeFloat(float f)
f
- a Java float to writepublic double readDouble()
public void writeDouble(double d)
d
- a Java double to writepublic char readChar()
public void writeChar(char c)
c
- a java char to writepublic byte readByte()
public void writeByte(byte b)
b
- a java byte to writepublic boolean readBoolean()
public void writeBoolean(boolean b)
b
- a java boolean to writepublic void read(byte[] bytes)
bytes
- byte arraypublic void write(byte[] bytes)
bytes
- byte to writepublic void writeString(String s)
s
- String to writepublic void writeString(String s, String charsetName)
s
- String to writecharsetName
- Name of the charsetRuntimeException
- that wraps UnsupportedEncodingExceptionpublic String readString()
public String readString(String charsetName)
charsetName
- Name of of charsetRuntimeException
- that wraps UnsupportedEncodingExceptionpublic int align(int byteBoundary)
byteBoundary
- alignement boundarypublic ByteBuffer getBuffer()
public void setEndianess(boolean endianessFlag)
endianessFlag
- If true, little endian is used. If false, big endian is used.public InputStream getInputStream()
public byte[] toArray()
public OutputStream getOutputStream()
Copyright © 2016. All rights reserved.