Class Profiles
java.lang.Object
org.verapdf.pdfa.validation.profiles.Profiles
Utitlity class that provides helper methods for handling
ValidationProfiles 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
Nested ClassesModifier and TypeClassDescriptionstatic classstatic class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ErrorDetailsReturns an immutable default instance of ErrorDetails.static ValidationProfileReturns an immutable default instance of a ValidationProfile.static ReferenceReturns an immutable default instance of a Reference.static RuleReturns an immutable default instance of a Rule.static RuleIdReturns an immutable default instance of a RuleId.static VariableReturns an immutable default instance of a Variable.static ProfileDirectorydirectoryFromProfiles(Set<ValidationProfile> profiles) static ErrorDetailserrorFromValues(String message, List<ErrorArgument> arguments) Returns aErrorDetailsinstance initialised with the passed values.static ValidationProfilegetProfileWithTags(ValidationProfile profile, Set<String> includeTags, Set<String> excludeTags) static StringReturns the JAXB generated XML schema for the ValidationProfileImpl type.static ProfileDirectoryReturns aProfileDirectoryinstance that has been pre-populated with the curatedValidationProfiles supplied with the veraPDF library.static ProfileDetailsprofileDetailsFromValues(String name, String description, String creator, Date created) Returns aProfileDetailsinstance initialised using the passed values.static ValidationProfileprofileFromSortedValues(PDFAFlavour flavour, ProfileDetails details, String hash, SortedSet<Rule> rules, SortedSet<Variable> variables) Returns aValidationProfileinstance initialised with the passed values.static ValidationProfileprofileFromValues(PDFAFlavour flavour, ProfileDetails details, String hash, Set<Rule> rules, Set<Variable> variables) Returns aValidationProfileinstance initialised with the passed values.static ValidationProfileprofileFromXml(InputStream source) Attempt to de-serialise and return aValidationProfileinstance from an XML representation that can be read fromtoConvert.static StringprofileToXml(ValidationProfile toConvert, boolean format, boolean fragment) Convert aValidationProfileinstance into an XML String.static voidprofileToXml(ValidationProfile toConvert, OutputStream dest, boolean format, boolean fragment) static voidprofileToXml(ValidationProfile toConvert, Writer dest, boolean format, boolean fragment) static ReferencereferenceFromValues(String specification, String clause) Returns aReferenceinstance initialised with the passed values.static RuleruleFromValues(RuleId id, String object, Boolean deferred, String tags, String description, String test, ErrorDetails error, List<Reference> references) Returns aRuleinstance initialised with the passed values.static RuleruleFromValues(RuleId id, String object, String description, String test, ErrorDetails error, List<Reference> references) Returns aRuleinstance initialised with the passed values.static RuleIdruleIdFromValues(PDFAFlavour.Specification specification, String clause, int testNumber) Returns aRuleIdinstance initialised with the passed values.static VariablevariableFromValues(String name, String object, String defaultValue, String value) Returns aVariableinstance 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 aValidationProfileinstance initialised with the passed values.- Parameters:
flavour- the PDF/A flavour supported by this profile represented as aPDFAFlavourinstance.details- theProfileDetailsfor the profile.hash- an identifying hash for the profilerules- the Set ofRules for the profilevariables- the Set ofVariables 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, SortedSet<Variable> variables) Returns aValidationProfileinstance initialised with the passed values.- Parameters:
flavour- the PDF/A flavour supported by this profile represented as aPDFAFlavourinstance.details- theProfileDetailsfor the profile.hash- an identifying hash for the profilerules- the Set ofRules for the profilevariables- the Set ofVariables 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
ValidationProfiledefault instance
-
profileDetailsFromValues
public static ProfileDetails profileDetailsFromValues(String name, String description, String creator, Date created) Returns aProfileDetailsinstance 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- aDateinstance 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
Referencedefault instance
-
referenceFromValues
Returns aReferenceinstance initialised with the passed values.- Parameters:
specification- a String identifying the specification theReferencerefers 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
RuleIddefault instance
-
ruleIdFromValues
public static RuleId ruleIdFromValues(PDFAFlavour.Specification specification, String clause, int testNumber) Returns aRuleIdinstance initialised with the passed values.- Parameters:
specification- aPDFAFlavour.Specificationinstance identifying the PDF/A specification part the RuleId is derivedclause- a String that identifies that clause within the specification that the RuleId is derivedtestNumber- anintthat 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
Ruledefault 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
ErrorDetailsdefault instance
-
errorFromValues
Returns aErrorDetailsinstance initialised with the passed values.- Parameters:
message- a String message for theErrorDetailsarguments- a List of String arguments for theErrorDetails.- Returns:
- an
ErrorDetailsinstance - 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 aRuleinstance initialised with the passed values.- Parameters:
id- theRuleIdid for theRuleobject- 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- theErrorDetailsassociated with theRule.references- a list of furtherReferences for this rule- Returns:
- a
Ruleinstance. - 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 tags, String description, String test, ErrorDetails error, List<Reference> references) Returns aRuleinstance initialised with the passed values.- Parameters:
id- theRuleIdid for theRuleobject- 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- theErrorDetailsassociated with theRule.references- a list of furtherReferences for this rule- Returns:
- a
Ruleinstance. - 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
Variabledefault instance
-
variableFromValues
public static Variable variableFromValues(String name, String object, String defaultValue, String value) Returns aVariableinstance initialised with the passed values.- Parameters:
name- a name for theVariableobject- a String identifying the object type for theVariabledefaultValue- a String default value for theVariablevalue- a value for the for theVariable- Returns:
- a new
Variableinstance - Throws:
IllegalArgumentException- if any of the parameters are null or empty
-
profileToXml
public static String profileToXml(ValidationProfile toConvert, boolean format, boolean fragment) throws jakarta.xml.bind.JAXBException Convert aValidationProfileinstance into an XML String.- Parameters:
toConvert- aValidationProfileto 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:
jakarta.xml.bind.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 jakarta.xml.bind.JAXBException - Parameters:
toConvert- aValidationProfileto convert to an XML Stringdest- an OutputStream used to write the generated XML toprettyXml- set to Boolean.TRUE for pretty formatted XML, Boolean.FALSE for no space formatting- Throws:
jakarta.xml.bind.JAXBException- thrown by JAXB marshaller if there's an error converting the objectIllegalArgumentException- if toConvert is null
-
profileFromXml
public static ValidationProfile profileFromXml(InputStream source) throws jakarta.xml.bind.JAXBException Attempt to de-serialise and return aValidationProfileinstance from an XML representation that can be read fromtoConvert.- Parameters:
source- an InputStream to an XML representation of a profile- Returns:
- a new
ValidationProfileinstance - Throws:
jakarta.xml.bind.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 jakarta.xml.bind.JAXBException - Parameters:
toConvert- aValidationProfileto convert to an XML Stringdest- a Writer used to write the generated XML toprettyXml- set to Boolean.TRUE for pretty formatted XML, Boolean.FALSE for no space formatting- Throws:
jakarta.xml.bind.JAXBException- thrown by JAXB marshaller if there's an error converting the objectIllegalArgumentException- if toConvert is null
-
directoryFromProfiles
Create aProfileDirectoryfrom aSetofValidationProfiles. Note that the returned directory uses eachValidationProfile's associatedPDFAFlavouras a directory key. This means that only a singleValidationProfilecan be associated with a particularPDFAFlavour. If theSetof Profiles passed inprofilescontains multipleValidationProfiles with the samePDFAFlavouronly one will be contained in the returnedProfileDirectory. Which one is indeterminate.- Parameters:
profiles- a Set ofValidationProfiles used to populate the directory instance- Returns:
- a ProfileDirectory populated with the
ValidationProfiles passed in the profiles parameter - Throws:
IllegalArgumentException- if the profiles parameter is null or empty
-
getVeraProfileDirectory
Returns aProfileDirectoryinstance that has been pre-populated with the curatedValidationProfiles supplied with the veraPDF library.While the veraPDF library and associated
ValidationProfiles 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
public static String getValidationProfileSchema() throws jakarta.xml.bind.JAXBException, IOExceptionReturns the JAXB generated XML schema for the ValidationProfileImpl type.- Returns:
- the String representation of the schema
- Throws:
jakarta.xml.bind.JAXBException- if there's a problem marshaling the schemaIOException- if there's a problem outputting the result
-
getProfileWithTags
public static ValidationProfile getProfileWithTags(ValidationProfile profile, Set<String> includeTags, Set<String> excludeTags)
-