pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gbaill...@apache.org
Subject svn commit: r1453416 [4/16] - in /pdfbox/trunk/preflight: ./ src/main/java/org/apache/pdfbox/preflight/ src/main/java/org/apache/pdfbox/preflight/action/ src/main/java/org/apache/pdfbox/preflight/annotation/ src/main/java/org/apache/pdfbox/preflight/an...
Date Wed, 06 Mar 2013 16:46:37 GMT
Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/UriAction.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/UriAction.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/UriAction.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/UriAction.java Wed Mar  6 16:46:35 2013
@@ -33,50 +33,49 @@ import org.apache.pdfbox.preflight.Valid
 import org.apache.pdfbox.preflight.utils.COSUtils;
 
 /**
- * ActionManager for the URI action URI action is valid if the URI entry is
- * present as a String.
+ * ActionManager for the URI action URI action is valid if the URI entry is present as a String.
  */
-public class UriAction extends AbstractActionManager {
+public class UriAction extends AbstractActionManager
+{
 
-  /**
-   * @param amFact
-   *          Instance of ActionManagerFactory used to create ActionManager to
-   *          check Next actions.
-   * @param adict
-   *          the COSDictionary of the action wrapped by this class.
-   * @param cDoc
-   *          the COSDocument from which the action comes from.
-   * @param aaKey
-   *          The name of the key which identify the action in a additional
-   *          action dictionary.
-   */
-  public UriAction(ActionManagerFactory amFact, COSDictionary adict,
-      PreflightContext ctx, String aaKey) {
-    super(amFact, adict, ctx, aaKey);
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see
-   * net.awl.edoc.pdfa.validation.actions.AbstractActionManager#valid(java.util
-   * .List)
-   */
-  @Override
-  protected boolean innerValid() {
-    COSBase uri = this.actionDictionnary.getItem(COSName.URI);
-    if (uri == null) {
-      context.addValidationError(new ValidationError(ERROR_ACTION_MISING_KEY,
-          "URI entry is mandatory for the UriAction"));
-      return false;
+    /**
+     * @param amFact
+     *            Instance of ActionManagerFactory used to create ActionManager to check Next actions.
+     * @param adict
+     *            the COSDictionary of the action wrapped by this class.
+     * @param cDoc
+     *            the COSDocument from which the action comes from.
+     * @param aaKey
+     *            The name of the key which identify the action in a additional action dictionary.
+     */
+    public UriAction(ActionManagerFactory amFact, COSDictionary adict, PreflightContext ctx, String aaKey)
+    {
+        super(amFact, adict, ctx, aaKey);
     }
 
-	COSDocument cosDocument = this.context.getDocument().getDocument();
-    if (!COSUtils.isString(uri, cosDocument)) {
-      context.addValidationError(new ValidationError(ERROR_ACTION_INVALID_TYPE, "URI entry should be a string"));
-      return false;
-    }
+    /*
+     * (non-Javadoc)
+     * 
+     * @see net.awl.edoc.pdfa.validation.actions.AbstractActionManager#valid(java.util .List)
+     */
+    @Override
+    protected boolean innerValid()
+    {
+        COSBase uri = this.actionDictionnary.getItem(COSName.URI);
+        if (uri == null)
+        {
+            context.addValidationError(new ValidationError(ERROR_ACTION_MISING_KEY,
+                    "URI entry is mandatory for the UriAction"));
+            return false;
+        }
 
-    return true;
-  }
+        COSDocument cosDocument = this.context.getDocument().getDocument();
+        if (!COSUtils.isString(uri, cosDocument))
+        {
+            context.addValidationError(new ValidationError(ERROR_ACTION_INVALID_TYPE, "URI entry should be a string"));
+            return false;
+        }
+
+        return true;
+    }
 }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/AnnotationValidator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/AnnotationValidator.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/AnnotationValidator.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/AnnotationValidator.java Wed Mar  6 16:46:35 2013
@@ -21,7 +21,6 @@
 
 package org.apache.pdfbox.preflight.annotation;
 
-
 import static org.apache.pdfbox.preflight.PreflightConfiguration.ACTIONS_PROCESS;
 import static org.apache.pdfbox.preflight.PreflightConfiguration.GRAPHIC_PROCESS;
 import static org.apache.pdfbox.preflight.PreflightConstants.ANNOT_DICTIONARY_VALUE_SUBTYPE_POPUP;
@@ -46,221 +45,240 @@ import org.apache.pdfbox.preflight.graph
 import org.apache.pdfbox.preflight.utils.COSUtils;
 import org.apache.pdfbox.preflight.utils.ContextHelper;
 
-public abstract class AnnotationValidator {
+public abstract class AnnotationValidator
+{
 
-	protected AnnotationValidatorFactory annotFact = null;
+    protected AnnotationValidatorFactory annotFact = null;
 
-	protected PreflightContext ctx = null;
-	protected COSDocument cosDocument = null;
-	/**
-	 * COSDictionary of the annotation
-	 */
-	protected COSDictionary annotDictionary = null;
-	/**
-	 * Instance of PDAnnotation built using the annotDictionary
-	 */
-	protected PDAnnotation pdAnnot = null;
-
-	public AnnotationValidator(PreflightContext context, COSDictionary annotDictionary) {
-		super();
-		this.ctx = context;
-		this.annotDictionary = annotDictionary;
-		this.cosDocument = this.ctx.getDocument().getDocument();
-	}
-
-	/**
-	 * Checks if flags of the annotation are authorized.
-	 * <UL>
-	 * <li>Print flag must be 1
-	 * <li>NoView flag must be 0
-	 * <li>Hidden flag must be 0
-	 * <li>Invisible flag must be 0
-	 * </UL>
-	 * If one of these flags is invalid, the errors list is updated with the
-	 * ERROR_ANNOT_FORBIDDEN_FLAG ValidationError code.
-	 * 
-	 * @return false if a flag is invalid, true otherwise.
-	 */
-	protected boolean checkFlags() {
-		boolean result = this.pdAnnot.isPrinted();
-		result = result && !this.pdAnnot.isHidden();
-		result = result && !this.pdAnnot.isInvisible();
-		result = result && !this.pdAnnot.isNoView();
-		if (!result) {
-			ctx.addValidationError(new ValidationError(ERROR_ANNOT_FORBIDDEN_FLAG, "Flags of " +  pdAnnot.getSubtype() + " annotation are invalid"));
-		}
-
-		return result;
-	}
-
-	/**
-	 * 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.
-	 * 
-	 * @return
-	 */
-	protected boolean checkCA() {
-		COSBase ca = this.pdAnnot.getDictionary().getItem(COSName.CA);
-		if (ca != null) {
-			float caf = COSUtils.getAsFloat(ca, cosDocument);
-			if (caf != 1.0f) { // ---- Only 1.0 is authorized as value
-				ctx.addValidationError(new ValidationError(ERROR_ANNOT_INVALID_CA, "CA entry is invalid. Expected 1.0 / Read " + caf));
-				return false;
-			}
-		} //else  optional field,  ok
-		return true;
-	}
-
-	/**
-	 * 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.
-	 * 
-	 * @return
-	 */
-	protected boolean checkColors() throws ValidationException {
-		if (this.pdAnnot.getColour() != null) {
-			if (!searchRGBProfile()) {
-				ctx.addValidationError(new ValidationError(ERROR_ANNOT_FORBIDDEN_COLOR,"Annotation uses a Color profile which isn't the same than the profile contained by the OutputIntent"));
-				return false;
-			}
-		}
-		return true;
-	}
-
-	/**
-	 * Search the RGB Profile in OutputIntents dictionaries
-	 * 
-	 * @return true if a rgb profile is found, false otherwise.
-	 */
-	protected boolean searchRGBProfile() throws ValidationException{
-		ICCProfileWrapper iccpw = ICCProfileWrapper.getOrSearchICCProfile(ctx);
-		if (iccpw != null) {
-			return iccpw.isRGBColorSpace();
-		}
-		return false;
-	}
-
-	/**
-	 * 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.
-	 * @return
-	 */
-	protected boolean checkAP() throws ValidationException {
-		PDAppearanceDictionary ap = this.pdAnnot.getAppearance();
-		if (ap != null) {
-			COSDictionary apDict = ap.getDictionary(); 
-			// Only N entry is authorized
-			if (apDict.getItem(COSName.D) != null || apDict.getItem(COSName.R) != null) {
-				ctx.addValidationError(new ValidationError(
-						ERROR_ANNOT_INVALID_AP_CONTENT,
-						"Only the N Appearance is authorized"));
-				return false;
-			} else if (apDict.getItem(COSName.N) == null) {
-				// N entry is required
-				ctx.addValidationError(new ValidationError(
-						ERROR_ANNOT_MISSING_AP_N_CONTENT,
-						"The N Appearance must be present"));
-				return false;
-			} else {
-				// the N entry must be a Stream (Dictionaries are forbidden)
-				COSBase apn = apDict.getItem(COSName.N);
-				if (!COSUtils.isStream(apn, cosDocument)) {
-					ctx.addValidationError(new ValidationError(
-							ERROR_ANNOT_INVALID_AP_CONTENT,
-							"The N Appearance must be a Stream"));
-					return false;
-				}
-
-				// Appearance stream is a XObjectForm, check it.
-				ContextHelper.validateElement(ctx, new PDXObjectForm(COSUtils.getAsStream(apn, cosDocument)), GRAPHIC_PROCESS);
-			}
-		} //else  ok, nothing to check,this field is optional
-		return true;
-	}
-
-	/**
-	 * 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.
-	 * 
-	 * @return
-	 * @throws ValidationException
-	 */
-	protected boolean checkActions() throws ValidationException {
-		ContextHelper.validateElement(ctx, annotDictionary, ACTIONS_PROCESS);
-		return true;
-	}
-
-	/**
-	 * This method validates the Popup entry. This entry shall contain an other
-	 * Annotation. This annotation is validated with the right
-	 * AnnotationValidator.
-	 * 
-	 * @param errors
-	 * @return
-	 * @throws ValidationException
-	 */
-	protected boolean checkPopup() throws ValidationException {
-		COSBase cosPopup = this.annotDictionary.getItem(ANNOT_DICTIONARY_VALUE_SUBTYPE_POPUP);
-		if (cosPopup != null) {
-			COSDictionary popupDict = COSUtils.getAsDictionary(cosPopup, cosDocument);
-			if (popupDict == null) {
-				ctx.addValidationError(new ValidationError(
-						ERROR_SYNTAX_DICT_INVALID,
-						"An Annotation has a Popup entry, but the value is missing or isn't a dictionary"));
-				return false;
-			}
-			AnnotationValidator popupVal = this.annotFact.getAnnotationValidator(ctx, popupDict);
-			return popupVal.validate();
-		}
-		return true;
-	}
-
-	/**
-	 * Execute validation of the Annotation dictionary.
-	 * 
-	 * @return true if validation succeed, false otherwise.
-	 * @throws ValidationException
-	 */
-	public boolean validate() throws ValidationException {
-		boolean isValide = checkMandatoryFields();
-		isValide = isValide && checkFlags();
-		isValide = isValide && checkColors();
-		isValide = isValide && checkAP();
-		isValide = isValide && checkCA();
-		isValide = isValide && checkActions();
-		isValide = isValide && checkPopup();
-		return isValide;
-	}
-
-	/**
-	 * 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.
-	 * 
-	 * @param errors
-	 *          list of errors which is updated if validation fails
-	 * @return true if validation succeed, false otherwise.
-	 */
-	protected abstract boolean checkMandatoryFields();
-
-	/**
-	 * 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.
-	 *  
-	 * @param fact
-	 */
-	public final void setFactory (AnnotationValidatorFactory fact) {
-		this.annotFact = fact;
-	}
+    protected PreflightContext ctx = null;
+    protected COSDocument cosDocument = null;
+    /**
+     * COSDictionary of the annotation
+     */
+    protected COSDictionary annotDictionary = null;
+    /**
+     * Instance of PDAnnotation built using the annotDictionary
+     */
+    protected PDAnnotation pdAnnot = null;
+
+    public AnnotationValidator(PreflightContext context, COSDictionary annotDictionary)
+    {
+        super();
+        this.ctx = context;
+        this.annotDictionary = annotDictionary;
+        this.cosDocument = this.ctx.getDocument().getDocument();
+    }
+
+    /**
+     * Checks if flags of the annotation are authorized.
+     * <UL>
+     * <li>Print flag must be 1
+     * <li>NoView flag must be 0
+     * <li>Hidden flag must be 0
+     * <li>Invisible flag must be 0
+     * </UL>
+     * If one of these flags is invalid, the errors list is updated with the ERROR_ANNOT_FORBIDDEN_FLAG ValidationError
+     * code.
+     * 
+     * @return false if a flag is invalid, true otherwise.
+     */
+    protected boolean checkFlags()
+    {
+        boolean result = this.pdAnnot.isPrinted();
+        result = result && !this.pdAnnot.isHidden();
+        result = result && !this.pdAnnot.isInvisible();
+        result = result && !this.pdAnnot.isNoView();
+        if (!result)
+        {
+            ctx.addValidationError(new ValidationError(ERROR_ANNOT_FORBIDDEN_FLAG, "Flags of " + pdAnnot.getSubtype()
+                    + " annotation are invalid"));
+        }
+
+        return result;
+    }
+
+    /**
+     * 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.
+     * 
+     * @return
+     */
+    protected boolean checkCA()
+    {
+        COSBase ca = this.pdAnnot.getDictionary().getItem(COSName.CA);
+        if (ca != null)
+        {
+            float caf = COSUtils.getAsFloat(ca, cosDocument);
+            if (caf != 1.0f)
+            { // ---- Only 1.0 is authorized as value
+                ctx.addValidationError(new ValidationError(ERROR_ANNOT_INVALID_CA,
+                        "CA entry is invalid. Expected 1.0 / Read " + caf));
+                return false;
+            }
+        } // else optional field, ok
+        return true;
+    }
+
+    /**
+     * 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.
+     * 
+     * @return
+     */
+    protected boolean checkColors() throws ValidationException
+    {
+        if (this.pdAnnot.getColour() != null)
+        {
+            if (!searchRGBProfile())
+            {
+                ctx.addValidationError(new ValidationError(ERROR_ANNOT_FORBIDDEN_COLOR,
+                        "Annotation uses a Color profile which isn't the same than the profile contained by the OutputIntent"));
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * Search the RGB Profile in OutputIntents dictionaries
+     * 
+     * @return true if a rgb profile is found, false otherwise.
+     */
+    protected boolean searchRGBProfile() throws ValidationException
+    {
+        ICCProfileWrapper iccpw = ICCProfileWrapper.getOrSearchICCProfile(ctx);
+        if (iccpw != null)
+        {
+            return iccpw.isRGBColorSpace();
+        }
+        return false;
+    }
+
+    /**
+     * 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.
+     * 
+     * @return
+     */
+    protected boolean checkAP() throws ValidationException
+    {
+        PDAppearanceDictionary ap = this.pdAnnot.getAppearance();
+        if (ap != null)
+        {
+            COSDictionary apDict = ap.getDictionary();
+            // Only N entry is authorized
+            if (apDict.getItem(COSName.D) != null || apDict.getItem(COSName.R) != null)
+            {
+                ctx.addValidationError(new ValidationError(ERROR_ANNOT_INVALID_AP_CONTENT,
+                        "Only the N Appearance is authorized"));
+                return false;
+            }
+            else if (apDict.getItem(COSName.N) == null)
+            {
+                // N entry is required
+                ctx.addValidationError(new ValidationError(ERROR_ANNOT_MISSING_AP_N_CONTENT,
+                        "The N Appearance must be present"));
+                return false;
+            }
+            else
+            {
+                // the N entry must be a Stream (Dictionaries are forbidden)
+                COSBase apn = apDict.getItem(COSName.N);
+                if (!COSUtils.isStream(apn, cosDocument))
+                {
+                    ctx.addValidationError(new ValidationError(ERROR_ANNOT_INVALID_AP_CONTENT,
+                            "The N Appearance must be a Stream"));
+                    return false;
+                }
+
+                // Appearance stream is a XObjectForm, check it.
+                ContextHelper.validateElement(ctx, new PDXObjectForm(COSUtils.getAsStream(apn, cosDocument)),
+                        GRAPHIC_PROCESS);
+            }
+        } // else ok, nothing to check,this field is optional
+        return true;
+    }
+
+    /**
+     * 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.
+     * 
+     * @return
+     * @throws ValidationException
+     */
+    protected boolean checkActions() throws ValidationException
+    {
+        ContextHelper.validateElement(ctx, annotDictionary, ACTIONS_PROCESS);
+        return true;
+    }
+
+    /**
+     * This method validates the Popup entry. This entry shall contain an other Annotation. This annotation is validated
+     * with the right AnnotationValidator.
+     * 
+     * @param errors
+     * @return
+     * @throws ValidationException
+     */
+    protected boolean checkPopup() throws ValidationException
+    {
+        COSBase cosPopup = this.annotDictionary.getItem(ANNOT_DICTIONARY_VALUE_SUBTYPE_POPUP);
+        if (cosPopup != null)
+        {
+            COSDictionary popupDict = COSUtils.getAsDictionary(cosPopup, cosDocument);
+            if (popupDict == null)
+            {
+                ctx.addValidationError(new ValidationError(ERROR_SYNTAX_DICT_INVALID,
+                        "An Annotation has a Popup entry, but the value is missing or isn't a dictionary"));
+                return false;
+            }
+            AnnotationValidator popupVal = this.annotFact.getAnnotationValidator(ctx, popupDict);
+            return popupVal.validate();
+        }
+        return true;
+    }
+
+    /**
+     * Execute validation of the Annotation dictionary.
+     * 
+     * @return true if validation succeed, false otherwise.
+     * @throws ValidationException
+     */
+    public boolean validate() throws ValidationException
+    {
+        boolean isValide = checkMandatoryFields();
+        isValide = isValide && checkFlags();
+        isValide = isValide && checkColors();
+        isValide = isValide && checkAP();
+        isValide = isValide && checkCA();
+        isValide = isValide && checkActions();
+        isValide = isValide && checkPopup();
+        return isValide;
+    }
+
+    /**
+     * 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.
+     * 
+     * @param errors
+     *            list of errors which is updated if validation fails
+     * @return true if validation succeed, false otherwise.
+     */
+    protected abstract boolean checkMandatoryFields();
+
+    /**
+     * 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.
+     * 
+     * @param fact
+     */
+    public final void setFactory(AnnotationValidatorFactory fact)
+    {
+        this.annotFact = fact;
+    }
 }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/AnnotationValidatorFactory.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/AnnotationValidatorFactory.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/AnnotationValidatorFactory.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/AnnotationValidatorFactory.java Wed Mar  6 16:46:35 2013
@@ -34,54 +34,67 @@ import org.apache.pdfbox.preflight.Valid
 import org.apache.pdfbox.preflight.action.ActionManagerFactory;
 import org.apache.pdfbox.preflight.exception.ValidationException;
 
-public abstract class AnnotationValidatorFactory {
-	protected ActionManagerFactory actionFact = null;
-
-	protected Map<String, Class<? extends AnnotationValidator>> validatorClasses = new HashMap<String, Class<? extends AnnotationValidator>>();
-
-	public AnnotationValidatorFactory() {
-		initializeClasses();
-	}
-
-	public AnnotationValidatorFactory(ActionManagerFactory actionFact) {
-		super();
-		this.actionFact = actionFact;
-	}
-
-	public final void setActionFact(ActionManagerFactory _actionFact) {
-		this.actionFact = _actionFact;
-	}
-
-	/**
-	 * Initialize the map of Validation classes used to create a validation object according to the Annotation subtype.
-	 */
-	protected abstract void initializeClasses();
-	
-	/**
-	 * Return an instance of AnnotationValidator.
-	 * 
-	 * @param ctx
-	 * @param annotDic
-	 * @return
-	 */
-	public final AnnotationValidator getAnnotationValidator(PreflightContext ctx, COSDictionary annotDic)
-	throws ValidationException {
-		
-		AnnotationValidator result = null;
-		String subtype = annotDic.getNameAsString(COSName.SUBTYPE);
-		Class<? extends AnnotationValidator> clazz = this.validatorClasses.get(subtype);
-		
-		if (clazz == null) {
-			ctx.addValidationError(new ValidationError(ERROR_ANNOT_FORBIDDEN_SUBTYPE,	"The subtype isn't authorized : " + subtype));
-		} else {
-			try {
-				Constructor<? extends AnnotationValidator> constructor = clazz.getConstructor(PreflightContext.class, COSDictionary.class);
-				result = constructor.newInstance(ctx, annotDic);
-				result.setFactory(this);
-			} catch (Exception e) {
-				throw new ValidationException(e.getMessage());
-			}
-		}
-		return result;
-	}
+public abstract class AnnotationValidatorFactory
+{
+    protected ActionManagerFactory actionFact = null;
+
+    protected Map<String, Class<? extends AnnotationValidator>> validatorClasses = new HashMap<String, Class<? extends AnnotationValidator>>();
+
+    public AnnotationValidatorFactory()
+    {
+        initializeClasses();
+    }
+
+    public AnnotationValidatorFactory(ActionManagerFactory actionFact)
+    {
+        super();
+        this.actionFact = actionFact;
+    }
+
+    public final void setActionFact(ActionManagerFactory _actionFact)
+    {
+        this.actionFact = _actionFact;
+    }
+
+    /**
+     * Initialize the map of Validation classes used to create a validation object according to the Annotation subtype.
+     */
+    protected abstract void initializeClasses();
+
+    /**
+     * Return an instance of AnnotationValidator.
+     * 
+     * @param ctx
+     * @param annotDic
+     * @return
+     */
+    public final AnnotationValidator getAnnotationValidator(PreflightContext ctx, COSDictionary annotDic)
+            throws ValidationException
+    {
+
+        AnnotationValidator result = null;
+        String subtype = annotDic.getNameAsString(COSName.SUBTYPE);
+        Class<? extends AnnotationValidator> clazz = this.validatorClasses.get(subtype);
+
+        if (clazz == null)
+        {
+            ctx.addValidationError(new ValidationError(ERROR_ANNOT_FORBIDDEN_SUBTYPE, "The subtype isn't authorized : "
+                    + subtype));
+        }
+        else
+        {
+            try
+            {
+                Constructor<? extends AnnotationValidator> constructor = clazz.getConstructor(PreflightContext.class,
+                        COSDictionary.class);
+                result = constructor.newInstance(ctx, annotDic);
+                result.setFactory(this);
+            }
+            catch (Exception e)
+            {
+                throw new ValidationException(e.getMessage());
+            }
+        }
+        return result;
+    }
 }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/FreeTextAnnotationValidator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/FreeTextAnnotationValidator.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/FreeTextAnnotationValidator.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/FreeTextAnnotationValidator.java Wed Mar  6 16:46:35 2013
@@ -32,39 +32,43 @@ import org.apache.pdfbox.preflight.Valid
 /**
  * Validation class for the FreeTextAnnotation
  */
-public class FreeTextAnnotationValidator extends AnnotationValidator {
-  /**
-   * PDFBox object which wraps the Annotation dictionary
-   */
-  protected PDAnnotationTextMarkup pdFreeText = null;
-
-  public FreeTextAnnotationValidator(PreflightContext ctx, COSDictionary annotDictionary) {
-    super(ctx, annotDictionary);
-    this.pdFreeText = new PDAnnotationTextMarkup(annotDictionary);
-    this.pdAnnot = this.pdFreeText;
-  }
+public class FreeTextAnnotationValidator extends AnnotationValidator
+{
+    /**
+     * PDFBox object which wraps the Annotation dictionary
+     */
+    protected PDAnnotationTextMarkup pdFreeText = null;
 
-  /*
-   * (non-Javadoc)
-   * 
-   * @seenet.awl.edoc.pdfa.validation.annotation.AnnotationValidator#
-   * checkMandatoryFields(java.util.List)
-   */
-  protected boolean checkMandatoryFields() {
-    boolean subtype = this.annotDictionary.containsKey(COSName.SUBTYPE);
-    boolean rect = this.annotDictionary.containsKey(COSName.RECT);
-    boolean f = this.annotDictionary.containsKey(COSName.F);
-    boolean contents = this.annotDictionary.containsKey(COSName.CONTENTS);
-    boolean da = this.annotDictionary.containsKey(COSName.DA);
+    public FreeTextAnnotationValidator(PreflightContext ctx, COSDictionary annotDictionary)
+    {
+        super(ctx, annotDictionary);
+        this.pdFreeText = new PDAnnotationTextMarkup(annotDictionary);
+        this.pdAnnot = this.pdFreeText;
+    }
 
     /*
-     * After PDF 1.4, all additional entries in this annotation are
-     * optional and they seem to be compatible with the PDF/A specification.
+     * (non-Javadoc)
+     * 
+     * @seenet.awl.edoc.pdfa.validation.annotation.AnnotationValidator# checkMandatoryFields(java.util.List)
      */
-    boolean result = (subtype && rect && f && da && contents);
-    if (!result) {
-      ctx.addValidationError(new ValidationError(ERROR_ANNOT_MISSING_FIELDS,"A mandatory field for the " + this.pdAnnot.getSubtype() + " annotation is missing"));
+    protected boolean checkMandatoryFields()
+    {
+        boolean subtype = this.annotDictionary.containsKey(COSName.SUBTYPE);
+        boolean rect = this.annotDictionary.containsKey(COSName.RECT);
+        boolean f = this.annotDictionary.containsKey(COSName.F);
+        boolean contents = this.annotDictionary.containsKey(COSName.CONTENTS);
+        boolean da = this.annotDictionary.containsKey(COSName.DA);
+
+        /*
+         * After PDF 1.4, all additional entries in this annotation are optional and they seem to be compatible with the
+         * PDF/A specification.
+         */
+        boolean result = (subtype && rect && f && da && contents);
+        if (!result)
+        {
+            ctx.addValidationError(new ValidationError(ERROR_ANNOT_MISSING_FIELDS, "A mandatory field for the "
+                    + this.pdAnnot.getSubtype() + " annotation is missing"));
+        }
+        return result;
     }
-    return result;
-  }
 }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/InkAnnotationValdiator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/InkAnnotationValdiator.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/InkAnnotationValdiator.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/InkAnnotationValdiator.java Wed Mar  6 16:46:35 2013
@@ -33,35 +33,38 @@ import org.apache.pdfbox.preflight.Valid
 /**
  * Validation class for the InkAnnotation
  */
-public class InkAnnotationValdiator extends AnnotationValidator {
-  /**
-   * PDFBox which wraps the annotation dictionary
-   */
-  protected PDAnnotationUnknown pdUnk = null;
+public class InkAnnotationValdiator extends AnnotationValidator
+{
+    /**
+     * PDFBox which wraps the annotation dictionary
+     */
+    protected PDAnnotationUnknown pdUnk = null;
 
-  public InkAnnotationValdiator(PreflightContext ctx, COSDictionary annotDictionary) {
-    super(ctx, annotDictionary);
-    this.pdUnk = new PDAnnotationUnknown(annotDictionary);
-    this.pdAnnot = this.pdUnk;
-  }
+    public InkAnnotationValdiator(PreflightContext ctx, COSDictionary annotDictionary)
+    {
+        super(ctx, annotDictionary);
+        this.pdUnk = new PDAnnotationUnknown(annotDictionary);
+        this.pdAnnot = this.pdUnk;
+    }
 
-  /*
-   * (non-Javadoc)
-   * 
-   * @seenet.awl.edoc.pdfa.validation.annotation.AnnotationValidator#
-   * checkMandatoryFields(java.util.List)
-   */
-  protected boolean checkMandatoryFields() {
-    boolean subtype = this.annotDictionary.containsKey(COSName.SUBTYPE);
-    boolean rect = this.annotDictionary.containsKey(COSName.RECT);
-    boolean f = this.annotDictionary.containsKey(COSName.F);
-    boolean contents = this.annotDictionary.containsKey(COSName.CONTENTS);
-    boolean inkList = this.annotDictionary.containsKey(COSName.getPDFName(ANNOT_DICTIONARY_KEY_INKLIST));
+    /*
+     * (non-Javadoc)
+     * 
+     * @seenet.awl.edoc.pdfa.validation.annotation.AnnotationValidator# checkMandatoryFields(java.util.List)
+     */
+    protected boolean checkMandatoryFields()
+    {
+        boolean subtype = this.annotDictionary.containsKey(COSName.SUBTYPE);
+        boolean rect = this.annotDictionary.containsKey(COSName.RECT);
+        boolean f = this.annotDictionary.containsKey(COSName.F);
+        boolean contents = this.annotDictionary.containsKey(COSName.CONTENTS);
+        boolean inkList = this.annotDictionary.containsKey(COSName.getPDFName(ANNOT_DICTIONARY_KEY_INKLIST));
 
-    boolean result = (subtype && rect && f && contents && inkList);
-    if (!result) {
-      ctx.addValidationError(new ValidationError(ERROR_ANNOT_MISSING_FIELDS));
+        boolean result = (subtype && rect && f && contents && inkList);
+        if (!result)
+        {
+            ctx.addValidationError(new ValidationError(ERROR_ANNOT_MISSING_FIELDS));
+        }
+        return result;
     }
-    return result;
-  }
 }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/LineAnnotationValidator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/LineAnnotationValidator.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/LineAnnotationValidator.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/LineAnnotationValidator.java Wed Mar  6 16:46:35 2013
@@ -34,71 +34,76 @@ import org.apache.pdfbox.preflight.excep
 /**
  * Validation class for the LineAnnotation
  */
-public class LineAnnotationValidator extends AnnotationValidator {
-  /**
-   * PDFBox object which wraps the annotation dictionary
-   */
-  protected PDAnnotationLine pdLine = null;
-
-  public LineAnnotationValidator(PreflightContext ctx, COSDictionary annotDictionary) {
-    super(ctx, annotDictionary);
-    this.pdLine = new PDAnnotationLine(annotDictionary);
-    this.pdAnnot = this.pdLine;
-  }
+public class LineAnnotationValidator extends AnnotationValidator
+{
+    /**
+     * PDFBox object which wraps the annotation dictionary
+     */
+    protected PDAnnotationLine pdLine = null;
 
-  /**
-   * In addition of the AnnotationValidator.validate() method, this method
-   * executes the the checkIColors method.
-   * 
-   * @see org.apache.padaf.preflight.annotation.AnnotationValidator#validate(java.util.List)
-   */
-  @Override
-  public boolean validate()  throws ValidationException {
-    boolean isValide = super.validate();
-    isValide = isValide && checkIColors();
-    return isValide;
-  }
+    public LineAnnotationValidator(PreflightContext ctx, COSDictionary annotDictionary)
+    {
+        super(ctx, annotDictionary);
+        this.pdLine = new PDAnnotationLine(annotDictionary);
+        this.pdAnnot = this.pdLine;
+    }
 
-  /**
-   * Return true if the IC field is present in the Annotation dictionary and if
-   * the RGB profile is used in the DestOutputProfile of the OutputIntent
-   * dictionary.
-   * 
-   * @param errors
-   *          list of errors with is updated if no RGB profile is found when the
-   *          IC element is present
-   * @return
-   */
-  protected boolean checkIColors() throws ValidationException {
-    if (this.pdLine.getInteriorColour() != null) {
-      if (!searchRGBProfile()) {
-        ctx.addValidationError(new ValidationError(ERROR_ANNOT_FORBIDDEN_COLOR,"Annotation uses a Color profile which isn't the same than the profile contained by the OutputIntent"));
-        return false;
-      }
+    /**
+     * In addition of the AnnotationValidator.validate() method, this method executes the the checkIColors method.
+     * 
+     * @see org.apache.padaf.preflight.annotation.AnnotationValidator#validate(java.util.List)
+     */
+    @Override
+    public boolean validate() throws ValidationException
+    {
+        boolean isValide = super.validate();
+        isValide = isValide && checkIColors();
+        return isValide;
     }
-    return true;
-  }
 
-  /*
-   * (non-Javadoc)
-   * 
-   * @seenet.awl.edoc.pdfa.validation.annotation.AnnotationValidator#
-   * checkMandatoryFields(java.util.List)
-   */
-  protected boolean checkMandatoryFields() {
-    boolean subtype = this.annotDictionary.containsKey(COSName.SUBTYPE);
-    boolean rect = this.annotDictionary.containsKey(COSName.RECT);
-    boolean f = this.annotDictionary.containsKey(COSName.F);
-    boolean l = this.annotDictionary.containsKey(COSName.L);
+    /**
+     * Return true if the IC field is present in the Annotation dictionary and if the RGB profile is used in the
+     * DestOutputProfile of the OutputIntent dictionary.
+     * 
+     * @param errors
+     *            list of errors with is updated if no RGB profile is found when the IC element is present
+     * @return
+     */
+    protected boolean checkIColors() throws ValidationException
+    {
+        if (this.pdLine.getInteriorColour() != null)
+        {
+            if (!searchRGBProfile())
+            {
+                ctx.addValidationError(new ValidationError(ERROR_ANNOT_FORBIDDEN_COLOR,
+                        "Annotation uses a Color profile which isn't the same than the profile contained by the OutputIntent"));
+                return false;
+            }
+        }
+        return true;
+    }
 
     /*
-     * After PDF 1.4, all additional entries in this annotation are
-     * optional and they seem to be compatible with the PDF/A specification.
+     * (non-Javadoc)
+     * 
+     * @seenet.awl.edoc.pdfa.validation.annotation.AnnotationValidator# checkMandatoryFields(java.util.List)
      */
-    boolean result = (subtype && rect && f && l);
-    if (!result) {
-      ctx.addValidationError(new ValidationError(ERROR_ANNOT_MISSING_FIELDS));
+    protected boolean checkMandatoryFields()
+    {
+        boolean subtype = this.annotDictionary.containsKey(COSName.SUBTYPE);
+        boolean rect = this.annotDictionary.containsKey(COSName.RECT);
+        boolean f = this.annotDictionary.containsKey(COSName.F);
+        boolean l = this.annotDictionary.containsKey(COSName.L);
+
+        /*
+         * After PDF 1.4, all additional entries in this annotation are optional and they seem to be compatible with the
+         * PDF/A specification.
+         */
+        boolean result = (subtype && rect && f && l);
+        if (!result)
+        {
+            ctx.addValidationError(new ValidationError(ERROR_ANNOT_MISSING_FIELDS));
+        }
+        return result;
     }
-    return result;
-  }
 }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/LinkAnnotationValidator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/LinkAnnotationValidator.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/LinkAnnotationValidator.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/LinkAnnotationValidator.java Wed Mar  6 16:46:35 2013
@@ -38,71 +38,78 @@ import org.apache.pdfbox.preflight.excep
 /**
  * Validation class for the LinkAnnotation
  */
-public class LinkAnnotationValidator extends AnnotationValidator {
-  /**
-   * PDFBox object which wraps the annotation dictionary
-   */
-  protected PDAnnotationLink pdLink = null;
+public class LinkAnnotationValidator extends AnnotationValidator
+{
+    /**
+     * PDFBox object which wraps the annotation dictionary
+     */
+    protected PDAnnotationLink pdLink = null;
 
-  public LinkAnnotationValidator(PreflightContext ctx, COSDictionary annotDictionary) {
-    super(ctx, annotDictionary);
-    this.pdLink = new PDAnnotationLink(annotDictionary);
-    this.pdAnnot = this.pdLink;
-  }
+    public LinkAnnotationValidator(PreflightContext ctx, COSDictionary annotDictionary)
+    {
+        super(ctx, annotDictionary);
+        this.pdLink = new PDAnnotationLink(annotDictionary);
+        this.pdAnnot = this.pdLink;
+    }
 
-  /**
-   * In addition of the AnnotationValidator.validate() method, this method
-   * executes the the checkDest method.
-   * 
-   * @see org.apache.padaf.preflight.annotation.AnnotationValidator#validate()
-   */
-  @Override
-  public boolean validate()  throws ValidationException {
-    boolean isValide = super.validate();
-    isValide = isValide && checkDest();
-    return isValide;
-  }
+    /**
+     * In addition of the AnnotationValidator.validate() method, this method executes the the checkDest method.
+     * 
+     * @see org.apache.padaf.preflight.annotation.AnnotationValidator#validate()
+     */
+    @Override
+    public boolean validate() throws ValidationException
+    {
+        boolean isValide = super.validate();
+        isValide = isValide && checkDest();
+        return isValide;
+    }
 
-  /**
-   * Check if the Dest element is authorized according to the A entry
-   * 
-   * @return
-   */
-  protected boolean checkDest() {
-    try {
-      PDDestination dest = this.pdLink.getDestination();
-      if (dest != null) {
-        // ---- check the if an A entry is present.
-        if (this.pdLink.getAction() != null) {
-          ctx.addValidationError(new ValidationError(ERROR_ANNOT_FORBIDDEN_DEST,
-              "Dest can't be used due to A element"));
-          return false;
+    /**
+     * Check if the Dest element is authorized according to the A entry
+     * 
+     * @return
+     */
+    protected boolean checkDest()
+    {
+        try
+        {
+            PDDestination dest = this.pdLink.getDestination();
+            if (dest != null)
+            {
+                // ---- check the if an A entry is present.
+                if (this.pdLink.getAction() != null)
+                {
+                    ctx.addValidationError(new ValidationError(ERROR_ANNOT_FORBIDDEN_DEST,
+                            "Dest can't be used due to A element"));
+                    return false;
+                }
+            }
         }
-      }
-    } catch (IOException e) {
-      ctx.addValidationError(new ValidationError(ERROR_ANNOT_INVALID_DEST,
-              "Dest can't be checked"));
-      return false;
+        catch (IOException e)
+        {
+            ctx.addValidationError(new ValidationError(ERROR_ANNOT_INVALID_DEST, "Dest can't be checked"));
+            return false;
+        }
+        return true;
     }
-    return true;
-  }
 
-  /*
-   * (non-Javadoc)
-   * (new ValidationError(
-            ValidationConstants.
-   * @seenet.awl.edoc.pdfa.validation.annotation.AnnotationValidator#
-   * checkMandatoryFields(java.util.List)
-   */
-  protected boolean checkMandatoryFields() {
-    boolean subtype = this.annotDictionary.containsKey(COSName.SUBTYPE);
-    boolean rect = this.annotDictionary.containsKey(COSName.RECT);
-    boolean f = this.annotDictionary.containsKey(COSName.F);
+    /*
+     * (non-Javadoc) (new ValidationError( ValidationConstants.
+     * 
+     * @seenet.awl.edoc.pdfa.validation.annotation.AnnotationValidator# checkMandatoryFields(java.util.List)
+     */
+    protected boolean checkMandatoryFields()
+    {
+        boolean subtype = this.annotDictionary.containsKey(COSName.SUBTYPE);
+        boolean rect = this.annotDictionary.containsKey(COSName.RECT);
+        boolean f = this.annotDictionary.containsKey(COSName.F);
 
-    boolean result = (subtype && rect && f);
-    if (!result) {
-      ctx.addValidationError(new ValidationError(ERROR_ANNOT_MISSING_FIELDS));
+        boolean result = (subtype && rect && f);
+        if (!result)
+        {
+            ctx.addValidationError(new ValidationError(ERROR_ANNOT_MISSING_FIELDS));
+        }
+        return result;
     }
-    return result;
-  }
 }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/MarkupAnnotationValidator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/MarkupAnnotationValidator.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/MarkupAnnotationValidator.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/MarkupAnnotationValidator.java Wed Mar  6 16:46:35 2013
@@ -33,35 +33,38 @@ import org.apache.pdfbox.preflight.Valid
 /**
  * Validation class for the MarkupAnnotation
  */
-public class MarkupAnnotationValidator extends AnnotationValidator {
-  /**
-   * PDFBox object which wraps the annotation dictionary
-   */
-  protected PDAnnotationTextMarkup pdMarkup = null;
+public class MarkupAnnotationValidator extends AnnotationValidator
+{
+    /**
+     * PDFBox object which wraps the annotation dictionary
+     */
+    protected PDAnnotationTextMarkup pdMarkup = null;
 
-  public MarkupAnnotationValidator(PreflightContext ctx, COSDictionary annotDictionary) {
-	super(ctx, annotDictionary);
-    this.pdMarkup = new PDAnnotationTextMarkup(annotDictionary);
-    this.pdAnnot = this.pdMarkup;
-  }
+    public MarkupAnnotationValidator(PreflightContext ctx, COSDictionary annotDictionary)
+    {
+        super(ctx, annotDictionary);
+        this.pdMarkup = new PDAnnotationTextMarkup(annotDictionary);
+        this.pdAnnot = this.pdMarkup;
+    }
 
-  /*
-   * (non-Javadoc)
-   * 
-   * @seenet.awl.edoc.pdfa.validation.annotation.AnnotationValidator#
-   * checkMandatoryFields(java.util.List)
-   */
-  protected boolean checkMandatoryFields() {
-    boolean subtype = this.annotDictionary.containsKey(COSName.SUBTYPE);
-    boolean rect = this.annotDictionary.containsKey(COSName.RECT);
-    boolean f = this.annotDictionary.containsKey(COSName.F);
-    boolean contents = this.annotDictionary.containsKey(COSName.CONTENTS);
-    boolean qp = this.annotDictionary.containsKey(COSName.getPDFName(ANNOT_DICTIONARY_KEY_QUADPOINTS));
+    /*
+     * (non-Javadoc)
+     * 
+     * @seenet.awl.edoc.pdfa.validation.annotation.AnnotationValidator# checkMandatoryFields(java.util.List)
+     */
+    protected boolean checkMandatoryFields()
+    {
+        boolean subtype = this.annotDictionary.containsKey(COSName.SUBTYPE);
+        boolean rect = this.annotDictionary.containsKey(COSName.RECT);
+        boolean f = this.annotDictionary.containsKey(COSName.F);
+        boolean contents = this.annotDictionary.containsKey(COSName.CONTENTS);
+        boolean qp = this.annotDictionary.containsKey(COSName.getPDFName(ANNOT_DICTIONARY_KEY_QUADPOINTS));
 
-    boolean result = (subtype && rect && f && contents && qp);
-    if (!result) {
-      ctx.addValidationError(new ValidationError(ERROR_ANNOT_MISSING_FIELDS));
+        boolean result = (subtype && rect && f && contents && qp);
+        if (!result)
+        {
+            ctx.addValidationError(new ValidationError(ERROR_ANNOT_MISSING_FIELDS));
+        }
+        return result;
     }
-    return result;
-  }
 }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/PopupAnnotationValidator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/PopupAnnotationValidator.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/PopupAnnotationValidator.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/PopupAnnotationValidator.java Wed Mar  6 16:46:35 2013
@@ -32,33 +32,36 @@ import org.apache.pdfbox.preflight.Valid
 /**
  * Validation class for the PopupAnnotation
  */
-public class PopupAnnotationValidator extends AnnotationValidator {
-  /**
-   * PDFBox object which wraps the annotation dictionary
-   */
-  protected PDAnnotationPopup pdPopup = null;
+public class PopupAnnotationValidator extends AnnotationValidator
+{
+    /**
+     * PDFBox object which wraps the annotation dictionary
+     */
+    protected PDAnnotationPopup pdPopup = null;
 
-  public PopupAnnotationValidator(PreflightContext ctx, COSDictionary annotDictionary) {
-	super(ctx, annotDictionary);
-    this.pdPopup = new PDAnnotationPopup(annotDictionary);
-    this.pdAnnot = this.pdPopup;
-  }
+    public PopupAnnotationValidator(PreflightContext ctx, COSDictionary annotDictionary)
+    {
+        super(ctx, annotDictionary);
+        this.pdPopup = new PDAnnotationPopup(annotDictionary);
+        this.pdAnnot = this.pdPopup;
+    }
 
-  /*
-   * (non-Javadoc)
-   * 
-   * @seenet.awl.edoc.pdfa.validation.annotation.AnnotationValidator#
-   * checkMandatoryFields(java.util.List)
-   */
-  protected boolean checkMandatoryFields() {
-	  boolean subtype = this.annotDictionary.containsKey(COSName.SUBTYPE);
-	  boolean rect = this.annotDictionary.containsKey(COSName.RECT);
-	  boolean f = this.annotDictionary.containsKey(COSName.F);
+    /*
+     * (non-Javadoc)
+     * 
+     * @seenet.awl.edoc.pdfa.validation.annotation.AnnotationValidator# checkMandatoryFields(java.util.List)
+     */
+    protected boolean checkMandatoryFields()
+    {
+        boolean subtype = this.annotDictionary.containsKey(COSName.SUBTYPE);
+        boolean rect = this.annotDictionary.containsKey(COSName.RECT);
+        boolean f = this.annotDictionary.containsKey(COSName.F);
 
-    boolean result = (subtype && rect && f);
-    if (!result) {
-      ctx.addValidationError(new ValidationError(ERROR_ANNOT_MISSING_FIELDS));
+        boolean result = (subtype && rect && f);
+        if (!result)
+        {
+            ctx.addValidationError(new ValidationError(ERROR_ANNOT_MISSING_FIELDS));
+        }
+        return result;
     }
-    return result;
-  }
 }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/PrintMarkAnnotationValidator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/PrintMarkAnnotationValidator.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/PrintMarkAnnotationValidator.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/PrintMarkAnnotationValidator.java Wed Mar  6 16:46:35 2013
@@ -32,33 +32,36 @@ import org.apache.pdfbox.preflight.Valid
 /**
  * Validation class for the PopupAnnotation
  */
-public class PrintMarkAnnotationValidator extends AnnotationValidator {
-	/**
-	 * PDFBox object which wraps the annotation dictionary
-	 */
-	protected PDAnnotationUnknown pdUnk = null;
+public class PrintMarkAnnotationValidator extends AnnotationValidator
+{
+    /**
+     * PDFBox object which wraps the annotation dictionary
+     */
+    protected PDAnnotationUnknown pdUnk = null;
 
-	public PrintMarkAnnotationValidator(PreflightContext ctx, COSDictionary annotDictionary) {
-		super(ctx, annotDictionary);
-		this.pdUnk = new PDAnnotationUnknown(annotDictionary);
-		this.pdAnnot = this.pdUnk;
-	}
+    public PrintMarkAnnotationValidator(PreflightContext ctx, COSDictionary annotDictionary)
+    {
+        super(ctx, annotDictionary);
+        this.pdUnk = new PDAnnotationUnknown(annotDictionary);
+        this.pdAnnot = this.pdUnk;
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @seenet.awl.edoc.pdfa.validation.annotation.AnnotationValidator#
-	 * checkMandatoryFields(java.util.List)
-	 */
-	protected boolean checkMandatoryFields() {
-		boolean subtype = this.annotDictionary.containsKey(COSName.SUBTYPE);
-		boolean rect = this.annotDictionary.containsKey(COSName.RECT);
-		boolean f = this.annotDictionary.containsKey(COSName.F);
+    /*
+     * (non-Javadoc)
+     * 
+     * @seenet.awl.edoc.pdfa.validation.annotation.AnnotationValidator# checkMandatoryFields(java.util.List)
+     */
+    protected boolean checkMandatoryFields()
+    {
+        boolean subtype = this.annotDictionary.containsKey(COSName.SUBTYPE);
+        boolean rect = this.annotDictionary.containsKey(COSName.RECT);
+        boolean f = this.annotDictionary.containsKey(COSName.F);
 
-		boolean result = (subtype && rect && f);
-		if (!result) {
-			ctx.addValidationError(new ValidationError(ERROR_ANNOT_MISSING_FIELDS));
-		}
-		return result;
-	}
+        boolean result = (subtype && rect && f);
+        if (!result)
+        {
+            ctx.addValidationError(new ValidationError(ERROR_ANNOT_MISSING_FIELDS));
+        }
+        return result;
+    }
 }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/RubberStampAnnotationValidator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/RubberStampAnnotationValidator.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/RubberStampAnnotationValidator.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/RubberStampAnnotationValidator.java Wed Mar  6 16:46:35 2013
@@ -32,35 +32,38 @@ import org.apache.pdfbox.preflight.Valid
 /**
  * Validation class for the BudderStampAnnotation
  */
-public class RubberStampAnnotationValidator extends AnnotationValidator {
-  /**
-   * PDFBox class which wraps the annotaiton dictionary
-   */
-  protected PDAnnotationRubberStamp pdRStamp = null;
+public class RubberStampAnnotationValidator extends AnnotationValidator
+{
+    /**
+     * PDFBox class which wraps the annotaiton dictionary
+     */
+    protected PDAnnotationRubberStamp pdRStamp = null;
 
-  public RubberStampAnnotationValidator(PreflightContext ctx, COSDictionary annotDictionary) {
-	    super(ctx, annotDictionary);
-    this.pdRStamp = new PDAnnotationRubberStamp(annotDictionary);
-    this.pdAnnot = this.pdRStamp;
-  }
+    public RubberStampAnnotationValidator(PreflightContext ctx, COSDictionary annotDictionary)
+    {
+        super(ctx, annotDictionary);
+        this.pdRStamp = new PDAnnotationRubberStamp(annotDictionary);
+        this.pdAnnot = this.pdRStamp;
+    }
 
-  /*
-   * (non-Javadoc)
-   * 
-   * @seenet.awl.edoc.pdfa.validation.annotation.AnnotationValidator#
-   * checkMandatoryFields(java.util.List)
-   */
-  protected boolean checkMandatoryFields() {
-    boolean subtype = this.annotDictionary.containsKey(COSName.SUBTYPE);
-    boolean rect = this.annotDictionary.containsKey(COSName.RECT);
-    boolean f = this.annotDictionary.containsKey(COSName.F);
-    boolean contents = this.annotDictionary.containsKey(COSName.CONTENTS);
+    /*
+     * (non-Javadoc)
+     * 
+     * @seenet.awl.edoc.pdfa.validation.annotation.AnnotationValidator# checkMandatoryFields(java.util.List)
+     */
+    protected boolean checkMandatoryFields()
+    {
+        boolean subtype = this.annotDictionary.containsKey(COSName.SUBTYPE);
+        boolean rect = this.annotDictionary.containsKey(COSName.RECT);
+        boolean f = this.annotDictionary.containsKey(COSName.F);
+        boolean contents = this.annotDictionary.containsKey(COSName.CONTENTS);
 
-    boolean result = (subtype && rect && f && contents);
-    if (!result) {
-      ctx.addValidationError(new ValidationError(ERROR_ANNOT_MISSING_FIELDS));
+        boolean result = (subtype && rect && f && contents);
+        if (!result)
+        {
+            ctx.addValidationError(new ValidationError(ERROR_ANNOT_MISSING_FIELDS));
+        }
+        return result;
     }
-    return result;
-  }
 
 }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/SquareCircleAnnotationValidator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/SquareCircleAnnotationValidator.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/SquareCircleAnnotationValidator.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/SquareCircleAnnotationValidator.java Wed Mar  6 16:46:35 2013
@@ -34,71 +34,76 @@ import org.apache.pdfbox.preflight.excep
 /**
  * Validation class for the Square/Circle Annotation
  */
-public class SquareCircleAnnotationValidator extends AnnotationValidator {
-  /**
-   * PDFBox object which wraps the annotation dictionary
-   */
-  protected PDAnnotationSquareCircle pdSquareCircle = null;
-
-  public SquareCircleAnnotationValidator(PreflightContext ctx, COSDictionary annotDictionary) {
-	    super(ctx, annotDictionary);
-    this.pdSquareCircle = new PDAnnotationSquareCircle(annotDictionary);
-    this.pdAnnot = this.pdSquareCircle;
-  }
-
-  /**
-   * In addition of the AnnotationValidator.validate() method, this method
-   * executes the the checkIColors method.
-   * 
-   * @see org.apache.padaf.preflight.annotation.AnnotationValidator#validate(java.util.List)
-   */
-  @Override
-  public boolean validate() throws ValidationException {
-    boolean isValide = super.validate();
-    isValide = isValide && checkIColors();
-    return isValide;
-  }
-
-  /**
-   * Return true if the IC field is present in the Annotation dictionary and if
-   * the RGB profile is used in the DestOutputProfile of the OutputIntent
-   * dictionary.
-   * 
-   * @param errors
-   *          list of errors with is updated if no RGB profile is found when the
-   *          IC element is present
-   * @return
-   */
-  protected boolean checkIColors() throws ValidationException {
-    if (this.pdSquareCircle.getInteriorColour() != null) {
-      if (!searchRGBProfile()) {
-        ctx.addValidationError(new ValidationError(ERROR_ANNOT_FORBIDDEN_COLOR,"Annotation uses a Color profile which isn't the same than the profile contained by the OutputIntent"));
-        return false;
-      }
+public class SquareCircleAnnotationValidator extends AnnotationValidator
+{
+    /**
+     * PDFBox object which wraps the annotation dictionary
+     */
+    protected PDAnnotationSquareCircle pdSquareCircle = null;
+
+    public SquareCircleAnnotationValidator(PreflightContext ctx, COSDictionary annotDictionary)
+    {
+        super(ctx, annotDictionary);
+        this.pdSquareCircle = new PDAnnotationSquareCircle(annotDictionary);
+        this.pdAnnot = this.pdSquareCircle;
     }
-    return true;
-  }
 
-  /*
-   * (non-Javadoc)
-   * 
-   * @seenet.awl.edoc.pdfa.validation.annotation.AnnotationValidator#
-   * checkMandatoryFields(java.util.List)
-   */
-  protected boolean checkMandatoryFields() {
-    boolean subtype = this.annotDictionary.containsKey(COSName.SUBTYPE);
-    boolean rect = this.annotDictionary.containsKey(COSName.RECT);
-    boolean f = this.annotDictionary.containsKey(COSName.F);
+    /**
+     * In addition of the AnnotationValidator.validate() method, this method executes the the checkIColors method.
+     * 
+     * @see org.apache.padaf.preflight.annotation.AnnotationValidator#validate(java.util.List)
+     */
+    @Override
+    public boolean validate() throws ValidationException
+    {
+        boolean isValide = super.validate();
+        isValide = isValide && checkIColors();
+        return isValide;
+    }
+
+    /**
+     * Return true if the IC field is present in the Annotation dictionary and if the RGB profile is used in the
+     * DestOutputProfile of the OutputIntent dictionary.
+     * 
+     * @param errors
+     *            list of errors with is updated if no RGB profile is found when the IC element is present
+     * @return
+     */
+    protected boolean checkIColors() throws ValidationException
+    {
+        if (this.pdSquareCircle.getInteriorColour() != null)
+        {
+            if (!searchRGBProfile())
+            {
+                ctx.addValidationError(new ValidationError(ERROR_ANNOT_FORBIDDEN_COLOR,
+                        "Annotation uses a Color profile which isn't the same than the profile contained by the OutputIntent"));
+                return false;
+            }
+        }
+        return true;
+    }
 
     /*
-     * ---- After PDF 1.4, all additional entries in this annotation are
-     * optional and they seem to be compatible with the PDF/A specification.
+     * (non-Javadoc)
+     * 
+     * @seenet.awl.edoc.pdfa.validation.annotation.AnnotationValidator# checkMandatoryFields(java.util.List)
      */
-    boolean result = (subtype && rect && f);
-    if (!result) {
-      ctx.addValidationError(new ValidationError(ERROR_ANNOT_MISSING_FIELDS));
+    protected boolean checkMandatoryFields()
+    {
+        boolean subtype = this.annotDictionary.containsKey(COSName.SUBTYPE);
+        boolean rect = this.annotDictionary.containsKey(COSName.RECT);
+        boolean f = this.annotDictionary.containsKey(COSName.F);
+
+        /*
+         * ---- After PDF 1.4, all additional entries in this annotation are optional and they seem to be compatible
+         * with the PDF/A specification.
+         */
+        boolean result = (subtype && rect && f);
+        if (!result)
+        {
+            ctx.addValidationError(new ValidationError(ERROR_ANNOT_MISSING_FIELDS));
+        }
+        return result;
     }
-    return result;
-  }
 
 }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/TextAnnotationValidator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/TextAnnotationValidator.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/TextAnnotationValidator.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/TextAnnotationValidator.java Wed Mar  6 16:46:35 2013
@@ -33,61 +33,63 @@ import org.apache.pdfbox.preflight.Valid
 /**
  * Validation class for Text Annotation
  */
-public class TextAnnotationValidator extends AnnotationValidator {
-  /**
-   * PDFBox object which wraps the annotation dictionary
-   */
-  protected PDAnnotationText pdText = null;
-
-  public TextAnnotationValidator(PreflightContext ctx, COSDictionary annotDictionary) {
-	    super(ctx, annotDictionary);
-    this.pdText = new PDAnnotationText(annotDictionary);
-    this.pdAnnot = this.pdText;
-  }
+public class TextAnnotationValidator extends AnnotationValidator
+{
+    /**
+     * PDFBox object which wraps the annotation dictionary
+     */
+    protected PDAnnotationText pdText = null;
 
-  /*
-   * (non-Javadoc)
-   * 
-   * @see
-   * net.awl.edoc.pdfa.validation.annotation.AnnotationValidator#checkFlags(
-   * java.util.List)
-   */
-  protected boolean checkFlags() {
-    // call common flags settings
-    boolean result = super.checkFlags();
+    public TextAnnotationValidator(PreflightContext ctx, COSDictionary annotDictionary)
+    {
+        super(ctx, annotDictionary);
+        this.pdText = new PDAnnotationText(annotDictionary);
+        this.pdAnnot = this.pdText;
+    }
 
     /*
-     * For Text Annotation, this two flags should be set to avoid potential
-     * ambiguity between the annotation dictionary and the reader behavior.
-     */ 
-    result = result && this.pdAnnot.isNoRotate();
-    result = result && this.pdAnnot.isNoZoom();
-    if (!result) {
-      ctx.addValidationError(new ValidationError(ERROR_ANNOT_NOT_RECOMMENDED_FLAG));
+     * (non-Javadoc)
+     * 
+     * @see net.awl.edoc.pdfa.validation.annotation.AnnotationValidator#checkFlags( java.util.List)
+     */
+    protected boolean checkFlags()
+    {
+        // call common flags settings
+        boolean result = super.checkFlags();
+
+        /*
+         * For Text Annotation, this two flags should be set to avoid potential ambiguity between the annotation
+         * dictionary and the reader behavior.
+         */
+        result = result && this.pdAnnot.isNoRotate();
+        result = result && this.pdAnnot.isNoZoom();
+        if (!result)
+        {
+            ctx.addValidationError(new ValidationError(ERROR_ANNOT_NOT_RECOMMENDED_FLAG));
+        }
+        return result;
     }
-    return result;
-  }
 
-  /*
-   * (non-Javadoc)
-   * 
-   * @seenet.awl.edoc.pdfa.validation.annotation.AnnotationValidator#
-   * checkMandatoryFields(java.util.List)
-   */
-  protected boolean checkMandatoryFields() {
-    boolean subtype = this.annotDictionary.containsKey(COSName.SUBTYPE);
-    boolean rect = this.annotDictionary.containsKey(COSName.RECT);
-    boolean f = this.annotDictionary.containsKey(COSName.F);
-    boolean contents = this.annotDictionary.containsKey(COSName.CONTENTS);
     /*
-     * Since PDF 1.5, two optional entries are possible. These new entries
-     * seem to e compatible with the PDF/A specification (used to set a State to
-     * the annotation - ex : rejected, reviewed...)
+     * (non-Javadoc)
+     * 
+     * @seenet.awl.edoc.pdfa.validation.annotation.AnnotationValidator# checkMandatoryFields(java.util.List)
      */
-    boolean result = (subtype && rect && f && contents);
-    if (!result) {
-      ctx.addValidationError(new ValidationError(ERROR_ANNOT_MISSING_FIELDS));
+    protected boolean checkMandatoryFields()
+    {
+        boolean subtype = this.annotDictionary.containsKey(COSName.SUBTYPE);
+        boolean rect = this.annotDictionary.containsKey(COSName.RECT);
+        boolean f = this.annotDictionary.containsKey(COSName.F);
+        boolean contents = this.annotDictionary.containsKey(COSName.CONTENTS);
+        /*
+         * Since PDF 1.5, two optional entries are possible. These new entries seem to e compatible with the PDF/A
+         * specification (used to set a State to the annotation - ex : rejected, reviewed...)
+         */
+        boolean result = (subtype && rect && f && contents);
+        if (!result)
+        {
+            ctx.addValidationError(new ValidationError(ERROR_ANNOT_MISSING_FIELDS));
+        }
+        return result;
     }
-    return result;
-  }
-}
\ No newline at end of file
+}

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/TrapNetAnnotationValidator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/TrapNetAnnotationValidator.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/TrapNetAnnotationValidator.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/TrapNetAnnotationValidator.java Wed Mar  6 16:46:35 2013
@@ -32,33 +32,36 @@ import org.apache.pdfbox.preflight.Valid
 /**
  * Validation class for the TrapNet annotation
  */
-public class TrapNetAnnotationValidator extends AnnotationValidator {
-  /**
-   * PDFBox object which wraps the annotation dictionary
-   */
-  protected PDAnnotationUnknown pdUnk = null;
+public class TrapNetAnnotationValidator extends AnnotationValidator
+{
+    /**
+     * PDFBox object which wraps the annotation dictionary
+     */
+    protected PDAnnotationUnknown pdUnk = null;
 
-  public TrapNetAnnotationValidator(PreflightContext ctx, COSDictionary annotDictionary) {
-	    super(ctx, annotDictionary);
-    this.pdUnk = new PDAnnotationUnknown(annotDictionary);
-    this.pdAnnot = this.pdUnk;
-  }
+    public TrapNetAnnotationValidator(PreflightContext ctx, COSDictionary annotDictionary)
+    {
+        super(ctx, annotDictionary);
+        this.pdUnk = new PDAnnotationUnknown(annotDictionary);
+        this.pdAnnot = this.pdUnk;
+    }
 
-  /*
-   * (non-Javadoc)
-   * 
-   * @seenet.awl.edoc.pdfa.validation.annotation.AnnotationValidator#
-   * checkMandatoryFields(java.util.List)
-   */
-  protected boolean checkMandatoryFields() {
-    boolean subtype = this.annotDictionary.containsKey(COSName.SUBTYPE);
-    boolean rect = this.annotDictionary.containsKey(COSName.RECT);
-    boolean f = this.annotDictionary.containsKey(COSName.F);
+    /*
+     * (non-Javadoc)
+     * 
+     * @seenet.awl.edoc.pdfa.validation.annotation.AnnotationValidator# checkMandatoryFields(java.util.List)
+     */
+    protected boolean checkMandatoryFields()
+    {
+        boolean subtype = this.annotDictionary.containsKey(COSName.SUBTYPE);
+        boolean rect = this.annotDictionary.containsKey(COSName.RECT);
+        boolean f = this.annotDictionary.containsKey(COSName.F);
 
-    boolean result = (subtype && rect && f);
-    if (!result) {
-      ctx.addValidationError(new ValidationError(ERROR_ANNOT_MISSING_FIELDS));
+        boolean result = (subtype && rect && f);
+        if (!result)
+        {
+            ctx.addValidationError(new ValidationError(ERROR_ANNOT_MISSING_FIELDS));
+        }
+        return result;
     }
-    return result;
-  }
 }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/WidgetAnnotationValidator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/WidgetAnnotationValidator.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/WidgetAnnotationValidator.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/WidgetAnnotationValidator.java Wed Mar  6 16:46:35 2013
@@ -34,61 +34,65 @@ import org.apache.pdfbox.preflight.excep
 /**
  * Validation class for the Widget Annotation
  */
-public class WidgetAnnotationValidator extends AnnotationValidator {
-  /**
-   * PDFBox object which wraps the annotation dictionary
-   */
-  protected PDAnnotationWidget pdWidget = null;
+public class WidgetAnnotationValidator extends AnnotationValidator
+{
+    /**
+     * PDFBox object which wraps the annotation dictionary
+     */
+    protected PDAnnotationWidget pdWidget = null;
 
-  public WidgetAnnotationValidator(PreflightContext ctx, COSDictionary annotDictionary) {
-	    super(ctx, annotDictionary);
-    this.pdWidget = new PDAnnotationWidget(annotDictionary);
-    this.pdAnnot = this.pdWidget;
-  }
+    public WidgetAnnotationValidator(PreflightContext ctx, COSDictionary annotDictionary)
+    {
+        super(ctx, annotDictionary);
+        this.pdWidget = new PDAnnotationWidget(annotDictionary);
+        this.pdAnnot = this.pdWidget;
+    }
 
-  /**
-   * In addition of the AnnotationValidator.validate() method, this method
-   * executes the the checkAAField method.
-   * 
-   * @see org.apache.padaf.preflight.annotation.AnnotationValidator#validate(java.util.List)
-   */
-  @Override
-  public boolean validate() throws ValidationException {
-    boolean isValide = super.validate();
-    isValide = isValide && checkAAField();
-    return isValide;
-  }
+    /**
+     * In addition of the AnnotationValidator.validate() method, this method executes the the checkAAField method.
+     * 
+     * @see org.apache.padaf.preflight.annotation.AnnotationValidator#validate(java.util.List)
+     */
+    @Override
+    public boolean validate() throws ValidationException
+    {
+        boolean isValide = super.validate();
+        isValide = isValide && checkAAField();
+        return isValide;
+    }
 
-  /**
-   * The AA field is forbidden for the Widget annotation when the PDF is a
-   * PDF/A. This method return false and update the errors list if this key is
-   * present. returns true otherwise
-   * 
-   * @return
-   */
-  protected boolean checkAAField() {
-    if (this.pdWidget.getActions() != null) {
-      ctx.addValidationError(new ValidationError(ERROR_ANNOT_FORBIDDEN_AA));
-      return false;
+    /**
+     * The AA field is forbidden for the Widget annotation when the PDF is a PDF/A. This method return false and update
+     * the errors list if this key is present. returns true otherwise
+     * 
+     * @return
+     */
+    protected boolean checkAAField()
+    {
+        if (this.pdWidget.getActions() != null)
+        {
+            ctx.addValidationError(new ValidationError(ERROR_ANNOT_FORBIDDEN_AA));
+            return false;
+        }
+        return true;
     }
-    return true;
-  }
 
-  /*
-   * (non-Javadoc)
-   * 
-   * @seenet.awl.edoc.pdfa.validation.annotation.AnnotationValidator#
-   * checkMandatoryFields()
-   */
-  protected boolean checkMandatoryFields() {
-    boolean subtype = this.annotDictionary.containsKey(COSName.SUBTYPE);
-    boolean rect = this.annotDictionary.containsKey(COSName.RECT);
-    boolean f = this.annotDictionary.containsKey(COSName.F);
+    /*
+     * (non-Javadoc)
+     * 
+     * @seenet.awl.edoc.pdfa.validation.annotation.AnnotationValidator# checkMandatoryFields()
+     */
+    protected boolean checkMandatoryFields()
+    {
+        boolean subtype = this.annotDictionary.containsKey(COSName.SUBTYPE);
+        boolean rect = this.annotDictionary.containsKey(COSName.RECT);
+        boolean f = this.annotDictionary.containsKey(COSName.F);
 
-    boolean result = (subtype && rect && f);
-    if (!result) {
-      ctx.addValidationError(new ValidationError(ERROR_ANNOT_MISSING_FIELDS));
+        boolean result = (subtype && rect && f);
+        if (!result)
+        {
+            ctx.addValidationError(new ValidationError(ERROR_ANNOT_MISSING_FIELDS));
+        }
+        return result;
     }
-    return result;
-  }
 }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/pdfa/PDFAbAnnotationFactory.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/pdfa/PDFAbAnnotationFactory.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/pdfa/PDFAbAnnotationFactory.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/pdfa/PDFAbAnnotationFactory.java Wed Mar  6 16:46:35 2013
@@ -55,28 +55,30 @@ import org.apache.pdfbox.preflight.annot
 /**
  * Factory to instantiate AnnotationValidator for a PDF/A-1b validation.
  */
-public class PDFAbAnnotationFactory extends AnnotationValidatorFactory {
+public class PDFAbAnnotationFactory extends AnnotationValidatorFactory
+{
 
-	protected void initializeClasses() {
-		this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_TEXT, TextAnnotationValidator.class);
-		this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_LINK, LinkAnnotationValidator.class);
-		this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_FREETEXT, FreeTextAnnotationValidator.class);
-		this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_LINE, LineAnnotationValidator.class);
-		
-		this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_SQUARE, SquareCircleAnnotationValidator.class);
-		this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_CIRCLE, SquareCircleAnnotationValidator.class);
+    protected void initializeClasses()
+    {
+        this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_TEXT, TextAnnotationValidator.class);
+        this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_LINK, LinkAnnotationValidator.class);
+        this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_FREETEXT, FreeTextAnnotationValidator.class);
+        this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_LINE, LineAnnotationValidator.class);
 
-		this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_HIGHLIGHT, MarkupAnnotationValidator.class);
-		this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_UNDERLINE, MarkupAnnotationValidator.class);
-		this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_STRIKEOUT, MarkupAnnotationValidator.class);
-		this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_SQUILGGLY, MarkupAnnotationValidator.class);
-		
-		this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_STAMP, RubberStampAnnotationValidator.class);
-		this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_INK, InkAnnotationValdiator.class);
-		this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_POPUP, PopupAnnotationValidator.class);
-		this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_WIDGET, WidgetAnnotationValidator.class);
-		this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_PRINTERMARK, PrintMarkAnnotationValidator.class);
-		this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_TRAPNET, TrapNetAnnotationValidator.class);
-	}
+        this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_SQUARE, SquareCircleAnnotationValidator.class);
+        this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_CIRCLE, SquareCircleAnnotationValidator.class);
 
-}
\ No newline at end of file
+        this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_HIGHLIGHT, MarkupAnnotationValidator.class);
+        this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_UNDERLINE, MarkupAnnotationValidator.class);
+        this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_STRIKEOUT, MarkupAnnotationValidator.class);
+        this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_SQUILGGLY, MarkupAnnotationValidator.class);
+
+        this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_STAMP, RubberStampAnnotationValidator.class);
+        this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_INK, InkAnnotationValdiator.class);
+        this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_POPUP, PopupAnnotationValidator.class);
+        this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_WIDGET, WidgetAnnotationValidator.class);
+        this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_PRINTERMARK, PrintMarkAnnotationValidator.class);
+        this.validatorClasses.put(ANNOT_DICTIONARY_VALUE_SUBTYPE_TRAPNET, TrapNetAnnotationValidator.class);
+    }
+
+}



Mime
View raw message