public void validate(PreflightContext context) throws ValidationException
{
PreflightPath vPath = context.getValidationPath();
XObjectValidator validator = null;
if (!vPath.isEmpty() && vPath.isExpectedType(PDXObjectImage.class))
{
validator = new XObjImageValidator(context, (PDXObjectImage) vPath.peek());
}
else if (!vPath.isEmpty() && vPath.isExpectedType(PDXObjectForm.class))
{
validator = new XObjFormValidator(context, (PDXObjectForm) vPath.peek());
}
else if (!vPath.isEmpty() && vPath.isExpectedType(COSStream.class))
{
COSStream stream = (COSStream) vPath.peek();
String subType = stream.getNameAsString(COSName.SUBTYPE);
if (XOBJECT_DICTIONARY_VALUE_SUBTYPE_POSTSCRIPT.equals(subType))
{
validator = new XObjPostscriptValidator(context, stream);
}
else
{
context.addValidationError(new ValidationError(PreflightConstants.ERROR_GRAPHIC_XOBJECT_INVALID_TYPE, "Invalid XObject subtype"));
}
}
else
{
context.addValidationError(new ValidationError(PreflightConstants.ERROR_GRAPHIC_MISSING_OBJECT, "Graphic validation process needs at least one PDXObject"));
}
if (validator != null) {
validator.validate();
}
}