Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public final class KanbanJson

  1. Object
  2. KanbanJson

Saves a board as JSON and reads it back.

DefaultKanbanModel model = new DefaultKanbanModel();
model.addColumn(new KanbanColumn("todo", "To do"));
KanbanBoard board = new KanbanBoard(model);

String json = KanbanJson.toJson(board.getModel());
Storage.getInstance().writeObject("board", json);
// later
board.setModel(KanbanJson.fromJson(json));

The document holds the lanes, and the columns in order, each with its cards in order. A card’s user data is the application’s own object and is left out unless a UserDataCodec says how to write it.

Nested types

interface KanbanJson.UserDataCodecTurns the user data of a card into something JSON can hold, and back.

Methods

public static String toJson(KanbanModel model)The whole board as a JSON document.
public static String toJson(KanbanModel model, KanbanJson.UserDataCodec codec)The whole board as a JSON document, with the cards’ user data written by a codec.
public static Map<String, Object> toMap(KanbanModel model, KanbanJson.UserDataCodec codec)The board as the tree a JSON writer takes: maps, lists, strings, numbers and booleans.
public static Map<String, Object> cardsToMap(Collection<KanbanCard> cards, KanbanJson.UserDataCodec codec)Cards alone, as a board puts them on the clipboard.
public static DefaultKanbanModel fromJson(String json) throws IOExceptionReads a board toJson wrote.
public static void read(String json, DefaultKanbanModel into, KanbanJson.UserDataCodec codec) throws IOExceptionReads a board toJson wrote into a model, adding to what it holds.
public static Map<String, Object> parse(String json) throws IOExceptionParses the text of a document toJson or a board’s clipboard wrote.
public static List<KanbanCard> readCards(Map<String, Object> holder, KanbanJson.UserDataCodec codec) throws IOExceptionReads the cards of a map cardsToMap built, or of one column of a board document, as a JSON parser returns it.

Inherited methods

Method details

toJson

public static String toJson(KanbanModel model)
The whole board as a JSON document.

toJson

public static String toJson(KanbanModel model, KanbanJson.UserDataCodec codec)
The whole board as a JSON document, with the cards’ user data written by a codec.

toMap

public static Map<String, Object> toMap(KanbanModel model, KanbanJson.UserDataCodec codec)
The board as the tree a JSON writer takes: maps, lists, strings, numbers and booleans.

cardsToMap

public static Map<String, Object> cardsToMap(Collection<KanbanCard> cards, KanbanJson.UserDataCodec codec)
Cards alone, as a board puts them on the clipboard.

fromJson

public static DefaultKanbanModel fromJson(String json) throws IOException
Reads a board toJson wrote.

Throws

IOException
when the text is not a board document, or a column, a lane or a card in it has no id

read

public static void read(String json, DefaultKanbanModel into, KanbanJson.UserDataCodec codec) throws IOException
Reads a board toJson wrote into a model, adding to what it holds.

Throws

IOException
when the text is not a board document, or a column, a lane or a card in it has no id or one that is taken; the model is then as it was

parse

public static Map<String, Object> parse(String json) throws IOException
Parses the text of a document toJson or a board’s clipboard wrote.

Throws

IOException
when the text is not a well-formed JSON object

readCards

public static List<KanbanCard> readCards(Map<String, Object> holder, KanbanJson.UserDataCodec codec) throws IOException
Reads the cards of a map cardsToMap built, or of one column of a board document, as a JSON parser returns it.

Throws

IOException
when a card has no id