Class JBIG2Document


  • class JBIG2Document
    extends java.lang.Object
    This class represents the document structure with its pages and global segments.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int amountOfPages
      According to D.4.3 - Number of pages field (4 bytes).
      private boolean amountOfPagesUnknown
      According to D.4.2 - Bit 1
      true if amount of pages is unknown, amount of pages field is not present false if there is a field in the file header where the amount of pages can be read
      private int[] FILE_HEADER_ID
      ID string in file header, see ISO/IEC 14492:2001, D.4.1
      private short fileHeaderLength
      The length of the file header if exists
      private boolean gbUseExtTemplate
      Defines whether extended Template is used.
      private JBIG2Globals globalSegments
      Holds a load of segments, that aren't associated with a page.
      private short organisationType
      According to D.4.2 - File header bit 0
      private java.util.Map<java.lang.Integer,​JBIG2Page> pages
      This map contains all pages of this document.
      static int RANDOM  
      static int SEQUENTIAL  
      private SubInputStream subInputStream
      This is the source data stream wrapped into a SubInputStream.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected JBIG2Document​(javax.imageio.stream.ImageInputStream input)  
      protected JBIG2Document​(javax.imageio.stream.ImageInputStream input, JBIG2Globals globals)  
    • Field Detail

      • FILE_HEADER_ID

        private int[] FILE_HEADER_ID
        ID string in file header, see ISO/IEC 14492:2001, D.4.1
      • pages

        private final java.util.Map<java.lang.Integer,​JBIG2Page> pages
        This map contains all pages of this document. The key is the number of the page.
      • fileHeaderLength

        private short fileHeaderLength
        The length of the file header if exists
      • organisationType

        private short organisationType
        According to D.4.2 - File header bit 0

        This flag contains information about the file organization:

        • 1 for sequential
        • 0 for random-access
        You can use the constants RANDOM and SEQUENTIAL.
      • amountOfPagesUnknown

        private boolean amountOfPagesUnknown
        According to D.4.2 - Bit 1
        • true if amount of pages is unknown, amount of pages field is not present
        • false if there is a field in the file header where the amount of pages can be read
      • amountOfPages

        private int amountOfPages
        According to D.4.3 - Number of pages field (4 bytes). Only present if amountOfPagesUnknown is false.
      • gbUseExtTemplate

        private boolean gbUseExtTemplate
        Defines whether extended Template is used.
      • globalSegments

        private JBIG2Globals globalSegments
        Holds a load of segments, that aren't associated with a page.
    • Constructor Detail

      • JBIG2Document

        protected JBIG2Document​(javax.imageio.stream.ImageInputStream input)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • JBIG2Document

        protected JBIG2Document​(javax.imageio.stream.ImageInputStream input,
                                JBIG2Globals globals)
                         throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • getGlobalSegment

        SegmentHeader getGlobalSegment​(int segmentNr)
        Retrieves the segment with the given segment number considering only segments that aren't associated with a page.
        Parameters:
        segmentNr - - The number of the wanted segment.
        Returns:
        The requested SegmentHeader.
      • getPage

        protected JBIG2Page getPage​(int pageNumber)
        Retrieves a JBIG2Page specified by the given page number.
        Parameters:
        pageNumber - - The page number of the wanted JBIG2Page.
        Returns:
        The requested JBIG2Page.
      • getAmountOfPages

        protected int getAmountOfPages()
                                throws java.io.IOException
        Retrieves the amount of pages in this JBIG2 document. If the pages are striped, the document will be completely parsed and the amount of pages will be gathered.
        Returns:
        The amount of pages in this JBIG2 document.
        Throws:
        java.io.IOException
      • mapStream

        private void mapStream()
                        throws java.io.IOException
        This method maps the stream and stores all segments.
        Throws:
        java.io.IOException
      • isFileHeaderPresent

        private boolean isFileHeaderPresent()
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • determineRandomDataOffsets

        private void determineRandomDataOffsets​(java.util.List<SegmentHeader> segments,
                                                long offset)
        Determines the start of the data parts and sets the offset.
        Parameters:
        segments -
        offset -
      • parseFileHeader

        private void parseFileHeader()
                              throws java.io.IOException
        This method reads the stream and sets variables for information about organization type and length etc.
        Throws:
        java.io.IOException
      • reachedEndOfStream

        private boolean reachedEndOfStream​(long offset)
                                    throws java.io.IOException
        This method checks, if the stream is at its end to avoid EOFExceptions and reads 32 bits.
        Parameters:
        offset -
        Returns:
      • true if end of stream reached
      • false if there are more bytes to read
      • Throws:
        java.io.IOException
      • getGlobalSegments

        protected JBIG2Globals getGlobalSegments()
      • isAmountOfPagesUnknown

        protected boolean isAmountOfPagesUnknown()
      • isGbUseExtTemplate

        boolean isGbUseExtTemplate()