Java Type Size sizeOfWriteLength(int len)

Here you can find the source of sizeOfWriteLength(int len)

Description

size Of Write Length

License

Open Source License

Declaration

static int sizeOfWriteLength(int len) 

Method Source Code

//package com.java2s;
//* Licensed Materials - Property of IBM, Miracle A/S, and            *

public class Main {
    static int sizeOfWriteLength(int len) {
        if (len < 0) {
            throw new RuntimeException("Invalid length < 0");
        }/*from   w w  w  . ja  v a  2s  .  c  o  m*/
        if (len <= 127) {
            return 1;
        } else if (len <= 16383) {
            return 2;
        } else if (len <= 2097151) {
            return 3;
        } else {
            throw new RuntimeException("Invalid length > 2^21-1");
        }
    }
}

Related

  1. sizeOfInVarInt32(int length)
  2. sizeOfPrimitive(Object object)
  3. sizeOfPrimitiveArray(Object object)
  4. sizeOfTreeMap(int size)
  5. sizeOfVarint(int value)