Top Description Fields Constructors Methods
org.apache.poi.util

public Class BitField

extends Object
Class Inheritance
Annotations
@Internal
since:POI 3.15 beta 3

Manage operations dealing with bit-mapped fields.

Field Summary

Modifier and TypeField and Description
private final int
private final int

Constructor Summary

AccessConstructor and Description
public
BitField(final int
the mask specifying which bits apply to this BitField. Bits that are set in this mask are the bits that this BitField operates on
mask
)

Create a BitField instance

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the value of holder with the specified bits cleared (set to 0)
clear
(final int
the int data containing the bits we're interested in
holder
)

Clear the bits.

public byte

Returns:

the value of holder with the specified bits cleared (set to 0)
clearByte
(final byte
the byte data containing the bits we're interested in
holder
)

Clear the bits.

public short

Returns:

the value of holder with the specified bits cleared (set to 0)
clearShort
(final short
the short data containing the bits we're interested in
holder
)

Clear the bits.

public int
public int

Returns:

the selected bits
getRawValue
(final int
the int data containing the bits we're interested in
holder
)

Obtain the value for the specified BitField, unshifted

public short

Returns:

the selected bits
getShortRawValue
(final short
the short data containing the bits we're interested in
holder
)

Obtain the value for the specified BitField, unshifted

public short

Returns:

the selected bits, shifted right appropriately
getShortValue
(final short
the short data containing the bits we're interested in
holder
)

Obtain the value for the specified BitField, appropriately shifted right, as a short.

public int

Returns:

the selected bits, shifted right appropriately
getValue
(final int
the int data containing the bits we're interested in
holder
)

Obtain the value for the specified BitField, appropriately shifted right.

public boolean

Returns:

true if all of the bits are set, else false
isAllSet
(final int
the int data containing the bits we're interested in
holder
)

Are all of the bits set or not?

public boolean

Returns:

true if any of the bits are set, else false
isSet
(final int
the int data containing the bits we're interested in
holder
)

Is the field set or not?

public int

Returns:

the value of holder with the specified bits set to 1
set
(final int
the int data containing the bits we're interested in
holder
)

Set the bits.

public int

Returns:

the value of holder with the specified bits set or cleared
setBoolean
(final int
the int data containing the bits we're interested in
holder
,
final boolean
indicating whether to set or clear the bits
flag
)

Set a boolean BitField

public byte

Returns:

the value of holder with the specified bits set to 1
setByte
(final byte
the byte data containing the bits we're interested in
holder
)

Set the bits.

public byte

Returns:

the value of holder with the specified bits set or cleared
setByteBoolean
(final byte
the byte data containing the bits we're interested in
holder
,
final boolean
indicating whether to set or clear the bits
flag
)

Set a boolean BitField

public short

Returns:

the value of holder with the specified bits set to 1
setShort
(final short
the short data containing the bits we're interested in
holder
)

Set the bits.

public short

Returns:

the value of holder with the specified bits set or cleared
setShortBoolean
(final short
the short data containing the bits we're interested in
holder
,
final boolean
indicating whether to set or clear the bits
flag
)

Set a boolean BitField

public short

Returns:

the value of holder with the bits from the value parameter replacing the old bits
setShortValue
(final short
the short data containing the bits we're interested in
holder
,
final short
the new value for the specified bits
value
)

Replace the bits with new values.

public int

Returns:

the value of holder with the bits from the value parameter replacing the old bits
setValue
(final int
the int data containing the bits we're interested in
holder
,
final int
the new value for the specified bits
value
)

Replace the bits with new values.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_maskback to summary
private final int _mask
_shift_countback to summary
private final int _shift_count

Constructor Detail

BitFieldback to summary
public BitField(final int mask)

Create a BitField instance

Parameters
mask:int

the mask specifying which bits apply to this BitField. Bits that are set in this mask are the bits that this BitField operates on

Method Detail

clearback to summary
public int clear(final int holder)

Clear the bits.

Parameters
holder:int

the int data containing the bits we're interested in

Returns:int

the value of holder with the specified bits cleared (set to 0)

clearByteback to summary
public byte clearByte(final byte holder)

Clear the bits.

Parameters
holder:byte

the byte data containing the bits we're interested in

Returns:byte

the value of holder with the specified bits cleared (set to 0)

clearShortback to summary
public short clearShort(final short holder)

Clear the bits.

Parameters
holder:short

the short data containing the bits we're interested in

Returns:short

the value of holder with the specified bits cleared (set to 0)

getMaskback to summary
public int getMask()
getRawValueback to summary
public int getRawValue(final int holder)

Obtain the value for the specified BitField, unshifted

Parameters
holder:int

the int data containing the bits we're interested in

Returns:int

the selected bits

getShortRawValueback to summary
public short getShortRawValue(final short holder)

Obtain the value for the specified BitField, unshifted

Parameters
holder:short

the short data containing the bits we're interested in

Returns:short

the selected bits

getShortValueback to summary
public short getShortValue(final short holder)

Obtain the value for the specified BitField, appropriately shifted right, as a short. Many users of a BitField will want to treat the specified bits as an int value, and will not want to be aware that the value is stored as a BitField (and so shifted left so many bits)

Parameters
holder:short

the short data containing the bits we're interested in

Returns:short

the selected bits, shifted right appropriately

getValueback to summary
public int getValue(final int holder)

Obtain the value for the specified BitField, appropriately shifted right. Many users of a BitField will want to treat the specified bits as an int value, and will not want to be aware that the value is stored as a BitField (and so shifted left so many bits)

Parameters
holder:int

the int data containing the bits we're interested in

Returns:int

the selected bits, shifted right appropriately

isAllSetback to summary
public boolean isAllSet(final int holder)

Are all of the bits set or not? This is a stricter test than isSet, in that all of the bits in a multi-bit set must be set for this method to return true

Parameters
holder:int

the int data containing the bits we're interested in

Returns:boolean

true if all of the bits are set, else false

isSetback to summary
public boolean isSet(final int holder)

Is the field set or not? This is most commonly used for a single-bit field, which is often used to represent a boolean value; the results of using it for a multi-bit field is to determine whether *any* of its bits are set

Parameters
holder:int

the int data containing the bits we're interested in

Returns:boolean

true if any of the bits are set, else false

setback to summary
public int set(final int holder)

Set the bits.

Parameters
holder:int

the int data containing the bits we're interested in

Returns:int

the value of holder with the specified bits set to 1

setBooleanback to summary
public int setBoolean(final int holder, final boolean flag)

Set a boolean BitField

Parameters
holder:int

the int data containing the bits we're interested in

flag:boolean

indicating whether to set or clear the bits

Returns:int

the value of holder with the specified bits set or cleared

setByteback to summary
public byte setByte(final byte holder)

Set the bits.

Parameters
holder:byte

the byte data containing the bits we're interested in

Returns:byte

the value of holder with the specified bits set to 1

setByteBooleanback to summary
public byte setByteBoolean(final byte holder, final boolean flag)

Set a boolean BitField

Parameters
holder:byte

the byte data containing the bits we're interested in

flag:boolean

indicating whether to set or clear the bits

Returns:byte

the value of holder with the specified bits set or cleared

setShortback to summary
public short setShort(final short holder)

Set the bits.

Parameters
holder:short

the short data containing the bits we're interested in

Returns:short

the value of holder with the specified bits set to 1

setShortBooleanback to summary
public short setShortBoolean(final short holder, final boolean flag)

Set a boolean BitField

Parameters
holder:short

the short data containing the bits we're interested in

flag:boolean

indicating whether to set or clear the bits

Returns:short

the value of holder with the specified bits set or cleared

setShortValueback to summary
public short setShortValue(final short holder, final short value)

Replace the bits with new values.

Parameters
holder:short

the short data containing the bits we're interested in

value:short

the new value for the specified bits

Returns:short

the value of holder with the bits from the value parameter replacing the old bits

setValueback to summary
public int setValue(final int holder, final int value)

Replace the bits with new values.

Parameters
holder:int

the int data containing the bits we're interested in

value:int

the new value for the specified bits

Returns:int

the value of holder with the bits from the value parameter replacing the old bits