Package org.apache.pdfbox.cos
Class COSIncrement
- java.lang.Object
-
- org.apache.pdfbox.cos.COSIncrement
-
- All Implemented Interfaces:
java.lang.Iterable<COSBase>
public class COSIncrement extends java.lang.Object implements java.lang.Iterable<COSBase>
ACOSIncrementstarts at a givenCOSUpdateInfoto collect updates, that have been made to aCOSDocumentand therefore should be added to it´s next increment.- See Also:
COSUpdateState,COSUpdateInfo
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<COSBase>excludedprivate COSUpdateInfoincrementOriginContains theCOSUpdateInfothat thisCOSIncrementcreates an increment for.private booleaninitializedWhether thisCOSIncrementhas already been determined, or must still be evaluated.private java.util.Set<COSBase>objectsContains theCOSBases, that shall be added to the increment at top level.private java.util.Set<COSObject>processedObjectsContains allCOSObjects, that have already been processed by thisCOSIncrementand shall not be processed again.
-
Constructor Summary
Constructors Constructor Description COSIncrement(COSUpdateInfo incrementOrigin)Creates a newCOSIncrementfor the givenCOSUpdateInfo, the increment will use it´sCOSDocumentStateas it´s own origin and shall collect all updates contained in the givenCOSUpdateInfo.
Should the given object benull, the resulting increment shall be empty.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidadd(COSBase object)The given object and actual {COSBase}s shall be part of the increment and must be added toobjects, if possible.
nullvalues shall be skipped.private voidaddProcessedObject(COSObject base)The givenCOSObjecthas been processed, or is being processed.private booleancollect(COSArray array)Collect all updates made to the givenCOSArrayand it's contained structures.private booleancollect(COSBase base)Collect all updates made to the givenCOSBaseand it's contained structures.
This shall forward allCOSUpdateInfoobjects to the proper specialized collection methods.private booleancollect(COSDictionary dictionary)Collect all updates made to the givenCOSDictionaryand it's contained structures.private booleancollect(COSObject object)Collect all updates made to the givenCOSObjectand it's contained structures.booleancontains(COSBase base)COSIncrementexclude(COSBase... base)java.util.Set<COSBase>getObjects()private booleanisExcluded(COSBase base)java.util.Iterator<COSBase>iterator()Return an iterator for the determinedobjectscontained in thisCOSIncrement.private voidupdateDifferentOrigin(COSUpdateState updateState)Check whether the givenCOSUpdateState´sCOSDocumentStatediffers from theCOSIncrement´s knownincrementOrigin.
Should that be the case, theCOSUpdateStateoriginates from anotherCOSDocumentand must be added to theCOSIncrement, hence callCOSUpdateState.update().
-
-
-
Field Detail
-
objects
private final java.util.Set<COSBase> objects
Contains theCOSBases, that shall be added to the increment at top level.
-
excluded
private final java.util.Set<COSBase> excluded
-
processedObjects
private final java.util.Set<COSObject> processedObjects
Contains allCOSObjects, that have already been processed by thisCOSIncrementand shall not be processed again.
-
incrementOrigin
private final COSUpdateInfo incrementOrigin
Contains theCOSUpdateInfothat thisCOSIncrementcreates an increment for.
-
initialized
private boolean initialized
Whether thisCOSIncrementhas already been determined, or must still be evaluated.
-
-
Constructor Detail
-
COSIncrement
public COSIncrement(COSUpdateInfo incrementOrigin)
Creates a newCOSIncrementfor the givenCOSUpdateInfo, the increment will use it´sCOSDocumentStateas it´s own origin and shall collect all updates contained in the givenCOSUpdateInfo.
Should the given object benull, the resulting increment shall be empty.- Parameters:
incrementOrigin- TheCOSUpdateInfoserving as an update source for thisCOSIncrement.
-
-
Method Detail
-
collect
private boolean collect(COSBase base)
Collect all updates made to the givenCOSBaseand it's contained structures.
This shall forward allCOSUpdateInfoobjects to the proper specialized collection methods.- Parameters:
base- TheCOSBaseupdates shall be collected for.- Returns:
- Returns
true, if theCOSBaserepresents a direct child structure, that would require it´s parent to be updated instead. - See Also:
collect(COSDictionary),collect(COSArray),collect(COSObject)
-
collect
private boolean collect(COSDictionary dictionary)
Collect all updates made to the givenCOSDictionaryand it's contained structures.- Parameters:
dictionary- TheCOSDictionaryupdates shall be collected for.- Returns:
- Returns
true, if theCOSDictionaryrepresents a direct child structure, that would require it´s parent to be updated instead.
-
collect
private boolean collect(COSArray array)
Collect all updates made to the givenCOSArrayand it's contained structures.- Parameters:
array- TheCOSDictionaryupdates shall be collected for.- Returns:
- Returns
true, if theCOSArray´s elements changed. ACOSArrayshall always be treated as a direct structure, that would require it´s parent to be updated instead.
-
collect
private boolean collect(COSObject object)
Collect all updates made to the givenCOSObjectand it's contained structures.
-
contains
public boolean contains(COSBase base)
- Parameters:
base- TheCOSBaseto check.- Returns:
true, if the givenCOSBaseis already known to and has been processed by thisCOSIncrement.- See Also:
objects,processedObjects
-
updateDifferentOrigin
private void updateDifferentOrigin(COSUpdateState updateState)
Check whether the givenCOSUpdateState´sCOSDocumentStatediffers from theCOSIncrement´s knownincrementOrigin.
Should that be the case, theCOSUpdateStateoriginates from anotherCOSDocumentand must be added to theCOSIncrement, hence callCOSUpdateState.update().- Parameters:
updateState- TheCOSUpdateStatethat shall be updated, if it's originating from anotherCOSDocument.- See Also:
incrementOrigin
-
add
private void add(COSBase object)
The given object and actual {COSBase}s shall be part of the increment and must be added toobjects, if possible.
nullvalues shall be skipped.
-
addProcessedObject
private void addProcessedObject(COSObject base)
The givenCOSObjecthas been processed, or is being processed. It shall be added toprocessedObjectsto skip it, should it be encountered again.
nullvalues shall be ignored.- Parameters:
base- TheCOSObjectto add toprocessedObjects.- See Also:
processedObjects
-
exclude
public COSIncrement exclude(COSBase... base)
The givenCOSBases are not fit for inclusion in an increment and shall be added toexcluded.
nullvalues shall be ignored.- Parameters:
base- TheCOSBases to add toexcluded.- Returns:
- The
COSIncrementitself, to allow method chaining. - See Also:
excluded
-
isExcluded
private boolean isExcluded(COSBase base)
-
getObjects
public java.util.Set<COSBase> getObjects()
-
iterator
public java.util.Iterator<COSBase> iterator()
Return an iterator for the determinedobjectscontained in thisCOSIncrement.- Specified by:
iteratorin interfacejava.lang.Iterable<COSBase>- Returns:
- An iterator for the determined
objectscontained in thisCOSIncrement.
-
-