com.cloudbees.diff.provider
Class CmdlineDiffProvider

java.lang.Object
  extended by com.cloudbees.diff.provider.DiffProvider
      extended by com.cloudbees.diff.provider.CmdlineDiffProvider
All Implemented Interfaces:
Serializable

public class CmdlineDiffProvider
extends DiffProvider
implements Serializable

The parser of an external diff utility compatible with Unix diff output.

The implementtaion is interruptible by Thread.interrupt(). On interrupt it kills external program and throws InterruptedIOException,

Author:
Martin Entlicher
See Also:
Serialized Form

Field Summary
static String DIFF_REGEXP
           
 
Constructor Summary
CmdlineDiffProvider(String diffCmd)
          Creates new CmdlineDiffProvider
 
Method Summary
 Diff computeDiff(Reader r1, Reader r2)
          Create the differences of the content two streams.
static CmdlineDiffProvider createDefault()
           
 String getDiffCommand()
          Get the diff command being used.
static void outputLine(String elements, Pattern pattern, List<Difference> differences, StringBuffer firstText, StringBuffer secondText)
          This method is called, with elements of the output data.
 void setDiffCommand(String diffCmd)
          Set a new diff command.
static void setTextOnLastDifference(List<Difference> differences, StringBuffer firstText, StringBuffer secondText)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIFF_REGEXP

public static final String DIFF_REGEXP
See Also:
Constant Field Values
Constructor Detail

CmdlineDiffProvider

public CmdlineDiffProvider(String diffCmd)
Creates new CmdlineDiffProvider

Parameters:
diffCmd - The diff command. Must contain "{0}" and "{1}", which will be replaced with the files being compared.
Method Detail

createDefault

public static CmdlineDiffProvider createDefault()

setDiffCommand

public void setDiffCommand(String diffCmd)
Set a new diff command.

Parameters:
diffCmd - The diff command. Must contain "{0}" and "{1}", which will be replaced with the files being compared.

getDiffCommand

public String getDiffCommand()
Get the diff command being used.


computeDiff

public Diff computeDiff(Reader r1,
                        Reader r2)
                 throws IOException
Create the differences of the content two streams.

Specified by:
computeDiff in class DiffProvider
Parameters:
r1 - the first source
r2 - the second source to be compared with the first one.
Returns:
the list of differences found, instances of Difference; or null when some error occured.
Throws:
IOException - when the reading from input streams fails.

setTextOnLastDifference

public static void setTextOnLastDifference(List<Difference> differences,
                                           StringBuffer firstText,
                                           StringBuffer secondText)

outputLine

public static void outputLine(String elements,
                              Pattern pattern,
                              List<Difference> differences,
                              StringBuffer firstText,
                              StringBuffer secondText)
This method is called, with elements of the output data.

Parameters:
elements - the elements of output data.


Copyright © 2011-2012. All Rights Reserved.