All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.topologi.diffx.config.DiffXConfig Maven / Gradle / Ivy

Go to download

docx4j is a library which helps you to work with the Office Open XML file format as used in docx documents, pptx presentations, and xlsx spreadsheets.

There is a newer version: 6.1.2
Show newest version
package com.topologi.diffx.config;

/**
 * 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 Diffx such as the: *

    *
  • The {@link com.topologi.diffx.load.XMLRecorder} implementations,
  • *
  • The {@link com.topologi.diffx.algorithm.DiffXAlgorithm} implementations,
  • *
  • and the {@link com.topologi.diffx.format.DiffXFormatter} implementations.
  • *
* *

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. * * @see com.topologi.diffx.load.XMLRecorder * @see com.topologi.diffx.algorithm.DiffXAlgorithm * @see com.topologi.diffx.format.DiffXFormatter * * @author Christophe Lauret * @version 15 April 2004 */ public final class DiffXConfig { // class attributes --------------------------------------------------------------------------- /** * Indicates whether the differences in white spaces should be ignored. */ private boolean ignoreWhiteSpace = true; //changed /** * Indicates whether the white spaces should be preserved. */ private boolean preserveWhiteSpace = true; /** * Indicates whether the namespaces should be handled or ignored. */ private boolean isNamespaceAware = true; /** * Indicates whether difference in prefixes should be reported. */ private boolean reportPrefixDifferences = false; /** * Whether to tokenize on sentences or entire text blocks */ private boolean tokenizeSentences = false; private boolean tokenizeBlocks = false; // class attributes --------------------------------------------------------------------------- /** * Creates a new configuration for DiffX */ public DiffXConfig() { } // methods ------------------------------------------------------------------------------------ /** * Sets whether the differences in white spaces should be ignored or not. * * @param ignore true to ignore differences in white spaces; * false otherwise. */ public void setIgnoreWhiteSpace(boolean ignore) { this.ignoreWhiteSpace = ignore; } /** * Sets whether the white spaces should be preserved or not. * * @param preserve true to preserve the white spaces; * false otherwise. */ public void setPreserveWhiteSpace(boolean preserve) { this.preserveWhiteSpace = preserve; } /** * Sets whether the 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. * * @param aware true to preserve the white spaces; * false otherwise. */ public void setNamespaceAware(boolean aware) { this.isNamespaceAware = aware; if (!aware) this.reportPrefixDifferences = true; } /** * 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. * * @param report true to report differences in prefixes; * false to ignore them. */ public void setReportPrefixDifferences(boolean report) { this.reportPrefixDifferences = report; if (!report) this.isNamespaceAware = true; } public void setTokenizeBlocks(boolean tokenizeBlocks) { this.tokenizeBlocks = tokenizeBlocks; } public void setTokenizeSentences(boolean tokenizeSentences) { this.tokenizeSentences = tokenizeSentences; } /** * Indicates whether the differences in white spaces should be ignored or not. * * @return true to ignore differences in white spaces; * false otherwise. */ public boolean isIgnoreWhiteSpace() { return this.ignoreWhiteSpace; } /** * Indicates whether the white spaces are preserved or not. * * @return true to preserve the white spaces; * false otherwise. */ public boolean isPreserveWhiteSpace() { return this.preserveWhiteSpace; } /** * Indicates whether the Diff-X takes namespaces into account. * * @return true to preserve the white spaces; * false otherwise. */ public boolean isNamespaceAware() { return this.isNamespaceAware; } /** * Returns whether the differences in prefixes are reported. * * @return true to report differences in prefixes; * false to ignore them. */ public boolean isReportPrefixDifferences() { return this.reportPrefixDifferences; } public boolean isTokenizeSentences() { return tokenizeSentences; } public boolean isTokenizeBlocks() { return tokenizeBlocks; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy