Example usage for java.lang Integer SIZE

List of usage examples for java.lang Integer SIZE

Introduction

In this page you can find the example usage for java.lang Integer SIZE.

Prototype

int SIZE

To view the source code for java.lang Integer SIZE.

Click Source Link

Document

The number of bits used to represent an int value in two's complement binary form.

Usage

From source file:org.apache.accumulo.server.security.SecurityConstants.java

private static AuthenticationToken makeSystemPassword() {
    int wireVersion = Constants.WIRE_VERSION;
    byte[] inst = HdfsZooInstance.getInstance().getInstanceID().getBytes(Constants.UTF8);
    try {//from w w w.  ja  va  2 s.  c o  m
        confChecksum = getSystemConfigChecksum();
    } catch (NoSuchAlgorithmException e) {
        throw new RuntimeException("Failed to compute configuration checksum", e);
    }

    ByteArrayOutputStream bytes = new ByteArrayOutputStream(
            3 * (Integer.SIZE / Byte.SIZE) + inst.length + confChecksum.length);
    DataOutputStream out = new DataOutputStream(bytes);
    try {
        out.write(wireVersion * -1);
        out.write(inst.length);
        out.write(inst);
        out.write(confChecksum.length);
        out.write(confChecksum);
    } catch (IOException e) {
        throw new RuntimeException(e); // this is impossible with
        // ByteArrayOutputStream; crash hard
        // if this happens
    }
    return new PasswordToken(Base64.encodeBase64(bytes.toByteArray()));
}

From source file:com.xsdn.main.util.Ip4Network.java

/**
 * Return an IPv4 prefix length represented by the given byte array.
 *
 * <p>/*  w ww . j a  v a2s.c  om*/
 *   Note that this method returns 32 if all the bits in the given array
 *   are not set.
 * </p>
 *
 * @param bytes  A byte array which represents IPv4 network mask.
 * @return  The IPv4 prefix length represented by the given byte array.
 * @throws NullPointerException
 *    {@code bytes} is {@code null}.
 * @throws IllegalArgumentException
 *    The given byte array does not represent an IPv4 network mask.
 */
public static int getPrefixLength(byte[] bytes) {
    // Verify the given network mask.
    int mask = NumberUtils.toInteger(bytes);
    if (mask == 0) {
        return Integer.SIZE;
    }

    int inv = ~mask;
    int p2 = inv + 1;
    if ((p2 & inv) != 0) {
        throw new IllegalArgumentException("Invalid IPv4 netmask: " + Integer.toHexString(mask));
    }

    return Integer.numberOfLeadingZeros(inv);
}

From source file:com.bah.culvert.util.Bytes.java

/**
 * Convert the integer to a byte []/* ww  w .  jav  a 2 s.  c  om*/
 * @param i
 * @return
 */
public static byte[] toBytes(int i) {
    int bytes = Integer.SIZE / 8;

    return ByteBuffer.allocate(bytes).putInt(i).array();
}

From source file:com.github.joulupunikki.math.random.BitsStreamGenerator64.java

/**
 * For 64 bit generators, {@link #nextL(int bits)} is the core generator
 * function and this method will delegate.
 *
 * @param bits// w w  w.j a  v a 2 s  .  c  o  m
 * @return
 */
@Override
protected int next(int bits) {
    if (isIntLeft) {
        isIntLeft = false;
        return intLeft >>> (Integer.SIZE - bits);
    } else {
        return nextInt() >>> (Integer.SIZE - bits);
    }
}

From source file:org.diorite.impl.world.chunk.palette.MapPaletteImpl.java

@Override
public int bitsPerBlock() {
    final int size = this.lastUsed;
    if (size <= 1) {
        return 4;
    }/*from w  ww.java2 s. c  o  m*/
    return Math.max(4, Integer.SIZE - Integer.numberOfLeadingZeros(size - 1));
}

From source file:com.lanacion.adminsiteln.controllers.DefaultController.java

License:asdf

@RequestMapping(value = "/testcrea", method = RequestMethod.GET)
@ResponseBody/*from   w  w  w  .j a  va 2 s  .co  m*/
public String getTestcrea() {

    infoService.create("titulo desde spring", "desde spring", 1, Integer.SIZE);

    return "Donde";
}

From source file:com.openteach.diamond.network.waverider.command.Command.java

/**
 * /* w ww .ja  v a 2 s .c  o m*/
 * @return
 */
public static int getHeaderSize() {
    int size = 0;
    size += Long.SIZE / Byte.SIZE;
    size += Integer.SIZE / Byte.SIZE;
    return size;
}

From source file:com.xsdn.main.util.Ip4Network.java

/**
 * Return an integer value which represents the IPv4 netmask specified by
 * the given prefix length./*from   w ww  .  j  a  v a2  s .c om*/
 *
 * @param length  The IPv4 prefix length.
 *                Note that zero means "no mask". So zero is treated as if
 *                the maximum prefix length is specified.
 * @return  An integer value.
 * @throws IllegalArgumentException
 *    The given prefix length is invalid.
 */
public static int getNetMask(int length) {
    if (length < 0 || length > Integer.SIZE) {
        throw new IllegalArgumentException("Invalid prefix length: " + length);
    }

    int nzeroes = Integer.SIZE - length;
    return (NETMASK_ALL << nzeroes);
}

From source file:com.openteach.diamond.network.waverider.network.Packet.java

/**
 * //from  w w  w  .j a  v  a  2 s  .  c o  m
 * @return
 */
public static int getHeaderSize() {
    int size = 0;
    size += NetWorkConstants.WAVERIDER_MAGIC.getBytes().length;
    size += Long.SIZE / Byte.SIZE;
    size += Long.SIZE / Byte.SIZE;
    size += Integer.SIZE / Byte.SIZE;

    return size;
}

From source file:com.github.joulupunikki.math.random.BitsStreamGenerator64.java

@Override
public int nextInt() {
    if (isIntLeft) {
        // use the 32 LSBs of the long already generated
        isIntLeft = false;/*  w  w  w.j a v a  2s.c om*/
        return intLeft;
    } else {
        // generate a new pair of integers (long split in half)
        long t = nextLong();
        intLeft = (int) t; // 32 LSBs stored
        isIntLeft = true;
        return (int) (t >>> Integer.SIZE); // 32 MSBs returned
    }
}