public class XrefTable
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected int[] |
_generation
The array of generation values.
|
protected long[] |
_index
The array of index values.
|
protected long[] |
_index_sorted
The array of sorted index values.
|
protected java.util.List |
_startxrefs
The list of startxref values associated with this
cross-reference table.
|
protected PdfDictionary |
_trailer
The trailer dictionary associated with this cross-reference
table.
|
protected byte[] |
_usage
The array of usage values.
|
static byte |
ENTRY_FREE
This indicates that an entry is free.
|
static byte |
ENTRY_IN_USE
This indicates that an entry is in-use.
|
static byte |
ENTRY_UNDEFINED
This indicates that an entry is undefined.
|
Modifier | Constructor and Description |
---|---|
protected |
XrefTable()
A protected constructor intended to be called only from
wrap(long[], int[], byte[], PdfDictionary) . |
|
XrefTable(long[] index,
int[] generation,
byte[] usage,
PdfDictionary trailerDictionary)
Constructs a cross-reference table from a set of arrays and
a trailer dictionary.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
Returns a shallow copy of this instance.
|
protected void |
createSortedIndexArray() |
long |
estimateObjectEnd(int n)
Returns an offset estimated to be relatively close to the
end of the object (specified by object number).
|
int |
getGeneration(int n)
Returns the generation value for a specified object.
|
int[] |
getGenerationArray()
Returns the array of generation values.
|
long |
getIndex(int n)
Returns the index value for a specified object.
|
long[] |
getIndexArray()
Returns the array of index values.
|
protected java.util.List |
getStartxrefList()
Returns the list of startxref values associated with this
cross-reference table.
|
PdfDictionary |
getTrailerDictionary()
Returns the trailer dictionary associated with this
cross-reference table.
|
byte |
getUsage(int n)
Returns the usage value for a specified object.
|
byte[] |
getUsageArray()
Returns the array of usage values.
|
int |
size()
Returns the number of entries in this cross-reference
table.
|
java.lang.String |
toString()
Returns the cross-reference table, associated trailer
dictionary, and a complete PDF trailer as a string in PDF
format.
|
protected int[] |
unwrapGenerationArray()
Returns the array of generation values.
|
protected long[] |
unwrapIndexArray()
Returns the array of index values.
|
protected byte[] |
unwrapUsageArray()
Returns the array of usage values.
|
protected static XrefTable |
wrap(long[] index,
int[] generation,
byte[] usage,
PdfDictionary trailerDictionary)
A factory for fast construction of this class.
|
protected int |
writePdf(PdfWriter w,
long startxref)
Writes the cross-reference table, associated trailer
dictionary, and a complete PDF trailer in PDF format.
|
protected void |
xrefGenerateFreeList()
Combines the free elements of this cross-reference table
into a linked list as required by the PDF specification.
|
protected int[] _generation
protected long[] _index
protected long[] _index_sorted
protected java.util.List _startxrefs
protected PdfDictionary _trailer
protected byte[] _usage
public static final byte ENTRY_FREE
public static final byte ENTRY_IN_USE
public static final byte ENTRY_UNDEFINED
protected XrefTable()
wrap(long[], int[], byte[], PdfDictionary)
.public XrefTable(long[] index, int[] generation, byte[] usage, PdfDictionary trailerDictionary) throws PdfFormatException
index
- the array of index values. Each value
represents either a byte offset (if in-use) or the next
free object number (if free).generation
- the array of generation values.usage
- the array of usage values. Each value is
ENTRY_FREE
, ENTRY_IN_USE
, or ENTRY_UNDEFINED
.trailerDictionary
- the trailer dictionary.PdfFormatException
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
protected void createSortedIndexArray()
public long estimateObjectEnd(int n)
n
- the specified object number.public int getGeneration(int n)
n
- the object number.public int[] getGenerationArray()
public long getIndex(int n)
n
- the object number.public long[] getIndexArray()
protected java.util.List getStartxrefList()
Long
objects.public PdfDictionary getTrailerDictionary()
public byte getUsage(int n)
n
- the object number.public byte[] getUsageArray()
public int size()
public java.lang.String toString()
toString
in class java.lang.Object
protected int[] unwrapGenerationArray()
protected long[] unwrapIndexArray()
protected byte[] unwrapUsageArray()
protected static XrefTable wrap(long[] index, int[] generation, byte[] usage, PdfDictionary trailerDictionary)
createSortedIndexArray()
before
the instance will be used.index
- the array of index values.generation
- the array of generation values.usage
- the array of usage values.trailerDictionary
- the trailer dictionary.protected int writePdf(PdfWriter w, long startxref) throws java.io.IOException
w
- the PdfWriter
to write to.startxref
- the byte offset within the output file
where the cross-reference table begins.java.io.IOException
protected void xrefGenerateFreeList()