return _cbuffer;
}
+ /**
+ * Converts the parameter to a hex value.
+ *
+ * @param value The value to convert
+ * @return A String representing the array of bytes
+ */
+ public static String toHex(final byte[] value)
+ {
+ StringBuffer retVal = new StringBuffer();
+ retVal.append('[');
+ for(int x = 0; x < value.length; x++)
+ {
+ retVal.append(toHex(value[x]));
+ retVal.append(", ");
+ }
+ retVal.append(']');
+ return retVal.toString();
+ }
/**
* Converts the parameter to a hex value.
*
}
/**
- * get a short array from a byte array. The short array is assumed
- * to start with a word describing the length of the array.
+ * get a short array from a byte array.
*/
- public static short[] getShortArray(final byte[] data, final int offset)
+ public static short[] getSimpleShortArray(final byte[] data, final int offset, final int size)
{
- int size = (short) getNumber(data, offset, SHORT_SIZE);
short[] results = new short[size];
for (int i = 0; i < size; i++)
{
}
return results;
}
+ /**
+ * get a short array from a byte array. The short array is assumed
+ * to start with a word describing the length of the array.
+ */
+ public static short[] getShortArray(final byte[] data, final int offset)
+ {
+ int size = (short) getNumber(data, offset, SHORT_SIZE);
+ short[] results = getSimpleShortArray(data, offset, size);
+ return results;
+ }
/**
* get a short value from the beginning of a byte array
{
return getUnsignedByte(data, 0);
}
+ /**
+ * Copy a portion of a byte array
+ *
+ * @param data the original byte array
+ * @param offset Where to start copying from.
+ * @param size Number of bytes to copy.
+ *
+ * @throws IndexOutOfBoundsException - if copying would cause access of data
+ * outside array bounds.
+ */
+ public static byte[] getByteArray(final byte[] data, int offset, int size)
+ {
+ byte[] copy = new byte[size];
+ System.arraycopy(data, offset, copy, 0, size);
+
+ return copy;
+ }
}