hermes.postoffice
Class OscMessage

java.lang.Object
  extended by hermes.postoffice.OscMessage
All Implemented Interfaces:
Message

public class OscMessage
extends java.lang.Object
implements Message

Message representing an OSC message.
Implements Message so that it can be used in PostOffice.
OSCMessages have arguments, which can be untyped, so great care must be taken by the user to ensure types.

Behavior for retrieving messages is First In, Last Out, meaning if you call a getAndRemove method, you'll receive arguments in the order that they were added to the message before it was sent.
Example: imagine your OSCMessage has a list of arguments: int A, string B, float C.
First, you would call "getAndRemoveInt()" which would return the int value of A.
Next, you would call "getAndRemoveString()" which would return string B.
Lastly, you would call getAndRemoveFloat()" which would return string C.
Take great care!!!! You should be well-aware of how many arguments a message will contain, and what types it has.


Constructor Summary
protected OscMessage(com.illposed.osc.OSCMessage message)
          Constructor taking an illposed OSCMessage.
  OscMessage(java.lang.String address, java.lang.Object[] contents)
          Basic constructor for unpacked OSCMessage.
 
Method Summary
 boolean equals(java.lang.Object o)
          Equality check for OscMessage, compares messages based on Address string.
 java.lang.String getAddress()
          Gets the OSCAddress that this message pertains to.
 float getAndRemoveFloat()
          Retrieves a float argument contained in the OSCMessage you've received.
 int getAndRemoveInt()
          Retrieves an int argument contained in the OSCMessage you've received.
 java.lang.String getAndRemoveString()
          Retrieves a String argument contained in the OSCMessage you've received.
protected  java.lang.Object[] getContents()
          Gets an object[] of the inner contents of an OSCMessage.
 int getNumberOfRemainingArguments()
          Returns the number of arguments available for extraction from this OSCMessage.
 java.lang.String getTypeTagOfNextArgument()
          Get the typetag of the next argument in this OSCMessage.
 boolean hasRemainingArguments()
          Method to find out if the user has any remaining arguments in the OSCMessage.
protected  com.illposed.osc.OSCMessage toIllposed()
          Get an illposed version of this message.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OscMessage

public OscMessage(java.lang.String address,
                  java.lang.Object[] contents)
Basic constructor for unpacked OSCMessage.

Parameters:
address - Address of OSCMessage
contents - Contents of OSCMessage

OscMessage

protected OscMessage(com.illposed.osc.OSCMessage message)
Constructor taking an illposed OSCMessage.

Parameters:
message - a packed OSCMessage in illposed's format
Method Detail

getNumberOfRemainingArguments

public int getNumberOfRemainingArguments()
Returns the number of arguments available for extraction from this OSCMessage.

Returns:
the number of arguments left to extract from this OSCMessage

hasRemainingArguments

public boolean hasRemainingArguments()
Method to find out if the user has any remaining arguments in the OSCMessage.

Returns:
true if the message has remaining arguments

getAndRemoveInt

public int getAndRemoveInt()
Retrieves an int argument contained in the OSCMessage you've received.

If your OSCMessage contains multiple arguments, call another "getAndRemove" method corresponding to the type of the next argument.

Returns:
the int argument in the OSCMessage

getAndRemoveString

public java.lang.String getAndRemoveString()
Retrieves a String argument contained in the OSCMessage you've received.

If your OSCMessage contains multiple arguments, call another "getAndRemove" method corresponding to the type of the next argument.

Returns:
the String argument in the OSCMessage

getAndRemoveFloat

public float getAndRemoveFloat()
Retrieves a float argument contained in the OSCMessage you've received.

If your OSCMessage contains multiple arguments, call another "getAndRemove" method corresponding to the type of the next argument.

Returns:
the float argument in the OSCMessage

getTypeTagOfNextArgument

public java.lang.String getTypeTagOfNextArgument()
Get the typetag of the next argument in this OSCMessage. This means: "i" for int, "f" for float, and "s" for string.
NOTE: if you have extracted all the arguments from this OSCMessage, calling this method will give an error.

Returns:
the typetag of the next argument in this OSCmessage

getAddress

public java.lang.String getAddress()
Gets the OSCAddress that this message pertains to.

Returns:
address

getContents

protected java.lang.Object[] getContents()
Gets an object[] of the inner contents of an OSCMessage. Be very careful using this! Please use getAndRemove methods instead!

Returns:
contents of message

toIllposed

protected com.illposed.osc.OSCMessage toIllposed()
Get an illposed version of this message.

Returns:
An illposed equivalent of this message

equals

public boolean equals(java.lang.Object o)
Equality check for OscMessage, compares messages based on Address string.

Overrides:
equals in class java.lang.Object