sky.monome.util
Class OSCMessageDigester

java.lang.Object
  extended by sky.monome.util.OSCMessageDigester

public class OSCMessageDigester
extends java.lang.Object

Digester for messages provided by the OSC protocol. With a digester, which treats the message, you can easily access to the instruction and arguments.

Author:
PJ Skyman

Field Summary
protected  java.lang.Object[] arguments
          Array of arguments included in the message digested by this digester.
protected  java.lang.String instruction
          Instruction included in the message digested by this digester.
 
Constructor Summary
OSCMessageDigester(com.illposed.osc.OSCMessage message)
          Constructs a message digester with the specified raw message.
 
Method Summary
<T> T
getArgument(java.lang.Class<T> clazz, int index)
          Returns the argument at the specified index included in the message digested by this digester.
<T> T
getArgument(int index)
          Returns the argument at the specified index included in the message digested by this digester.
 java.lang.String getInstruction()
          Returns the instruction included in the message digested by this digester.
 java.lang.String toString()
          Returns a string representation of this message digester.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

instruction

protected final java.lang.String instruction
Instruction included in the message digested by this digester.


arguments

protected final java.lang.Object[] arguments
Array of arguments included in the message digested by this digester.

Constructor Detail

OSCMessageDigester

public OSCMessageDigester(com.illposed.osc.OSCMessage message)
Constructs a message digester with the specified raw message.

Parameters:
message - Raw message which must be digested by this digester.
Method Detail

getInstruction

public java.lang.String getInstruction()
Returns the instruction included in the message digested by this digester. The returned instruction contains the initial slash character ('/').

Returns:
The instruction included in the message digested by this digester.

getArgument

public <T> T getArgument(int index)
Returns the argument at the specified index included in the message digested by this digester. The returned argument can be typed if you parametrize this call.

Type Parameters:
T - Type of the returned argument.
Parameters:
index - Index of the argument in the array of arguments.
Returns:
The (eventually typed) argument at the specified index included in the message digested by this digester.
Throws:
java.lang.ArrayIndexOutOfBoundsException - When the index is not valid for the array of arguments.
java.lang.ClassCastException - When the argument can't be typed to the specified type.
Since:
SkyMonome v1.1

getArgument

public <T> T getArgument(java.lang.Class<T> clazz,
                         int index)
Returns the argument at the specified index included in the message digested by this digester. The returned argument is typed, if possible, to the specified type.

Type Parameters:
T - Type of the returned argument.
Parameters:
clazz - Class object which indicates the type of the returned argument.
index - Index of the argument in the array of arguments.
Returns:
The typed argument at the specified index included in the message digested by this digester.
Throws:
java.lang.ArrayIndexOutOfBoundsException - When the index is not valid for the array of arguments.
java.lang.ClassCastException - When the argument can't be typed to the specified type.

toString

public java.lang.String toString()
Returns a string representation of this message digester.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of this message digester.