org.pdfbox.pdmodel.common
Class COSArrayList

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

public class COSArrayList
extends Object
implements List

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

Version:
$Revision: 1.12 $
Author:
Ben Litchfield (ben@csh.rit.edu)

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

Constructor Detail

COSArrayList

public COSArrayList(List actualList,
                    COSArray cosArray)
Constructor.

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

COSArrayList

public COSArrayList(Object actualObject,
                    COSBase item,
                    COSDictionary dictionary,
                    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 Collection
Specified by:
size in interface List
See Also:
List.size()

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection
Specified by:
isEmpty in interface List
See Also:
List.isEmpty()

contains

public boolean contains(Object o)
Specified by:
contains in interface Collection
Specified by:
contains in interface List
See Also:
List.contains( Object )

iterator

public Iterator iterator()
Specified by:
iterator in interface Iterable
Specified by:
iterator in interface Collection
Specified by:
iterator in interface List
See Also:
List.iterator()

toArray

public Object[] toArray()
Specified by:
toArray in interface Collection
Specified by:
toArray in interface List
See Also:
List.toArray()

toArray

public Object[] toArray(Object[] a)
Specified by:
toArray in interface Collection
Specified by:
toArray in interface List
See Also:
List.toArray( Object[] )

add

public boolean add(Object o)
Specified by:
add in interface Collection
Specified by:
add in interface List
See Also:
List.add( Object )

remove

public boolean remove(Object o)
Specified by:
remove in interface Collection
Specified by:
remove in interface List
See Also:
List.remove( Object )

containsAll

public boolean containsAll(Collection c)
Specified by:
containsAll in interface Collection
Specified by:
containsAll in interface List
See Also:
List.containsAll( Collection )

addAll

public boolean addAll(Collection c)
Specified by:
addAll in interface Collection
Specified by:
addAll in interface List
See Also:
List.addAll( Collection )

addAll

public boolean addAll(int index,
                      Collection c)
Specified by:
addAll in interface List
See Also:
List.addAll( int, Collection )

convertIntegerCOSArrayToList

public static 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 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 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 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(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(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(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(Collection c)
Specified by:
removeAll in interface Collection
Specified by:
removeAll in interface List
See Also:
List.removeAll( Collection )

retainAll

public boolean retainAll(Collection c)
Specified by:
retainAll in interface Collection
Specified by:
retainAll in interface List
See Also:
List.retainAll( Collection )

clear

public void clear()
Specified by:
clear in interface Collection
Specified by:
clear in interface List
See Also:
List.clear()

equals

public boolean equals(Object o)
Specified by:
equals in interface Collection
Specified by:
equals in interface List
Overrides:
equals in class Object
See Also:
List.equals( Object )

hashCode

public int hashCode()
Specified by:
hashCode in interface Collection
Specified by:
hashCode in interface List
Overrides:
hashCode in class Object
See Also:
List.hashCode()

get

public Object get(int index)
Specified by:
get in interface List
See Also:
List.get( int )

set

public Object set(int index,
                  Object element)
Specified by:
set in interface List
See Also:
List.set( int, Object )

add

public void add(int index,
                Object element)
Specified by:
add in interface List
See Also:
List.add( int, Object )

remove

public Object remove(int index)
Specified by:
remove in interface List
See Also:
List.remove( int )

indexOf

public int indexOf(Object o)
Specified by:
indexOf in interface List
See Also:
List.indexOf( Object )

lastIndexOf

public int lastIndexOf(Object o)
Specified by:
lastIndexOf in interface List
See Also:
List.lastIndexOf( Object )

listIterator

public ListIterator listIterator()
Specified by:
listIterator in interface List
See Also:
List.listIterator()

listIterator

public ListIterator listIterator(int index)
Specified by:
listIterator in interface List
See Also:
List.listIterator( int )

subList

public List subList(int fromIndex,
                    int toIndex)
Specified by:
subList in interface List
See Also:
List.subList( int, int )


Copyright © 2006-2007 EGIZ - E-Government Innovationszentrum. All Rights Reserved.