PDF Clown
0.0.8

it.stefanochizzolini.clown.objects
Class PdfObjectWrapper<TDataObject extends PdfDataObject>

java.lang.Object
  extended by it.stefanochizzolini.clown.objects.PdfObjectWrapper<TDataObject>
Direct Known Subclasses:
Action, Annotation, AnnotationActions, Appearance, AppearanceCharacteristics, AppearanceCharacteristics.IconFitObject, AppearanceStates, Bookmark, Bookmarks, Border, CalloutNote.LineObject, ChainedActions, ChoiceItem, ChoiceItems, ColorSpace, ColorSpaceResources, Contents, Document, DocumentActions, EmbeddedFile, ExtGState, ExtGStateResources, Field, FieldActions, Fields, FieldWidgets, Font, FontResources, Form, GoToEmbedded.TargetObject, Information, Launch.WinParametersObject, Movie, Names, NameTree, Page, PageActions, PageAnnotations, Pages, PdfNamedObjectWrapper, Rectangle, RelatedFiles, Resources, Sound, Transition, ViewerPreferences, XObject, XObjectResources

public abstract class PdfObjectWrapper<TDataObject extends PdfDataObject>
extends Object

Base high-level representation of a PDF object. All specialized objects (e.g. Document, Page, Pages, ContentStream...) inherit from it.

Remarks

Somebody may wonder why I didn't directly make specialized objects inherit from their low-level counterparts (e.g. Page extends PdfDictionary, ContentStream extends PdfStream and so on): that could have been much smoother anyway, you argue. Yeah, I could agree if there was a plain one-to-one mapping between primitive PDF types and specialized instances, but (you know!) reality is not so polished as theory: the 'Content' entry of Page dictionaries may be a simple reference to a PdfStream or a PdfArray of references to PdfStream-s, Pages collections may be spread across a B-tree instead of a flat PdfArray etc. So: in order to hide all these annoying inner workings, I chose to adopt a composition pattern instead of the apparently-reasonable (but actually awkward!) inheritance pattern. Nonetheless, users are always enabled to navigate through the low-level structure accessing the getBaseDataObject() method.

Version:
0.0.7
Author:
Stefano Chizzolini (http://www.stefanochizzolini.it)

Constructor Summary
protected PdfObjectWrapper(File context, TDataObject baseDataObject)
           
protected PdfObjectWrapper(PdfDirectObject baseObject, PdfIndirectObject container)
           
 
Method Summary
abstract  Object clone(Document context)
          Gets a clone of the object, registered inside the given document context.
 boolean delete()
          Removes the object from its document context.
 TDataObject getBaseDataObject()
          Gets the underlying data object.
 PdfDirectObject getBaseObject()
          Gets the underlying reference object, if available; otherwise, behaves like getBaseDataObject().
 PdfIndirectObject getContainer()
          Gets the indirect object containing the base object.
 Document getDocument()
          Gets the document context.
 File getFile()
          Gets the file context.
protected  void setBaseObject(PdfDirectObject value)
           
 void setContainer(PdfIndirectObject value)
          For internal use only.
 void update()
          Manually update the underlying indirect object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PdfObjectWrapper

protected PdfObjectWrapper(File context,
                           TDataObject baseDataObject)

PdfObjectWrapper

protected PdfObjectWrapper(PdfDirectObject baseObject,
                           PdfIndirectObject container)
Parameters:
baseObject - Base PDF object. MUST be a PdfReference everytime available.
container - Indirect object containing the base object.
Method Detail

clone

public abstract Object clone(Document context)
Gets a clone of the object, registered inside the given document context.

Parameters:
context - Which document the clone has to be registered in.

delete

public boolean delete()
Removes the object from its document context.

Remarks

The object is no more usable after this method returns.

Returns:
Whether the object was actually decontextualized (only indirect objects can be decontextualized).

getBaseDataObject

public TDataObject getBaseDataObject()
Gets the underlying data object.


getBaseObject

public PdfDirectObject getBaseObject()
Gets the underlying reference object, if available; otherwise, behaves like getBaseDataObject().


getContainer

public PdfIndirectObject getContainer()
Gets the indirect object containing the base object.

Remarks

It's used for update purposes.


getDocument

public Document getDocument()
Gets the document context.


getFile

public File getFile()
Gets the file context.


update

public void update()
Manually update the underlying indirect object.


setBaseObject

protected void setBaseObject(PdfDirectObject value)

setContainer

public void setContainer(PdfIndirectObject value)
For internal use only.


PDF Clown
0.0.8

Project home page

Copyright © 2006-2010 Stefano Chizzolini. Some Rights Reserved.
This documentation is available under the terms of the GNU Free Documentation License.