com.machinezoo.sourceafis

Class FingerprintTransparency

SourceAFIS for Java » API Reference » FingerprintTransparency

  • All Implemented Interfaces:
    AutoCloseable


    public abstract class FingerprintTransparency
    extends Object
    implements AutoCloseable
    Algorithm transparency API that can capture all intermediate data structures produced by SourceAFIS algorithm. See algorithm transparency pages on SourceAFIS website for more information and a tutorial on how to use this class.
    Applications can subclass FingerprintTransparency and override capture(String, Map) method to define new transparency data logger. One default implementation of FingerprintTransparency is returned by zip(OutputStream) method.
    FingerprintTransparency instance should be created in try-with-resource construct. It will be capturing transparency data from all operations on current thread between invocation of the constructor and invocation of close() method, which happens automatically in try-with-resource construct.
    See Also:
    Algorithm transparency in SourceAFIS
    • Constructor Detail

      • FingerprintTransparency

        protected FingerprintTransparency()
        Creates an instance of FingerprintTransparency and activates it.
        Activation places the new FingerprintTransparency instance in thread-local storage, which causes all operations executed by current thread to log data to this FingerprintTransparency instance. If activations are nested, data is only logged to the currently innermost FingerprintTransparency.
        Deactivation happens in close() method. Instances of FingerprintTransparency should be created in try-with-resources construct to ensure that close() is always called.
        FingerprintTransparency is an abstract class. This constructor is only called by subclasses.
        See Also:
        close()
    • Method Detail

      • capture

        protected void capture(String keyword,
                               Map<String,Supplier<byte[]>> data)
        Record transparency data. Subclasses must override this method, because the default implementation does nothing. While this FingerprintTransparency object is active (between call to the constructor and call to close()), this method is called with transparency data in its parameters.
        Parameter keyword specifies the kind of transparency data being logged, usually corresponding to some stage in the algorithm. For convenience, several related pieces of transparency data are reported together. All pieces are available via map in parameter data, keyed by file suffix identifying the kind of data, usually .json or .dat for JSON and binary data respectively. See algorithm transparency on SourceAFIS website for documentation of the structure of the transparency data.
        Transparency data is offered indirectly via Supplier. If this Supplier is not evaluated, the data is never serialized. This allows applications to efficiently collect only transparency data that is actually needed.
        If this method throws, exception is propagated through SourceAFIS code.
        Parameters:
        keyword - specifies the kind of transparency data being reported
        data - a map of suffixes (like .json or .dat) to Supplier of the available transparency data
        See Also:
        Algorithm transparency in SourceAFIS, zip(OutputStream)
      • close

        public void close()
        Deactivate transparency logging and release system resources held by this instance if any. This method is normally called automatically when FingerprintTransparency is used in try-with-resources construct.
        Deactivation stops transparency data logging to this instance of FingerprintTransparency, which was started by the constructor (FingerprintTransparency()). If activations were nested, this method reactivates the outer FingerprintTransparency.
        Subclasses can override this method to perform cleanup. Default implementation of this method performs deactivation. It must be called by overriding methods for deactivation to work correctly.
        This method doesn't declare any checked exceptions in order to spare callers of mandatory exception checking. If your code needs to throw a checked exception, wrap it in an unchecked exception.
        Specified by:
        close in interface AutoCloseable
        See Also:
        FingerprintTransparency()
      • zip

        public static FingerprintTransparency zip(OutputStream stream)
        Write all transparency data to a ZIP file. This is a convenience method to enable easy exploration of the available data. Programmatic processing of transparency data should be done by subclassing FingerprintTransparency and overriding capture(String, Map) method.
        The returned FingerprintTransparency object holds system resources and callers are responsible for calling close() method, perhaps using try-with-resources construct. Failure to close the returned FingerprintTransparency instance may result in damaged ZIP file.
        If the provided stream throws IOException, the exception will be wrapped in an unchecked exception and propagated.
        Parameters:
        stream - output stream where ZIP file will be written (will be closed when the returned FingerprintTransparency is closed)
        Returns:
        algorithm transparency logger that writes data to a ZIP file
        See Also:
        close(), capture(String, Map)