/** * Build an advanced {@link SelectionBuilder} to match the requested {@link Uri}. This is usually * only used by {@link #query}, since it performs table joins useful for {@link Cursor} data. */ private SelectionBuilder buildExpandedSelection(Uri uri, int match) { final SelectionBuilder builder = new SelectionBuilder(); switch (match) { case ALBUMS: { return builder.table(Tables.ALBUMS_JOIN_ARTISTS); } case ALBUMS_ID: { final String albumId = Albums.getAlbumId(uri); return builder.table(Tables.ALBUMS).where(Albums.ID + "=?", albumId); } case ARTISTS: { return builder .table(Tables.ARTISTS) .map(Artists.ALBUMS_COUNT, Subquery.ARTIST_ALBUMS_COUNT); } case ARTISTS_ID_ALBUMS: { final String artistId = Artists.getArtistId(uri); return builder.table(Tables.ALBUMS).where(Artists.ID + "=?", artistId); } default: { throw new UnsupportedOperationException("Unknown uri: " + uri); } } }
/** * Build a simple {@link SelectionBuilder} to match the requested {@link Uri}. This is usually * enough to support {@link #insert}, {@link #update}, and {@link #delete} operations. */ private SelectionBuilder buildSimpleSelection(Uri uri) { final SelectionBuilder builder = new SelectionBuilder(); final int match = sUriMatcher.match(uri); switch (match) { case ALBUMS: { return builder.table(Tables.ALBUMS); } case ALBUMS_ID: { final String albumId = Albums.getAlbumId(uri); return builder.table(Tables.ALBUMS).where(Albums.ID + "=?", albumId); } case ARTISTS: { return builder.table(Tables.ARTISTS); } case ARTISTS_ID: { final String artistId = Artists.getArtistId(uri); return builder.table(Tables.ARTISTS).where(Artists.ID + "=?", artistId); } default: { throw new UnsupportedOperationException("Unknown uri: " + uri); } } }