Top Description Fields Constructors Methods
org.apache.pdfbox.cos

public Class COSIncrement

extends Object
implements Iterable<COSBase>
Class Inheritance
All Implemented Interfaces
java.lang.Iterable
Imports
java.util.Arrays, .HashSet, .Iterator, .LinkedHashSet, .Set

A COSIncrement starts at a given COSUpdateInfo to collect updates, that have been made to a COSDocument and therefore should be added to it´s next increment.
Author
Christian Appl
See Also
COSUpdateState, COSUpdateInfo

Field Summary

Modifier and TypeField and Description
private final Set<COSBase>
excluded

Contains the direct COSBases, that are either contained written directly by structures contained in objects or that must be excluded from being written as indirect COSObjects for other reasons.

private final COSUpdateInfo
incrementOrigin

Contains the COSUpdateInfo that this COSIncrement creates an increment for.

private boolean
initialized

Whether this COSIncrement has already been determined, or must still be evaluated.

private final Set<COSBase>
objects

Contains the COSBases, that shall be added to the increment at top level.

private final Set<COSObject>
processedObjects

Contains all COSObjects, that have already been processed by this COSIncrement and shall not be processed again.

Constructor Summary

AccessConstructor and Description
public
COSIncrement(COSUpdateInfo
The COSUpdateInfo serving as an update source for this COSIncrement.
incrementOrigin
)

Creates a new COSIncrement for the given COSUpdateInfo, the increment will use it´s COSDocumentState as it´s own origin and shall collect all updates contained in the given COSUpdateInfo.

Method Summary

Modifier and TypeMethod and Description
private void
add(COSBase
The COSBase to add to objects.
object
)

The given object and actual {COSBase}s shall be part of the increment and must be added to objects, if possible.

private void
addProcessedObject(COSObject base)

The given COSObject has been processed, or is being processed.

private boolean

Returns:

Returns true, if the COSBase represents a direct child structure, that would require it´s parent to be updated instead.
collect
(COSBase
The COSBase updates shall be collected for.
base
)

Collect all updates made to the given COSBase and it's contained structures.

private boolean

Returns:

Returns true, if the COSDictionary represents a direct child structure, that would require it´s parent to be updated instead.
collect
(COSDictionary
The COSDictionary updates shall be collected for.
dictionary
)

Collect all updates made to the given COSDictionary and it's contained structures.

private boolean

Returns:

Returns true, if the COSArray´s elements changed. A COSArray shall always be treated as a direct structure, that would require it´s parent to be updated instead.
collect
(COSArray
The COSDictionary updates shall be collected for.
array
)

Collect all updates made to the given COSArray and it's contained structures.

private boolean

Returns:

Always returns false. COSObjects by definition are indirect and shall never cause a parent structure to be updated.
collect
(COSObject
The COSObject updates shall be collected for.
object
)

Collect all updates made to the given COSObject and it's contained structures.

public boolean

Returns:

true, if the given COSBase is already known to and has been processed by this COSIncrement.
contains
(COSBase
The COSBase to check.
base
)

Returns true, if the given COSBase is already known to and has been processed by this COSIncrement.

public COSIncrement

Returns:

The COSIncrement itself, to allow method chaining.
exclude
(COSBase...
The COSBases to add to excluded.
base
)

The given COSBases are not fit for inclusion in an increment and shall be added to excluded.

public Set<COSBase>

Returns:

All indirect COSBases, that shall be written to an increment as top level COSObjects.
getObjects
()

Returns all indirect COSBases, that shall be written to an increment as top level COSObjects.

private boolean

Returns:

true, if the given COSBase has been excluded from the increment, and hence is contained in excluded.
isExcluded
(COSBase
The COSBase to check for exclusion.
base
)

Returns true, if the given COSBase has been excluded from the increment, and hence is contained in excluded.

public Iterator<COSBase>

Returns:

An iterator for the determined objects contained in this COSIncrement.
iterator
()

Implements java.lang.Iterable.iterator.

Return an iterator for the determined objects contained in this COSIncrement.

private void
updateDifferentOrigin(COSUpdateState
The COSUpdateState that shall be updated, if it's originating from another COSDocument.
updateState
)

Check whether the given COSUpdateState´s COSDocumentState differs from the COSIncrement´s known incrementOrigin.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

excludedback to summary
private final Set<COSBase> excluded

Contains the direct COSBases, that are either contained written directly by structures contained in objects or that must be excluded from being written as indirect COSObjects for other reasons.

incrementOriginback to summary
private final COSUpdateInfo incrementOrigin

Contains the COSUpdateInfo that this COSIncrement creates an increment for.

initializedback to summary
private boolean initialized

Whether this COSIncrement has already been determined, or must still be evaluated.

objectsback to summary
private final Set<COSBase> objects

Contains the COSBases, that shall be added to the increment at top level.

processedObjectsback to summary
private final Set<COSObject> processedObjects

Contains all COSObjects, that have already been processed by this COSIncrement and shall not be processed again.

Constructor Detail

COSIncrementback to summary
public COSIncrement(COSUpdateInfo incrementOrigin)

Creates a new COSIncrement for the given COSUpdateInfo, the increment will use it´s COSDocumentState as it´s own origin and shall collect all updates contained in the given COSUpdateInfo.
Should the given object be null, the resulting increment shall be empty.

Parameters
incrementOrigin:COSUpdateInfo

The COSUpdateInfo serving as an update source for this COSIncrement.

Method Detail

addback to summary
private void add(COSBase object)

The given object and actual {COSBase}s shall be part of the increment and must be added to objects, if possible.
null values shall be skipped.

Parameters
object:COSBase

The COSBase to add to objects.

See Also
objects
addProcessedObjectback to summary
private void addProcessedObject(COSObject base)

The given COSObject has been processed, or is being processed. It shall be added to processedObjects to skip it, should it be encountered again.
null values shall be ignored.

Parameters
base:COSObject

The COSObject to add to processedObjects.

See Also
processedObjects
collectback to summary
private boolean collect(COSBase base)

Collect all updates made to the given COSBase and it's contained structures.
This shall forward all COSUpdateInfo objects to the proper specialized collection methods.

Parameters
base:COSBase

The COSBase updates shall be collected for.

Returns:boolean

Returns true, if the COSBase represents a direct child structure, that would require it´s parent to be updated instead.

See Also
collect(COSDictionary), collect(COSArray), collect(COSObject)
collectback to summary
private boolean collect(COSDictionary dictionary)

Collect all updates made to the given COSDictionary and it's contained structures.

Parameters
dictionary:COSDictionary

The COSDictionary updates shall be collected for.

Returns:boolean

Returns true, if the COSDictionary represents a direct child structure, that would require it´s parent to be updated instead.

collectback to summary
private boolean collect(COSArray array)

Collect all updates made to the given COSArray and it's contained structures.

Parameters
array:COSArray

The COSDictionary updates shall be collected for.

Returns:boolean

Returns true, if the COSArray´s elements changed. A COSArray shall always be treated as a direct structure, that would require it´s parent to be updated instead.

collectback to summary
private boolean collect(COSObject object)

Collect all updates made to the given COSObject and it's contained structures.

Parameters
object:COSObject

The COSObject updates shall be collected for.

Returns:boolean

Always returns false. COSObjects by definition are indirect and shall never cause a parent structure to be updated.

containsback to summary
public boolean contains(COSBase base)

Returns true, if the given COSBase is already known to and has been processed by this COSIncrement.

Parameters
base:COSBase

The COSBase to check.

Returns:boolean

true, if the given COSBase is already known to and has been processed by this COSIncrement.

See Also
objects, processedObjects
excludeback to summary
public COSIncrement exclude(COSBase... base)

The given COSBases are not fit for inclusion in an increment and shall be added to excluded.
null values shall be ignored.

Parameters
base:COSBase[]

The COSBases to add to excluded.

Returns:COSIncrement

The COSIncrement itself, to allow method chaining.

See Also
excluded
getObjectsback to summary
public Set<COSBase> getObjects()

Returns all indirect COSBases, that shall be written to an increment as top level COSObjects.
Calling this method will cause the increment to be initialized.

Returns:Set<COSBase>

All indirect COSBases, that shall be written to an increment as top level COSObjects.

See Also
objects
isExcludedback to summary
private boolean isExcluded(COSBase base)

Returns true, if the given COSBase has been excluded from the increment, and hence is contained in excluded.

Parameters
base:COSBase

The COSBase to check for exclusion.

Returns:boolean

true, if the given COSBase has been excluded from the increment, and hence is contained in excluded.

See Also
excluded
iteratorback to summary
public Iterator<COSBase> iterator()

Implements java.lang.Iterable.iterator.

Return an iterator for the determined objects contained in this COSIncrement.

Returns:Iterator<COSBase>

An iterator for the determined objects contained in this COSIncrement.

Annotations
@Override
updateDifferentOriginback to summary
private void updateDifferentOrigin(COSUpdateState updateState)

Check whether the given COSUpdateState´s COSDocumentState differs from the COSIncrement´s known incrementOrigin.
Should that be the case, the COSUpdateState originates from another COSDocument and must be added to the COSIncrement, hence call COSUpdateState#update().

Parameters
updateState:COSUpdateState

The COSUpdateState that shall be updated, if it's originating from another COSDocument.

See Also
incrementOrigin