## net.sf.statsvn.input
Class RepositoryFileManager

    java.lang.Object
      net.sf.statsvn.input.RepositoryFileManager

    public class RepositoryFileManager

extends Object

Manages a checked-out repository and provides access to line number counts for repository files. New in StatSVN: Also provides a central point of access to abstract out calls to the server. Many of the methods here simply redirect to the static util/SvnXXXUtils classes. Therefore, clients don't have to know where the information is located, they can simply invoke this class.

Version:
  $Id: RepositoryFileManager.java 394 2009-08-10 20:08:46Z jkealey $
Author:
  Manuel Schulze, Steffen Pingel, Jason Kealey <jkealey@shade.ca>

Constructor Summary
`RepositoryFileManager(String pathName)` Creates a new instance with root at `pathName`.

Method Summary
`String` `absolutePathToUrl(String absolute)` Converts an absolute path in the repository to a URL, using the repository URL
`String` `absoluteToRelativePath(String stringData)` Converts an absolute path in the repository to a path relative to the working folder root.
`void` `addDirectory(String relativePath)` Adds a directory to the list of known directories.
`boolean` `existsInWorkingCopy(String relativePath)` Returns true if the file exists in the working copy (according to the svn metadata, and not file system checks).
`protected ISvnDiffProcessor` `getDiffProcessor()`
`protected ISvnInfoProcessor` `getInfoProcessor()`
`protected int` `getLineCount(BufferedReader reader)` Counts lines on a BufferedReader
`int[]` `getLineDiff(String oldRevNr, String newRevNr, String filename)` Returns line count differences between two revisions of a file.
`int` `getLinesOfCode(String filename)` Returns the lines of code for a repository file.
`String` `getModuleName()` Assumes #loadInfo(String) has been called.
`ISvnProcessor` `getProcessor()`
`protected ISvnPropgetProcessor` `getPropgetProcessor()`
`String` `getRepositoryUuid()` Assumes #loadInfo(String) has been called.
`String` `getRevision(String filename)` Returns the revision of filename in the local working directory by reading the svn metadata.
`Vector` `getRevisionDiff(String newRevNr)` Returns line count differences for all files in a particular revision.
`String` `getRootRevisionNumber()` Assumes #loadInfo(String) has been called.
`protected ISvnVersionProcessor` `getVersionProcessor()`
`boolean` `isBinary(String relativePath)` Is the given path a binary file in the working directory?
`boolean` `isDirectory(String relativePath)` Returns true if the path has been identified as a directory.
`void` `loadInfo()` Initializes our representation of the repository.
`String` `relativePathToUrl(String relative)` Converts a relative path in the working folder to a URL, using the working folder's root URL
`String` `relativeToAbsolutePath(String relative)` Converts a relative path in the working folder to an absolute path in the repository.
`String` `urlToAbsolutePath(String url)` Converts a url to an absolute path in the repository.
`String` `urlToRelativePath(String url)` Converts a url to a relative path in the repository.

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

Constructor Detail

### RepositoryFileManager

    public RepositoryFileManager(String pathName)

  Creates a new instance with root at `pathName`.

  Parameters:
    `pathName` - the root of the checked out repository

Method Detail

### absolutePathToUrl

    public String absolutePathToUrl(String absolute)

  Converts an absolute path in the repository to a URL, using the repository URL

  Parameters:
    `absolute` - Example: /trunk/statsvn/package.html
  Returns:
    Example: svn://svn.statsvn.org/statsvn/trunk/statsvn/package.html

### absoluteToRelativePath

    public String absoluteToRelativePath(String stringData)

  Converts an absolute path in the repository to a path relative to the working folder root. Will return null if absolute path does not start with getModuleName();

  Parameters:
    `absolute` - Example (assume getModuleName() returns /trunk/statsvn) /trunk/statsvn/package.html
  Returns:
    Example: package.html

### addDirectory

    public void addDirectory(String relativePath)

  Adds a directory to the list of known directories. Used when inferring implicit actions on deleted paths.

  Parameters:
    `relativePath` - the relative path.

### existsInWorkingCopy

    public boolean existsInWorkingCopy(String relativePath)

  Returns true if the file exists in the working copy (according to the svn metadata, and not file system checks).

  Parameters:
    `relativePath` - the path
  Returns:
    `true` if it exists

### getLineCount

    protected int getLineCount(BufferedReader reader)
                        throws IOException

  Counts lines on a BufferedReader

  Parameters:
    `reader` - the buffered reader
  Returns:
    the number of lines read
  Throws:
    `IOException` - error reading from reader

### getLineDiff

    public int[] getLineDiff(String oldRevNr,
                             String newRevNr,
                             String filename)
                      throws IOException,
                             BinaryDiffException

  Returns line count differences between two revisions of a file.

  Parameters:
    `oldRevNr` - old revision number
    `newRevNr` - new revision number
    `filename` - the filename
  Returns:
    A int[2] array of [lines added, lines removed] is returned.
  Throws:
    `IOException` - problem parsing the stream
    `BinaryDiffException` - if the error message is due to trying to diff binary files.

### getRevisionDiff

    public Vector getRevisionDiff(String newRevNr)
                           throws IOException,
                                  BinaryDiffException

  Returns line count differences for all files in a particular revision.

  Parameters:
    `newRevNr` - new revision number
  Returns:
    A vector of object[3] array of [filename, int[2](lines added, lines removed), isBinary] is returned.
  Throws:
    `IOException` - problem parsing the stream
    `BinaryDiffException` - if the error message is due to trying to diff binary files.

### getLinesOfCode

    public int getLinesOfCode(String filename)
                       throws net.sf.statcvs.input.NoLineCountException

  Returns the lines of code for a repository file. (Currently checked out version)

  Parameters:
    `filename` - a file in the repository
  Returns:
    the lines of code for a repository file
  Throws:
    `net.sf.statcvs.input.NoLineCountException` - when the line count could not be retrieved, for example when the file was not found.

### getModuleName

    public String getModuleName()

  Assumes #loadInfo(String) has been called. Never ends with /, might be empty.

  Returns:
    The absolute path of the root of the working folder in the repository.

### getRepositoryUuid

    public String getRepositoryUuid()

  Assumes #loadInfo(String) has been called.

  Returns:
    The uuid of the repository.

### getRevision

    public String getRevision(String filename)
                       throws IOException

  Returns the revision of filename in the local working directory by reading the svn metadata.

  Parameters:
    `filename` - the filename
  Returns:
    the revision of filename
  Throws:
    `IOException`

### getRootRevisionNumber

    public String getRootRevisionNumber()

  Assumes #loadInfo(String) has been called.

  Returns:
    the revision number of the root of the working folder (last checked out revision number)

### isBinary

    public boolean isBinary(String relativePath)

  Is the given path a binary file in the working directory?

  Parameters:
    `relativePath` - the directory
  Returns:
    true if it is marked as a binary file

### isDirectory

    public boolean isDirectory(String relativePath)

  Returns true if the path has been identified as a directory.

  Parameters:
    `relativePath` - the path
  Returns:
    true if it is a known directory.

### loadInfo

    public void loadInfo()
                  throws net.sf.statcvs.input.LogSyntaxException,
                         IOException

  Initializes our representation of the repository.

  Throws:
    `net.sf.statcvs.input.LogSyntaxException` - if the svn info --xml is malformed
    `IOException` - if there is an error reading from the stream

### relativePathToUrl

    public String relativePathToUrl(String relative)

  Converts a relative path in the working folder to a URL, using the working folder's root URL

  Parameters:
    `relative` - Example: src/Messages.java
  Returns:
    Example: svn://svn.statsvn.org/statsvn/trunk/statsvn/src/Messages.java

### relativeToAbsolutePath

    public String relativeToAbsolutePath(String relative)

  Converts a relative path in the working folder to an absolute path in the repository.

  Parameters:
    `relative` - Example: src/Messages.java
  Returns:
    Example: /trunk/statsvn/src/Messages.java

### urlToAbsolutePath

    public String urlToAbsolutePath(String url)

  Converts a url to an absolute path in the repository.

  Parameters:
    `url` - Examples: svn://svn.statsvn.org/statsvn/trunk/statsvn, svn://svn.statsvn.org/statsvn/trunk/statsvn/package.html
  Returns:
    Example: /trunk/statsvn, /trunk/statsvn/package.html

### urlToRelativePath

    public String urlToRelativePath(String url)

  Converts a url to a relative path in the repository.

  Parameters:
    `url` - Examples: svn://svn.statsvn.org/statsvn/trunk/statsvn, svn://svn.statsvn.org/statsvn/trunk/statsvn/package.html
  Returns:
    Example: ".", package.html

### getProcessor

    public ISvnProcessor getProcessor()

### getDiffProcessor

    protected ISvnDiffProcessor getDiffProcessor()

### getInfoProcessor

    protected ISvnInfoProcessor getInfoProcessor()

### getPropgetProcessor

    protected ISvnPropgetProcessor getPropgetProcessor()

### getVersionProcessor

    protected ISvnVersionProcessor getVersionProcessor()