pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gbaill...@apache.org
Subject svn commit: r1453416 [3/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/PreflightPath.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/PreflightPath.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/PreflightPath.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/PreflightPath.java Wed Mar  6 16:46:35 2013
@@ -23,96 +23,109 @@ package org.apache.pdfbox.preflight;
 
 import java.util.Stack;
 
-
 /**
- * Contains a stack of objects to follow the validation path.
- * Ex : 
- * - if the ValidationProcess computes a Type1Font object, this object
- * should contains a path like PDPage|PDResources|PDFont.
- * - if the ValidationProcess computes a XObject object, this object
- * could contains a path like PDPage|PDResources|PDFontType3|PDResource|PDXObject.
+ * Contains a stack of objects to follow the validation path. Ex : - if the ValidationProcess computes a Type1Font
+ * object, this object should contains a path like PDPage|PDResources|PDFont. - if the ValidationProcess computes a
+ * XObject object, this object could contains a path like PDPage|PDResources|PDFontType3|PDResource|PDXObject.
  */
-public class PreflightPath {
+public class PreflightPath
+{
 
-	@SuppressWarnings("rawtypes")
-	private Stack objectPath = new Stack();
+    @SuppressWarnings("rawtypes")
+    private Stack objectPath = new Stack();
 
-	@SuppressWarnings("rawtypes")
-	private Stack<Class> classObjPath = new Stack<Class>();
+    @SuppressWarnings("rawtypes")
+    private Stack<Class> classObjPath = new Stack<Class>();
 
-	@SuppressWarnings("unchecked")
-	public boolean pushObject(Object pathElement) {
-		boolean pushed = false;
-		if (pathElement != null) {
-			this.objectPath.push(pathElement);
-			this.classObjPath.push(pathElement.getClass());
-			pushed = true;
-		}
-		return pushed;
-	}
-
-	/**
-	 * Return the object at the given position. The object must be an
-	 * instance of the given class.
-	 * @param position
-	 * @param expectedType
-	 * @return
-	 */
-	@SuppressWarnings("unchecked")
-	public <T> T getPathElement(int position, Class<T> expectedType) {
-		if (position < 0 || position >= this.objectPath.size()) {
-			return null;
-		}
-		return (T)this.objectPath.get(position);
-	}
-
-	/**
-	 * Return the index of the first object that have the given type. 
-	 * @param type
-	 * @return the object position, -1 if the type doesn't exist in the stack.
-	 */
-	public <T> int getClosestTypePosition(Class<T> type) {
-		for (int i = this.objectPath.size(); i-->0;) {
-			if (this.classObjPath.get(i).equals(type)) {
-				return i;
-			}
-		}
-		return -1;
-	}
-
-	public <T> T getClosestPathElement(Class<T> type) {
-		return getPathElement(getClosestTypePosition(type), type);
-	}
-	
-	/**
-	 * Looks at the object at the top of this stack without removing it from the stack.
-	 * @return
-	 */
-	public Object peek() {
-		return this.objectPath.peek();
-	}
-
-	public Object pop() {
-		this.classObjPath.pop();
-		return this.objectPath.pop();
-	}
-
-	public void clear() {
-		this.classObjPath.clear();
-		this.objectPath.clear();
-	}
-
-	public int size() {
-		return this.objectPath.size();
-	}
-
-	public boolean isEmpty() {
-		return this.objectPath.isEmpty();
-	}
-
-	public boolean isExpectedType(Class<?> type) {
-		@SuppressWarnings("rawtypes")
-		Class knownType = this.classObjPath.peek();
-		return (knownType != null && (type.equals(knownType) || type.isAssignableFrom(knownType)));
-	}
+    @SuppressWarnings("unchecked")
+    public boolean pushObject(Object pathElement)
+    {
+        boolean pushed = false;
+        if (pathElement != null)
+        {
+            this.objectPath.push(pathElement);
+            this.classObjPath.push(pathElement.getClass());
+            pushed = true;
+        }
+        return pushed;
+    }
+
+    /**
+     * Return the object at the given position. The object must be an instance of the given class.
+     * 
+     * @param position
+     * @param expectedType
+     * @return
+     */
+    @SuppressWarnings("unchecked")
+    public <T> T getPathElement(int position, Class<T> expectedType)
+    {
+        if (position < 0 || position >= this.objectPath.size())
+        {
+            return null;
+        }
+        return (T) this.objectPath.get(position);
+    }
+
+    /**
+     * Return the index of the first object that have the given type.
+     * 
+     * @param type
+     * @return the object position, -1 if the type doesn't exist in the stack.
+     */
+    public <T> int getClosestTypePosition(Class<T> type)
+    {
+        for (int i = this.objectPath.size(); i-- > 0;)
+        {
+            if (this.classObjPath.get(i).equals(type))
+            {
+                return i;
+            }
+        }
+        return -1;
+    }
+
+    public <T> T getClosestPathElement(Class<T> type)
+    {
+        return getPathElement(getClosestTypePosition(type), type);
+    }
+
+    /**
+     * Looks at the object at the top of this stack without removing it from the stack.
+     * 
+     * @return
+     */
+    public Object peek()
+    {
+        return this.objectPath.peek();
+    }
+
+    public Object pop()
+    {
+        this.classObjPath.pop();
+        return this.objectPath.pop();
+    }
+
+    public void clear()
+    {
+        this.classObjPath.clear();
+        this.objectPath.clear();
+    }
+
+    public int size()
+    {
+        return this.objectPath.size();
+    }
+
+    public boolean isEmpty()
+    {
+        return this.objectPath.isEmpty();
+    }
+
+    public boolean isExpectedType(Class<?> type)
+    {
+        @SuppressWarnings("rawtypes")
+        Class knownType = this.classObjPath.peek();
+        return (knownType != null && (type.equals(knownType) || type.isAssignableFrom(knownType)));
+    }
 }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/ValidationResult.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/ValidationResult.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/ValidationResult.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/ValidationResult.java Wed Mar  6 16:46:35 2013
@@ -27,253 +27,312 @@ import java.util.List;
 import org.apache.xmpbox.XMPMetadata;
 
 /**
- * Object returned by the validate method of the PDFValidator. This object
- * contains a boolean to know if the PDF is PDF/A-1<I>x</I> compliant. If the
- * document isn't PDF/A-1<I>x</I> a list of errors is provided.
+ * Object returned by the validate method of the PDFValidator. This object contains a boolean to know if the PDF is
+ * PDF/A-1<I>x</I> compliant. If the document isn't PDF/A-1<I>x</I> a list of errors is provided.
  */
-public class ValidationResult {
-	/**
-	 * Boolean to know if the PDF is a valid PDF/A
-	 */
-	private boolean isValid = false;
-
-	/**
-	 * Errors to know why the PDF isn't valid. If the PDF is valid, this list is
-	 * empty.
-	 */
-	private List<ValidationError> lErrors = new ArrayList<ValidationError>();
-
-	/**
-	 * Object representation of the XMPMetaData contained by the pdf file
-	 * This attribute can be null if the Validation fails.
-	 */
-	private XMPMetadata xmpMetaData = null;
-
-	/**
-	 * Create a Validation result object
-	 * 
-	 * @param isValid
-	 */
-	public ValidationResult(boolean isValid) {
-		this.isValid = isValid;
-	}
-
-	/**
-	 * Create a Validation Result object. This constructor force the isValid to
-	 * false and add the given error to the list or ValidationErrors.
-	 * 
-	 * @param error
-	 *          if error is null, no error is added to the list.
-	 */
-	public ValidationResult(ValidationError error) {
-		this.isValid = false;
-		if (error != null) {
-			this.lErrors.add(error);
-		}
-	}
-
-	/**
-	 * Create a Validation Result object. This constructor force the isValid to
-	 * false and add all the given errors to the list or ValidationErrors.
-	 * 
-	 * @param error
-	 *          if error is null, no error is added to the list.
-	 */
-	public ValidationResult(List<ValidationError> errors) {
-		this.isValid = false;
-		this.lErrors = errors;
-	}
-
-	/**
-	 * Add the ValidationError object of the otherResult in the Error list of the current object.
-	 * Apply a logical AND on the isValid boolean.
-	 * @param otherResult
-	 */
-	public void mergeResult(ValidationResult otherResult) {
-		if (otherResult != null) {
-			this.lErrors.addAll(otherResult.getErrorsList());
-			this.isValid &= otherResult.isValid();
-		}
-	}
-	
-	/**
-	 * @return the xmpMetaData
-	 */
-	public XMPMetadata getXmpMetaData() {
-		return xmpMetaData;
-	}
-
-	/**
-	 * @param xmpMetaData the xmpMetaData to set
-	 */
-	void setXmpMetaData(XMPMetadata xmpMetaData) {
-		this.xmpMetaData = xmpMetaData;
-	}
-
-	/**
-	 * @return true if the PDF is valid,false otherwise
-	 */
-	public boolean isValid() {
-		return isValid;
-	}
-
-	/**
-	 * Add error to the list of ValidationError. 
-	 * If the given error is null, this method does nothing
-	 * 
-	 * @param error
-	 */
-	public void addError(ValidationError error) {
-		if (error != null) {
-			this.isValid &= error.isWarning();
-			this.lErrors.add(error);
-		}
-	}
-
-	/**
-	 * Add a set of errors to the list of ValidationError. 
-	 * If the given list is null, this method does nothing.
-	 * @param errors
-	 */
-	public void addErrors(List<ValidationError> errors) {
-		if (errors != null) {
-			for (ValidationError validationError : errors) {
-				addError(validationError);
-			}
-		}
-	}
-	
-	/**
-	 * @return the list of validation errors
-	 */
-	public List<ValidationError> getErrorsList() {
-		return this.lErrors;
-	}
-
-	/**
-	 * This Class represents an error of validation. It contains an error code and
-	 * an error explanation.
-	 */
-	public static class ValidationError {
-		/**
-		 * Error identifier. This error code can be used as identifier to
-		 * internationalize the logging message using i18n.
-		 */
-		private String errorCode;
-
-		/**
-		 * Error details
-		 */
-		private String details;
-
-		/**
-		 * false : this error can't be ignore
-		 * true : this error can be ignore
-		 */
-		private boolean isWarning = false;
-
-		// TODO Add here COSObject or the PDObject that is linked to the error may a automatic fix can be done.
-		
-		/**
-		 * Create a validation error with the given error code
-		 * 
-		 * @param errorCode
-		 */
-		public ValidationError(String errorCode) {
-			this.errorCode = errorCode;
-			if (errorCode.startsWith(PreflightConstants.ERROR_SYNTAX_COMMON)){
-				this.details = "Syntax error";
-			} else if (errorCode.startsWith(PreflightConstants.ERROR_SYNTAX_HEADER)){
-				this.details = "Body Syntax error";
-			} else if (errorCode.startsWith(PreflightConstants.ERROR_SYNTAX_BODY)){
-				this.details = "Body Syntax error";
-			} else if (errorCode.startsWith(PreflightConstants.ERROR_SYNTAX_CROSS_REF)){
-				this.details = "CrossRef Syntax error";
-			} else if (errorCode.startsWith(PreflightConstants.ERROR_SYNTAX_TRAILER)){
-				this.details = "Trailer Syntax error";
-			} else if (errorCode.startsWith(PreflightConstants.ERROR_GRAPHIC_INVALID)){
-				this.details = "Invalid Graphis object";
-			} else if (errorCode.startsWith(PreflightConstants.ERROR_GRAPHIC_TRANSPARENCY)){
-				this.details = "Invalid Graphis transparency";
-			} else if (errorCode.startsWith(PreflightConstants.ERROR_GRAPHIC_UNEXPECTED_KEY)){
-				this.details = "Unexpected key in Graphic object definition";
-			} else if (errorCode.startsWith(PreflightConstants.ERROR_GRAPHIC_INVALID_COLOR_SPACE)){
-				this.details = "Invalid Color space";
-			} else if (errorCode.startsWith(PreflightConstants.ERROR_FONTS_INVALID_DATA)){
-				this.details = "Invalid Font definition";
-			} else if (errorCode.startsWith(PreflightConstants.ERROR_FONTS_DAMAGED)){
-				this.details = "Font damaged";
-			} else if (errorCode.startsWith(PreflightConstants.ERROR_FONTS_GLYPH)){
-				this.details = "Glyph error";
-			} else if (errorCode.startsWith(PreflightConstants.ERROR_TRANSPARENCY_EXT_GRAPHICAL_STATE)){
-				this.details = "Transparency error";
-			} else if (errorCode.startsWith(PreflightConstants.ERROR_ANNOT_MISSING_FIELDS)){
-				this.details = "Missing field in an annotation definition";
-			} else if (errorCode.startsWith(PreflightConstants.ERROR_ANNOT_FORBIDDEN_ELEMENT)){
-				this.details = "Forbidden field in an annotation definition";
-			} else if (errorCode.startsWith(PreflightConstants.ERROR_ANNOT_INVALID_ELEMENT)){
-				this.details = "Invalid field value in an annotation definition";
-			} else if (errorCode.startsWith(PreflightConstants.ERROR_ACTION_INVALID_ACTIONS)){
-				this.details = "Invalid action definition";
-			} else if (errorCode.startsWith(PreflightConstants.ERROR_ACTION_FORBIDDEN_ACTIONS)){
-				this.details = "Action is forbidden";
-			} else if (errorCode.startsWith(PreflightConstants.ERROR_METADATA_MAIN)){
-				this.details = "Error on MetaData";
-			} else {
-				// default Unkown error
-				this.details = "Unknown error";
-			}
-		}
-
-		/**
-		 * Create a validation error with the given error code and the error
-		 * explanation.
-		 * 
-		 * @param errorCode
-		 *          the error code
-		 * @param details
-		 *          the error explanation
-		 */
-		public ValidationError(String errorCode, String details) {
-			this(errorCode);
-			if (details != null) {
-				StringBuilder sb = new StringBuilder(this.details.length()+details.length()+2);
-				sb.append(this.details).append(", ").append(details);
-				this.details = sb.toString(); 
-			} 
-		}
-
-		/**
-		 * @return the error code
-		 */
-		public String getErrorCode() {
-			return errorCode;
-		}
-
-		/**
-		 * @return the error explanation
-		 */
-		public String getDetails() {
-			return details;
-		}
-
-		/**
-		 * Set the error explanation
-		 * 
-		 * @param details
-		 */
-		public void setDetails(String details) {
-			this.details = details;
-		}
-
-		public boolean isWarning() {
-			return isWarning;
-		}
-
-		public void setWarning(boolean isWarning) {
-			this.isWarning = isWarning;
-		}
-		
-		
-	}
+public class ValidationResult
+{
+    /**
+     * Boolean to know if the PDF is a valid PDF/A
+     */
+    private boolean isValid = false;
+
+    /**
+     * Errors to know why the PDF isn't valid. If the PDF is valid, this list is empty.
+     */
+    private List<ValidationError> lErrors = new ArrayList<ValidationError>();
+
+    /**
+     * Object representation of the XMPMetaData contained by the pdf file This attribute can be null if the Validation
+     * fails.
+     */
+    private XMPMetadata xmpMetaData = null;
+
+    /**
+     * Create a Validation result object
+     * 
+     * @param isValid
+     */
+    public ValidationResult(boolean isValid)
+    {
+        this.isValid = isValid;
+    }
+
+    /**
+     * Create a Validation Result object. This constructor force the isValid to false and add the given error to the
+     * list or ValidationErrors.
+     * 
+     * @param error
+     *            if error is null, no error is added to the list.
+     */
+    public ValidationResult(ValidationError error)
+    {
+        this.isValid = false;
+        if (error != null)
+        {
+            this.lErrors.add(error);
+        }
+    }
+
+    /**
+     * Create a Validation Result object. This constructor force the isValid to false and add all the given errors to
+     * the list or ValidationErrors.
+     * 
+     * @param error
+     *            if error is null, no error is added to the list.
+     */
+    public ValidationResult(List<ValidationError> errors)
+    {
+        this.isValid = false;
+        this.lErrors = errors;
+    }
+
+    /**
+     * Add the ValidationError object of the otherResult in the Error list of the current object. Apply a logical AND on
+     * the isValid boolean.
+     * 
+     * @param otherResult
+     */
+    public void mergeResult(ValidationResult otherResult)
+    {
+        if (otherResult != null)
+        {
+            this.lErrors.addAll(otherResult.getErrorsList());
+            this.isValid &= otherResult.isValid();
+        }
+    }
+
+    /**
+     * @return the xmpMetaData
+     */
+    public XMPMetadata getXmpMetaData()
+    {
+        return xmpMetaData;
+    }
+
+    /**
+     * @param xmpMetaData
+     *            the xmpMetaData to set
+     */
+    void setXmpMetaData(XMPMetadata xmpMetaData)
+    {
+        this.xmpMetaData = xmpMetaData;
+    }
+
+    /**
+     * @return true if the PDF is valid,false otherwise
+     */
+    public boolean isValid()
+    {
+        return isValid;
+    }
+
+    /**
+     * Add error to the list of ValidationError. If the given error is null, this method does nothing
+     * 
+     * @param error
+     */
+    public void addError(ValidationError error)
+    {
+        if (error != null)
+        {
+            this.isValid &= error.isWarning();
+            this.lErrors.add(error);
+        }
+    }
+
+    /**
+     * Add a set of errors to the list of ValidationError. If the given list is null, this method does nothing.
+     * 
+     * @param errors
+     */
+    public void addErrors(List<ValidationError> errors)
+    {
+        if (errors != null)
+        {
+            for (ValidationError validationError : errors)
+            {
+                addError(validationError);
+            }
+        }
+    }
+
+    /**
+     * @return the list of validation errors
+     */
+    public List<ValidationError> getErrorsList()
+    {
+        return this.lErrors;
+    }
+
+    /**
+     * This Class represents an error of validation. It contains an error code and an error explanation.
+     */
+    public static class ValidationError
+    {
+        /**
+         * Error identifier. This error code can be used as identifier to internationalize the logging message using
+         * i18n.
+         */
+        private String errorCode;
+
+        /**
+         * Error details
+         */
+        private String details;
+
+        /**
+         * false : this error can't be ignore true : this error can be ignore
+         */
+        private boolean isWarning = false;
+
+        // TODO Add here COSObject or the PDObject that is linked to the error may a automatic fix can be done.
+
+        /**
+         * Create a validation error with the given error code
+         * 
+         * @param errorCode
+         */
+        public ValidationError(String errorCode)
+        {
+            this.errorCode = errorCode;
+            if (errorCode.startsWith(PreflightConstants.ERROR_SYNTAX_COMMON))
+            {
+                this.details = "Syntax error";
+            }
+            else if (errorCode.startsWith(PreflightConstants.ERROR_SYNTAX_HEADER))
+            {
+                this.details = "Body Syntax error";
+            }
+            else if (errorCode.startsWith(PreflightConstants.ERROR_SYNTAX_BODY))
+            {
+                this.details = "Body Syntax error";
+            }
+            else if (errorCode.startsWith(PreflightConstants.ERROR_SYNTAX_CROSS_REF))
+            {
+                this.details = "CrossRef Syntax error";
+            }
+            else if (errorCode.startsWith(PreflightConstants.ERROR_SYNTAX_TRAILER))
+            {
+                this.details = "Trailer Syntax error";
+            }
+            else if (errorCode.startsWith(PreflightConstants.ERROR_GRAPHIC_INVALID))
+            {
+                this.details = "Invalid Graphis object";
+            }
+            else if (errorCode.startsWith(PreflightConstants.ERROR_GRAPHIC_TRANSPARENCY))
+            {
+                this.details = "Invalid Graphis transparency";
+            }
+            else if (errorCode.startsWith(PreflightConstants.ERROR_GRAPHIC_UNEXPECTED_KEY))
+            {
+                this.details = "Unexpected key in Graphic object definition";
+            }
+            else if (errorCode.startsWith(PreflightConstants.ERROR_GRAPHIC_INVALID_COLOR_SPACE))
+            {
+                this.details = "Invalid Color space";
+            }
+            else if (errorCode.startsWith(PreflightConstants.ERROR_FONTS_INVALID_DATA))
+            {
+                this.details = "Invalid Font definition";
+            }
+            else if (errorCode.startsWith(PreflightConstants.ERROR_FONTS_DAMAGED))
+            {
+                this.details = "Font damaged";
+            }
+            else if (errorCode.startsWith(PreflightConstants.ERROR_FONTS_GLYPH))
+            {
+                this.details = "Glyph error";
+            }
+            else if (errorCode.startsWith(PreflightConstants.ERROR_TRANSPARENCY_EXT_GRAPHICAL_STATE))
+            {
+                this.details = "Transparency error";
+            }
+            else if (errorCode.startsWith(PreflightConstants.ERROR_ANNOT_MISSING_FIELDS))
+            {
+                this.details = "Missing field in an annotation definition";
+            }
+            else if (errorCode.startsWith(PreflightConstants.ERROR_ANNOT_FORBIDDEN_ELEMENT))
+            {
+                this.details = "Forbidden field in an annotation definition";
+            }
+            else if (errorCode.startsWith(PreflightConstants.ERROR_ANNOT_INVALID_ELEMENT))
+            {
+                this.details = "Invalid field value in an annotation definition";
+            }
+            else if (errorCode.startsWith(PreflightConstants.ERROR_ACTION_INVALID_ACTIONS))
+            {
+                this.details = "Invalid action definition";
+            }
+            else if (errorCode.startsWith(PreflightConstants.ERROR_ACTION_FORBIDDEN_ACTIONS))
+            {
+                this.details = "Action is forbidden";
+            }
+            else if (errorCode.startsWith(PreflightConstants.ERROR_METADATA_MAIN))
+            {
+                this.details = "Error on MetaData";
+            }
+            else
+            {
+                // default Unkown error
+                this.details = "Unknown error";
+            }
+        }
+
+        /**
+         * Create a validation error with the given error code and the error explanation.
+         * 
+         * @param errorCode
+         *            the error code
+         * @param details
+         *            the error explanation
+         */
+        public ValidationError(String errorCode, String details)
+        {
+            this(errorCode);
+            if (details != null)
+            {
+                StringBuilder sb = new StringBuilder(this.details.length() + details.length() + 2);
+                sb.append(this.details).append(", ").append(details);
+                this.details = sb.toString();
+            }
+        }
+
+        /**
+         * @return the error code
+         */
+        public String getErrorCode()
+        {
+            return errorCode;
+        }
+
+        /**
+         * @return the error explanation
+         */
+        public String getDetails()
+        {
+            return details;
+        }
+
+        /**
+         * Set the error explanation
+         * 
+         * @param details
+         */
+        public void setDetails(String details)
+        {
+            this.details = details;
+        }
+
+        public boolean isWarning()
+        {
+            return isWarning;
+        }
+
+        public void setWarning(boolean isWarning)
+        {
+            this.isWarning = isWarning;
+        }
+
+    }
 }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/Validator_A1b.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/Validator_A1b.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/Validator_A1b.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/Validator_A1b.java Wed Mar  6 16:46:35 2013
@@ -28,9 +28,6 @@ import org.apache.pdfbox.preflight.Valid
 import org.apache.pdfbox.preflight.exception.SyntaxValidationException;
 import org.apache.pdfbox.preflight.parser.PreflightParser;
 
-
-
-
 /**
  * This class is a simple main class used to check the validity of a pdf file.
  * 
@@ -39,39 +36,48 @@ import org.apache.pdfbox.preflight.parse
  * @author gbailleul
  * 
  */
-public class Validator_A1b {
-
-	public static void main(String[] args) throws Exception {
-		if (args.length == 0) {
-			System.out
-			.println("Usage : java org.apache.pdfbox.preflight.Validator_A1b <file path>");
-			System.out.println("Version : "+Version.getVersion());
-			System.exit(1);
-		}
-
-		ValidationResult result = null;
-		FileDataSource fd = new FileDataSource(args[0]);
-		PreflightParser parser = new PreflightParser(fd);
-		try {
-			parser.parse();
-			PreflightDocument document = parser.getPreflightDocument();
-			document.validate();
-			result = document.getResult();
-			document.close();
-		} catch (SyntaxValidationException e) {
-			result = e.getResult();
-		}
-
-		if (result.isValid()) {
-			System.out.println("The file " + args[0] + " is a valid PDF/A-1b file");
-			System.exit(0);
-		} else {
-			System.out.println("The file" + args[0] + " is not valid, error(s) :");
-			for (ValidationError error : result.getErrorsList()) {
-				System.out.println(error.getErrorCode() + " : " + error.getDetails());
-			}
+public class Validator_A1b
+{
 
-			System.exit(-1);
-		}
-	}
+    public static void main(String[] args) throws Exception
+    {
+        if (args.length == 0)
+        {
+            System.out.println("Usage : java org.apache.pdfbox.preflight.Validator_A1b <file path>");
+            System.out.println("Version : " + Version.getVersion());
+            System.exit(1);
+        }
+
+        ValidationResult result = null;
+        FileDataSource fd = new FileDataSource(args[0]);
+        PreflightParser parser = new PreflightParser(fd);
+        try
+        {
+            parser.parse();
+            PreflightDocument document = parser.getPreflightDocument();
+            document.validate();
+            result = document.getResult();
+            document.close();
+        }
+        catch (SyntaxValidationException e)
+        {
+            result = e.getResult();
+        }
+
+        if (result.isValid())
+        {
+            System.out.println("The file " + args[0] + " is a valid PDF/A-1b file");
+            System.exit(0);
+        }
+        else
+        {
+            System.out.println("The file" + args[0] + " is not valid, error(s) :");
+            for (ValidationError error : result.getErrorsList())
+            {
+                System.out.println(error.getErrorCode() + " : " + error.getDetails());
+            }
+
+            System.exit(-1);
+        }
+    }
 }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/AbstractActionManager.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/AbstractActionManager.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/AbstractActionManager.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/AbstractActionManager.java Wed Mar  6 16:46:35 2013
@@ -30,132 +30,138 @@ import org.apache.pdfbox.preflight.Prefl
 import org.apache.pdfbox.preflight.ValidationResult.ValidationError;
 import org.apache.pdfbox.preflight.exception.ValidationException;
 
-public abstract class AbstractActionManager {
-  /**
-   * ActionManager factory used to create new ActionManager
-   */
-  protected ActionManagerFactory actionFact = null;
-  /**
-   * Action name in a Additional Action dictionary
-   */
-  protected String aaKey = null;
-  /**
-   * The action dictionary checked by this class
-   */
-  protected COSDictionary actionDictionnary = null;
-  /**
-   * The validation context
-   */
-  protected PreflightContext context = null;
-
-  /**
-   * 
-   * @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 ctx the validation context .
-   * @param aaKey
-   *          The name of the key which identify the action in a additional
-   *          action dictionary.
-   */
-  AbstractActionManager(ActionManagerFactory amFact, COSDictionary adict, PreflightContext ctx, String aaKey) {
-    this.actionFact = amFact;
-    this.actionDictionnary = adict;
-    this.aaKey = aaKey;
-    this.context = ctx;
-  }
-
-  /**
-   * @return the isAdditionalAction
-   */
-  public boolean isAdditionalAction() {
-    return this.aaKey != null;
-  }
-
-  /**
-   * @return the actionDictionnary
-   */
-  public COSDictionary getActionDictionnary() {
-    return actionDictionnary;
-  }
-
-  /**
-   * @return the aaKey
-   */
-  public String getAdditionalActionKey() {
-    return aaKey;
-  }
-
-  /**
-   * This method create a list of Action Managers which represent actions in the
-   * Next entry of the current action dictionary. For each Next Action, the
-   * innerValid is called and the method returns false if a validation fails.
-   * 
-   * @return True if all Next Action are valid, false otherwise.
-   * @throws ValidationException
-   */
-  protected boolean validNextActions() throws ValidationException {
-    List<AbstractActionManager> lActions = this.actionFact.getNextActions(this.context, this.actionDictionnary);
-    for (AbstractActionManager nAction : lActions) {
-      if (!nAction.innerValid()) {
-        return false;
-      }
-    }
-    return true;
-  }
-
-  /**
-   * Call the valid(boolean, List) method with the additonalActionAuth set to
-   * false.
-   * 
-   * @param error
-   *          the validation error list to updated if the validation fails.
-   * @return
-   * @throws ValidationException
-   */
-  public boolean valid() throws ValidationException {
-    return valid(false);
-  }
-
-  /**
-   * Validate an Action dictionary.
-   * 
-   * Return false if the dictionary is invalid (ex : missing key). If the
-   * ActionManager represents an AdditionalAction, this method returns false and
-   * updates the error list when the additonalActionAuth parameter is set to
-   * false.
-   * 
-   * This method call the innerValid method to process specific checks according
-   * to the action type.
-   * 
-   * If innerValid successes, all actions contained in the Next entry of the
-   * Action dictionary are validated.
-   * 
-   * @param additonalActionAuth
-   *          boolean to know if an additional action is authorized.
-   * @return 
-   * @throws ValidationException
-   */
-  public boolean valid(boolean additonalActionAuth) throws ValidationException {
-    if (isAdditionalAction() && !additonalActionAuth) {
-      context.addValidationError(new ValidationError(ERROR_ACTION_FORBIDDEN_ADDITIONAL_ACTION, "Additional Action are forbidden" ));
-      return false;
-    }
-
-    if (innerValid()) {
-      return validNextActions();
-    }
-
-    return true;
-  }
-
-  /**
-   * This method must be implemented by inherited classes to process specific
-   * validation.
-   * 
-   * @return True if the action is valid, false otherwise.
-   */
-  protected abstract boolean innerValid();
+public abstract class AbstractActionManager
+{
+    /**
+     * ActionManager factory used to create new ActionManager
+     */
+    protected ActionManagerFactory actionFact = null;
+    /**
+     * Action name in a Additional Action dictionary
+     */
+    protected String aaKey = null;
+    /**
+     * The action dictionary checked by this class
+     */
+    protected COSDictionary actionDictionnary = null;
+    /**
+     * The validation context
+     */
+    protected PreflightContext context = null;
+
+    /**
+     * 
+     * @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 ctx
+     *            the validation context .
+     * @param aaKey
+     *            The name of the key which identify the action in a additional action dictionary.
+     */
+    AbstractActionManager(ActionManagerFactory amFact, COSDictionary adict, PreflightContext ctx, String aaKey)
+    {
+        this.actionFact = amFact;
+        this.actionDictionnary = adict;
+        this.aaKey = aaKey;
+        this.context = ctx;
+    }
+
+    /**
+     * @return the isAdditionalAction
+     */
+    public boolean isAdditionalAction()
+    {
+        return this.aaKey != null;
+    }
+
+    /**
+     * @return the actionDictionnary
+     */
+    public COSDictionary getActionDictionnary()
+    {
+        return actionDictionnary;
+    }
+
+    /**
+     * @return the aaKey
+     */
+    public String getAdditionalActionKey()
+    {
+        return aaKey;
+    }
+
+    /**
+     * This method create a list of Action Managers which represent actions in the Next entry of the current action
+     * dictionary. For each Next Action, the innerValid is called and the method returns false if a validation fails.
+     * 
+     * @return True if all Next Action are valid, false otherwise.
+     * @throws ValidationException
+     */
+    protected boolean validNextActions() throws ValidationException
+    {
+        List<AbstractActionManager> lActions = this.actionFact.getNextActions(this.context, this.actionDictionnary);
+        for (AbstractActionManager nAction : lActions)
+        {
+            if (!nAction.innerValid())
+            {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * Call the valid(boolean, List) method with the additonalActionAuth set to false.
+     * 
+     * @param error
+     *            the validation error list to updated if the validation fails.
+     * @return
+     * @throws ValidationException
+     */
+    public boolean valid() throws ValidationException
+    {
+        return valid(false);
+    }
+
+    /**
+     * Validate an Action dictionary.
+     * 
+     * Return false if the dictionary is invalid (ex : missing key). If the ActionManager represents an
+     * AdditionalAction, this method returns false and updates the error list when the additonalActionAuth parameter is
+     * set to false.
+     * 
+     * This method call the innerValid method to process specific checks according to the action type.
+     * 
+     * If innerValid successes, all actions contained in the Next entry of the Action dictionary are validated.
+     * 
+     * @param additonalActionAuth
+     *            boolean to know if an additional action is authorized.
+     * @return
+     * @throws ValidationException
+     */
+    public boolean valid(boolean additonalActionAuth) throws ValidationException
+    {
+        if (isAdditionalAction() && !additonalActionAuth)
+        {
+            context.addValidationError(new ValidationError(ERROR_ACTION_FORBIDDEN_ADDITIONAL_ACTION,
+                    "Additional Action are forbidden"));
+            return false;
+        }
+
+        if (innerValid())
+        {
+            return validNextActions();
+        }
+
+        return true;
+    }
+
+    /**
+     * This method must be implemented by inherited classes to process specific validation.
+     * 
+     * @return True if the action is valid, false otherwise.
+     */
+    protected abstract boolean innerValid();
 }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/ActionManagerFactory.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/ActionManagerFactory.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/ActionManagerFactory.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/ActionManagerFactory.java Wed Mar  6 16:46:35 2013
@@ -57,228 +57,249 @@ import org.apache.pdfbox.preflight.Prefl
 import org.apache.pdfbox.preflight.exception.ValidationException;
 import org.apache.pdfbox.preflight.utils.COSUtils;
 
-public class ActionManagerFactory {
-	/**
-	 * This method extract actions from the given dictionary. An action is
-	 * identified by the following entries :
-	 * <UL>
-	 * <li>A (Action) : Available in Annotations, Outline items
-	 * <li>OpenAction (OpenAction) : Available in the Catalog dictionary
-	 * <li>AA (Additional Action) : Available in the Catalog dictionary,
-	 * Annotations, Pages
-	 * </UL>
-	 * 
-	 * If there are no action, an empty list is returned.
-	 * 
-	 * @param dictionary
-	 * @param cDoc
-	 * @return
-	 * @throws ValidationException
-	 */
-	public final List<AbstractActionManager> getActionManagers(PreflightContext ctx, COSDictionary dictionary) 
-	throws ValidationException {
-		List<AbstractActionManager> result = new ArrayList<AbstractActionManager>(0);
-		Map<COSObjectKey, Boolean> alreadyCreated = new HashMap<COSObjectKey, Boolean>();
-
-		COSBase aDict = dictionary.getDictionaryObject(COSName.A);
-		if (aDict != null) {
-			callCreateAction(aDict, ctx, result, alreadyCreated);
-		}
-
-		COSDocument cosDocument = ctx.getDocument().getDocument();
-		COSBase oaDict = dictionary.getDictionaryObject(DICTIONARY_KEY_OPEN_ACTION);
-		if (oaDict != null) {
-			if (!COSUtils.isArray(oaDict, cosDocument)) {
-				callCreateAction(oaDict, ctx, result, alreadyCreated);
-			} 
-			// else Nothing to do because of an array contains a Destination not an
-			// action.
-		}
-
-		COSBase aa = dictionary.getDictionaryObject(DICTIONARY_KEY_ADDITIONAL_ACTION);
-		if (aa != null) {
-			COSDictionary aaDict = COSUtils.getAsDictionary(aa, cosDocument);
-			if (aaDict != null) {
-				for (Object key : aaDict.keySet()) {
-					COSName name = (COSName) key;
-					callCreateAction(aaDict.getItem(name), ctx, result, name.getName(), alreadyCreated);
-				}
-			}
-		}
-		return result;
-	}
-
-	/**
-	 * Call the callCreateAction(COSBase, COSDocument, List<ActionManager>,
-	 * String) method with null as isAA parameter.
-	 * 
-	 * @param aDict
-	 *          a COSBase object (COSObject or COSDictionary) which represent the
-	 *          action dictionary.
-	 * @param ctx
-	 *          the preflight context.
-	 * @param result
-	 *          the list of ActionManager to updated if the aDict parameter is
-	 *          valid.
-	 * @param alreadyCreated This map is used to know if an Action has already been validated. It is
-	 * useful to avoid infinite loop in an action which has a Next entry.
-	 * @throws ValidationException
-	 */
-	private void callCreateAction(COSBase aDict, PreflightContext ctx, List<AbstractActionManager> result, Map<COSObjectKey, Boolean> alreadyCreated) throws ValidationException {
-		callCreateAction(aDict, ctx, result, null, alreadyCreated);
-	}
-
-	/**
-	 * Call the create action to add the ActionManager to the result list. If the
-	 * aDict parameter isn't an instance of COSDictionary, this method throws a
-	 * ValdiationException. If the aDict parameter is a reference to a
-	 * COSDicitonary, the action manager is create only if the linked COSObjectKey
-	 * is missing from the "alreadyCreated" map, in this case the action is added
-	 * to the map. If the aDict parameter is an instance of COSDIctionary, it is
-	 * impossible to check if the ActionManager already exists in the
-	 * "alreadyCreated" map.
-	 * 
-	 * @param aDict
-	 *          a COSBase object (COSObject or COSDictionary) which represent the
-	 *          action dictionary.
-	 * @param ctx
-	 *          the preflight validation context.
-	 * @param result
-	 *          the list of ActionManager to updated if the aDict parameter is
-	 *          valid.
-	 * @param additionActionKey
-	 *          the Action identifier if it is an additional action
-     * @param alreadyCreated This map is used to know if an Action has already been validated. It is
-	 * useful to avoid infinite loop in an action which has a Next entry.
-	 * @throws ValidationException
-	 */
-	private void callCreateAction(COSBase aDict, PreflightContext ctx, List<AbstractActionManager> result, String additionActionKey, Map<COSObjectKey, Boolean> alreadyCreated)
-	throws ValidationException {
-		COSDocument cosDocument = ctx.getDocument().getDocument();
-		if (COSUtils.isDictionary(aDict, cosDocument)) {
-			if (aDict instanceof COSObject) {
-				COSObjectKey cok = new COSObjectKey((COSObject) aDict);
-				if (!alreadyCreated.containsKey(cok)) {
-					result.add(createActionManager(ctx, COSUtils.getAsDictionary(aDict, cosDocument), additionActionKey));
-					alreadyCreated.put(cok, true);
-				}
-			} else {
-				result.add(createActionManager(ctx, COSUtils.getAsDictionary(aDict, cosDocument), additionActionKey));
-			}
-		} else {
-			throw new ValidationException("Action entry isn't an instance of COSDictionary");
-		}
-	}
-
-	/**
-	 * Returns all actions contained by the Next entry. If the action dictionary
-	 * doesn't have Next action, the result is an empty list.
-	 * 
-	 * @param actionDictionary
-	 *          the action dictionary which contains Next entry
-	 * @param cDoc
-	 *          the COSDocument which contains actions.
-	 * @return
-	 * @throws ValidationException
-	 */
-	public final List<AbstractActionManager> getNextActions(PreflightContext ctx, COSDictionary actionDictionary)
-	throws ValidationException {
-		List<AbstractActionManager> result = new ArrayList<AbstractActionManager>(0);
-		Map<COSObjectKey, Boolean> alreadyCreated = new HashMap<COSObjectKey, Boolean>();
-		
-		COSBase nextDict = actionDictionary.getDictionaryObject(ACTION_DICTIONARY_KEY_NEXT);
-		if (nextDict != null) {
-			COSDocument cosDocument = ctx.getDocument().getDocument();
-			if (COSUtils.isArray(nextDict, cosDocument)) {
-				COSArray array = COSUtils.getAsArray(nextDict, cosDocument);
-				// ---- Next may contains an array of Action dictionary
-				for (int i = 0; i < array.size(); ++i) {
-					callCreateAction(array.get(i), ctx, result, alreadyCreated);
-				}
-			} else {
-				// ---- Next field contains a Dictionary or a reference to a Dictionary
-				callCreateAction(nextDict, ctx, result, alreadyCreated);
-			}
-		}
-		return result;
-	}
-
-	/**
-	 * Create an instance of ActionManager according to the value of the S entry.
-	 * If the type entry isn't Action, a ValidationException will be thrown.
-	 * 
-	 * If the action type isn't authorized in a PDF/A file, an instance of
-	 * InvalidAction is returned.
-	 * 
-	 * @param ctx
-	 * @param action
-	 *          the action dictionary used to instantiate the ActionManager
-	 * @param isAA
-	 *          the Action identifier if it is an additional action
-	 * @return
-	 * @throws ValidationException
-	 */
-	protected AbstractActionManager createActionManager(PreflightContext ctx, COSDictionary action, String aaKey) 
-	throws ValidationException {
-
-		String type = action.getNameAsString(COSName.TYPE);
-		if (type != null && !ACTION_DICTIONARY_VALUE_TYPE.equals(type)) {
-			throw new ValidationException("The given dictionary isn't the dictionary of an Action");
-		}
-
-		// ---- S is a mandatory fields. If S entry is missing, the return will
-		// return the InvalidAction manager
-		String s = action.getNameAsString(COSName.S);
-
-		// --- Here is authorized actions
-		if (ACTION_DICTIONARY_VALUE_ATYPE_GOTO.equals(s)) {
-			return new GoToAction(this, action, ctx, aaKey);
-		}
-
-		if (ACTION_DICTIONARY_VALUE_ATYPE_GOTOR.equals(s)) {
-			return new GoToRemoteAction(this, action, ctx, aaKey);
-		}
-
-		if (ACTION_DICTIONARY_VALUE_ATYPE_THREAD.equals(s)) {
-			return new ThreadAction(this, action, ctx, aaKey);
-		}
-
-		if (ACTION_DICTIONARY_VALUE_ATYPE_URI.equals(s)) {
-			return new UriAction(this, action, ctx, aaKey);
-		}
-
-		if (ACTION_DICTIONARY_VALUE_ATYPE_HIDE.equals(s)) {
-			return new HideAction(this, action, ctx, aaKey);
-		}
-
-		if (ACTION_DICTIONARY_VALUE_ATYPE_NAMED.equals(s)) {
-			return new NamedAction(this, action, ctx, aaKey);
-		}
-
-		if (ACTION_DICTIONARY_VALUE_ATYPE_SUBMIT.equals(s)) {
-			return new SubmitAction(this, action, ctx, aaKey);
-		}
-
-		// --- Here is forbidden actions
-		if (ACTION_DICTIONARY_VALUE_ATYPE_LAUNCH.equals(s) || 
-				ACTION_DICTIONARY_VALUE_ATYPE_SOUND.equals(s) ||
-				ACTION_DICTIONARY_VALUE_ATYPE_MOVIE.equals(s) ||
-				ACTION_DICTIONARY_VALUE_ATYPE_RESET.equals(s) ||
-				ACTION_DICTIONARY_VALUE_ATYPE_IMPORT.equals(s) ||
-				ACTION_DICTIONARY_VALUE_ATYPE_JAVASCRIPT.equals(s) ||
-				ACTION_DICTIONARY_VALUE_ATYPE_SETSTATE.equals(s) ||
-				ACTION_DICTIONARY_VALUE_ATYPE_NOOP.equals(s)) {
-			return new InvalidAction(this, action, ctx, aaKey,s);
-		}
-
-		// ---- The default ActionManager is the undefined one.
-		// Actions defined in a PDF Reference greater than 1.4 will be considered as
-		// Undefined actions, here the list of new actions until the PDF 1.6 :
-		// # GoToE (1.6) : Not PDF/A, uses EmbeddedFiles.
-		// # SetOCGState (1.5) : Not PDF/A, uses optional content.
-		// # Rendition (1.5) : Not PDF/A, use multimedia content.
-		// # Trans (1.5) : ??
-		// # GoTo3DView (1.6) : ??
-		return new UndefAction(this, action, ctx, aaKey, s);
-	}
+public class ActionManagerFactory
+{
+    /**
+     * This method extract actions from the given dictionary. An action is identified by the following entries :
+     * <UL>
+     * <li>A (Action) : Available in Annotations, Outline items
+     * <li>OpenAction (OpenAction) : Available in the Catalog dictionary
+     * <li>AA (Additional Action) : Available in the Catalog dictionary, Annotations, Pages
+     * </UL>
+     * 
+     * If there are no action, an empty list is returned.
+     * 
+     * @param dictionary
+     * @param cDoc
+     * @return
+     * @throws ValidationException
+     */
+    public final List<AbstractActionManager> getActionManagers(PreflightContext ctx, COSDictionary dictionary)
+            throws ValidationException
+    {
+        List<AbstractActionManager> result = new ArrayList<AbstractActionManager>(0);
+        Map<COSObjectKey, Boolean> alreadyCreated = new HashMap<COSObjectKey, Boolean>();
+
+        COSBase aDict = dictionary.getDictionaryObject(COSName.A);
+        if (aDict != null)
+        {
+            callCreateAction(aDict, ctx, result, alreadyCreated);
+        }
+
+        COSDocument cosDocument = ctx.getDocument().getDocument();
+        COSBase oaDict = dictionary.getDictionaryObject(DICTIONARY_KEY_OPEN_ACTION);
+        if (oaDict != null)
+        {
+            if (!COSUtils.isArray(oaDict, cosDocument))
+            {
+                callCreateAction(oaDict, ctx, result, alreadyCreated);
+            }
+            // else Nothing to do because of an array contains a Destination not an
+            // action.
+        }
+
+        COSBase aa = dictionary.getDictionaryObject(DICTIONARY_KEY_ADDITIONAL_ACTION);
+        if (aa != null)
+        {
+            COSDictionary aaDict = COSUtils.getAsDictionary(aa, cosDocument);
+            if (aaDict != null)
+            {
+                for (Object key : aaDict.keySet())
+                {
+                    COSName name = (COSName) key;
+                    callCreateAction(aaDict.getItem(name), ctx, result, name.getName(), alreadyCreated);
+                }
+            }
+        }
+        return result;
+    }
+
+    /**
+     * Call the callCreateAction(COSBase, COSDocument, List<ActionManager>, String) method with null as isAA parameter.
+     * 
+     * @param aDict
+     *            a COSBase object (COSObject or COSDictionary) which represent the action dictionary.
+     * @param ctx
+     *            the preflight context.
+     * @param result
+     *            the list of ActionManager to updated if the aDict parameter is valid.
+     * @param alreadyCreated
+     *            This map is used to know if an Action has already been validated. It is useful to avoid infinite loop
+     *            in an action which has a Next entry.
+     * @throws ValidationException
+     */
+    private void callCreateAction(COSBase aDict, PreflightContext ctx, List<AbstractActionManager> result,
+            Map<COSObjectKey, Boolean> alreadyCreated) throws ValidationException
+    {
+        callCreateAction(aDict, ctx, result, null, alreadyCreated);
+    }
+
+    /**
+     * Call the create action to add the ActionManager to the result list. If the aDict parameter isn't an instance of
+     * COSDictionary, this method throws a ValdiationException. If the aDict parameter is a reference to a
+     * COSDicitonary, the action manager is create only if the linked COSObjectKey is missing from the "alreadyCreated"
+     * map, in this case the action is added to the map. If the aDict parameter is an instance of COSDIctionary, it is
+     * impossible to check if the ActionManager already exists in the "alreadyCreated" map.
+     * 
+     * @param aDict
+     *            a COSBase object (COSObject or COSDictionary) which represent the action dictionary.
+     * @param ctx
+     *            the preflight validation context.
+     * @param result
+     *            the list of ActionManager to updated if the aDict parameter is valid.
+     * @param additionActionKey
+     *            the Action identifier if it is an additional action
+     * @param alreadyCreated
+     *            This map is used to know if an Action has already been validated. It is useful to avoid infinite loop
+     *            in an action which has a Next entry.
+     * @throws ValidationException
+     */
+    private void callCreateAction(COSBase aDict, PreflightContext ctx, List<AbstractActionManager> result,
+            String additionActionKey, Map<COSObjectKey, Boolean> alreadyCreated) throws ValidationException
+    {
+        COSDocument cosDocument = ctx.getDocument().getDocument();
+        if (COSUtils.isDictionary(aDict, cosDocument))
+        {
+            if (aDict instanceof COSObject)
+            {
+                COSObjectKey cok = new COSObjectKey((COSObject) aDict);
+                if (!alreadyCreated.containsKey(cok))
+                {
+                    result.add(createActionManager(ctx, COSUtils.getAsDictionary(aDict, cosDocument), additionActionKey));
+                    alreadyCreated.put(cok, true);
+                }
+            }
+            else
+            {
+                result.add(createActionManager(ctx, COSUtils.getAsDictionary(aDict, cosDocument), additionActionKey));
+            }
+        }
+        else
+        {
+            throw new ValidationException("Action entry isn't an instance of COSDictionary");
+        }
+    }
+
+    /**
+     * Returns all actions contained by the Next entry. If the action dictionary doesn't have Next action, the result is
+     * an empty list.
+     * 
+     * @param actionDictionary
+     *            the action dictionary which contains Next entry
+     * @param cDoc
+     *            the COSDocument which contains actions.
+     * @return
+     * @throws ValidationException
+     */
+    public final List<AbstractActionManager> getNextActions(PreflightContext ctx, COSDictionary actionDictionary)
+            throws ValidationException
+    {
+        List<AbstractActionManager> result = new ArrayList<AbstractActionManager>(0);
+        Map<COSObjectKey, Boolean> alreadyCreated = new HashMap<COSObjectKey, Boolean>();
+
+        COSBase nextDict = actionDictionary.getDictionaryObject(ACTION_DICTIONARY_KEY_NEXT);
+        if (nextDict != null)
+        {
+            COSDocument cosDocument = ctx.getDocument().getDocument();
+            if (COSUtils.isArray(nextDict, cosDocument))
+            {
+                COSArray array = COSUtils.getAsArray(nextDict, cosDocument);
+                // ---- Next may contains an array of Action dictionary
+                for (int i = 0; i < array.size(); ++i)
+                {
+                    callCreateAction(array.get(i), ctx, result, alreadyCreated);
+                }
+            }
+            else
+            {
+                // ---- Next field contains a Dictionary or a reference to a Dictionary
+                callCreateAction(nextDict, ctx, result, alreadyCreated);
+            }
+        }
+        return result;
+    }
+
+    /**
+     * Create an instance of ActionManager according to the value of the S entry. If the type entry isn't Action, a
+     * ValidationException will be thrown.
+     * 
+     * If the action type isn't authorized in a PDF/A file, an instance of InvalidAction is returned.
+     * 
+     * @param ctx
+     * @param action
+     *            the action dictionary used to instantiate the ActionManager
+     * @param isAA
+     *            the Action identifier if it is an additional action
+     * @return
+     * @throws ValidationException
+     */
+    protected AbstractActionManager createActionManager(PreflightContext ctx, COSDictionary action, String aaKey)
+            throws ValidationException
+    {
+
+        String type = action.getNameAsString(COSName.TYPE);
+        if (type != null && !ACTION_DICTIONARY_VALUE_TYPE.equals(type))
+        {
+            throw new ValidationException("The given dictionary isn't the dictionary of an Action");
+        }
+
+        // ---- S is a mandatory fields. If S entry is missing, the return will
+        // return the InvalidAction manager
+        String s = action.getNameAsString(COSName.S);
+
+        // --- Here is authorized actions
+        if (ACTION_DICTIONARY_VALUE_ATYPE_GOTO.equals(s))
+        {
+            return new GoToAction(this, action, ctx, aaKey);
+        }
+
+        if (ACTION_DICTIONARY_VALUE_ATYPE_GOTOR.equals(s))
+        {
+            return new GoToRemoteAction(this, action, ctx, aaKey);
+        }
+
+        if (ACTION_DICTIONARY_VALUE_ATYPE_THREAD.equals(s))
+        {
+            return new ThreadAction(this, action, ctx, aaKey);
+        }
+
+        if (ACTION_DICTIONARY_VALUE_ATYPE_URI.equals(s))
+        {
+            return new UriAction(this, action, ctx, aaKey);
+        }
+
+        if (ACTION_DICTIONARY_VALUE_ATYPE_HIDE.equals(s))
+        {
+            return new HideAction(this, action, ctx, aaKey);
+        }
+
+        if (ACTION_DICTIONARY_VALUE_ATYPE_NAMED.equals(s))
+        {
+            return new NamedAction(this, action, ctx, aaKey);
+        }
+
+        if (ACTION_DICTIONARY_VALUE_ATYPE_SUBMIT.equals(s))
+        {
+            return new SubmitAction(this, action, ctx, aaKey);
+        }
+
+        // --- Here is forbidden actions
+        if (ACTION_DICTIONARY_VALUE_ATYPE_LAUNCH.equals(s) || ACTION_DICTIONARY_VALUE_ATYPE_SOUND.equals(s)
+                || ACTION_DICTIONARY_VALUE_ATYPE_MOVIE.equals(s) || ACTION_DICTIONARY_VALUE_ATYPE_RESET.equals(s)
+                || ACTION_DICTIONARY_VALUE_ATYPE_IMPORT.equals(s) || ACTION_DICTIONARY_VALUE_ATYPE_JAVASCRIPT.equals(s)
+                || ACTION_DICTIONARY_VALUE_ATYPE_SETSTATE.equals(s) || ACTION_DICTIONARY_VALUE_ATYPE_NOOP.equals(s))
+        {
+            return new InvalidAction(this, action, ctx, aaKey, s);
+        }
+
+        // ---- The default ActionManager is the undefined one.
+        // Actions defined in a PDF Reference greater than 1.4 will be considered as
+        // Undefined actions, here the list of new actions until the PDF 1.6 :
+        // # GoToE (1.6) : Not PDF/A, uses EmbeddedFiles.
+        // # SetOCGState (1.5) : Not PDF/A, uses optional content.
+        // # Rendition (1.5) : Not PDF/A, use multimedia content.
+        // # Trans (1.5) : ??
+        // # GoTo3DView (1.6) : ??
+        return new UndefAction(this, action, ctx, aaKey, s);
+    }
 }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/GoToAction.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/GoToAction.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/GoToAction.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/GoToAction.java Wed Mar  6 16:46:35 2013
@@ -33,54 +33,53 @@ import org.apache.pdfbox.preflight.Valid
 import org.apache.pdfbox.preflight.utils.COSUtils;
 
 /**
- * ActionManager for the GoTo action GoToAction is valid if the D entry is
- * present.
+ * ActionManager for the GoTo action GoToAction is valid if the D entry is present.
  */
-public class GoToAction extends AbstractActionManager {
+public class GoToAction 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 aa
-   *          The name of the key which identify the action in a additional
-   *          action dictionary.
-   */
-  public GoToAction(ActionManagerFactory amFact, COSDictionary adict,
-      PreflightContext ctx, String aa) {
-    super(amFact, adict, ctx, aa);
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see
-   * net.awl.edoc.pdfa.validation.actions.AbstractActionManager#valid(java.util
-   * .List)
-   */
-  @Override
-  protected boolean innerValid() {
-    COSBase d = this.actionDictionnary.getItem(COSName.D);
-
-    // ---- D entry is mandatory
-    if (d == null) {
-      context.addValidationError(new ValidationError(ERROR_ACTION_MISING_KEY,
-          "D entry is mandatory for the GoToActions"));
-      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 aa
+     *            The name of the key which identify the action in a additional action dictionary.
+     */
+    public GoToAction(ActionManagerFactory amFact, COSDictionary adict, PreflightContext ctx, String aa)
+    {
+        super(amFact, adict, ctx, aa);
     }
 
-	COSDocument cosDocument = this.context.getDocument().getDocument();
-    if (!(d instanceof COSName || COSUtils.isString(d, cosDocument) || COSUtils.isArray(d, cosDocument))) {
-      context.addValidationError(new ValidationError(ERROR_ACTION_INVALID_TYPE, "Type of D entry is invalid"));
-      return false;
-    }
+    /*
+     * (non-Javadoc)
+     * 
+     * @see net.awl.edoc.pdfa.validation.actions.AbstractActionManager#valid(java.util .List)
+     */
+    @Override
+    protected boolean innerValid()
+    {
+        COSBase d = this.actionDictionnary.getItem(COSName.D);
+
+        // ---- D entry is mandatory
+        if (d == null)
+        {
+            context.addValidationError(new ValidationError(ERROR_ACTION_MISING_KEY,
+                    "D entry is mandatory for the GoToActions"));
+            return false;
+        }
+
+        COSDocument cosDocument = this.context.getDocument().getDocument();
+        if (!(d instanceof COSName || COSUtils.isString(d, cosDocument) || COSUtils.isArray(d, cosDocument)))
+        {
+            context.addValidationError(new ValidationError(ERROR_ACTION_INVALID_TYPE, "Type of D entry is invalid"));
+            return false;
+        }
 
-    return true;
-  }
+        return true;
+    }
 
 }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/GoToRemoteAction.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/GoToRemoteAction.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/GoToRemoteAction.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/GoToRemoteAction.java Wed Mar  6 16:46:35 2013
@@ -30,45 +30,45 @@ import org.apache.pdfbox.preflight.Prefl
 import org.apache.pdfbox.preflight.ValidationResult.ValidationError;
 
 /**
- * ActionManager for the GoToRemote action GoToRemoteAction is valid if the F
- * entry is present.
+ * ActionManager for the GoToRemote action GoToRemoteAction is valid if the F entry is present.
  */
-public class GoToRemoteAction extends GoToAction {
+public class GoToRemoteAction extends GoToAction
+{
 
-  /**
-   * 
-   * @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 GoToRemoteAction(ActionManagerFactory amFact, COSDictionary adict, PreflightContext ctx, String aaKey) {
-    super(amFact, adict, ctx, aaKey);
-  }
+    /**
+     * 
+     * @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 GoToRemoteAction(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() {
-    if (super.innerValid()) {
-      COSBase f = this.actionDictionnary.getItem(COSName.F);
-      if (f == null) {
-        context.addValidationError(new ValidationError(ERROR_ACTION_MISING_KEY, 
-        		"F entry is mandatory for the GoToRemoteActions"));
-        return false;
-      }
+    /*
+     * (non-Javadoc)
+     * 
+     * @see net.awl.edoc.pdfa.validation.actions.AbstractActionManager#valid(java.util .List)
+     */
+    @Override
+    protected boolean innerValid()
+    {
+        if (super.innerValid())
+        {
+            COSBase f = this.actionDictionnary.getItem(COSName.F);
+            if (f == null)
+            {
+                context.addValidationError(new ValidationError(ERROR_ACTION_MISING_KEY,
+                        "F entry is mandatory for the GoToRemoteActions"));
+                return false;
+            }
+        }
+        return true;
     }
-    return true;
-  }
 }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/HideAction.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/HideAction.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/HideAction.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/HideAction.java Wed Mar  6 16:46:35 2013
@@ -34,76 +34,71 @@ import org.apache.pdfbox.preflight.Valid
 import org.apache.pdfbox.preflight.utils.COSUtils;
 
 /**
- * ActionManager for the Hide action. The Hide action isn't specifically
- * prohibited by PDF/A-1, but should have been. So this action manager isn't an
- * instance of InvalidAction but authorized only the H entry with the false
- * value.
+ * ActionManager for the Hide action. The Hide action isn't specifically prohibited by PDF/A-1, but should have been. So
+ * this action manager isn't an instance of InvalidAction but authorized only the H entry with the false value.
  */
-public class HideAction extends AbstractActionManager {
+public class HideAction 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 ctx
-   *          the DocumentHandler from which the action comes from.
-   * @param aaKey
-   *          The name of the key which identify the action in a additional
-   *          action dictionary.
-   */
-  public HideAction(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 t = this.actionDictionnary.getItem(COSName.T);
-    // ---- T entry is mandatory
-    if (t == null) {
-      context.addValidationError(new ValidationError(ERROR_ACTION_MISING_KEY,
-          "T entry is mandatory for the NamedActions"));
-      return false;
-    }
-
-	COSDocument cosDocument = this.context.getDocument().getDocument();
-    if (!(COSUtils.isDictionary(t, cosDocument) || COSUtils.isArray(t, cosDocument) || COSUtils.isString(t, cosDocument))) {
-        context.addValidationError(new ValidationError(ERROR_ACTION_INVALID_TYPE,"T entry type is invalid"));
-      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 ctx
+     *            the DocumentHandler from which the action comes from.
+     * @param aaKey
+     *            The name of the key which identify the action in a additional action dictionary.
+     */
+    public HideAction(ActionManagerFactory amFact, COSDictionary adict, PreflightContext ctx, String aaKey)
+    {
+        super(amFact, adict, ctx, aaKey);
     }
 
     /*
-     * ---- H entry is optional but the default value is True (annotations of
-     * the T entry will be hidden) according to the aim of a PDF/A it should be
-     * false (annotations of the T entry will be shown).
+     * (non-Javadoc)
      * 
-     * We check the H value and we throw an error if it is true because of the
-     * PDF/A Application Notes sentence :
-     * 
-     * The PDF Reference supports a concept whereby something will happen when
-     * the user performs an explicit or implicit action in a PDF viewer - these
-     * "things" are called Actions. PDF/A-1 permits a limited set of these
-     * Actions, which are detailed in section 6.6.1. Specifically, any action
-     * that could change the visual representation of the document or is not
-     * documented in the PDF Reference is not permitted. This includes the /Hide
-     * action which isn't specifically prohibited by PDF/A-1, but should have
-     * been.
+     * @see net.awl.edoc.pdfa.validation.actions.AbstractActionManager#valid(java.util .List)
      */
-    boolean h = this.actionDictionnary.getBoolean(COSName.H, true);
-    if (h) {
-      context.addValidationError(new ValidationError(ERROR_ACTION_HIDE_H_INVALID,
-          "H entry is \"true\""));
-      return false;
-    }
+    @Override
+    protected boolean innerValid()
+    {
+        COSBase t = this.actionDictionnary.getItem(COSName.T);
+        // ---- T entry is mandatory
+        if (t == null)
+        {
+            context.addValidationError(new ValidationError(ERROR_ACTION_MISING_KEY,
+                    "T entry is mandatory for the NamedActions"));
+            return false;
+        }
+
+        COSDocument cosDocument = this.context.getDocument().getDocument();
+        if (!(COSUtils.isDictionary(t, cosDocument) || COSUtils.isArray(t, cosDocument) || COSUtils.isString(t,
+                cosDocument)))
+        {
+            context.addValidationError(new ValidationError(ERROR_ACTION_INVALID_TYPE, "T entry type is invalid"));
+            return false;
+        }
+
+        /*
+         * ---- H entry is optional but the default value is True (annotations of the T entry will be hidden) according
+         * to the aim of a PDF/A it should be false (annotations of the T entry will be shown).
+         * 
+         * We check the H value and we throw an error if it is true because of the PDF/A Application Notes sentence :
+         * 
+         * The PDF Reference supports a concept whereby something will happen when the user performs an explicit or
+         * implicit action in a PDF viewer - these "things" are called Actions. PDF/A-1 permits a limited set of these
+         * Actions, which are detailed in section 6.6.1. Specifically, any action that could change the visual
+         * representation of the document or is not documented in the PDF Reference is not permitted. This includes the
+         * /Hide action which isn't specifically prohibited by PDF/A-1, but should have been.
+         */
+        boolean h = this.actionDictionnary.getBoolean(COSName.H, true);
+        if (h)
+        {
+            context.addValidationError(new ValidationError(ERROR_ACTION_HIDE_H_INVALID, "H entry is \"true\""));
+            return false;
+        }
 
-    return true;
-  }
+        return true;
+    }
 }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/InvalidAction.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/InvalidAction.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/InvalidAction.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/InvalidAction.java Wed Mar  6 16:46:35 2013
@@ -28,43 +28,43 @@ import org.apache.pdfbox.preflight.Prefl
 import org.apache.pdfbox.preflight.ValidationResult.ValidationError;
 
 /**
- * ActionManager for InvalidAction. An invalid action is an action which isn't
- * authorized in a PDF/A file but should be valid in a standard PDF file.
+ * ActionManager for InvalidAction. An invalid action is an action which isn't authorized in a PDF/A file but should be
+ * valid in a standard PDF file.
  */
-public class InvalidAction extends AbstractActionManager {
-  private String actionName = null;
+public class InvalidAction extends AbstractActionManager
+{
+    private String actionName = null;
 
-  /**
-   * 
-   * @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 ctx
-   *          the DocumentHandler from which the action comes from.
-   * @param aaKey
-   *          The name of the key which identify the action in a additional
-   *          action dictionary.
-   * @param name
-   *          the action type
-   */
-  public InvalidAction(ActionManagerFactory amFact, COSDictionary adict, PreflightContext ctx, String aaKey, String name) {
-    super(amFact, adict, ctx, aaKey);
-    this.actionName = name;
-  }
+    /**
+     * 
+     * @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 ctx
+     *            the DocumentHandler from which the action comes from.
+     * @param aaKey
+     *            The name of the key which identify the action in a additional action dictionary.
+     * @param name
+     *            the action type
+     */
+    public InvalidAction(ActionManagerFactory amFact, COSDictionary adict, PreflightContext ctx, String aaKey,
+            String name)
+    {
+        super(amFact, adict, ctx, aaKey);
+        this.actionName = name;
+    }
 
-  /*
-   * (non-Javadoc)
-   * 
-   * @see
-   * net.awl.edoc.pdfa.validation.actions.AbstractActionManager#valid(java.util
-   * .List)
-   */
-  @Override
-  protected boolean innerValid() {
-    context.addValidationError(new ValidationError(ERROR_ACTION_FORBIDDEN_ACTIONS_EXPLICITLY_FORBIDDEN, "The action "
-        + actionName + " is forbidden"));
-    return false;
-  }
+    /*
+     * (non-Javadoc)
+     * 
+     * @see net.awl.edoc.pdfa.validation.actions.AbstractActionManager#valid(java.util .List)
+     */
+    @Override
+    protected boolean innerValid()
+    {
+        context.addValidationError(new ValidationError(ERROR_ACTION_FORBIDDEN_ACTIONS_EXPLICITLY_FORBIDDEN,
+                "The action " + actionName + " is forbidden"));
+        return false;
+    }
 }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/NamedAction.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/NamedAction.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/NamedAction.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/NamedAction.java Wed Mar  6 16:46:35 2013
@@ -34,8 +34,7 @@ import org.apache.pdfbox.preflight.Prefl
 import org.apache.pdfbox.preflight.ValidationResult.ValidationError;
 
 /**
- * ActionManager for the Named action. Named action is valid if N entry is
- * present with one of the four values :
+ * ActionManager for the Named action. Named action is valid if N entry is present with one of the four values :
  * <UL>
  * <li>NextPage
  * <li>PrevPage
@@ -43,50 +42,52 @@ import org.apache.pdfbox.preflight.Valid
  * <li>LastPage
  * </UL>
  */
-public class NamedAction extends AbstractActionManager {
+public class NamedAction 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 NamedAction(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() {
-    String n = this.actionDictionnary.getNameAsString(COSName.N);
-
-    // ---- N entry is mandatory
-    if (n == null || "".equals(n)) {
-      context.addValidationError(new ValidationError(ERROR_ACTION_MISING_KEY, "N entry is mandatory for the NamedActions"));
-      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 NamedAction(ActionManagerFactory amFact, COSDictionary adict, PreflightContext ctx, String aaKey)
+    {
+        super(amFact, adict, ctx, aaKey);
     }
 
-    // ---- Only Predefine name actions are authorized
-    if (!(ACTION_DICTIONARY_VALUE_ATYPE_NAMED_FIRST.equals(n)
-        || ACTION_DICTIONARY_VALUE_ATYPE_NAMED_LAST.equals(n)
-        || ACTION_DICTIONARY_VALUE_ATYPE_NAMED_NEXT.equals(n) || ACTION_DICTIONARY_VALUE_ATYPE_NAMED_PREV
-        .equals(n))) {
-      context.addValidationError(new ValidationError(ERROR_ACTION_FORBIDDEN_ACTIONS_NAMED, n + " isn't authorized as named action"));
-      return false;
-    }
+    /*
+     * (non-Javadoc)
+     * 
+     * @see net.awl.edoc.pdfa.validation.actions.AbstractActionManager#valid(java.util .List)
+     */
+    @Override
+    protected boolean innerValid()
+    {
+        String n = this.actionDictionnary.getNameAsString(COSName.N);
+
+        // ---- N entry is mandatory
+        if (n == null || "".equals(n))
+        {
+            context.addValidationError(new ValidationError(ERROR_ACTION_MISING_KEY,
+                    "N entry is mandatory for the NamedActions"));
+            return false;
+        }
+
+        // ---- Only Predefine name actions are authorized
+        if (!(ACTION_DICTIONARY_VALUE_ATYPE_NAMED_FIRST.equals(n) || ACTION_DICTIONARY_VALUE_ATYPE_NAMED_LAST.equals(n)
+                || ACTION_DICTIONARY_VALUE_ATYPE_NAMED_NEXT.equals(n) || ACTION_DICTIONARY_VALUE_ATYPE_NAMED_PREV
+                    .equals(n)))
+        {
+            context.addValidationError(new ValidationError(ERROR_ACTION_FORBIDDEN_ACTIONS_NAMED, n
+                    + " isn't authorized as named action"));
+            return false;
+        }
 
-    return true;
-  }
+        return true;
+    }
 }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/SubmitAction.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/SubmitAction.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/SubmitAction.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/SubmitAction.java Wed Mar  6 16:46:35 2013
@@ -30,43 +30,42 @@ import org.apache.pdfbox.preflight.Prefl
 import org.apache.pdfbox.preflight.ValidationResult.ValidationError;
 
 /**
- * ActionManager for the Submit action SubmitAction is valid if the F entry is
- * present.
+ * ActionManager for the Submit action SubmitAction is valid if the F entry is present.
  */
-public class SubmitAction extends AbstractActionManager {
+public class SubmitAction 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 SubmitAction(ActionManagerFactory amFact, COSDictionary adict, PreflightContext ctx, String aaKey) {
-    super(amFact, adict, ctx, aaKey);
-  }
+    /**
+     * @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 SubmitAction(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 f = this.actionDictionnary.getItem(COSName.F);
-    if (f == null) {
-      context.addValidationError(new ValidationError(ERROR_ACTION_MISING_KEY,
-          "F entry is mandatory for the SubmitActions"));
-      return false;
+    /*
+     * (non-Javadoc)
+     * 
+     * @see net.awl.edoc.pdfa.validation.actions.AbstractActionManager#valid(java.util .List)
+     */
+    @Override
+    protected boolean innerValid()
+    {
+        COSBase f = this.actionDictionnary.getItem(COSName.F);
+        if (f == null)
+        {
+            context.addValidationError(new ValidationError(ERROR_ACTION_MISING_KEY,
+                    "F entry is mandatory for the SubmitActions"));
+            return false;
+        }
+        return true;
     }
-    return true;
-  }
 
 }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/ThreadAction.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/ThreadAction.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/ThreadAction.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/ThreadAction.java Wed Mar  6 16:46:35 2013
@@ -33,52 +33,53 @@ import org.apache.pdfbox.preflight.Valid
 import org.apache.pdfbox.preflight.utils.COSUtils;
 
 /**
- * ActionManager for the Thread action ThreadAction is valid if the D entry is
- * present.
+ * ActionManager for the Thread action ThreadAction is valid if the D entry is present.
  */
-public class ThreadAction extends AbstractActionManager {
+public class ThreadAction 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 ThreadAction(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 d = this.actionDictionnary.getItem(COSName.D);
-
-    // ---- D entry is mandatory
-    if (d == null) {
-      context.addValidationError(new ValidationError(ERROR_ACTION_MISING_KEY,
-          "D entry is mandatory for the ThreadAction"));
-      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 ThreadAction(ActionManagerFactory amFact, COSDictionary adict, PreflightContext ctx, String aaKey)
+    {
+        super(amFact, adict, ctx, aaKey);
     }
 
-	COSDocument cosDocument = this.context.getDocument().getDocument();
-    if (!(COSUtils.isInteger(d, cosDocument) || COSUtils.isString(d, cosDocument) || COSUtils.isDictionary(d, cosDocument))) {
-      context.addValidationError(new ValidationError(ERROR_ACTION_INVALID_TYPE, "D entry type is invalid"));
-      return false;
-    }
+    /*
+     * (non-Javadoc)
+     * 
+     * @see net.awl.edoc.pdfa.validation.actions.AbstractActionManager#valid(java.util .List)
+     */
+    @Override
+    protected boolean innerValid()
+    {
+        COSBase d = this.actionDictionnary.getItem(COSName.D);
+
+        // ---- D entry is mandatory
+        if (d == null)
+        {
+            context.addValidationError(new ValidationError(ERROR_ACTION_MISING_KEY,
+                    "D entry is mandatory for the ThreadAction"));
+            return false;
+        }
+
+        COSDocument cosDocument = this.context.getDocument().getDocument();
+        if (!(COSUtils.isInteger(d, cosDocument) || COSUtils.isString(d, cosDocument) || COSUtils.isDictionary(d,
+                cosDocument)))
+        {
+            context.addValidationError(new ValidationError(ERROR_ACTION_INVALID_TYPE, "D entry type is invalid"));
+            return false;
+        }
 
-    return true;
-  }
+        return true;
+    }
 
 }

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/UndefAction.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/UndefAction.java?rev=1453416&r1=1453415&r2=1453416&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/UndefAction.java (original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/action/UndefAction.java Wed Mar  6 16:46:35 2013
@@ -28,45 +28,43 @@ import org.apache.pdfbox.preflight.Prefl
 import org.apache.pdfbox.preflight.ValidationResult.ValidationError;
 
 /**
- * ActionManager for Undefined Actions. An undefined action is an action which isn't
- * declared in the PDF Reference Third Edition. This kind of actions are forbidden to 
- * avoid wrong result due to new features which can't be consistent with the PDF/A-1 format 
+ * ActionManager for Undefined Actions. An undefined action is an action which isn't declared in the PDF Reference Third
+ * Edition. This kind of actions are forbidden to avoid wrong result due to new features which can't be consistent with
+ * the PDF/A-1 format
  */
-public class UndefAction extends AbstractActionManager {
-  private String actionName = null;
+public class UndefAction extends AbstractActionManager
+{
+    private String actionName = null;
 
-  /**
-   * 
-   * @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 ctx
-   *          the COSDocument from which the action comes from.
-   * @param aaKey
-   *          The name of the key which identify the action in a additional
-   *          action dictionary.
-   * @param name
-   *          the action type
-   */
-  public UndefAction(ActionManagerFactory amFact, COSDictionary adict,
-      PreflightContext ctx, String aaKey, String name) {
-    super(amFact, adict, ctx, aaKey);
-    this.actionName = name;
-  }
+    /**
+     * 
+     * @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 ctx
+     *            the COSDocument from which the action comes from.
+     * @param aaKey
+     *            The name of the key which identify the action in a additional action dictionary.
+     * @param name
+     *            the action type
+     */
+    public UndefAction(ActionManagerFactory amFact, COSDictionary adict, PreflightContext ctx, String aaKey, String name)
+    {
+        super(amFact, adict, ctx, aaKey);
+        this.actionName = name;
+    }
 
-  /*
-   * (non-Javadoc)
-   * 
-   * @see
-   * net.awl.edoc.pdfa.validation.actions.AbstractActionManager#valid(java.util
-   * .List)
-   */
-  @Override
-  protected boolean innerValid() {
-    context.addValidationError(new ValidationError(ERROR_ACTION_FORBIDDEN_ACTIONS_UNDEF, "The action "
-        + actionName + " is undefined"));
-    return false;
-  }
+    /*
+     * (non-Javadoc)
+     * 
+     * @see net.awl.edoc.pdfa.validation.actions.AbstractActionManager#valid(java.util .List)
+     */
+    @Override
+    protected boolean innerValid()
+    {
+        context.addValidationError(new ValidationError(ERROR_ACTION_FORBIDDEN_ACTIONS_UNDEF, "The action " + actionName
+                + " is undefined"));
+        return false;
+    }
 }



Mime
View raw message