public class COSDocument extends Object implements ICOSContainer, ICOSExceptionHandler, de.intarsys.tools.attribute.IAttributeSupport, de.intarsys.tools.locator.ILocatorSupport
COSObject instances. These objects are arranged
according to the PDF file format specification.
See PDF File Format Specification [PDF].
| Modifier and Type | Field and Description |
|---|---|
static Object |
SLOT_ALL
A dummy object indicating a unconstrained change
|
static Object |
SLOT_DIRTY |
static Object |
SLOT_LOCATOR |
static Object |
SLOT_TRAILER |
| Modifier and Type | Method and Description |
|---|---|
void |
add(COSDocumentElement element)
This should not be used by the application programmer.
|
void |
addDocumentListener(ICOSDocumentListener listener)
Add an
ICOSDocumentListener to be informed about the documents
events. |
void |
addMonitor(ICOSMonitor listener) |
ICOSContainer |
associate(ICOSContainer newContainer,
COSObject object)
This method should not be used by the application programmer.
|
void |
close()
Close the document.
|
COSDocumentElement |
containable(COSObject object)
This method should not be used by the application programmer.
|
COSDocument |
copyDeep()
Make a deep copy of the receiver.
|
static COSDocument |
createFromLocator(de.intarsys.tools.locator.ILocator locator) |
static COSDocument |
createFromLocator(de.intarsys.tools.locator.ILocator locator,
Map options)
Create a COSDocument based on a Locator.
|
static COSDocument |
createFromST(STDocument doc)
Create a COSDocument based on a STDocument.
|
static COSDocument |
createNew()
Create a new empty PDF COSDocument.
|
static COSDocument |
createNew(STDocType docType)
Create a new empty COSDocument.
|
ICOSContainer |
disassociate(ICOSContainer oldContainer,
COSObject object)
This method should not be used by the application programmer.
|
IAccessPermissions |
getAccessPermissions()
The currently active access permissions if supported by the
ISecurityHandler. |
Object |
getAttribute(Object key) |
COSCatalog |
getCatalog()
Get the root object (the catalog) for the document.
|
COSDocument |
getDoc()
This method should not be used by the application programmer.
|
ICOSExceptionHandler |
getExceptionHandler() |
int |
getIncrementalCount()
The number of versions created for this document so far.
|
COSInfoDict |
getInfoDict()
Get the info dictionary containing metadata.
|
de.intarsys.tools.locator.ILocator |
getLocator()
The
ILocator for this document. |
String |
getName()
The document name.
|
COSTrailer |
getTrailer()
The trailer for the document.
|
EnumWriteMode |
getWriteModeHint()
The write mode to be used when the document is written the next time.
|
void |
handleException(COSRuntimeException ex)
Handle
ex, optionally rethrow. |
void |
harden(COSObject object)
"Harden" the reference to
object, keeping it from being
garbage collected even if (temporarily) not accessed. |
boolean |
isAutoUpdate()
When auto update is true, the
COSWriter will automatically create
new values for the file modification date in the info dictionary and the
file id in the trailer. |
boolean |
isDirty()
Answer
true if the document has changes to be committed. |
boolean |
isEncrypted()
Answer
true if the document is encrypted. |
boolean |
isNew()
Answer
true if the document is new, i.e. not yet written. |
boolean |
isReadOnly()
Answer
true if the document is read only. |
Iterator<COSObject> |
objects()
An iterator on all COSObject instances of this that are managed as
indirect objects in the storage layer.
|
int |
referenceCount()
This method should not be used by the application programmer.
|
COSIndirectObject |
referenceIndirect(COSObject object)
This method should not be used by the application programmer.
|
void |
register(COSDocumentElement object)
This method should not be used by the application programmer.
|
Object |
removeAttribute(Object key) |
void |
removeDocumentListener(ICOSDocumentListener listener)
Remove an
ICOSDocumentListener. |
void |
removeMonitor(ICOSMonitor monitor) |
void |
restore(de.intarsys.tools.locator.ILocator locator)
Restore this from a locator.
|
ICOSContainer |
restoreStateContainer(ICOSContainer container)
This method should not be used by the application programmer.
|
void |
save()
Save the document to its current
ILocator. |
void |
save(de.intarsys.tools.locator.ILocator locator)
Save the document nto a new
ILocator. |
void |
save(de.intarsys.tools.locator.ILocator locator,
Map options)
Save the document to an optional new
ILocator using the
options to control specific serializing behavior such as
"incremental writing". |
ICOSContainer |
saveStateContainer()
This method should not be used by the application programmer.
|
Object |
setAttribute(Object key,
Object value) |
void |
setAutoUpdate(boolean autoUpdate) |
void |
setCatalog(COSCatalog catalog)
Assign a new catalog (/Root entry in the trailer).
|
void |
setExceptionHandler(ICOSExceptionHandler exceptionHandler) |
void |
setInfoDict(COSInfoDict infoDict)
Set the info dictionary containing metadata.
|
void |
setName(String name)
Assign a new name to the document.
|
void |
setWriteModeHint(EnumWriteMode writeMode)
The write mode to be used when the document is written the next time.
|
void |
soften(COSObject object)
"Soften" the reference to
object, making it accessible
for swapping out / garbage collection if the counter for hardening is
zero. |
STDocument |
stGetDoc()
The storage layer document.
|
void |
triggerChangedAll()
This method should not be used by the application programmer.
|
void |
willChange(COSObject change)
This method should not be used by the application programmer.
|
public static final Object SLOT_ALL
public static final Object SLOT_DIRTY
public static final Object SLOT_LOCATOR
public static final Object SLOT_TRAILER
public static COSDocument createFromLocator(de.intarsys.tools.locator.ILocator locator) throws IOException, COSLoadException
IOExceptionCOSLoadExceptionpublic static COSDocument createFromLocator(de.intarsys.tools.locator.ILocator locator, Map options) throws IOException, COSLoadException
locator - The ILocater referencing the documents data stream.COSLoadExceptionIOExceptionpublic static COSDocument createFromST(STDocument doc) throws COSLoadException
doc - The storage layer document.COSLoadExceptionpublic static COSDocument createNew()
public static COSDocument createNew(STDocType docType)
public void add(COSDocumentElement element)
public for package visibility reasons.element - public void addDocumentListener(ICOSDocumentListener listener)
ICOSDocumentListener to be informed about the documents
events.listener - THe new listenerpublic void addMonitor(ICOSMonitor listener)
public ICOSContainer associate(ICOSContainer newContainer, COSObject object)
COSObject lifecycle to ensure internal consistency.associate in interface ICOSContainerICOSContainer for objectpublic void close()
throws IOException
close.IOExceptionpublic COSDocumentElement containable(COSObject object)
COSObject lifecycle to ensure internal consistency.containable in interface ICOSContainerobject - THe object whose containable is requested.public COSDocument copyDeep()
public ICOSContainer disassociate(ICOSContainer oldContainer, COSObject object)
COSObject lifecycle to ensure internal consistency.disassociate in interface ICOSContainerICOSContainer for objectpublic IAccessPermissions getAccessPermissions()
ISecurityHandler.ISecurityHandler.public Object getAttribute(Object key)
getAttribute in interface de.intarsys.tools.attribute.IAttributeSupportpublic COSCatalog getCatalog()
public COSDocument getDoc()
COSObject lifecycle to ensure internal consistency.getDoc in interface ICOSContainerpublic ICOSExceptionHandler getExceptionHandler()
public int getIncrementalCount()
public COSInfoDict getInfoDict()
public de.intarsys.tools.locator.ILocator getLocator()
ILocator for this document. The ILocator designates
the physical storage for the PDF data.getLocator in interface de.intarsys.tools.locator.ILocatorSupportILocator for this document.public String getName()
ILocator.public COSTrailer getTrailer()
public EnumWriteMode getWriteModeHint()
public void handleException(COSRuntimeException ex) throws COSRuntimeException
ICOSExceptionHandlerex, optionally rethrow.handleException in interface ICOSExceptionHandlerex - The exceptioin to be handeled.COSRuntimeExceptionpublic void harden(COSObject object)
ICOSContainerobject, keeping it from being
garbage collected even if (temporarily) not accessed. Otherwise a
container may decide to "swap" its descendants out of memory.
Hardening uses a counter to decide if a strong reference can be finally released.
harden in interface ICOSContainerobject - The object that should be kept in memory.public boolean isAutoUpdate()
COSWriter will automatically create
new values for the file modification date in the info dictionary and the
file id in the trailer. When false, these values are under client code
control.public boolean isDirty()
true if the document has changes to be committed.true if the document has changes to be
committed.public boolean isEncrypted()
true if the document is encrypted.true if the document is encrypted.public boolean isNew()
true if the document is new, i.e. not yet written.true if the document is new, i.e. not yet
written.public boolean isReadOnly()
true if the document is read only. To save the
document and its changes you have to define another ILocator when
saving.true if the document is read only.public Iterator<COSObject> objects()
ATTENTION: This iterator may (and on incremental documents most often will) return objects that are no longer used (referenced) in the document.
public int referenceCount()
COSObject lifecycle to ensure internal consistency.referenceCount in interface ICOSContainerpublic COSIndirectObject referenceIndirect(COSObject object)
COSObject lifecycle to ensure internal consistency.referenceIndirect in interface ICOSContainerobject - The object to be indirectpublic void register(COSDocumentElement object)
COSObject lifecycle to ensure internal consistency.register in interface ICOSContainerobject - The new object to be registered in the hierarchy.public Object removeAttribute(Object key)
removeAttribute in interface de.intarsys.tools.attribute.IAttributeSupportpublic void removeDocumentListener(ICOSDocumentListener listener)
ICOSDocumentListener.listener - The listener to be removedpublic void removeMonitor(ICOSMonitor monitor)
public void restore(de.intarsys.tools.locator.ILocator locator)
throws IOException,
COSLoadException
ILocator must reference a data
stream that was previously used to parse the document.locator - The ILocator defining the new physical content.IOExceptionCOSLoadExceptionpublic ICOSContainer restoreStateContainer(ICOSContainer container)
COSObject lifecycle to ensure internal consistency.restoreStateContainer in interface ICOSContainerpublic void save()
throws IOException
ILocator.IOExceptionpublic void save(de.intarsys.tools.locator.ILocator locator)
throws IOException
ILocator.locator - The ILocator defining the new data location.IOExceptionpublic void save(de.intarsys.tools.locator.ILocator locator,
Map options)
throws IOException
ILocator using the
options to control specific serializing behavior such as
"incremental writing".locator - options - IOExceptionpublic ICOSContainer saveStateContainer()
COSObject lifecycle to ensure internal consistency.saveStateContainer in interface ICOSContainerpublic Object setAttribute(Object key, Object value)
setAttribute in interface de.intarsys.tools.attribute.IAttributeSupportpublic void setAutoUpdate(boolean autoUpdate)
public void setCatalog(COSCatalog catalog)
catalog - The new catalog.public void setExceptionHandler(ICOSExceptionHandler exceptionHandler)
public void setInfoDict(COSInfoDict infoDict)
infoDict - The info dictionary containing metadata.public void setName(String name)
name - The new name.public void setWriteModeHint(EnumWriteMode writeMode)
writeMode - The write mode to be used when the document is written.public void soften(COSObject object)
ICOSContainerobject, making it accessible
for swapping out / garbage collection if the counter for hardening is
zero.soften in interface ICOSContainerobject - The object that should be kept in memory.public STDocument stGetDoc()
public void triggerChangedAll()
COSObject lifecycle to ensure internal consistency.public void willChange(COSObject change)
COSObject lifecycle to ensure internal consistency.willChange in interface ICOSContainerCopyright © 2013 intarsys consulting GmbH. All Rights Reserved.