List of utility methods to do Type Size
int | sizeOf(Class> cls) size Of if (cls == boolean.class) return 1; if (cls == byte.class) return 1; if (cls == char.class) return 2; if (cls == short.class) return 2; ... |
int | sizeOf(Class> clz) Get the size of a primitive type. switch (clz.getName()) { case "int": return Integer.BYTES; case "short": return Short.BYTES; case "long": return Long.BYTES; case "double": ... |
int | sizeOf(double v) size Of return 8;
|
int | sizeOf(int fieldNumber) size Of return fieldNumber > 15 ? 2 : 1;
|
int | sizeOf(int tagNumber, int contentLength) Computes the DER-encoded size of content with a specified tag number. if (tagNumber < 0 || contentLength < 0) { throw new IllegalArgumentException( "Invalid tagNumber/contentLength: " + tagNumber + ", " + contentLength); int len = 0; if (tagNumber <= 30) { len++; } else { ... |
int | sizeOf(int value) size Of if (value < 0) value = ~value; value >>= BYTE_OFFSET - 1; for (int i = 1; i < 4; i++) { if (value == 0) return i; value >>= BYTE_OFFSET; return 4; |
int | sizeOf(int[] arr) size Of return arr == null ? 0 : arr.length;
|
int | sizeOf(String str) Returns the number of bytes required to be written out for the given object. if (str == null) { return 1; } else { return 5 + (2 * str.length()); |
int | sizeOf(String type) size Of if ("byte".equals(type)) { return 1; } else if ("char".equals(type)) { return 1; } else if ("double".equals(type)) { return 2; } else if ("float".equals(type)) { return 1; ... |
int | sizeOf(String typeDescriptor) Return the size of a type. if (typeDescriptor.length() != 1) { return 1; char ch = typeDescriptor.charAt(0); if (ch == 'J' || ch == 'D') { return 2; } else { return 1; ... |