use of me.himanshusoni.quantumflux.model.util.QuantumFluxException in project QuantumFlux by himanshu-soni.
the class QuantumFluxContentProvider method constructLimit.
private String constructLimit(Uri uri) {
String offsetParam = uri.getQueryParameter(PARAMETER_OFFSET);
String limitParam = uri.getQueryParameter(PARAMETER_LIMIT);
Integer offset = null;
Integer limit = null;
if (!TextUtils.isEmpty(offsetParam) && TextUtils.isDigitsOnly(offsetParam)) {
offset = Integer.valueOf(offsetParam);
}
if (!TextUtils.isEmpty(limitParam) && TextUtils.isDigitsOnly(limitParam)) {
limit = Integer.valueOf(limitParam);
}
if (limit == null && offset == null) {
return null;
}
StringBuilder limitStatement = new StringBuilder();
if (limit != null && offset != null) {
limitStatement.append(offset);
limitStatement.append(",");
limitStatement.append(limit);
} else if (limit != null) {
limitStatement.append(limit);
} else {
throw new QuantumFluxException("A limit must also be provided when setting an offset");
}
return limitStatement.toString();
}
Aggregations