Parses a connection string.
if (connection == null) {
throw new IllegalArgumentException("connection is null");
}
// Parse a connection string partially (fetching scheme and the rest)
// Actually, I'd rather factor it into a class
final int colonPos = connection.indexOf(':");
if (colonPos == -1) {
throw new IllegalArgumentException("connection is invalid");
}
if (colonPos < 1) {
throw new IllegalArgumentException("invalid protocol");
}
final String protocol = connection.substring(0, colonPos);
final String targetAndParams = connection.substring(colonPos + 1);
final int paramsPos = targetAndParams.indexOf(';");
if (paramsPos == -1) {
return new Connection(protocol, targetAndParams, null);
} else {
final String target = targetAndParams.substring(0, paramsPos);
final String params = targetAndParams.substring(paramsPos);
return new Connection(protocol, target, params);
}