public class PdfArray extends PdfObject
PdfArray
is the PDF Array object.
An array is a sequence of PDF objects. An array may contain a mixture of
object types. An array is written as a left square bracket ([), followed by a
sequence of objects, followed by a right square bracket (]).
This object is described in the 'Portable Document Format Reference Manual
version 1.7' section 3.2.5 (page 58).
PdfObject
Modifier and Type | Field and Description |
---|---|
protected List<PdfObject> |
arrayList
this is the actual array of PdfObjects
|
Constructor and Description |
---|
PdfArray()
Constructs an empty
PdfArray -object. |
PdfArray(float[] values)
Constructs a
PdfArray -object, containing all
float values in a specified array. |
PdfArray(int[] values)
Constructs a
PdfArray -object, containing all
int values in a specified array. |
PdfArray(List<PdfObject> pdfObjectList)
Constructs a
PdfArray , containing all elements of a
specified List . |
PdfArray(PdfArray array)
Constructs an
PdfArray -object, containing all
PdfObject s in a specified PdfArray . |
PdfArray(PdfObject object)
Constructs an
PdfArray -object, containing 1
PdfObject . |
Modifier and Type | Method and Description |
---|---|
boolean |
add(float[] values)
Adds an array of
float values to end of the
PdfArray . |
boolean |
add(int[] values)
Adds an array of
int values to end of the
PdfArray . |
void |
add(int index,
PdfObject element)
Inserts the specified element at the specified position.
|
boolean |
add(PdfObject object)
Adds a
PdfObject to the end of the PdfArray . |
void |
addFirst(PdfObject object)
Inserts a
PdfObject at the beginning of the
PdfArray . |
boolean |
contains(PdfObject object)
Checks if the
PdfArray already contains a certain
PdfObject . |
List<PdfObject> |
getArrayList()
Deprecated.
Please use getElements() instead.
|
PdfArray |
getAsArray(int idx)
Returns a
PdfObject as a PdfArray , resolving
indirect references. |
PdfBoolean |
getAsBoolean(int idx)
Returns a
PdfObject as a PdfBoolean , resolving
indirect references. |
PdfDictionary |
getAsDict(int idx)
Returns a
PdfObject as a PdfDictionary ,
resolving indirect references. |
PdfIndirectReference |
getAsIndirectObject(int idx)
Returns a
PdfObject as a PdfIndirectReference . |
PdfName |
getAsName(int idx)
Returns a
PdfObject as a PdfName , resolving
indirect references. |
PdfNumber |
getAsNumber(int idx)
Returns a
PdfObject as a PdfNumber , resolving
indirect references. |
PdfStream |
getAsStream(int idx)
Returns a
PdfObject as a PdfStream , resolving
indirect references. |
PdfString |
getAsString(int idx)
Returns a
PdfObject as a PdfString , resolving
indirect references. |
PdfObject |
getDirectObject(int idx)
Returns the
PdfObject with the specified index, resolving a
possible indirect reference to a direct object. |
List<PdfObject> |
getElements()
Get a copy the internal list for this PdfArray.
|
PdfObject |
getPdfObject(int idx)
Returns the
PdfObject with the specified index. |
boolean |
isEmpty()
Returns
true if the array is empty. |
ListIterator<PdfObject> |
listIterator()
Returns the list iterator for the array.
|
PdfObject |
remove(int idx)
Remove the element at the specified position from the array.
|
PdfObject |
set(int idx,
PdfObject obj)
Overwrites a specified location of the array, returning the previous
value
|
int |
size()
Returns the number of entries in the array.
|
void |
toPdf(PdfWriter writer,
OutputStream os)
Writes the PDF representation of this
PdfArray as an array
of byte to the specified OutputStream . |
String |
toString()
Returns a string representation of this
PdfArray . |
canBeInObjStm, getBytes, getIndRef, isArray, isBoolean, isDictionary, isIndirect, isName, isNull, isNumber, isStream, isString, length, setContent, setIndRef, type
public PdfArray()
PdfArray
-object.public PdfArray(PdfObject object)
PdfArray
-object, containing 1
PdfObject
.object
- a PdfObject
that has to be added to the arraypublic PdfArray(float[] values)
PdfArray
-object, containing all
float
values in a specified array.
The float
values are internally converted to
PdfNumber
objects.values
- an array of float
values to be addedpublic PdfArray(int[] values)
PdfArray
-object, containing all
int
values in a specified array.
The int
values are internally converted to
PdfNumber
objects.values
- an array of int
values to be addedpublic PdfArray(List<PdfObject> pdfObjectList)
PdfArray
, containing all elements of a
specified List
.pdfObjectList
- an List
with PdfObject
s to be
added to the arraypublic PdfArray(PdfArray array)
PdfArray
-object, containing all
PdfObject
s in a specified PdfArray
.array
- a PdfArray
to be added to the arraypublic void toPdf(PdfWriter writer, OutputStream os) throws IOException
PdfArray
as an array
of byte
to the specified OutputStream
.toPdf
in class PdfObject
writer
- for backwards compatibilityos
- the OutputStream
to write the bytes to.IOException
public String toString()
PdfArray
.
The string representation consists of a list of all
PdfObject
s contained in this PdfArray
, enclosed
in square brackets ("[]"). Adjacent elements are separated by the
characters ", " (comma and space).public PdfObject set(int idx, PdfObject obj)
idx
- The index of the element to be overwrittenobj
- new value for the specified indexIndexOutOfBoundsException
- if the specified position doesn't existpublic PdfObject remove(int idx)
idx
- The index of the element to be removed.IndexOutOfBoundsException
- the specified position doesn't exist@Deprecated public List<PdfObject> getArrayList()
public List<PdfObject> getElements()
public int size()
public boolean isEmpty()
true
if the array is empty.true
if the array is emptypublic boolean add(PdfObject object)
PdfObject
to the end of the PdfArray
.
The PdfObject
will be the last element.object
- PdfObject
to addtrue
public boolean add(float[] values)
float
values to end of the
PdfArray
.
The values will be the last elements. The float
values are
internally converted to PdfNumber
objects.values
- An array of float
values to addtrue
public boolean add(int[] values)
int
values to end of the
PdfArray
.
The values will be the last elements. The int
values are
internally converted to PdfNumber
objects.values
- An array of int
values to addtrue
public void add(int index, PdfObject element)
index
- The index at which the specified element is to be insertedelement
- The element to be insertedIndexOutOfBoundsException
- if the specified index is larger than the last position
currently set, plus 1.public void addFirst(PdfObject object)
PdfObject
at the beginning of the
PdfArray
.
The PdfObject
will be the first element, any other elements
will be shifted to the right (adds one to their indices).object
- The PdfObject
to addpublic boolean contains(PdfObject object)
PdfArray
already contains a certain
PdfObject
.object
- The PdfObject
to checktrue
public ListIterator<PdfObject> listIterator()
public PdfObject getPdfObject(int idx)
PdfObject
with the specified index.
A possible indirect references is not resolved, so the returned
PdfObject
may be either a direct object or an indirect
reference, depending on how the object is stored in the
PdfArray
.idx
- The index of the PdfObject
to be returnedPdfObject
public PdfObject getDirectObject(int idx)
PdfObject
with the specified index, resolving a
possible indirect reference to a direct object.
Thus this method will never return a PdfIndirectReference
object.idx
- The index of the PdfObject
to be returnedPdfObject
or null
public PdfDictionary getAsDict(int idx)
PdfObject
as a PdfDictionary
,
resolving indirect references.
The object corresponding to the specified index is retrieved and
resolvedto a direct object. If it is a PdfDictionary
, it is
cast down and returned as such. Otherwise null
is returned.idx
- The index of the PdfObject
to be returnedPdfDictionary
object, or
null
public PdfArray getAsArray(int idx)
PdfObject
as a PdfArray
, resolving
indirect references.
The object corresponding to the specified index is retrieved and resolved
to a direct object. If it is a PdfArray
, it is cast down and
returned as such. Otherwise null
is returned.idx
- The index of the PdfObject
to be returnedPdfArray
object, or
null
public PdfStream getAsStream(int idx)
PdfObject
as a PdfStream
, resolving
indirect references.
The object corresponding to the specified index is retrieved and resolved
to a direct object. If it is a PdfStream
, it is cast down
and returned as such. Otherwise null
is returned.idx
- The index of the PdfObject
to be returnedPdfStream
object, or
null
public PdfString getAsString(int idx)
PdfObject
as a PdfString
, resolving
indirect references.
The object corresponding to the specified index is retrieved and resolved
to a direct object. If it is a PdfString
, it is cast down
and returned as such. Otherwise null
is returned.idx
- The index of the PdfObject
to be returnedPdfString
object, or
null
public PdfNumber getAsNumber(int idx)
PdfObject
as a PdfNumber
, resolving
indirect references.
The object corresponding to the specified index is retrieved and resolved
to a direct object. If it is a PdfNumber
, it is cast down
and returned as such. Otherwise null
is returned.idx
- The index of the PdfObject
to be returnedPdfNumber
object, or
null
public PdfName getAsName(int idx)
PdfObject
as a PdfName
, resolving
indirect references.
The object corresponding to the specified index is retrieved and resolved
to a direct object. If it is a PdfName
, it is cast down and
returned as such. Otherwise null
is returned.idx
- The index of the PdfObject
to be returnedPdfName
object, or
null
public PdfBoolean getAsBoolean(int idx)
PdfObject
as a PdfBoolean
, resolving
indirect references.
The object corresponding to the specified index is retrieved and resolved
to a direct object. If it is a PdfBoolean
, it is cast down
and returned as such. Otherwise null
is returned.idx
- The index of the PdfObject
to be returnedPdfBoolean
object, or
null
public PdfIndirectReference getAsIndirectObject(int idx)
PdfObject
as a PdfIndirectReference
.
The object corresponding to the specified index is retrieved. If it is a
PdfIndirectReference
, it is cast down and returned as such.
Otherwise null
is returned.idx
- The index of the PdfObject
to be returnedPdfIndirectReference
object, or
null
Copyright © 2018. All rights reserved.