Class COSArrayList<E>
- java.lang.Object
-
- com.tom_roush.pdfbox.pdmodel.common.COSArrayList<E>
-
- All Implemented Interfaces:
Iterable<E>,Collection<E>,List<E>
public class COSArrayList<E> extends Object implements List<E>
This is an implementation of a List that will sync its contents to a COSArray.
-
-
Constructor Summary
Constructors Constructor Description COSArrayList()Default constructor.COSArrayList(COSDictionary dictionary, COSName dictionaryKey)This constructor is to be used if the array doesn't exist, but is to be created and added to the parent dictionary as soon as the first element is added to the array.COSArrayList(E actualObject, COSBase item, COSDictionary dictionary, COSName dictionaryKey)This is a really special constructor.COSArrayList(List<E> actualList, COSArray cosArray)Create the COSArrayList specifying the List and the backing COSArray.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidadd(int index, E element)booleanadd(E o)booleanaddAll(int index, Collection<? extends E> c)booleanaddAll(Collection<? extends E> c)voidclear()booleancontains(Object o)booleancontainsAll(Collection<?> c)static List<String>convertCOSNameCOSArrayToList(COSArray nameArray)This will take an array of COSName and return a COSArrayList of java.lang.String values.static List<String>convertCOSStringCOSArrayToList(COSArray stringArray)This will take an array of COSString and return a COSArrayList of java.lang.String values.static COSArrayconverterToCOSArray(List<?> cosObjectableList)This will convert a list of COSObjectables to an array list of COSBase objects.static List<Float>convertFloatCOSArrayToList(COSArray floatArray)This will take an array of COSNumbers and return a COSArrayList of java.lang.Float values.static List<Integer>convertIntegerCOSArrayToList(COSArray intArray)This will take an array of COSNumbers and return a COSArrayList of java.lang.Integer values.static COSArrayconvertStringListToCOSNameCOSArray(List<String> strings)This will take an list of string objects and return a COSArray of COSName objects.static COSArrayconvertStringListToCOSStringCOSArray(List<String> strings)This will take an list of string objects and return a COSArray of COSName objects.booleanequals(Object o)Eget(int index)COSArraygetCOSArray()This will return the underlying COSArray.inthashCode()intindexOf(Object o)booleanisEmpty()Iterator<E>iterator()intlastIndexOf(Object o)ListIterator<E>listIterator()ListIterator<E>listIterator(int index)Eremove(int index)booleanremove(Object o)booleanremoveAll(Collection<?> c)booleanretainAll(Collection<?> c)Eset(int index, E element)intsize()List<E>subList(int fromIndex, int toIndex)Object[]toArray()<X> X[]toArray(X[] a)COSArraytoList()Deprecated.usegetCOSArray()instead.StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.List
replaceAll, sort, spliterator
-
-
-
-
Constructor Detail
-
COSArrayList
public COSArrayList()
Default constructor.
-
COSArrayList
public COSArrayList(List<E> actualList, COSArray cosArray)
Create the COSArrayList specifying the List and the backing COSArray.User of this constructor need to ensure that the entries in the List and the backing COSArray are matching i.e. the COSObject of the List entry is included in the COSArray.
If the number of entries in the List and the COSArray differ it is assumed that the List has been filtered. In that case the COSArrayList shall only be used for reading purposes and no longer for updating.
- Parameters:
actualList- The list of standard java objectscosArray- The COS array object to sync to.
-
COSArrayList
public COSArrayList(COSDictionary dictionary, COSName dictionaryKey)
This constructor is to be used if the array doesn't exist, but is to be created and added to the parent dictionary as soon as the first element is added to the array.- Parameters:
dictionary- The dictionary that holds the item, and will hold the array if an item is added.dictionaryKey- The key into the dictionary to set the item.
-
COSArrayList
public COSArrayList(E actualObject, COSBase item, COSDictionary dictionary, COSName dictionaryKey)
This is a really special constructor. Sometimes the PDF spec says that a dictionary entry can either be a single item or an array of those items. But in the PDModel interface we really just want to always return a java.util.List. In the case were we get the list and never modify it we don't want to convert to COSArray and put one element, unless we append to the list. So here we are going to create this object with a single item instead of a list, but allow more items to be added and then converted to an array.- Parameters:
actualObject- The PDModel object.item- The COS Model object.dictionary- The dictionary that holds the item, and will hold the array if an item is added.dictionaryKey- The key into the dictionary to set the item.
-
-
Method Detail
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
contains
public boolean contains(Object o)
-
toArray
public Object[] toArray()
-
toArray
public <X> X[] toArray(X[] a)
-
add
public boolean add(E o)
-
remove
public boolean remove(Object o)
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceList<E>
-
addAll
public boolean addAll(Collection<? extends E> c)
-
addAll
public boolean addAll(int index, Collection<? extends E> c)
-
convertIntegerCOSArrayToList
public static List<Integer> convertIntegerCOSArrayToList(COSArray intArray)
This will take an array of COSNumbers and return a COSArrayList of java.lang.Integer values.- Parameters:
intArray- The existing integer Array.- Returns:
- A list that is part of the core Java collections.
-
convertFloatCOSArrayToList
public static List<Float> convertFloatCOSArrayToList(COSArray floatArray)
This will take an array of COSNumbers and return a COSArrayList of java.lang.Float values.- Parameters:
floatArray- The existing float Array.- Returns:
- The list of Float objects.
-
convertCOSNameCOSArrayToList
public static List<String> convertCOSNameCOSArrayToList(COSArray nameArray)
This will take an array of COSName and return a COSArrayList of java.lang.String values.- Parameters:
nameArray- The existing name Array.- Returns:
- The list of String objects.
-
convertCOSStringCOSArrayToList
public static List<String> convertCOSStringCOSArrayToList(COSArray stringArray)
This will take an array of COSString and return a COSArrayList of java.lang.String values.- Parameters:
stringArray- The existing name Array.- Returns:
- The list of String objects.
-
convertStringListToCOSNameCOSArray
public static COSArray convertStringListToCOSNameCOSArray(List<String> strings)
This will take an list of string objects and return a COSArray of COSName objects.- Parameters:
strings- A list of strings- Returns:
- An array of COSName objects
-
convertStringListToCOSStringCOSArray
public static COSArray convertStringListToCOSStringCOSArray(List<String> strings)
This will take an list of string objects and return a COSArray of COSName objects.- Parameters:
strings- A list of strings- Returns:
- An array of COSName objects
-
converterToCOSArray
public static COSArray converterToCOSArray(List<?> cosObjectableList)
This will convert a list of COSObjectables to an array list of COSBase objects.- Parameters:
cosObjectableList- A list of COSObjectable.- Returns:
- A list of COSBase.
- Throws:
IllegalArgumentException- if an object type is not supported for conversion to a COSBase object.
-
removeAll
public boolean removeAll(Collection<?> c)
-
retainAll
public boolean retainAll(Collection<?> c)
-
clear
public void clear()
-
equals
public boolean equals(Object o)
-
hashCode
public int hashCode()
-
lastIndexOf
public int lastIndexOf(Object o)
- Specified by:
lastIndexOfin interfaceList<E>
-
listIterator
public ListIterator<E> listIterator()
- Specified by:
listIteratorin interfaceList<E>
-
listIterator
public ListIterator<E> listIterator(int index)
- Specified by:
listIteratorin interfaceList<E>
-
getCOSArray
public COSArray getCOSArray()
This will return the underlying COSArray.- Returns:
- the COSArray
-
toList
@Deprecated public COSArray toList()
Deprecated.usegetCOSArray()instead.This will return the underlying COSArray.- Returns:
- the COSArray
-
-