|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractMap
org.astrogrid.samp.SampMap
public abstract class SampMap
Abstract superclass for objects represented within the SAMP package as
key-value maps. There are several of these, represented by subclasses
of SampMap, for instance Message, Metadata etc.
A SampMap is-a Map, but has some
additional useful features:
asClass
method to convert from a normal Map to the class in question
In general
any time a map-encoded object is required by a method in the toolkit,
any Map can be used. When the toolkit provides a map-encoded
object however (as return value or callback method parameter), an object
of the more specific SampMap type is used.
This allows maximum convenience for the application programmer, but
means that you don't have to use these additional features if you
don't want to, you can treat everything as a plain old Map.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
Map.Entry |
| Field Summary | |
|---|---|
static Map |
EMPTY
|
| Constructor Summary | |
|---|---|
protected |
SampMap(String[] knownKeys)
Constructor. |
| Method Summary | |
|---|---|
void |
check()
Checks that this object is ready for use with the SAMP toolkit. |
void |
checkHasKeys(String[] keys)
Checks that this map contains at least the given set of keys. |
Set |
entrySet()
|
List |
getList(String key)
Returns the value for a given key in this map, cast to List. |
Map |
getMap(String key)
returns the value for a given key in this map, cast to Map. |
String |
getString(String key)
Returns the value for a given key in this map, cast to String. |
URL |
getUrl(String key)
Returns the value for a given key in this map as a URL. |
Object |
put(Object key,
Object value)
|
| 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 |
| Field Detail |
|---|
public static final Map EMPTY
| Constructor Detail |
|---|
protected SampMap(String[] knownKeys)
knownKeys - array of well-known keys for this class| Method Detail |
|---|
public Object put(Object key,
Object value)
put in interface Mapput in class AbstractMappublic Set entrySet()
entrySet in interface MapentrySet in class AbstractMappublic void check()
SampUtils.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 informative DataException will be thrown.
DataException - if this object's current state
is not suitable for SAMP usepublic void checkHasKeys(String[] keys)
DataException will be
thrown. Normally called by check().
keys - array of required keys for this map
DataException - if this object does not contain entries
for all elements of the array keyspublic String getString(String key)
keypublic Map getMap(String key)
keypublic List getList(String key)
keypublic URL getUrl(String key)
key
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||