org.pdfsam.console.utils
Class ValidationUtility

java.lang.Object
  extended by org.pdfsam.console.utils.ValidationUtility

public final class ValidationUtility
extends java.lang.Object

Utility for the arguments validation

Author:
Andrea Vacondio

Field Summary
static java.lang.String ALL_STRING
           
static java.lang.String EVEN_STRING
           
static java.lang.String ODD_STRING
           
static java.lang.String PDF_EXTENSION
           
 
Method Summary
static void assertNotIntersectedBoundsList(java.util.List bounds)
          validates the input bounds list ensuring that there is no intersections between the objects of the input list
static void assertValidBounds(Bounds bounds, int pdfNumberOfPages)
          validates the input Bounds object
static void assertValidDirectory(java.io.File inputDir)
          check if the given file is a directory
static void assertValidPageSelectionsArray(java.lang.String[] selections)
          validates the selections array.
static void assertValidPdfExtension(java.lang.String inputFileName)
          check if the given file path identifies a pdf format file
static PageLabel getPageLabel(java.lang.String inputString)
           
static PageRotation[] getPagesRotation(java.lang.String inputString)
          Overloaded getPagesRotation(String, boolean).
static PageRotation[] getPagesRotation(java.lang.String inputString, boolean allowSinglePagesRotation)
          all, odd and even pages rotation cannot be mixed together or with single pages rotations
static boolean isValidPageSelectionsArray(java.lang.String[] selections)
          validates the selections array
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALL_STRING

public static final java.lang.String ALL_STRING
See Also:
Constant Field Values

ODD_STRING

public static final java.lang.String ODD_STRING
See Also:
Constant Field Values

EVEN_STRING

public static final java.lang.String EVEN_STRING
See Also:
Constant Field Values

PDF_EXTENSION

public static final java.lang.String PDF_EXTENSION
See Also:
Constant Field Values
Method Detail

getPagesRotation

public static PageRotation[] getPagesRotation(java.lang.String inputString,
                                              boolean allowSinglePagesRotation)
                                       throws ValidationException
all, odd and even pages rotation cannot be mixed together or with single pages rotations

Parameters:
inputString - the input command line string for the -r param
allowSinglePagesRotation - if true single pages rotation are allowd, if false only all, odd end even pages rotations are allowed
Returns:
the rotations array
Throws:
ValidationException

getPageLabel

public static PageLabel getPageLabel(java.lang.String inputString)
                              throws ValidationException
Parameters:
inputString -
Returns:
the PageLabel object resulting by the -l option value
Throws:
ValidationException

getPagesRotation

public static PageRotation[] getPagesRotation(java.lang.String inputString)
                                       throws ValidationException
Overloaded getPagesRotation(String, boolean). Allow single pages rotation.

Parameters:
inputString -
Returns:
the rotations array
Throws:
ValidationException
See Also:
ValidationUtility#getPagesRotation(String, boolean)}

assertValidPdfExtension

public static void assertValidPdfExtension(java.lang.String inputFileName)
                                    throws ValidationException
check if the given file path identifies a pdf format file

Parameters:
inputFileName -
Throws:
ValidationException - if not a pdf format

assertValidDirectory

public static void assertValidDirectory(java.io.File inputDir)
                                 throws ValidationException
check if the given file is a directory

Parameters:
inputDir -
Throws:
ValidationException - if not a directory

assertValidPageSelectionsArray

public static void assertValidPageSelectionsArray(java.lang.String[] selections)
                                           throws ValidationException
validates the selections array. Every array item must be a valid selection string.

Parameters:
selections -
Throws:
ValidationException

isValidPageSelectionsArray

public static boolean isValidPageSelectionsArray(java.lang.String[] selections)
validates the selections array

Parameters:
selections -
Returns:
true if the array is valid

assertValidBounds

public static void assertValidBounds(Bounds bounds,
                                     int pdfNumberOfPages)
                              throws ValidationException
validates the input Bounds object

Parameters:
bounds -
pdfNumberOfPages - number of total pages
Throws:
ValidationException

assertNotIntersectedBoundsList

public static void assertNotIntersectedBoundsList(java.util.List bounds)
                                           throws ValidationException
validates the input bounds list ensuring that there is no intersections between the objects of the input list

Parameters:
bounds -
Throws:
ValidationException