<commit_before>package net.x4a42.volksempfaenger.data;

import java.util.List;

import android.content.ContentProvider;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;

public class VolksempfaengerContentProvider extends ContentProvider {

	public static final String AUTHORITY = "net.x4a42.volksempfaenger";
	public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY);
	public static final Uri PODCAST_URI = Uri.parse("content://" + AUTHORITY
			+ "/podcast");
	public static final Uri EPISODE_URI = Uri.parse("content://" + AUTHORITY
			+ "/episode");
	public static final Uri ENCLOSURE_URI = Uri.parse("content://" + AUTHORITY
			+ "/enclosure");

	public static final String MIME_PODCAST_ITEM = "vnd.android.cursor.item/vnd.volksempfaenger.podcast";
	public static final String MIME_PODCAST_DIR = "vnd.android.cursor.dir/vnd.volksempfaenger.podcast";
	public static final String MIME_EPISODE_ITEM = "vnd.android.cursor.item/vnd.volksempfaenger.episode";
	public static final String MIME_EPISODE_DIR = "vnd.android.cursor.dir/vnd.volksempfaenger.episode";
	public static final String MIME_ENCLOSURE_ITEM = "vnd.android.cursor.item/vnd.volksempfaenger.enclosure";
	public static final String MIME_ENCLOSURE_DIR = "vnd.android.cursor.dir/vnd.volksempfaenger.enclosure";

	private DatabaseHelper dbHelper;

	@Override
	public boolean onCreate() {
		dbHelper = DatabaseHelper.getInstance(getContext());
		return true;
	}

	@Override
	public String getType(Uri uri) {
		if (!AUTHORITY.equals(uri.getAuthority())) {
			return null;
		}

		List<String> segments = uri.getPathSegments();
		if (segments == null || segments.size() == 0) {
			return null;
		}

		String type = segments.get(0);
		if ("podcast".equals(type)) {
			switch (segments.size()) {
			case 1:
				return MIME_PODCAST_DIR;
			case 2:
				return MIME_PODCAST_ITEM;
			default:
				return null;
			}
		} else if ("episode".equals(type)) {
			switch (segments.size()) {
			case 1:
				return MIME_EPISODE_DIR;
			case 2:
				return MIME_EPISODE_ITEM;
			default:
				return null;
			}
		} else if ("enclosure".equals(type)) {
			switch (segments.size()) {
			case 1:
				return MIME_ENCLOSURE_DIR;
			case 2:
				return MIME_ENCLOSURE_ITEM;
			default:
				return null;
			}
		} else {<commit_msg>Added an enum which should be faster than string comparision later.<commit_after>package net.x4a42.volksempfaenger.data;

import java.util.List;

import android.content.ContentProvider;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;

public class VolksempfaengerContentProvider extends ContentProvider {

	public static final String AUTHORITY = "net.x4a42.volksempfaenger";
	public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY);
	public static final Uri PODCAST_URI = Uri.parse("content://" + AUTHORITY
			+ "/podcast");
	public static final Uri EPISODE_URI = Uri.parse("content://" + AUTHORITY
			+ "/episode");
	public static final Uri ENCLOSURE_URI = Uri.parse("content://" + AUTHORITY
			+ "/enclosure");

	public static final String MIME_PODCAST_DIR = "vnd.android.cursor.dir/vnd.volksempfaenger.podcast";
	public static final String MIME_PODCAST_ITEM = "vnd.android.cursor.item/vnd.volksempfaenger.podcast";
	public static final String MIME_EPISODE_DIR = "vnd.android.cursor.dir/vnd.volksempfaenger.episode";
	public static final String MIME_EPISODE_ITEM = "vnd.android.cursor.item/vnd.volksempfaenger.episode";
	public static final String MIME_ENCLOSURE_DIR = "vnd.android.cursor.dir/vnd.volksempfaenger.enclosure";
	public static final String MIME_ENCLOSURE_ITEM = "vnd.android.cursor.item/vnd.volksempfaenger.enclosure";

	private enum Mime {
		PODCAST_DIR, PODCAST_ITEM, EPISODE_DIR, EPISODE_ITEM, ENCLOSURE_DIR, ENCLOSURE_ITEM
	}

	private DatabaseHelper dbHelper;

	@Override
	public boolean onCreate() {
		dbHelper = DatabaseHelper.getInstance(getContext());
		return true;
	}

	private Mime getTypeMime(Uri uri) {
		if (!AUTHORITY.equals(uri.getAuthority())) {
			return null;
		}

		List<String> segments = uri.getPathSegments();
		if (segments == null || segments.size() == 0) {
			return null;
		}

		String type = segments.get(0);
		if ("podcast".equals(type)) {
			switch (segments.size()) {
			case 1:
				return Mime.PODCAST_DIR;
			case 2:
				return Mime.PODCAST_ITEM;
			default:
				return null;
			}
		} else if ("episode".equals(type)) {
			switch (segments.size()) {
			case 1:
				return Mime.EPISODE_DIR;
			case 2:
				return Mime.EPISODE_ITEM;
			default:
				return null;
			}
		} else if ("enclosure".equals(type)) {
			switch (segments.size()) {
			case 1:
				return Mime.ENCLOSURE_DIR;
			case 2:
				return Mime.ENCLOSURE_ITEM;
			default:
				return null;
			}
		} else {
			return null;
		}
	}

	@Override
	public String getType(Uri uri) {
		switch (getTypeMime(uri)) {
		case PODCAST_DIR:
			return MIME_PODCAST_DIR;
		case PODCAST_ITEM:
			return MIME_PODCAST_ITEM;
		case EPISODE_DIR:
			return MIME_EPISODE_DIR;
		case EPISODE_ITEM:
			return MIME_EPISODE_ITEM;
		case ENCLOSURE_DIR:
			return MIME_ENCLOSURE_DIR;
		case ENCLOSURE_ITEM:
			return MIME_ENCLOSURE_ITEM;
		default:
{'fraction_non_alphanumeric': 0.11015160237958166, 'fraction_numerical': 0.005373248896564959, 'mean_word_length': 4.248741188318228, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5452981', 'n_tokens_mistral': 2077, 'n_tokens_neox': 1797, 'n_words': 394}