Top Description Inners Fields Constructors Methods
org.apache.pdfbox.preflight

public Class ValidationResult

extends Object
Class Inheritance
Imports
java.util.ArrayList, .List, 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-1x compliant. If the document isn't PDF/A-1x a list of errors is provided.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ValidationResult.ValidationError

This Class represents an error of validation.

Field Summary

Modifier and TypeField and Description
private boolean
isValid

Boolean to know if the PDF is a valid PDF/A

private List<ValidationResult.ValidationError>
lErrors

Errors to know why the PDF isn't valid.

private XMPMetadata
xmpMetaData

Object representation of the XMPMetaData contained by the pdf file This attribute can be null if the Validation fails.

Constructor Summary

AccessConstructor and Description
public
ValidationResult(boolean isValid)

Create a Validation result object

public
ValidationResult(ValidationResult.ValidationError
if error is null, no error is added to the list.
error
)

Create a Validation Result object.

public
ValidationResult(List<ValidationResult.ValidationError>
if error is null, no error is added to the list.
errors
)

Create a Validation Result object.

Method Summary

Modifier and TypeMethod and Description
public void
addError(ValidationResult.ValidationError error)

Add error to the list of ValidationError.

public void
addErrors(List<ValidationResult.ValidationError> errors)

Add a set of errors to the list of ValidationError.

public List<ValidationResult.ValidationError>

Returns:

the list of validation errors
getErrorsList
()

public XMPMetadata

Returns:

the xmpMetaData
getXmpMetaData
()

public boolean

Returns:

true if the PDF is valid,false otherwise
isValid
()

public void
mergeResult(ValidationResult otherResult)

Add the ValidationError object of the otherResult in the Error list of the current object.

pack-priv void
setXmpMetaData(XMPMetadata
the xmpMetaData to set
xmpMetaData
)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

isValidback to summary
private boolean isValid

Boolean to know if the PDF is a valid PDF/A

lErrorsback to summary
private List<ValidationResult.ValidationError> lErrors

Errors to know why the PDF isn't valid. If the PDF is valid, this list is empty.

xmpMetaDataback to summary
private XMPMetadata xmpMetaData

Object representation of the XMPMetaData contained by the pdf file This attribute can be null if the Validation fails.

Constructor Detail

ValidationResultback to summary
public ValidationResult(boolean isValid)

Create a Validation result object

ValidationResultback to summary
public ValidationResult(ValidationResult.ValidationError error)

Create a Validation Result object. This constructor force the isValid to false and add the given error to the list or ValidationErrors.

Parameters
error:ValidationResult.ValidationError

if error is null, no error is added to the list.

ValidationResultback to summary
public ValidationResult(List<ValidationResult.ValidationError> errors)

Create a Validation Result object. This constructor force the isValid to false and add all the given errors to the list or ValidationErrors.

Parameters
errors:List<ValidationResult.ValidationError>

if error is null, no error is added to the list.

Method Detail

addErrorback to summary
public void addError(ValidationResult.ValidationError error)

Add error to the list of ValidationError. If the given error is null, this method does nothing

addErrorsback to summary
public void addErrors(List<ValidationResult.ValidationError> errors)

Add a set of errors to the list of ValidationError. If the given list is null, this method does nothing.

getErrorsListback to summary
public List<ValidationResult.ValidationError> getErrorsList()
Returns:List<ValidationResult.ValidationError>

the list of validation errors

getXmpMetaDataback to summary
public XMPMetadata getXmpMetaData()
Returns:XMPMetadata

the xmpMetaData

isValidback to summary
public boolean isValid()
Returns:boolean

true if the PDF is valid,false otherwise

mergeResultback to summary
public void mergeResult(ValidationResult otherResult)

Add the ValidationError object of the otherResult in the Error list of the current object. Apply a logical AND on the isValid boolean.

setXmpMetaDataback to summary
pack-priv void setXmpMetaData(XMPMetadata xmpMetaData)
Parameters
xmpMetaData:XMPMetadata

the xmpMetaData to set

org.apache.pdfbox.preflight back to summary

public Class ValidationResult.ValidationError

extends Object
Class Inheritance

This Class represents an error of validation. It contains an error code and an error explanation.

Field Summary

Modifier and TypeField and Description
private Throwable
cause

The underlying cause if the ValidationError was caused by a Throwable.

private String
details

Error details

private final String
errorCode

Error identifier.

private boolean
isWarning

false: this error can't be ignored; true: this error can be ignored

private Integer
pageNumber

The page number on which the error happened, if known.

private Throwable
t

Always record the place in the source code where the ValidationError was created, in case the ValidationError was not caused by a Throwable.

Constructor Summary

AccessConstructor and Description
public
ValidationError(String errorCode)

Create a validation error with the given error code

public
ValidationError(String
the error code
errorCode
,
String
the error explanation
details
,
Throwable
the error cause
cause
)

Create a validation error with the given error code and the error explanation.

public
ValidationError(String
the error code
errorCode
,
String
the error explanation
details
)

Create a validation error with the given error code and the error explanation.

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public Throwable

Returns:

The underlying cause if the ValidationError was caused by a Throwable, or null if not.
getCause
()

Get the underlying cause if the ValidationError was caused by a Throwable.

public String

Returns:

the error explanation
getDetails
()

public String

Returns:

the error code
getErrorCode
()

public Integer
getPageNumber()

Returns the page number, or null if not known.

public Throwable

Returns:

The place where the ValidationError was created.
getThrowable
()

Get the place where the ValidationError was created, useful if the ValidationError was not caused by a Throwable.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean
public void
setDetails(String details)

Set the error explanation

public void
setPageNumber(Integer
zero based page number or null if none is known.
pageNumber
)

Sets or resets the page number.

public void
setWarning(boolean isWarning)

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

causeback to summary
private Throwable cause

The underlying cause if the ValidationError was caused by a Throwable.

detailsback to summary
private String details

Error details

errorCodeback to summary
private final String errorCode

Error identifier. This error code can be used as identifier to internationalize the logging message using i18n.

isWarningback to summary
private boolean isWarning

false: this error can't be ignored; true: this error can be ignored

pageNumberback to summary
private Integer pageNumber

The page number on which the error happened, if known.

tback to summary
private Throwable t

Always record the place in the source code where the ValidationError was created, in case the ValidationError was not caused by a Throwable.

Constructor Detail

ValidationErrorback to summary
public ValidationError(String errorCode)

Create a validation error with the given error code

ValidationErrorback to summary
public ValidationError(String errorCode, String details, Throwable cause)

Create a validation error with the given error code and the error explanation.

Parameters
errorCode:String

the error code

details:String

the error explanation

cause:Throwable

the error cause

ValidationErrorback to summary
public ValidationError(String errorCode, String details)

Create a validation error with the given error code and the error explanation.

Parameters
errorCode:String

the error code

details:String

the error explanation

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getCauseback to summary
public Throwable getCause()

Get the underlying cause if the ValidationError was caused by a Throwable.

Returns:Throwable

The underlying cause if the ValidationError was caused by a Throwable, or null if not.

getDetailsback to summary
public String getDetails()
Returns:String

the error explanation

getErrorCodeback to summary
public String getErrorCode()
Returns:String

the error code

getPageNumberback to summary
public Integer getPageNumber()

Returns the page number, or null if not known.

getThrowableback to summary
public Throwable getThrowable()

Get the place where the ValidationError was created, useful if the ValidationError was not caused by a Throwable.

Returns:Throwable

The place where the ValidationError was created.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
isWarningback to summary
public boolean isWarning()
setDetailsback to summary
public void setDetails(String details)

Set the error explanation

setPageNumberback to summary
public void setPageNumber(Integer pageNumber)

Sets or resets the page number.

Parameters
pageNumber:Integer

zero based page number or null if none is known.

setWarningback to summary
public void setWarning(boolean isWarning)