public class PebbleDictionary extends java.lang.Object implements java.lang.Iterable<PebbleTuple>
Modifier and Type | Class and Description |
---|---|
static class |
PebbleDictionary.PebbleDictTypeException |
static class |
PebbleDictionary.TupleOverflowException |
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.lang.Integer,PebbleTuple> |
tuples |
Constructor and Description |
---|
PebbleDictionary() |
Modifier and Type | Method and Description |
---|---|
void |
addBytes(int key,
byte[] bytes)
Associate the specified byte array with the provided key in the dictionary.
|
void |
addInt16(int key,
short s)
Associate the specified signed short with the provided key in the dictionary.
|
void |
addInt32(int key,
int i)
Associate the specified signed int with the provided key in the dictionary.
|
void |
addInt8(int key,
byte b)
Associate the specified signed byte with the provided key in the dictionary.
|
void |
addString(int key,
java.lang.String value)
Associate the specified String with the provided key in the dictionary.
|
protected void |
addTuple(PebbleTuple tuple) |
void |
addUint16(int key,
short s)
Associate the specified unsigned short with the provided key in the dictionary.
|
void |
addUint32(int key,
int i)
Associate the specified unsigned int with the provided key in the dictionary.
|
void |
addUint8(int key,
byte b)
Associate the specified unsigned byte with the provided key in the dictionary.
|
boolean |
contains(int key)
Returns true if this dictionary contains a mapping for the specified key.
|
static PebbleDictionary |
fromJson(java.lang.String jsonString)
Deserializes a JSON representation of a PebbleDictionary.
|
byte[] |
getBytes(int key)
Returns the byte array to which the specified key is mapped, or null if the key does not exist in this
dictionary.
|
java.lang.Long |
getInteger(int key)
Returns the signed integer to which the specified key is mapped, or null if the key does not exist in this
dictionary.
|
java.lang.String |
getString(int key)
Returns the string to which the specified key is mapped, or null if the key does not exist in this dictionary.
|
java.lang.Long |
getUnsignedIntegerAsLong(int key)
Returns the unsigned integer as a long to which the specified key is mapped, or null if the key does not exist in this
dictionary.
|
java.util.Iterator<PebbleTuple> |
iterator() |
void |
remove(int key)
Removes the mapping for a key from this map if it is present.
|
int |
size()
Returns the number of key-value pairs in this dictionary.
|
java.lang.String |
toJsonString()
Returns a JSON representation of this dictionary.
|
protected final java.util.Map<java.lang.Integer,PebbleTuple> tuples
public java.util.Iterator<PebbleTuple> iterator()
iterator
in interface java.lang.Iterable<PebbleTuple>
public int size()
public boolean contains(int key)
key
- key whose presence in this dictionary is to be testedpublic void remove(int key)
key
- key to be removed from the dictionarypublic void addBytes(int key, byte[] bytes)
key
- key with which the specified value is associatedbytes
- value to be associated with the specified keypublic void addString(int key, java.lang.String value)
key
- key with which the specified value is associatedvalue
- value to be associated with the specified keypublic void addInt8(int key, byte b)
key
- key with which the specified value is associatedb
- value to be associated with the specified keypublic void addUint8(int key, byte b)
key
- key with which the specified value is associatedb
- value to be associated with the specified keypublic void addInt16(int key, short s)
key
- key with which the specified value is associateds
- value to be associated with the specified keypublic void addUint16(int key, short s)
key
- key with which the specified value is associateds
- value to be associated with the specified keypublic void addInt32(int key, int i)
key
- key with which the specified value is associatedi
- value to be associated with the specified keypublic void addUint32(int key, int i)
key
- key with which the specified value is associatedi
- value to be associated with the specified keypublic java.lang.Long getInteger(int key)
key
- key whose associated value is to be returnedpublic java.lang.Long getUnsignedIntegerAsLong(int key)
key
- key whose associated value is to be returnedpublic byte[] getBytes(int key)
key
- key whose associated value is to be returnedpublic java.lang.String getString(int key)
key
- key whose associated value is to be returnedprotected void addTuple(PebbleTuple tuple)
public java.lang.String toJsonString()
public static PebbleDictionary fromJson(java.lang.String jsonString) throws org.json.JSONException
jsonString
- the JSON representation to be deserializedorg.json.JSONException
- thrown if the specified JSON representation cannot be parsed