AI2 Component  (Version nb184) Class Reference
Inheritance diagram for< YailList >

Public Member Functions

 YailDictionary ()
 YailDictionary (Map< Object, Object > prevMap)
void setPair (YailList pair)
Object getObjectAtKeyPath (List<?> keysOrIndices)
void setValueForKeyPath (List<?> keys, Object value)
boolean containsKey (Object key)
boolean containsValue (Object value)
Object get (Object key)
Object put (Object key, Object value)
Object remove (Object key)
String toString ()
Object getObject (int index)
Iterator< YailListiterator ()
- Public Member Functions inherited from< YailList >
Object getObject (int index)
int size ()
boolean isEmpty ()
Iterator< T > iterator ()

Static Public Member Functions

static YailDictionary makeDictionary ()
static YailDictionary makeDictionary (Map< Object, Object > prevMap)
static YailDictionary makeDictionary (Object... keysAndValues)
static YailDictionary makeDictionary (List< YailList > pairs)
static YailDictionary alistToDict (YailList alist)
static YailList dictToAlist (YailDictionary dict)
static< T > List< Object > walkKeyPath (YailObject<?> object, List< T > keysOrIndices)

Static Public Attributes

static final Object ALL

Detailed Description

The YailList is a wrapper around the gnu.list.Pair class used by the Kawa framework. YailList is the main list primitive used by App Inventor components.

Author (Danny Tang)

Definition at line 32 of file

Constructor & Destructor Documentation

◆ YailDictionary() [1/2] ( )

Create an empty YailDictionary.

Definition at line 46 of file

◆ YailDictionary() [2/2] ( Map< Object, Object >  prevMap)

Definition at line 50 of file

Member Function Documentation

◆ alistToDict()

static YailDictionary ( YailList  alist)

Definition at line 159 of file

◆ containsKey()

boolean ( Object  key)

Definition at line 500 of file

◆ containsValue()

boolean ( Object  value)

Definition at line 508 of file

◆ dictToAlist()

static YailList ( YailDictionary  dict)

Definition at line 227 of file

◆ get()

Object ( Object  key)

Definition at line 516 of file

◆ getObject()

Object ( int  index)

Definition at line 552 of file

◆ getObjectAtKeyPath()

Object ( List<?>  keysOrIndices)

Definition at line 262 of file

◆ iterator()

Iterator<YailList> ( )

Definition at line 570 of file

◆ makeDictionary() [1/4]

static YailDictionary ( )

Create an empty YailDictionary.

Definition at line 58 of file

◆ makeDictionary() [2/4]

static YailDictionary ( List< YailList pairs)

Construct a new dictionary from a list of pairs stored in



pairsThe list of pairs used to populate the dictionary.
A newly constructed dictionary from the pairs.
IndexOutOfBoundsExceptionif any of the lists isn't a pair.

Definition at line 119 of file

◆ makeDictionary() [3/4]

static YailDictionary ( Map< Object, Object >  prevMap)

Create a YailDictionary containing the contents of the given Map. The caller is responsible for ensuring that the contents of the map are coercible to types in YAIL.

prevMapThe existing collection to use in the YailDictionary.
A new YailDictionary that is a shallow copy of

Definition at line 71 of file

◆ makeDictionary() [4/4]

static YailDictionary ( Object...  keysAndValues)

Create a YailDictionary from the given list of keys and values. The list must have an even number of entries with the key first and value second for each pair of values.

For example:

YailDictionary.makeDictionary("foo", 1, "bar", 2);

will yield a YailDictionary object equivalent to the JSON:

{ "foo": 1, "bar": 2 }

keysAndValuesThe list of key-value pairs to be added to the YailDictionary.
A newly constructed YailDictionary object.

Definition at line 100 of file

◆ put()

Object ( Object  key,
Object  value 

Definition at line 524 of file

◆ remove()

Object ( Object  key)

Definition at line 535 of file

◆ setPair()

void ( YailList  pair)

Definition at line 235 of file

◆ setValueForKeyPath()

void ( List<?>  keys,
Object  value 

Sets the value for the given key path.

Key traversal occurs for both dictionaries and arrays. Consider the following JSON data structure:

    "data": [
        "id": 1,
        "name": "Foo",
        "address": {
          "number": 77,
          "street": "Massachusetts Avenue"
      }, {
        "id": 2,
        "name": "Bar"
        "address": {
          "number": 32,
          "street": "Vassar Street"

Calling setValueForKeyPath with the path ["data", 1, "name"] and the value "Baz" will update name of the first value from "Foo" to "Baz". This method will work so long as the path represented by the n-1 elements in the path exist in the data structure. Following the previous example, if one used the path ["data", 1, "course"] with the value 6, the first data element would have the course field added with the value 6:

    "id": 1,
    "name": "Baz",
    "address": {
      "number": 77,
      "street": "Massachusetts Avenue"
    "course": 6

If the last item in the path is a list and the given path index is a number, the item at the given index in the list will be replaced.

There are X error conditions that can occur when performing this operation. If an error occurs, it is thrown as a DispatchableError, which will result in the Screen's ErrorOccurred event to run.

  1. The item at a given point in the path is not a list or a dictionary
  2. The key in the path is mismatched to the data type at that location in the data structure. For example, a string is given as the key but the data structure at that point in the traversal is a list.
  3. The data structure at a given point in the traversal is a list and the key is a number, but the value is out of bounds for the list.
keysa list of keys to traverse in the dictionary
valuethe value to set at the end of the key path if the first n-1 keys map to a valid object.

Definition at line 469 of file

◆ toString()

String ( )

Definition at line 543 of file

◆ walkKeyPath()

static <T> List<Object> ( YailObject<?>  object,
List< T >  keysOrIndices 

Definition at line 361 of file

Member Data Documentation


final Object
Initial value:
= new Object() {
public String toString() {
return "ALL_ITEMS";

Definition at line 36 of file

The documentation for this class was generated from the following file:
String toString()