com.lowagie.rups.model

Class IndirectObjectFactory

public class IndirectObjectFactory extends Object

A factory that can produce all the indirect objects in a PDF file.
Field Summary
protected intcurrent
The current xref number.
protected IntHashtableidxToRef
Mapping between the index in the objects list and the reference number in the xref table.
protected intn
The highest xref number.
protected ArrayList<PdfObject>objects
A list of all the indirect objects in a PDF file.
protected PdfReaderreader
The reader object.
protected IntHashtablerefToIdx
Mapping between the reference number in the xref table and the index in the objects list .
Constructor Summary
IndirectObjectFactory(PdfReader reader)
Creates a list that will contain all the indirect objects in a PDF document.
Method Summary
intgetCurrent()
Gets the last object that has been registered.
intgetIndexByRef(int ref)
Gets the index of an object based on its number in the xref table.
PdfObjectgetObjectByIndex(int i)
Gets an object based on its index in the indirect object list.
PdfObjectgetObjectByReference(int ref)
Gets an object based on its reference number in the xref table.
intgetRefByIndex(int i)
Gets the reference number in the xref table based on the index in the indirect object list.
intgetXRefMaximum()
Gets the highest possible object number in the XRef table.
PdfObjectloadObjectByReference(int ref)
Loads an object based on its reference number in the xref table.
intsize()
Gets the total number of indirect objects in the PDF file.
voidstore(PdfObject object)
If we store all the objects, we might run out of memory; that's why we'll only store the objects that are necessary to construct other objects (for instance the page table).
booleanstoreNextObject()
Stores the next object of the XRef table.

Field Detail

current

protected int current
The current xref number.

idxToRef

protected IntHashtable idxToRef
Mapping between the index in the objects list and the reference number in the xref table.

n

protected int n
The highest xref number.

objects

protected ArrayList<PdfObject> objects
A list of all the indirect objects in a PDF file.

reader

protected PdfReader reader
The reader object.

refToIdx

protected IntHashtable refToIdx
Mapping between the reference number in the xref table and the index in the objects list .

Constructor Detail

IndirectObjectFactory

public IndirectObjectFactory(PdfReader reader)
Creates a list that will contain all the indirect objects in a PDF document.

Parameters: reader the reader that will read the PDF document

Method Detail

getCurrent

public int getCurrent()
Gets the last object that has been registered. This method only makes sense while loading the factory. with loadNextObject().

Returns: the number of the last object that was stored

getIndexByRef

public int getIndexByRef(int ref)
Gets the index of an object based on its number in the xref table.

Parameters: ref a number in the xref table

Returns: the index in the list of indirect objects

getObjectByIndex

public PdfObject getObjectByIndex(int i)
Gets an object based on its index in the indirect object list.

Parameters: i an index in the indirect object list

Returns: a PDF object

getObjectByReference

public PdfObject getObjectByReference(int ref)
Gets an object based on its reference number in the xref table.

Parameters: ref a number in the xref table

Returns: a PDF object

getRefByIndex

public int getRefByIndex(int i)
Gets the reference number in the xref table based on the index in the indirect object list.

Parameters: i the index of an object in the indirect object list

Returns: the corresponding reference number in the xref table

getXRefMaximum

public int getXRefMaximum()
Gets the highest possible object number in the XRef table.

Returns: an object number

loadObjectByReference

public PdfObject loadObjectByReference(int ref)
Loads an object based on its reference number in the xref table.

Parameters: ref a reference number in the xref table.

Returns: a PDF object

size

public int size()
Gets the total number of indirect objects in the PDF file. This isn't necessarily the same number as returned by getXRefMaximum(). The PDF specification allows gaps between object numbers.

Returns: the total number of indirect objects in the PDF.

store

private void store(PdfObject object)
If we store all the objects, we might run out of memory; that's why we'll only store the objects that are necessary to construct other objects (for instance the page table).

Parameters: object an object we might want to store

storeNextObject

public boolean storeNextObject()
Stores the next object of the XRef table. As soon as this method returns false, it makes no longer sense calling it as all the objects have been stored.

Returns: false if there are no objects left to check.