Package nl.tue.id.oocsi
Class OOCSIEvent
java.lang.Object
nl.tue.id.oocsi.OOCSIEvent
- Direct Known Subclasses:
OOCSIMessage
public class OOCSIEvent
extends java.lang.Object
event class for receiving events from OOCSI
- Author:
- matsfunk
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
channelName
protected java.util.Map<java.lang.String,java.lang.Object>
data
protected java.lang.String
sender
protected java.util.Date
timestamp
-
Constructor Summary
Constructors Constructor Description OOCSIEvent(java.lang.String channelName, java.util.Map<java.lang.String,java.lang.Object> data, java.lang.String sender)
constructor (implicit timestamp upon creation)OOCSIEvent(java.lang.String channelName, java.util.Map<java.lang.String,java.lang.Object> data, java.lang.String sender, long timestamp)
constructorOOCSIEvent(java.lang.String channelName, java.util.Map<java.lang.String,java.lang.Object> data, java.lang.String sender, java.util.Date timestamp)
constructor -
Method Summary
Modifier and Type Method Description <T> T[]
getArray(java.lang.String key, T[] defaultValue)
get the array value for the given key as array of type T.boolean
getBoolean(java.lang.String key, boolean defaultValue)
get value for the given key as booleanboolean[]
getBooleanArray(java.lang.String key, boolean[] defaultValue)
get the value for the given key as boolean array (boolean[])java.lang.String
getChannel()
get the name of the recipient or channel that this event was sent todouble
getDouble(java.lang.String key, double defaultValue)
get value for the given key as doubledouble[]
getDoubleArray(java.lang.String key, double[] defaultValue)
get the value for the given key as double array (double[])float
getFloat(java.lang.String key, float defaultValue)
get value for the given key as floatfloat[]
getFloatArray(java.lang.String key, float[] defaultValue)
get the value for the given key as float array (float[])int
getInt(java.lang.String key, int defaultValue)
get value for the given key as intint[]
getIntArray(java.lang.String key, int[] defaultValue)
get the value for the given key as int array (int[])long
getLong(java.lang.String key, long defaultValue)
get value for the given key as longlong[]
getLongArray(java.lang.String key, long[] defaultValue)
get the value for the given key as long array (long[])java.lang.Object
getObject(java.lang.String key)
get the value for the given key as Objectjava.lang.String
getRecipient()
get the name of the recipient or channel that this event was sent tojava.lang.String
getSender()
get the name or handle of the sender who sent this eventjava.lang.String
getString(java.lang.String key)
get the value for the given key as Stringjava.lang.String
getString(java.lang.String key, java.lang.String defaultValue)
get the value for the given key as Stringjava.lang.String[]
getStringArray(java.lang.String key, java.lang.String[] defaultValue)
get the value for the given key as String array (String[])long
getTime()
get timestamp of this event as long valuejava.util.Date
getTimestamp()
get timestamp of this event as Date objectboolean
has(java.lang.String key)
check if the event contains data with the keyjava.lang.String[]
keys()
retrieve all keys from the eventjava.lang.String
toString()
get a String representation of this eventMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Field Details
-
channelName
protected java.lang.String channelName -
sender
protected java.lang.String sender -
data
protected java.util.Map<java.lang.String,java.lang.Object> data -
timestamp
protected java.util.Date timestamp
-
-
Constructor Details
-
OOCSIEvent
public OOCSIEvent(java.lang.String channelName, java.util.Map<java.lang.String,java.lang.Object> data, java.lang.String sender)constructor (implicit timestamp upon creation)- Parameters:
channelName
- where to?data
- what data?sender
- who sends it?
-
OOCSIEvent
public OOCSIEvent(java.lang.String channelName, java.util.Map<java.lang.String,java.lang.Object> data, java.lang.String sender, long timestamp)constructor- Parameters:
channelName
- where to?data
- what data?sender
- who sends it?timestamp
- when? (as UNIX timestamp, long value)
-
OOCSIEvent
public OOCSIEvent(java.lang.String channelName, java.util.Map<java.lang.String,java.lang.Object> data, java.lang.String sender, java.util.Date timestamp)constructor- Parameters:
channelName
- where to?data
- what data?sender
- who sends it?timestamp
- when? (as Date object)
-
-
Method Details
-
getBoolean
public boolean getBoolean(java.lang.String key, boolean defaultValue)get value for the given key as boolean- Parameters:
key
-defaultValue
-- Returns:
-
getInt
public int getInt(java.lang.String key, int defaultValue)get value for the given key as int- Parameters:
key
-defaultValue
-- Returns:
-
getLong
public long getLong(java.lang.String key, long defaultValue)get value for the given key as long- Parameters:
key
-defaultValue
-- Returns:
-
getFloat
public float getFloat(java.lang.String key, float defaultValue)get value for the given key as float- Parameters:
key
-defaultValue
-- Returns:
-
getDouble
public double getDouble(java.lang.String key, double defaultValue)get value for the given key as double- Parameters:
key
-defaultValue
-- Returns:
-
getString
public java.lang.String getString(java.lang.String key)get the value for the given key as String- Parameters:
key
-- Returns:
-
getString
public java.lang.String getString(java.lang.String key, java.lang.String defaultValue)get the value for the given key as String- Parameters:
key
-defaultValue
-- Returns:
-
getBooleanArray
public boolean[] getBooleanArray(java.lang.String key, boolean[] defaultValue)get the value for the given key as boolean array (boolean[])- Parameters:
key
-defaultValue
-- Returns:
-
getIntArray
public int[] getIntArray(java.lang.String key, int[] defaultValue)get the value for the given key as int array (int[])- Parameters:
key
-defaultValue
-- Returns:
-
getFloatArray
public float[] getFloatArray(java.lang.String key, float[] defaultValue)get the value for the given key as float array (float[])- Parameters:
key
-defaultValue
-- Returns:
-
getLongArray
public long[] getLongArray(java.lang.String key, long[] defaultValue)get the value for the given key as long array (long[])- Parameters:
key
-defaultValue
-- Returns:
-
getDoubleArray
public double[] getDoubleArray(java.lang.String key, double[] defaultValue)get the value for the given key as double array (double[])- Parameters:
key
-defaultValue
-- Returns:
-
getStringArray
public java.lang.String[] getStringArray(java.lang.String key, java.lang.String[] defaultValue)get the value for the given key as String array (String[])- Parameters:
key
-defaultValue
-- Returns:
-
getArray
public <T> T[] getArray(java.lang.String key, T[] defaultValue)get the array value for the given key as array of type T. note that you need to call this with the type T specified. example: getArray() - Type Parameters:
T
-- Parameters:
key
-defaultValue
-- Returns:
-
getObject
public java.lang.Object getObject(java.lang.String key)get the value for the given key as Object- Parameters:
key
-- Returns:
-
has
public boolean has(java.lang.String key)check if the event contains data with the key- Parameters:
key
-- Returns:
-
keys
public java.lang.String[] keys()retrieve all keys from the event- Returns:
-
getSender
public java.lang.String getSender()get the name or handle of the sender who sent this event- Returns:
-
getRecipient
public java.lang.String getRecipient()get the name of the recipient or channel that this event was sent to- Returns:
-
getChannel
public java.lang.String getChannel()get the name of the recipient or channel that this event was sent to- Returns:
-
getTimestamp
public java.util.Date getTimestamp()get timestamp of this event as Date object- Returns:
-
getTime
public long getTime()get timestamp of this event as long value- Returns:
-
toString
public java.lang.String toString()get a String representation of this event- Overrides:
toString
in classjava.lang.Object
-