com.firebase.geofire.util.Base32Utils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of geofire-java Show documentation
Show all versions of geofire-java Show documentation
GeoFire is an open-source library for Android/Java that allows you to store and query a set of keys based on their geographic location.
package com.firebase.geofire.util;
public class Base32Utils {
/* number of bits per base 32 character */
public static final int BITS_PER_BASE32_CHAR = 5;
private static final String BASE32_CHARS = "0123456789bcdefghjkmnpqrstuvwxyz";
private Base32Utils() {}
public static char valueToBase32Char(int value) {
if (value < 0 || value >= BASE32_CHARS.length()) {
throw new IllegalArgumentException("Not a valid base32 value: " + value);
}
return BASE32_CHARS.charAt(value);
}
public static int base32CharToValue(char base32Char) {
int value = BASE32_CHARS.indexOf(base32Char);
if (value == -1) {
throw new IllegalArgumentException("Not a valid base32 char: " + base32Char);
} else {
return value;
}
}
public static boolean isValidBase32String(String string) {
return string.matches("^[" + BASE32_CHARS + "]*$");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy