Package com.itextpdf.kernel.pdf
Class PdfIndirectReference
- java.lang.Object
-
- com.itextpdf.kernel.pdf.PdfObject
-
- com.itextpdf.kernel.pdf.PdfIndirectReference
-
- All Implemented Interfaces:
java.lang.Comparable<PdfIndirectReference>
public class PdfIndirectReference extends PdfObject implements java.lang.Comparable<PdfIndirectReference>
-
-
Field Summary
Fields Modifier and Type Field Description protected int
genNr
Object generation.private static int
LENGTH_OF_INDIRECTS_CHAIN
protected int
objectStreamNumber
Indirect reference number of object stream containing refersTo object.protected int
objNr
Object number.protected long
offsetOrIndex
Offset in a document of therefersTo
object.protected PdfDocument
pdfDocument
PdfDocument object belongs to.protected PdfObject
refersTo
PdfObject that current PdfIndirectReference instance refers to.-
Fields inherited from class com.itextpdf.kernel.pdf.PdfObject
ARRAY, BOOLEAN, DICTIONARY, FLUSHED, FORBID_RELEASE, FREE, INDIRECT_REFERENCE, indirectReference, LITERAL, MODIFIED, MUST_BE_FLUSHED, MUST_BE_INDIRECT, NAME, NULL, NUMBER, ORIGINAL_OBJECT_STREAM, READ_ONLY, READING, STREAM, STRING, UNENCRYPTED
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
PdfIndirectReference(PdfDocument doc, int objNr)
protected
PdfIndirectReference(PdfDocument doc, int objNr, int genNr)
protected
PdfIndirectReference(PdfDocument doc, int objNr, int genNr, long offset)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private int
comparePdfDocumentLinks(PdfIndirectReference toCompare)
int
compareTo(PdfIndirectReference o)
protected void
copyContent(PdfObject from, PdfDocument document)
Copies object content from object 'from'.protected void
copyContent(PdfObject from, PdfDocument document, ICopyFilter copyFilter)
Copies object content from object 'from'.boolean
equals(java.lang.Object o)
(package private) void
fixOffset(long offset)
PdfDocument
getDocument()
int
getGenNumber()
int
getIndex()
Gets refersTo object index in the object stream.int
getObjNumber()
int
getObjStreamNumber()
long
getOffset()
Gets refersTo object offset in a document.protected PdfReader
getReader()
Gets a PdfReader associated with the document object belongs to.PdfObject
getRefersTo()
PdfObject
getRefersTo(boolean recursively)
Gets direct object and try to resolve indirects chain.byte
getType()
Gets object type.protected PdfWriter
getWriter()
Gets a PdfWriter associated with the document object belongs to.int
hashCode()
boolean
isFree()
Checks if thisPdfIndirectReference
instance corresponds to free indirect reference.protected PdfObject
newInstance()
Creates new instance of object.void
setFree()
Marks indirect reference as free in the document.(package private) void
setIndex(long index)
(package private) void
setObjStreamNumber(int objectStreamNumber)
(package private) void
setOffset(long offset)
protected void
setRefersTo(PdfObject refersTo)
protected PdfObject
setState(short state)
Sets special states of current object.java.lang.String
toString()
-
Methods inherited from class com.itextpdf.kernel.pdf.PdfObject
checkState, clearState, clone, clone, containsIndirectReference, copyTo, copyTo, copyTo, copyTo, equalContent, flush, flush, getIndirectReference, isArray, isBoolean, isDictionary, isFlushed, isIndirect, isIndirectReference, isLiteral, isModified, isName, isNull, isNumber, isReleaseForbidden, isStream, isString, makeIndirect, makeIndirect, processCopying, processCopying, release, setIndirectReference, setModified
-
-
-
-
Field Detail
-
LENGTH_OF_INDIRECTS_CHAIN
private static final int LENGTH_OF_INDIRECTS_CHAIN
- See Also:
- Constant Field Values
-
objNr
protected final int objNr
Object number.
-
genNr
protected int genNr
Object generation.
-
refersTo
protected PdfObject refersTo
PdfObject that current PdfIndirectReference instance refers to.
-
objectStreamNumber
protected int objectStreamNumber
Indirect reference number of object stream containing refersTo object. If refersTo is not placed into object stream - objectStreamNumber = 0.
-
offsetOrIndex
protected long offsetOrIndex
Offset in a document of therefersTo
object. If the object placed into object stream then it is an object index inside object stream.
-
pdfDocument
protected PdfDocument pdfDocument
PdfDocument object belongs to. For direct objects it is null.
-
-
Constructor Detail
-
PdfIndirectReference
protected PdfIndirectReference(PdfDocument doc, int objNr)
-
PdfIndirectReference
protected PdfIndirectReference(PdfDocument doc, int objNr, int genNr)
-
PdfIndirectReference
protected PdfIndirectReference(PdfDocument doc, int objNr, int genNr, long offset)
-
-
Method Detail
-
getObjNumber
public int getObjNumber()
-
getGenNumber
public int getGenNumber()
-
getRefersTo
public PdfObject getRefersTo()
-
getRefersTo
public PdfObject getRefersTo(boolean recursively)
Gets direct object and try to resolve indirects chain.Note: If chain of references has length of more than 32, this method return 31st reference in chain.
- Parameters:
recursively
-true
to resolve indirects chain- Returns:
- the
PdfObject
result of indirect reference resolving
-
setRefersTo
protected void setRefersTo(PdfObject refersTo)
-
getObjStreamNumber
public int getObjStreamNumber()
-
getOffset
public long getOffset()
Gets refersTo object offset in a document.- Returns:
- object offset in a document. If refersTo object is in object stream then -1.
-
getIndex
public int getIndex()
Gets refersTo object index in the object stream.- Returns:
- object index in a document. If refersTo object is not in object stream then -1.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
compareTo
public int compareTo(PdfIndirectReference o)
- Specified by:
compareTo
in interfacejava.lang.Comparable<PdfIndirectReference>
-
getType
public byte getType()
Description copied from class:PdfObject
Gets object type.
-
getDocument
public PdfDocument getDocument()
-
setFree
public void setFree()
Marks indirect reference as free in the document. This doesn't "remove" indirect objects from the document, it only ensures that corresponding xref entry is free and indirect object referred by this reference is no longer linked to it. Actual object still might be written to the resultant document (and would get a new corresponding indirect reference in this case) if it is still contained in some other object.This method will not give any result if the corresponding indirect object or another object that contains a reference to this object is already flushed.
Note: in some cases, removing a link of indirect object to it's indirect reference while leaving the actual object in the document structure might lead to errors, because some objects are expected to always have such explicit link (e.g. Catalog object, page objects, etc).
-
isFree
public boolean isFree()
Checks if thisPdfIndirectReference
instance corresponds to free indirect reference. Indirect reference might be in a free state either because it was read as such from the opened existing PDF document or because it was set free viasetFree()
method.- Returns:
true
if thisPdfIndirectReference
is free,false
otherwise.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getWriter
protected PdfWriter getWriter()
Gets a PdfWriter associated with the document object belongs to.- Returns:
- PdfWriter.
-
getReader
protected PdfReader getReader()
Gets a PdfReader associated with the document object belongs to.- Returns:
- PdfReader.
-
newInstance
protected PdfObject newInstance()
Description copied from class:PdfObject
Creates new instance of object.- Specified by:
newInstance
in classPdfObject
- Returns:
- new instance of object.
-
copyContent
protected void copyContent(PdfObject from, PdfDocument document, ICopyFilter copyFilter)
Description copied from class:PdfObject
Copies object content from object 'from'.- Overrides:
copyContent
in classPdfObject
- Parameters:
from
- object to copy content from.document
- document to copy object to.copyFilter
-ICopyFilter
a filter that will apply on dictionaries and array UseNullCopyFilter
for no filtering
-
copyContent
protected void copyContent(PdfObject from, PdfDocument document)
Description copied from class:PdfObject
Copies object content from object 'from'.- Overrides:
copyContent
in classPdfObject
- Parameters:
from
- object to copy content from.document
- document to copy object to.
-
setState
protected PdfObject setState(short state)
Sets special states of current object.
-
setObjStreamNumber
void setObjStreamNumber(int objectStreamNumber)
-
setIndex
void setIndex(long index)
-
setOffset
void setOffset(long offset)
-
fixOffset
void fixOffset(long offset)
-
comparePdfDocumentLinks
private int comparePdfDocumentLinks(PdfIndirectReference toCompare)
-
-