Package org.jmrtd.lds

Class AbstractImageInfo

    • Constructor Detail

      • AbstractImageInfo

        protected AbstractImageInfo​(int type)
        Constructs an abstract image info with a type.
        Parameters:
        type - the type of image
      • AbstractImageInfo

        protected AbstractImageInfo​(int type,
                                    String mimeType)
        Constructs an abstract image info with a type and a mime-type.
        Parameters:
        type - the type
        mimeType - the mime-type string
      • AbstractImageInfo

        public AbstractImageInfo​(int type,
                                 int width,
                                 int height,
                                 InputStream inputStream,
                                 long imageLength,
                                 String mimeType)
                          throws IOException
        Constructs an abstract image info.
        Parameters:
        type - type of image info
        width - width of image
        height - height of image
        inputStream - encoded image
        imageLength - length of encoded image
        mimeType - mime-type of encoded image
        Throws:
        IOException - if reading fails
    • Method Detail

      • getMimeType

        public String getMimeType()
        Returns the mime-type of the encoded image.
        Specified by:
        getMimeType in interface ImageInfo
        Returns:
        the mime-type of the encoded image
      • getWidth

        public int getWidth()
        Returns the width of the image.
        Specified by:
        getWidth in interface ImageInfo
        Returns:
        the width of the image
      • getHeight

        public int getHeight()
        Returns the height of the image.
        Specified by:
        getHeight in interface ImageInfo
        Returns:
        the height of the image
      • getImageLength

        public int getImageLength()
        Returns the length of the encoded image.
        Specified by:
        getImageLength in interface ImageInfo
        Returns:
        the length of the encoded image
      • toString

        public String toString()
        Gets a textual representation of this image info.
        Overrides:
        toString in class Object
        Returns:
        a textual representation of this image info
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getEncoded

        public byte[] getEncoded()
        Encodes this image info.
        Specified by:
        getEncoded in interface LDSElement
        Returns:
        a byte array containing the encoded image info
      • getImageInputStream

        public InputStream getImageInputStream()
        Gets the encoded image as an input stream.
        Specified by:
        getImageInputStream in interface ImageInfo
        Returns:
        an input stream containing the encoded image
      • readImage

        protected void readImage​(InputStream inputStream,
                                 long imageLength)
                          throws IOException
        Clients should call this method after positioning the input stream to the image bytes.
        Parameters:
        inputStream - input stream
        imageLength - image length
        Throws:
        IOException - on error reading the input stream, for example at EOF
      • writeImage

        protected void writeImage​(OutputStream outputStream)
                           throws IOException
        Writes this image to a stream.
        Parameters:
        outputStream - the stream to write to
        Throws:
        IOException - on error writing to the stream
      • setMimeType

        protected final void setMimeType​(String mimeType)
        Sets the mime-type.
        Parameters:
        mimeType - the new mime-type
      • setType

        protected final void setType​(int type)
        Sets the type.
        Parameters:
        type - the new type
      • setWidth

        protected final void setWidth​(int width)
        Sets the width of this image.
        Parameters:
        width - the new width
      • setHeight

        protected final void setHeight​(int height)
        Sets the height of this image.
        Parameters:
        height - the new height
      • setImageBytes

        protected final void setImageBytes​(byte[] imageBytes)
        Sets the encoded image bytes of this image.
        Parameters:
        imageBytes - the image bytes
      • readObject

        protected abstract void readObject​(InputStream inputStream)
                                    throws IOException
        Reads this object from a stream.
        Parameters:
        inputStream - the stream to read from
        Throws:
        IOException - on error reading from the stream
      • writeObject

        protected abstract void writeObject​(OutputStream outputStream)
                                     throws IOException
        Writes this object to a stream.
        Parameters:
        outputStream - the stream to write to
        Throws:
        IOException - on error writing to the stream