Java Utililty Methods Integer Create

List of utility methods to do Integer Create

Description

The list of methods to do Integer Create are organized into topic(s).

Method

int[]toIntArrayUnshifted(byte... arguments)
to Int Array Unshifted
int[] result = new int[arguments.length];
for (int i = 0; i < result.length; i++)
    result[i] = (byte) (arguments[i] + 128);
return result;
inttoIntBE(byte[] src, int offset)
32bit to int
return (((src[offset] & 0xFF) << 24) + ((src[++offset] & 0xFF) << 16) + ((src[++offset] & 0xFF) << 8)
        + (src[++offset] & 0xFF));
inttoIntBigEndian(byte[] input)
Convert a byte array of length 4 into an int number, using big-endian notation
int result = 0;
if (input.length != 4) {
    return 0;
result ^= (input[0] & 0xff) << 24;
result ^= (input[1] & 0xff) << 16;
result ^= (input[2] & 0xff) << 8;
result ^= input[3] & 0xff;
...
inttoIntDecoded(String s)
to Int Decoded
return Integer.decode(s);
inttoIntDefaultIfNull(Integer configured, int theDefault)
to Int Default If Null
return configured != null ? configured.intValue() : theDefault;
inttoInteger(boolean b)
Cast a boolean value to integer.
return b ? 1 : 0;
inttoInteger(boolean bool)
to Integer
return bool ? 1 : 0;
inttoInteger(boolean bool)

Converts a boolean to an int using the convention that zero is false.

 BooleanUtils.toInteger(true)  = 1 BooleanUtils.toInteger(false) = 0 
return bool ? 1 : 0;
inttoInteger(boolean bool)
Converts a primitive boolean to a primitive integer by assuming 0 is false and everything else (1) is true.
return bool ? 1 : 0;
inttoInteger(byte b1, byte b2, byte b3, byte b4)
Creates an integer from four bytes.
return ((b1 & 0xFF) << 24) | ((b2 & 0xFF) << 16) | ((b3 & 0xFF) << 8) | (b4 & 0xFF);