intarsys PDF library API

de.intarsys.pdf.cos
Class COSDictionary

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.COSDictionary
All Implemented Interfaces:
ICOSContainer, ICOSExceptionHandler, IAttributeSupport, de.intarsys.tools.component.ISaveStateSupport

public class COSDictionary
extends COSCompositeObject

Represents a collection of associations (Map).

The keys of the association are COSName objects, the value may be any COSDocumentElement


Nested Class Summary
static class COSDictionary.Entry
           
 
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.
 void addAll(COSDictionary dict)
          Add all objects from dict.
 void addIfAbsent(COSDictionary dict)
          Add all values from dict that are not yet defined in the receiver.
 COSDictionary asDictionary()
           
 Iterator basicEntryIterator()
          An iterator over all entries.
 COSDocumentElement basicGet(COSName key)
          The COSDocumentElement associated with key.
 Iterator basicIterator()
          An iterator over all values.
 COSDocumentElement basicPutSilent(COSName key, COSDocumentElement element)
          Add a document element to the collection.
 void clear()
          Remove all associations from the receiver.
 boolean containsKey(COSName key)
          Answer true if key is a valid key in the collection .
 boolean containsValue(COSObject obj)
          Answer true if obj is contained in the collection
 COSObject copyDeep(Map copied)
          Make a deep copy of the receiver within the same document.
 COSObject copyShallow()
          Make a copy of the receiver.
static COSDictionary create()
          Create an empty COSDictionary.
static COSDictionary create(int size)
          Create an empty COSDictionary with an initial capacity.
 Iterator entryIterator()
          An iterator over all entries, returning dereferenced entries ( COSObject).
 COSObject get(COSName key)
          The COSObject associated with key.
 Iterator iterator()
          An iterator over contained objects.
 COSObject keyOf(COSObject obj)
          The key of obj when it is contained in this or COSNull.
 Set keySet()
          The set of keys.
 COSObject put(COSName key, COSObject object)
          Add an association to the collection.
 COSIndirectObject referenceIndirect(COSObject object)
          Change the reference to the object contained in this to an indirect one via reference.
 COSObject remove(COSName key)
          Remove the element from the collection associated with key.
 void restoreState(Object object)
           
 Object saveState()
           
 int size()
          The number of elements in this.
 List values()
          A list of COSObject instances within 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
asArray, asBoolean, 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.intarsys.pdf.cos.ICOSContainer
getDoc
 

Method Detail

create

public static COSDictionary create()
Create an empty COSDictionary.

Returns:
Create an empty COSDictionary.

create

public static COSDictionary create(int size)
Create an empty COSDictionary with an initial capacity.

Returns:
Create an empty COSDictionary with an initial capacity.

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.

addAll

public void addAll(COSDictionary dict)
Add all objects from dict. Associations already available in this are replaced with new content .

Parameters:
dict - The collection of associations to add to this.

addIfAbsent

public void addIfAbsent(COSDictionary dict)
Add all values from dict that are not yet defined in the receiver.

Parameters:
dict - The dictionary with the associations to add.

asDictionary

public COSDictionary asDictionary()
Overrides:
asDictionary in class COSObject
Returns:
a COSDictionary or null

basicEntryIterator

public Iterator basicEntryIterator()
An iterator over all entries. The value of the entries returned are the not - dereferenced elements.

Returns:
An interator over all entries.

basicGet

public COSDocumentElement basicGet(COSName key)
The COSDocumentElement associated with key.

Parameters:
key - The name to lookup
Returns:
The COSDocumentElement associated with key.

basicIterator

public Iterator basicIterator()
An iterator over all values. The objects returned are not dereferenced.

Specified by:
basicIterator in class COSObject
Returns:
An iterator over all values.

basicPutSilent

public COSDocumentElement basicPutSilent(COSName key,
                                         COSDocumentElement element)
Add a document element to the collection.

The element is inserted without change propagation.

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

Parameters:
key - The key where to store the new element.
element - The COSDocumentElement to store.
Returns:
The COSDocumentElement associated with key so far.

clear

public void clear()
Remove all associations from the receiver.


containsKey

public boolean containsKey(COSName key)
Answer true if key is a valid key in the collection .

Parameters:
key - The key whose existence is to be checked.
Returns:
Answer true if key is a valid key in the collection .

containsValue

public boolean containsValue(COSObject obj)
Answer true if obj is contained in the collection

Parameters:
obj - The object to look up in the collection
Returns:
Answer true if obj is contained in the collection

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()

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

entryIterator

public Iterator entryIterator()
An iterator over all entries, returning dereferenced entries ( COSObject).

Returns:
An interator over all entries, returning dereferenced entries.

get

public COSObject get(COSName key)
The COSObject associated with key.

Parameters:
key - The key to lookup
Returns:
The COSObject associated with key.

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.

keyOf

public COSObject keyOf(COSObject obj)
The key of obj when it is contained in this or COSNull.

Parameters:
obj - The object to look up in the collection
Returns:
The key of obj when it is contained in this or COSNull.

keySet

public Set keySet()
The set of keys. Keys are COSName instances.

Returns:
The set of keys .

put

public COSObject put(COSName key,
                     COSObject object)
Add an association to the collection.

Parameters:
key - The key where to store the object
object - The object to store in the collection
Returns:
The COSObject associated with key so far.

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 COSObject remove(COSName key)
Remove the element from the collection associated with key.

Parameters:
key - The key of the object to remove
Returns:
The COSObject removed or null.

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()

size

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

Returns:
The number of elements in this.

values

public List values()
A list of COSObject instances within this.

Returns:
A list of COSObject instances within this.

intarsys PDF library API

Copyright © 2006 intarsys consulting GmbH. All Rights Reserved.