BitDefs.class
is a class that represents the individual bit positions
for integer bits 1-32. These constants are used to
generate bitwise bitmasks. BIT1,BIT2,BIT3,...etc.
to BIT32. Example: // To see if a bit is set int bitMask = BitDefs.BIT1; // Bit 1 is set if((bitMask & BitDefs.BIT1)!=0) { // do something } //To set a bit you OR in the bit bitMask |= bitMask.BIT1; // Or in the bit //To unset a bit AND it with its exclusive OR mask bitMask &= ~BitDefs.BIT1; / / And with Exclusive OR of Bit1 //Check multiple bits by making a compare mask int compareMask = BitDefs.BIT1|BitDefs.BIT2|BitDefs.BIT3; if((compareMask & bitMask)!=0) // Check all bits { // do somethng } public interface BitDefs { final static int BIT1 = 0x00000001; BIT2 = 0x00000002; BIT3 = 0x00000004; BIT4 = 0x00000008; BIT5 = 0x00000010; BIT6 = 0x00000020; BIT7 = 0x00000040; BIT8 = 0x00000080; BIT9 = 0x00000100; BIT10 = 0x00000200; BIT11 = 0x00000400; BIT12 = 0x00000800; BIT13 = 0x00001000; BIT14 = 0x00002000; BIT15 = 0x00004000; BIT16 = 0x00008000; BIT17 = 0x00010000; BIT18 = 0x00020000; BIT19 = 0x00040000; BIT20 = 0x00080000; BIT21 = 0x00100000; BIT22 = 0x00200000; BIT23 = 0x00400000; BIT24 = 0x00800000; BIT25 = 0x01000000; BIT26 = 0x02000000; BIT27 = 0x04000000; BIT28 = 0x08000000; BIT29 = 0x10000000; BIT30 = 0x20000000; BIT31 = 0x40000000; BIT32 = 0x80000000; } |