SVNKit Home

## org.tmatesoft.svn.core.wc
Class DefaultSVNDiffGenerator

    java.lang.Object
      org.tmatesoft.svn.core.wc.DefaultSVNDiffGenerator

All Implemented Interfaces:
  ISVNDiffGenerator

public class DefaultSVNDiffGenerator
extends Object
implements ISVNDiffGenerator

DefaultSVNDiffGenerator is a default implementation of ISVNDiffGenerator.

By default, if there's no any specified implementation of the diff generator's interface, SVNKit uses this default implementation. To set a custom diff driver use `setDiffGenerator()`.

Version:
  1.1.1
Author:
  TMate Software Ltd.

Field Summary
`protected static InputStream` `EMPTY_FILE_IS`
`protected static byte[]` `EOL`
`protected static byte[]` `HEADER_SEPARATOR`
`protected static byte[]` `PROPERTIES_SEPARATOR`
`protected static String` `WC_REVISION_LABEL`

Constructor Summary
`DefaultSVNDiffGenerator()` Constructs a DefaultSVNDiffGenerator.

Method Summary
`File` `createTempDirectory()` Creates a temporary directory (when necessary) where temporary files will be created.
`void` `displayAddedDirectory(String path, String rev1, String rev2)` Does nothing.
`protected void` `displayBinary(OutputStream os, String mimeType1, String mimeType2)`
`void` `displayDeletedDirectory(String path, String rev1, String rev2)` Does nothing.
`void` `displayFileDiff(String path, File file1, File file2, String rev1, String rev2, String mimeType1, String mimeType2, OutputStream result)` Generates and writes differences between two files to the specified output stream.
`protected boolean` `displayHeader(OutputStream os, String path, boolean deleted)`
`protected void` `displayHeaderFields(OutputStream os, String path1, String rev1, String path2, String rev2)`
`void` `displayPropDiff(String path, Map baseProps, Map diff, OutputStream result)` Writes the differences in file properties to the specified output stream.
`protected File` `getBasePath()`
`SVNDiffOptions` `getDiffOptions()` Gets the diff options that are used by this generator.
`protected String` `getDisplayPath(String path)`
`String` `getEncoding()` Gets the encoding charset being in use for a diff output.
`void` `init(String anchorPath1, String anchorPath2)` Initializes the driver setting up the paths/URLs that should be compared, or root paths/URLs for those paths to which a diff operation should be restricted.
`boolean` `isDiffAdded()` Tells whether added files are enabled to be diffed.
`boolean` `isDiffCopied()` Tells whether copied files are enabled to be diffed against their copy sources.
`boolean` `isDiffDeleted()` Tells whether deleted files are enabled to be diffed.
`boolean` `isDiffUnversioned()` Says if unversioned files are also diffed or ignored.
`boolean` `isForcedBinaryDiff()`
`protected boolean` `isHeaderForced(File file1, File file2)`
`void` `setBasePath(File basePath)` Sets the root path for this diff generator.
`void` `setDiffAdded(boolean isDiffAdded)` Enables or disables generating differences for added files.
`void` `setDiffCopied(boolean isDiffCopied)` Enables or disables generating differences against copy source for copied files.
`void` `setDiffDeleted(boolean isDiffDeleted)` Enables or disables generating differences for deleted files.
`void` `setDiffOptions(SVNDiffOptions options)` Sets diff options containing diff rules.
`void` `setDiffUnversioned(boolean diffUnversioned)` Includes or not unversioned files into diff processing.
`void` `setEncoding(String encoding)` Sets the encoding charset to be used for a diff output.
`void` `setForcedBinaryDiff(boolean forced)` Enables or disables generating differnces between files having a binary MIME type.
`protected boolean` `useLocalFileSeparatorChar()`

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

Field Detail

### PROPERTIES_SEPARATOR

    protected static final byte[] PROPERTIES_SEPARATOR

### HEADER_SEPARATOR

    protected static final byte[] HEADER_SEPARATOR

### EOL

    protected static final byte[] EOL

### WC_REVISION_LABEL

    protected static final String WC_REVISION_LABEL

See Also:
  Constant Field Values

### EMPTY_FILE_IS

    protected static final InputStream EMPTY_FILE_IS

Constructor Detail

### DefaultSVNDiffGenerator

    public DefaultSVNDiffGenerator()

  Constructs a DefaultSVNDiffGenerator.

Method Detail

### init

    public void init(String anchorPath1,
                     String anchorPath2)

  Description copied from interface: `ISVNDiffGenerator`
  Initializes the driver setting up the paths/URLs that should be compared, or root paths/URLs for those paths to which a diff operation should be restricted.

  These paths have got the same meaning as OLD-TGT (`anchorPath1`) and NEW-TGT (`anchorPath2`) in the SVN command line client's 'svn diff' command. So, they can be either local paths, or URLs pointing to repository locations. If one of them (or both) is a URL it may differ from that one passed to an appropriate doDiff() method of SVNDiffClient in that case when in a peg revision it's one URL, but in the target revision it was changed (moved?) to some other one. So, this method should receive the real one.

  Specified by:
    `init` in interface `ISVNDiffGenerator`
  Parameters:
    `anchorPath1` - an old path/URL
    `anchorPath2` - a new path/URL

### setDiffOptions

    public void setDiffOptions(SVNDiffOptions options)

  Sets diff options containing diff rules.

  Parameters:
    `options` - diff options

### setBasePath

    public void setBasePath(File basePath)

  Description copied from interface: `ISVNDiffGenerator`
  Sets the root path for this diff generator.

  This can be used to make all paths in a diff output be relative to this base path.

  Specified by:
    `setBasePath` in interface `ISVNDiffGenerator`
  Parameters:
    `basePath` - a base path for this driver

### setDiffDeleted

    public void setDiffDeleted(boolean isDiffDeleted)

  Description copied from interface: `ISVNDiffGenerator`
  Enables or disables generating differences for deleted files.

  Like the '--no-diff-deleted' option of the 'svn diff' or 'svnlook diff' commands.

  Specified by:
    `setDiffDeleted` in interface `ISVNDiffGenerator`
  Parameters:
    `isDiffDeleted` - if true then deleted files will be diffed, otherwise not
  See Also:
    `ISVNDiffGenerator.isDiffDeleted()`

### isDiffDeleted

    public boolean isDiffDeleted()

  Description copied from interface: `ISVNDiffGenerator`
  Tells whether deleted files are enabled to be diffed.

  Specified by:
    `isDiffDeleted` in interface `ISVNDiffGenerator`
  Returns:
    true if deleted files should be diffed (the driver is set to generate differences for deleted files as well), otherwise false
  See Also:
    `ISVNDiffGenerator.setDiffDeleted(boolean)`

### setDiffAdded

    public void setDiffAdded(boolean isDiffAdded)

  Description copied from interface: `ISVNDiffGenerator`
  Enables or disables generating differences for added files. This switch is relevant to `SVNLookClient`'s diff operations.

  Like the '--no-diff-added' option of the 'svnlook diff' command.

  Specified by:
    `setDiffAdded` in interface `ISVNDiffGenerator`
  Parameters:
    `isDiffAdded` - if true then added files will be diffed, otherwise not
  See Also:
    `ISVNDiffGenerator.isDiffAdded()`

### isDiffAdded

    public boolean isDiffAdded()

  Description copied from interface: `ISVNDiffGenerator`
  Tells whether added files are enabled to be diffed. This switch is relevant to `SVNLookClient`'s diff operations.

  Specified by:
    `isDiffAdded` in interface `ISVNDiffGenerator`
  Returns:
    true if added files should be diffed, otherwise false
  See Also:
    `ISVNDiffGenerator.setDiffAdded(boolean)`

### setDiffCopied

    public void setDiffCopied(boolean isDiffCopied)

  Description copied from interface: `ISVNDiffGenerator`
  Enables or disables generating differences against copy source for copied files. This switch is relevant to `SVNLookClient`'s diff operations.

  Like the '--diff-copy-from' option of the 'svnlook diff' command.

  Specified by:
    `setDiffCopied` in interface `ISVNDiffGenerator`
  Parameters:
    `isDiffCopied` - if true then copied files will be diffed against copy sources, otherwise they will be treated as newly added files
  See Also:
    `ISVNDiffGenerator.isDiffCopied()`

### isDiffCopied

    public boolean isDiffCopied()

  Description copied from interface: `ISVNDiffGenerator`
  Tells whether copied files are enabled to be diffed against their copy sources. This switch is relevant to `SVNLookClient`'s diff operations.

  Specified by:
    `isDiffCopied` in interface `ISVNDiffGenerator`
  Returns:
    true if copied files should be diffed against copy sources; false if copied files should be treated as newly added
  See Also:
    `ISVNDiffGenerator.setDiffCopied(boolean)`

### getDiffOptions

    public SVNDiffOptions getDiffOptions()

  Gets the diff options that are used by this generator. Creates a new one if none was used before.

  Returns:
    diff options

### getDisplayPath

    protected String getDisplayPath(String path)

### setForcedBinaryDiff

    public void setForcedBinaryDiff(boolean forced)

  Description copied from interface: `ISVNDiffGenerator`
  Enables or disables generating differnces between files having a binary MIME type.

  Like the '--force' option of the 'svn diff' command.

  Specified by:
    `setForcedBinaryDiff` in interface `ISVNDiffGenerator`
  Parameters:
    `forced` - if true binary files will also be diffed, otherwise not

### isForcedBinaryDiff

    public boolean isForcedBinaryDiff()

  Specified by:
    `isForcedBinaryDiff` in interface `ISVNDiffGenerator`

### displayPropDiff

    public void displayPropDiff(String path,
                                Map baseProps,
                                Map diff,
                                OutputStream result)
                         throws SVNException

  Description copied from interface: `ISVNDiffGenerator`
  Writes the differences in file properties to the specified output stream.

  Specified by:
    `displayPropDiff` in interface `ISVNDiffGenerator`
  Parameters:
    `path` - a file path on which the property changes are written to the output
    `baseProps` - a `Map` of old properties (property names are mapped to their values)
    `diff` - a `Map` of changed properties (property names are mapped to their values)
    `result` - the target `OutputStream` where the differences will be written to
  Throws:
    `SVNException` - if can not save diff data

### getBasePath

    protected File getBasePath()

### displayFileDiff

    public void displayFileDiff(String path,
                                File file1,
                                File file2,
                                String rev1,
                                String rev2,
                                String mimeType1,
                                String mimeType2,
                                OutputStream result)
                         throws SVNException

  Description copied from interface: `ISVNDiffGenerator`
  Generates and writes differences between two files to the specified output stream.

  `file1` or `file2` may be temporary files crteated to get file contents from the repository (when running diff on URLs). These temporary files will be deleted with the temporary directory (created by `ISVNDiffGenerator.createTempDirectory()`) when the operation ends up.

  Specified by:
    `displayFileDiff` in interface `ISVNDiffGenerator`
  Parameters:
    `path` - a file path on which the differences are generated and written to the output
    `file1` - a file with old contents
    `file2` - a file with new contents
    `rev1` - the first diff revision of `file1`
    `rev2` - the second diff revision of `file2`
    `mimeType1` - the MIME-type of `file1`
    `mimeType2` - the MIME-type of `file2`
    `result` - the target `OutputStream` where the differences will be written to
  Throws:
    `SVNException` - if can not save diff data

### setEncoding

    public void setEncoding(String encoding)

  Description copied from interface: `ISVNDiffGenerator`
  Sets the encoding charset to be used for a diff output.

  Specified by:
    `setEncoding` in interface `ISVNDiffGenerator`
  Parameters:
    `encoding` - the name of a charset

### getEncoding

    public String getEncoding()

  Description copied from interface: `ISVNDiffGenerator`
  Gets the encoding charset being in use for a diff output.

  Specified by:
    `getEncoding` in interface `ISVNDiffGenerator`
  Returns:
    the name of the charset being in use

### createTempDirectory

    public File createTempDirectory()
                             throws SVNException

  Description copied from interface: `ISVNDiffGenerator`
  Creates a temporary directory (when necessary) where temporary files will be created.

  This temporary directory exists till the end of the diff operation.

  Specified by:
    `createTempDirectory` in interface `ISVNDiffGenerator`
  Returns:
    an abstract pathname denoting a newly-created temporary directory
  Throws:
    `SVNException` - if a directory can not be created

### isDiffUnversioned

    public boolean isDiffUnversioned()

  Says if unversioned files are also diffed or ignored.

  By default unversioned files are ignored.

  Specified by:
    `isDiffUnversioned` in interface `ISVNDiffGenerator`
  Returns:
    true if diffed, false if ignored
  See Also:
    `setDiffUnversioned(boolean)`

### setDiffUnversioned

    public void setDiffUnversioned(boolean diffUnversioned)

  Includes or not unversioned files into diff processing.

  If a diff operation is invoked on a versioned directory and `diffUnversioned` is true then all unversioned files that may be met in the directory will be processed as added. Otherwise if `diffUnversioned` is false such files are ignored.

  By default unversioned files are ignored.

  Specified by:
    `setDiffUnversioned` in interface `ISVNDiffGenerator`
  Parameters:
    `diffUnversioned` - controls whether to diff unversioned files or not
  See Also:
    `isDiffUnversioned()`

### displayDeletedDirectory

    public void displayDeletedDirectory(String path,
                                        String rev1,
                                        String rev2)
                                 throws SVNException

  Does nothing.

  Specified by:
    `displayDeletedDirectory` in interface `ISVNDiffGenerator`
  Parameters:
    `path` - a directory path
    `rev1` - the first diff revision
    `rev2` - the second diff revision
  Throws:
    `SVNException`

### displayAddedDirectory

    public void displayAddedDirectory(String path,
                                      String rev1,
                                      String rev2)
                               throws SVNException

  Does nothing.

  Specified by:
    `displayAddedDirectory` in interface `ISVNDiffGenerator`
  Parameters:
    `path` - a directory path
    `rev1` - the first diff revision
    `rev2` - the second diff revision
  Throws:
    `SVNException`

### displayBinary

    protected void displayBinary(OutputStream os,
                                 String mimeType1,
                                 String mimeType2)
                          throws IOException

  Throws:
    `IOException`

### displayHeader

    protected boolean displayHeader(OutputStream os,
                                    String path,
                                    boolean deleted)
                             throws IOException

  Throws:
    `IOException`

### displayHeaderFields

    protected void displayHeaderFields(OutputStream os,
                                       String path1,
                                       String rev1,
                                       String path2,
                                       String rev2)
                                throws IOException

  Throws:
    `IOException`

### isHeaderForced

    protected boolean isHeaderForced(File file1,
                                     File file2)

### useLocalFileSeparatorChar

    protected boolean useLocalFileSeparatorChar()

SVNKit Home

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