Class SequentialMerge
- All Implemented Interfaces:
MergeBase
A sequential merge class which supports n-way merging of the sequentially edited DITA documents.
The term sequential describes a scenario in which the each of the versions added to the merge would be a derivative of the previous version. Such a merge would be 'non-concurrent'.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLicenseFile(File licenseFile) Adds the license file for use with Flexera licensing.voidaddLicenseServer(String hostname) Adds a license server for use with concurrent licensing.voidaddLicenseServer(String hostname, int port) Adds a license server and port for use with concurrent licensing.voidaddProgressListener(MergeProgressListener listener) Add a progress listener to the list of registered progress listeners.voidaddVersion(File file, String version) Adds a version with a File input.voidaddVersion(InputStream is, String systemId, String version) Adds a version with an input stream input.voidaddVersion(Reader r, String systemId, String version) Adds a version with a File input.voidaddVersion(URL url, String version) Adds a version with a URL input.voidRemove all currently registered progress listeners.voidextractAll(File file) Extracts the entire content of all added versions of the Merger to a File using the deltaV2 merge format.voidExtracts the entire content of all added versions of the Merger to a OutputStream using the deltaV2 merge format.voidextractAll(Writer w) Extracts the entire content of all added versions of the Merger to a Writer using the deltaV2 merge format.Returns the current configuration options for CALS table comparison.Returns the current state of the DitaMerge object.booleanGets whether the production of debug files is on or not.Get the current prefix used for debug result files.Reports the current mode.booleanStates whether modified elements containing text are split when the amount of unchanged text falls below 10%.Reports the current mode.Gets the explicitly set EntityResolver in use by the merger.getEntityResolver(boolean builtInResolver) Gets the EntityResolver in use by the merger.Reports the current setting of the format extraction priority list.Returns the currently used FormattingElementConfiguration object.Get the output type used for representing formatting elements in the output.Returns the current configuration options for HTML table comparison.Reports the result type setting for the Merger.Returns an immutable list of versions which have been added.booleanReports the state of the WordByWord setting.voidremoveProgressListener(MergeProgressListener listener) Remove a progress listener from the list of registered progress listeners.voidreset()Reverts the state of the merger to the point whereMergeCommon.setAncestor(java.io.File, String)can be used.voidSets the configuration options for CALS table comparison.voidsetDebugFiles(boolean debug) Enables the generation of intermediate pipeline debug files.voidsetDebugFilesPrefix(String prefix) Provides a prefix for debug result files.voidSets how Doctype declarations should be preserved.voidsetElementSplitting(boolean enabled) Sets whether modified elements containing text should be split when the amount of unchanged text falls below 10%.voidSets how Entity references should be preserved.voidsetEntityResolver(EntityResolver resolver, boolean fallbackToDefaultCatalogResolver) Sets the EntityResolver to use during the comparison.voidsetFormatExtractionPriorityList(List<String> priorityList) Merge operations represent overlapping hierarchies from the input documents by flattening and subsequently fragmenting formatting elements where necessary.voidsetFormattingElementsConfiguration(FormattingElementsConfiguration formattingElementsConfiguration) Provides various settings for specifying formatting elements.voidsetFormattingOutputType(FormattingOutputType formattingOutputType) Set the output type used for representing formatting elements in the output.voidSets the configuration options for HTML table comparison.voidsetIndent(boolean indent) Enables indentation of output using the serializer output indent property.voidSets the type of result which this Merger will produce.voidsetWordByWord(boolean wbwValue) Determines whether WordByWord filter is used.
-
Constructor Details
-
SequentialMerge
public SequentialMerge()Constructs a new SequentialMerge instance.
Default settings
After construction the SequentialMerge object will, by default, preserve Doctype information. The
DoctypePreservationMode.PRESERVE_WHEN_UNCHANGEDsetting is used unless configured with thesetDoctypePreservationMode(com.deltaxml.mergecommon.config.DoctypePreservationMode)method.Also, entity references will be preserved by default. The
EntityReferencePreservationMode.PRESERVE_REFERENCESsetting is used unless configured with thesetEntityReferencePreservationMode(com.deltaxml.mergecommon.config.EntityReferencePreservationMode)method.
-
-
Method Details
-
setResultType
Sets the type of result which this Merger will produce.- Parameters:
type- the desired result type
-
getResultType
Reports the result type setting for the Merger.- Returns:
- the current result type setting
-
setDebugFiles
public void setDebugFiles(boolean debug) Enables the generation of intermediate pipeline debug files.
- Specified by:
setDebugFilesin interfaceMergeBase- Parameters:
debug- when true debug files are generated
-
getDebugFiles
public boolean getDebugFiles()Gets whether the production of debug files is on or not.
- Specified by:
getDebugFilesin interfaceMergeBase- Returns:
- whether the production of debug files is on or not.
- See Also:
-
setDebugFilesPrefix
Provides a prefix for debug result files.
- Specified by:
setDebugFilesPrefixin interfaceMergeBase- Parameters:
prefix- The prefix that will be used for debug file names in subsequent merge operations- See Also:
-
getDebugFilesPrefix
Get the current prefix used for debug result files.- Specified by:
getDebugFilesPrefixin interfaceMergeBase- Returns:
- the current prefix used for debug result files.
- See Also:
-
setIndent
public void setIndent(boolean indent) Enables indentation of output using the serializer output indent property.
-
getEntityResolver
Gets the explicitly set EntityResolver in use by the merger.
- Specified by:
getEntityResolverin interfaceMergeBase- Returns:
- the explicitly set EntityResolver in use by the merger.
-
getEntityResolver
Gets the EntityResolver in use by the merger.
- Specified by:
getEntityResolverin interfaceMergeBase- Parameters:
builtInResolver- Whether to get the built in resolver (with any explicit enhancement), or just the explicitly set resolver.- Returns:
- the EntityResolver in use by the merger.
-
setEntityResolver
public void setEntityResolver(EntityResolver resolver, boolean fallbackToDefaultCatalogResolver) throws IllegalStateException Sets the EntityResolver to use during the comparison.
By default, the Apache Commons Resolver is used as an EntityResolver. If you wish to use a different one, set it up using this method. Note you can turn off the default catalog support by providing a
nullresolver and setting thefallbackToDefaultCatalogResolvertofalse.- Specified by:
setEntityResolverin interfaceMergeBase- Parameters:
resolver- The resolver to use. Using null removes an existing resolver.fallbackToDefaultCatalogResolver- Sets whether to use the inbuilt catalog resolver if the provided resolver fails to resolve the entity.- Throws:
IllegalStateException- Thrown if the merger object's state is not INITIAL or RESET.
-
reset
public void reset()Reverts the state of the merger to the point where
MergeCommon.setAncestor(java.io.File, String)can be used. This is useful if you want to perform a new merge with the same configuration settings.The merger has a state machine to control the proper ordering of setAncestor and addVersion methods. reset() is used to clear the ancestor and version state. After calling reset() a new ancestor should be provided.
It does not completely re-initialize a merger to the state it would have after calling the constructor, in particular settings for catalogs, entity resolvers and word by word are preserved through a reset method (methods are provided to change these settings, alternatively you can create a new merger object via the constructor).
-
getCurrentState
Returns the current state of the DitaMerge object. The state affects which methods can be validly be called, this is documented in the
SequentialMergeStateenum.- Returns:
- The current state of the DitaMerge object.
-
addVersion
public void addVersion(File file, String version) throws IllegalStateException, IllegalArgumentException, FileNotFoundException, DifferentRootElementException, InvalidInputException, com.deltaxml.licensing.LicenseException, UnorderedDuplicateKeysException, DifferingOrderedAttributesException, UnorderedElementContainingPCDATAException, ComparisonCancelledException Adds a version with a File input.The version parameter appears in the result file and must correspond to the NMTOKEN production rule in the XML Specification (the same production rule is used in both XML 1.0 and XML 1.1). This precludes the use of the '!' (0x21) and '=' (0x3d) characters used for version delimiting and other characters which could cause confusion such as the space character.
- Specified by:
addVersionin interfaceMergeBase- Parameters:
file- The input file which is the version to be added.version- The string to use as the name of the version. This appears in thedeltaxml:deltaV2attributes in the result. This cannot contain '=' or '!' characters.- Throws:
IllegalStateException- Thrown if the merge object's state is not STARTED or EXTRACTABLE.IllegalArgumentException- Thrown if the version parameter is not an NMTOKEN, if a version has already been added with this name, or if the supplied name is the same as the ancestor version.FileNotFoundException- Thrown if the provided file object does not exist.DifferentRootElementException- Thrown if the version added has a different root XML element as the ancestor.InvalidInputException- Thrown if the input is invalid.com.deltaxml.licensing.LicenseException- Thrown if there is no license installed, or if the installed license is invalid.UnorderedDuplicateKeysException- Thrown if there are duplicate keys in orderless merge.DifferingOrderedAttributesException- Thrown if inputs have different deltaxml:ordered attribute values.UnorderedElementContainingPCDATAException- Thrown if input contains mixed content in orderless merge.ComparisonCancelledException- See Also:
-
addVersion
public void addVersion(InputStream is, String systemId, String version) throws IllegalStateException, IllegalArgumentException, DifferentRootElementException, InvalidInputException, com.deltaxml.licensing.LicenseException, UnorderedDuplicateKeysException, DifferingOrderedAttributesException, UnorderedElementContainingPCDATAException, ComparisonCancelledException Adds a version with an input stream input.The version parameter appears in the result file and must correspond to the NMTOKEN production rule in the XML Specification (the same production rule is used in both XML 1.0 and XML 1.1). This precludes the use of the '!' (0x21) and '=' (0x3d) characters used for version delimiting and other characters which could cause confusion such as the space character.
- Specified by:
addVersionin interfaceMergeBase- Parameters:
is- The input stream which is the version to be added.systemId- The location of the version input stream (for relative lookup).version- The string to use as the name of the version. This appears in thedeltaxml:deltaV2attributes in the result. This cannot contain '=' or '!' characters.- Throws:
IllegalStateException- Thrown if the merge object's state is not STARTED or EXTRACTABLE.IllegalArgumentException- Thrown if the version parameter is not an NMTOKEN, if a version has already been added with this name, or if the supplied name is the same as the ancestor version.DifferentRootElementException- Thrown if the version added has a different root XML element as the ancestor.InvalidInputException- Thrown if the input is invalid.com.deltaxml.licensing.LicenseException- Thrown if there is no license installed, or if the installed license is invalid.UnorderedDuplicateKeysException- Thrown if there are duplicate keys in orderless merge.DifferingOrderedAttributesException- Thrown if inputs have different deltaxml:ordered attribute values.UnorderedElementContainingPCDATAException- Thrown if input contains mixed content in orderless merge.ComparisonCancelledException- See Also:
-
addVersion
public void addVersion(Reader r, String systemId, String version) throws IllegalStateException, IllegalArgumentException, InvalidInputException, DifferingOrderedAttributesException, com.deltaxml.licensing.LicenseException, UnorderedDuplicateKeysException, UnorderedElementContainingPCDATAException, ComparisonCancelledException, DifferentRootElementException Adds a version with a File input.The version parameter appears in the result file and must correspond to the NMTOKEN production rule in the XML Specification (the same production rule is used in both XML 1.0 and XML 1.1). This precludes the use of the '!' (0x21) and '=' (0x3d) characters used for version delimiting and other characters which could cause confusion such as the space character.
- Specified by:
addVersionin interfaceMergeBase- Parameters:
r- The input reader which is the version to be added.systemId- The location of the ancestor reader (for relative lookup).version- The string to use as the name of the version. This appears in thedeltaxml:deltaV2attributes in the result. This cannot contain '=' or '!' characters.- Throws:
IllegalStateException- Thrown if the merge object's state is not STARTED or EXTRACTABLE.IllegalArgumentException- Thrown if the version parameter is not an NMTOKEN, if a version has already been added with this name, or if the supplied name is the same as the ancestor version.InvalidInputException- Thrown if the input is invalid.DifferingOrderedAttributesException- Thrown if inputs have different deltaxml:ordered attribute values.com.deltaxml.licensing.LicenseException- Thrown if there is no license installed, or if the installed license is invalid.UnorderedDuplicateKeysException- Thrown if there are duplicate keys in orderless merge.UnorderedElementContainingPCDATAException- Thrown if input contains mixed content in orderless merge.ComparisonCancelledExceptionDifferentRootElementException- Thrown if the version added has a different root XML element as the ancestor.- See Also:
-
addVersion
public void addVersion(URL url, String version) throws IllegalStateException, IllegalArgumentException, IOException, InvalidInputException, com.deltaxml.licensing.LicenseException, UnorderedDuplicateKeysException, DifferingOrderedAttributesException, UnorderedElementContainingPCDATAException, ComparisonCancelledException, DifferentRootElementException Adds a version with a URL input.The version parameter appears in the result file and must correspond to the NMTOKEN production rule in the XML Specification (the same production rule is used in both XML 1.0 and XML 1.1). This precludes the use of the '!' (0x21) and '=' (0x3d) characters used for version delimiting and other characters which could cause confusion such as the space character.
- Specified by:
addVersionin interfaceMergeBase- Parameters:
url- The URL which is the version to be added.version- The string to use as the name of the version. This appears in thedeltaxml:deltaV2attributes in the result. This cannot contain '=' or '!' characters.- Throws:
IllegalStateException- Thrown if the merger object's state is not STARTED or EXTRACTABLE.IllegalArgumentException- Thrown if the version parameter is not an NMTOKEN, if a version has already been added with this name, or if the supplied name is the same as the ancestor version.IOException- Thrown if a stream for the supplied URL cannot be opened.InvalidInputException- Thrown if the input is invalid.com.deltaxml.licensing.LicenseException- Thrown if there is no license installed, or if the installed license is invalid.UnorderedDuplicateKeysException- Thrown if there are duplicate keys in orderless merge.DifferingOrderedAttributesException- Thrown if inputs have different deltaxml:ordered attribute values.UnorderedElementContainingPCDATAException- Thrown if input contains mixed content in orderless merge.ComparisonCancelledExceptionDifferentRootElementException- Thrown if the version added has a different root XML element as the ancestor.- See Also:
-
setWordByWord
Determines whether WordByWord filter is used.- Specified by:
setWordByWordin interfaceMergeBase- Parameters:
wbwValue- The new WordByWord setting to use.- Throws:
IllegalStateException- when this operation is not allowed according to the MergeState
-
getWordByWord
public boolean getWordByWord()Reports the state of the WordByWord setting.- Specified by:
getWordByWordin interfaceMergeBase- Returns:
- the current value
-
setDoctypePreservationMode
Sets how Doctype declarations should be preserved.Default Setting
The
DoctypePreservationMode.PRESERVE_WHEN_UNCHANGEDsetting is used by default.- Parameters:
mode- the new preservation mode
-
getDoctypePreservationMode
Reports the current mode.- Returns:
- the current mode
-
setEntityReferencePreservationMode
Sets how Entity references should be preserved.Default Setting
The
EntityReferencePreservationMode.PRESERVE_REFERENCESsetting is used by default.- Parameters:
mode- the new preservation mode- See Also:
-
getEntityReferencePreservationMode
Reports the current mode.- Returns:
- the current mode
-
extractAll
public void extractAll(File file) throws IllegalStateException, DoctypeChangeException, DoctypeMissingException, InvalidInputException, com.deltaxml.licensing.LicenseException Extracts the entire content of all added versions of the Merger to a File using the deltaV2 merge format.- Specified by:
extractAllin interfaceMergeBase- Parameters:
file- The file into which the deltaV2 content is extracted- Throws:
IllegalStateException- the Merger is not in a state ready for extractionDoctypeChangeException- when there are doctype changes and DoctypePreservationMode specifies that they are reportedDoctypeMissingException- when there are doctype is missing and DoctypePreservationMode specifies that they are reportedInvalidInputException- Thrown if the input is invalid in some way.com.deltaxml.licensing.LicenseException- if there are any problems with the supplied license or its use
-
extractAll
public void extractAll(Writer w) throws IllegalStateException, DoctypeChangeException, DoctypeMissingException, InvalidInputException, com.deltaxml.licensing.LicenseException Extracts the entire content of all added versions of the Merger to a Writer using the deltaV2 merge format.- Specified by:
extractAllin interfaceMergeBase- Parameters:
w- The writer into which the deltaV2 content is extracted- Throws:
IllegalStateException- the Merger is not in a state ready for extractionDoctypeChangeException- when there are doctype changes and DoctypePreservationMode specifies that they are reportedDoctypeMissingException- when there are doctype is missing and DoctypePreservationMode specifies that they are reportedInvalidInputException- Thrown if the input is invalid in some way.com.deltaxml.licensing.LicenseException- if there are any problems with the supplied license or its use
-
extractAll
public void extractAll(OutputStream os) throws IllegalStateException, DoctypeChangeException, DoctypeMissingException, InvalidInputException, com.deltaxml.licensing.LicenseException Extracts the entire content of all added versions of the Merger to a OutputStream using the deltaV2 merge format.- Specified by:
extractAllin interfaceMergeBase- Parameters:
os- The OutputStream into which the deltaV2 content is extracted- Throws:
IllegalStateException- the Merger is not in a state ready for extractionDoctypeChangeException- when there are doctype changes and DoctypePreservationMode specifies that they are reportedDoctypeMissingException- when there are doctype is missing and DoctypePreservationMode specifies that they are reportedInvalidInputException- Thrown if the input is invalid in some way.com.deltaxml.licensing.LicenseException- if there are any problems with the supplied license or its use
-
getVersions
Returns an immutable list of versions which have been added.- Specified by:
getVersionsin interfaceMergeBase- Returns:
- an immutable list of versions which have been added
-
addLicenseFile
public void addLicenseFile(File licenseFile) throws SecurityException, IOException, com.deltaxml.licensing.LicenseException Adds the license file for use with Flexera licensing. This can be either simple fixed host/user licensing, or a concurrent licensing containing the USE_SERVER directive- Specified by:
addLicenseFilein interfaceMergeBase- Parameters:
licenseFile- the FlexLM format license file- Throws:
SecurityException- if the file cannot be accessedIOException- if there are problems reading the filecom.deltaxml.licensing.LicenseException- if there is a problem using the license file
-
addLicenseServer
Adds a license server for use with concurrent licensing.- Specified by:
addLicenseServerin interfaceMergeBase- Parameters:
hostname- the license server host or its ip address- Throws:
com.deltaxml.licensing.LicenseException- if there is a problem using the license server
-
addLicenseServer
public void addLicenseServer(String hostname, int port) throws IllegalArgumentException, com.deltaxml.licensing.LicenseException Adds a license server and port for use with concurrent licensing.- Specified by:
addLicenseServerin interfaceMergeBase- Parameters:
hostname- the license server host or its ip addressport- the port number on the license server for the lmgrd- Throws:
IllegalArgumentException- if the port number is out of rangecom.deltaxml.licensing.LicenseException- if there is a problem using the license server
-
setCalsTableConfiguration
Sets the configuration options for CALS table comparison.
- Specified by:
setCalsTableConfigurationin interfaceMergeBase- Parameters:
config- aCalsTableConfigurationobject that contains the settings to use for CALS table comparison
-
getCalsTableConfiguration
Returns the current configuration options for CALS table comparison.
- Specified by:
getCalsTableConfigurationin interfaceMergeBase- Returns:
- a
CalsTableConfigurationobject that contains the settings to use for CALS table comparison
-
setHtmlTableConfiguration
Sets the configuration options for HTML table comparison.
- Specified by:
setHtmlTableConfigurationin interfaceMergeBase- Parameters:
config- aHtmlTableConfigurationobject that contains the settings to use for HTML table comparison
-
getHtmlTableConfiguration
Returns the current configuration options for HTML table comparison.
- Specified by:
getHtmlTableConfigurationin interfaceMergeBase- Returns:
- a
HtmlTableConfigurationobject that contains the settings to use for HTML table comparison
-
addProgressListener
Add a progress listener to the list of registered progress listeners. It is possible to add the same listener multiple times.- Specified by:
addProgressListenerin interfaceMergeBase- Parameters:
listener- the progress listener to register.
-
removeProgressListener
Remove a progress listener from the list of registered progress listeners. This will remove the first occurrence of a progress listener.- Specified by:
removeProgressListenerin interfaceMergeBase- Parameters:
listener- the progress listener to remove.
-
clearProgressListeners
public void clearProgressListeners()Remove all currently registered progress listeners.- Specified by:
clearProgressListenersin interfaceMergeBase
-
setElementSplitting
Sets whether modified elements containing text should be split when the amount of unchanged text falls below 10%.
Note that element splitting does not happen when the WordByWord setting is 'false'.
Default:
trueCertain DITA elements such as a section, title are only permitted once in the DITA DTD. Therefore, the element splitting feature is not applied to such elements.
Element splitting is currently applied to following DITA elements.
DITA elements : apiname, b, cite, cmdname, codeph, filepath, i, li, lines, msgnum, msgph, note, p, parmname, pre, q, sli, sub, sup, systemoutput, term, text, tm, tt, u, uicontrol, userinput, var, varname, wintitle
- Specified by:
setElementSplittingin interfaceMergeBase- Parameters:
enabled- whether or not to enable element splitting- Throws:
IllegalStateException- when this operation is not allowed according to the MergeState
-
getElementSplitting
public boolean getElementSplitting()States whether modified elements containing text are split when the amount of unchanged text falls below 10%.
- Specified by:
getElementSplittingin interfaceMergeBase- Returns:
- a boolean stating whether the splitting behaviour is enabled or not
-
setFormattingElementsConfiguration
public void setFormattingElementsConfiguration(FormattingElementsConfiguration formattingElementsConfiguration) throws IllegalStateException, IllegalArgumentException Provides various settings for specifying formatting elements.- Parameters:
formattingElementsConfiguration- a FormattingElementsConfiguration object- Throws:
IllegalStateException- when this operation is not allowed according to the merge stateIllegalArgumentException- when FormattingElementsConfiguration is null
-
getFormattingElementsConfiguration
Returns the currently used FormattingElementConfiguration object.- Returns:
- the FormattingElementConfiguration object
-
setFormattingOutputType
Set the output type used for representing formatting elements in the output. The default is
FormattingOutputType.DELTA_V_2_1which represents Formatting Elements using our Delta v2.1 format.- Specified by:
setFormattingOutputTypein interfaceMergeBase- Parameters:
formattingOutputType- the type of representation to use.- See Also:
-
getFormattingOutputType
Get the output type used for representing formatting elements in the output.
- Specified by:
getFormattingOutputTypein interfaceMergeBase- Returns:
- the output type
- See Also:
-
setFormatExtractionPriorityList
Merge operations represent overlapping hierarchies from the input documents by flattening and subsequently fragmenting formatting elements where necessary.
To produce a result without overlapping or nesting of formatting elements, it may be necessary to remove formatting information in a controlled way.
The format extraction priority list specifies the list of versions by priority. This priority list will be used to extract formatting to resolve overlaps and nesting to produce a deltaV2 result.
Please note that if only some, not all, of the versions are specified in the priority list there is a possibility of format loss due to additions/deletions of formatting by the missing version(s).
- Specified by:
setFormatExtractionPriorityListin interfaceMergeBase- Parameters:
priorityList- a list of priority versions specified using Strings
-
getFormatExtractionPriorityList
Reports the current setting of the format extraction priority list.- Specified by:
getFormatExtractionPriorityListin interfaceMergeBase- Returns:
- the current list of priority versions
-