Class KanbanJson
java.lang.Object
com.codename1.kanban.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 Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceTurns the user data of a card into something JSON can hold, and back. -
Method Summary
Modifier and TypeMethodDescriptioncardsToMap(Collection<KanbanCard> cards, KanbanJson.UserDataCodec codec) Cards alone, as a board puts them on the clipboard.static DefaultKanbanModelReads a boardtoJsonwrote.Parses the text of a documenttoJsonor a board's clipboard wrote.static voidread(String json, DefaultKanbanModel into, KanbanJson.UserDataCodec codec) Reads a boardtoJsonwrote into a model, adding to what it holds.static List<KanbanCard> readCards(Map<String, Object> holder, KanbanJson.UserDataCodec codec) Reads the cards of a mapcardsToMapbuilt, or of one column of a board document, as a JSON parser returns it.static StringtoJson(KanbanModel model) The whole board as a JSON document.static StringtoJson(KanbanModel model, KanbanJson.UserDataCodec codec) The whole board as a JSON document, with the cards' user data written by a codec.toMap(KanbanModel model, KanbanJson.UserDataCodec codec) The board as the tree a JSON writer takes: maps, lists, strings, numbers and booleans.
-
Method Details
-
toJson
The whole board as a JSON document. -
toJson
The whole board as a JSON document, with the cards' user data written by a codec. -
toMap
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
Reads a board
toJsonwrote.Throws
IOException: when the text is not a board document, or a column, a lane or a card in it has no id
- Throws:
IOException
-
read
public static void read(String json, DefaultKanbanModel into, KanbanJson.UserDataCodec codec) throws IOException Reads a board
toJsonwrote 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
- Throws:
IOException
-
parse
Parses the text of a document
toJsonor a board's clipboard wrote.Throws
IOException: when the text is not a well-formed JSON object
- Throws:
IOException
-
readCards
public static List<KanbanCard> readCards(Map<String, Object> holder, KanbanJson.UserDataCodec codec) throws IOExceptionReads the cards of a map
cardsToMapbuilt, or of one column of a board document, as a JSON parser returns it.Throws
IOException: when a card has no id
- Throws:
IOException
-