/** * Converts the given value into a desired bit order. * * @param aValue * the value to convert; * @param aBitCount * the number of bits that are supposed to be in the given value; * @param aBitOrder * the desired bit order. * @return the converted value. */ public static int convertBitOrder( final int aValue, final int aBitCount, final BitOrder aBitOrder ) { if ( ( aBitCount <= 0 ) || ( aBitCount > 32 ) ) { throw new IllegalArgumentException( "Bit count cannot be zero, negative or beyond 32-bits!" ); } // We already have the most significant bit first, convert only if the bit // order is LSB first... if ( aBitOrder == BitOrder.MSB_FIRST ) { return ( aValue & getBitMask( aBitCount ) ); } return reverseBits( aValue, aBitCount ); }
int mask = getBitMask( aBitCount ); while ( ( s >>= 1 ) > 0 )
enabledChannels = NumberUtils.getBitMask( channels );
/** * Creates a mocked data set with a given number of sample/time values. * * @param aDataSize * the number of sample/time values in the returned data container, > * 0; * @param aChannelCount * the number of <em>enabled</em> channels in the returned data * container, > 0 && < 32; * @param aSampleRate * the sample rate (in Hertz), > 0; * @param aProvider * the test data provider to use, cannot be <code>null</code>. * @return a mocked data container, never <code>null</code>. */ public static DataSet createStubDataSet( final int aDataSize, final int aChannelCount, final int aSampleRate, final TestDataProvider aProvider ) { final int[] values = new int[aDataSize]; final long[] timestamps = new long[aDataSize]; aProvider.fillData( values, timestamps, aDataSize ); final StubDataSet project = new StubDataSet(); project.setCapturedData( new CapturedData( values, timestamps, 0, aSampleRate, aChannelCount, NumberUtils .getBitMask( aChannelCount ), timestamps[aDataSize - 1] + 1L ) ); return project; }