Class COSArrayList<E>

java.lang.Object
org.apache.pdfbox.pdmodel.common.COSArrayList<E>
Type Parameters:
E - Element type.
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.
  • Field Details

    • array

      private final COSArray array
    • actual

      private final List<E> actual
    • isFiltered

      private boolean isFiltered
    • parentDict

      private COSDictionary parentDict
    • dictKey

      private COSName dictKey
  • Constructor Details

    • 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 objects
      cosArray - 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 Details