com.topologi.diffx.config
Class DiffXConfig

java.lang.Object
  extended by com.topologi.diffx.config.DiffXConfig

public final class DiffXConfig
extends Object

The configuration to use with a DiffX operation.

This class acts as a container for a set of properties that can be applied to the main components of Diff-X such as the:

In order to produce the correct results, the configuration must be applied throughout the three steps of processing.

There is an illegal state in this configuration, if the the diffx is not namespace aware it cannot not report the differences in the prefixes. Therefore it is impossible to set both flags to false.

The set methods for those flags will ensure that this situation does not occur. The general rule is that the flag being set takes precedence.

Note that it simply mimics SAX2 which cannot have the features http://xml.org/sax/features/namespaces and http://xml.org/sax/features/namespace-prefixes both set to false.

Version:
10 May 2010
Author:
Christophe Lauret
See Also:
XMLRecorder, DiffXAlgorithm, DiffXFormatter

Constructor Summary
DiffXConfig()
          Creates a new configuration for Diff-X.
DiffXConfig(TextGranularity granularity)
          Creates a new configuration for Diff-X.
DiffXConfig(WhiteSpaceProcessing whitespace, TextGranularity granularity)
          Creates a new configuration for Diff-X.
 
Method Summary
 TextGranularity getGranularity()
          Returns the granularity of text diffing for this configuration.
 WhiteSpaceProcessing getWhiteSpaceProcessing()
          Returns the granularity of text diffing for this configuration.
 boolean isIgnoreWhiteSpace()
          Indicates whether the differences in white spaces should be ignored or not.
 boolean isNamespaceAware()
          Indicates whether the Diff-X takes namespaces into account.
 boolean isPreserveWhiteSpace()
          Indicates whether the white spaces are preserved or not.
 boolean isReportPrefixDifferences()
          Returns whether the differences in prefixes are reported.
 void setGranularity(TextGranularity granularity)
          Sets the granularity of text diffing for this configuration.
 void setIgnoreWhiteSpace(boolean ignore)
          Deprecated. use setWhiteSpaceProcessing instead
 void setNamespaceAware(boolean aware)
          Sets whether Diff-X should take namespaces into account.
 void setPreserveWhiteSpace(boolean preserve)
          Deprecated. use setWhiteSpaceProcessing instead
 void setReportPrefixDifferences(boolean report)
          Sets whether the Diff-X should report differences in prefixes.
 void setWhiteSpaceProcessing(WhiteSpaceProcessing whitespace)
          Sets the white space processing for this configuration.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DiffXConfig

public DiffXConfig()
Creates a new configuration for Diff-X.


DiffXConfig

public DiffXConfig(TextGranularity granularity)
Creates a new configuration for Diff-X.

Parameters:
granularity - The granularity of text diffing.

DiffXConfig

public DiffXConfig(WhiteSpaceProcessing whitespace,
                   TextGranularity granularity)
Creates a new configuration for Diff-X.

Parameters:
whitespace - How whitespace should be processed.
granularity - The granularity of text diffing.
Method Detail

setGranularity

public void setGranularity(TextGranularity granularity)
Sets the granularity of text diffing for this configuration.

Parameters:
granularity - the text granularity of text diffing for this configuration.

setWhiteSpaceProcessing

public void setWhiteSpaceProcessing(WhiteSpaceProcessing whitespace)
Sets the white space processing for this configuration.

Parameters:
whitespace - the white space processing for this configuration.

setNamespaceAware

public void setNamespaceAware(boolean aware)
Sets whether Diff-X should take namespaces into account.

It is more efficient to disable namespace processing when the XML to compare are not expected to use any namespace.

In order to avoid an illegal state, if this flag is set to false and the differences in prefixes will be automatically reported.

Parameters:
aware - true to preserve the white spaces; false otherwise.

setReportPrefixDifferences

public void setReportPrefixDifferences(boolean report)
Sets whether the Diff-X should report differences in prefixes.

In order to avoid an illegal state, if this flag is set to false and then the processor becomes namespace aware.

Parameters:
report - true to report differences in prefixes; false to ignore them.

isNamespaceAware

public boolean isNamespaceAware()
Indicates whether the Diff-X takes namespaces into account.

Returns:
true to preserve the white spaces; false otherwise.

isReportPrefixDifferences

public boolean isReportPrefixDifferences()
Returns whether the differences in prefixes are reported.

Returns:
true to report differences in prefixes; false to ignore them.

getGranularity

public TextGranularity getGranularity()
Returns the granularity of text diffing for this configuration.

Returns:
the text granularity of text diffing for this configuration.

getWhiteSpaceProcessing

public WhiteSpaceProcessing getWhiteSpaceProcessing()
Returns the granularity of text diffing for this configuration.

Returns:
the text granularity of text diffing for this configuration.

isIgnoreWhiteSpace

public boolean isIgnoreWhiteSpace()
Indicates whether the differences in white spaces should be ignored or not.

Returns:
true to ignore differences in white spaces; false otherwise.

isPreserveWhiteSpace

public boolean isPreserveWhiteSpace()
Indicates whether the white spaces are preserved or not.

Returns:
true to preserve the white spaces; false otherwise.

setIgnoreWhiteSpace

@Deprecated
public void setIgnoreWhiteSpace(boolean ignore)
Deprecated. use setWhiteSpaceProcessing instead

Sets whether the differences in white spaces should be ignored or not.

Parameters:
ignore - true to ignore differences in white spaces; false otherwise.

setPreserveWhiteSpace

@Deprecated
public void setPreserveWhiteSpace(boolean preserve)
Deprecated. use setWhiteSpaceProcessing instead

Sets whether the white spaces should be preserved or not.

Parameters:
preserve - true to preserve the white spaces; false otherwise.