Processor

abstract class Processor<T : Any>

A general purpose file processor that handles converting a single file from one format FileFormat to another appropriate FileFormat.

A single processor should handle all formats under that medium. For example, ImageProcessor is a builtin processor that handles most popular vector and bitmap formats. It is thus, unwise to create another similar processor that just converts PNG to JPG.

Inheritors

Properties

Link copied to clipboard

Functions

Link copied to clipboard
open fun buffer(input: File): T

This is when you want the processor to just read a file and return an in memory version. You can then take the return value and do whatever you want with it. By default, it will throw NotImplementedError.

Link copied to clipboard
open fun canProcessType(type: FileFormat<T>?): Boolean

Checks whether type can be processed by this processor.

Link copied to clipboard
abstract fun detectFileType(input: File): FileFormat<T>

Tries to detect the FileFormat of input using mediumKey and targetedFormats. This mechanism is thus implemented per basis for each processor.

Link copied to clipboard
abstract fun process(input: File, fromType: FileFormat<T>? = null, toType: FileFormat<T>, renamerContext: TemplateContext = emptyMap())

Processes input with an optional input file type fromType. If fromType is null, then the implementor should call detectFileType to grab that format.

Link copied to clipboard

Returns the targeted formats provided in Public.MEDIUMS using the internal Processor.mediumKey