Class DTCPConfiguration
Loads a DataComparator from a DTCP configuration.
DTCP (Data Comparator Pipeline) is a declarative file format for defining the pipeline and settings for the Data Comparator. It supports DTCP file format version 1.0 as described in DTCP TODO make user guide User Guide.
This class provides methods for obtaining information from DTCP files and also for loading a DataComparator instance and
configuring it using data from the DTCP and any supplied override parameters. The constructor of this class is responsible for
ensuring basic validity of the input DTCP. Full validation is performed by default when generate() or
setParams(Map, Map) is called.
The constructor optionally allows a 'checkDTCP' argument that can be set false to disable validation of the DTCP. This may improve performance, but results in less informative exception messages. It is therefore recommended that this is only used for cases where the DTCP file and any parameter overrides are already known to be valid.
- Since:
- 17.0
- Author:
- Charlotte Lawrence, Edward Monah
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a DTCPConfiguration object from a DTCP file.DTCPConfiguration(File f, boolean checkDTCP) Creates a DTCPConfiguration object from a DTCP file.DTCPConfiguration(File f, net.sf.saxon.s9api.Processor suppliedProcessor) Creates a DTCPConfiguration object from a DTCP file.DTCPConfiguration(File f, net.sf.saxon.s9api.Processor suppliedProcessor, boolean checkDTCP) Creates a DTCPConfiguration object from a DTCP file.DTCPConfiguration(net.sf.saxon.s9api.XdmNode dtcpNode) Creates a DTCPConfiguration object from a supplied XdmNode tree.DTCPConfiguration(net.sf.saxon.s9api.XdmNode dtcpNode, boolean checkDTCP) Creates a DTCPConfiguration object from a supplied XdmNode tree.DTCPConfiguration(InputSource dtcpSource) Creates a DTCPConfiguration object from an InputSource.DTCPConfiguration(InputSource dtcpSource, boolean checkDTCP) Creates a DTCPConfiguration object from an InputSource.DTCPConfiguration(InputSource dtcpSource, net.sf.saxon.s9api.Processor suppliedProcessor) Creates a DTCPConfiguration object from an InputSource.DTCPConfiguration(InputSource dtcpSource, net.sf.saxon.s9api.Processor suppliedProcessor, boolean checkDTCP) Creates a DTCPConfiguration object from an InputSource. -
Method Summary
Modifier and TypeMethodDescriptionvoidgenerate()Initializes the internal instance of a concreteFeatureComparator.voidInitializes the internal instance of aDataComparator.Returns the boolean parameters declared in a configuration file.Returns the boolean parameters declared in a configuration file.Returns the configuredDataComparatorinstance.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.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 DTCP 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
-
DTCPConfiguration
public DTCPConfiguration(File f, net.sf.saxon.s9api.Processor suppliedProcessor, boolean checkDTCP) throws StaticPDFormatException, FileNotFoundException Creates a DTCPConfiguration object from a DTCP file. Once loaded this Object can be queried for information from the DTCP configuration file and a DataComparator object can be generated usinggenerate().- Parameters:
f- A File containing a DTCP configurationsuppliedProcessor- A Saxon Processor instance. This will be used to process the DTCP file but will also be supplied to the generated DataComparator instance as its underlying Processor. SeeDataComparator(Processor)for more details.checkDTCP- Specifies whether to validate and perform other checks on input DTCP- Throws:
StaticPDFormatException- if the DTCP file is not well-formed or validFileNotFoundException- if the DTCP file cannot be located
-
DTCPConfiguration
public DTCPConfiguration(File f, boolean checkDTCP) throws StaticPDFormatException, FileNotFoundException Creates a DTCPConfiguration object from a DTCP file. Once loaded this Object can be queried for information from the DTCP configuration file and a DataComparator object can be generated usinggenerate().- Parameters:
f- A File containing a DTCP configurationcheckDTCP- Specifies whether to validate and perform other checks on input DTCP- Throws:
StaticPDFormatException- if the DTCP file is not well-formed or validFileNotFoundException- if the DTCP file cannot be located
-
DTCPConfiguration
public DTCPConfiguration(InputSource dtcpSource, net.sf.saxon.s9api.Processor suppliedProcessor, boolean checkDTCP) throws StaticPDFormatException Creates a DTCPConfiguration object from an InputSource. It is recommended that the supplied InputSource should have a systemId set, otherwise validation issues may arise.- Parameters:
dtcpSource- An InputSource containing a DTCP configurationsuppliedProcessor- A Saxon Processor instance. This will be used to process the DTCP file but will also be supplied to the generated DataComparator instance as its underlying Processor. SeeDataComparator(Processor)for more details.checkDTCP- Specifies whether to validate and perform other checks on input DTCP- Throws:
StaticPDFormatException- if the DTCP source is not well-formed or valid
-
DTCPConfiguration
Creates a DTCPConfiguration object from an InputSource. It is recommended that the supplied InputSource should have a systemId set, otherwise validation issues may arise.- Parameters:
dtcpSource- An InputSource containing a DTCP configurationcheckDTCP- Specifies whether to validate and perform other checks on input DTCP- Throws:
StaticPDFormatException- if the DTCP source is not well-formed or valid
-
DTCPConfiguration
public DTCPConfiguration(net.sf.saxon.s9api.XdmNode dtcpNode, boolean checkDTCP) throws StaticPDFormatException Creates a DTCPConfiguration object from a supplied XdmNode tree.- Parameters:
dtcpNode- An XdmNode tree containing a DTCP configurationcheckDTCP- Specifies whether to validate and perform other checks on input DTCP- Throws:
StaticPDFormatException- if the DTCP document is not valid
-
DTCPConfiguration
public DTCPConfiguration(File f, net.sf.saxon.s9api.Processor suppliedProcessor) throws StaticPDFormatException, FileNotFoundException Creates a DTCPConfiguration object from a DTCP file. Once loaded this Object can be queried for information from the DTCP configuration file and a DataComparator object can be generated usinggenerate().- Parameters:
f- A File containing a DTCP configurationsuppliedProcessor- A Saxon Processor instance. This will be used to process the DTCP file but will also be supplied to the generated DataComparator instance as its underlying Processor. SeeDataComparator(Processor)for more details.- Throws:
StaticPDFormatException- if the DTCP file is not well-formed or validFileNotFoundException- if the DTCP file cannot be located
-
DTCPConfiguration
Creates a DTCPConfiguration object from a DTCP file. Once loaded this Object can be queried for information from the DTCP configuration file and a DataComparator object can be generated usinggenerate().- Parameters:
f- A File containing a DTCP configuration- Throws:
StaticPDFormatException- if the DTCP file is not well-formed or validFileNotFoundException- if the DTCP file cannot be located
-
DTCPConfiguration
public DTCPConfiguration(InputSource dtcpSource, net.sf.saxon.s9api.Processor suppliedProcessor) throws StaticPDFormatException Creates a DTCPConfiguration object from an InputSource. It is recommended that the supplied InputSource should have a systemId set, otherwise validation issues may arise.- Parameters:
dtcpSource- An InputSource containing a DTCP configurationsuppliedProcessor- A Saxon Processor instance. This will be used to process the DTCP file but will also be supplied to the generated DataComparator instance as its underlying Processor. SeeDataComparator(Processor)for more details.- Throws:
StaticPDFormatException- if the DTCP source is not well-formed or valid
-
DTCPConfiguration
Creates a DTCPConfiguration object from an InputSource. It is recommended that the supplied InputSource should have a systemId set, otherwise validation issues may arise.- Parameters:
dtcpSource- An InputSource containing a DTCP configuration- Throws:
StaticPDFormatException- if the DTCP source is not well-formed or valid
-
DTCPConfiguration
Creates a DTCPConfiguration object from a supplied XdmNode tree.- Parameters:
dtcpNode- An XdmNode tree containing a DTCP configuration- Throws:
StaticPDFormatException- if the DTCP 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 aDataComparator. This method must only be called once.- Parameters:
booleanOverrides- A map of name, boolean value parameters with which to configure the generatedDataComparatorstringOverrides- A map of name, String value parameters with which to configure the generatedDataComparator- Throws:
DynamicPDFormatException- if a problem is found when attempting to resolve DTCP valuesPDFilterConfigurationException- if a problem is found when loading an XML filterStaticPDFormatException- if the resolved DTCP 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 DynamicPDFormatException, PDAdvancedConfigException, PDFilterConfigurationExceptionString> stringOverrides) Set new parameter values to override named default parameter settings included in the DTCP file. This method call must be preceded by a call to thegenerate()method.- Parameters:
booleanOverrides- set parameter values for DTCP-defined boolean pipeline parametersstringOverrides- set parameter values for DTCP-defined string pipeline parameters- Throws:
PDFilterConfigurationException- if problem found while resolving DTCP valuesIllegalStateException- ifgenerate()method has not been called firstDynamicPDFormatExceptionPDAdvancedConfigException
-
getComparator
Returns the configuredDataComparatorinstance. Must be used after thegenerate()method is called to initialize theDataComparator- Returns:
- the DTCP-configured
DataComparator - Throws:
IllegalStateException- ifgenerate()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)orDCPConfiguration.generate(Map, Map)method.- Returns:
- a Map describing the boolean parameters and their default values
- See Also:
-
DXPConfiguration.generate(Map, Map)DCPConfiguration.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)orDCPConfiguration.generate(Map, Map)method.- Returns:
- a Map describing the string parameters and their default values
- See Also:
-
DXPConfiguration.generate(Map, Map)DCPConfiguration.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.
-