Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.crosswire.common.diff
Class PatchEntry

    java.lang.Object
      org.crosswire.common.diff.PatchEntry

All Implemented Interfaces:
  Iterable<Difference>

    public class PatchEntry

extends Object
implements Iterable<Difference>

A PatchEntry is a single "instruction" in a Patch, consisting of a interval over which differences are applied and the differences that should be applied. Based on the LGPL Diff_Match_Patch v1.5 javascript of Neil Fraser, Copyright (C) 2006
http://neil.fraser.name/software/diff_match_patch/

Author:
  DM Smith
See Also:
  `The GNU Lesser General Public License for details.`

Field Summary
`private List<Difference>` | `diffs`
`private static int` | `margin`
`private static int` | `MARGIN` Chunk size for context length.
`private static Pattern` | `newlinePattern`
`private static Pattern` | `patchPattern`
`private int` | `sourceLength`
`private int` | `sourceStart`
`private int` | `targetLength`
`private int` | `targetStart`

Constructor Summary
`PatchEntry()`
`PatchEntry(String patchText)`

Method Summary
`void` | `addContext(String text)`
`void` | `addDifference(Difference diff)`
`void` | `adjustSourceLength(int adjustment)`
`void` | `adjustSourceStart(int adjustment)`
`void` | `adjustTargetLength(int adjustment)`
`void` | `adjustTargetStart(int adjustment)`
`private String` | `decode(String str)` Undo encoding
`private String` | `encode(String str)` This algorithm allows for \n to be included in a difference.
`PatchEntry` | `fromText(String input)` Parse a textual representation of a patch entry and populate this patch entry.
`private String` | `getCoordinates(int start, int length)`
`int` | `getDifferenceCount()`
`Difference` | `getFirstDifference()`
`Difference` | `getLastDifference()`
`static int` | `getMargin()`
`int` | `getSourceLength()`
`int` | `getSourceStart()`
`String` | `getSourceText()`
`int` | `getTargetLength()`
`int` | `getTargetStart()`
`String` | `getTargetText()`
`boolean` | `hasDifferences()`
`Iterator<Difference>` | `iterator()`
`Difference` | `removeFirstDifference()`
`protected void` | `setDifferences(List<Difference> newDiffs)`
`static void` | `setMargin(int newMargin)`
`void` | `setSourceLength(int length)`
`void` | `setSourceStart(int start)`
`void` | `setTargetLength(int length)`
`void` | `setTargetStart(int start)`
`String` | `toString()`

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

Field Detail

### MARGIN

    private static final int MARGIN

  Chunk size for context length.

  See Also:
    Constant Field Values

### margin

    private static int margin

### newlinePattern

    private static Pattern newlinePattern

### patchPattern

    private static Pattern patchPattern

### diffs

    private List<Difference> diffs

### sourceStart

    private int sourceStart

### targetStart

    private int targetStart

### sourceLength

    private int sourceLength

### targetLength

    private int targetLength

Constructor Detail

### PatchEntry

    public PatchEntry()

### PatchEntry

    public PatchEntry(String patchText)

Method Detail

### getSourceStart

    public int getSourceStart()

  Returns:
    the sourceStart

### setSourceStart

    public void setSourceStart(int start)

  Parameters:
    `start` - the sourceStart to set

### adjustSourceStart

    public void adjustSourceStart(int adjustment)

  Parameters:
    `adjustment` - the adjustment to sourceStart

### getTargetStart

    public int getTargetStart()

  Returns:
    the targetStart

### setTargetStart

    public void setTargetStart(int start)

  Parameters:
    `start` - the targetStart to set

### adjustTargetStart

    public void adjustTargetStart(int adjustment)

  Parameters:
    `adjustment` - the adjustment to targetStart

### getSourceLength

    public int getSourceLength()

  Returns:
    the sourceLength

### setSourceLength

    public void setSourceLength(int length)

  Parameters:
    `length` - the sourceLength to set

### adjustSourceLength

    public void adjustSourceLength(int adjustment)

  Parameters:
    `adjustment` - the adjustment to sourceLength

### getTargetLength

    public int getTargetLength()

  Returns:
    the targetLength

### setTargetLength

    public void setTargetLength(int length)

  Parameters:
    `length` - the targetLength to set

### adjustTargetLength

    public void adjustTargetLength(int adjustment)

  Parameters:
    `adjustment` - the adjustment to targetLength

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### fromText

    public PatchEntry fromText(String input)

  Parse a textual representation of a patch entry and populate this patch entry.

  Parameters:
    `input` - Text representation of this patch entry
  Returns:
    this patch entry

### getSourceText

    public String getSourceText()

### getTargetText

    public String getTargetText()

### addContext

    public void addContext(String text)

### addDifference

    public void addDifference(Difference diff)

### getDifferenceCount

    public int getDifferenceCount()

### hasDifferences

    public boolean hasDifferences()

### iterator

    public Iterator<Difference> iterator()

  Specified by:
    `iterator` in interface `Iterable<Difference>`

### getFirstDifference

    public Difference getFirstDifference()

### removeFirstDifference

    public Difference removeFirstDifference()

### getLastDifference

    public Difference getLastDifference()

### setDifferences

    protected void setDifferences(List<Difference> newDiffs)

### setMargin

    public static void setMargin(int newMargin)

  Parameters:
    `newMargin` - the margin to set

### getMargin

    public static int getMargin()

  Returns:
    the margin

### getCoordinates

    private String getCoordinates(int start,
                                  int length)

### encode

    private String encode(String str)

  This algorithm allows for \n to be included in a difference. Thus it needs to be escaped. We will use URL encoding of \n. But this makes % a meta-character, thus it needs to be encoded too.

  Parameters:
    `str` - the unencoded string
  Returns:
    the encoded string

### decode

    private String decode(String str)

  Undo encoding

  Parameters:
    `str` - the encoded string
  Returns:
    the unencoded string

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Copyright ¨ 2003-2015
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD