package com.biotronisis.pettplant.communication.transfer;

import java.io.Serializable;

public abstract class AbstractResponse implements Serializable {
    private static final long serialVersionUID = 1L;

    public abstract void fromResponseBytes(byte[] responseBytes);

    public abstract Byte getResponseId();

    public abstract int getMinimumResponseLength();

    public int asInt(byte msb, byte lsb) {
        int msbInt = msb & (0x000000FF);
        int lsbInt = lsb & (0x000000FF);
//		int result = (msbInt << 8) + lsbInt;     // DEBUG
//        return result;
        return (msbInt << 8) + lsbInt;
    }

    int asInt(byte myByte) {
        return myByte & (0x000000FF);
    }

    public boolean validateChecksum(byte[] bytes) {
        boolean result = true;

        if (bytes.length < getMinimumResponseLength()) {
            result = false;
//			return false;              // DEBUG
        }

//		int msglen = bytes[0]+1;
        if (bytes.length != bytes[0] + 1) {
            result = false;
//			return false;
        }

        byte checksum = 0;
        for (int i = 0; i < bytes.length - 1; i++) {
            checksum ^= bytes[i];
        }

        if (checksum != bytes[bytes.length - 1]) {
            result = false;
//			return false;
        }
        return result;
//		return true;
    }

}


@@ -861,49 +861,8 @@
 se;%0A
-//%09%09%09return false;              // DEBUG%0A
     
@@ -969,35 +969,16 @@
  false;%0A
-//%09%09%09return false;%0A
         
@@ -1188,27 +1188,8 @@
 se;%0A
-//%09%09%09return false;%0A
     
@@ -1221,25 +1221,8 @@
 lt;%0A
-//%09%09return true;%0A
     

Delete several commented out lines.