Java API Sample

1. Introduction

This sample is a basic demonstration of how to use Merge's Java API to run some simple Merge operations with hard-coded file paths.

2. Implementation

The sample is implemented in the main method of a single Java class, SimpleRunner.java, and the approach taken is as follows:

  1. Create File objects for sample inputs.
  2. Instantiate the merge object using either ConcurrentMerge or SequentialMerge;
  3. Set the ancestor file (Only for ConcurrentMerge) with: ConcurrentMerge.setAncestor;
  4. Add the demo input versions by using one of the following:
    1. ConcurrentMerge.addVersion
    2. SequentialMerge.addVersion
  5. Call one of the following methods to produce a DeltaV2 representation of the merge.
    1. ConcurrentMerge.extractAll
    2. SequentialMerge.extractAll

Additionally, the ThreeWayMerge class can be used with one of its merge methods to allow merge operations to be performed with a single method call. This class also allows the approach shown above but we only demonstrate the simpler method calls in the sample code.

3. Running

To run this sample, you will require Apache Ant and a JDK. From a command prompt in the sample directory, you can invoke the sample with:

ant

The following targets are supplied in:

TargetDescription
runDefault. This depends on the compile target, and runs the main method of SimpleRunner.java.
compileCompiles SimpleRunner.java into a Java .class file in the class directory, which can be invoked either through the java command or from the ant run target above.
cleanThis deletes everything in the .class directory.