Comparer

Inheritance: java.lang.Object

All Implemented Interfaces: com.aspose.ms.System.IDisposable, java.io.Closeable

public class Comparer implements System.IDisposable, Closeable

Represents main class that controls the documents comparison process.

Constructors

Constructor Description
Comparer(String filePath) Initializes new instance of Comparer class with source file path.
Comparer(Path filePath) Initializes new instance of Comparer class with source file path.
Comparer(String filePath, LoadOptions loadOptions) Initializes new instance of Comparer with source file path and LoadOptions.
Comparer(Path filePath, LoadOptions loadOptions) Initializes new instance of Comparer with source file path and LoadOptions.
Comparer(String filePath, LoadOptions loadOptions, ComparerSettings settings) Initializes new instance of Comparer class with source file path, LoadOptions and ComparerSettings.
Comparer(String filePath, ComparerSettings settings) Initializes new instance of Comparer class with source file path and ComparerSettings.
Comparer(Path filePath, ComparerSettings settings) Initializes new instance of Comparer class with source file path and ComparerSettings.
Comparer(Path filePath, LoadOptions loadOptions, ComparerSettings settings) Initializes new instance of Comparer class with source file path, LoadOptions and ComparerSettings.
Comparer(InputStream document) Initializes new instance of Comparer class with source document stream.
Comparer(InputStream document, LoadOptions loadOptions) Initializes new instance of Comparer with source document stream and LoadOptions.
Comparer(InputStream document, ComparerSettings settings) Initializes new instance of Comparer class with source document stream and ComparerSettings.
Comparer(InputStream document, LoadOptions loadOptions, ComparerSettings settings) Initializes new instance of Comparer class with document stream, LoadOptions and ComparerSettings.
Comparer(ComparerSettings settings) Instantiates a new Comparer.

Fields

Field Description
FILE_PATH

Methods

Method Description
getSource() Source file that is being compared.
getTargets() List of target files to compare with source file.
compare() Compares documents without saving result with default options
compare(String filePath) Compares documents and saves result to file path
compare(Path filePath) Compares documents and saves result to file path
compare(OutputStream outputStream) Compares documents and saves result to file stream
compare(String filePath, CompareOptions compareOptions) Compares documents and saves result to file path
compare(Path filePath, CompareOptions compareOptions) Compares documents and saves result to file path
compare(OutputStream document, CompareOptions compareOptions) Compares documents and saves result to file stream
compare(SaveOptions saveOptions, CompareOptions compareOptions) Compares documents without saving result.
compare(String filePath, SaveOptions saveOptions) Compares documents and save result to file path
compare(Path filePath, SaveOptions saveOptions) Compares documents and save result to file path
compare(OutputStream document, SaveOptions saveOptions) Compares documents and save result to file stream
compare(CompareOptions compareOptions) Compares documents without saving result.
compare(OutputStream outputStream, SaveOptions saveOptions, CompareOptions compareOptions) Compares documents and saves result to a stream.
compare(String filePath, SaveOptions saveOptions, CompareOptions compareOptions) Compares documents and saves result to file path
compare(Path filePath, SaveOptions saveOptions, CompareOptions compareOptions) Compares documents and saves result to file path
add(String filePath) Adds file to comparison.
add(Path filePath) Adds file to comparison.
add(String[] filePaths) Adds file to comparison.
add(Path[] filePaths) Adds file to comparison.
add(String filePath, LoadOptions loadOptions) Adds file to comparison with loading options specified.
add(Path filePath, LoadOptions loadOptions) Adds file to comparison with loading options specified.
add(InputStream document) Adds document stream to comparison.
add(InputStream[] documents) Adds document stream to comparison.
add(InputStream document, LoadOptions loadOptions) Adds document stream to comparison with loading options specified.
getChanges() Gets list of changes between source and target file(s).
getChanges(GetChangeOptions getChangeOptions) Gets list of changes between source and target file(s).
applyChanges(String filePath, ApplyChangeOptions applyChangeOptions) Accepts or rejects changes and applies them to resultant document.
applyChanges(Path filePath, ApplyChangeOptions applyChangeOptions) Accepts or rejects changes and applies them to resultant document.
applyChanges(OutputStream document, ApplyChangeOptions applyChangeOptions) Accepts or rejects changes and applies them to resultant document.
applyChanges(String filePath, SaveOptions saveOptions, ApplyChangeOptions applyChangeOptions) Accepts or rejects changes and applies them to resultant document.
applyChanges(Path filePath, SaveOptions saveOptions, ApplyChangeOptions applyChangeOptions) Accepts or rejects changes and applies them to resultant document.
applyChanges(OutputStream document, SaveOptions saveOptions, ApplyChangeOptions applyChangeOptions) Accepts or rejects changes and applies them to resultant document.
getResultString() Get result string after comparison (For Text Comparison only).
close()
dispose() Releases resources.

Comparer(String filePath)

public Comparer(String filePath)

Initializes new instance of Comparer class with source file path.

Parameters:

Parameter Type Description
filePath java.lang.String File path

Comparer(Path filePath)

public Comparer(Path filePath)

Initializes new instance of Comparer class with source file path.

Parameters:

Parameter Type Description
filePath java.nio.file.Path File path

Comparer(String filePath, LoadOptions loadOptions)

public Comparer(String filePath, LoadOptions loadOptions)

Initializes new instance of Comparer with source file path and LoadOptions.

Parameters:

Parameter Type Description
filePath java.lang.String File path
loadOptions LoadOptions Load options

Comparer(Path filePath, LoadOptions loadOptions)

public Comparer(Path filePath, LoadOptions loadOptions)

Initializes new instance of Comparer with source file path and LoadOptions.

Parameters:

Parameter Type Description
filePath java.nio.file.Path File path
loadOptions LoadOptions Load options

Comparer(String filePath, LoadOptions loadOptions, ComparerSettings settings)

public Comparer(String filePath, LoadOptions loadOptions, ComparerSettings settings)

Initializes new instance of Comparer class with source file path, LoadOptions and ComparerSettings.

Parameters:

Parameter Type Description
filePath java.lang.String File path
loadOptions LoadOptions Load options
settings ComparerSettings Settings for comparison

Comparer(String filePath, ComparerSettings settings)

public Comparer(String filePath, ComparerSettings settings)

Initializes new instance of Comparer class with source file path and ComparerSettings.

Parameters:

Parameter Type Description
filePath java.lang.String File pats
settings ComparerSettings Settings for comparison

Comparer(Path filePath, ComparerSettings settings)

public Comparer(Path filePath, ComparerSettings settings)

Initializes new instance of Comparer class with source file path and ComparerSettings.

Parameters:

Parameter Type Description
filePath java.nio.file.Path File pats
settings ComparerSettings Settings for comparison

Comparer(Path filePath, LoadOptions loadOptions, ComparerSettings settings)

public Comparer(Path filePath, LoadOptions loadOptions, ComparerSettings settings)

Initializes new instance of Comparer class with source file path, LoadOptions and ComparerSettings.

Parameters:

Parameter Type Description
filePath java.nio.file.Path File path
loadOptions LoadOptions Load options
settings ComparerSettings Settings for comparison

Comparer(InputStream document)

public Comparer(InputStream document)

Initializes new instance of Comparer class with source document stream.

Parameters:

Parameter Type Description
document java.io.InputStream Source document stream

Comparer(InputStream document, LoadOptions loadOptions)

public Comparer(InputStream document, LoadOptions loadOptions)

Initializes new instance of Comparer with source document stream and LoadOptions.

Parameters:

Parameter Type Description
document java.io.InputStream Source document stream
loadOptions LoadOptions Load options

Comparer(InputStream document, ComparerSettings settings)

public Comparer(InputStream document, ComparerSettings settings)

Initializes new instance of Comparer class with source document stream and ComparerSettings.

Parameters:

Parameter Type Description
document java.io.InputStream Source document stream
settings ComparerSettings Settings for comparison

Comparer(InputStream document, LoadOptions loadOptions, ComparerSettings settings)

public Comparer(InputStream document, LoadOptions loadOptions, ComparerSettings settings)

Initializes new instance of Comparer class with document stream, LoadOptions and ComparerSettings.

Parameters:

Parameter Type Description
document java.io.InputStream Source document stream
loadOptions LoadOptions Load options
settings ComparerSettings Settings for comparison

Comparer(ComparerSettings settings)

public Comparer(ComparerSettings settings)

Instantiates a new Comparer.

Parameters:

Parameter Type Description
settings ComparerSettings the settings

FILE_PATH

public static final String FILE_PATH

getSource()

public final Document getSource()

Source file that is being compared.

Returns: Document - the source

getTargets()

public final List<Document> getTargets()

List of target files to compare with source file.

Returns: java.util.List<com.groupdocs.comparison.Document> - the targets

compare()

public final Path compare()

Compares documents without saving result with default options

Returns: java.nio.file.Path - the path

compare(String filePath)

public final Path compare(String filePath)

Compares documents and saves result to file path

Parameters:

Parameter Type Description
filePath java.lang.String Result document path

Returns: java.nio.file.Path - result file path or null. In some situations it’s extension can be changed

compare(Path filePath)

public final Path compare(Path filePath)

Compares documents and saves result to file path

Parameters:

Parameter Type Description
filePath java.nio.file.Path Result document path

Returns: java.nio.file.Path - result file path, in some situations it’s extension can be changed

compare(OutputStream outputStream)

public final Path compare(OutputStream outputStream)

Compares documents and saves result to file stream

Note: In case return value is null, use data that was written into outputStream

Parameters:

Parameter Type Description
outputStream java.io.OutputStream Result document stream

Returns: java.nio.file.Path - result file path or null when data from outputStream must be used. In some situations result file’s extension can be changed

compare(String filePath, CompareOptions compareOptions)

public final Path compare(String filePath, CompareOptions compareOptions)

Compares documents and saves result to file path

Parameters:

Parameter Type Description
filePath java.lang.String Result document file path
compareOptions CompareOptions Compare options

Returns: java.nio.file.Path - result file path, in some situations it’s extension can be changed

compare(Path filePath, CompareOptions compareOptions)

public final Path compare(Path filePath, CompareOptions compareOptions)

Compares documents and saves result to file path

Parameters:

Parameter Type Description
filePath java.nio.file.Path Result document file path
compareOptions CompareOptions Compare options

Returns: java.nio.file.Path - result file path, in some situations it’s extension can be changed

compare(OutputStream document, CompareOptions compareOptions)

public final Path compare(OutputStream document, CompareOptions compareOptions)

Compares documents and saves result to file stream

Note: In case return value is null, use data that was written into outputStream

Parameters:

Parameter Type Description
document java.io.OutputStream Result document stream
compareOptions CompareOptions Compare options

Returns: java.nio.file.Path - result file path or null when data from outputStream must be used. In some situations result file’s extension can be changed

compare(SaveOptions saveOptions, CompareOptions compareOptions)

public final Path compare(SaveOptions saveOptions, CompareOptions compareOptions)

Compares documents without saving result.

Parameters:

Parameter Type Description
saveOptions SaveOptions Save options
compareOptions CompareOptions Compare options

Returns: java.nio.file.Path - the path

compare(String filePath, SaveOptions saveOptions)

public final Path compare(String filePath, SaveOptions saveOptions)

Compares documents and save result to file path

Parameters:

Parameter Type Description
filePath java.lang.String Result document file path
saveOptions SaveOptions Save options

Returns: java.nio.file.Path - result file path, in some situations it’s extension can be changed

compare(Path filePath, SaveOptions saveOptions)

public final Path compare(Path filePath, SaveOptions saveOptions)

Compares documents and save result to file path

Parameters:

Parameter Type Description
filePath java.nio.file.Path Result document file path
saveOptions SaveOptions Save options

Returns: java.nio.file.Path - result file path, in some situations it’s extension can be changed

compare(OutputStream document, SaveOptions saveOptions)

public final Path compare(OutputStream document, SaveOptions saveOptions)

Compares documents and save result to file stream

Note: In case return value is null, use data that was written into outputStream

Parameters:

Parameter Type Description
document java.io.OutputStream Result document stream
saveOptions SaveOptions Save options

Returns: java.nio.file.Path - result file path or null when data from outputStream must be used. In some situations result file’s extension can be changed

compare(CompareOptions compareOptions)

public final Path compare(CompareOptions compareOptions)

Compares documents without saving result.

Parameters:

Parameter Type Description
compareOptions CompareOptions Compare options

Returns: java.nio.file.Path - the path

compare(OutputStream outputStream, SaveOptions saveOptions, CompareOptions compareOptions)

public final Path compare(OutputStream outputStream, SaveOptions saveOptions, CompareOptions compareOptions)

Compares documents and saves result to a stream.

Note: In case return value is null, use data that was written into outputStream

Parameters:

Parameter Type Description
outputStream java.io.OutputStream Result document stream
saveOptions SaveOptions Save options
compareOptions CompareOptions Compare options

Returns: java.nio.file.Path - result file path or null when data from outputStream must be used. In some situations result file’s extension can be changed

compare(String filePath, SaveOptions saveOptions, CompareOptions compareOptions)

public final Path compare(String filePath, SaveOptions saveOptions, CompareOptions compareOptions)

Compares documents and saves result to file path

Parameters:

Parameter Type Description
filePath java.lang.String Result document file path
saveOptions SaveOptions Save options
compareOptions CompareOptions Compare options

Returns: java.nio.file.Path - result file path, in some situations it’s extension can be changed

compare(Path filePath, SaveOptions saveOptions, CompareOptions compareOptions)

public final Path compare(Path filePath, SaveOptions saveOptions, CompareOptions compareOptions)

Compares documents and saves result to file path

Parameters:

Parameter Type Description
filePath java.nio.file.Path Result document file path
saveOptions SaveOptions Save options
compareOptions CompareOptions Compare options

Returns: java.nio.file.Path - result file path, in some situations it’s extension can be changed

add(String filePath)

public final void add(String filePath)

Adds file to comparison.

Parameters:

Parameter Type Description
filePath java.lang.String Compared file path

add(Path filePath)

public final void add(Path filePath)

Adds file to comparison.

Parameters:

Parameter Type Description
filePath java.nio.file.Path Compared file path

add(String[] filePaths)

public final void add(String[] filePaths)

Adds file to comparison.

Parameters:

Parameter Type Description
filePaths java.lang.String[] Compared files paths

add(Path[] filePaths)

public final void add(Path[] filePaths)

Adds file to comparison.

Parameters:

Parameter Type Description
filePaths java.nio.file.Path[] Compared files paths

add(String filePath, LoadOptions loadOptions)

public final void add(String filePath, LoadOptions loadOptions)

Adds file to comparison with loading options specified.

Parameters:

Parameter Type Description
filePath java.lang.String Compared file path
loadOptions LoadOptions Load options

add(Path filePath, LoadOptions loadOptions)

public final void add(Path filePath, LoadOptions loadOptions)

Adds file to comparison with loading options specified.

Parameters:

Parameter Type Description
filePath java.nio.file.Path Compared file path
loadOptions LoadOptions Load options

add(InputStream document)

public final void add(InputStream document)

Adds document stream to comparison.

Parameters:

Parameter Type Description
document java.io.InputStream Compared document stream

add(InputStream[] documents)

public final void add(InputStream[] documents)

Adds document stream to comparison.

Parameters:

Parameter Type Description
documents java.io.InputStream[] Compared documents streams

add(InputStream document, LoadOptions loadOptions)

public final void add(InputStream document, LoadOptions loadOptions)

Adds document stream to comparison with loading options specified.

Parameters:

Parameter Type Description
document java.io.InputStream Compared document stream
loadOptions LoadOptions Load options

getChanges()

public final ChangeInfo[] getChanges()

Gets list of changes between source and target file(s).

Returns: com.groupdocs.comparison.result.ChangeInfo[] - array of changes

getChanges(GetChangeOptions getChangeOptions)

public final ChangeInfo[] getChanges(GetChangeOptions getChangeOptions)

Gets list of changes between source and target file(s).

Parameters:

Parameter Type Description
getChangeOptions GetChangeOptions Get change options

Returns: com.groupdocs.comparison.result.ChangeInfo[] - array of changes

applyChanges(String filePath, ApplyChangeOptions applyChangeOptions)

public final void applyChanges(String filePath, ApplyChangeOptions applyChangeOptions)

Accepts or rejects changes and applies them to resultant document.

Parameters:

Parameter Type Description
filePath java.lang.String Result file path
applyChangeOptions ApplyChangeOptions Apply change options

applyChanges(Path filePath, ApplyChangeOptions applyChangeOptions)

public final void applyChanges(Path filePath, ApplyChangeOptions applyChangeOptions)

Accepts or rejects changes and applies them to resultant document.

Parameters:

Parameter Type Description
filePath java.nio.file.Path Result file path
applyChangeOptions ApplyChangeOptions Apply change options

applyChanges(OutputStream document, ApplyChangeOptions applyChangeOptions)

public final void applyChanges(OutputStream document, ApplyChangeOptions applyChangeOptions)

Accepts or rejects changes and applies them to resultant document.

Parameters:

Parameter Type Description
document java.io.OutputStream Result document
applyChangeOptions ApplyChangeOptions Apply change options

applyChanges(String filePath, SaveOptions saveOptions, ApplyChangeOptions applyChangeOptions)

public final void applyChanges(String filePath, SaveOptions saveOptions, ApplyChangeOptions applyChangeOptions)

Accepts or rejects changes and applies them to resultant document.

Parameters:

Parameter Type Description
filePath java.lang.String Result file path
saveOptions SaveOptions Save options
applyChangeOptions ApplyChangeOptions Apply change options

applyChanges(Path filePath, SaveOptions saveOptions, ApplyChangeOptions applyChangeOptions)

public final void applyChanges(Path filePath, SaveOptions saveOptions, ApplyChangeOptions applyChangeOptions)

Accepts or rejects changes and applies them to resultant document.

Parameters:

Parameter Type Description
filePath java.nio.file.Path Result file path
saveOptions SaveOptions Save options
applyChangeOptions ApplyChangeOptions Apply change options

applyChanges(OutputStream document, SaveOptions saveOptions, ApplyChangeOptions applyChangeOptions)

public final void applyChanges(OutputStream document, SaveOptions saveOptions, ApplyChangeOptions applyChangeOptions)

Accepts or rejects changes and applies them to resultant document.

Parameters:

Parameter Type Description
document java.io.OutputStream Result document
saveOptions SaveOptions Save options
applyChangeOptions ApplyChangeOptions Apply change options

getResultString()

public String getResultString()

Get result string after comparison (For Text Comparison only).

Returns: java.lang.String - the result string

close()

public void close()

dispose()

public final void dispose()

Releases resources.