/**
 * This class is automatically generated by mig. DO NOT EDIT THIS FILE.
 * This class implements a Java interface to the 'ConnlessMsg'
 * message type.
 */

public class ConnlessMsg extends net.tinyos.message.Message {

    /** The default size of this message type in bytes. */
    public static final int DEFAULT_MESSAGE_SIZE = 108;

    /** The Active Message type associated with this message. */
    public static final int AM_TYPE = 27;

    /** Create a new ConnlessMsg of size 108. */
    public ConnlessMsg() {
        super(DEFAULT_MESSAGE_SIZE);
        amTypeSet(AM_TYPE);
    }

    /** Create a new ConnlessMsg of the given data_length. */
    public ConnlessMsg(int data_length) {
        super(data_length);
        amTypeSet(AM_TYPE);
    }

    /**
     * Create a new ConnlessMsg with the given data_length
     * and base offset.
     */
    public ConnlessMsg(int data_length, int base_offset) {
        super(data_length, base_offset);
        amTypeSet(AM_TYPE);
    }

    /**
     * Create a new ConnlessMsg using the given byte array
     * as backing store.
     */
    public ConnlessMsg(byte[] data) {
        super(data);
        amTypeSet(AM_TYPE);
    }

    /**
     * Create a new ConnlessMsg using the given byte array
     * as backing store, with the given base offset.
     */
    public ConnlessMsg(byte[] data, int base_offset) {
        super(data, base_offset);
        amTypeSet(AM_TYPE);
    }

    /**
     * Create a new ConnlessMsg using the given byte array
     * as backing store, with the given base offset and data length.
     */
    public ConnlessMsg(byte[] data, int base_offset, int data_length) {
        super(data, base_offset, data_length);
        amTypeSet(AM_TYPE);
    }

    /**
     * Create a new ConnlessMsg embedded in the given message
     * at the given base offset.
     */
    public ConnlessMsg(net.tinyos.message.Message msg, int base_offset) {
        super(msg, base_offset, DEFAULT_MESSAGE_SIZE);
        amTypeSet(AM_TYPE);
    }

    /**
     * Create a new ConnlessMsg embedded in the given message
     * at the given base offset and length.
     */
    public ConnlessMsg(net.tinyos.message.Message msg, int base_offset, int data_length) {
        super(msg, base_offset, data_length);
        amTypeSet(AM_TYPE);
    }

    /**
    /* Return a String representation of this message. Includes the
     * message type name and the non-indexed field values.
     */
    public String toString() {
      String s = "Message <ConnlessMsg> \n";
      try {
        s += "  [msg_type=0x"+Long.toHexString(get_msg_type())+"]\n";
      } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ }
      try {
        s += "  [island_addr=0x"+Long.toHexString(get_island_addr())+"]\n";
      } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ }
      try {
        s += "  [mote_addr=0x"+Long.toHexString(get_mote_addr())+"]\n";
      } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ }
      try {
        s += "  [reliable=0x"+Long.toHexString(get_reliable())+"]\n";
      } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ }
      try {
        s += "  [seq_num=0x"+Long.toHexString(get_seq_num())+"]\n";
      } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ }
      try {
        s += "  [nbytes=0x"+Long.toHexString(get_nbytes())+"]\n";
      } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ }
      try {
        s += "  [payload=";
        for (int i = 0; i < 100; i++) {
          s += "0x"+Long.toHexString(getElement_payload(i) & 0xff)+" ";
        }
        s += "]\n";
      } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ }
      return s;
    }

    // Message-type-specific access methods appear below.

    /////////////////////////////////////////////////////////
    // Accessor methods for field: msg_type
    //   Field type: short, signed
    //   Offset (bits): 0
    //   Size (bits): 8
    /////////////////////////////////////////////////////////

    /**
     * Return whether the field 'msg_type' is signed (true).
     */
    public static boolean isSigned_msg_type() {
        return true;
    }

    /**
     * Return whether the field 'msg_type' is an array (false).
     */
    public static boolean isArray_msg_type() {
        return false;
    }

    /**
     * Return the offset (in bytes) of the field 'msg_type'
     */
    public static int offset_msg_type() {
        return (0 / 8);
    }

    /**
     * Return the offset (in bits) of the field 'msg_type'
     */
    public static int offsetBits_msg_type() {
        return 0;
    }

    /**
     * Return the value (as a short) of the field 'msg_type'
     */
    public short get_msg_type() {
        return (short)getUIntBEElement(offsetBits_msg_type(), 8);
    }

    /**
     * Set the value of the field 'msg_type'
     */
    public void set_msg_type(short value) {
        setUIntBEElement(offsetBits_msg_type(), 8, value);
    }

    /**
     * Return the size, in bytes, of the field 'msg_type'
     */
    public static int size_msg_type() {
        return (8 / 8);
    }

    /**
     * Return the size, in bits, of the field 'msg_type'
     */
    public static int sizeBits_msg_type() {
        return 8;
    }

    /////////////////////////////////////////////////////////
    // Accessor methods for field: island_addr
    //   Field type: short, signed
    //   Offset (bits): 8
    //   Size (bits): 8
    /////////////////////////////////////////////////////////

    /**
     * Return whether the field 'island_addr' is signed (true).
     */
    public static boolean isSigned_island_addr() {
        return true;
    }

    /**
     * Return whether the field 'island_addr' is an array (false).
     */
    public static boolean isArray_island_addr() {
        return false;
    }

    /**
     * Return the offset (in bytes) of the field 'island_addr'
     */
    public static int offset_island_addr() {
        return (8 / 8);
    }

    /**
     * Return the offset (in bits) of the field 'island_addr'
     */
    public static int offsetBits_island_addr() {
        return 8;
    }

    /**
     * Return the value (as a short) of the field 'island_addr'
     */
    public short get_island_addr() {
        return (short)getUIntBEElement(offsetBits_island_addr(), 8);
    }

    /**
     * Set the value of the field 'island_addr'
     */
    public void set_island_addr(short value) {
        setUIntBEElement(offsetBits_island_addr(), 8, value);
    }

    /**
     * Return the size, in bytes, of the field 'island_addr'
     */
    public static int size_island_addr() {
        return (8 / 8);
    }

    /**
     * Return the size, in bits, of the field 'island_addr'
     */
    public static int sizeBits_island_addr() {
        return 8;
    }

    /////////////////////////////////////////////////////////
    // Accessor methods for field: mote_addr
    //   Field type: int, signed
    //   Offset (bits): 16
    //   Size (bits): 16
    /////////////////////////////////////////////////////////

    /**
     * Return whether the field 'mote_addr' is signed (true).
     */
    public static boolean isSigned_mote_addr() {
        return true;
    }

    /**
     * Return whether the field 'mote_addr' is an array (false).
     */
    public static boolean isArray_mote_addr() {
        return false;
    }

    /**
     * Return the offset (in bytes) of the field 'mote_addr'
     */
    public static int offset_mote_addr() {
        return (16 / 8);
    }

    /**
     * Return the offset (in bits) of the field 'mote_addr'
     */
    public static int offsetBits_mote_addr() {
        return 16;
    }

    /**
     * Return the value (as a int) of the field 'mote_addr'
     */
    public int get_mote_addr() {
        return (int)getUIntBEElement(offsetBits_mote_addr(), 16);
    }

    /**
     * Set the value of the field 'mote_addr'
     */
    public void set_mote_addr(int value) {
        setUIntBEElement(offsetBits_mote_addr(), 16, value);
    }

    /**
     * Return the size, in bytes, of the field 'mote_addr'
     */
    public static int size_mote_addr() {
        return (16 / 8);
    }

    /**
     * Return the size, in bits, of the field 'mote_addr'
     */
    public static int sizeBits_mote_addr() {
        return 16;
    }

    /////////////////////////////////////////////////////////
    // Accessor methods for field: reliable
    //   Field type: byte, signed
    //   Offset (bits): 32
    //   Size (bits): 8
    /////////////////////////////////////////////////////////

    /**
     * Return whether the field 'reliable' is signed (true).
     */
    public static boolean isSigned_reliable() {
        return true;
    }

    /**
     * Return whether the field 'reliable' is an array (false).
     */
    public static boolean isArray_reliable() {
        return false;
    }

    /**
     * Return the offset (in bytes) of the field 'reliable'
     */
    public static int offset_reliable() {
        return (32 / 8);
    }

    /**
     * Return the offset (in bits) of the field 'reliable'
     */
    public static int offsetBits_reliable() {
        return 32;
    }

    /**
     * Return the value (as a byte) of the field 'reliable'
     */
    public byte get_reliable() {
        return (byte)getSIntBEElement(offsetBits_reliable(), 8);
    }

    /**
     * Set the value of the field 'reliable'
     */
    public void set_reliable(byte value) {
        setSIntBEElement(offsetBits_reliable(), 8, value);
    }

    /**
     * Return the size, in bytes, of the field 'reliable'
     */
    public static int size_reliable() {
        return (8 / 8);
    }

    /**
     * Return the size, in bits, of the field 'reliable'
     */
    public static int sizeBits_reliable() {
        return 8;
    }

    /////////////////////////////////////////////////////////
    // Accessor methods for field: seq_num
    //   Field type: int, signed
    //   Offset (bits): 40
    //   Size (bits): 16
    /////////////////////////////////////////////////////////

    /**
     * Return whether the field 'seq_num' is signed (true).
     */
    public static boolean isSigned_seq_num() {
        return true;
    }

    /**
     * Return whether the field 'seq_num' is an array (false).
     */
    public static boolean isArray_seq_num() {
        return false;
    }

    /**
     * Return the offset (in bytes) of the field 'seq_num'
     */
    public static int offset_seq_num() {
        return (40 / 8);
    }

    /**
     * Return the offset (in bits) of the field 'seq_num'
     */
    public static int offsetBits_seq_num() {
        return 40;
    }

    /**
     * Return the value (as a int) of the field 'seq_num'
     */
    public int get_seq_num() {
        return (int)getUIntBEElement(offsetBits_seq_num(), 16);
    }

    /**
     * Set the value of the field 'seq_num'
     */
    public void set_seq_num(int value) {
        setUIntBEElement(offsetBits_seq_num(), 16, value);
    }

    /**
     * Return the size, in bytes, of the field 'seq_num'
     */
    public static int size_seq_num() {
        return (16 / 8);
    }

    /**
     * Return the size, in bits, of the field 'seq_num'
     */
    public static int sizeBits_seq_num() {
        return 16;
    }

    /////////////////////////////////////////////////////////
    // Accessor methods for field: nbytes
    //   Field type: short, signed
    //   Offset (bits): 56
    //   Size (bits): 8
    /////////////////////////////////////////////////////////

    /**
     * Return whether the field 'nbytes' is signed (true).
     */
    public static boolean isSigned_nbytes() {
        return true;
    }

    /**
     * Return whether the field 'nbytes' is an array (false).
     */
    public static boolean isArray_nbytes() {
        return false;
    }

    /**
     * Return the offset (in bytes) of the field 'nbytes'
     */
    public static int offset_nbytes() {
        return (56 / 8);
    }

    /**
     * Return the offset (in bits) of the field 'nbytes'
     */
    public static int offsetBits_nbytes() {
        return 56;
    }

    /**
     * Return the value (as a short) of the field 'nbytes'
     */
    public short get_nbytes() {
        return (short)getUIntBEElement(offsetBits_nbytes(), 8);
    }

    /**
     * Set the value of the field 'nbytes'
     */
    public void set_nbytes(short value) {
        setUIntBEElement(offsetBits_nbytes(), 8, value);
    }

    /**
     * Return the size, in bytes, of the field 'nbytes'
     */
    public static int size_nbytes() {
        return (8 / 8);
    }

    /**
     * Return the size, in bits, of the field 'nbytes'
     */
    public static int sizeBits_nbytes() {
        return 8;
    }

    /////////////////////////////////////////////////////////
    // Accessor methods for field: payload
    //   Field type: byte[], signed
    //   Offset (bits): 64
    //   Size of each element (bits): 8
    /////////////////////////////////////////////////////////

    /**
     * Return whether the field 'payload' is signed (true).
     */
    public static boolean isSigned_payload() {
        return true;
    }

    /**
     * Return whether the field 'payload' is an array (true).
     */
    public static boolean isArray_payload() {
        return true;
    }

    /**
     * Return the offset (in bytes) of the field 'payload'
     */
    public static int offset_payload(int index1) {
        int offset = 64;
        if (index1 < 0 || index1 >= 100) throw new ArrayIndexOutOfBoundsException();
        offset += 0 + index1 * 8;
        return (offset / 8);
    }

    /**
     * Return the offset (in bits) of the field 'payload'
     */
    public static int offsetBits_payload(int index1) {
        int offset = 64;
        if (index1 < 0 || index1 >= 100) throw new ArrayIndexOutOfBoundsException();
        offset += 0 + index1 * 8;
        return offset;
    }

    /**
     * Return the entire array 'payload' as a byte[]
     */
    public byte[] get_payload() {
        byte[] tmp = new byte[100];
        for (int index0 = 0; index0 < numElements_payload(0); index0++) {
            tmp[index0] = getElement_payload(index0);
        }
        return tmp;
    }

    /**
     * Set the contents of the array 'payload' from the given byte[]
     */
    public void set_payload(byte[] value) {
        for (int index0 = 0; index0 < value.length; index0++) {
            setElement_payload(index0, value[index0]);
        }
    }

    /**
     * Return an element (as a byte) of the array 'payload'
     */
    public byte getElement_payload(int index1) {
        return (byte)getSIntBEElement(offsetBits_payload(index1), 8);
    }

    /**
     * Set an element of the array 'payload'
     */
    public void setElement_payload(int index1, byte value) {
        setSIntBEElement(offsetBits_payload(index1), 8, value);
    }

    /**
     * Return the total size, in bytes, of the array 'payload'
     */
    public static int totalSize_payload() {
        return (800 / 8);
    }

    /**
     * Return the total size, in bits, of the array 'payload'
     */
    public static int totalSizeBits_payload() {
        return 800;
    }

    /**
     * Return the size, in bytes, of each element of the array 'payload'
     */
    public static int elementSize_payload() {
        return (8 / 8);
    }

    /**
     * Return the size, in bits, of each element of the array 'payload'
     */
    public static int elementSizeBits_payload() {
        return 8;
    }

    /**
     * Return the number of dimensions in the array 'payload'
     */
    public static int numDimensions_payload() {
        return 1;
    }

    /**
     * Return the number of elements in the array 'payload'
     */
    public static int numElements_payload() {
        return 100;
    }

    /**
     * Return the number of elements in the array 'payload'
     * for the given dimension.
     */
    public static int numElements_payload(int dimension) {
      int array_dims[] = { 100,  };
        if (dimension < 0 || dimension >= 1) throw new ArrayIndexOutOfBoundsException();
        if (array_dims[dimension] == 0) throw new IllegalArgumentException("Array dimension "+dimension+" has unknown size");
        return array_dims[dimension];
    }

    /**
     * Fill in the array 'payload' with a String
     */
    public void setString_payload(String s) { 
         int len = s.length();
         int i;
         for (i = 0; i < len; i++) {
             setElement_payload(i, (byte)s.charAt(i));
         }
         setElement_payload(i, (byte)0); //null terminate
    }

    /**
     * Read the array 'payload' as a String
     */
    public String getString_payload() { 
         char carr[] = new char[Math.min(net.tinyos.message.Message.MAX_CONVERTED_STRING_LENGTH,100)];
         int i;
         for (i = 0; i < carr.length; i++) {
             if ((char)getElement_payload(i) == (char)0) break;
             carr[i] = (char)getElement_payload(i);
         }
         return new String(carr,0,i);
    }

}
