remove obsolete class RadixConverter
This commit is contained in:
@@ -1,42 +0,0 @@
|
||||
package org.lucares.pdb.api;
|
||||
|
||||
public class RadixConverter {
|
||||
|
||||
private static final String ALPHABET = "0123456789ABCDEFGHIJKLMNOPRSTUVWXYZacbdefghijklmnopqrstuvwxyz";
|
||||
|
||||
public static String toString(final int value) {
|
||||
|
||||
if (value < 0) {
|
||||
throw new IllegalArgumentException("value must not be negative");
|
||||
}
|
||||
|
||||
final StringBuilder result = new StringBuilder();
|
||||
int v = value;
|
||||
|
||||
if (v == 0) {
|
||||
result.append(ALPHABET.charAt(0));
|
||||
} else {
|
||||
while (v > 0) {
|
||||
final int remainder = v % ALPHABET.length();
|
||||
v = v / ALPHABET.length();
|
||||
|
||||
result.insert(0, ALPHABET.charAt(remainder));
|
||||
}
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public static int fromString(final String string) {
|
||||
|
||||
int result = 0;
|
||||
|
||||
for (int i = 0; i < string.length(); i++) {
|
||||
final int value = ALPHABET.indexOf(string.charAt(i));
|
||||
result = result * ALPHABET.length() + value;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user