FormAdapter

public final class FormAdapter

Class responsible for deserializing forms from JSON.

Methods

isAttribute

public static boolean isAttribute(String key)

Checks whether the given key is an attribute.

Parameters:
  • key – the key to be checked
Returns:

true if the key is an attribute, false otherwise

isValue

public static boolean isValue(String key)

Checks whether the given key is a value.

Parameters:
  • key – the key to be checked
Returns:

true if the key is a value, false otherwise

readJson

public static CommcareForm readJson(String json)

Deserializes the given JSON string into an instance of the CommcareForm class.

Parameters:
  • json – the JSON representation of the form
Returns:

the deserialized form

readListJson

public static CommcareFormList readListJson(String json)

Reads a list o forms with metadata from the json file. The result is represented as a CommcareFormList object.

Parameters:
  • json – the json to read
Returns:

the parsed value

recursivelyParse

public static FormValueElement recursivelyParse(String key, JsonElement jsonElement)

Parses the given jsonElement into an instance of the FormValueElement class. The created object will have its name set to the key.

Parameters:
  • key – the name of the element to set
  • jsonElement – the JSON element
Returns:

the parsed object