Class FileCleaningTracker.Tracker

  • Enclosing class:
    FileCleaningTracker

    private static final class FileCleaningTracker.Tracker
    extends java.lang.ref.PhantomReference<java.lang.Object>
    Inner class which acts as the reference for a file pending deletion.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private FileDeleteStrategy deleteStrategy
      The strategy for deleting files.
      private java.lang.String path
      The full path to the file being tracked.
    • Constructor Summary

      Constructors 
      Constructor Description
      Tracker​(java.lang.String path, FileDeleteStrategy deleteStrategy, java.lang.Object marker, java.lang.ref.ReferenceQueue<? super java.lang.Object> queue)
      Constructs an instance of this class from the supplied parameters.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean delete()
      Deletes the file associated with this tracker instance.
      java.lang.String getPath()
      Return the path.
      • Methods inherited from class java.lang.ref.PhantomReference

        get
      • Methods inherited from class java.lang.ref.Reference

        clear, clone, enqueue, isEnqueued, reachabilityFence
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • path

        private final java.lang.String path
        The full path to the file being tracked.
      • deleteStrategy

        private final FileDeleteStrategy deleteStrategy
        The strategy for deleting files.
    • Constructor Detail

      • Tracker

        Tracker​(java.lang.String path,
                FileDeleteStrategy deleteStrategy,
                java.lang.Object marker,
                java.lang.ref.ReferenceQueue<? super java.lang.Object> queue)
        Constructs an instance of this class from the supplied parameters.
        Parameters:
        path - the full path to the file to be tracked, not null
        deleteStrategy - the strategy to delete the file, null means normal
        marker - the marker object used to track the file, not null
        queue - the queue on to which the tracker will be pushed, not null
    • Method Detail

      • getPath

        public java.lang.String getPath()
        Return the path.
        Returns:
        the path
      • delete

        public boolean delete()
        Deletes the file associated with this tracker instance.
        Returns:
        true if the file was deleted successfully; false otherwise.