Interface ImageScraper.ImageReceiver

  • 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.ImageReceiver
    A functional-interface that allows a user to save an image-file to a location of his or her choosing.

    When this FunctionalInterface is implemented, saving the images to the file-system at all can be eliminated, and instead, those images are sent to this class' save(...) method. Some programs may wish to download all the images on a particular website, but rather than saving them to disk, they might want to store them in a database, or something different altogether - for instance "Fire Base" Technology, or even Google Pub Sub. If this FunctionalInterface is implemented, then the images will not be saved to disk, but rather sent to a target destination of the users choice - via this interfaces provided save(...) method.

    • Method Summary

      @FunctionalInterface (Lambda) Method
      Modifier and Type Method
      void save​(URL url, String fileName, IF imageFormat, int iteratorCount, int successCount, java.awt.image.BufferedImage image)
    • 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

      • save

        void save​( url,
                  java.lang.String fileName,
                  IF imageFormat,
                  int iteratorCount,
                  int successCount,
                  java.awt.image.BufferedImage image)
        Implement this class if saving image files to a target-directory on the file-system is not acceptable, and the programmer wishes to do something else with the downloaded images. The lone-method in this interface (the "save" method) will be invoked each time and image is downloaded.
        url - This is the URL that was used to connect to the internet, and download the image in question.
        fileName - This parameter will receive the computed filename of the image.
        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).
        image - This is the newly downloaded image.