|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.sciss.net.OSCPacket
public abstract class OSCPacket
OSCPacket
is the superclass
of OSC messages and bundles. It provides
methods that apply to both of these OSC packet
types, like calculating the packet's size
encoding the packet from a given byte buffer
or decoding a received message from a given buffer.
Constructor Summary | |
---|---|
protected |
OSCPacket()
Constructs a new OSCPacket . |
Method Summary | |
---|---|
static OSCPacket |
decode(ByteBuffer b)
Creates a new packet decoded from the ByteBuffer, using the default codec. |
void |
encode(ByteBuffer b)
Encodes the contents of this packet into the provided ByteBuffer ,
beginning at the buffer's current position, using the
default codec. |
void |
encode(OSCPacketCodec c,
ByteBuffer b)
Encodes the contents of this packet into the provided ByteBuffer ,
beginning at the buffer's current position, using a
given codec. |
int |
getSize()
Calculates and returns the packet's size in bytes, using the default codec. |
int |
getSize(OSCPacketCodec c)
Calculates and returns the packet's size in bytes, using a given codec. |
static void |
printHexOn(PrintStream stream,
ByteBuffer b)
Prints a hexdump version of a packet to a given stream. |
static void |
printTextOn(PrintStream stream,
OSCPacket p)
Prints a text version of a packet to a given stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected OSCPacket()
OSCPacket
.
Refer to the subclasses for the particular
way they instantiate the class
Method Detail |
---|
public final int getSize() throws IOException
encode
method.
IOException
- if an error occurs during the calculationgetSize( OSCPacketCodec )
public final int getSize(OSCPacketCodec c) throws IOException
c
- the codec that is shall used for encoding the packet
encode
method.
IOException
- if an error occurs during the calculationOSCPacketCodec.getSize( OSCPacket )
public final void encode(ByteBuffer b) throws IOException
ByteBuffer
,
beginning at the buffer's current position, using the
default codec. To write the
encoded packet, you will typically call flip()
on the buffer, then write()
on the channel.
b
- ByteBuffer
pointing right at
the beginning of the osc packet.
buffer position will be right after the end
of the packet when the method returns.
IOException
- in case some of the
writing procedures failed.encode( OSCPacketCodec, ByteBuffer )
public final void encode(OSCPacketCodec c, ByteBuffer b) throws IOException
ByteBuffer
,
beginning at the buffer's current position, using a
given codec. To write the
encoded packet, you will typically call flip()
on the buffer, then write()
on the channel.
b
- ByteBuffer
pointing right at
the beginning of the osc packet.
buffer position will be right after the end
of the packet when the method returns.c
- the codec that is shall used for encoding the packet
IOException
- in case some of the
writing procedures failed.OSCPacketCodec.encode( OSCPacket, ByteBuffer )
public static OSCPacket decode(ByteBuffer b) throws IOException
OSCPacketCodec
.
b
- ByteBuffer
pointing right at
the beginning of the packet. the buffer's
limited should be set appropriately to
allow the complete packet to be read. when
the method returns, the buffer's position
is right after the end of the packet.
IOException
- in case some of the
reading or decoding p rocedures failed.
IllegalArgumentException
- occurs in some cases of buffer underflowOSCPacketCodec.decode( ByteBuffer )
public static void printTextOn(PrintStream stream, OSCPacket p)
stream
- the print stream to use, for example System.out
p
- the packet to print (either a message or bundle)public static void printHexOn(PrintStream stream, ByteBuffer b)
printTextOn
this takes a raw received
or encoded byte buffer and not a decoded instance
of OSCPacket
.
stream
- the print stream to use, for example System.out
b
- the byte buffer containing the packet. read position
should be at the very beginning of the packet, limit
should be at the end of the packet. this method alters
the buffer position in a manner that a successive flip()
will restore the original position and limit.Buffer.limit()
,
Buffer.position()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |