public class PipelinedComparatorS9 extends java.lang.Object implements CommonComparator
Provides a Pipeline abstraction for the Comparator.
Each of the two comparator input streams is passed through a number of input filters and the comparator output is fed through a chain of output filters. Filters can be used for input processing or cleaning (removing unnecessary whitespace or elements not significant for comparison), keying, or output report generation. They could be implemented using XSLT or Java. The current implementation also supports filter parameterization using String parameters.
Note: This class instantiates the underlying SAX parsers using the JAXP factory mechanisms. A configuration property is also available which can be used to bypass the factory and instantiate Apache Xerces-J directly. Reconfiguring the factories so as to change the underlying factory implementation classes during the existence of a PipelinedComparator is not supported and may result in unpredictable results.
Note: A single instance of this class should not be used by multiple threads. Different instances may be used by different threads.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COMPARATOR_FULL_FEATURE
Comparator feature name for full delta output.
|
static java.lang.String |
CONFIG_DEBUG_FILES
This is a boolean configuration property that when true will send most or all intermediate results to files.
|
static java.lang.String |
CONFIG_OPTIMIZE_XMLFILTERS_AROUND_COMPARATOR
This configuration property provides the default or initial value for this optimization setting.
|
static java.lang.String |
DELTAV2_FEATURE
Comparator feature name for controlling the delta version.
|
static java.lang.String |
ENHANCED_MATCH_1_FEATURE
Comparator feature name for enhanced matching.
|
static java.lang.String |
ORDERLESS_PRESENTATION
A property setting controlling how orderless children are reported.
|
Constructor and Description |
---|
PipelinedComparatorS9()
Creates a new PipelinedComparatorS9.
|
PipelinedComparatorS9(net.sf.saxon.s9api.Processor suppliedProcessor)
A constructor allowing the use of a supplied s9api Processor.
|
Modifier and Type | Method and Description |
---|---|
void |
addLicenseFile(java.io.File licenseFile)
Sets the license file for use with Flexera licensing.
|
void |
addLicenseServer(java.lang.String hostname)
Sets a license server for use with concurrent licensing.
|
void |
addLicenseServer(java.lang.String hostname,
int port)
Sets a license server and port for use with concurrent licensing.
|
void |
addProgressListener(PipelineProgressListener ppl)
Add a progress listener to the list of registered progress listeners.
|
void |
addUsageListener(com.deltaxml.cores9api.common.usage.ComUsageListener ul) |
void |
clearProgressListeners()
Remove all currently registered progress listeners.
|
void |
compare(java.io.File f1,
java.io.File f2,
java.io.File result)
Compares File objects and uses a File to represent the result.
|
void |
compare(org.xml.sax.InputSource a,
org.xml.sax.InputSource b,
javax.xml.transform.stream.StreamResult result)
Compares the XML obtained from InputSource Objects and writes the pipeline result to a StreamResult.
|
void |
compare(java.io.InputStream a,
java.lang.String systemIdA,
java.io.InputStream b,
java.lang.String systemIdB,
java.io.OutputStream result)
Compares the XML obtained from InputStream objects and uses an OutputStream to represent the pipeline result.
|
void |
compare(java.io.Reader a,
java.lang.String systemIdA,
java.io.Reader b,
java.lang.String systemIdB,
java.io.Writer result)
Compares the XML obtained from Reader objects and uses a Writer to represent the pipeline result.
|
void |
compare(java.lang.String a,
java.lang.String systemIdA,
java.lang.String b,
java.lang.String systemIdB,
java.lang.StringBuilder result)
Compares the XML obtained from Strings and uses a StringBuilder to represent the pipeline result.
|
void |
compare(java.net.URL a,
java.net.URL b,
java.io.File result)
Compares the XML obtained from URLs and writes the pipeline result to a File.
|
void |
compare(java.net.URL a,
java.net.URL b,
java.io.OutputStream result)
Compares the XML obtained from URLs and writes the pipeline result to an OutputStream.
|
net.sf.saxon.s9api.XdmNode |
compare(net.sf.saxon.s9api.XdmNode a,
net.sf.saxon.s9api.XdmNode b)
Compares two Saxon XdmNode trees and generates an XdmNode tree result from the pipeline.
|
boolean |
getComparatorFeature(java.lang.String name)
Allows the current settings of comparator features to be determined.
|
java.lang.Object |
getComparatorProperty(java.lang.String name)
Allows the current settings of the comparator properties to be determined.
|
java.lang.String |
getDebugPrefix()
This returns where the debug files will be found.
|
org.xml.sax.EntityResolver |
getEntityResolver()
Returns the current entity resolver setting.
|
LexicalPreservationConfig |
getLexicalPreservationConfig()
Returns the current lexical preservation configuration settings.
|
int |
getNumberOfProgressStages()
Get the total number of enabled Progress Reporting Stages.
|
boolean |
getOptimizeXMLFiltersAroundComparator()
Reports the current value of the optimization setting.
|
java.lang.String |
getOutputProperty(net.sf.saxon.s9api.Serializer.Property property)
Allows the current settings of the serializer properties to be determined.
|
boolean |
getParserFeature(java.lang.String featureName)
Allows the current settings of parser features to be determined.
|
java.lang.Object |
getParserProperty(java.lang.String propertyName)
Allows the current settings of parser properties to be determined.
|
java.lang.Object |
getTransformerConfigurationOption(java.lang.String name)
Reports current attribute settings of the XSLT transformers in the pipeline.
|
javax.xml.transform.URIResolver |
getURIResolver()
Returns the current URI resolver setting.
|
boolean |
isBypassLexicalPreservationOutputChain()
States whether the lexical preservation output chain is being bypassed or not.
|
boolean |
isEqual(java.io.File f1,
java.io.File f2)
Compares two File inputs and returns whether they're equal.
|
boolean |
isEqual(org.xml.sax.InputSource is1,
org.xml.sax.InputSource is2)
Compares two InputSource inputs and returns whether they're equal.
|
boolean |
isEqual(java.io.InputStream a,
java.lang.String systemIdA,
java.io.InputStream b,
java.lang.String systemIdB)
Compares two InputStream inputs and returns whether they're equal.
|
boolean |
isEqual(java.io.Reader a,
java.lang.String systemIdA,
java.io.Reader b,
java.lang.String systemIdB)
Compares two Reader inputs and returns whether they're equal.
|
boolean |
isEqual(java.lang.String a,
java.lang.String systemIdA,
java.lang.String b,
java.lang.String systemIdB)
Compares two String inputs and returns whether they're equal.
|
boolean |
isEqual(java.net.URL u1,
java.net.URL u2)
Compares two URL inputs and returns whether they're equal.
|
boolean |
isEqual(net.sf.saxon.s9api.XdmNode a,
net.sf.saxon.s9api.XdmNode b)
Compares two XdmNode inputs and returns whether they're equal.
|
FilterStepHelper |
newFilterStepHelper()
Creates a
FilterStepHelper using the Processor and URIResolver currently in use by this Core S9 API
Comparator. |
FilterChain |
newLexicalPreservationOutputFilterChain(LexicalPreservationConfig config)
Generates a
FilterChain to process lexical preservation items. |
void |
removeProgressListener(PipelineProgressListener ppl)
Remove a progress listener from the list of registered progress listeners.
|
void |
removeUsageListener(com.deltaxml.cores9api.common.usage.ComUsageListener ul) |
void |
setBypassLexicalPreservationOutputChain(boolean value)
Sets whether or not to bypass the automatically added lexical preservation output chain during the comparison.
|
void |
setCancellationPolicy(CancellationPolicy policy,
java.util.Optional<java.lang.Long> timeoutMs)
Set a policy to timeout the comparison.
|
void |
setComparatorFeature(java.lang.String name,
boolean value)
Sets a Feature (or option) associated with the comparator at the centre of the pipeline.
|
void |
setComparatorProperty(java.lang.String name,
java.lang.Object value)
Configures comparator properties for the pipeline.
|
void |
setComUsageReporter(boolean isReportingFromExternal,
com.deltaxml.cores9api.common.usage.ComUsageReporter reporter,
java.util.Map<java.lang.String,com.deltaxml.cores9api.common.usage.ComJobFile> inputJobFiles,
java.util.Map<java.lang.String,java.lang.String> configuration) |
void |
setDebugFiles(boolean debug)
Determines whether intermediate pipeline result files are generated.
|
void |
setDebugFilesPrefix(java.lang.String debugPrefix)
Provides a prefix for debug result files.
|
void |
setEntityResolver(org.xml.sax.EntityResolver resolver)
Set an entity resolver for use when reading the inputs to the pipelined comparator.
|
void |
setEntityResolver(org.xml.sax.EntityResolver resolver,
boolean useFallbackEntityResolver)
Set an entity resolver for use when reading the inputs to the pipelined comparator.
|
void |
setInput1Filters(FilterChain filters)
Allows filters to be specified using a
FilterChain . |
void |
setInput2Filters(FilterChain filters)
Allows filters to be specified using a
FilterChain . |
void |
setInputFilters(FilterChain filters)
Allows input filters to be specified using a
FilterChain . |
void |
setLexicalPreservationConfig(LexicalPreservationConfig lpc)
Sets the
LexicalPreservationConfig to use during comparison. |
void |
setOptimizeXMLFiltersAroundComparator(boolean optimize)
Apply streaming optimization to filters around the comparator.
|
void |
setOutputFilters(FilterChain filters)
Allows output filters to be specified using a
FilterChain . |
void |
setOutputProperty(net.sf.saxon.s9api.Serializer.Property property,
java.lang.String value)
Configures output formatting and control.
|
void |
setParserFeature(java.lang.String featureName,
boolean value)
Sets a feature on the parser used for reading XML inputs into a Core S9 Comparator.
|
void |
setParserProperty(java.lang.String propertyName,
java.lang.Object value)
Configures parser properties for the pipeline input parsers.
|
void |
setRedistributionLicenseContent(long[] encodedLicense)
Sets a redistribution license for use with subsequent compare operations.
|
void |
setTransformerConfigurationOption(java.lang.String name,
java.lang.Object value)
Set a configuration option on the XSLT transformers used in the pipeline.
|
void |
setURIResolver(javax.xml.transform.URIResolver resolver)
Sets a resolver for use by all XSLT based filters in a Core S9 API comparator.
|
void |
setURIResolver(javax.xml.transform.URIResolver resolver,
boolean useFallbackURIResolver)
Sets a resolver for use by all XSLT based filters in a Core S9 API comparator.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addLicenseFile, addLicenseServer, addLicenseServer, compare, compare, compare, compare, compare, compare, compare, compare, getEntityResolver, getLexicalPreservationConfig, getOutputProperty, getParserFeature, getParserProperty, getURIResolver, setEntityResolver, setEntityResolver, setParserFeature, setParserProperty, setURIResolver, setURIResolver
public static final java.lang.String CONFIG_DEBUG_FILES
public static final java.lang.String CONFIG_OPTIMIZE_XMLFILTERS_AROUND_COMPARATOR
public static final java.lang.String COMPARATOR_FULL_FEATURE
Comparator feature name for full delta output.
The String value of this feature is: "http://deltaxml.com/api/feature/isFullDelta"
A comparator can produce a minimal changes only delta (useful in conjunction with com.deltaxml.api.XMLCombiner
) where
unchanged subtrees are not included in the result, or a full delta which contains all of the information from both inputs and
describes where it is changed or unchanged.
When the feature is true a full delta is produced. A false setting will give a minimal or changes only delta. The default value is true.
public static final java.lang.String ENHANCED_MATCH_1_FEATURE
Comparator feature name for enhanced matching.
The String value of this feature is: "http://deltaxml.com/api/feature/enhancedMatch1"
When this feature is set to true a modified comparison (matching) algorithm that is tailored to documents, i.e. XML with a high proportion of text data, is used. This gives better matching results particularly when used in conjunction with word-by-word filtering.
When false a backwards-compatible (pre release 4.x) matching algorithm is used.
The default value is true.
public static final java.lang.String DELTAV2_FEATURE
Comparator feature name for controlling the delta version.
The String value of this feature is: "http://deltaxml.com/api/feature/deltaV2"
This feature setting controls the version of the delta format produced by the comparator. The true setting causes the newer version 2 delta format to be generated. We recommend this setting for all new users. With a false setting a backwards-compatible (version 1) delta is produced. The default value is: true.
public static final java.lang.String ORDERLESS_PRESENTATION
A property setting controlling how orderless children are reported.
This feature has a name of: "http://deltaxml.com/api/property/orderlessPresentation" and its value is also a String object
When the value is a_matches_deletes_adds the output for any orderless comparison is presented in a defined order as follows:
The 'adds' and then the 'deletes' appear in the same order as they appear in their respective inputs.
When the value is a_adds all of the elements from the A input appear in the result in the same order as they appear in that input. Their deltaxml:deltaV2 values ('A=B', 'A!=B' and 'A') will indicate if a similar (as defined by exact subtree or key matching) element appears in the B input and if so how they correspond. Finally the 'adds' - elements from B, with no matches to those in the A input, are listed in the order in which they appear in B.
When the value is b_matches_adds_deletes the output is presented as follows:
The 'deletes' and then the 'adds' appear in the same order as they appear in their respective inputs.
When the value is b_deletes all of the elements from the B input appear in the result in the same order as they appear in that input. Their deltaxml:deltaV2 values ('A=B', 'A!=B' and 'B') will indicate if a similar (as defined by exact subtree or key matching) element appears in the A input and if so how they correspond. Finally the 'deletes' - elements from A, with no matches to those in the B input, are listed in the order in which they appear in A.
The default value for this parameter setting is: a_matches_deletes_adds
A definition of how the orderless results are presented was not included in releases of XML Compare prior to 5.3, however this setting, corresponds to the presentation used in earlier 5.0 - 5.2 releases. Therefore it has been chosen as the default value for maximal compatibility.
public PipelinedComparatorS9() throws ParserInstantiationException, ComparatorInstantiationException
Creates a new PipelinedComparatorS9. This will use an internal Saxon Processor for running XSLT transformations and therefore this constructor should not be used in conjunction with methods which perform XdmNode IO. If planning to use these methods see the constructor that takes a Processor argument.
ParserInstantiationException
- if there is a problem instantiating the XML parserComparatorInstantiationException
- if there is a problem instantiating the underlying comparator used in the pipelinePipelinedComparatorS9(Processor)
public PipelinedComparatorS9(net.sf.saxon.s9api.Processor suppliedProcessor) throws ParserInstantiationException, ComparatorInstantiationException, java.lang.IllegalArgumentException
suppliedProcessor
- A Saxon processor to be used for the NamePool and filter compilation.ParserInstantiationException
- if there is a problem instantiating the XML parserComparatorInstantiationException
- if there is a problem instantiating the underlying comparator used in the pipelinejava.lang.IllegalArgumentException
- if the supplied Processor is not based on Saxon version 9.9 or 10.0.public FilterStepHelper newFilterStepHelper()
Creates a FilterStepHelper
using the Processor
and URIResolver
currently in use by this Core S9 API
Comparator.
Due to the way that Saxon's Processor works, all internal XdmNodes and compiled XSLT must be created by the same
Processor
. Therefore FilterChain
s and FilterStep
s that are to be associated with this Core S9 API
Comparator, should be instantiated by this Comparator's FilterStepHelper
, which is what this method provides.
Note that the set input and output filter methods (e.g. PipelinedComparatorS9.setOutputFilters(FilterChain)
) make use of a
FilterStepHelper
behind the scenes.
newFilterStepHelper
in interface CommonComparator
FilterStepHelper
with which to create FilterChain
s and FilterStep
s for this
Core S9 API Comparator.public void setRedistributionLicenseContent(long[] encodedLicense) throws LicenseException
CommonComparator
DeltaXML Redistribtion or 'OEM' customers should use this method in conjunction with supplied code which is typically compiled and integrated into their own products. The supplied code provides examples of usage. This method is not intended to be used by other types of license/customer.
A LicenseException should always contain a nested exception or cause containing further details of the underlying issue. This will typically be either LicenseContentException or LicenseSecurityException
Note that some of the exceptions thrown here can also be thrown by a compare method.
setRedistributionLicenseContent
in interface CommonComparator
encodedLicense
- a redistribution licenseLicenseException
- if there are any problems with the supplied license or its usepublic void setTransformerConfigurationOption(java.lang.String name, java.lang.Object value) throws java.lang.IllegalArgumentException
Set a configuration option on the XSLT transformers used in the pipeline. Some of the configuration options affect the compilation of XSLT filters and as the compilation process can be triggered by setInputFilters and setOutputFilters methods this method should be used prior to these methods if appropriate.
Please note: Some of the options available with Saxon assume that the Transformer is 'in control' of the
parser or XMLReader used for input processing. In a PipelinedComparatorS9 this is not the case; if an attribute seems to have
no effect look for alternative techniques such as using equivalent features and the setParserFeature(java.lang.String, boolean)
method.
setTransformerConfigurationOption
in interface CommonComparator
name
- The name of the option to setvalue
- The value to be set (an Object)java.lang.IllegalArgumentException
- if the attribute name is not recognized by the underlying TransformerPipelinedComparatorS9.getTransformerConfigurationOption(String)
,
setParserFeature(String, boolean)
public java.lang.Object getTransformerConfigurationOption(java.lang.String name) throws java.lang.IllegalArgumentException
getTransformerConfigurationOption
in interface CommonComparator
name
- of the option to reportjava.lang.IllegalArgumentException
- if the attribute name is not recognized by the underlying TransformerFactoryPipelinedComparatorS9.setTransformerConfigurationOption(String, Object)
public void setComparatorFeature(java.lang.String name, boolean value) throws FeatureNotRecognizedException, java.lang.IllegalArgumentException
com.deltaxml.api
package documentation.name
- the name of the feature whose value is being configuredvalue
- the new value for the featurejava.lang.IllegalArgumentException
- when the feature name parameter is nullFeatureNotRecognizedException
- if the feature name is not recognizedPipelinedComparatorS9.getComparatorFeature(String)
public boolean getComparatorFeature(java.lang.String name) throws FeatureNotRecognizedException, java.lang.IllegalArgumentException
name
- the name of the feature whose value is being queriedjava.lang.IllegalArgumentException
- when the feature name parameter is nullFeatureNotRecognizedException
- if the feature name is not recognizedPipelinedComparatorS9.setComparatorFeature(String, boolean)
public void setComparatorProperty(java.lang.String name, java.lang.Object value) throws PropertyNotRecognizedException, java.lang.IllegalArgumentException
name
- the name of the property to be setvalue
- the Object representing the value of the propertyPropertyNotRecognizedException
- if the property name is not recognizedjava.lang.IllegalArgumentException
- if a property name or value is null or if a value is not supportedPipelinedComparatorS9.getComparatorProperty(String)
public java.lang.Object getComparatorProperty(java.lang.String name) throws PropertyNotRecognizedException, java.lang.IllegalArgumentException
name
- the name of the property whose value is being queriedPropertyNotRecognizedException
- if the property name is not recognizedjava.lang.IllegalArgumentException
- if the property name is nullPipelinedComparatorS9.setComparatorProperty(String, Object)
public void setOutputProperty(net.sf.saxon.s9api.Serializer.Property property, java.lang.String value) throws java.lang.IllegalArgumentException
Configures output formatting and control.
Any properties set here are then passed to the Serializer
used to write the output in most of the
compare methods. The compare method which returns an XdmNode result bypasses XML serialization and any properties will have
no effect with this method.
NOTE The Saxon s9api Serializer will throw an XPathException which in turn will be presented as an exception during compare or isEqual when "omit-xml-declaration" has the value "yes" and standalone has either of the values "yes" or "no". Saxon does however support setting the "standalone" property to "omit" as described in the XSLT2 serialization specification.
Earlier releases supported only a limited subset of the common properties. The drawback of the new approach is that PropertyNotRecognized exceptions cannot be reported immediately when the property is set.
Output properties should be set using the Serializer.Property
enumeration as follows:
PipelinedComparatorS9 pc= new PipelinedComparatorS9(); ... pc.setOutputProperty(Serializer.Property.INDENT, "yes");
setOutputProperty
in interface CommonComparator
property
- the property to setvalue
- the new value for the propertyjava.lang.IllegalArgumentException
- if a parameter value is illegal in some waySerializer.setOutputProperty(net.sf.saxon.s9api.Serializer.Property, java.lang.String)
,
Serializer.Property
,
XSLT 2.0 and XQuery 1.0
Serialization, section 5.1.5public void setLexicalPreservationConfig(LexicalPreservationConfig lpc)
Sets the LexicalPreservationConfig
to use during comparison.
Note that setting the config
value to null
disables the lexical preservation.
setLexicalPreservationConfig
in interface CommonComparator
lpc
- the LexicalPreservationConfig
object to use during comparisonfor details of what the settings are used for
public void setBypassLexicalPreservationOutputChain(boolean value)
Sets whether or not to bypass the automatically added lexical preservation output chain during the comparison.
Typically, this will be set to true and if a LexicalPreservationConfig
object is set on this
PipelinedComparatorS9
, the output chain will be added automatically. However, if you wish to add these filters to a
different location, you can create them using PipelinedComparatorS9.newLexicalPreservationOutputFilterChain(LexicalPreservationConfig)
and
manually add them to the output FilterChain
. If you do this, you should turn off the automatic addition by passing a
value of false
to this method.
value
- whether or not to bypass the automatic lexical preservation output chainpublic boolean isBypassLexicalPreservationOutputChain()
States whether the lexical preservation output chain is being bypassed or not.
PipelinedComparatorS9.setBypassLexicalPreservationOutputChain(boolean)
public void setCancellationPolicy(CancellationPolicy policy, java.util.Optional<java.lang.Long> timeoutMs)
policy
- The policy which dictates how the timeout will work. The default is CancellationPolicy.Noop
timeoutMs
- An Optional timeout for use when policy is CancellationPolicy.Timed
. The default is 5 minutesCancellationPolicy
public void setInput1Filters(FilterChain filters)
FilterChain
.
Filters added using this method will be applied to input 1 only.
filters
- the FilterChain
object to be set as the input filters on input 1 for this PipelinedComparatorpublic void setInput2Filters(FilterChain filters)
FilterChain
.
Filters added using this method will be applied to input 2 only.
filters
- the FilterChain
object to be set as the input filters on input 2 for this PipelinedComparatorpublic void setInputFilters(FilterChain filters)
FilterChain
.
Filters added using this method will be applied to both inputs.
If the FilterChain
contains any XMLFilterImplStep
s then consideration of serial reusability and multithreaded
operation is necessary. Please see the javadoc for the XMLFilterImplStep
class.
filters
- the FilterChain
object to be set as the input filters on this PipelinedComparatorXMLFilterImplStep
public void setOutputFilters(FilterChain filters)
FilterChain
.
Filters added using this method will be applied to the output only.
filters
- the FilterChain
object to be set as the output filters for this PipelinedComparatorpublic void setDebugFiles(boolean debug)
setDebugFiles
in interface CommonComparator
debug
- when true intermediate result files are producedPipelinedComparatorS9.setDebugFilesPrefix(String)
public void setDebugFilesPrefix(java.lang.String debugPrefix)
setDebugFilesPrefix
in interface CommonComparator
debugPrefix
- Must be a non null String which can be used as a valid name for a directory in which debug files will be
put.PipelinedComparatorS9.setDebugFiles(boolean)
public java.lang.String getDebugPrefix()
PipelinedComparatorS9.setDebugFilesPrefix(String)
public void setOptimizeXMLFiltersAroundComparator(boolean optimize)
optimize
- if true optimization is donepublic boolean getOptimizeXMLFiltersAroundComparator()
public FilterChain newLexicalPreservationOutputFilterChain(LexicalPreservationConfig config)
Generates a FilterChain
to process lexical preservation items.
The parameter settings of the FilterStep
s in the FilterChain
will be based upon the supplied
LexicalPreservationConfig
.
N.B. Serialization aspects of lexical preservation output (e.g. DOCTYPE, CDATA etc.) will not be configured in the resultant FilterChain. These options will still need to be set on whatever object is being used for Serialization (whether that be as part of the comparison or as a separate serialization step)
config
- the configuration object upon which to base the lexical preservation output parametersFilterChain
of a PipelinedComparatorS9
public boolean isEqual(net.sf.saxon.s9api.XdmNode a, net.sf.saxon.s9api.XdmNode b) throws FilterProcessingException, ComparisonException, LicenseException, ComparisonCancelledException
a
- the first XdmNode tree to compareb
- the second XdmNode tree to compare against the firstLicenseException
- if there is a licensing issue that prevents operationFilterProcessingException
- if there was a problem running any of the filtersComparisonException
- if there is a problem during the comparison stage of the pipelineComparisonCancelledException
- If the comparison was cancelledpublic boolean isEqual(java.io.File f1, java.io.File f2) throws ComparisonException, FilterProcessingException, java.io.FileNotFoundException, java.io.IOException, PipelineLoadingException, LicenseException, ComparisonCancelledException
f1
- the first File object to comparef2
- the second File object to compare against the firstjava.io.IOException
- if there is a problem constructing or closing FileInputStreams using the argumentsjava.io.FileNotFoundException
- if the input File argument cannot be foundPipelineLoadingException
- if the inputs cannot be loaded or parsedFilterProcessingException
- if there was a problem running any of the filtersLicenseException
- if there is a licensing issue that prevents operationComparisonException
- if there is a problem during the comparison stage of the pipelineComparisonCancelledException
- if the comparison is cancelledpublic boolean isEqual(java.io.Reader a, java.lang.String systemIdA, java.io.Reader b, java.lang.String systemIdB) throws ComparisonException, FilterProcessingException, PipelineLoadingException, LicenseException, ComparisonCancelledException
Warning: Using this isEqual method with input data that refers to relative URIs is not recommended. We would
recommend using PipelinedComparatorS9.isEqual(InputSource, InputSource)
and constructing InputSources with a Reader and a systemId to
ensure that relative URIs are referenced correctly.
a
- The reader from which the first input is readb
- The reader for the second inputsystemIdA
- the SystemId used for resolving URIs and reporting errors associated with the A inputsystemIdB
- the SystemId used for resolving URIs and reporting errors associated with the B inputComparisonException
- if there is a problem during the comparison stage of the pipelinePipelineLoadingException
- if the inputs cannot be loaded or parsedFilterProcessingException
- if there was a problem running any of the filtersLicenseException
- if there is a licensing issue that prevents operationComparisonCancelledException
- if the comparison is cancelledpublic boolean isEqual(org.xml.sax.InputSource is1, org.xml.sax.InputSource is2) throws ComparisonException, FilterProcessingException, PipelineLoadingException, LicenseException, ComparisonCancelledException
is1
- the first InputSource object to compareis2
- the second InputSource object to compare against the firstComparisonException
- if there is a problem during the comparison stage of the pipelinePipelineLoadingException
- if the inputs cannot be loaded or parsedFilterProcessingException
- if there was a problem running any of the filtersLicenseException
- if there is a licensing issue that prevents operationComparisonCancelledException
- if the comparison is cancelledpublic boolean isEqual(java.io.InputStream a, java.lang.String systemIdA, java.io.InputStream b, java.lang.String systemIdB) throws ComparisonException, PipelineLoadingException, FilterProcessingException, LicenseException, ComparisonCancelledException
a
- The InputStream from which the first input is readb
- The InputStream for the second inputsystemIdA
- the SystemId used for resolving URIs and reporting errors associated with the A inputsystemIdB
- the SystemId used for resolving URIs and reporting errors associated with the B inputComparisonException
- if there is a problem during the comparison stage of the pipelinePipelineLoadingException
- if the inputs cannot be loaded or parsedFilterProcessingException
- if there was a problem running any of the filtersLicenseException
- if there is a licensing issue that prevents operationComparisonCancelledException
- if the comparison is cancelledpublic boolean isEqual(java.lang.String a, java.lang.String systemIdA, java.lang.String b, java.lang.String systemIdB) throws ComparisonException, PipelineLoadingException, FilterProcessingException, LicenseException, ComparisonCancelledException
a
- The String from which the first input is readb
- The String for the second inputsystemIdA
- the SystemId used for resolving URIs and reporting errors associated with the A inputsystemIdB
- the SystemId used for resolving URIs and reporting errors associated with the B inputComparisonException
- if there is a problem during the comparison stage of the pipelinePipelineLoadingException
- if the inputs cannot be loaded or parsedFilterProcessingException
- if there was a problem running any of the filtersLicenseException
- if there is a licensing issue that prevents operationComparisonCancelledException
- if the comparison is cancelledpublic boolean isEqual(java.net.URL u1, java.net.URL u2) throws ComparisonException, PipelineLoadingException, FilterProcessingException, LicenseException, ComparisonCancelledException
u1
- the first URL to compareu2
- the second URL to compare against the firstComparisonException
- if there is a problem during the comparison stage of the pipelinePipelineLoadingException
- if the inputs cannot be loaded or parsedFilterProcessingException
- if there was a problem running any of the filtersLicenseException
- if there is a licensing issue that prevents operationComparisonCancelledException
- if the comparison is cancelledpublic void addProgressListener(PipelineProgressListener ppl)
ppl
- the progress listener to register.public void removeProgressListener(PipelineProgressListener ppl)
ppl
- the progress listener to remove.public int getNumberOfProgressStages()
CommonComparator
PipelineProgressListener
.getNumberOfProgressStages
in interface CommonComparator
public LexicalPreservationConfig getLexicalPreservationConfig()
CommonComparator
Returns the current lexical preservation configuration settings.
getLexicalPreservationConfig
in interface CommonComparator
public void clearProgressListeners()
public org.xml.sax.EntityResolver getEntityResolver()
CommonComparator
getEntityResolver
in interface CommonComparator
public void setEntityResolver(org.xml.sax.EntityResolver resolver)
CommonComparator
setEntityResolver(resolver, true)
.setEntityResolver
in interface CommonComparator
resolver
- the user specified entity resolver.public void setEntityResolver(org.xml.sax.EntityResolver resolver, boolean useFallbackEntityResolver)
CommonComparator
setEntityResolver
in interface CommonComparator
resolver
- the user specified entity resolver.useFallbackEntityResolver
- whether to use the internal catalog support (supplied by the fallback entity resolver).public javax.xml.transform.URIResolver getURIResolver()
CommonComparator
getURIResolver
in interface CommonComparator
public void setURIResolver(javax.xml.transform.URIResolver resolver)
CommonComparator
<xsl:import>
,
<xml:include>
and document()
constructs. This is equivalent to calling
setURIResolver(resolver, true)
.setURIResolver
in interface CommonComparator
resolver
- An implementation of the URIResolver interface, or nullpublic void setURIResolver(javax.xml.transform.URIResolver resolver, boolean useFallbackURIResolver)
CommonComparator
<xsl:import>
, <xsl:include>
and document()
constructs.setURIResolver
in interface CommonComparator
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.XsltTransformer.setURIResolver(javax.xml.transform.URIResolver)
public boolean getParserFeature(java.lang.String featureName) throws FeatureNotRecognizedException, java.lang.IllegalArgumentException
CommonComparator
getParserFeature
in interface CommonComparator
featureName
- the name of the feature whose value is being queriedFeatureNotRecognizedException
- if the featureName is not recognizedjava.lang.IllegalArgumentException
- if the argument is nullCommonComparator.setParserFeature(String, boolean)
public void setParserFeature(java.lang.String featureName, boolean value) throws FeatureSettingNotSupportedException, FeatureNotRecognizedException, java.lang.IllegalArgumentException
CommonComparator
Sets a feature on the parser used for reading XML inputs into a Core S9 Comparator.
Feature setting modify the parsing behaviour of a pipeline. In particular features relating to input validation, schema and DTD handling can be controlled. The features which can be controlled are features of the underlying SAX parser used in the pipeline (but with some exceptions described below). If the SAX parser being used is Apache Xerces, the features which can be set are both the generic SAX features and Apache specific ones.
These features are only appropriate and will only be applied when the compare methods in this class are responsible for parsing and loading input XML data. When the compare or isEqual methods use XdmNode arguments the data has already been parsed and the code being used for creating the XdmNode objects should be configured appropriately.
The following table lists settings which should not be used, as the Saxon s9api code used internally in the
PipelinedComparatorS9 will override these settings. Alternative settings using the CommonComparator.setTransformerConfigurationOption(java.lang.String, java.lang.Object)
method must be used instead:
Parser Feature | Corresponding setTransformerConfigurationOption |
---|---|
http://xml.org/sax/features/validation | Feature.DTD_VALIDATION |
http://apache.org/xml/features/xinclude-aware | Feature.XINCLUDE |
http://apache.org/xml/features/xinclude | Feature.XINCLUDE |
The following list includes some of the features which we consider useful in conjunction with a pipelined comparator architecture:
The following table lists features that can only be set to specific values. These fixed settings are necessary for the
comparator to operate properly. This in turn is because Saxon requires particular feature settings to be used and supported
by setFeature. Any attempt to set values other than those shown below will result in a
FeatureSettingNotSupportedException
being thrown.
Feature | fixed/permissible value |
---|---|
http://xml.org/sax/features/namespaces | true |
http://xml.org/sax/features/namespace- prefixes | false |
setParserFeature
in interface CommonComparator
featureName
- the name of the feature to be setvalue
- the new value for the featureFeatureSettingNotSupportedException
- if the feature cannot be set to the specific valueFeatureNotRecognizedException
- if the featureName is not recognizedjava.lang.IllegalArgumentException
- if the featureName argument is nullXMLReader.setFeature(String, boolean)
,
Processor.setConfigurationProperty(Feature, Object)
,
Feature
public java.lang.Object getParserProperty(java.lang.String propertyName) throws PropertyNotRecognizedException, java.lang.IllegalArgumentException
CommonComparator
getParserProperty
in interface CommonComparator
propertyName
- the name of the property whose value is being queriedPropertyNotRecognizedException
- if the property name is not recognizedjava.lang.IllegalArgumentException
- if the argument is nullCommonComparator.setParserProperty(String, Object)
public void setParserProperty(java.lang.String propertyName, java.lang.Object value) throws PropertyNotRecognizedException, PropertySettingNotSupportedException, java.lang.IllegalArgumentException
CommonComparator
Configures parser properties for the pipeline input parsers.
Allows properties of the underlying parser to be configured. If using Apache Xerces-J the following properties may prove useful in comparator pipelines:
setParserProperty
in interface CommonComparator
propertyName
- the name of the property to set on the parservalue
- the new value for the propertyPropertyNotRecognizedException
- if the property name is not recognizedPropertySettingNotSupportedException
- if the property cannot be set to the specific valuejava.lang.IllegalArgumentException
- if an argument is nullCommonComparator.getParserProperty(String)
,
XMLReader.setProperty(java.lang.String, java.lang.Object)
public java.lang.String getOutputProperty(net.sf.saxon.s9api.Serializer.Property property)
CommonComparator
getOutputProperty
in interface CommonComparator
property
- the output property whose value is being queriedSerializer.Property
public void compare(java.io.File f1, java.io.File f2, java.io.File result) throws ComparisonException, FilterProcessingException, java.io.FileNotFoundException, java.io.IOException, PipelineLoadingException, PipelineSerializationException, LicenseException, PipelinedComparatorError, ComparisonCancelledException
CommonComparator
Compares File objects and uses a File to represent the result.
compare
in interface CommonComparator
f1
- the first comparison inputf2
- the second inputresult
- the location where the pipeline result will be writtenComparisonException
- if there is a problem during the comparison processingFilterProcessingException
- if there was a problem running any of the filtersjava.io.FileNotFoundException
- if the input or output files cannot be foundjava.io.IOException
- if there is a problem opening/closing streams associated with the File argumentsPipelineLoadingException
- if the inputs cannot be loaded or parsedPipelineSerializationException
- if the result cannot be saved or serialized to the result locationLicenseException
- if there is a licensing issue that prevents operationPipelinedComparatorError
- if a comparator execution thread is interrupted by another threadComparisonCancelledException
- if a comparison is cancelled according to the CancellationPolicy
in forcepublic void compare(java.io.Reader a, java.lang.String systemIdA, java.io.Reader b, java.lang.String systemIdB, java.io.Writer result) throws ComparisonException, FilterProcessingException, PipelineLoadingException, PipelineSerializationException, LicenseException, PipelinedComparatorError, ComparisonCancelledException
CommonComparator
Compares the XML obtained from Reader objects and uses a Writer to represent the pipeline result.
systemId parameters are provided so that relative URIs can be resolved in the inputs, they are also useful when reporting errors as the systemId may be useful when locating the error position. Using identifiers such as "string1" or "database2" may be useful when the inputs do not contain URIs to resolve as they can aid error diagnosis.
compare
in interface CommonComparator
a
- The reader from which the first input is readsystemIdA
- the SystemId used for resolving URIs and reporting errors associated with the A inputb
- The reader for the second inputsystemIdB
- the SystemId used for resolving URIs and reporting errors associated with the B inputresult
- where the pipeline result will be writtenComparisonException
- if there is a problem during the comparison processingFilterProcessingException
- if there was a problem running any of the filtersPipelineLoadingException
- if the inputs cannot be loaded or parsedPipelineSerializationException
- if the output cannot be saved or serialized to the result locationLicenseException
- if there is a licensing issue that prevents operationPipelinedComparatorError
- if a comparator execution thread is interrupted by another threadComparisonCancelledException
- if a comparison is cancelled according to the CancellationPolicy
in forcepublic void compare(java.io.InputStream a, java.lang.String systemIdA, java.io.InputStream b, java.lang.String systemIdB, java.io.OutputStream result) throws ComparisonException, PipelineLoadingException, FilterProcessingException, PipelineSerializationException, LicenseException, PipelinedComparatorError, ComparisonCancelledException
CommonComparator
Compares the XML obtained from InputStream objects and uses an OutputStream to represent the pipeline result.
systemId parameters are provided so that relative URIs can be resolved in the inputs, they are also useful when reporting errors as the systemId may be useful when locating the error position. Using identifiers such as "string1" or "database2" may be useful when the inputs do not contain URIs to resolve as they can aid error diagnosis.
compare
in interface CommonComparator
a
- The InputStream from which the first input is readsystemIdA
- the SystemId used for resolving URIs and reporting errors associated with the A inputb
- The InputStream for the second inputsystemIdB
- the SystemId used for resolving URIs and reporting errors associated with the B inputresult
- where the pipeline result will be writtenComparisonException
- if there is a problem during the comparison processingPipelineLoadingException
- if the inputs cannot be loaded or parsedFilterProcessingException
- if there was a problem running any of the filtersPipelineSerializationException
- if the output cannot be saved or serialized to the result locationLicenseException
- if there is a licensing issue that prevents operationPipelinedComparatorError
- if a comparator execution thread is interrupted by another threadComparisonCancelledException
- if a comparison is cancelled according to the CancellationPolicy
in forcepublic void compare(java.lang.String a, java.lang.String systemIdA, java.lang.String b, java.lang.String systemIdB, java.lang.StringBuilder result) throws ComparisonException, PipelineLoadingException, FilterProcessingException, PipelineSerializationException, LicenseException, PipelinedComparatorError, ComparisonCancelledException
CommonComparator
Compares the XML obtained from Strings and uses a StringBuilder to represent the pipeline result.
systemId parameters are provided so that relative URIs can be resolved in the inputs, they are also useful when reporting errors as the systemId may be useful when locating the error position. Using identifiers such as "string1" or "database2" may be useful when the inputs do not contain URIs to resolve as they can aid error diagnosis.
compare
in interface CommonComparator
a
- The String from which the first input is readsystemIdA
- the SystemId used for resolving URIs and reporting errors associated with the A inputb
- The String for the second inputsystemIdB
- the SystemId used for resolving URIs and reporting errors associated with the B inputresult
- where the pipeline result will be writtenComparisonException
- if there is a problem during the comparison processingPipelineLoadingException
- if the inputs cannot be loaded or parsedFilterProcessingException
- if there was a problem running any of the filtersPipelineSerializationException
- if the output cannot be saved or serialized to the result locationLicenseException
- if there is a licensing issue that prevents operationPipelinedComparatorError
- if a comparator execution thread is interrupted by another threadComparisonCancelledException
- if a comparison is cancelled according to the CancellationPolicy
in forcepublic void compare(java.net.URL a, java.net.URL b, java.io.File result) throws ComparisonException, PipelineLoadingException, FilterProcessingException, PipelineSerializationException, java.io.FileNotFoundException, LicenseException, PipelinedComparatorError, ComparisonCancelledException
CommonComparator
Compares the XML obtained from URLs and writes the pipeline result to a File.
compare
in interface CommonComparator
a
- The URL from which the first input is loadedb
- The URL for the second inputresult
- where the pipeline result will be writtenComparisonException
- if there is a problem during the comparison processingPipelineLoadingException
- if the inputs cannot be loaded or parsedFilterProcessingException
- if there was a problem running any of the filtersPipelineSerializationException
- if the output cannot be saved or serialized to the result locationjava.io.FileNotFoundException
- if the output file location cannot be foundLicenseException
- if there is a licensing issue that prevents operationPipelinedComparatorError
- if a comparator execution thread is interrupted by another threadComparisonCancelledException
- if a comparison is cancelled according to the CancellationPolicy
in forcepublic void compare(java.net.URL a, java.net.URL b, java.io.OutputStream result) throws ComparisonException, PipelineLoadingException, FilterProcessingException, PipelineSerializationException, LicenseException, PipelinedComparatorError, ComparisonCancelledException
CommonComparator
Compares the XML obtained from URLs and writes the pipeline result to an OutputStream.
compare
in interface CommonComparator
a
- The URL from which the first input is loadedb
- The URL for the second inputresult
- where the pipeline result will be writtenComparisonException
- if there is a problem during the comparison processingPipelineLoadingException
- if the inputs cannot be loaded or parsedFilterProcessingException
- if there was a problem running any of the filtersPipelineSerializationException
- if the input cannot be saved or serialized to the result locationLicenseException
- if there is a licensing issue that prevents operationPipelinedComparatorError
- if a comparator execution thread is interrupted by another threadComparisonCancelledException
- if a comparison is cancelled according to the CancellationPolicy
in forcepublic void compare(org.xml.sax.InputSource a, org.xml.sax.InputSource b, javax.xml.transform.stream.StreamResult result) throws ComparisonException, PipelineLoadingException, FilterProcessingException, PipelineSerializationException, LicenseException, PipelinedComparatorError, ComparisonCancelledException
CommonComparator
Compares the XML obtained from InputSource Objects and writes the pipeline result to a StreamResult.
It is recommended that systemIds be associated with the InputSource parameters so that relative URIs and external entities can be resolved.
compare
in interface CommonComparator
a
- The InputSource from which the first input is loadedb
- The InputSource for the second inputresult
- where the pipeline result will be writtenComparisonException
- if their is a problem during the comparison stage of the pipelinePipelineLoadingException
- if the inputs cannot be loaded or parsedFilterProcessingException
- if there was a problem running any of the filtersPipelineSerializationException
- if the output cannot be saved or serialized to the result locationLicenseException
- if there is a licensing issue that prevents operationPipelinedComparatorError
- if a comparator execution thread is interrupted by another threadComparisonCancelledException
- if a comparison is cancelled according to the CancellationPolicy
in forcepublic net.sf.saxon.s9api.XdmNode compare(net.sf.saxon.s9api.XdmNode a, net.sf.saxon.s9api.XdmNode b) throws FilterProcessingException, ComparisonException, LicenseException, java.lang.IllegalArgumentException, PipelinedComparatorError, ComparisonCancelledException
CommonComparator
Compares two Saxon XdmNode trees and generates an XdmNode tree result from the pipeline.
XdmNode trees are associated with specific s9api Processors. This method should be used in conjunction with one of the class constructors which takes a Processor argument.
compare
in interface CommonComparator
a
- The first XdmNode input tree to be comparedb
- The second XdmNode inputFilterProcessingException
- if there is a problem executing the pipeline filtersComparisonException
- if there is a problem during the comparison processingLicenseException
- if there is a licensing issuejava.lang.IllegalArgumentException
- if the XdmNodes were produced by an unknown Saxon ProcessorPipelinedComparatorError
- if a comparator execution thread is interrupted by another threadComparisonCancelledException
- if a comparison is cancelled according to the CancellationPolicy
in forcepublic void addLicenseFile(java.io.File licenseFile) throws java.lang.SecurityException, java.io.IOException, LicenseException
CommonComparator
addLicenseFile
in interface CommonComparator
licenseFile
- the FlexLM format license filejava.lang.SecurityException
- if the file cannot be accessedjava.io.IOException
- if there are problems reading the fileLicenseException
- if there is a problem using the license filepublic void addLicenseServer(java.lang.String hostname) throws LicenseException
CommonComparator
addLicenseServer
in interface CommonComparator
hostname
- the license server host or its ip addressLicenseException
- if there is a problem using the license serverpublic void addLicenseServer(java.lang.String hostname, int port) throws java.lang.IllegalArgumentException, LicenseException
CommonComparator
addLicenseServer
in interface CommonComparator
hostname
- the license server host or its ip addressport
- the port number on the license server for the lmgrdjava.lang.IllegalArgumentException
- if the port number is out of rangeLicenseException
- if there is a problem using the license serverpublic void addUsageListener(com.deltaxml.cores9api.common.usage.ComUsageListener ul)
public void removeUsageListener(com.deltaxml.cores9api.common.usage.ComUsageListener ul)
public void setComUsageReporter(boolean isReportingFromExternal, com.deltaxml.cores9api.common.usage.ComUsageReporter reporter, java.util.Map<java.lang.String,com.deltaxml.cores9api.common.usage.ComJobFile> inputJobFiles, java.util.Map<java.lang.String,java.lang.String> configuration)