Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## junitutils
Class Diff

    java.lang.Object
      junitutils.Diff

public class Diff
extends java.lang.Object

Class for calculating a (somewhat) detailed comparison of two strings.

Version:
  $Revision: 1.4 $
Author:
  Curtis Clifton

Field Summary
`private boolean` | `areDifferent` This is set to true if the oldText and newText are not the same
`private static java.lang.String` | `DELIM` This string holds line delimiters
`private static java.lang.String` | `NEW_CH` This string is used to mark lines of new text
`private static java.lang.String` | `NEWLINE` This is the system new line character
`private java.lang.String` | `newText` This is the supplied new text, to be compared against the old text
`private static java.lang.String` | `OLD_CH` This string is used to mark lines of old text
`private java.lang.String` | `oldText` This is the supplied old text, to be compared against the new text
`private java.lang.String` | `result` This output String holds the description of the differences between the old and new text.

Constructor Summary
`Diff(java.lang.String oldTextLabel, java.lang.String oldText, java.lang.String newTextLabel, java.lang.String newText)` Calculate a difference between the given strings.

Method Summary
`boolean` | `areDifferent()` Returns true if strings on which this was constructed are different.
`private void` | `calculate(java.lang.String oldTextLabel, java.lang.String newTextLabel)` Sets the values of areDifferent and result according to a comparison between oldText and newText
`java.lang.String` | `result()` Returns the differences between the given strings.
`private java.lang.String[]` | `splitByLine(java.lang.String text)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### oldText

    private java.lang.String oldText

  This is the supplied old text, to be compared against the new text

### newText

    private java.lang.String newText

  This is the supplied new text, to be compared against the old text

### areDifferent

    private boolean areDifferent

  This is set to true if the oldText and newText are not the same

### result

    private java.lang.String result

  This output String holds the description of the differences between the old and new text.

### DELIM

    private static final java.lang.String DELIM

  This string holds line delimiters

  See Also:
    Constant Field Values

### NEWLINE

    private static final java.lang.String NEWLINE

  This is the system new line character

### OLD_CH

    private static final java.lang.String OLD_CH

  This string is used to mark lines of old text

  See Also:
    Constant Field Values

### NEW_CH

    private static final java.lang.String NEW_CH

  This string is used to mark lines of new text

  See Also:
    Constant Field Values

Constructor Detail

### Diff

    public Diff(java.lang.String oldTextLabel,
                java.lang.String oldText,
                java.lang.String newTextLabel,
                java.lang.String newText)

  Calculate a difference between the given strings.

Parameters:
  `oldTextLabel` - a label for the `oldText` parameter
  `oldText` - a value to be compared
  `newTextLabel` - a label for the `newText` parameter
  `newText` - a value to be compared

Method Detail

### calculate

    private void calculate(java.lang.String oldTextLabel,
                           java.lang.String newTextLabel)

  Sets the values of areDifferent and result according to a comparison between oldText and newText

  Parameters:
    `oldTextLabel` - a label for the `oldText` parameter
    `newTextLabel` - a label for the `newText` parameter

### splitByLine

    private java.lang.String[] splitByLine(java.lang.String text)

### areDifferent

    public boolean areDifferent()

  Returns true if strings on which this was constructed are different.

### result

    public java.lang.String result()

  Returns the differences between the given strings.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

The ESC/Java2 Project Homepage