MCPcopy Create free account
hub / github.com/e2wugui/zeze / parseVersion

Method parseVersion

ZezeJava/ZezeJava/src/main/java/Zeze/Util/Str.java:180–199  ·  view source on GitHub ↗
(@NotNull String version)

Source from the content-addressed store, hash-verified

178 }
179
180 public static long parseVersion(@NotNull String version) {
181 long v = 0;
182 int t = 0, s = 48;
183 for (int i = 0, n = version.length(); i < n; i++) {
184 int c = version.charAt(i);
185 if (c >= '0' && c <= '9') {
186 t = t * 10 + c - '0';
187 if (t > 0xffff)
188 throw new NumberFormatException(version);
189 } else if (c == '.') {
190 if (s == 0)
191 break;
192 v += (long)t << s;
193 t = 0;
194 s -= 16;
195 } else if (!Character.isSpaceChar(c))
196 throw new NumberFormatException(version);
197 }
198 return v + ((long)t << s);
199 }
200
201 public static @NotNull String toVersionStr(long version) {
202 return String.format("%d.%d.%d.%d",

Callers 3

testParseVersionMethod · 0.95
parseMethod · 0.95
ProcessAuthRequestMethod · 0.95

Calls

no outgoing calls

Tested by 1

testParseVersionMethod · 0.76