<commit_before>/*
 * Copyright (c) 2021 toastkidjp.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompany this distribution.
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html.
 */

package jp.toastkid.yobidashi.media.image.preview.detail

import androidx.exifinterface.media.ExifInterface

class ExifInformationExtractorUseCase(
        private val stringBuilder: StringBuilder = StringBuilder()
) {
    
    operator fun invoke(exifInterface: ExifInterface): String? {
        TARGET_TAGS.forEach { extractAttribute(exifInterface, it) }

        val content = stringBuilder.toString()
        stringBuilder.setLength(0)
        return content
    }

    private fun extractAttribute(exifInterface: androidx.exifinterface.media.ExifInterface, tag: String) {
        exifInterface.getAttribute(tag)?.let {
            stringBuilder.append("$tag: $it${System.lineSeparator()}")
        }
    }

    companion object {<commit_msg>refactor #506 Remove redundant qualifier name.<commit_after>/*
 * Copyright (c) 2021 toastkidjp.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompany this distribution.
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html.
 */

package jp.toastkid.yobidashi.media.image.preview.detail

import androidx.exifinterface.media.ExifInterface

class ExifInformationExtractorUseCase(
        private val stringBuilder: StringBuilder = StringBuilder()
) {
    
    operator fun invoke(exifInterface: ExifInterface): String? {
        TARGET_TAGS.forEach { extractAttribute(exifInterface, it) }

        val content = stringBuilder.toString()
        stringBuilder.setLength(0)
        return content
    }

    private fun extractAttribute(exifInterface: ExifInterface, tag: String) {
        exifInterface.getAttribute(tag)?.let {
            stringBuilder.append("$tag: $it${System.lineSeparator()}")
        }
    }

    companion object {
{'fraction_non_alphanumeric': 0.08900279589934762, 'fraction_numerical': 0.0097856477166822, 'mean_word_length': 3.607296137339056, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5457160', 'n_tokens_mistral': 600, 'n_tokens_neox': 575, 'n_words': 153}