org.icepdf.core.pobjects
Class StateManager

java.lang.Object
  extended by org.icepdf.core.pobjects.StateManager

public class StateManager
extends java.lang.Object

This class is responsible for keeping track of which object in the document have change. When a file is written to disk this class is used to find the object that should be written in the body section of the file as part of an incremental update.

Once this object is created should be added to the library so that is accessible by any PObject.

Since:
4.0

Constructor Summary
StateManager(PTrailer trailer)
          Creates a new instance of the state manager.
 
Method Summary
 void addChange(PObject pObject)
          Add a new PObject containing changed data to the cache.
 boolean contains(Reference reference)
          Checks the state manager to see if an instance of the specified reference already exists in the cache.
 java.lang.Object getChange(Reference reference)
          Returns an instance of the specified reference
 int getChangedSize()
          Gets the number of change object in the state manager.
 Reference getNewReferencNumber()
          Gets the next available reference number from the trailer.
 PTrailer getTrailer()
           
 boolean isChanged()
           
 java.util.Iterator<PObject> iteratorSortedByObjectNumber()
           
 void removeChange(PObject pObject)
          Remove a PObject from the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StateManager

public StateManager(PTrailer trailer)
Creates a new instance of the state manager.

Parameters:
trailer - document trailer
Method Detail

getNewReferencNumber

public Reference getNewReferencNumber()
Gets the next available reference number from the trailer.

Returns:
valid reference number.

addChange

public void addChange(PObject pObject)
Add a new PObject containing changed data to the cache.

Parameters:
pObject - object to add to cache.

contains

public boolean contains(Reference reference)
Checks the state manager to see if an instance of the specified reference already exists in the cache.

Parameters:
reference - reference to look for an existing usage.
Returns:
true if reference is already a key in the cache; otherwise, false.

getChange

public java.lang.Object getChange(Reference reference)
Returns an instance of the specified reference

Parameters:
reference - reference to look for an existing usage
Returns:
PObject of corresponding reference if present, false otherwise.

removeChange

public void removeChange(PObject pObject)
Remove a PObject from the cache.

Parameters:
pObject - pObject to removed from the cache.

isChanged

public boolean isChanged()
Returns:
If there are any changes

getChangedSize

public int getChangedSize()
Gets the number of change object in the state manager.

Returns:
zero or more changed object count.

iteratorSortedByObjectNumber

public java.util.Iterator<PObject> iteratorSortedByObjectNumber()
Returns:
An Iterator for all the changes objects, sorted

getTrailer

public PTrailer getTrailer()