Class AnnotationValidator
- java.lang.Object
-
- org.apache.pdfbox.preflight.annotation.AnnotationValidator
-
- Direct Known Subclasses:
FreeTextAnnotationValidator
,InkAnnotationValidator
,LineAnnotationValidator
,LinkAnnotationValidator
,MarkupAnnotationValidator
,PopupAnnotationValidator
,PrintMarkAnnotationValidator
,RubberStampAnnotationValidator
,SquareCircleAnnotationValidator
,TextAnnotationValidator
,TrapNetAnnotationValidator
,WidgetAnnotationValidator
public abstract class AnnotationValidator extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected COSDictionary
annotDictionary
COSDictionary of the annotationprivate AnnotationValidatorFactory
annotFact
private COSDocument
cosDocument
protected PreflightContext
ctx
protected PDAnnotation
pdAnnot
Instance of PDAnnotation built using the annotDictionary
-
Constructor Summary
Constructors Constructor Description AnnotationValidator(PreflightContext context, COSDictionary annotDictionary)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
checkActions()
Extract a list of ActionManager from the Annotation dictionary and valid them.protected boolean
checkAP()
This method checks the AP entry of the Annotation Dictionary.protected boolean
checkCA()
Check if the CA value is 1.0.protected boolean
checkColors()
Return true if the C field is present in the Annotation dictionary and if the RGB profile is used in the DestOutputProfile of the OutputIntent dictionary.protected boolean
checkFlags()
Checks if flags of the annotation are authorized.protected boolean
checkMandatoryFields()
Checks if all mandatory fields of an annotation are present.protected boolean
checkPopup()
This method validates the Popup entry.protected boolean
checkSpecificMandatoryFields()
Override this method to check the presence of specific fieldsprivate COSBase
getFieldType()
protected boolean
searchRGBProfile()
Search the RGB Profile in OutputIntents dictionariesvoid
setFactory(AnnotationValidatorFactory fact)
Initialize the annotFact attribute of this object.boolean
validate()
Execute validation of the Annotation dictionary.
-
-
-
Field Detail
-
annotFact
private AnnotationValidatorFactory annotFact
-
ctx
protected PreflightContext ctx
-
cosDocument
private COSDocument cosDocument
-
annotDictionary
protected COSDictionary annotDictionary
COSDictionary of the annotation
-
pdAnnot
protected PDAnnotation pdAnnot
Instance of PDAnnotation built using the annotDictionary
-
-
Constructor Detail
-
AnnotationValidator
public AnnotationValidator(PreflightContext context, COSDictionary annotDictionary)
-
-
Method Detail
-
checkFlags
protected boolean checkFlags()
Checks if flags of the annotation are authorized.- Print flag must be 1
- NoView flag must be 0
- Hidden flag must be 0
- Invisible flag must be 0
- Returns:
- false if a flag is invalid, true otherwise.
-
checkCA
protected boolean checkCA()
Check if the CA value is 1.0. Return true if the CA element is missing or if the value is 1.0. Return false otherwise and update the list of errors present in the DocumentHandler.- Returns:
- true if the CA element is missing or if the value is 1.0.
-
checkColors
protected boolean checkColors() throws ValidationException
Return true if the C field is present in the Annotation dictionary and if the RGB profile is used in the DestOutputProfile of the OutputIntent dictionary.- Returns:
- true if the C field is present and the RGB profile is used.
- Throws:
ValidationException
-
searchRGBProfile
protected boolean searchRGBProfile() throws ValidationException
Search the RGB Profile in OutputIntents dictionaries- Returns:
- true if a rgb profile is found, false otherwise.
- Throws:
ValidationException
-
checkAP
protected boolean checkAP() throws ValidationException
This method checks the AP entry of the Annotation Dictionary. If the AP key is missing, this method returns true. If the AP key exists, only the N entry is authorized and must be a Stream which define the appearance of the annotation. (Currently, only the type of the N entry is checked because of the Appearance stream is a Form XObject, so it will be checked by the Graphics Helper) If the AP content isn't valid, this method return false and updates the errors list.- Returns:
- the validation state of the AP content.
- Throws:
ValidationException
-
checkActions
protected boolean checkActions() throws ValidationException
Extract a list of ActionManager from the Annotation dictionary and valid them. If an action is invalid, the errors list is updated and the method returns false. Otherwise, the method returns true and the errors list doesn't change.- Returns:
- the validation state of the annotations actions.
- Throws:
ValidationException
-
checkPopup
protected boolean checkPopup() throws ValidationException
This method validates the Popup entry. This entry shall contain an other Annotation. This annotation is validated with the right AnnotationValidator.- Returns:
- true if the popup entry is valid, false if not.
- Throws:
ValidationException
-
validate
public boolean validate() throws ValidationException
Execute validation of the Annotation dictionary.- Returns:
- true if validation succeed, false otherwise.
- Throws:
ValidationException
-
checkMandatoryFields
protected boolean checkMandatoryFields()
Checks if all mandatory fields of an annotation are present. If some fields are missing, the method returns false and the errors list is updated.- Returns:
- true if validation succeed, false otherwise.
-
checkSpecificMandatoryFields
protected boolean checkSpecificMandatoryFields()
Override this method to check the presence of specific fields- Returns:
- the presence of specific fields.
-
setFactory
public final void setFactory(AnnotationValidatorFactory fact)
Initialize the annotFact attribute of this object. This method must be called by the Factory at the creation of this object. Only the Factory should call this method.- Parameters:
fact
-
-
getFieldType
private COSBase getFieldType()
-
-