Class DCPConfiguration
Loads a DocumentComparator from a DCP configuration.
DCP (Document Comparator Pipeline) is a declarative file format for defining the pipeline and settings for the Document Comparator. It supports DCP file format version 1.0 as described in DCP User Guide.
This class provides methods for obtaining information from DCP files and also for loading a DocumentComparator instance and
configuring it using data from the DCP and any supplied override parameters. The constructor of this class is responsible for
ensuring basic validity of the input DCP. Full validation is performed by default when generate() or
setParams(Map, Map) is called.
The constructor optionally allows a 'checkDCP' argument that can be set false to disable validation of the DCP. This may improve performance, but results in less informative exception messages. It is therefore recommended that this is only used for cases where the DCP file and any parameter overrides are already known to be valid.
- Since:
- 7.2
- Author:
- John Morgan
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a DCPConfiguration object from a DCP file.DCPConfiguration(File f, boolean checkDCP) Creates a DCPConfiguration object from a DCP file.DCPConfiguration(File f, net.sf.saxon.s9api.Processor suppliedProcessor) Creates a DCPConfiguration object from a DCP file.DCPConfiguration(File f, net.sf.saxon.s9api.Processor suppliedProcessor, boolean checkDCP) Creates a DCPConfiguration object from a DCP file.DCPConfiguration(net.sf.saxon.s9api.XdmNode dcpNode) Creates a DCPConfiguration object from a supplied XdmNode tree.DCPConfiguration(net.sf.saxon.s9api.XdmNode dcpNode, boolean checkDCP) Creates a DCPConfiguration object from a supplied XdmNode tree.DCPConfiguration(InputSource dcpSource) Creates a DCPConfiguration object from an InputSource.DCPConfiguration(InputSource dcpSource, boolean checkDCP) Creates a DCPConfiguration object from an InputSource.DCPConfiguration(InputSource dcpSource, net.sf.saxon.s9api.Processor suppliedProcessor) Creates a DCPConfiguration object from an InputSource.DCPConfiguration(InputSource dcpSource, net.sf.saxon.s9api.Processor suppliedProcessor, boolean checkDCP) Creates a DCPConfiguration object from an InputSource. -
Method Summary
Modifier and TypeMethodDescriptionvoidgenerate()Initializes the internal instance of a concreteFeatureComparator.voidInitializes the internal instance of aDocumentComparator.Returns the boolean parameters declared in a configuration file.Returns the boolean parameters declared in a configuration file.Returns the configuredDocumentComparatorinstance.Returns the contents of the description attribute of a DXP/DCP File.Returns the contents of the parameter elements as a formatted table.getFormattedParametersDescription(int width, int indent) Returns the contents of the parameter elements as a formatted table.static StringgetFormattedPipelineSummaryTable(Collection<? extends com.deltaxml.core.FeatureConfiguration> featureConfigs, int width, int indent) Returns a table summarising the provided pipelines as a multi-line string.Returns the contents of the fullDescription element.getId()Returns the id attribute from a DXP/DCP file.Returns the description of each of the parameters in a configuration file.Returns the parameters declared in a configuration file.getProcessingInstruction(String instructionName) Returns the value of a processing instruction that is a child node of the root element of the configuration.getResolvedParameterValue(String parameterName) Returns the resolved value of the specified pipelineParameter in the DCP.Returns the string parameters declared in a configuration file.Returns the String parameters declared in a configuration file.Returns the systemId of the loaded DXP/DCP file.Returns the user specified URIResolver.final voidSet new parameter values to override named default parameter settings included in the DCP file.voidsetURIResolver(URIResolver resolver) Specifies the URIResolver to be used with the generated comparator and also during compilation of XSLT scripts.voidsetURIResolver(URIResolver resolver, boolean useFallbackURIResolver) Specifies the URIResolver to be used with the generated comparator and also during compilation of XSLT scripts.toString()Provides a string representation of the configuration based on the systemId of the DXP/DCP file.
-
Constructor Details
-
DCPConfiguration
public DCPConfiguration(File f, net.sf.saxon.s9api.Processor suppliedProcessor, boolean checkDCP) throws StaticPDFormatException, FileNotFoundException Creates a DCPConfiguration object from a DCP file. Once loaded this Object can be queried for information from the DCP configuration file and a DocumentComparator object can be generated usinggenerate().- Parameters:
f- A File containing a DCP configurationsuppliedProcessor- A Saxon Processor instance. This will be used to process the DCP file but will also be supplied to the generated DocumentComparator instance as its underlying Processor. SeeDocumentComparator(Processor)for more details.checkDCP- Specifies whether to validate and perform other checks on input DCP- Throws:
StaticPDFormatException- if the DCP file is not well-formed or validFileNotFoundException- if the DCP file cannot be located
-
DCPConfiguration
public DCPConfiguration(File f, boolean checkDCP) throws StaticPDFormatException, FileNotFoundException Creates a DCPConfiguration object from a DCP file. Once loaded this Object can be queried for information from the DCP configuration file and a DocumentComparator object can be generated usinggenerate().- Parameters:
f- A File containing a DCP configurationcheckDCP- Specifies whether to validate and perform other checks on input DCP- Throws:
StaticPDFormatException- if the DCP file is not well-formed or validFileNotFoundException- if the DCP file cannot be located
-
DCPConfiguration
public DCPConfiguration(InputSource dcpSource, net.sf.saxon.s9api.Processor suppliedProcessor, boolean checkDCP) throws StaticPDFormatException Creates a DCPConfiguration object from an InputSource. It is recommended that the supplied InputSource should have a systemId set, otherwise validation issues may arise.- Parameters:
dcpSource- An InputSource containing a DCP configurationsuppliedProcessor- A Saxon Processor instance. This will be used to process the DCP file but will also be supplied to the generated DocumentComparator instance as its underlying Processor. SeeDocumentComparator(Processor)for more details.checkDCP- Specifies whether to validate and perform other checks on input DCP- Throws:
StaticPDFormatException- if the DCP source is not well-formed or valid
-
DCPConfiguration
Creates a DCPConfiguration object from an InputSource. It is recommended that the supplied InputSource should have a systemId set, otherwise validation issues may arise.- Parameters:
dcpSource- An InputSource containing a DCP configurationcheckDCP- Specifies whether to validate and perform other checks on input DCP- Throws:
StaticPDFormatException- if the DCP source is not well-formed or valid
-
DCPConfiguration
public DCPConfiguration(net.sf.saxon.s9api.XdmNode dcpNode, boolean checkDCP) throws StaticPDFormatException Creates a DCPConfiguration object from a supplied XdmNode tree.- Parameters:
dcpNode- An XdmNode tree containing a DCP configurationcheckDCP- Specifies whether to validate and perform other checks on input DCP- Throws:
StaticPDFormatException- if the DCP document is not valid
-
DCPConfiguration
public DCPConfiguration(File f, net.sf.saxon.s9api.Processor suppliedProcessor) throws StaticPDFormatException, FileNotFoundException Creates a DCPConfiguration object from a DCP file. Once loaded this Object can be queried for information from the DCP configuration file and a DocumentComparator object can be generated usinggenerate().- Parameters:
f- A File containing a DCP configurationsuppliedProcessor- A Saxon Processor instance. This will be used to process the DCP file but will also be supplied to the generated DocumentComparator instance as its underlying Processor. SeeDocumentComparator(Processor)for more details.- Throws:
StaticPDFormatException- if the DCP file is not well-formed or validFileNotFoundException- if the DCP file cannot be located
-
DCPConfiguration
Creates a DCPConfiguration object from a DCP file. Once loaded this Object can be queried for information from the DCP configuration file and a DocumentComparator object can be generated usinggenerate().- Parameters:
f- A File containing a DCP configuration- Throws:
StaticPDFormatException- if the DCP file is not well-formed or validFileNotFoundException- if the DCP file cannot be located
-
DCPConfiguration
public DCPConfiguration(InputSource dcpSource, net.sf.saxon.s9api.Processor suppliedProcessor) throws StaticPDFormatException Creates a DCPConfiguration object from an InputSource. It is recommended that the supplied InputSource should have a systemId set, otherwise validation issues may arise.- Parameters:
dcpSource- An InputSource containing a DCP configurationsuppliedProcessor- A Saxon Processor instance. This will be used to process the DCP file but will also be supplied to the generated DocumentComparator instance as its underlying Processor. SeeDocumentComparator(Processor)for more details.- Throws:
StaticPDFormatException- if the DCP source is not well-formed or valid
-
DCPConfiguration
Creates a DCPConfiguration object from an InputSource. It is recommended that the supplied InputSource should have a systemId set, otherwise validation issues may arise.- Parameters:
dcpSource- An InputSource containing a DCP configuration- Throws:
StaticPDFormatException- if the DCP source is not well-formed or valid
-
DCPConfiguration
Creates a DCPConfiguration object from a supplied XdmNode tree.- Parameters:
dcpNode- An XdmNode tree containing a DCP configuration- Throws:
StaticPDFormatException- if the DCP document is not valid
-
-
Method Details
-
generate
public void generate(Map<String, Boolean> booleanOverrides, Map<String, throws DynamicPDFormatException, PDAdvancedConfigException, StaticPDFormatException, PDFilterConfigurationExceptionString> stringOverrides) Initializes the internal instance of aDocumentComparator. This method must only be called once.- Parameters:
booleanOverrides- A map of name, boolean value parameters with which to configure the generatedDocumentComparatorstringOverrides- A map of name, String value parameters with which to configure the generatedDocumentComparator- Throws:
DynamicPDFormatException- if a problem is found when attempting to resolve DCP valuesPDFilterConfigurationException- if a problem is found when loading an XML filterStaticPDFormatException- if the resolved DCP values are invalidPDAdvancedConfigException- when properties or features in 'advancedConfig' element cause an errorIllegalStateException- if called more than once
-
setParams
public final void setParams(Map<String, Boolean> booleanOverrides, Map<String, throws PDFilterConfigurationException, DynamicPDFormatException, PDAdvancedConfigException, IllegalStateExceptionString> stringOverrides) Set new parameter values to override named default parameter settings included in the DCP file. This method call must be preceded by a call to thegenerate()method.- Parameters:
booleanOverrides- set parameter values for DCP-defined boolean pipeline parametersstringOverrides- set parameter values for DCP-defined string pipeline parameters- Throws:
PDAdvancedConfigException- when properties or features in 'advancedConfig' element cause an errorDynamicPDFormatException- if problem found while resolving DCP valuesPDFilterConfigurationException- if problem found when loading an XML filterIllegalStateException- ifgenerate()method has not been called first
-
getComparator
Returns the configuredDocumentComparatorinstance. Must be used after thegenerate()method is called to initialize theDocumentComparator- Returns:
- the DCP-configured
DocumentComparator - Throws:
IllegalStateException- ifgenerate()method has not been called first
-
getResolvedParameterValue
Returns the resolved value of the specified pipelineParameter in the DCP.- Parameters:
parameterName- name of the parameter- Returns:
- the resolved parameter value as a string. Null is returned when no matching parameter is found or the
generate()method has not been called first
-
generate
public void generate() throws StaticPDFormatException, PDFilterConfigurationException, DynamicPDFormatException, PDAdvancedConfigException, IllegalStateExceptionInitializes the internal instance of a concreteFeatureComparator. This method must only be called once.- Throws:
DynamicPDFormatException- if a problem is found when attempting to resolve Comparator Pipeline valuesPDFilterConfigurationException- if a problem is found when loading an XML filterStaticPDFormatException- if the resolved Comparator Pipeline values are invalidPDAdvancedConfigException- when properties or features in 'advancedConfig' element cause an errorIllegalStateException- if called more than once
-
getProcessingInstruction
Returns the value of a processing instruction that is a child node of the root element of the configuration. Processing instruction values are available as soon as the Configuration object is instantiated.- Parameters:
instructionName- name of the processing-instruction (cannot be in a namespace)- Returns:
- the processing-instruction value
- See Also:
-
getFormattedPipelineSummaryTable
public static String getFormattedPipelineSummaryTable(Collection<? extends com.deltaxml.core.FeatureConfiguration> featureConfigs, int width, int indent) Returns a table summarising the provided pipelines as a multi-line string. There is a minimum width of 40, any provided width less than 40 is treated as 40.- Parameters:
featureConfigs- The dxpConfigurations to summarise.width- the maximum width of each line for the description (not including the indent)indent- the number of spaces to prefix each line with.- Returns:
- a table summarising the provided pipeline as a multi-line string.
- Since:
- 6.2
-
getId
Returns the id attribute from a DXP/DCP file. The id attribute is compulsory on a valid DXP or DCP file butnullmay be returned on an invalid file.- Returns:
- the value of the id attribute
-
getSystemId
Returns the systemId of the loaded DXP/DCP file. The value will depend on how the DXP/DCP file was loaded. The following list provides a summary.- Loaded as an
InputSource- returns the result ofInputSource.getSystemId() - Loaded as a
File- returns the result ofFile.toURI().toURL().toExternalForm() - Loaded as an XdmNode - returns the result of
XdmNode.getDocumentURI()
- Returns:
- the SystemId of the loaded DXP/DCP file, null if unknown or cannot be determined
- See Also:
- Loaded as an
-
getDescription
Returns the contents of the description attribute of a DXP/DCP File. This attribute provides a more human friendly description of the pipeline and can be used in command-lines or selection boxes for example.- Returns:
- the contents of description attribute
-
getBooleanParameterList
Returns the boolean parameters declared in a configuration file. This method can be used in UIs and other applications which may wish to display parameter options prior to creating a pipeline instance.- Returns:
- a list of boolean DXP/DCP parameter definitions.
-
getStringParameterList
Returns the string parameters declared in a configuration file. This method can be used in UIs and other applications which may wish to display parameter options prior to creating a pipeline instance.- Returns:
- a list of string DXP/DCP parameter definitions.
-
getParameterList
Returns the parameters declared in a configuration file. This method can be used in UIs and other applications which may wish to display parameter options prior to creating a pipeline instance.- Returns:
- a list of DXP/DCP parameter definitions.
-
getBooleanParameters
Returns the boolean parameters declared in a configuration file. This method can be used in UIs and other applications which may wish to display parameter options prior to creating a pipeline instance. For example it is possible to obtain the Map provided by this method and then pass the Map, possibly modified, as an argument to the applicableDXPConfiguration.generate(Map, Map)orgenerate(Map, Map)method.- Returns:
- a Map describing the boolean parameters and their default values
- See Also:
-
DXPConfiguration.generate(Map, Map)generate(Map, Map)AbstractDPConfiguration.getStringParameters()
-
getParameterDescriptions
Returns the description of each of the parameters in a configuration file. This method can be used in UIs and other applications which may wish to display parameters prior to creating a pipeline instance.- Returns:
- a Map containing each of the parameters by name along with a textual description
-
getStringParameters
Returns the String parameters declared in a configuration file. This method can be used in UIs and other applications which may wish to display parameter options prior to creating a pipeline instance. For example, it is possible to obtain the Map provided by this method and then pass the Map, possibly modified, as an argument to the applicableDXPConfiguration.generate(Map, Map)orgenerate(Map, Map)method.- Returns:
- a Map describing the string parameters and their default values
- See Also:
-
DXPConfiguration.generate(Map, Map)generate(Map, Map)AbstractDPConfiguration.getBooleanParameters()
-
getFullDescription
Returns the contents of the fullDescription element.- Returns:
- the contents of the description element or an empty String.
-
getFormattedParametersDescription
Returns the contents of the parameter elements as a formatted table. This can be used to provide multi-line information to the user about the pipeline's parameters.- Returns:
- the contents of the description and parameter elements or an empty String.
-
getFormattedParametersDescription
Returns the contents of the parameter elements as a formatted table. This can be used to provide multi-line information to the user about the pipeline's parameters.- Parameters:
width- the maximum width of each line for the description (not including the indent)indent- the number of spaces to prefix each line with.- Returns:
- the contents of the description and parameter elements or an empty String.
-
setURIResolver
Specifies the URIResolver to be used with the generated comparator and also during compilation of XSLT scripts. A URIResolver used in this way is useful when resolving files referenced by
<xsl:import>,<xsl:include>anddocument()- Parameters:
resolver- An implementation of the URIResolver interface, or nulluseFallbackURIResolver- Whether to use the fallback URI Resolver, if the user supplied URI Resolver fails to resolve.
-
setURIResolver
Specifies the URIResolver to be used with the generated comparator and also during compilation of XSLT scripts. A URIResolver used in this way is useful when resolving files referenced by
<xsl:import>,<xsl:include>anddocument()This method is equivalent to calling
setURIResolver(resolver, true).- Parameters:
resolver- An implementation of the URIResolver interface, or null
-
getURIResolver
Returns the user specified URIResolver.- Returns:
- the resolver that was last set using one of the setURIResolver methods.
-
toString
Provides a string representation of the configuration based on the systemId of the DXP/DCP file.
-