Converts the token with a size unit suffix to a numeric value. The suffixes "kb", "mb" and "gb" are considered in the calculation. @param token token to be converted @return long
(final byte[] token)
| 101 | * @return long |
| 102 | */ |
| 103 | private static long sizeToLong(final byte[] token) { |
| 104 | int tl = token.length, f = 0; |
| 105 | final int s1 = tl < 1 ? 0 : lc(token[tl - 1]), s2 = tl < 2 ? 0 : lc(token[tl - 2]); |
| 106 | if(s1 == 'k') { tl -= 1; f = 10; } |
| 107 | if(s1 == 'm') { tl -= 1; f = 20; } |
| 108 | if(s1 == 'g') { tl -= 1; f = 30; } |
| 109 | if(s1 == 'b' && s2 == 'k') { tl -= 2; f = 10; } |
| 110 | if(s1 == 'b' && s2 == 'm') { tl -= 2; f = 20; } |
| 111 | if(s1 == 'b' && s2 == 'g') { tl -= 2; f = 30; } |
| 112 | final long i = toLong(token, 0, tl) << f; |
| 113 | return i == Long.MIN_VALUE ? 0 : i; |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Splits the string and returns an array. |
no test coverage detected