Methods Summary |
---|
public boolean | equals(java.lang.Object obj)
if (!(obj instanceof NumberFixedLength))
{
return false;
}
NumberFixedLength object = (NumberFixedLength) obj;
return this.size == object.size && super.equals(obj);
|
public int | getSize()Return size
return size;
|
public void | readByteArray(byte[] arr, int offset)Read the number from the byte array
if (arr == null)
{
throw new NullPointerException("Byte array is null");
}
if ((offset < 0) || (offset >= arr.length))
{
throw new InvalidDataTypeException("Offset to byte array is out of bounds: offset = " + offset + ", array.length = " + arr.length);
}
if(offset + size > arr.length)
{
throw new InvalidDataTypeException("Offset plus size to byte array is out of bounds: offset = "
+ offset + ", size = "+size +" + arr.length "+ arr.length );
}
long lvalue = 0;
for (int i = offset; i < (offset + size); i++)
{
lvalue <<= 8;
lvalue += (arr[i] & 0xff);
}
value = lvalue;
logger.config("Read NumberFixedlength:" + value);
|
public void | setSize(int size)Set Size in Bytes of this Object
if (size > 0)
{
this.size = size;
}
|
public void | setValue(java.lang.Object value)
if (!(value instanceof Number))
{
throw new IllegalArgumentException("Invalid value type for NumberFixedLength:" + value.getClass());
}
super.setValue(value);
|
public java.lang.String | toString()
if (value == null)
{
return "";
}
else
{
return value.toString();
}
|
public byte[] | writeByteArray()Write data to byte array
byte[] arr;
arr = new byte[size];
if (value != null)
{
//Convert value to long
long temp = ID3Tags.getWholeNumber(value);
for (int i = size - 1; i >= 0; i--)
{
arr[i] = (byte) (temp & 0xFF);
temp >>= 8;
}
}
return arr;
|