Package com.inet.pdfc.generator.model
Class Modification
- java.lang.Object
-
- com.inet.pdfc.generator.model.Modification
-
- All Implemented Interfaces:
java.io.Serializable
@JsonData public class Modification extends java.lang.Object implements java.io.Serializable
AModification
is the smallest change description in the differences model of i-net PDFC. It contains a set of subsequent elements which were all modified in the same manner and thus are of the same basicElementType
. 'Subsequent' refers here to left-to-right top-down order which i-net PDFC assumes as reading order. This order might by modified by filter (e.G. the 'multi column' filter), so please mind that this 'reading order' is not necessarily a strict Y-X order!
A modification can span several lines or whole pages. It's only restricted by another modification or a set of matched elements.- Since:
- 3.0
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Modification.ModificationType
The type of the modification which side has modifications and whether the changes do apply- This is loosely coupled to the severity type ofDiffGroup
s.
-
Constructor Summary
Constructors Constructor Description Modification(DiffGroup.GroupType sourceType, com.inet.pdfc.model.PagedElement affectedFirst, com.inet.pdfc.model.PagedElement affectedSecond, java.util.List<AttributeDifference<?>> changes)
Creates a modification description for a pair of elements.Modification(DiffGroup.GroupType sourceType, java.util.List<com.inet.pdfc.model.PagedElement> affectedFirst, java.util.List<com.inet.pdfc.model.PagedElement> affectedSecond, java.util.List<AttributeDifference<?>> changes)
Creates a modification description for a list of elements.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<com.inet.pdfc.model.PagedElement>
getAffectedElements(boolean first)
Returns a list of element, affected by this modification in either document<T extends AttributeDifference<?>>
TgetAttributeDifference(java.lang.Class<T> type)
Returns a certain tyoe of changes which was applied to all affected elements.java.util.List<AttributeDifference<?>>
getAttributeDifferences()
Returns a list of changes which was applied to all affected elements.com.inet.pdfc.model.ElementType
getContentType()
Returns the base type of the elements in this modification.DifferencePages
getDifferencePages(boolean first)
Return the difference pageNumbers or null if no elements exist for this documentjava.lang.String
getMessage()
Returns a log message which describes this modification.Modification.ModificationType
getModificationType()
Returns the type of modification described by this instanceDiffGroup.GroupType
getSourceType()
boolean
isShouldPageElementMerge()
A flag, for merge the pageElements to one elementsboolean
isVisible()
Returns whether or not this difference will be displayed in any rendered output.void
setShouldMerge(boolean shouldMerge)
A flag, for merge the pageElements to one elementsvoid
setVisible(boolean visible)
Defines whether or not this difference will be displayed in any rendered output.java.lang.String
toString()
-
-
-
Constructor Detail
-
Modification
public Modification(DiffGroup.GroupType sourceType, java.util.List<com.inet.pdfc.model.PagedElement> affectedFirst, java.util.List<com.inet.pdfc.model.PagedElement> affectedSecond, java.util.List<AttributeDifference<?>> changes)
Creates a modification description for a list of elements.- Parameters:
sourceType
- the sourceDiffGroup.GroupType
type, must not benull
affectedFirst
- the affected elements in the first document, may benull
affectedSecond
- the affected elements in the second document, may benull
changes
- the list if attribute changes, must not be null or empty, if the sourceType isDiffGroup.GroupType.Modified
orDiffGroup.GroupType.MetadataChanged
- Throws:
java.lang.IllegalArgumentException
- in case of inconsistent data:- affected element on both sides to type
DiffGroup.GroupType.AddedOrRemoved
- no changes for type
DiffGroup.GroupType.MetadataChanged
orDiffGroup.GroupType.Modified
- changes for type
DiffGroup.GroupType.AddedOrRemoved
orDiffGroup.GroupType.Replaced
- affected element on both sides to type
- Since:
- 3.0
-
Modification
public Modification(DiffGroup.GroupType sourceType, com.inet.pdfc.model.PagedElement affectedFirst, com.inet.pdfc.model.PagedElement affectedSecond, java.util.List<AttributeDifference<?>> changes)
Creates a modification description for a pair of elements.- Parameters:
sourceType
- the sourceDiffGroup.GroupType
type, must not benull
affectedFirst
- the affected element in the first document, must not be notnull
affectedSecond
- the affected element in the second document, must not be notnull
changes
- the list if attribute changes, must not benull
or empty- Throws:
java.lang.IllegalArgumentException
- in case of inconsistent data:- no changes
- one of the affected elements is null
- Since:
- 3.0
-
-
Method Detail
-
setShouldMerge
public void setShouldMerge(boolean shouldMerge)
A flag, for merge the pageElements to one elements- Parameters:
shouldMerge
- true for merge all pageElements, otherwise false- Since:
- 4.3
-
isShouldPageElementMerge
public boolean isShouldPageElementMerge()
A flag, for merge the pageElements to one elements- Returns:
- true for merge all pageElements, otherwise false
- Since:
- 4.3
-
getModificationType
public Modification.ModificationType getModificationType()
Returns the type of modification described by this instance- Returns:
- the type of modification described by this instance
- Since:
- 3.0
- See Also:
Modification.ModificationType
-
getDifferencePages
public DifferencePages getDifferencePages(boolean first)
Return the difference pageNumbers or null if no elements exist for this document- Parameters:
first
-true
for the first document,false
- Returns:
- the difference pageNumbers
- Since:
- 4.0
-
getSourceType
public DiffGroup.GroupType getSourceType()
- Returns:
DiffGroup.GroupType
of theDiffGroup
which contains thisModification
- Since:
- 3.0
- See Also:
DiffGroup.GroupType
-
getAffectedElements
public java.util.List<com.inet.pdfc.model.PagedElement> getAffectedElements(boolean first)
Returns a list of element, affected by this modification in either document- Parameters:
first
- true to get the effected element in the first document, false for the second document- Returns:
- a list of affected elements, never
null
but may be empty - Since:
- 3.0
-
getContentType
public com.inet.pdfc.model.ElementType getContentType()
Returns the base type of the elements in this modification. This type can be used as a guideline for the formatter of this modification.
As a general contract: all effected elements fulfill the condition '- Returns:
- the base element type of this modification.
- Since:
- 3.0
-
getAttributeDifferences
public java.util.List<AttributeDifference<?>> getAttributeDifferences()
Returns a list of changes which was applied to all affected elements. This method will only return a list if theModification.ModificationType
isModification.ModificationType.attributeDifference
, otherwise it will returnnull
.
NOTE: Each differnces in the returned list is of a different class. Please have a loot at thecom.inet.pdfc.generator.model.diff
package for all available types.- Returns:
- the changes made to the elements, may be
null
- Since:
- 3.0
-
getAttributeDifference
public <T extends AttributeDifference<?>> T getAttributeDifference(java.lang.Class<T> type)
Returns a certain tyoe of changes which was applied to all affected elements. This method will only return aAttributeDifference
if theModification.ModificationType
isModification.ModificationType.attributeDifference
and there is a change of exactly that type, otherwise it will returnnull
.- Type Parameters:
T
- the actual difference implementation type- Parameters:
type
- the exact type of theAttributeDifference
to get- Returns:
- the change made to the elements, may be
null
- Since:
- 3.0
-
getMessage
public java.lang.String getMessage()
Returns a log message which describes this modification. The message will be localized using the defaultLocale
.
This message is meant for convenience and is equal to
new ModificationFormatter().format( this )
- Returns:
- a localized modification message
- Since:
- 3.0
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
isVisible
public boolean isVisible()
Returns whether or not this difference will be displayed in any rendered output. This flag is an addition to the visibility of the differentDiffGroup.GroupType
s to allow to hide distinct differences.- Returns:
true
if the difference is to be rendered,false
if the difference must not be shown in any graphical output- Since:
- 20.04
-
setVisible
public void setVisible(boolean visible)
Defines whether or not this difference will be displayed in any rendered output. This flag is an addition to the visibility of the differentDiffGroup.GroupType
s to allow to hide distinct differences.- Parameters:
visible
-true
if the difference is to be rendered,false
if the difference must not be shown in any graphical output- Since:
- 20.04
-
-