<commit_before>/*
 * Copyright 2017 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.matthewtamlin.mixtape.example.data;

import android.graphics.Bitmap;

import com.matthewtamlin.mixtape.example.util.Id3Util;
import com.matthewtamlin.mixtape.library.data.LibraryItem;
import com.matthewtamlin.mixtape.library.data.LibraryReadException;
import com.matthewtamlin.mixtape.library.data.LibraryWriteException;

import java.io.File;
import java.io.IOException;

import static android.R.id.input;
import static com.matthewtamlin.java_utilities.checkers.NullChecker.checkNotNull;

public class Mp3Song implements LibraryItem {
	private File mp3File;

	public Mp3Song(final File mp3File) {
		this.mp3File = checkNotNull(mp3File, "mp3File cannot be null.");
	}

	public File getMp3File() {
		return mp3File;
	}

	@Override
	public CharSequence getTitle() throws LibraryReadException {
		try {
			return Id3Util.getMetadataFromId3Tag(mp3File, Id3Util.MetadataField.TITLE);
		} catch (final IOException e) {
			throw new LibraryReadException("Cannot read ID3 tag from file " + mp3File, e);
		}
	}

	@Override
	public CharSequence getSubtitle() throws LibraryReadException {
		try {
			return Id3Util.getMetadataFromId3Tag(mp3File, Id3Util.MetadataField.ARTIST);
		} catch (final IOException e) {
			throw new LibraryReadException("Cannot read ID3 tag from file " + mp3File, e);
		}
	}

	@Override
	public Bitmap getArtwork(final int width, final int height) throws LibraryReadException {
		try {
			return Id3Util.getCoverArtFromId3Tag(mp3File, width, height);
		} catch (final IOException e) {
			throw new LibraryReadException("Cannot read ID3 tag from file " + mp3File, e);
		}
	}

	@Override
	public void setSubtitle(final CharSequence subtitle)
			throws LibraryReadException, LibraryWriteException {
		throw new LibraryWriteException("Item is read only.");
	}

	@Override
	public void setArtwork(final Bitmap artwork)
			throws LibraryReadException, LibraryWriteException {
		throw new LibraryWriteException("Item is read only.");
	}

	@Override
	public boolean isReadOnly() {
		return true;
	}

	@Override
	public void setTitle(final CharSequence title)
			throws LibraryReadException, LibraryWriteException {
		throw new LibraryWriteException("Item is read only.");
	}

	@Override
	public boolean equals(final Object obj) {
		if (obj == null) {
			return false;
		}
<commit_msg>Deleted methods no longer defined by LibraryItem<commit_after>/*
 * Copyright 2017 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.matthewtamlin.mixtape.example.data;

import android.graphics.Bitmap;

import com.matthewtamlin.mixtape.example.util.Id3Util;
import com.matthewtamlin.mixtape.library.data.LibraryItem;
import com.matthewtamlin.mixtape.library.data.LibraryReadException;

import java.io.File;
import java.io.IOException;

import static com.matthewtamlin.java_utilities.checkers.NullChecker.checkNotNull;

public class Mp3Song implements LibraryItem {
	private File mp3File;

	public Mp3Song(final File mp3File) {
		this.mp3File = checkNotNull(mp3File, "mp3File cannot be null.");
	}

	public File getMp3File() {
		return mp3File;
	}

	@Override
	public CharSequence getTitle() throws LibraryReadException {
		try {
			return Id3Util.getMetadataFromId3Tag(mp3File, Id3Util.MetadataField.TITLE);
		} catch (final IOException e) {
			throw new LibraryReadException("Cannot read ID3 tag from file " + mp3File, e);
		}
	}

	@Override
	public CharSequence getSubtitle() throws LibraryReadException {
		try {
			return Id3Util.getMetadataFromId3Tag(mp3File, Id3Util.MetadataField.ARTIST);
		} catch (final IOException e) {
			throw new LibraryReadException("Cannot read ID3 tag from file " + mp3File, e);
		}
	}

	@Override
	public Bitmap getArtwork(final int width, final int height) throws LibraryReadException {
		try {
			return Id3Util.getCoverArtFromId3Tag(mp3File, width, height);
		} catch (final IOException e) {
			throw new LibraryReadException("Cannot read ID3 tag from file " + mp3File, e);
		}
	}

	@Override
	public boolean equals(final Object obj) {
		if (obj == null) {
			return false;
		}

{'fraction_non_alphanumeric': 0.08380213385063046, 'fraction_numerical': 0.013579049466537343, 'mean_word_length': 4.574054054054054, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '420443', 'n_tokens_mistral': 1642, 'n_tokens_neox': 1533, 'n_words': 486}