java.lang.Object
org.sejda.sambox.cos.COSBase
org.sejda.sambox.cos.COSArray
- All Implemented Interfaces:
Iterable<COSBase>,Collection<COSBase>,List<COSBase>,COSObjectable
An array of PDFBase objects as part of the PDF document.
- Author:
- Ben Litchfield
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(COSVisitor visitor) Visitor pattern for the COS model objectsvoidvoidadd(int index, COSObjectable object) Add an object at the index location and push the rest to the right.booleanbooleanadd(COSObjectable object) Add an object to the arraybooleanaddAll(int i, Collection<? extends COSBase> objectList) booleanaddAll(Collection<? extends COSBase> objectsList) booleanThis will add all objects to this array.voidclear()booleanbooleancontainsAll(Collection<?> c) booleanget(int index) Get an object from the array.intgetInt(int index) Get the value of the array as an integer.intgetInt(int index, int defaultValue) Get the value of the array as an integer, return the default if it does not exist.getName(int index) Get the value of the array as a string.Get an entry in the array that is expected to be a COSName.getObject(int index) This will get an object from the array.<T extends COSBase>
TThis will get an object from the array.getString(int index) Get the value of the array as a string.Get an entry in the array that is expected to be a COSName.growToSize(int size) This will add null values until the size of the array is at least as large as the parameter.growToSize(int size, COSBase object) This will add the object until the size of the array is at least as large as the parameter.inthashCode()intintindexOfObject(COSBase object) This will return the index of the entry or -1 if it is not found.booleanisEmpty()iterator()intlistIterator(int index) remove(int i) booleanbooleanremoveAll(Collection<?> objectsList) Removes the last object of the arraybooleanThis will remove an element from the array.booleanretainAll(Collection<?> objectsList) voidset(int index, COSObjectable object) Set an object at a specific index.voidsetFloatArray(float[] value) Clear the current contents of the COSArray and set it with the float[].voidSet the value in the array as a string.intsize()subList(int fromIndex, int toIndex) Object[]toArray()<T> T[]toArray(T[] a) float[]This will take an COSArray of numbers and convert it to a float[].toList()toString()trimToSize(int size) trims the array to the given sizeMethods inherited from class org.sejda.sambox.cos.COSBase
getCOSObject, hasId, id, idIfAbsentMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
replaceAll, sort, spliterator
-
Constructor Details
-
COSArray
public COSArray() -
COSArray
-
-
Method Details
-
add
Add an object to the array- Parameters:
object- The object to add to the array.- See Also:
-
add
-
add
Add an object at the index location and push the rest to the right.- Parameters:
index- The index to add at.object- The object to add at that index.- See Also:
-
add
-
clear
public void clear() -
removeAll
-
retainAll
-
addAll
-
addAll
This will add all objects to this array.- Parameters:
objectList- The objects to add.
-
addAll
-
set
-
set
Set an object at a specific index.- Parameters:
index- zero based index into array.object- The object to set.
-
getObject
This will get an object from the array. This will dereference the object. If the object is COSNull then null will be returned.- Parameters:
index- The index into the array to get the object.- Returns:
- The object at the requested index.
-
getObject
This will get an object from the array. This will dereference the object. If the type is not compatible, null is returned- Parameters:
index-clazz-- Returns:
- The object that matches the key and the type or null.
-
get
Get an object from the array. This will NOT derefernce the COS object. -
getInt
public int getInt(int index) Get the value of the array as an integer.- Parameters:
index- The index into the list.- Returns:
- The value at that index or -1 if it is null.
-
getInt
public int getInt(int index, int defaultValue) Get the value of the array as an integer, return the default if it does not exist.- Parameters:
index- The value of the array.defaultValue- The value to return if the value is null.- Returns:
- The value at the index or the defaultValue.
-
getName
Get the value of the array as a string.- Parameters:
index- The index into the array.- Returns:
- The name converted to a string or null if it does not exist.
-
getName
Get an entry in the array that is expected to be a COSName.- Parameters:
index- The index into the array.defaultValue- The value to return if it is null.- Returns:
- The value at the index or defaultValue if none is found.
-
setString
Set the value in the array as a string.- Parameters:
index- The index into the array.string- The string to set in the array.
-
getString
Get the value of the array as a string.- Parameters:
index- The index into the array.- Returns:
- The string or null if it does not exist.
-
getString
Get an entry in the array that is expected to be a COSName.- Parameters:
index- The index into the array.defaultValue- The value to return if it is null.- Returns:
- The value at the index or defaultValue if none is found.
-
size
public int size() -
remove
-
removeLast
Removes the last object of the array- Returns:
- the removed object or null if the array was empty
-
remove
-
removeObject
This will remove an element from the array. This method will also remove a reference to the object.- Parameters:
o- The object to remove.- Returns:
trueif the object was removed,falseotherwise
-
iterator
-
listIterator
- Specified by:
listIteratorin interfaceList<COSBase>
-
listIterator
- Specified by:
listIteratorin interfaceList<COSBase>
-
lastIndexOf
- Specified by:
lastIndexOfin interfaceList<COSBase>
-
indexOf
-
indexOfObject
This will return the index of the entry or -1 if it is not found. This method will also find references to indirect objects.- Parameters:
object- The object to search for.- Returns:
- The index of the object or -1.
-
growToSize
This will add null values until the size of the array is at least as large as the parameter. If the array is already larger than the parameter then nothing is done.- Parameters:
size- The desired size of the array.
-
growToSize
This will add the object until the size of the array is at least as large as the parameter. If the array is already larger than the parameter then nothing is done.- Parameters:
size- The desired size of the array.object- The object to fill the array with.
-
trimToSize
trims the array to the given size- Parameters:
size-
-
toFloatArray
public float[] toFloatArray()This will take an COSArray of numbers and convert it to a float[].- Returns:
- This COSArray as an array of float numbers.
-
setFloatArray
public void setFloatArray(float[] value) Clear the current contents of the COSArray and set it with the float[].- Parameters:
value- The new value of the float array.
-
toList
- Returns:
- the COSArray as List
-
isEmpty
public boolean isEmpty() -
toArray
-
toArray
public <T> T[] toArray(T[] a) -
contains
-
containsAll
- Specified by:
containsAllin interfaceCollection<COSBase>- Specified by:
containsAllin interfaceList<COSBase>
-
subList
-
accept
Description copied from class:COSBaseVisitor pattern for the COS model objects- Specified by:
acceptin classCOSBase- Throws:
IOException
-
duplicate
- Returns:
- a new
COSArraythat is a duplicate of this
-
equals
-
hashCode
public int hashCode() -
toString
-