JavaSVN Home

## org.tmatesoft.svn.core.io.diff
Class SVNDiffWindow

    java.lang.Object
      org.tmatesoft.svn.core.io.diff.SVNDiffWindow

public class SVNDiffWindow
extends Object

The SVNDiffWindow class represents a diff window that contains instructions and new data of a delta to apply to a file.

Version:
  1.0
Author:
  TMate Software Ltd.

Constructor Summary
`SVNDiffWindow(long sourceViewOffset, long sourceViewLength, long targetViewLength, long instructionsLength, long newDataLength)` Constructs an SVNDiffWindow object.
`SVNDiffWindow(long sourceViewOffset, long sourceViewLength, long targetViewLength, SVNDiffInstruction[] instructions, long newDataLength)` Constructs an SVNDiffWindow object.

Method Summary
`void` `apply(SVNDiffWindowApplyBaton applyBaton, InputStream newData)` Applies this window's instructions.
`SVNDiffInstruction` `getInstructionAt(int index)` Gets a definite diff instruction from an array of instructions.
`int` `getInstructionsCount()` Returns the number of instructions contained in this diff window.
`long` `getInstructionsLength()` Returns the length of instructions in bytes.
`long` `getNewDataLength()` Returns the number of new data bytes to copy to the target view.
`long` `getSourceViewLength()` Returns the number of bytes to copy from the source view to the target one.
`long` `getSourceViewOffset()` Returns the source view offset.
`long` `getTargetViewLength()` Returns the length in bytes of the target view.
`String` `toString()` Gives a string representation of this object.

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

Constructor Detail

### SVNDiffWindow

    public SVNDiffWindow(long sourceViewOffset,
                         long sourceViewLength,
                         long targetViewLength,
                         SVNDiffInstruction[] instructions,
                         long newDataLength)

  Constructs an SVNDiffWindow object.

Parameters:
  `sourceViewOffset` - an offset in the source view
  `sourceViewLength` - a number of bytes to read from the source view
  `targetViewLength` - a length in bytes of the target view it must have after copying bytes
  `instructions` - diff instructions to copy bytes
  `newDataLength` - a number of bytes of new data

### SVNDiffWindow

    public SVNDiffWindow(long sourceViewOffset,
                         long sourceViewLength,
                         long targetViewLength,
                         long instructionsLength,
                         long newDataLength)

  Constructs an SVNDiffWindow object. This constructor is used when bytes of instructions are not decoded and converted to SVNDiffInstruction objects yet, but are kept elsewhere along with new data.

Parameters:
  `sourceViewOffset` - an offset in the source view
  `sourceViewLength` - a number of bytes to read from the source view
  `targetViewLength` - a length in bytes of the target view it must have after copying bytes
  `instructionsLength` - a number of instructions bytes
  `newDataLength` - a number of bytes of new data
See Also:
  `SVNDiffInstruction`

Method Detail

### getInstructionsLength

    public long getInstructionsLength()

  Returns the length of instructions in bytes.

  Returns:
    a number of instructions bytes

### getSourceViewOffset

    public long getSourceViewOffset()

  Returns the source view offset.

  Returns:
    an offset in the source from where the source bytes must be copied

### getSourceViewLength

    public long getSourceViewLength()

  Returns the number of bytes to copy from the source view to the target one.

  Returns:
    a number of source bytes to copy

### getTargetViewLength

    public long getTargetViewLength()

  Returns the length in bytes of the target view. The length of the target view is actually the number of bytes that should be totally copied by all the instructions of this window.

  Returns:
    a length in bytes of the target view

### getInstructionsCount

    public int getInstructionsCount()

  Returns the number of instructions contained in this diff window.

  Returns:
    an instructions number

### getInstructionAt

    public SVNDiffInstruction getInstructionAt(int index)

  Gets a definite diff instruction from an array of instructions.

  Parameters:
    `index` - a zero based instruction index
  Returns:
    an instrucion at `index`

### getNewDataLength

    public long getNewDataLength()

  Returns the number of new data bytes to copy to the target view.

  Returns:
    a number of new data bytes

### apply

    public void apply(SVNDiffWindowApplyBaton applyBaton,
                      InputStream newData)
               throws SVNException

  Applies this window's instructions. The source and target streams are provided by `applyBaton`.

  If this window has got any `SVNDiffInstruction.COPY_FROM_SOURCE` instructions, then:

  1. At first copies a source view from the source stream of `applyBaton` to the baton's inner source buffer. `SVNDiffInstruction.COPY_FROM_SOURCE` instructions of this window are relative to the bounds of that source buffer (source view, in other words).
  2. Second, according to instructions copies source bytes from the source buffer to the baton's target buffer (target view, in other words).
  3. Then, if `applyBaton` is supplied with an MD5 digest, updates it with those bytes in the target buffer. So, after instructions applying completes, it will be the checksum for the full text.
  4. The last step - appends the target buffer bytes to the baton's target stream.

  `SVNDiffInstruction.COPY_FROM_NEW_DATA` instructions are relative to the bounds of the provided `newData` stream.

  `SVNDiffInstruction.COPY_FROM_TARGET` instructions are relative to the bounds of the target buffer.

  Parameters:
    `applyBaton` - a baton that provides the source and target views
    `newData` - an input stream to read new data bytes from
  Throws:
    `SVNException`

### toString

    public String toString()

  Gives a string representation of this object.

  Returns:
    a string representation of this object

JavaSVN Home

Copyright © 2004-2006 TMate Software Ltd. All Rights Reserved.