Package org.apache.pdfbox.pdmodel.common
Class COSArrayList<E>
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.common.COSArrayList<E>
-
- All Implemented Interfaces:
java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.List<E>
public class COSArrayList<E> extends java.lang.Object implements java.util.List<E>
This is an implementation of a List that will sync its contents to a COSArray.- Version:
- $Revision: 1.15 $
- Author:
- Ben Litchfield
-
-
Constructor Summary
Constructors Constructor Description COSArrayList()
Default constructor.COSArrayList(E actualObject, COSBase item, COSDictionary dictionary, java.lang.String dictionaryKey)
Deprecated.use theCOSArrayList(Object, COSBase, COSDictionary, COSName)
method insteadCOSArrayList(E actualObject, COSBase item, COSDictionary dictionary, COSName dictionaryKey)
This is a really special constructor.COSArrayList(java.util.List<E> actualList, COSArray cosArray)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, E element)
boolean
add(E o)
boolean
addAll(int index, java.util.Collection<? extends E> c)
boolean
addAll(java.util.Collection<? extends E> c)
void
clear()
boolean
contains(java.lang.Object o)
boolean
containsAll(java.util.Collection<?> c)
static java.util.List<java.lang.String>
convertCOSNameCOSArrayToList(COSArray nameArray)
This will take an array of COSName and return a COSArrayList of java.lang.String values.static java.util.List<java.lang.String>
convertCOSStringCOSArrayToList(COSArray stringArray)
This will take an array of COSString and return a COSArrayList of java.lang.String values.static COSArray
converterToCOSArray(java.util.List<?> cosObjectableList)
This will convert a list of COSObjectables to an array list of COSBase objects.static java.util.List<java.lang.Float>
convertFloatCOSArrayToList(COSArray floatArray)
This will take an array of COSNumbers and return a COSArrayList of java.lang.Float values.static java.util.List<java.lang.Integer>
convertIntegerCOSArrayToList(COSArray intArray)
This will take an array of COSNumbers and return a COSArrayList of java.lang.Integer values.static COSArray
convertStringListToCOSNameCOSArray(java.util.List<java.lang.String> strings)
This will take an list of string objects and return a COSArray of COSName objects.static COSArray
convertStringListToCOSStringCOSArray(java.util.List<java.lang.String> strings)
This will take an list of string objects and return a COSArray of COSName objects.boolean
equals(java.lang.Object o)
E
get(int index)
int
hashCode()
int
indexOf(java.lang.Object o)
boolean
isEmpty()
java.util.Iterator<E>
iterator()
int
lastIndexOf(java.lang.Object o)
java.util.ListIterator<E>
listIterator()
java.util.ListIterator<E>
listIterator(int index)
E
remove(int index)
boolean
remove(java.lang.Object o)
boolean
removeAll(java.util.Collection<?> c)
boolean
retainAll(java.util.Collection<?> c)
E
set(int index, E element)
int
size()
java.util.List<E>
subList(int fromIndex, int toIndex)
java.lang.Object[]
toArray()
<X> X[]
toArray(X[] a)
COSArray
toList()
This will return then underlying COSArray.java.lang.String
toString()
-
-
-
Constructor Detail
-
COSArrayList
public COSArrayList()
Default constructor.
-
COSArrayList
public COSArrayList(java.util.List<E> actualList, COSArray cosArray)
Constructor.- Parameters:
actualList
- The list of standard java objectscosArray
- The COS array object to sync to.
-
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.
-
COSArrayList
public COSArrayList(E actualObject, COSBase item, COSDictionary dictionary, java.lang.String dictionaryKey)
Deprecated.use theCOSArrayList(Object, COSBase, COSDictionary, COSName)
method instead
-
-
Method Detail
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
contains
public boolean contains(java.lang.Object o)
-
iterator
public java.util.Iterator<E> iterator()
-
toArray
public java.lang.Object[] toArray()
-
toArray
public <X> X[] toArray(X[] a)
-
add
public boolean add(E o)
-
remove
public boolean remove(java.lang.Object o)
-
containsAll
public boolean containsAll(java.util.Collection<?> c)
-
addAll
public boolean addAll(java.util.Collection<? extends E> c)
-
addAll
public boolean addAll(int index, java.util.Collection<? extends E> c)
- Specified by:
addAll
in interfacejava.util.List<E>
-
convertIntegerCOSArrayToList
public static java.util.List<java.lang.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 java.util.List<java.lang.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 java.util.List<java.lang.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 java.util.List<java.lang.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(java.util.List<java.lang.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(java.util.List<java.lang.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(java.util.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.
-
removeAll
public boolean removeAll(java.util.Collection<?> c)
-
retainAll
public boolean retainAll(java.util.Collection<?> c)
-
clear
public void clear()
-
equals
public boolean equals(java.lang.Object o)
-
hashCode
public int hashCode()
-
indexOf
public int indexOf(java.lang.Object o)
- Specified by:
indexOf
in interfacejava.util.List<E>
-
lastIndexOf
public int lastIndexOf(java.lang.Object o)
- Specified by:
lastIndexOf
in interfacejava.util.List<E>
-
listIterator
public java.util.ListIterator<E> listIterator()
- Specified by:
listIterator
in interfacejava.util.List<E>
-
listIterator
public java.util.ListIterator<E> listIterator(int index)
- Specified by:
listIterator
in interfacejava.util.List<E>
-
subList
public java.util.List<E> subList(int fromIndex, int toIndex)
- Specified by:
subList
in interfacejava.util.List<E>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toList
public COSArray toList()
This will return then underlying COSArray.- Returns:
- the COSArray
-
-