Class Profiles
java.lang.Object
org.verapdf.pdfa.validation.profiles.Profiles
Utitlity class that provides helper methods for handling
ValidationProfile
s and associated classes.
The utility methods generally fall into one of the following categories:
- default instance creators,
defaultTypeName()
, used for testing or when a vanilla instance of a particular type is required. - from values instance creators,
typeNameFromValues(...)
, used to create instances from their contained types. - XML helper methods,
typeNameToXml(...)
, to facilitate XML serialisation to Strings, OutputStreams and Writers. - XML helper methods,
typeNameFromXml(...)
, to facilitate XML deserialisation.
TODO: Defensive Checks for all parameters.
- Author:
- Carl Wilson
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ErrorDetails
Returns an immutable default instance of ErrorDetails.static ValidationProfile
Returns an immutable default instance of a ValidationProfile.static Reference
Returns an immutable default instance of a Reference.static Rule
Returns an immutable default instance of a Rule.static RuleId
Returns an immutable default instance of a RuleId.static Variable
Returns an immutable default instance of a Variable.static ProfileDirectory
directoryFromProfiles
(Set<ValidationProfile> profiles) static ErrorDetails
errorFromValues
(String message, List<ErrorArgument> arguments) Returns aErrorDetails
instance initialised with the passed values.static String
Returns the JAXB generated XML schema for the ValidationProfileImpl type.static ProfileDirectory
Returns aProfileDirectory
instance that has been pre-populated with the curatedValidationProfile
s supplied with the veraPDF library.static ProfileDetails
profileDetailsFromValues
(String name, String description, String creator, Date created) Returns aProfileDetails
instance initialised using the passed values.static ValidationProfile
profileFromSortedValues
(PDFAFlavour flavour, ProfileDetails details, String hash, SortedSet<Rule> rules, Set<Variable> variables) Returns aValidationProfile
instance initialised with the passed values.static ValidationProfile
profileFromValues
(PDFAFlavour flavour, ProfileDetails details, String hash, Set<Rule> rules, Set<Variable> variables) Returns aValidationProfile
instance initialised with the passed values.static ValidationProfile
profileFromXml
(InputStream source) Attempt to de-serialise and return aValidationProfile
instance from an XML representation that can be read fromtoConvert
.static String
profileToXml
(ValidationProfile toConvert, boolean format, boolean fragment) Convert aValidationProfile
instance into an XML String.static void
profileToXml
(ValidationProfile toConvert, OutputStream dest, boolean format, boolean fragment) static void
profileToXml
(ValidationProfile toConvert, Writer dest, boolean format, boolean fragment) static Reference
referenceFromValues
(String specification, String clause) Returns aReference
instance initialised with the passed values.static Rule
ruleFromValues
(RuleId id, String object, Boolean deferred, String description, String test, ErrorDetails error, List<Reference> references) Returns aRule
instance initialised with the passed values.static Rule
ruleFromValues
(RuleId id, String object, String description, String test, ErrorDetails error, List<Reference> references) Returns aRule
instance initialised with the passed values.static RuleId
ruleIdFromValues
(PDFAFlavour.Specification specification, String clause, int testNumber) Returns aRuleId
instance initialised with the passed values.static Variable
variableFromValues
(String name, String object, String defaultValue, String value) Returns aVariable
instance initialised with the passed values.
-
Constructor Details
-
Profiles
public Profiles()
-
-
Method Details
-
profileFromValues
public static ValidationProfile profileFromValues(PDFAFlavour flavour, ProfileDetails details, String hash, Set<Rule> rules, Set<Variable> variables) Returns aValidationProfile
instance initialised with the passed values.- Parameters:
flavour
- the PDF/A flavour supported by this profile represented as aPDFAFlavour
instance.details
- theProfileDetails
for the profile.hash
- an identifying hash for the profilerules
- the Set ofRule
s for the profilevariables
- the Set ofVariable
s for the profile- Returns:
- a new ValidationProfile instance.
- Throws:
IllegalArgumentException
- if any of the passed parameters are null or if any of name, description or creator are empty.
-
profileFromSortedValues
public static ValidationProfile profileFromSortedValues(PDFAFlavour flavour, ProfileDetails details, String hash, SortedSet<Rule> rules, Set<Variable> variables) Returns aValidationProfile
instance initialised with the passed values.- Parameters:
flavour
- the PDF/A flavour supported by this profile represented as aPDFAFlavour
instance.details
- theProfileDetails
for the profile.hash
- an identifying hash for the profilerules
- the Set ofRule
s for the profilevariables
- the Set ofVariable
s for the profile- Returns:
- a new ValidationProfile instance.
- Throws:
IllegalArgumentException
- if any of the passed parameters are null or if any of name, description or creator are empty.
-
defaultProfile
Returns an immutable default instance of a ValidationProfile. This is a static single instance, i.e.Profiles.defaultProfile() == Profiles.defaultProfile()
is always true.- Returns:
- the
ValidationProfile
default instance
-
profileDetailsFromValues
public static ProfileDetails profileDetailsFromValues(String name, String description, String creator, Date created) Returns aProfileDetails
instance initialised using the passed values.- Parameters:
name
- a String name that identifies the profiledescription
- a short, textual String description of the profile.creator
- a String that identifies the creator of the profilecreated
- aDate
instance indicating when the profile was created.- Returns:
- the ProfileDetails instance initialised from the values
-
defaultReference
Returns an immutable default instance of a Reference. This is a static single instance, i.e.Profiles.defaultReference() == Profiles.defaultReference()
is always true.- Returns:
- the
Reference
default instance
-
referenceFromValues
Returns aReference
instance initialised with the passed values.- Parameters:
specification
- a String identifying the specification theReference
refers to.clause
- a String identifying the location referred to within the specification.- Returns:
- an appropriately initialised Reference instance
- Throws:
IllegalArgumentException
- if any of the parameters are null or the specification is empty
-
defaultRuleId
Returns an immutable default instance of a RuleId. This is a static single instance, i.e.Profiles.defaultRuleId() == Profiles.defaultRuleId()
is always true.- Returns:
- the
RuleId
default instance
-
ruleIdFromValues
public static RuleId ruleIdFromValues(PDFAFlavour.Specification specification, String clause, int testNumber) Returns aRuleId
instance initialised with the passed values.- Parameters:
specification
- aPDFAFlavour.Specification
instance identifying the PDF/A specification part the RuleId is derivedclause
- a String that identifies that clause within the specification that the RuleId is derivedtestNumber
- anint
that identifies the test number for the RuleId- Returns:
- a RuleId instance
- Throws:
IllegalArgumentException
- if any of the parameters are null or the clause is empty
-
defaultRule
Returns an immutable default instance of a Rule. This is a static single instance, i.e.Profiles.defaultRule() == Profiles.defaultRule()
is always true.- Returns:
- the
Rule
default instance
-
defaultError
Returns an immutable default instance of ErrorDetails. This is a static single instance, i.e.Profiles.defaultError() == Profiles.defaultError()
is always true.- Returns:
- the
ErrorDetails
default instance
-
errorFromValues
Returns aErrorDetails
instance initialised with the passed values.- Parameters:
message
- a String message for theErrorDetails
arguments
- a List of String arguments for theErrorDetails
.- Returns:
- an
ErrorDetails
instance - Throws:
IllegalArgumentException
- if any of the parameters are null or message is empty
-
ruleFromValues
public static Rule ruleFromValues(RuleId id, String object, String description, String test, ErrorDetails error, List<Reference> references) Returns aRule
instance initialised with the passed values.- Parameters:
id
- theRuleId
id for theRule
object
- a String that identifies the Object that the rule applies todescription
- a textual description of theRule
.test
- a JavaScript expression that is the test carried out on a model instanceerror
- theErrorDetails
associated with theRule
.references
- a list of furtherReference
s for this rule- Returns:
- a
Rule
instance. - Throws:
IllegalArgumentException
- if any of the parameters are null or the test, object, or description is empty
-
ruleFromValues
public static Rule ruleFromValues(RuleId id, String object, Boolean deferred, String description, String test, ErrorDetails error, List<Reference> references) Returns aRule
instance initialised with the passed values.- Parameters:
id
- theRuleId
id for theRule
object
- a String that identifies the Object that the rule applies todeferred
- a Boolean that identifies the deferred property of the ruledescription
- a textual description of theRule
.test
- a JavaScript expression that is the test carried out on a model instanceerror
- theErrorDetails
associated with theRule
.references
- a list of furtherReference
s for this rule- Returns:
- a
Rule
instance. - Throws:
IllegalArgumentException
- if any of the parameters are null or the test, object, or description is empty
-
defaultVariable
Returns an immutable default instance of a Variable. This is a static single instance, i.e.Profiles.defaultVariable() == Profiles.defaultVariable()
is always true.- Returns:
- the
Variable
default instance
-
variableFromValues
public static Variable variableFromValues(String name, String object, String defaultValue, String value) Returns aVariable
instance initialised with the passed values.- Parameters:
name
- a name for theVariable
object
- a String identifying the object type for theVariable
defaultValue
- a String default value for theVariable
value
- a value for the for theVariable
- Returns:
- a new
Variable
instance - Throws:
IllegalArgumentException
- if any of the parameters are null or empty
-
profileToXml
public static String profileToXml(ValidationProfile toConvert, boolean format, boolean fragment) throws JAXBException Convert aValidationProfile
instance into an XML String.- Parameters:
toConvert
- aValidationProfile
to convert to an XML StringprettyXml
- set to Boolean.TRUE for pretty formatted XML, Boolean.FALSE for no space formatting- Returns:
- a String xml representation of toConvert
- Throws:
JAXBException
- thrown by JAXB marshaller if there's an error converting the objectIOException
- thrown when's there's a problem closing the underlying StringWriterIllegalArgumentException
- if toConvert is null
-
profileToXml
public static void profileToXml(ValidationProfile toConvert, OutputStream dest, boolean format, boolean fragment) throws JAXBException - Parameters:
toConvert
- aValidationProfile
to convert to an XML StringforXmlOutput
- an OutputStream used to write the generated XML toprettyXml
- set to Boolean.TRUE for pretty formatted XML, Boolean.FALSE for no space formatting- Throws:
JAXBException
- thrown by JAXB marshaller if there's an error converting the objectIllegalArgumentException
- if toConvert is null
-
profileFromXml
Attempt to de-serialise and return aValidationProfile
instance from an XML representation that can be read fromtoConvert
.- Parameters:
toConvert
- an InputStream to an XML representation of a profile- Returns:
- a new
ValidationProfile
instance - Throws:
JAXBException
- thrown by JAXB marshaller if there's an error converting the objectIllegalArgumentException
- if toConvert is null
-
profileToXml
public static void profileToXml(ValidationProfile toConvert, Writer dest, boolean format, boolean fragment) throws JAXBException - Parameters:
toConvert
- aValidationProfile
to convert to an XML StringforXmlOutput
- a Writer used to write the generated XML toprettyXml
- set to Boolean.TRUE for pretty formatted XML, Boolean.FALSE for no space formatting- Throws:
JAXBException
- thrown by JAXB marshaller if there's an error converting the objectIllegalArgumentException
- if toConvert is null
-
directoryFromProfiles
Create aProfileDirectory
from aSet
ofValidationProfile
s. Note that the returned directory uses eachValidationProfile
's associatedPDFAFlavour
as a directory key. This means that only a singleValidationProfile
can be associated with a particularPDFAFlavour
. If theSet
of Profiles passed inprofiles
contains multipleValidationProfile
s with the samePDFAFlavour
only one will be contained in the returnedProfileDirectory
. Which one is indeterminate.- Parameters:
profiles
- a Set ofValidationProfile
s used to populate the directory instance- Returns:
- a ProfileDirectory populated with the
ValidationProfile
s passed in the profiles parameter - Throws:
IllegalArgumentException
- if the profiles parameter is null or empty
-
getVeraProfileDirectory
Returns aProfileDirectory
instance that has been pre-populated with the curatedValidationProfile
s supplied with the veraPDF library.While the veraPDF library and associated
ValidationProfile
s are under development, there is no guarantee that the profiles supplied are complete and accurate. Please check the validation profiles GitHub repo to find out the current status of our ValidationProfiles.- Returns:
- the pre-populated veraPDF ValidationProfile directory
-
getValidationProfileSchema
Returns the JAXB generated XML schema for the ValidationProfileImpl type.- Returns:
- the String representation of the schema
- Throws:
JAXBException
- if there's a problem marshaling the schemaIOException
- if there's a problem outputting the result
-