Clarifying Parenthesis
This commit is contained in:
1 parent
6e1d6a4688
commit
cc40cc2c67
40 files changed
+1828
-1828
No files matched your search
@@ -17,28 +17,28 @@ public class StringUtil {
|
||||
|
||||
public static long getBase37(String s) {
|
||||
long l = 0L;
|
||||
for (int i = 0; i < s.length() && i < 12; i++) {
|
||||
for (int i = 0; (i < s.length()) && (i < 12); i++) {
|
||||
char c = s.charAt(i);
|
||||
l *= 37L;
|
||||
if (c >= 'A' && c <= 'Z') {
|
||||
if ((c >= 'A') && (c <= 'Z')) {
|
||||
l += (1 + c) - 'A';
|
||||
} else if (c >= 'a' && c <= 'z') {
|
||||
} else if ((c >= 'a') && (c <= 'z')) {
|
||||
l += (1 + c) - 'a';
|
||||
} else if (c >= '0' && c <= '9') {
|
||||
} else if ((c >= '0') && (c <= '9')) {
|
||||
l += (27 + c) - '0';
|
||||
}
|
||||
}
|
||||
while (l % 37L == 0L && l != 0L) {
|
||||
while (((l % 37L) == 0L) && (l != 0L)) {
|
||||
l /= 37L;
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
public static String fromBase37(long value) {
|
||||
if (value <= 0L || value >= 0x5b5b57f8a98a5dd1L/*37^12*/) {
|
||||
if ((value <= 0L) || (value >= 0x5b5b57f8a98a5dd1L)/*37^12*/) {
|
||||
return "invalid_name";
|
||||
}
|
||||
if (value % 37L == 0L) {
|
||||
if ((value % 37L) == 0L) {
|
||||
return "invalid_name";
|
||||
}
|
||||
int len = 0;
|
||||
@@ -46,23 +46,23 @@ public class StringUtil {
|
||||
while (value != 0L) {
|
||||
long last = value;
|
||||
value /= 37L;
|
||||
tmp[11 - len++] = BASE37_TABLE[(int) (last - value * 37L)];
|
||||
tmp[11 - len++] = BASE37_TABLE[(int) (last - (value * 37L))];
|
||||
}
|
||||
return new String(tmp, 12 - len, len);
|
||||
}
|
||||
|
||||
public static long hashCode(String s) {
|
||||
s = s.toUpperCase();
|
||||
long l = 0L;
|
||||
long hash = 0L;
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
l = (l * 61L + (long) s.charAt(i)) - 32L;
|
||||
l = l + (l >> 56) & 0xffffffffffffffL;
|
||||
hash = ((hash * 61L) + (long) s.charAt(i)) - 32L;
|
||||
hash = (hash + (hash >> 56)) & 0xffffffffffffffL;
|
||||
}
|
||||
return l;
|
||||
return hash;
|
||||
}
|
||||
|
||||
public static String formatIPv4(int ipv4) {
|
||||
return String.format("%d.%d.%d.%d", ipv4 >> 24 & 0xff, ipv4 >> 16 & 0xff, ipv4 >> 8 & 0xff, ipv4 & 0xff);
|
||||
return String.format("%d.%d.%d.%d", (ipv4 >> 24) & 0xff, (ipv4 >> 16) & 0xff, (ipv4 >> 8) & 0xff, ipv4 & 0xff);
|
||||
}
|
||||
|
||||
public static String method587(String s) {
|
||||
@@ -71,12 +71,12 @@ public class StringUtil {
|
||||
for (int j = 0; j < ac.length; j++) {
|
||||
if (ac[j] == '_') {
|
||||
ac[j] = ' ';
|
||||
if (j + 1 < ac.length && ac[j + 1] >= 'a' && ac[j + 1] <= 'z') {
|
||||
if (((j + 1) < ac.length) && (ac[j + 1] >= 'a') && (ac[j + 1] <= 'z')) {
|
||||
ac[j + 1] = (char) ((ac[j + 1] + 'A') - 'a');
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ac[0] >= 'a' && ac[0] <= 'z') {
|
||||
if ((ac[0] >= 'a') && (ac[0] <= 'z')) {
|
||||
ac[0] = (char) ((ac[0] + 'A') - 'a');
|
||||
}
|
||||
return new String(ac);
|
||||
|
||||
Reference in new issue
Block a user