public class Subscriptions extends SampMap
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
ATOM_REGEX |
private static java.util.regex.Pattern |
MSUB_PATTERN |
private static java.lang.String |
MSUB_REGEX |
private static java.lang.String |
MTYPE_REGEX |
Constructor and Description |
---|
Subscriptions()
Constructs an empty subscriptions object.
|
Subscriptions(java.util.Map map)
Constructs a subscriptions object based on an existing map.
|
Modifier and Type | Method and Description |
---|---|
void |
addMType(java.lang.String mtype)
Adds a subscription to a given MType.
|
static Subscriptions |
asSubscriptions(java.util.Map map)
Returns a given map in the form of a Subscriptions object.
|
void |
check()
Checks that this object is ready for use with the SAMP toolkit.
|
private static int |
countAtoms(java.lang.String text)
Counts the number of dot-separated "atoms" in a string.
|
java.util.Map |
getSubscription(java.lang.String mtype)
Returns the map which forms the value for a given MType key.
|
boolean |
isSubscribed(java.lang.String mtype)
Determines whether a given (non-wildcarded) MType is subscribed to
by this object.
|
static int |
matchLevel(java.lang.String pattern,
java.lang.String mtype)
Performs wildcard matching of MTypes.
|
checkHasKeys, entrySet, getList, getMap, getString, getUrl, put
clear, clone, containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, putAll, remove, size, toString, values
private static final java.lang.String ATOM_REGEX
private static java.lang.String MTYPE_REGEX
private static java.lang.String MSUB_REGEX
private static final java.util.regex.Pattern MSUB_PATTERN
public Subscriptions()
public Subscriptions(java.util.Map map)
map
- map containing initial data for this objectpublic void addMType(java.lang.String mtype)
mtype
may include
a wildcard according to the SAMP rules.mtype
- subscribed MType, possibly wildcardedpublic boolean isSubscribed(java.lang.String mtype)
mtype
- MType to testpublic java.util.Map getSubscription(java.lang.String mtype)
mtype
, the corresponding value is returned.
If mtype
is not subscribed to, null
is returned.mtype
- MType to querymtype
, or nullpublic void check()
SampMap
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.public static Subscriptions asSubscriptions(java.util.Map map)
map
- mappublic static int matchLevel(java.lang.String pattern, java.lang.String mtype)
pattern
- MType pattern; may contain a wildcardmtype
- unwildcarded MType for comparison with
pattern
pattern
which match
mtype
; if pattern
="*" the result is
0, and if there is no match the result is -1private static int countAtoms(java.lang.String text)
text
- string to test