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

package net.tinyos.tinydb;

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

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

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

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

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

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

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

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

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

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

    /**
     * Create a new StatusMsg embedded in the given message
     * at the given base offset and length.
     */
    public StatusMsg(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 <StatusMsg> \n";
      try {
        s += "  [fromBase=0x"+Long.toHexString(get_fromBase())+"]\n";
      } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ }
      try {
        s += "  [numQueries=0x"+Long.toHexString(get_numQueries())+"]\n";
      } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ }
      try {
        s += "  [queries=";
        for (int i = 0; i < 8; i++) {
          s += "0x"+Long.toHexString(getElement_queries(i) & 0xff)+" ";
        }
        s += "]\n";
      } catch (ArrayIndexOutOfBoundsException aioobe) { /* Skip field */ }
      return s;
    }

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

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

    /**
     * Return whether the field 'fromBase' is signed (false).
     */
    public static boolean isSigned_fromBase() {
        return false;
    }

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

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

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

    /**
     * Return the value (as a short) of the field 'fromBase'
     */
    public short get_fromBase() {
        return (short)getUIntElement(offsetBits_fromBase(), 8);
    }

    /**
     * Set the value of the field 'fromBase'
     */
    public void set_fromBase(short value) {
        setUIntElement(offsetBits_fromBase(), 8, value);
    }

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

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

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

    /**
     * Return whether the field 'numQueries' is signed (false).
     */
    public static boolean isSigned_numQueries() {
        return false;
    }

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

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

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

    /**
     * Return the value (as a short) of the field 'numQueries'
     */
    public short get_numQueries() {
        return (short)getUIntElement(offsetBits_numQueries(), 8);
    }

    /**
     * Set the value of the field 'numQueries'
     */
    public void set_numQueries(short value) {
        setUIntElement(offsetBits_numQueries(), 8, value);
    }

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

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

    /////////////////////////////////////////////////////////
    // Accessor methods for field: queries
    //   Field type: short[], unsigned
    //   Offset (bits): 16
    //   Size of each element (bits): 8
    /////////////////////////////////////////////////////////

    /**
     * Return whether the field 'queries' is signed (false).
     */
    public static boolean isSigned_queries() {
        return false;
    }

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

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

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

    /**
     * Return the entire array 'queries' as a short[]
     */
    public short[] get_queries() {
        short[] tmp = new short[8];
        for (int index0 = 0; index0 < numElements_queries(0); index0++) {
            tmp[index0] = getElement_queries(index0);
        }
        return tmp;
    }

    /**
     * Set the contents of the array 'queries' from the given short[]
     */
    public void set_queries(short[] value) {
        for (int index0 = 0; index0 < value.length; index0++) {
            setElement_queries(index0, value[index0]);
        }
    }

    /**
     * Return an element (as a short) of the array 'queries'
     */
    public short getElement_queries(int index1) {
        return (short)getUIntElement(offsetBits_queries(index1), 8);
    }

    /**
     * Set an element of the array 'queries'
     */
    public void setElement_queries(int index1, short value) {
        setUIntElement(offsetBits_queries(index1), 8, value);
    }

    /**
     * Return the total size, in bytes, of the array 'queries'
     */
    public static int totalSize_queries() {
        return (64 / 8);
    }

    /**
     * Return the total size, in bits, of the array 'queries'
     */
    public static int totalSizeBits_queries() {
        return 64;
    }

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

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

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

    /**
     * Return the number of elements in the array 'queries'
     */
    public static int numElements_queries() {
        return 8;
    }

    /**
     * Return the number of elements in the array 'queries'
     * for the given dimension.
     */
    public static int numElements_queries(int dimension) {
      int array_dims[] = { 8,  };
        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 'queries' with a String
     */
    public void setString_queries(String s) { 
         int len = s.length();
         int i;
         for (i = 0; i < len; i++) {
             setElement_queries(i, (short)s.charAt(i));
         }
         setElement_queries(i, (short)0); //null terminate
    }

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

}
