Package net.windwards.dnsfrontend.client

Source Code of net.windwards.dnsfrontend.client.JSONClientProtocol

package net.windwards.dnsfrontend.client;

import net.windwards.dnsfrontend.dialog.JSONProtocol;
import net.windwards.dnsfrontend.dialog.Message;
import net.windwards.dnsfrontend.dialog.ProtocolCodingException;
import net.windwards.dnsfrontend.dialog.Request;
import net.windwards.dnsfrontend.dialog.Update;

import java.io.IOException;


public class JSONClientProtocol extends JSONProtocol {
    public byte[] encode(Update update) throws ProtocolCodingException {
        try {
            return this.mapper.writeValueAsBytes(update);
        } catch (IOException e) {
            throw new ProtocolCodingException(e);
        }
    }

    public Message decode(byte[] data) throws ProtocolCodingException {
        try {
            return this.mapper.readValue(data, Message.class);
        } catch (IOException e) {
            throw new ProtocolCodingException(e);
        }
    }
}
TOP

Related Classes of net.windwards.dnsfrontend.client.JSONClientProtocol

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.