Class MotionDetection.BufferedImageSource

  • All Implemented Interfaces:
    javax.activation.DataSource
    Enclosing class:
    MotionDetection

    private static class MotionDetection.BufferedImageSource
    extends java.lang.Object
    implements javax.activation.DataSource
    A DataSource to prepare a BufferedImage for emailing.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.io.ByteArrayOutputStream baos
      A temporary place to hold the data from the BufferedImage
    • Constructor Summary

      Constructors 
      Constructor Description
      BufferedImageSource​(java.awt.image.BufferedImage image)
      Creates a new BufferedImageSource with the specified BufferedImage
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getContentType()
      Gets the content type of the converted image, in this case image/jpeg
      java.io.InputStream getInputStream()
      Gets an InputStream from which to read the image data
      java.lang.String getName()
      Gets the name of the data, usually a file name but in this case a generic file name of "image.jpg".
      java.io.OutputStream getOutputStream()
      Get the OutputStream associated with this data source, in this case there is no OutputStream and calling this method just throws an IOException.
      • Methods inherited from class java.lang.Object

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

      • baos

        private final java.io.ByteArrayOutputStream baos
        A temporary place to hold the data from the BufferedImage
    • Constructor Detail

      • BufferedImageSource

        public BufferedImageSource​(java.awt.image.BufferedImage image)
                            throws java.io.IOException
        Creates a new BufferedImageSource with the specified BufferedImage
        Parameters:
        image - the BufferedImage to source
        Throws:
        java.io.IOException - if an error occurs writing the image to the temporary ByteArrayOutputStream
    • Method Detail

      • getContentType

        public java.lang.String getContentType()
        Gets the content type of the converted image, in this case image/jpeg
        Specified by:
        getContentType in interface javax.activation.DataSource
        Returns:
        a String with the mime type of the data source
      • getInputStream

        public java.io.InputStream getInputStream()
        Gets an InputStream from which to read the image data
        Specified by:
        getInputStream in interface javax.activation.DataSource
        Returns:
        the InputStream containing the image data
      • getName

        public java.lang.String getName()
        Gets the name of the data, usually a file name but in this case a generic file name of "image.jpg".
        Specified by:
        getName in interface javax.activation.DataSource
        Returns:
        the String containing the name of the data
      • getOutputStream

        public java.io.OutputStream getOutputStream()
                                             throws java.io.IOException
        Get the OutputStream associated with this data source, in this case there is no OutputStream and calling this method just throws an IOException.
        Specified by:
        getOutputStream in interface javax.activation.DataSource
        Returns:
        the OutputStream for the data source
        Throws:
        java.io.IOException - if this method is called