An exception thrown during encoding or decoding, indicating that the buffer is too small to encode that packet.
An exception thrown during decoding, indicating that the received packet is malformed and does not comply with the OSC standard.
An exception thrown during encoding or decoding, indicating that no atom exists to encode or decode a particular type.
Creates a new codec builder, initialized to strict OSC 1_0 spec.
A packet codec defines how the translation between Java objects and OSC atoms is accomplished. For example, by default, when an OSC message is assembled for transmission, the encoder will translate a
java.lang.Integer
argument into a four byte integer with typetag'i'
. Or when a received message is being decoded, finding an atom typetagged'f'
, the decoder will create ajava.lang.Float
out of it.This example sounds trivial, but the codec is also able to handle type conversions. For instance, in the strict OSC 1.0 specification, only 32bit numeric atoms are defined (
'i'
and'f'
). A codec with modeMODE_STRICT_V1
will reject ajava.lang.Double
in the encoding process and not be able to decode a typetag'd'
. A codec with modeMODE_MODEST
automatically breaks down everything the 32bit, so ajava.lang.Double
gets encoded as 32bit'f'
and a received atom tagged'd'
becomes ajava.lang.Float
. Other configurations exist.Another important function of the codec is to specify the charset encoding of strings, something that was overseen in the OSC 1.0 spec. By default,
UTF-8
is used so all special characters can be safely encoded.Last but not least, using the
putDecoder
andputEncoder
methods, the codec can be extended to support additional Java classes or OSC typetags, without the need to subclassPacketCodec
.