org.pdfbox.pdmodel.common
Class COSArrayList

java.lang.Object
  extended by org.pdfbox.pdmodel.common.COSArrayList
All Implemented Interfaces:
java.lang.Iterable, java.util.Collection, java.util.List

public class COSArrayList
extends java.lang.Object
implements java.util.List

This is an implementation of a List that will sync its contents to a COSArray.

Version:
$Revision: 1.15 $
Author:
Ben Litchfield

Constructor Summary
COSArrayList()
          Default constructor.
COSArrayList(java.util.List actualList, COSArray cosArray)
          Constructor.
COSArrayList(java.lang.Object actualObject, COSBase item, COSDictionary dictionary, java.lang.String dictionaryKey)
          This is a really special constructor.
 
Method Summary
 void add(int index, java.lang.Object element)
          
 boolean add(java.lang.Object o)
          
 boolean addAll(java.util.Collection c)
          
 boolean addAll(int index, java.util.Collection c)
          
 void clear()
          
 boolean contains(java.lang.Object o)
          
 boolean containsAll(java.util.Collection c)
          
static java.util.List convertCOSNameCOSArrayToList(COSArray nameArray)
          This will take an array of COSName and return a COSArrayList of java.lang.String values.
static java.util.List 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 convertFloatCOSArrayToList(COSArray floatArray)
          This will take an array of COSNumbers and return a COSArrayList of java.lang.Float values.
static java.util.List 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 strings)
          This will take an list of string objects and return a COSArray of COSName objects.
static COSArray convertStringListToCOSStringCOSArray(java.util.List strings)
          This will take an list of string objects and return a COSArray of COSName objects.
 boolean equals(java.lang.Object o)
          
 java.lang.Object get(int index)
          
 int hashCode()
          
 int indexOf(java.lang.Object o)
          
 boolean isEmpty()
          
 java.util.Iterator iterator()
          
 int lastIndexOf(java.lang.Object o)
          
 java.util.ListIterator listIterator()
          
 java.util.ListIterator listIterator(int index)
          
 java.lang.Object remove(int index)
          
 boolean remove(java.lang.Object o)
          
 boolean removeAll(java.util.Collection c)
          
 boolean retainAll(java.util.Collection c)
          
 java.lang.Object set(int index, java.lang.Object element)
          
 int size()
          
 java.util.List subList(int fromIndex, int toIndex)
          
 java.lang.Object[] toArray()
          
 java.lang.Object[] toArray(java.lang.Object[] a)
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

COSArrayList

public COSArrayList()
Default constructor.


COSArrayList

public COSArrayList(java.util.List actualList,
                    COSArray cosArray)
Constructor.

Parameters:
actualList - The list of standard java objects
cosArray - The COS array object to sync to.

COSArrayList

public COSArrayList(java.lang.Object actualObject,
                    COSBase item,
                    COSDictionary dictionary,
                    java.lang.String 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()

Specified by:
size in interface java.util.Collection
Specified by:
size in interface java.util.List

isEmpty

public boolean isEmpty()

Specified by:
isEmpty in interface java.util.Collection
Specified by:
isEmpty in interface java.util.List

contains

public boolean contains(java.lang.Object o)

Specified by:
contains in interface java.util.Collection
Specified by:
contains in interface java.util.List

iterator

public java.util.Iterator iterator()

Specified by:
iterator in interface java.lang.Iterable
Specified by:
iterator in interface java.util.Collection
Specified by:
iterator in interface java.util.List

toArray

public java.lang.Object[] toArray()

Specified by:
toArray in interface java.util.Collection
Specified by:
toArray in interface java.util.List

toArray

public java.lang.Object[] toArray(java.lang.Object[] a)

Specified by:
toArray in interface java.util.Collection
Specified by:
toArray in interface java.util.List

add

public boolean add(java.lang.Object o)

Specified by:
add in interface java.util.Collection
Specified by:
add in interface java.util.List

remove

public boolean remove(java.lang.Object o)

Specified by:
remove in interface java.util.Collection
Specified by:
remove in interface java.util.List

containsAll

public boolean containsAll(java.util.Collection c)

Specified by:
containsAll in interface java.util.Collection
Specified by:
containsAll in interface java.util.List

addAll

public boolean addAll(java.util.Collection c)

Specified by:
addAll in interface java.util.Collection
Specified by:
addAll in interface java.util.List

addAll

public boolean addAll(int index,
                      java.util.Collection c)

Specified by:
addAll in interface java.util.List

convertIntegerCOSArrayToList

public static java.util.List 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 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 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 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 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 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)

Specified by:
removeAll in interface java.util.Collection
Specified by:
removeAll in interface java.util.List

retainAll

public boolean retainAll(java.util.Collection c)

Specified by:
retainAll in interface java.util.Collection
Specified by:
retainAll in interface java.util.List

clear

public void clear()

Specified by:
clear in interface java.util.Collection
Specified by:
clear in interface java.util.List

equals

public boolean equals(java.lang.Object o)

Specified by:
equals in interface java.util.Collection
Specified by:
equals in interface java.util.List
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Specified by:
hashCode in interface java.util.Collection
Specified by:
hashCode in interface java.util.List
Overrides:
hashCode in class java.lang.Object

get

public java.lang.Object get(int index)

Specified by:
get in interface java.util.List

set

public java.lang.Object set(int index,
                            java.lang.Object element)

Specified by:
set in interface java.util.List

add

public void add(int index,
                java.lang.Object element)

Specified by:
add in interface java.util.List

remove

public java.lang.Object remove(int index)

Specified by:
remove in interface java.util.List

indexOf

public int indexOf(java.lang.Object o)

Specified by:
indexOf in interface java.util.List

lastIndexOf

public int lastIndexOf(java.lang.Object o)

Specified by:
lastIndexOf in interface java.util.List

listIterator

public java.util.ListIterator listIterator()

Specified by:
listIterator in interface java.util.List

listIterator

public java.util.ListIterator listIterator(int index)

Specified by:
listIterator in interface java.util.List

subList

public java.util.List subList(int fromIndex,
                              int toIndex)

Specified by:
subList in interface java.util.List