Top Description Fields Constructors Methods
org.apache.pdfbox.jbig2

pack-priv Class JBIG2Document

extends Object
Class Inheritance
Imports
java.io.EOFException, .IOException, java.util.LinkedList, .List, .Map, .TreeMap, javax.imageio.stream.ImageInputStream, org.apache.pdfbox.jbig2.io.SubInputStream

This class represents the document structure with its pages and global segments.

Field Summary

Modifier and TypeField and 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

This flag contains information about the file organization:

  • 1 for sequential
  • 0 for random-access
private final Map<Integer, JBIG2Page>
pages

This map contains all pages of this document.

public static final int
public static final int
private final SubInputStream
subInputStream

This is the source data stream wrapped into a SubInputStream.

Constructor Summary

AccessConstructor and Description
protected
protected

Method Summary

Modifier and TypeMethod and Description
private void
determineRandomDataOffsets(List<SegmentHeader> segments, long offset)

Determines the start of the data parts and sets the offset.

protected int

Returns:

The amount of pages in this JBIG2 document.
getAmountOfPages
()

Retrieves the amount of pages in this JBIG2 document.

pack-priv SegmentHeader

Returns:

The requested SegmentHeader.
getGlobalSegment
(int
- The number of the wanted segment.
segmentNr
)

Retrieves the segment with the given segment number considering only segments that aren't associated with a page.

protected JBIG2Globals
protected JBIG2Page

Returns:

The requested JBIG2Page.
getPage
(int
- The page number of the wanted JBIG2Page.
pageNumber
)

Retrieves a JBIG2Page specified by the given page number.

protected boolean
private boolean
pack-priv boolean
private void
mapStream()

This method maps the stream and stores all segments.

private void
parseFileHeader()

This method reads the stream and sets variables for information about organization type and length etc.

private boolean

Returns:

  • true if end of stream reached
  • false if there are more bytes to read
  • reachedEndOfStream
    (long offset)

    This method checks, if the stream is at its end to avoid EOFExceptions and reads 32 bits.

    Inherited from java.lang.Object:
    cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

    Field Detail

    amountOfPagesback to summary
    private int amountOfPages

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

    amountOfPagesUnknownback to summary
    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
    FILE_HEADER_IDback to summary
    private int[] FILE_HEADER_ID

    ID string in file header, see ISO/IEC 14492:2001, D.4.1

    fileHeaderLengthback to summary
    private short fileHeaderLength

    The length of the file header if exists

    gbUseExtTemplateback to summary
    private boolean gbUseExtTemplate

    Defines whether extended Template is used.

    globalSegmentsback to summary
    private JBIG2Globals globalSegments

    Holds a load of segments, that aren't associated with a page.

    organisationTypeback to summary
    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 JBIG2Document#SEQUENTIAL.
    pagesback to summary
    private final Map<Integer, JBIG2Page> pages

    This map contains all pages of this document. The key is the number of the page.

    RANDOMback to summary
    public static final int RANDOM
    SEQUENTIALback to summary
    public static final int SEQUENTIAL
    subInputStreamback to summary
    private final SubInputStream subInputStream

    This is the source data stream wrapped into a SubInputStream.

    Constructor Detail

    JBIG2Documentback to summary
    protected JBIG2Document(ImageInputStream input) throws IOException
    JBIG2Documentback to summary
    protected JBIG2Document(ImageInputStream input, JBIG2Globals globals) throws IOException

    Method Detail

    determineRandomDataOffsetsback to summary
    private void determineRandomDataOffsets(List<SegmentHeader> segments, long offset)

    Determines the start of the data parts and sets the offset.

    getAmountOfPagesback to summary
    protected int getAmountOfPages() throws 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:int

    The amount of pages in this JBIG2 document.

    getGlobalSegmentback to summary
    pack-priv SegmentHeader getGlobalSegment(int segmentNr)

    Retrieves the segment with the given segment number considering only segments that aren't associated with a page.

    Parameters
    segmentNr:int

    - The number of the wanted segment.

    Returns:SegmentHeader

    The requested SegmentHeader.

    getGlobalSegmentsback to summary
    protected JBIG2Globals getGlobalSegments()
    getPageback to summary
    protected JBIG2Page getPage(int pageNumber)

    Retrieves a JBIG2Page specified by the given page number.

    Parameters
    pageNumber:int

    - The page number of the wanted JBIG2Page.

    Returns:JBIG2Page

    The requested JBIG2Page.

    isAmountOfPagesUnknownback to summary
    protected boolean isAmountOfPagesUnknown()
    isFileHeaderPresentback to summary
    private boolean isFileHeaderPresent() throws IOException
    isGbUseExtTemplateback to summary
    pack-priv boolean isGbUseExtTemplate()
    mapStreamback to summary
    private void mapStream() throws IOException

    This method maps the stream and stores all segments.

    parseFileHeaderback to summary
    private void parseFileHeader() throws IOException

    This method reads the stream and sets variables for information about organization type and length etc.

    reachedEndOfStreamback to summary
    private boolean reachedEndOfStream(long offset) throws IOException

    This method checks, if the stream is at its end to avoid EOFExceptions and reads 32 bits.

    Returns:boolean

  • true if end of stream reached
  • false if there are more bytes to read