FileDocCategorySizeDatePackage
BooleanByte.javaAPI DocJaudiotagger 2.0.43750Wed Mar 30 16:12:12 BST 2011org.jaudiotagger.tag.datatype

BooleanByte

public class BooleanByte extends AbstractDataType
Represents a bit flag within a byte

Fields Summary
int
bitPosition
Constructors Summary
public BooleanByte(String identifier, org.jaudiotagger.tag.id3.AbstractTagFrameBody frameBody, int bitPosition)
Creates a new ObjectBooleanByte datatype.

param
identifier
param
frameBody
param
bitPosition
throws
IndexOutOfBoundsException


                      
          
    
        super(identifier, frameBody);
        if ((bitPosition < 0) || (bitPosition > 7))
        {
            throw new IndexOutOfBoundsException("Bit position needs to be from 0 - 7 : " + bitPosition);
        }

        this.bitPosition = bitPosition;
    
public BooleanByte(BooleanByte copy)

        super(copy);
        this.bitPosition = copy.bitPosition;
    
Methods Summary
public booleanequals(java.lang.Object obj)

param
obj
return

        if (!(obj instanceof BooleanByte))
        {
            return false;
        }

        BooleanByte object = (BooleanByte) obj;

        return this.bitPosition == object.bitPosition && super.equals(obj);

    
public intgetBitPosition()

return

        return bitPosition;
    
public intgetSize()

return

        return 1;
    
public voidreadByteArray(byte[] arr, int offset)

param
arr
param
offset
throws
NullPointerException
throws
IndexOutOfBoundsException

        if (arr == null)
        {
            throw new NullPointerException("Byte array is null");
        }

        if ((offset < 0) || (offset >= arr.length))
        {
            throw new IndexOutOfBoundsException("Offset to byte array is out of bounds: offset = " + offset + ", array.length = " + arr.length);
        }

        byte newValue = arr[offset];

        newValue >>= bitPosition;
        newValue &= 0x1;
        this.value = newValue == 1;
    
public java.lang.StringtoString()

return

        return "" + value;
    
public byte[]writeByteArray()

return

        byte[] retValue;

        retValue = new byte[1];

        if (value != null)
        {
            retValue[0] = (byte) ((Boolean) value ? 1 : 0);
            retValue[0] <<= bitPosition;
        }

        return retValue;