Class CosArray
java.lang.Object
com.adobe.internal.pdftoolkit.core.cos.CosObject
com.adobe.internal.pdftoolkit.core.cos.CosContainer
com.adobe.internal.pdftoolkit.core.cos.CosArray
Represents a COS array as defined in section 3.2.5 of the PDF Reference
Manual version 1.4.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class com.adobe.internal.pdftoolkit.core.cos.CosObject
DIRECT, INDIRECT, t_Array, t_Boolean, t_Dictionary, t_KeyAbsent, t_Name, t_Null, t_Numeric, t_ObjectRef, t_Stream, t_String
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Inserts the specified element at the specified position in this list.boolean
Appends the specified CosObject to the end of this list.boolean
addBoolean
(boolean value) Creates an appropriate cos object and adds it to array.void
addBoolean
(int pos, boolean value) Creates an appropriate cos object and adds it to array at specified position.boolean
addDouble
(double value) Creates an appropriate cos object and adds it to array.void
addDouble
(int pos, double value) Creates an appropriate cos object and adds it to array at specified position.boolean
addInt
(int value) Creates an appropriate cos object and adds it to array.void
addInt
(int pos, int value) Creates an appropriate cos object and adds it to array at specified position.void
addLong
(int pos, long value) Creates an appropriate cos object and adds it to array at specified position.boolean
addLong
(long value) Creates an appropriate cos object and adds it to array.void
Creates an appropriate cos object and adds it to array at specified position.boolean
Creates an appropriate cos object and adds it to array.void
Creates an appropriate cos object and adds it to array at specified position.boolean
Creates an appropriate cos object and adds it to array.void
Creates an appropriate cos object and adds it to array at specified position.boolean
Creates an appropriate cos object and adds it to array.void
clear()
Removes all elements from the CosArray.boolean
Returns true if this array contains the object passed, else false.boolean
This method checks the inside data of CosArray and returns true if they are clone of each other.void
extendIfNecessaryAndSet
(int pos, CosObject cosObject) Adds the CosObject at the specified position in this list.int
Returns the index of name object with the same name as passed.int
findString
(ASString name) Looks for the CosString in the array.get
(int pos) Obtains the specified element from the array.byte[][]
getArrayBytes() presumes that the CosArray contains string values only and delivers an array of array of byte values.double[]
getArrayDouble() presumes that the CosArray contains numeric values only and delivers an array of double values.double[]
getArrayDouble
(int start, int length) getArrayDouble() presumes that the CosArray contains numeric values only and delivers an array of double values.int[]
getArrayInt() presumes that the CosArray contains numeric values only and delivers an array of integer values.long[]
getArrayInt() presumes that the CosArray contains numeric values only and delivers an array of integer values.ASName[]
getArrayName() presumes that the CosArray contains ASName values only and delivers an array of ASName values.boolean
getBoolean
(int pos) It assumes that the object at index "pos" is of typeCosBoolean
and returns it's value.getCosArray
(int pos) It assumes that the object at index "pos" is of typeCosArray
and returns it's value.getCosDictionary
(int pos) It assumes that the object at index "pos" is of typeCosDictionary
and returns it's value.getCosStream
(int pos) It assumes that the object at index "pos" is of typeCosStream
and returns it's value.getCosString
(int pos) It assumes that the object at index "pos" is of typeCosString
and returns it's value.double
getDouble
(int pos) It assumes that the object at index "pos" is of typeCosNumeric
and returns it's value.getHexString
(int pos) It assumes that the object at index "pos" is of typeCosString
and returns it's value.int
getInt
(int pos) It assumes that the object at index "pos" is of typeCosNumeric
and returns it's value.long
getLong
(int pos) It assumes that the object at index "pos" is of typeCosNumeric
and returns it's value.getName
(int pos) It assumes that the object at index "pos" is of typeCosName
and returns it's value.getStream
(int pos) This gets a slice of the underlyingInputByteStream
.getString
(int pos) It assumes that the object at index "pos" is of typeCosString
and returns it's value.getText
(int pos) It assumes that the object at index "pos" is of typeCosString
and returns it's value.int
getType()
return the type of this CosObjectint
getType
(int pos) Returns the type of the value at the given positiongetValue()
boolean
isEmpty()
Tests whether the array contains any elements.iterator()
Returns an iterator over the elements of the array.Returns a list iterator over the elements of the array.remove
(int index) Removes the element at the specified position in this list.boolean
Removes all instances of the specified object from the array.boolean
Adds the CosObject at the specified position in this list.boolean
setBoolean
(int pos, boolean value) Creates an appropriate cos object and sets it to array at specified position.boolean
setDouble
(int pos, double value) Creates an appropriate cos object and sets it to array at specified position.void
setEncryptionState
(boolean state) Set the specified encryption state for all strings and streams in an array recursivelyboolean
setInt
(int pos, int value) Creates an appropriate cos object and sets it to array at specified position.boolean
setLong
(int pos, long value) Creates an appropriate cos object and sets it to array at specified position.boolean
Creates an appropriate cos object and sets it to array at specified position.boolean
Creates an appropriate cos object and sets it to array at specified position.boolean
Creates an appropriate cos object and sets it to array at specified position.boolean
Creates an appropriate cos object and sets it to array at specified position.int
size()
Returns the number of elements in the array.splitBefore
(int pos) Returns a new array containing all the values before "pos" index in current array.Methods inherited from class com.adobe.internal.pdftoolkit.core.cos.CosContainer
findObjPos, markNotDirty
Methods inherited from class com.adobe.internal.pdftoolkit.core.cos.CosObject
booleanValue, doubleValue, equals, getDocument, getObjEOF, getObjGen, getObjNum, getObjPos, getObjRevision, getStreamManager, hexStringValue, intValue, isCompressed, isDirty, isIndirect, longValue, nameValue, numberValue, stringValue, textValue, toString
-
Method Details
-
getType
public int getType()return the type of this CosObject -
size
public int size()Returns the number of elements in the array.- Returns:
- Number of elements in the array.
-
isEmpty
public boolean isEmpty()Tests whether the array contains any elements.- Returns:
- true if the array does not contain elements; false otherwise.
-
iterator
Returns an iterator over the elements of the array.- Returns:
- Iterator
-
listIterator
Returns a list iterator over the elements of the array.- Returns:
- ListIterator
-
getValuesIterator
- Specified by:
getValuesIterator
in classCosContainer
-
getValue
public ArrayList<Object> getValue() throws PDFCosParseException, PDFIOException, PDFSecurityException- Specified by:
getValue
in classCosObject
- Returns:
- Object value of CosObject
- Throws:
PDFCosParseException
PDFIOException
PDFSecurityException
-
contains
Returns true if this array contains the object passed, else false. -
findName
Returns the index of name object with the same name as passed. If not found, then returns -1. -
findString
public int findString(ASString name) throws PDFCosParseException, PDFIOException, PDFSecurityException Looks for the CosString in the array. -
get
Obtains the specified element from the array. An indirect object reference is resolved to its referenced object before being returned.- Parameters:
pos
- Zero-based index of the desired array element- Returns:
- Object at the specified array position.
- Throws:
PDFCosParseException
PDFIOException
PDFSecurityException
-
getType
public int getType(int pos) Returns the type of the value at the given position- Parameters:
pos
-
-
getName
It assumes that the object at index "pos" is of typeCosName
and returns it's value. -
getBoolean
public boolean getBoolean(int pos) throws PDFCosParseException, PDFIOException, PDFSecurityException It assumes that the object at index "pos" is of typeCosBoolean
and returns it's value. -
getDouble
It assumes that the object at index "pos" is of typeCosNumeric
and returns it's value. -
getArrayDouble
getArrayDouble() presumes that the CosArray contains numeric values only and delivers an array of double values. -
getArrayDouble
public double[] getArrayDouble(int start, int length) throws PDFCosParseException, PDFIOException, PDFSecurityException getArrayDouble() presumes that the CosArray contains numeric values only and delivers an array of double values.- Parameters:
start
- the index to start conversion fromlength
- the number of indices to convert- Throws:
PDFCosParseException
PDFIOException
PDFSecurityException
-
getLong
It assumes that the object at index "pos" is of typeCosNumeric
and returns it's value. -
getInt
It assumes that the object at index "pos" is of typeCosNumeric
and returns it's value. -
getArrayLong
getArrayInt() presumes that the CosArray contains numeric values only and delivers an array of integer values. -
getArrayInt
getArrayInt() presumes that the CosArray contains numeric values only and delivers an array of integer values. -
getArrayBytes
getArrayBytes() presumes that the CosArray contains string values only and delivers an array of array of byte values. -
getString
public ASString getString(int pos) throws PDFCosParseException, PDFIOException, PDFSecurityException It assumes that the object at index "pos" is of typeCosString
and returns it's value. -
getHexString
public ASHexString getHexString(int pos) throws PDFCosParseException, PDFIOException, PDFSecurityException It assumes that the object at index "pos" is of typeCosString
and returns it's value. -
getText
It assumes that the object at index "pos" is of typeCosString
and returns it's value. -
getCosString
public CosString getCosString(int pos) throws PDFCosParseException, PDFIOException, PDFSecurityException It assumes that the object at index "pos" is of typeCosString
and returns it's value. -
getCosArray
public CosArray getCosArray(int pos) throws PDFCosParseException, PDFIOException, PDFSecurityException It assumes that the object at index "pos" is of typeCosArray
and returns it's value. -
getCosDictionary
public CosDictionary getCosDictionary(int pos) throws PDFCosParseException, PDFIOException, PDFSecurityException It assumes that the object at index "pos" is of typeCosDictionary
and returns it's value. -
getCosStream
public CosStream getCosStream(int pos) throws PDFCosParseException, PDFIOException, PDFSecurityException It assumes that the object at index "pos" is of typeCosStream
and returns it's value. -
getStream
public InputByteStream getStream(int pos) throws PDFCosParseException, PDFIOException, PDFSecurityException This gets a slice of the underlyingInputByteStream
. It is the repsonsibility of the caller to close theInputByteStream
when they are finished with it. -
clear
Removes all elements from the CosArray. -
remove
public CosObject remove(int index) throws PDFCosParseException, PDFIOException, PDFSecurityException Removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts one from their indices).- Parameters:
index
- the index of the element to removed.- Returns:
- the element that was removed from the list.
- Throws:
PDFCosParseException
PDFIOException
PDFSecurityException
IndexOutOfBoundsException
- if index out of range
-
remove
public boolean remove(CosObject cosObject) throws PDFCosParseException, PDFIOException, PDFSecurityException Removes all instances of the specified object from the array.- Parameters:
cosObject
- Object to be removed from the array- Returns:
- true if object successfully removed.
- Throws:
PDFCosParseException
PDFIOException
PDFSecurityException
-
add
public boolean add(CosObject cosObject) throws PDFCosParseException, PDFIOException, PDFSecurityException Appends the specified CosObject to the end of this list. If the object is indirect, it adds the object reference. The CosArray is marked dirty after the operation.- Parameters:
cosObject
- to be added to the list- Returns:
- true (as per the general contract of Collection.add).
- Throws:
PDFIOException
PDFCosParseException
PDFSecurityException
-
addName
public boolean addName(ASName value) throws PDFCosParseException, PDFIOException, PDFSecurityException Creates an appropriate cos object and adds it to array. -
addBoolean
public boolean addBoolean(boolean value) throws PDFCosParseException, PDFIOException, PDFSecurityException Creates an appropriate cos object and adds it to array. -
addDouble
public boolean addDouble(double value) throws PDFCosParseException, PDFIOException, PDFSecurityException Creates an appropriate cos object and adds it to array. -
addLong
public boolean addLong(long value) throws PDFCosParseException, PDFIOException, PDFSecurityException Creates an appropriate cos object and adds it to array. -
addInt
Creates an appropriate cos object and adds it to array. -
addText
public boolean addText(String value) throws PDFCosParseException, PDFIOException, PDFSecurityException Creates an appropriate cos object and adds it to array. -
addString
public boolean addString(ASString value) throws PDFCosParseException, PDFIOException, PDFSecurityException Creates an appropriate cos object and adds it to array. -
add
public void add(int pos, CosObject cosObject) throws PDFCosParseException, PDFIOException, PDFSecurityException Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).- Parameters:
pos
- index at which the specified element is to be inserted.cosObject
- element to be inserted.- Throws:
PDFCosParseException
PDFIOException
PDFSecurityException
IndexOutOfBoundsException
- if index is out of range
-
addName
public void addName(int pos, ASName value) throws PDFCosParseException, PDFIOException, PDFSecurityException Creates an appropriate cos object and adds it to array at specified position. -
addBoolean
public void addBoolean(int pos, boolean value) throws PDFCosParseException, PDFIOException, PDFSecurityException Creates an appropriate cos object and adds it to array at specified position. -
addDouble
public void addDouble(int pos, double value) throws PDFCosParseException, PDFIOException, PDFSecurityException Creates an appropriate cos object and adds it to array at specified position. -
addLong
public void addLong(int pos, long value) throws PDFCosParseException, PDFIOException, PDFSecurityException Creates an appropriate cos object and adds it to array at specified position. -
addInt
public void addInt(int pos, int value) throws PDFCosParseException, PDFIOException, PDFSecurityException Creates an appropriate cos object and adds it to array at specified position. -
addText
public void addText(int pos, String value) throws PDFCosParseException, PDFIOException, PDFSecurityException Creates an appropriate cos object and adds it to array at specified position. -
addString
public void addString(int pos, ASString value) throws PDFCosParseException, PDFIOException, PDFSecurityException Creates an appropriate cos object and adds it to array at specified position. -
set
public boolean set(int pos, CosObject cosObject) throws PDFCosParseException, PDFIOException, PDFSecurityException Adds the CosObject at the specified position in this list.- Parameters:
pos
- index of element being added.cosObject
- element to be added at the specified position.- Returns:
- true
- Throws:
PDFCosParseException
PDFIOException
PDFSecurityException
IndexOutOfBoundsException
- if index out of range
-
extendIfNecessaryAndSet
public void extendIfNecessaryAndSet(int pos, CosObject cosObject) throws PDFCosParseException, PDFIOException, PDFSecurityException Adds the CosObject at the specified position in this list. If the list is too short, it is first extended with 'null'.- Parameters:
pos
- index of element being added.cosObject
- element to be added at the specified position.- Throws:
PDFCosParseException
PDFIOException
PDFSecurityException
-
setName
public boolean setName(int pos, ASName value) throws PDFCosParseException, PDFIOException, PDFSecurityException Creates an appropriate cos object and sets it to array at specified position. -
setName
public boolean setName(int pos, String value) throws PDFCosParseException, PDFIOException, PDFSecurityException Creates an appropriate cos object and sets it to array at specified position. -
setBoolean
public boolean setBoolean(int pos, boolean value) throws PDFCosParseException, PDFIOException, PDFSecurityException Creates an appropriate cos object and sets it to array at specified position. -
setDouble
public boolean setDouble(int pos, double value) throws PDFCosParseException, PDFIOException, PDFSecurityException Creates an appropriate cos object and sets it to array at specified position. -
setInt
public boolean setInt(int pos, int value) throws PDFCosParseException, PDFIOException, PDFSecurityException Creates an appropriate cos object and sets it to array at specified position. -
setLong
public boolean setLong(int pos, long value) throws PDFCosParseException, PDFIOException, PDFSecurityException Creates an appropriate cos object and sets it to array at specified position. -
setString
public boolean setString(int pos, ASString value) throws PDFCosParseException, PDFIOException, PDFSecurityException Creates an appropriate cos object and sets it to array at specified position. -
setText
public boolean setText(int pos, String value) throws PDFCosParseException, PDFIOException, PDFSecurityException Creates an appropriate cos object and sets it to array at specified position. -
equals
This method checks the inside data of CosArray and returns true if they are clone of each other. Returns false if passed CosObject is not an instance of CosArray. This maintains a continuously growing list of indirect CosObject pairs, which have already been compared, to get rid of infinite recursion. This method can take some time if called on large Cos Objects. -
setEncryptionState
public void setEncryptionState(boolean state) throws PDFCosParseException, PDFIOException, PDFSecurityException Set the specified encryption state for all strings and streams in an array recursively -
splitBefore
public CosArray splitBefore(int pos) throws PDFCosParseException, PDFIOException, PDFSecurityException Returns a new array containing all the values before "pos" index in current array. -
getArrayName
getArrayName() presumes that the CosArray contains ASName values only and delivers an array of ASName values.
-