Interface ImageScraper.FileNameRetriever

  • All Superinterfaces:
    Enclosing class:
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    public static interface ImageScraper.FileNameRetriever
    A functional-interface allowing a user to specify a file-name for an image, which provides some details about the image before it is saved to disk.

    When this FunctionalInterface is implemented, the "save file-name" for a particular image can be provided on an image-by-image basis.

    • Method Summary

      @FunctionalInterface (Lambda) Method
      Modifier and Type Method
      String fileName​(URL url, IF imageFormat, int iteratorCount, int successCount)
    • Field Detail

      • serialVersionUID

        static final long serialVersionUID
        This fulfils the SerialVersion UID requirement for all classes that implement Java's interface 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.

        Functional Interfaces are usually not thought of as Data Objects that need to be saved, stored and retrieved; however, having the ability to store intermediate results along with the lambda-functions that helped get those results can make debugging easier.
        See Also:
        Constant Field Values
        Exact Field Declaration Expression:
        public static final long serialVersionUID = 1;
    • Method Detail

      • fileName

        java.lang.String fileName​( url,
                                  IF imageFormat,
                                  int iteratorCount,
                                  int successCount)
        The intention of implementing this method is to provide the code with an 'adjusted' file name for saving images downloaded from the internet.
        url - This is the URL that was used to connect to the internet, and download the image in question.
        imageFormat - This identifies whether the image-in-question is a GIF, JPG, PNG, etc... Remember the image might not be saved by the same name which was used in the HTML on the website from which this was downloaded.
        iteratorCount - Identifies the 'count' in the Iterator's retrieval. Since this int is used as an array-index pointer, it is initialized to '0' (zero). Specifically, if this method were called upon completion of three iterations of Image-URL retrieval, this counter would be '2' (two).
        successCount - This identifies how many images have successfully downloaded, not the number of images for which a "download attempt" occurred. Since this int is used as an array-index pointer, it is initialized to '0' (zero). If on the third iteration of the source-Iterator, an IOException occurred between the Java-Virtual-Machine and the internet, the following invocation of this method would have successCount as '2' (two), but the iteratorCount would be '3' (three).
        utilizing the information provided in the method-signature, the programmer is expected to provide a file-name for saving the image that was provided.