/* * This class comes as is, no warranties whatsoever. * Copyright Comerge AG 2009. All Rights Reserved." * * http://comerge.net */ package sudoku.core; import java.util.Collections; import java.util.List; import java.util.Map; import net.comerge.aranea.core.messages.AraneaMessage; import net.comerge.aranea.core.messages.AraneaMessageHandler; import net.comerge.aranea.core.messages.AraneaType; import net.comerge.aranea.core.messages.AraneaMessageNamespace; import net.comerge.aranea.core.messages.AraneaMessageType; import net.comerge.aranea.core.messages.json.JSONValueSerializer; import net.comerge.aranea.core.messages.json.NestedRecord; import net.comerge.aranea.core.messages.json.NestedRecordFactory; import org.json.JSONException; import org.json.JSONObject; import sudoku.internal.*; /** * Message implementation for message of type SolvedSudokuReply defined in the sudoku.core namespace. *

GENERATED DO NOT MODIFY

* @author Comerge AG http://www.comerge.net */ public class SolvedSudokuReplyMessage extends AraneaMessage { /** * The sudoku for which solutions have been calculated. */ public final byte[] board; /** * All possible solutions for the given sudoku. */ public final List solutions; /** * Constructs a SolvedSudokuReply message without reply handler. * * @param board The sudoku for which solutions have been calculated. * @param solutions All possible solutions for the given sudoku. */ public SolvedSudokuReplyMessage(byte[] board, List solutions) { this(board, solutions, null); } /** * Constructs a SolvedSudokuReply message without reply handler. * * @param board The sudoku for which solutions have been calculated. * @param solutions All possible solutions for the given sudoku. * @param replyHandler the handler to call when a reply to this message is received. */ public SolvedSudokuReplyMessage(byte[] board, List solutions, AraneaMessageHandler replyHandler) { super(replyHandler); this.board= board; if (board == null) throw new IllegalArgumentException("board must not be null"); this.solutions= solutions; if (solutions == null) throw new IllegalArgumentException("solutions must not be null"); } public void serialize(JSONObject target) throws JSONException { JSONValueSerializer serializer= JSONValueSerializer.createDefault(); target.put(sudoku.core.SudokuCoreMessageConstants .SOLVED_SUDOKU_REPLY_MESSAGE_BOARD_NAME , serializer.serialize(board, AraneaType.BINARY)); target.put(sudoku.core.SudokuCoreMessageConstants .SOLVED_SUDOKU_REPLY_MESSAGE_SOLUTIONS_NAME , serializer.serialize(solutions, AraneaType.SEQUENCE, AraneaType.BINARY)); } /** * @inheritDoc */ @Override public AraneaMessageNamespace getNamespace() { return AraneaMessageNamespace.getNamespace(SudokuCoreMessageConstants.SUDOKU_CORE_NAMESPACE_NAME); } /** * @inheritDoc */ @Override public AraneaMessageType getType() { return AraneaMessageType.getType(getNamespace(), SudokuCoreMessageConstants.MESSAGE_TYPE_NAME_SOLVED_SUDOKU_REPLY); } }