intarsys PDF library API

de.intarsys.pdf.cos
Class COSArray

java.lang.Object
  extended by de.intarsys.pdf.cos.COSDocumentElement
      extended by de.intarsys.pdf.cos.COSObject
          extended by de.intarsys.pdf.cos.COSCompositeObject
              extended by de.intarsys.pdf.cos.COSArray
All Implemented Interfaces:
ICOSContainer, ICOSExceptionHandler, IAttributeSupport, de.intarsys.tools.component.ISaveStateSupport

public class COSArray
extends COSCompositeObject

A COSArray represents an indexed collection of COSDocumentElement instances.

Using the standard access methods, always "dereferenced" COSObject instances are returned. Use the "basic" falvor of methods to access the optional COSIndirectObject.


Field Summary
 
Fields inherited from class de.intarsys.pdf.cos.COSObject
CONSTANT_CONTAINER, NULL_CONTAINER, SLOT_CONTAINER
 
Method Summary
 Object accept(ICOSObjectVisitor visitor)
          Accept a visitor object.
 COSArray add(COSObject object)
          Add a COSObject to the collection.
 COSArray add(int index, COSObject object)
          Add a COSObject to the collection.
 COSArray asArray()
          this as a COSArray or null
 COSArray basicAddSilent(COSDocumentElement element)
          Add a document element (an object or a reference) to the collection.
 COSDocumentElement basicGet(int index)
          Get the COSDocumentElement (an object or a reference) from this at the specified index.
 Iterator basicIterator()
          An iterator that returns all contained COSDocumentElement instances without dereferencing.
 void clear()
          Remove all elements from this.
 COSObject copyDeep(Map copied)
          Make a deep copy of the receiver within the same document.
 COSObject copyShallow()
          Make a copy of the receiver.
static COSArray create()
          Create an empty COSArray.
static COSArray create(int size)
          Create an empty COSArray with a preallocated size.
static COSArray createWith(float a, float b, float c, float d)
          Shortcut for fast creation of rectangle arrays
static COSArray createWith(float a, float b, float c, float d, float e, float f)
          Shortcut for fast creation of matrix arrays
 boolean equals(Object o)
           
 COSObject get(int index)
          The COSObject at the given index.
 List getObjects()
          A copy of all COSObject's in this.
 int hashCode()
          ATTENTION: this implementation returns a hash code that does not remain constant when manipulating the arrays content
 int indexOf(COSObject object)
          The index of object within this or -1 if not found.
 boolean isEmpty()
          true if this.size() == 0.
 Iterator iterator()
          An iterator over contained objects.
 COSIndirectObject referenceIndirect(COSObject object)
          Change the reference to the object contained in this to an indirect one via reference.
 boolean remove(COSObject object)
          Remove object from this.
 COSObject remove(int index)
          Remove the object at index from the collection.
 void restoreState(Object object)
           
 Object saveState()
           
 COSObject set(int i, COSObject object)
          Replace the object at index i with object.
 int size()
          The number of elements in this.
 
Methods inherited from class de.intarsys.pdf.cos.COSCompositeObject
addObjectListener, associate, containable, copyDeep, disassociate, getAttribute, isObjectListenerAvailable, isPrimitive, referenceCount, register, removeAttribute, removeObjectListener, restoreStateContainer, saveStateContainer, setAttribute, willChange
 
Methods inherited from class de.intarsys.pdf.cos.COSObject
asBoolean, asDictionary, asFixed, asInteger, asName, asNull, asNumber, asStream, asString, beConstant, beIndirect, containable, copyOptional, copySubGraph, dereference, getContainer, getDoc, getIndirectObject, isDangling, isIndirect, isNull, isNumber, isSwapped, stringValue, toString
 
Methods inherited from class de.intarsys.pdf.cos.COSDocumentElement
handleException, isReference
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.intarsys.pdf.cos.ICOSContainer
getDoc
 

Method Detail

create

public static COSArray create()
Create an empty COSArray.

Returns:
Create an empty COSArray.

create

public static COSArray create(int size)
Create an empty COSArray with a preallocated size.

Returns:
Create an empty COSArray.

createWith

public static COSArray createWith(float a,
                                  float b,
                                  float c,
                                  float d)
Shortcut for fast creation of rectangle arrays

Parameters:
a -
b -
c -
d -
Returns:
a new COSArray

createWith

public static COSArray createWith(float a,
                                  float b,
                                  float c,
                                  float d,
                                  float e,
                                  float f)
Shortcut for fast creation of matrix arrays

Parameters:
a -
b -
c -
d -
e -
f -
Returns:
a new COSArray

getObjects

public List getObjects()
A copy of all COSObject's in this.

Indirect objects and dangling references are handled by this method.

Returns:
A copy of all COSObject's in this.

accept

public Object accept(ICOSObjectVisitor visitor)
              throws COSVisitorException
Description copied from class: COSDocumentElement
Accept a visitor object. The receiver selects the correct implementation in the visitor by "double dispatching".

Specified by:
accept in class COSDocumentElement
Parameters:
visitor - The object visiting the receiver.
Returns:
Object An object depending on the visitor semantics.
Throws:
COSVisitorException - An exception depending on the visitor semantics.

add

public COSArray add(COSObject object)
Add a COSObject to the collection.

This method takes care of change propagation for incremental writing.

this method should be used by the application level programmer to ensure he deals not with references.

Parameters:
object - the object to be added
Returns:
this

add

public COSArray add(int index,
                    COSObject object)
Add a COSObject to the collection.

This method takes care of change propagation for incremental writing.

this method should be used by the application level programmer to ensure he deals not with references.

Parameters:
index - The index where to insert object
object - the object to be added
Returns:
this

basicAddSilent

public COSArray basicAddSilent(COSDocumentElement element)
Add a document element (an object or a reference) to the collection.

The change is not propagated.

This should not be used by the application level programmer. It is public for package visibility reasons.

Parameters:
element - the element to be added
Returns:
The receiver.

basicGet

public COSDocumentElement basicGet(int index)
Get the COSDocumentElement (an object or a reference) from this at the specified index.

This method should only be used for low level programming.

Parameters:
index - The index into this
Returns:
Get the COSDocumentElement (an object or a reference) from this at the specified index.

basicIterator

public Iterator basicIterator()
An iterator that returns all contained COSDocumentElement instances without dereferencing.

This should be used in low level programming.

Specified by:
basicIterator in class COSObject
Returns:
An iterator that returns all contained COSDocumentElement instances without dereferencing.

clear

public void clear()
Remove all elements from this.


copyShallow

public COSObject copyShallow()
Description copied from class: COSObject
Make a copy of the receiver.

A copy is made of the receiver and after this recursively of all not indirect objects.

Be careful when copying objects, as there are semantics that may NOT be recognized by this method.

Overrides:
copyShallow in class COSObject
Returns:
The object copied

equals

public boolean equals(Object o)
Overrides:
equals in class Object

get

public COSObject get(int index)
The COSObject at the given index. Any index outisde the valid array range results in COSNull (compare Adobe Core ApI Reference).

Parameters:
index - The index of the COSObject to select from this.
Returns:
The COSObject at the given index or COSNull.

hashCode

public int hashCode()
ATTENTION: this implementation returns a hash code that does not remain constant when manipulating the arrays content

Overrides:
hashCode in class Object
See Also:
Object.hashCode()

indexOf

public int indexOf(COSObject object)
The index of object within this or -1 if not found.

Parameters:
object - The object to be searched within this.
Returns:
The index of object within this or -1 if not found.

iterator

public Iterator iterator()
Description copied from class: COSObject
An iterator over contained objects. The iterator is an empty iterator if this is not a container.

This iterator returns only COSObject instances, references are dereferenced.

Specified by:
iterator in class COSObject
Returns:
Iterator over contained objects.

referenceIndirect

public COSIndirectObject referenceIndirect(COSObject object)
Description copied from class: COSCompositeObject
Change the reference to the object contained in this to an indirect one via reference.

This method must be redefined by all containers to reflect the new reference type in their child references.

This event is delegated to the document to create the correct state for a new indirect object. If a document is not yet present, the state is changed when the COSObject (s) are added to the document finally. This can happen when constructing a COSObject graph "offline" and later add it to the document.

From the COS invariants you can be sure that the object referenced by ref is contained in this at most once

Specified by:
referenceIndirect in interface ICOSContainer
Overrides:
referenceIndirect in class COSCompositeObject
Parameters:
object - The object to be indirect

remove

public boolean remove(COSObject object)
Remove object from this. If object is not contained, nothing happens.

This method cycles all elements wich may cause heavy lazy loading.

Parameters:
object - The object to remove from this.
Returns:
true if object was removed.

remove

public COSObject remove(int index)
Remove the object at index from the collection.

Parameters:
index - The index of the object to remove from the collection.
Returns:
The object previously stored at the index.

set

public COSObject set(int i,
                     COSObject object)
Replace the object at index i with object.

Parameters:
i - The index
object - The object to put at the specified index
Returns:
The previuosly referenced object

size

public int size()
The number of elements in this.

Returns:
The number of elements in this.

isEmpty

public boolean isEmpty()
true if this.size() == 0.

Returns:
true if this.size() == 0.

copyDeep

public COSObject copyDeep(Map copied)
Description copied from class: COSObject
Make a deep copy of the receiver within the same document. The result is a "PDF semantic" deep copy, implementation artifacts as "attributes" and listeners are NOT copied.

The copied map is used to identify objects copied in earlier runs of this method to avoid duplicating resources used in different copy targets (for example the pages of a document). copied is modified while executing copyDeep and contains a mapping from indirect objects in the original document to copied objects.

The algorithm copies this along with all outgoing references (recursively).

Object identity is preserved.

Be careful when copying objects, as there are semantics that may NOT be recognized by this method.

Overrides:
copyDeep in class COSCompositeObject
Returns:
the object copied recursively
See Also:
COSObject.copyDeep()

restoreState

public void restoreState(Object object)
Specified by:
restoreState in interface de.intarsys.tools.component.ISaveStateSupport
Overrides:
restoreState in class COSObject

saveState

public Object saveState()

asArray

public COSArray asArray()
Description copied from class: COSObject
this as a COSArray or null

Overrides:
asArray in class COSObject
Returns:
a COSArray or null

intarsys PDF library API

Copyright © 2006 intarsys consulting GmbH. All Rights Reserved.