Class OpenFile


  • public class OpenFile
    extends AbstractFile
    Action performed when a file is opened.
    • Field Summary

    • Constructor Summary

      Constructors 
      Constructor Description
      OpenFile​(java.io.File file)
      Creates an open file action in read mode.
      OpenFile​(java.io.File file, boolean writeMode, boolean overwrite)
      Creates an open file action.
      OpenFile​(java.io.RandomAccessFile file)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long getOverwritingSize()
      Returns the size of the file before overwriting.
      boolean isOverwritten()
      Tells whether the file will be overwritten if it exists.
      boolean isWriteMode()
      Tells whether the file is opened in write mode or not.
      void onEnd​(boolean endWithSuccess)
      Called when the execution of the action is finished.
      void onStart()
      Called when the execution of the action is about to start.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • OpenFile

        public OpenFile​(java.io.File file,
                        boolean writeMode,
                        boolean overwrite)
        Creates an open file action.
        Parameters:
        file - the file to be opened.
        writeMode - true if the file is opened in write mode.
        overwrite - true if the file will be overwritten if it exists; false otherwise. This parameter has no effect if writeMode is set to false.
      • OpenFile

        public OpenFile​(java.io.File file)
        Creates an open file action in read mode.
        Parameters:
        file - the file to be opened in read mode.
      • OpenFile

        public OpenFile​(java.io.RandomAccessFile file)
    • Method Detail

      • isOverwritten

        public boolean isOverwritten()
        Tells whether the file will be overwritten if it exists.
        Returns:
        true if the file will be overwritten; false otherwise.
      • isWriteMode

        public boolean isWriteMode()
        Tells whether the file is opened in write mode or not.
        Returns:
        true if the file is opened in write mode; false otherwise.
      • getOverwritingSize

        public long getOverwritingSize()
        Returns the size of the file before overwriting.
        Returns:
        the size of the file before it's overwriting.
      • onStart

        public void onStart()
                     throws java.lang.SecurityException
        Called when the execution of the action is about to start. This hook is used to check if the action is allowed to be performed.
        Throws:
        java.lang.SecurityException - if the action is not allowed to be performed.
      • onEnd

        public void onEnd​(boolean endWithSuccess)
        Called when the execution of the action is finished. This hook is used to update the current resources state of the module that performs the action.
        Parameters:
        endWithSuccess - true if the execution of the action was ended with success; false otherwise.