Package org.astrogrid.samp
Class Message
java.lang.Object
java.util.AbstractMap
org.astrogrid.samp.SampMap
org.astrogrid.samp.Message
- All Implemented Interfaces:
Map
Represents an encoded SAMP Message.
- Since:
- 14 Jul 2008
- Author:
- Mark Taylor
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,
V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSets the value for a single entry in this message'ssamp.params
map.static Message
Returns a given map as a Message object.void
check()
Checks that this object is ready for use with the SAMP toolkit.getMType()
Returns this message's MType.Returns the value of a single entry in this message'ssamp.params
map.Returns this message's params map.getRequiredParam
(String name) Returns the value of a single entry in this message'ssamp.params
map, throwing an exception if it is not present.void
Sets this message's params map.Methods inherited from class org.astrogrid.samp.SampMap
checkHasKeys, entrySet, getList, getMap, getString, getUrl, put
Methods inherited from class java.util.AbstractMap
clear, clone, containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, putAll, remove, size, toString, values
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
MTYPE_KEY
Key for message MType.- See Also:
-
PARAMS_KEY
Key for map of parameters used by this message.- See Also:
-
-
Constructor Details
-
Message
public Message()Constructs an empty message. -
Message
Constructs a message based on an existing map.- Parameters:
map
- map containing initial data for this object
-
Message
Constructs a message with a given MType and params map.- Parameters:
mtype
- value forMTYPE_KEY
keyparams
- value forPARAMS_KEY
key
-
Message
Constructs a message with a given MType. The parameters map will be mutable.- Parameters:
mtype
- value forMTYPE_KEY
key
-
-
Method Details
-
getMType
Returns this message's MType.- Returns:
- value for
MTYPE_KEY
-
setParams
Sets this message's params map.- Parameters:
params
- value forPARAMS_KEY
-
getParams
Returns this message's params map.- Returns:
- value for
PARAMS_KEY
-
addParam
Sets the value for a single entry in this message'ssamp.params
map.- Parameters:
name
- param namevalue
- param value
-
getParam
Returns the value of a single entry in this message'ssamp.params
map. Null is returned if the parameter does not appear.- Parameters:
name
- param name- Returns:
- param value, or null
-
getRequiredParam
Returns the value of a single entry in this message'ssamp.params
map, throwing an exception if it is not present.- Parameters:
name
- param name- Returns:
- param value
- Throws:
DataException
- if no parametername
is present
-
check
public void check()Description copied from class:SampMap
Checks that this object is ready for use with the SAMP toolkit. As well as callingSampUtils.checkMap(java.util.Map)
(ensuring that all keys are Strings, and all values Strings, Lists or Maps), subclass-specific invariants may be checked. In the case that there's something wrong, an informativeDataException
will be thrown. -
asMessage
Returns a given map as a Message object.- Parameters:
map
- map- Returns:
- message
-