@Test public void testConvertByteOrderOk() { assertEquals( 0xBEBC200, convertByteOrder( 0x00C2EB0B, 32, ByteOrder.LITTLE_ENDIAN ) ); assertEquals( 0x6000, convertByteOrder( 0x00600000, 32, ByteOrder.LITTLE_ENDIAN ) ); }
public static int convertByteOrder( final int aValue, final int aByteCount, final ByteOrder aByteOrder ) { if ( ( aByteCount <= 0 ) || ( aByteCount > 32 ) ) { throw new IllegalArgumentException( "Bit count cannot be zero, negative or beyond 32-bits!" ); } final ByteBuffer buf = ByteBuffer.allocate( aByteCount ); buf.putInt( aValue ); buf.order( aByteOrder ); buf.position( 0 ); final int result = buf.getInt(); return result; }
NumberUtils { public static int convertByteOrder( final int aValue, final int aByteCount, final ByteOrder aByteOrder ) { if ( ( aByteCount <= 0 ) || ( aByteCount > 32 ) ) { throw new IllegalArgumentException( "Bit count cannot be zero, negative or beyond 32-bits!" ); } final ByteBuffer buf = ByteBuffer.allocate( aByteCount ); buf.putInt( aValue ); buf.order( aByteOrder ); buf.position( 0 ); final int result = buf.getInt(); return result; } }
NumberUtils { public static int convertByteOrder( final int aValue, final int aByteCount, final ByteOrder aByteOrder ) { if ( ( aByteCount <= 0 ) || ( aByteCount > 32 ) ) { throw new IllegalArgumentException( "Bit count cannot be zero, negative or beyond 32-bits!" ); } final ByteBuffer buf = ByteBuffer.allocate( aByteCount ); buf.putInt( aValue ); buf.order( aByteOrder ); buf.position( 0 ); final int result = buf.getInt(); return result; } private  NumberUtils(); }
NumberUtils { public static int convertByteOrder( final int aValue, final int aByteCount, final ByteOrder aByteOrder ) { if ( ( aByteCount <= 0 ) || ( aByteCount > 32 ) ) { throw new IllegalArgumentException( "Bit count cannot be zero, negative or beyond 32-bits!" ); } final ByteBuffer buf = ByteBuffer.allocate( aByteCount ); buf.putInt( aValue ); buf.order( aByteOrder ); buf.position( 0 ); final int result = buf.getInt(); 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 convertByteOrder( final int aValue, final int aByteCount, final ByteOrder aByteOrder ) { if ( ( aByteCount <= 0 ) || ( aByteCount > 32 ) ) { throw new IllegalArgumentException( "Bit count cannot be zero, negative or beyond 32-bits!" ); } final ByteBuffer buf = ByteBuffer.allocate( aByteCount ); buf.putInt( aValue ); buf.order( aByteOrder ); buf.position( 0 ); final int result = buf.getInt(); 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 );  }