Class MimeTypeContent

    • Constructor Detail

      • MimeTypeContent

        public MimeTypeContent​(@Nonnull @Nonempty
                               byte[] aContentBytes,
                               @Nonnull
                               IMimeType aMimeType)
        Constructor
        Parameters:
        aContentBytes - The beginning bytes. May neither be null nor empty.
        aMimeType - The corresponding mime type. May not be null.
      • MimeTypeContent

        public MimeTypeContent​(@Nonnull @Nonempty
                               byte[] aContentBytes,
                               boolean bCopyBytes,
                               @Nonnull
                               IMimeType aMimeType)
        Constructor
        Parameters:
        aContentBytes - The beginning bytes. May neither be null nor empty.
        bCopyBytes - true to copy the bytes, false to reuse the provided instance.
        aMimeType - The corresponding mime type. May not be null.
    • Method Detail

      • getContentByteCount

        @Nonnegative
        public int getContentByteCount()
        Returns:
        The number of content bytes available. Always > 0.
      • writeContentBytes

        public void writeContentBytes​(@Nonnull @WillNotClose
                                      OutputStream aOS)
                               throws IOException
        Write the content bytes to the specified output stream.
        Parameters:
        aOS - The output stream to write to. The stream is NOT closed. May not be null.
        Throws:
        IOException - In case of a write error
      • getMimeType

        @Nonnull
        public IMimeType getMimeType()
        Returns:
        The matching mime type. Never null.
      • matchesBeginning

        public boolean matchesBeginning​(@Nonnull
                                        byte[] aCmpBytes)
        Check if the passed byte array starts with the bytes of this object.
        Parameters:
        aCmpBytes - The bytes to compare to. May not be null.
        Returns:
        true if the passed bytes start with the bytes in this object.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object