Wednesday, December 10, 2008

Java Utility Methods

1. Conversion
  a) Array => String

String modeStr = StringUtils.join(modes, '/')

  b) String => Array
String[] modes = StringUtils.split(protocolStr, '/')

2. Bit Ops
  a) Check bit
int RADIO_PROTOCOL_A = 0x1;
if (radioMode & RADIO_PROTOCOL_A) == RADIO_PROTOCOL_A

   b) Set/Unset bit
radioMode = radioMode | RADIO_PROTOCOL_A
radioMode = radioMode & ~RADIO_PROTOCOL_A