Package Torello.Java

Class FileExpectedException

  • All Implemented Interfaces:
    java.io.Serializable

    public class FileExpectedException
    extends java.lang.RuntimeException
    FileExpectedException - Documentation.

    This class is used inside the class FileNode. It may be used to inform a user he has attempted to perform a particular method or operation on an instance of FileNode that was created to function as a "directory" rather than a "file." If the method involved may only be used on files, this exception (a RuntimeException) will be thrown.

    This class provides some public final "inspection & convenience" fields which are guaranteed not to be null when this Exception is thrown by an internal method to the HTML Node-Search package. 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



    • Method Summary

      All Methods Static Methods Concrete 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:
        1
        public static final long serialVersionUID = 1;
        
      • fn

        public final FileNode fn
        This field is provided to the user as a matter of convenience. All instantiations of this Exception are guaranteed to enforce and ensure that when an instance of this exception is thrown, the convenience field will not be null. If this package is extended, it is up to the programmer/user to make sure not to leave this field null when using one of these constructors. This constructor will not check whether a convenience field is null or not, when constructing the exception.

        IMPORTANT: 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 (like NullPointerException) - BECAUSE THIS CONVENIENCE FIELD WAS LEFT NULL - would be an unnecessary source of headache.

        This public final field contains the FileNode that caused an exception to throw.
        Code:
        Exact Field Declaration Expression:
        1
        public final FileNode fn;
        
    • 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 exceptions while checking exceptions!
        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.
        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 exceptions while checking exceptions!
        cause - This parameter may be used when generating "multiple-exceptions" that are modified as they are thrown.
        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:
        1
        2
        3
        4
        5
         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
         );