All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dipien.byebyejetifier.scanner.ScannerProcessor.kt Maven / Gradle / Ivy

There is a newer version: 1.2.2
Show newest version
package com.dipien.byebyejetifier.scanner

import com.dipien.byebyejetifier.archive.Archive
import com.dipien.byebyejetifier.archive.ArchiveFile
import com.dipien.byebyejetifier.archive.ArchiveItemVisitor
import com.dipien.byebyejetifier.common.LoggerHelper

class ScannerProcessor(
    private val context: ScannerContext,
    private val scannerList: List
) : ArchiveItemVisitor {

    fun scanLibrary(archive: Archive): List {
        val scanResults = mutableListOf()
        archive.accept(this, scanResults)
        return scanResults
    }

    override fun visit(archive: Archive, scanResults: MutableList) {
        archive.files.forEach {
            it.accept(this, scanResults)
        }
    }

    override fun visit(archiveFile: ArchiveFile, scanResults: MutableList) {
        if (context.isExcludedFileFromScanning(archiveFile)) {
            LoggerHelper.debug("Excluded for scanning: ${archiveFile.relativePath}")
            return
        }

        var fileLogged = false

        scannerList.forEach {
            if (it.canScan(archiveFile)) {
                if (!fileLogged) {
                    fileLogged = true
                    LoggerHelper.debug("File: ${archiveFile.relativePath}")
                }
                scanResults.addAll(it.scan(archiveFile))
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy