redis.clients.util.JedisURIHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jedis Show documentation
Show all versions of jedis Show documentation
Jedis Redis java client with some modifications to support new commands in YB Redis.
package redis.clients.util;
import java.net.URI;
public final class JedisURIHelper {
private static final int DEFAULT_DB = 0;
private JedisURIHelper(){
throw new InstantiationError( "Must not instantiate this class" );
}
public static String getPassword(URI uri) {
String userInfo = uri.getUserInfo();
if (userInfo != null) {
return userInfo.split(":", 2)[1];
}
return null;
}
public static int getDBIndex(URI uri) {
String[] pathSplit = uri.getPath().split("/", 2);
if (pathSplit.length > 1) {
String dbIndexStr = pathSplit[1];
if (dbIndexStr.isEmpty()) {
return DEFAULT_DB;
}
return Integer.parseInt(dbIndexStr);
} else {
return DEFAULT_DB;
}
}
public static boolean isValid(URI uri) {
if (isEmpty(uri.getScheme()) || isEmpty(uri.getHost()) || uri.getPort() == -1) {
return false;
}
return true;
}
private static boolean isEmpty(String value) {
return value == null || value.trim().length() == 0;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy