@Test public void testPackBytes() { assertEquals( 0x1234, packBytes( 0x00001234 ) ); assertEquals( 0x1234, packBytes( 0x12003400 ) ); assertEquals( 0x1234, packBytes( 0x00120034 ) ); assertEquals( 0x1234, packBytes( 0x12003400 ) ); assertEquals( 0x12, packBytes( 0x00120000 ) ); assertEquals( 0x123456, packBytes( 0x12003456 ) ); assertEquals( 0x12345678, packBytes( 0x12345678 ) ); }
public static int packBytes( final int aValue ) { int mask = 0xFF000000; int result = 0; for ( int i = 0, j = 3; i < 4; i++, j-- ) { int tmp = ( aValue & mask ) >> ( j * 8 ); if ( tmp != 0 ) { result <<= 8; result |= tmp; } mask >>>= 8; } return result; }
NumberUtils { public static int packBytes( final int aValue ) { int mask = 0xFF000000; int result = 0; for ( int i = 0, j = 3; i < 4; i++, j-- ) { int tmp = ( aValue & mask ) >> ( j * 8 ); if ( tmp != 0 ) { result <<= 8; result |= tmp; } mask >>>= 8; } return result; } }
NumberUtils { public static int packBytes( final int aValue ) { int mask = 0xFF000000; int result = 0; for ( int i = 0, j = 3; i < 4; i++, j-- ) { int tmp = ( aValue & mask ) >> ( j * 8 ); if ( tmp != 0 ) { result <<= 8; result |= tmp; } mask >>>= 8; } return result; } private  NumberUtils(); }
NumberUtils { public static int packBytes( final int aValue ) { int mask = 0xFF000000; int result = 0; for ( int i = 0, j = 3; i < 4; i++, j-- ) { int tmp = ( aValue & mask ) >> ( j * 8 ); if ( tmp != 0 ) { result <<= 8; result |= tmp; } mask >>>= 8; } return result; } private  NumberUtils(); static int convertBitOrder( final int aValue, final int aBitCount, final BitOrder aBitOrder ); static int convertByteOrder( final int aValue, final int aByteCount, final ByteOrder aByteOrder ); static Comparator<T> createNumberComparator( final boolean aSortAscending ); static int getBitIndex( final int aMaskValue ); static int getBitMask( final int aBitCount ); static int getPercentage( final int aValue, final int aRange ); static int getPercentage( final int aValue, final int aLowerBound, final int aUpperBound ); static int getPercentage( final long aValue, final long aRange ); static int getPercentage( final long aValue, final long aLowerBound, final long aUpperBound ); static boolean isPowerOfTwo( final int aValue ); static int packBytes( final int aValue ); static int reverseBits( final int aValue, final int aBitCount ); static int safeParseInt( final String aText ); static int safeParseInt( final String aText, final int aDefault ); static long safeParseLong( final String aText ); static long safeParseLong( final String aText, final long aDefault ); static int smartParseInt( final String aText ); static int smartParseInt( final String aText, final int aDefault ); static int smartParseInt( final String aText, final UnitDefinition aUnitDefinition ); static int smartParseInt( final String aText, final UnitDefinition aUnitDefinition, final int aDefault ); }
NumberUtils { public static int packBytes( final int aValue ) { int mask = 0xFF000000; int result = 0; for ( int i = 0, j = 3; i < 4; i++, j-- ) { int tmp = ( aValue & mask ) >> ( j * 8 ); if ( tmp != 0 ) { result <<= 8; result |= tmp; } mask >>>= 8; } return result; } private  NumberUtils(); static int convertBitOrder( final int aValue, final int aBitCount, final BitOrder aBitOrder ); static int convertByteOrder( final int aValue, final int aByteCount, final ByteOrder aByteOrder ); static Comparator<T> createNumberComparator( final boolean aSortAscending ); static int getBitIndex( final int aMaskValue ); static int getBitMask( final int aBitCount ); static int getPercentage( final int aValue, final int aRange ); static int getPercentage( final int aValue, final int aLowerBound, final int aUpperBound ); static int getPercentage( final long aValue, final long aRange ); static int getPercentage( final long aValue, final long aLowerBound, final long aUpperBound ); static boolean isPowerOfTwo( final int aValue ); static int packBytes( final int aValue ); static int reverseBits( final int aValue, final int aBitCount ); static int safeParseInt( final String aText ); static int safeParseInt( final String aText, final int aDefault ); static long safeParseLong( final String aText ); static long safeParseLong( final String aText, final long aDefault ); static int smartParseInt( final String aText ); static int smartParseInt( final String aText, final int aDefault ); static int smartParseInt( final String aText, final UnitDefinition aUnitDefinition ); static int smartParseInt( final String aText, final UnitDefinition aUnitDefinition, final int aDefault );  }