Package Torello.Java

Class FileExpectedException

  • All Implemented Interfaces:
    java.io.Serializable

    public class FileExpectedException
    extends java.lang.RuntimeException
    Thrown when a FileNode operation has been invoked on an instance that represents an Operating-System Directory, but that invoked-method may only be applied to Operating-System File instances. This is a RuntimeException, not a checked-exception.

    This class provides some public final "inspection & convenience" fields which should guarantee to avoid having null values when this Exception is thrown by an internal method. If as a programmer, you intended to extend use of this class, make sure to pass valid-information & valid-data, to the constructors of this class.
    See Also:
    Serialized Form


    • Field Summary

       
      Serializable ID
      Modifier and Type Field
      static long serialVersionUID
       
      'final' Exception Convenience Fields
      Modifier and Type Field
      FileNode fn
    • Constructor Summary

      Constructors 
      Constructor Description
      FileExpectedException​(String message, Throwable cause, FileNode fn)
      Constructs a new exception with the specified detail message, cause-chain Throwable, and one public, final parameter: fn.
      FileExpectedException​(String message, FileNode fn)
      Constructs a new exception with the specified detail message, and one public, final parameter: fn.
    • Method Summary

       
      'static' Exception Check Methods
      Modifier and Type Method
      static void check​(FileNode fn)
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

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

      • serialVersionUID

        🡇     🗕  🗗  🗖
        public static final long serialVersionUID
        This fulfils the SerialVersion UID requirement for all classes that implement Java's interface java.io.Serializable. Using the Serializable Implementation offered by java is very easy, and can make saving program state when debugging a lot easier. It can also be used in place of more complicated systems like "hibernate" to store data as well.

        Note that Java's java.lang.Exception and java.lang.Error classes implement the Serializable interface, and a warning-free build expects this field be defined here.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
         public static final long serialVersionUID = 1;
        
      • fn

        🡅  🡇     🗕  🗗  🗖
        public final FileNode fn
        This field is provided to the user as a matter of convenience. All instances of this Exception ought to guarantee that when an instance is thrown - any & all "Convenience Fields" have been properly set.

        If this package is extended, or if this exception is used elsewhere, try to remember to not to accidentally leave this field null when using this class' constructors.

        In Summary:
        All this is really trying to explain is that, when debugging your code, if in the analysis of a particular Exception, that analysis causes another exception throw (NullPointerException) - BECAUSE THIS CONVENIENCE FIELD WAS LEFT NULL - you would likely get pretty angry.

        This public final field contains the FileNode that caused an exception to throw.
    • Constructor Detail

      • FileExpectedException

        🡅  🡇     🗕  🗗  🗖
        public FileExpectedException​(java.lang.String message,
                                     FileNode fn)
        Constructs a new exception with the specified detail message, and one public, final parameter: fn.
        Parameters:
        message - This is any message informing the user what has occurred.
        fn - This is the instance of class FileNode that was involved in the mistake.

        This parameter should not be left null. If it were accidentally left null, this could force exception-handling code to to throw an exception itself - while checking exceptions! Note that checking the input to this constructor does occur, and if this parameter is passed a null value, an instance of Torello.Java.ExceptionCheckError will throw.
        Throws:
        ExceptionCheckError - If parameter 'fn' is passed null
        See Also:
        fn
      • FileExpectedException

        🡅  🡇     🗕  🗗  🗖
        public FileExpectedException​(java.lang.String message,
                                     java.lang.Throwable cause,
                                     FileNode fn)
        Constructs a new exception with the specified detail message, cause-chain Throwable, and one public, final parameter: fn.
        Parameters:
        message - This is any message informing the user what has occurred.
        cause - This parameter may be used when generating "multiple-exceptions" that are modified as they are thrown.
        fn - This is the instance of class FileNode that was involved in the mistake.

        This parameter should not be left null. If it were accidentally left null, this could force exception-handling code to to throw an exception itself - while checking exceptions! Note that checking the input to this constructor does occur, and if this parameter is passed a null value, an instance of Torello.Java.ExceptionCheckError will throw.
        Throws:
        ExceptionCheckError - If parameter 'fn' is passed null
        See Also:
        fn
    • Method Detail

      • check

        🡅     🗕  🗗  🗖
        public static void check​(FileNode fn)
        Checks whether or not the FileNode parameter passed is actually one representing a file, not a directory.
        Parameters:
        fn - This may be any instance of FileNode however if it is not one that is meaning to represent an operating-system file, then this method will automatically throw an exception.
        Throws:
        FileExpectedException - If parameter 'fn' is a file, not a directory.
        Code:
        Exact Method Body:
         if (fn.isDirectory) throw new FileExpectedException(
             "The invocation of the previous method on a FileNode that is, itself, a directory " +
             "and not a file instead cannot proceed.",
             fn
         );