Search in sources :

Example 6 with QuantumFluxException

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();
}
Also used : QuantumFluxException(me.himanshusoni.quantumflux.model.util.QuantumFluxException)

Aggregations

QuantumFluxException (me.himanshusoni.quantumflux.model.util.QuantumFluxException)6 Collection (java.util.Collection)2 Iterator (java.util.Iterator)2 ContentResolver (android.content.ContentResolver)1 Cursor (android.database.Cursor)1 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 TableDetails (me.himanshusoni.quantumflux.model.generate.TableDetails)1