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
-
public class CosArray extends CosContainer
Represents a COS array as defined in section 3.2.5 of the PDF Reference Manual version 1.4.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
CosArray.CosArrayListIterator
-
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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int pos, CosObject cosObject)
Inserts the specified element at the specified position in this list.boolean
add(CosObject cosObject)
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
addName(int pos, ASName value)
Creates an appropriate cos object and adds it to array at specified position.boolean
addName(ASName value)
Creates an appropriate cos object and adds it to array.void
addString(int pos, ASString value)
Creates an appropriate cos object and adds it to array at specified position.boolean
addString(ASString value)
Creates an appropriate cos object and adds it to array.void
addText(int pos, java.lang.String value)
Creates an appropriate cos object and adds it to array at specified position.boolean
addText(java.lang.String value)
Creates an appropriate cos object and adds it to array.void
clear()
Removes all elements from the CosArray.boolean
contains(CosObject obj)
Returns true if this array contains the object passed, else false.boolean
equals(CosObject value)
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
findName(ASName name)
Returns the index of name object with the same name as passed.int
findString(ASString name)
Looks for the CosString in the array.CosObject
get(int pos)
Obtains the specified element from the array.byte[][]
getArrayBytes()
getArrayBytes() presumes that the CosArray contains string values only and delivers an array of array of byte values.double[]
getArrayDouble()
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()
getArrayInt() presumes that the CosArray contains numeric values only and delivers an array of integer values.long[]
getArrayLong()
getArrayInt() presumes that the CosArray contains numeric values only and delivers an array of integer values.ASName[]
getArrayName()
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.CosArray
getCosArray(int pos)
It assumes that the object at index "pos" is of typeCosArray
and returns it's value.CosDictionary
getCosDictionary(int pos)
It assumes that the object at index "pos" is of typeCosDictionary
and returns it's value.CosStream
getCosStream(int pos)
It assumes that the object at index "pos" is of typeCosStream
and returns it's value.CosString
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.ASHexString
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.ASName
getName(int pos)
It assumes that the object at index "pos" is of typeCosName
and returns it's value.InputByteStream
getStream(int pos)
This gets a slice of the underlyingInputByteStream
.ASString
getString(int pos)
It assumes that the object at index "pos" is of typeCosString
and returns it's value.java.lang.String
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 positionjava.util.ArrayList<java.lang.Object>
getValue()
CosContainerValuesIterator
getValuesIterator()
boolean
isEmpty()
Tests whether the array contains any elements.java.util.Iterator<CosObject>
iterator()
Returns an iterator over the elements of the array.java.util.ListIterator<CosObject>
listIterator()
Returns a list iterator over the elements of the array.CosObject
remove(int index)
Removes the element at the specified position in this list.boolean
remove(CosObject cosObject)
Removes all instances of the specified object from the array.boolean
set(int pos, CosObject cosObject)
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
setName(int pos, ASName value)
Creates an appropriate cos object and sets it to array at specified position.boolean
setName(int pos, java.lang.String value)
Creates an appropriate cos object and sets it to array at specified position.boolean
setString(int pos, ASString value)
Creates an appropriate cos object and sets it to array at specified position.boolean
setText(int pos, java.lang.String value)
Creates an appropriate cos object and sets it to array at specified position.int
size()
Returns the number of elements in the array.CosArray
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 Detail
-
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
public java.util.Iterator<CosObject> iterator()
Returns an iterator over the elements of the array.- Returns:
- Iterator
-
listIterator
public java.util.ListIterator<CosObject> listIterator()
Returns a list iterator over the elements of the array.- Returns:
- ListIterator
-
getValuesIterator
public CosContainerValuesIterator getValuesIterator()
- Specified by:
getValuesIterator
in classCosContainer
-
getValue
public java.util.ArrayList<java.lang.Object> getValue() throws PDFCosParseException, PDFIOException, PDFSecurityException
- Specified by:
getValue
in classCosObject
- Returns:
- Object value of CosObject
- Throws:
PDFCosParseException
PDFIOException
PDFSecurityException
-
contains
public boolean contains(CosObject obj)
Returns true if this array contains the object passed, else false.
-
findName
public int findName(ASName name) throws PDFCosParseException, PDFIOException, PDFSecurityException
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
public CosObject get(int pos) throws PDFCosParseException, PDFIOException, PDFSecurityException
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
public ASName getName(int pos) throws PDFCosParseException, PDFIOException, PDFSecurityException
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
public double getDouble(int pos) throws PDFCosParseException, PDFIOException, PDFSecurityException
It assumes that the object at index "pos" is of typeCosNumeric
and returns it's value.
-
getArrayDouble
public double[] getArrayDouble() throws PDFCosParseException, PDFIOException, PDFSecurityException
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
public long getLong(int pos) throws PDFCosParseException, PDFIOException, PDFSecurityException
It assumes that the object at index "pos" is of typeCosNumeric
and returns it's value.
-
getInt
public int getInt(int pos) throws PDFCosParseException, PDFIOException, PDFSecurityException
It assumes that the object at index "pos" is of typeCosNumeric
and returns it's value.
-
getArrayLong
public long[] getArrayLong() throws PDFCosParseException, PDFIOException, PDFSecurityException
getArrayInt() presumes that the CosArray contains numeric values only and delivers an array of integer values.
-
getArrayInt
public int[] getArrayInt() throws PDFCosParseException, PDFIOException, PDFSecurityException
getArrayInt() presumes that the CosArray contains numeric values only and delivers an array of integer values.
-
getArrayBytes
public byte[][] getArrayBytes() throws PDFCosParseException, PDFIOException, PDFSecurityException
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
public java.lang.String getText(int pos) throws PDFCosParseException, PDFIOException, PDFSecurityException
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
public void clear() throws PDFCosParseException, PDFIOException, PDFSecurityException
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
java.lang.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
public boolean addInt(int value) throws PDFCosParseException, PDFIOException, PDFSecurityException
Creates an appropriate cos object and adds it to array.
-
addText
public boolean addText(java.lang.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
java.lang.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, java.lang.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
java.lang.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, java.lang.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, java.lang.String value) throws PDFCosParseException, PDFIOException, PDFSecurityException
Creates an appropriate cos object and sets it to array at specified position.
-
equals
public boolean equals(CosObject value)
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
public ASName[] getArrayName() throws PDFCosParseException, PDFIOException, PDFSecurityException
getArrayName() presumes that the CosArray contains ASName values only and delivers an array of ASName values.
-
-