Package ro.sync.diff.api
Class DiffOptions
java.lang.Object
ro.sync.diff.api.DiffOptions
Holds options needed to decide which diff algorithm and which diff options
will be used.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe algorithm is automatically chosen based on content type, text length, options etc.static final intAlgorithm based on characters comparison.static final intAlgorithm based on line by line comparison.static final intAlgorithm based on comparing the syntax tokens.static final intAlgorithm based on words comparison.static final intXML accurate diff based on Sasha and Zhang algorithm.static final intFast XML hybrid heuristic algorithm. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor for default options.DiffOptions(int algorithm, boolean ignoreWhitespaces, int maxNumberOfDiffs, boolean ignorePI, boolean ignoreComments, boolean ignoreCDATA, boolean ignoreDOCTYPE, boolean ignoreText, boolean ignoreAttributesOrder, boolean ignorePrefixes, boolean ignoreNamespaces, boolean ignoreNamespaceDeclarations, boolean ignoreEntities, boolean mergeAdjacentDifferences, boolean markEndTagsAsDifferent, boolean ignoreStateOfEmptyElements) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionintGet the default XPath that will be used to ignore nodes from comparison it no XPath is specified in XPath combo from DIFF Files toolbar.intbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanCheck if the default XPath should be used to ignore nodes from comparison if no XPath is specified in XPath combo from DIFF Files toolbarbooleanbooleanbooleanbooleanbooleanbooleanbooleanvoidsetAlgorithm(int algorithm) voidsetDefaultXPath(String defaultXPath) Set default XPath that will be used to ignore nodes from comparison it no XPath is specified in XPath combo from DIFF Files toolbar.voidsetEnableHierarchicalDiff(boolean enableHierarchicalDiff) Enable or disable hierarchical diff.voidsetIgnoreAttributesOrder(boolean ignoreAttributesOrder) voidsetIgnoreCDATA(boolean ignoreCDATA) voidsetIgnoreComments(boolean ignoreComments) voidsetIgnoreDOCTYPE(boolean ignoreDOCTYPE) voidsetIgnoreEntities(boolean ignoreEntities) voidsetIgnoreNamespaceDeclarations(boolean ignoreNamespaceDeclarations) voidsetIgnoreNamespaces(boolean ignoreNamespaces) voidsetIgnoreNodesByXPath(boolean ignoreNodesByXPath) Set if the default XPath should be used to ignore nodes from comparison if no XPath is specified in XPath combo from DIFF Files toolbarvoidsetIgnorePI(boolean ignorePI) voidsetIgnorePrefixes(boolean ignorePrefixes) voidsetIgnoreStateOfEmptyElements(boolean ignoreStateOfEmptyElements) voidsetIgnoreText(boolean ignoreText) voidsetIgnoreWhitespaces(boolean ignoreWhitespaces) voidsetMarkEndTagsAsDifferent(boolean markEndTagsAsDifferent) voidsetMaxNumberOfDiffs(int maxNumberOfDiffs) voidsetMergeAdjacentDifferences(boolean mergeAdjacentDifferences)
-
Field Details
-
AUTO
public static final int AUTOThe algorithm is automatically chosen based on content type, text length, options etc.- See Also:
-
CHARACTERS_COMPARE
public static final int CHARACTERS_COMPAREAlgorithm based on characters comparison.- See Also:
-
WORDS_COMPARE
public static final int WORDS_COMPAREAlgorithm based on words comparison.- See Also:
-
LINES_COMPARE
public static final int LINES_COMPAREAlgorithm based on line by line comparison.- See Also:
-
SYNTAX_AWARE
public static final int SYNTAX_AWAREAlgorithm based on comparing the syntax tokens.- See Also:
-
XML_FAST
public static final int XML_FASTFast XML hybrid heuristic algorithm.- See Also:
-
XML_ACCURATE
public static final int XML_ACCURATEXML accurate diff based on Sasha and Zhang algorithm.- See Also:
-
-
Constructor Details
-
DiffOptions
public DiffOptions(int algorithm, boolean ignoreWhitespaces, int maxNumberOfDiffs, boolean ignorePI, boolean ignoreComments, boolean ignoreCDATA, boolean ignoreDOCTYPE, boolean ignoreText, boolean ignoreAttributesOrder, boolean ignorePrefixes, boolean ignoreNamespaces, boolean ignoreNamespaceDeclarations, boolean ignoreEntities, boolean mergeAdjacentDifferences, boolean markEndTagsAsDifferent, boolean ignoreStateOfEmptyElements) Constructor.- Parameters:
algorithm- The used algorithm, one of the constants:ignoreWhitespaces-trueif differences consisting only in whitespaces should be ignored.maxNumberOfDiffs- The maximum number of modifications you are interested in. If the document contain a larger number of differences the diff will only signal that they are different and stop after reaching the limit.ignorePI-trueif processing instructions should be ignored. It applies when using XML aware algorithms.ignoreComments-trueif comments should be ignored. It applies when using XML aware algorithms.ignoreCDATA-trueif CDATA sections should be ignored. It applies when using XML aware algorithms.ignoreDOCTYPE-trueif DOCTYPE sections should be ignored. It applies when using XML aware algorithms.ignoreText-trueif differences in the text content should be ignored. It applies when using XML aware algorithms.ignoreAttributesOrder-trueif the order of the attributes should be ignored. It applies when using XML aware algorithms.ignorePrefixes-trueif the prefixes should be ignored. Even if this is set the comparing takes into account the namespacea. It applies when using XML aware algorithms.ignoreNamespaces-trueif namespaces should be ignored. It applies when using XML aware algorithms.ignoreNamespaceDeclarations-trueif the namespace declaration ("xmlns" attributes) should be ignored. It applies when using XML aware algorithms.ignoreEntities-trueif entity content should be ignored. It applies when using XML aware algorithms.mergeAdjacentDifferences-trueif adjacent differences should be merged and present as a single difference. Applies when using XML aware algorithms.markEndTagsAsDifferent-trueif end tags with the same name for elements that are different in other sense will be shown as different also. It applies when using XML aware algorithms.ignoreStateOfEmptyElements-trueif sequences representing empty elements like<a/> and <a></a>
will be considered identical. It applies when using XML aware algorithms.
-
DiffOptions
public DiffOptions()Default constructor for default options.
-
-
Method Details
-
getAlgorithm
public int getAlgorithm()- Returns:
- Returns The used algorithm, one of the constants:
-
setAlgorithm
public void setAlgorithm(int algorithm) - Parameters:
algorithm- The algorithm to use, one of the constants:
-
getMaxNumberOfDiffs
public int getMaxNumberOfDiffs()- Returns:
- Returns The maximum number of modifications you are interested in. If the document contain a larger number of differences the diff will only signal that they are different and stop after reaching the limit.
-
setMaxNumberOfDiffs
public void setMaxNumberOfDiffs(int maxNumberOfDiffs) - Parameters:
maxNumberOfDiffs- The maximum number of modifications you are interested in. If the document contain a larger number of differences the diff will only signal that they are different and stop after reaching the limit.
-
isIgnoreWhitespaces
public boolean isIgnoreWhitespaces()- Returns:
- Returns
trueif differences consisting only in whitespaces will be ignored.
-
setIgnoreWhitespaces
public void setIgnoreWhitespaces(boolean ignoreWhitespaces) - Parameters:
ignoreWhitespaces-trueif differences consisting only in whitespaces should be ignored.
-
isIgnorePI
public boolean isIgnorePI()- Returns:
- Returns
trueif processing instructions are ignored. It applies when using XML aware algorithms.
-
setIgnorePI
public void setIgnorePI(boolean ignorePI) - Parameters:
ignorePI-trueif processing instructions should be ignored. It applies when using XML aware algorithms.
-
isIgnoreComments
public boolean isIgnoreComments()- Returns:
- Returns
trueif comments are be ignored. It applies when using XML aware algorithms.
-
setIgnoreComments
public void setIgnoreComments(boolean ignoreComments) - Parameters:
ignoreComments-trueif comments should be ignored. It applies when using XML aware algorithms.
-
isIgnoreCDATA
public boolean isIgnoreCDATA()- Returns:
- Returns
trueif CDATA sections are ignored. It applies when using XML aware algorithms.
-
setIgnoreCDATA
public void setIgnoreCDATA(boolean ignoreCDATA) - Parameters:
ignoreCDATA-trueif CDATA sections should be ignored. It applies when using XML aware algorithms.
-
isIgnoreDOCTYPE
public boolean isIgnoreDOCTYPE()- Returns:
- Returns
trueif DOCTYPE sections are ignored. It applies when using XML aware algorithms.
-
setIgnoreDOCTYPE
public void setIgnoreDOCTYPE(boolean ignoreDOCTYPE) - Parameters:
ignoreDOCTYPE-trueif DOCTYPE sections should be ignored. It applies when using XML aware algorithms.
-
isIgnoreText
public boolean isIgnoreText()- Returns:
- Returns
trueif differences in the text content is ignored. It applies when using XML aware algorithms.
-
setIgnoreText
public void setIgnoreText(boolean ignoreText) - Parameters:
ignoreText-trueif differences in the text content should be ignored. It applies when using XML aware algorithms.
-
isIgnoreAttributesOrder
public boolean isIgnoreAttributesOrder()- Returns:
- Returns
trueif the order of the attributes is ignored. It applies when using XML aware algorithms.
-
setIgnoreAttributesOrder
public void setIgnoreAttributesOrder(boolean ignoreAttributesOrder) - Parameters:
ignoreAttributesOrder-trueif the order of the attributes should be ignored. It applies when using XML aware algorithms.
-
isIgnorePrefixes
public boolean isIgnorePrefixes()- Returns:
- Returns
trueif the prefixes are ignored. Even if this is set the comparing takes into account the namespaces. It applies when using XML aware algorithms.
-
setIgnorePrefixes
public void setIgnorePrefixes(boolean ignorePrefixes) - Parameters:
ignorePrefixes-trueif the prefixes should be ignored. Even if this is set the comparing takes into account the namespaces. It applies when using XML aware algorithms.
-
isIgnoreNamespaces
public boolean isIgnoreNamespaces()- Returns:
- Returns
trueif namespaces are ignored. It applies when using XML aware algorithms.
-
setIgnoreNamespaces
public void setIgnoreNamespaces(boolean ignoreNamespaces) - Parameters:
ignoreNamespaces-trueif namespaces should be ignored. It applies when using XML aware algorithms.
-
isIgnoreNamespaceDeclarations
public boolean isIgnoreNamespaceDeclarations()- Returns:
- Returns
trueif the namespace declarations ("xmlns" attributes) are ignored. It applies when using XML aware algorithms.
-
setIgnoreNamespaceDeclarations
public void setIgnoreNamespaceDeclarations(boolean ignoreNamespaceDeclarations) - Parameters:
ignoreNamespaceDeclarations-trueif the namespace declarations ("xmlns" attributes) should be ignored. It applies when using XML aware algorithms.
-
isIgnoreEntities
public boolean isIgnoreEntities()- Returns:
- Returns
trueif entity content is ignored. It applies when using XML aware algorithms.
-
setIgnoreEntities
public void setIgnoreEntities(boolean ignoreEntities) - Parameters:
ignoreEntities-trueif entity content should be ignored. It applies when using XML aware algorithms.
-
isIgnoreStateOfEmptyElements
public boolean isIgnoreStateOfEmptyElements()- Returns:
- Returns
trueif sequences representing empty elements like<a/> and <a></a>
are considered identical. It applies when using XML aware algorithms.
-
setIgnoreStateOfEmptyElements
public void setIgnoreStateOfEmptyElements(boolean ignoreStateOfEmptyElements) - Parameters:
ignoreStateOfEmptyElements-trueif sequences representing empty elements like<a/> and <a></a>
will be considered identical. It applies when using XML aware algorithms.
-
isMergeAdjacentDifferences
public boolean isMergeAdjacentDifferences()- Returns:
- Returns
trueif adjacent differences are merged and present as a single difference. It applies when using XML aware algorithms.
-
setMergeAdjacentDifferences
public void setMergeAdjacentDifferences(boolean mergeAdjacentDifferences) - Parameters:
mergeAdjacentDifferences-trueif adjacent differences should be merged and present as a single difference. It applies when using XML aware algorithms.
-
isMarkEndTagsAsDifferent
public boolean isMarkEndTagsAsDifferent()- Returns:
- Returns
trueif end tags with the same name for elements that are different in other sense are shown as different also. It applies when using XML aware algorithms.
-
setMarkEndTagsAsDifferent
public void setMarkEndTagsAsDifferent(boolean markEndTagsAsDifferent) - Parameters:
markEndTagsAsDifferent-trueif end tags with the same name for elements that are different in other sense will be shown as different also. It applies when using XML aware algorithms.
-
isIgnoreNodesByXPath
public boolean isIgnoreNodesByXPath()Check if the default XPath should be used to ignore nodes from comparison if no XPath is specified in XPath combo from DIFF Files toolbar- Returns:
trueif the default XPath expression should be used to ignore nodes from comparison if no other XPath is specified in XPath combo from DIFF Files toolbar
-
setIgnoreNodesByXPath
public void setIgnoreNodesByXPath(boolean ignoreNodesByXPath) Set if the default XPath should be used to ignore nodes from comparison if no XPath is specified in XPath combo from DIFF Files toolbar- Parameters:
ignoreNodesByXPath-trueto use the default XPath should be used to ignore nodes from comparison if no XPath is specified in XPath combo from DIFF Files toolbar
-
getDefaultXPath
Get the default XPath that will be used to ignore nodes from comparison it no XPath is specified in XPath combo from DIFF Files toolbar.- Returns:
- The default XPath that will be used to ignore nodes from comparison it no XPath is specified in XPath combo from DIFF Files toolbar.
-
setDefaultXPath
Set default XPath that will be used to ignore nodes from comparison it no XPath is specified in XPath combo from DIFF Files toolbar.- Parameters:
defaultXPath- The default XPath that will be used to ignore nodes from comparison it no XPath is specified in XPath combo from DIFF Files toolbar.
-
setEnableHierarchicalDiff
public void setEnableHierarchicalDiff(boolean enableHierarchicalDiff) Enable or disable hierarchical diff.- Parameters:
enableHierarchicalDiff- Iftruedifferences from the same line or adjacent lines will be grouped and added in a parent difference. Iffalse, no parent difference will be set for the created differences.
-
isEnableHierarchicalDiff
public boolean isEnableHierarchicalDiff()- Returns:
- Returns
trueif differences from the same line or adjacent lines will be grouped and added in a parent difference.false, if no parent difference will be set for the created differences. This option is available only for Text difference performer.
-