intarsys PDF library API

de.intarsys.pdf.cos
Class COSCompositeObject

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

public abstract class COSCompositeObject
extends COSObject
implements ICOSContainer, IAttributeSupport

A superclass implementation for all containers of other COSObject instances.


Field Summary
 
Fields inherited from class de.intarsys.pdf.cos.COSObject
CONSTANT_CONTAINER, NULL_CONTAINER, SLOT_CONTAINER
 
Method Summary
 void addObjectListener(ICOSObjectListener listener)
          Add a listener for object changes.
 ICOSContainer associate(ICOSContainer newContainer, COSObject object)
          It is the responsibility of the current container to create the association with the new one.
 COSDocumentElement containable(COSObject object)
          The stand-in to be used when object should be contained in a container.
 COSObject copyDeep()
          Make a deep copy of the receiver within the same document.
 COSObject copyDeep(Map copied)
          Make a deep copy of the receiver within the same document.
 ICOSContainer disassociate(ICOSContainer oldContainer, COSObject object)
          It is the responsibility of the current container to remove the association from the old one.
 Object getAttribute(Object key)
          get an attribute from the context
 boolean isObjectListenerAvailable()
          true if an ICOSObjectListener is registered.
 boolean isPrimitive()
          Answer true if this object is of a primitive type
 int referenceCount()
          The number of references to the contained object.
 COSIndirectObject referenceIndirect(COSObject object)
          Change the reference to the object contained in this to an indirect one via reference.
 void register(COSDocumentElement object)
          It is the responsibility of the active container to register object in its data structures.
 Object removeAttribute(Object key)
          remove an attribute in the context
 void removeObjectListener(ICOSObjectListener listener)
          Remove a listener for object changes.
 ICOSContainer restoreStateContainer(ICOSContainer pContainer)
          Restore the save state for the container.
 ICOSContainer saveStateContainer()
          Create a save state for the container when saving the COSObject state.
 Object setAttribute(Object key, Object value)
          set the value of an attribute in the context
 void willChange(COSObject change)
          Propagate a change from a COSObject down in the hierarchy.
 
Methods inherited from class de.intarsys.pdf.cos.COSObject
asArray, asBoolean, asDictionary, asFixed, asInteger, asName, asNull, asNumber, asStream, asString, basicIterator, beConstant, beIndirect, containable, copyOptional, copyShallow, copySubGraph, dereference, getContainer, getDoc, getIndirectObject, isDangling, isIndirect, isNull, isNumber, isSwapped, iterator, restoreState, stringValue, toString
 
Methods inherited from class de.intarsys.pdf.cos.COSDocumentElement
accept, 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
 
Methods inherited from interface de.intarsys.tools.component.ISaveStateSupport
saveState
 

Method Detail

setAttribute

public Object setAttribute(Object key,
                           Object value)
Description copied from interface: IAttributeSupport
set the value of an attribute in the context

Specified by:
setAttribute in interface IAttributeSupport
Parameters:
key - the name of the attribute to set
value - the new value the attribute
Returns:
The previously associated object for key

referenceIndirect

public COSIndirectObject referenceIndirect(COSObject object)
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
Parameters:
object -

willChange

public void willChange(COSObject change)
Description copied from interface: ICOSContainer
Propagate a change from a COSObject down in the hierarchy.

Specified by:
willChange in interface ICOSContainer

isPrimitive

public boolean isPrimitive()
Description copied from class: COSObject
Answer true if this object is of a primitive type

Specified by:
isPrimitive in class COSObject
Returns:
Answer true if this object is of a primitive type

getAttribute

public Object getAttribute(Object key)
Description copied from interface: IAttributeSupport
get an attribute from the context

Specified by:
getAttribute in interface IAttributeSupport
Parameters:
key - the name of the attribute to get
Returns:
The value of the attribute to get

removeAttribute

public Object removeAttribute(Object key)
Description copied from interface: IAttributeSupport
remove an attribute in the context

Specified by:
removeAttribute in interface IAttributeSupport
Parameters:
key - the name of the attribute to remove
Returns:
The previously associated object for key

addObjectListener

public void addObjectListener(ICOSObjectListener listener)
Description copied from class: COSObject
Add a listener for object changes.

Specified by:
addObjectListener in class COSObject
Parameters:
listener - The listener to be informed about changes.

isObjectListenerAvailable

public boolean isObjectListenerAvailable()
Description copied from class: COSObject
true if an ICOSObjectListener is registered. This is for test purposes.

Specified by:
isObjectListenerAvailable in class COSObject

removeObjectListener

public void removeObjectListener(ICOSObjectListener listener)
Description copied from class: COSObject
Remove a listener for object changes.

Specified by:
removeObjectListener in class COSObject
Parameters:
listener - The listener to be removed.

associate

public ICOSContainer associate(ICOSContainer newContainer,
                               COSObject object)
Description copied from interface: ICOSContainer
It is the responsibility of the current container to create the association with the new one. The table shows the available transitions | composite | indirect | | constant | n.a. | n.a. | (always copied before by "containable") null | ok | ok | composite | error | ok | indirect | ok | ok |

Specified by:
associate in interface ICOSContainer
Returns:
The resulting ICOSContainer for object

disassociate

public ICOSContainer disassociate(ICOSContainer oldContainer,
                                  COSObject object)
Description copied from interface: ICOSContainer
It is the responsibility of the current container to remove the association from the old one. The table shows the available transitions.
              | composite  | indirect   |
              |
    constant  | n.a.       | n.a.       |
    null      | n.a.       | n.a.       |
    composite | ok         | n.a.       |
    indirect  | ok         | n.a.       |
 

Specified by:
disassociate in interface ICOSContainer
Returns:
The resulting ICOSContainer for object

containable

public COSDocumentElement containable(COSObject object)
Description copied from interface: ICOSContainer
The stand-in to be used when object should be contained in a container. This is either the object itself or the COSIndirectObject to it.

Specified by:
containable in interface ICOSContainer
Parameters:
object - THe object whose containable is requested.
Returns:
The stand-in to be used when object should be contained in a container.

copyDeep

public final COSObject copyDeep()
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 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.

Specified by:
copyDeep in class COSObject
Returns:
the object copied recursively

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.

Specified by:
copyDeep in class COSObject
Returns:
the object copied recursively
See Also:
COSObject.copyDeep()

register

public void register(COSDocumentElement object)
Description copied from interface: ICOSContainer
It is the responsibility of the active container to register object in its data structures.

Specified by:
register in interface ICOSContainer
Parameters:
object - The new object to be registered in the hierarchy.

referenceCount

public int referenceCount()
Description copied from interface: ICOSContainer
The number of references to the contained object. This method returns -1 when the value can not be determined (as for indirect objects parsed from a file).

Specified by:
referenceCount in interface ICOSContainer
Returns:
The number of references to the contained object.

saveStateContainer

public ICOSContainer saveStateContainer()
Description copied from interface: ICOSContainer
Create a save state for the container when saving the COSObject state.

Specified by:
saveStateContainer in interface ICOSContainer
Returns:
The save state for the container.

restoreStateContainer

public ICOSContainer restoreStateContainer(ICOSContainer pContainer)
Description copied from interface: ICOSContainer
Restore the save state for the container.

Specified by:
restoreStateContainer in interface ICOSContainer
Returns:
The "before" state of the receiver.

intarsys PDF library API

Copyright © 2006 intarsys consulting GmbH. All Rights Reserved.