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 classCosArray.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 voidadd(int pos, CosObject cosObject)Inserts the specified element at the specified position in this list.booleanadd(CosObject cosObject)Appends the specified CosObject to the end of this list.booleanaddBoolean(boolean value)Creates an appropriate cos object and adds it to array.voidaddBoolean(int pos, boolean value)Creates an appropriate cos object and adds it to array at specified position.booleanaddDouble(double value)Creates an appropriate cos object and adds it to array.voidaddDouble(int pos, double value)Creates an appropriate cos object and adds it to array at specified position.booleanaddInt(int value)Creates an appropriate cos object and adds it to array.voidaddInt(int pos, int value)Creates an appropriate cos object and adds it to array at specified position.voidaddLong(int pos, long value)Creates an appropriate cos object and adds it to array at specified position.booleanaddLong(long value)Creates an appropriate cos object and adds it to array.voidaddName(int pos, ASName value)Creates an appropriate cos object and adds it to array at specified position.booleanaddName(ASName value)Creates an appropriate cos object and adds it to array.voidaddString(int pos, ASString value)Creates an appropriate cos object and adds it to array at specified position.booleanaddString(ASString value)Creates an appropriate cos object and adds it to array.voidaddText(int pos, java.lang.String value)Creates an appropriate cos object and adds it to array at specified position.booleanaddText(java.lang.String value)Creates an appropriate cos object and adds it to array.voidclear()Removes all elements from the CosArray.booleancontains(CosObject obj)Returns true if this array contains the object passed, else false.booleanequals(CosObject value)This method checks the inside data of CosArray and returns true if they are clone of each other.voidextendIfNecessaryAndSet(int pos, CosObject cosObject)Adds the CosObject at the specified position in this list.intfindName(ASName name)Returns the index of name object with the same name as passed.intfindString(ASString name)Looks for the CosString in the array.CosObjectget(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.booleangetBoolean(int pos)It assumes that the object at index "pos" is of typeCosBooleanand returns it's value.CosArraygetCosArray(int pos)It assumes that the object at index "pos" is of typeCosArrayand returns it's value.CosDictionarygetCosDictionary(int pos)It assumes that the object at index "pos" is of typeCosDictionaryand returns it's value.CosStreamgetCosStream(int pos)It assumes that the object at index "pos" is of typeCosStreamand returns it's value.CosStringgetCosString(int pos)It assumes that the object at index "pos" is of typeCosStringand returns it's value.doublegetDouble(int pos)It assumes that the object at index "pos" is of typeCosNumericand returns it's value.ASHexStringgetHexString(int pos)It assumes that the object at index "pos" is of typeCosStringand returns it's value.intgetInt(int pos)It assumes that the object at index "pos" is of typeCosNumericand returns it's value.longgetLong(int pos)It assumes that the object at index "pos" is of typeCosNumericand returns it's value.ASNamegetName(int pos)It assumes that the object at index "pos" is of typeCosNameand returns it's value.InputByteStreamgetStream(int pos)This gets a slice of the underlyingInputByteStream.ASStringgetString(int pos)It assumes that the object at index "pos" is of typeCosStringand returns it's value.java.lang.StringgetText(int pos)It assumes that the object at index "pos" is of typeCosStringand returns it's value.intgetType()return the type of this CosObjectintgetType(int pos)Returns the type of the value at the given positionjava.util.ArrayList<java.lang.Object>getValue()CosContainerValuesIteratorgetValuesIterator()booleanisEmpty()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.CosObjectremove(int index)Removes the element at the specified position in this list.booleanremove(CosObject cosObject)Removes all instances of the specified object from the array.booleanset(int pos, CosObject cosObject)Adds the CosObject at the specified position in this list.booleansetBoolean(int pos, boolean value)Creates an appropriate cos object and sets it to array at specified position.booleansetDouble(int pos, double value)Creates an appropriate cos object and sets it to array at specified position.voidsetEncryptionState(boolean state)Set the specified encryption state for all strings and streams in an array recursivelybooleansetInt(int pos, int value)Creates an appropriate cos object and sets it to array at specified position.booleansetLong(int pos, long value)Creates an appropriate cos object and sets it to array at specified position.booleansetName(int pos, ASName value)Creates an appropriate cos object and sets it to array at specified position.booleansetName(int pos, java.lang.String value)Creates an appropriate cos object and sets it to array at specified position.booleansetString(int pos, ASString value)Creates an appropriate cos object and sets it to array at specified position.booleansetText(int pos, java.lang.String value)Creates an appropriate cos object and sets it to array at specified position.intsize()Returns the number of elements in the array.CosArraysplitBefore(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:
getValuesIteratorin classCosContainer
-
getValue
public java.util.ArrayList<java.lang.Object> getValue() throws PDFCosParseException, PDFIOException, PDFSecurityException- Specified by:
getValuein classCosObject- Returns:
- Object value of CosObject
- Throws:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
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:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
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 typeCosNameand returns it's value.
-
getBoolean
public boolean getBoolean(int pos) throws PDFCosParseException, PDFIOException, PDFSecurityExceptionIt assumes that the object at index "pos" is of typeCosBooleanand returns it's value.
-
getDouble
public double getDouble(int pos) throws PDFCosParseException, PDFIOException, PDFSecurityExceptionIt assumes that the object at index "pos" is of typeCosNumericand returns it's value.
-
getArrayDouble
public double[] getArrayDouble() throws PDFCosParseException, PDFIOException, PDFSecurityExceptiongetArrayDouble() 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, PDFSecurityExceptiongetArrayDouble() 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:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
getLong
public long getLong(int pos) throws PDFCosParseException, PDFIOException, PDFSecurityExceptionIt assumes that the object at index "pos" is of typeCosNumericand returns it's value.
-
getInt
public int getInt(int pos) throws PDFCosParseException, PDFIOException, PDFSecurityExceptionIt assumes that the object at index "pos" is of typeCosNumericand returns it's value.
-
getArrayLong
public long[] getArrayLong() throws PDFCosParseException, PDFIOException, PDFSecurityExceptiongetArrayInt() presumes that the CosArray contains numeric values only and delivers an array of integer values.
-
getArrayInt
public int[] getArrayInt() throws PDFCosParseException, PDFIOException, PDFSecurityExceptiongetArrayInt() presumes that the CosArray contains numeric values only and delivers an array of integer values.
-
getArrayBytes
public byte[][] getArrayBytes() throws PDFCosParseException, PDFIOException, PDFSecurityExceptiongetArrayBytes() 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 typeCosStringand returns it's value.
-
getHexString
public ASHexString getHexString(int pos) throws PDFCosParseException, PDFIOException, PDFSecurityException
It assumes that the object at index "pos" is of typeCosStringand returns it's value.
-
getText
public java.lang.String getText(int pos) throws PDFCosParseException, PDFIOException, PDFSecurityExceptionIt assumes that the object at index "pos" is of typeCosStringand returns it's value.
-
getCosString
public CosString getCosString(int pos) throws PDFCosParseException, PDFIOException, PDFSecurityException
It assumes that the object at index "pos" is of typeCosStringand returns it's value.
-
getCosArray
public CosArray getCosArray(int pos) throws PDFCosParseException, PDFIOException, PDFSecurityException
It assumes that the object at index "pos" is of typeCosArrayand returns it's value.
-
getCosDictionary
public CosDictionary getCosDictionary(int pos) throws PDFCosParseException, PDFIOException, PDFSecurityException
It assumes that the object at index "pos" is of typeCosDictionaryand returns it's value.
-
getCosStream
public CosStream getCosStream(int pos) throws PDFCosParseException, PDFIOException, PDFSecurityException
It assumes that the object at index "pos" is of typeCosStreamand 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 theInputByteStreamwhen they are finished with it.
-
clear
public void clear() throws PDFCosParseException, PDFIOException, PDFSecurityExceptionRemoves 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:
PDFCosParseExceptionPDFIOExceptionPDFSecurityExceptionjava.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:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
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:
PDFIOExceptionPDFCosParseExceptionPDFSecurityException
-
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, PDFSecurityExceptionCreates an appropriate cos object and adds it to array.
-
addDouble
public boolean addDouble(double value) throws PDFCosParseException, PDFIOException, PDFSecurityExceptionCreates an appropriate cos object and adds it to array.
-
addLong
public boolean addLong(long value) throws PDFCosParseException, PDFIOException, PDFSecurityExceptionCreates an appropriate cos object and adds it to array.
-
addInt
public boolean addInt(int value) throws PDFCosParseException, PDFIOException, PDFSecurityExceptionCreates an appropriate cos object and adds it to array.
-
addText
public boolean addText(java.lang.String value) throws PDFCosParseException, PDFIOException, PDFSecurityExceptionCreates 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, PDFSecurityExceptionInserts 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:
PDFCosParseExceptionPDFIOExceptionPDFSecurityExceptionjava.lang.IndexOutOfBoundsException- if index is out of range
-
addName
public void addName(int pos, ASName value) throws PDFCosParseException, PDFIOException, PDFSecurityExceptionCreates an appropriate cos object and adds it to array at specified position.
-
addBoolean
public void addBoolean(int pos, boolean value) throws PDFCosParseException, PDFIOException, PDFSecurityExceptionCreates an appropriate cos object and adds it to array at specified position.
-
addDouble
public void addDouble(int pos, double value) throws PDFCosParseException, PDFIOException, PDFSecurityExceptionCreates an appropriate cos object and adds it to array at specified position.
-
addLong
public void addLong(int pos, long value) throws PDFCosParseException, PDFIOException, PDFSecurityExceptionCreates an appropriate cos object and adds it to array at specified position.
-
addInt
public void addInt(int pos, int value) throws PDFCosParseException, PDFIOException, PDFSecurityExceptionCreates 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, PDFSecurityExceptionCreates an appropriate cos object and adds it to array at specified position.
-
addString
public void addString(int pos, ASString value) throws PDFCosParseException, PDFIOException, PDFSecurityExceptionCreates an appropriate cos object and adds it to array at specified position.
-
set
public boolean set(int pos, CosObject cosObject) throws PDFCosParseException, PDFIOException, PDFSecurityExceptionAdds 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:
PDFCosParseExceptionPDFIOExceptionPDFSecurityExceptionjava.lang.IndexOutOfBoundsException- if index out of range
-
extendIfNecessaryAndSet
public void extendIfNecessaryAndSet(int pos, CosObject cosObject) throws PDFCosParseException, PDFIOException, PDFSecurityExceptionAdds 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:
PDFCosParseExceptionPDFIOExceptionPDFSecurityException
-
setName
public boolean setName(int pos, ASName value) throws PDFCosParseException, PDFIOException, PDFSecurityExceptionCreates 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, PDFSecurityExceptionCreates an appropriate cos object and sets it to array at specified position.
-
setBoolean
public boolean setBoolean(int pos, boolean value) throws PDFCosParseException, PDFIOException, PDFSecurityExceptionCreates an appropriate cos object and sets it to array at specified position.
-
setDouble
public boolean setDouble(int pos, double value) throws PDFCosParseException, PDFIOException, PDFSecurityExceptionCreates an appropriate cos object and sets it to array at specified position.
-
setInt
public boolean setInt(int pos, int value) throws PDFCosParseException, PDFIOException, PDFSecurityExceptionCreates an appropriate cos object and sets it to array at specified position.
-
setLong
public boolean setLong(int pos, long value) throws PDFCosParseException, PDFIOException, PDFSecurityExceptionCreates an appropriate cos object and sets it to array at specified position.
-
setString
public boolean setString(int pos, ASString value) throws PDFCosParseException, PDFIOException, PDFSecurityExceptionCreates 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, PDFSecurityExceptionCreates 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, PDFSecurityExceptionSet 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.
-
-