/*
* This class comes as is, no warranties whatsoever.
* Copyright Comerge AG 2009. All Rights Reserved."
*
* http://comerge.net
*/
package sudoku.internal;
import java.util.List;
import java.util.Map;
import javax.jms.JMSException;
import javax.jms.TextMessage;
import javax.jms.Message;
import net.comerge.aranea.core.messages.AraneaMessage;
import net.comerge.aranea.core.messages.AraneaMessageCreationException;
import net.comerge.aranea.core.messages.AraneaMessageFactory;
import net.comerge.aranea.core.messages.AraneaType;
import net.comerge.aranea.core.messages.json.JSONDeserializer;
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.core.*;
/**
* JSON deserializer for messages defined in the sudoku.core
namespace.
*
Deserializes messages for following types:
*
* solve_sudoku_request
* solved_sudoku_reply
*
* GENERATED DO NOT MODIFY
* @author Comerge AG http://www.comerge.net
*/
public class SudokuCoreMessageJSONDeserializer extends JSONDeserializer {
private final JSONValueSerializer fSerializer;
public SudokuCoreMessageJSONDeserializer() {
fSerializer= JSONValueSerializer.createDefault();
}
public AraneaMessage deserializeSolveSudokuRequestMessage(Message message_4711_) throws AraneaMessageCreationException {
JSONObject content_4711_= parseMessage(message_4711_);
try {
byte[] board= (byte[]) fSerializer.deserialize(sudoku.core.SudokuCoreMessageConstants
.SOLVE_SUDOKU_REQUEST_MESSAGE_BOARD_NAME
, content_4711_, null, AraneaType.BINARY);
return new SolveSudokuRequestMessage(board, null);
} catch (JSONException e) {
throw new AraneaMessageCreationException(e);
}
}
public AraneaMessage deserializeSolvedSudokuReplyMessage(Message message_4711_) throws AraneaMessageCreationException {
JSONObject content_4711_= parseMessage(message_4711_);
try {
byte[] board= (byte[]) fSerializer.deserialize(sudoku.core.SudokuCoreMessageConstants
.SOLVED_SUDOKU_REPLY_MESSAGE_BOARD_NAME
, content_4711_, null, AraneaType.BINARY);
List solutions= (List) fSerializer.deserialize(sudoku.core.SudokuCoreMessageConstants
.SOLVED_SUDOKU_REPLY_MESSAGE_SOLUTIONS_NAME
, content_4711_, null, AraneaType.SEQUENCE, AraneaType.BINARY);
return new SolvedSudokuReplyMessage(board, solutions, null);
} catch (JSONException e) {
throw new AraneaMessageCreationException(e);
}
}
}