package network.MessageDecoders; import java.util.Arrays; import static network.Utils.ByteConverter.*; /** * Created by hba56 on 21/04/17. */ public class RaceStartStatusDecoder { private byte messageVersion; private byte[] timestamp; private byte[] ackNumber; private byte[] raceStartTime; private byte[] raceIdentifier; private byte notificationType; private long time; private short ack; private long startTime; private int raceID; private char notification; public RaceStartStatusDecoder(byte[] encodedRaceStartStatus) { messageVersion = encodedRaceStartStatus[0]; timestamp = Arrays.copyOfRange(encodedRaceStartStatus, 1, 7); ackNumber = Arrays.copyOfRange(encodedRaceStartStatus, 7, 9); raceStartTime = Arrays.copyOfRange(encodedRaceStartStatus, 9, 15); raceIdentifier = Arrays.copyOfRange(encodedRaceStartStatus, 15, 19); notificationType = encodedRaceStartStatus[19]; time = bytesToLong(timestamp); ack = bytesToShort(ackNumber); startTime = bytesToLong(raceStartTime); raceID = bytesToInt(raceIdentifier); notification = bytesToChar(notificationType); } public byte getMessageVersion() { return messageVersion; } public long getTime() { return time; } public short getAck() { return ack; } public long getStartTime() { return startTime; } public int getRaceID() { return raceID; } public char getNotification() { return notification; } }