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

## net.sf.statsvn.util
Class SvnInfoUtils

    java.lang.Object
      net.sf.statsvn.util.SvnInfoUtils

public final class SvnInfoUtils
extends Object

Utilities class that manages calls to svn info. Used to find repository information, latest revision numbers, and directories.

Version:
  $Id: SvnInfoUtils.java 351 2008-03-28 18:46:26Z benoitx $
Author:
  Jason Kealey

Nested Class Summary
`protected static class` | `SvnInfoUtils.SvnInfoHandler` SAX parser for the svn info --xml command.

Method Summary
`static String` | `absolutePathToUrl(String absolute)` Converts an absolute path in the repository to a URL, using the repository URL
`static String` | `absoluteToRelativePath(String absolute)` Converts an absolute path in the repository to a path relative to the working folder root.
`static void` | `addDirectory(String relativePath)` Adds a directory to the list of known directories.
`static boolean` | `existsInWorkingCopy(String relativePath)` Returns true if the file exists in the working copy (according to the svn metadata, and not file system checks).
`static String` | `getModuleName()` Assumes #loadInfo(String) has been called.
`static String` | `getRepositoryUrl()` Assumes #loadInfo() has been invoked.
`static String` | `getRepositoryUuid()` Assumes #loadInfo() has been invoked.
`static String` | `getRevisionNumber(String relativePath)` Returns the revision number of the file in the working copy.
`static String` | `getRootRevisionNumber()` Assumes #loadInfo() has been invoked.
`static String` | `getRootUrl()` Assumes #loadInfo() has been invoked.
`protected static ProcessUtils` | `getSvnInfo(boolean bRootOnly)` Invokes svn info.
`static boolean` | `isDirectory(String relativePath)` Returns true if the path has been identified as a directory.
`protected static boolean` | `isQueryNeeded(boolean bRootOnly)` Do we need to re-invoke svn info?
`static void` | `loadInfo()` Initializes our representation of the repository.
`protected static void` | `loadInfo(boolean bRootOnly)` Loads the information from svn info if needed.
`static void` | `loadInfo(ProcessUtils pUtils)` Loads the information from svn info if needed.
`static String` | `relativePathToUrl(String relative)` Converts a relative path in the working folder to a URL, using the working folder's root URL
`static String` | `relativeToAbsolutePath(String relative)` Converts a relative path in the working folder to an absolute path in the repository.
`static String` | `replace(String originalPattern, String newPattern, String originalString)` This method is a 1.4 replacement of the String.replace(CharSequence, CharSequence) found in 1.5.
`protected static void` | `setRepositoryUrl(String repositoryUrl)` Sets the project's repository URL.
`protected static void` | `setRootUrl(String rootUrl)` Sets the project's root URL.
`static String` | `urlToAbsolutePath(String url)` Converts a url to an absolute path in the repository.
`static 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`

Method Detail

### absoluteToRelativePath

    public static String absoluteToRelativePath(String absolute)

  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

### absolutePathToUrl

    public static 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

### relativePathToUrl

    public static 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 static 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

### existsInWorkingCopy

    public static 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

### getModuleName

    public static 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.

### getRevisionNumber

    public static String getRevisionNumber(String relativePath)

  Returns the revision number of the file in the working copy.

  Parameters:
    `relativePath` - the filename
  Returns:
    the revision number if it exists in the working copy, null otherwise.

### getRootRevisionNumber

    public static String getRootRevisionNumber()

  Assumes #loadInfo() has been invoked.

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

### getRootUrl

    public static String getRootUrl()

  Assumes #loadInfo() has been invoked.

  Returns:
    the root of the working folder's url (example: svn://svn.statsvn.org/statsvn/trunk/statsvn)

### getRepositoryUuid

    public static String getRepositoryUuid()

  Assumes #loadInfo() has been invoked.

  Returns:
    the uuid of the repository

### getRepositoryUrl

    public static String getRepositoryUrl()

  Assumes #loadInfo() has been invoked.

  Returns:
    the repository url (example: svn://svn.statsvn.org/statsvn)

### getSvnInfo

    protected static ProcessUtils getSvnInfo(boolean bRootOnly)

  Invokes svn info.

  Parameters:
    `bRootOnly` - true if should we check for the root only or false otherwise (recurse for all files)
  Returns:
    the response.

### isDirectory

    public static 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.

### addDirectory

    public static 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.

### isQueryNeeded

    protected static boolean isQueryNeeded(boolean bRootOnly)

  Do we need to re-invoke svn info?

  Parameters:
    `bRootOnly` - true if we need the root only
  Returns:
    true if we it needs to be re-invoked.

### loadInfo

    protected static void loadInfo(boolean bRootOnly)
                            throws net.sf.statcvs.input.LogSyntaxException,
                                   IOException

  Loads the information from svn info if needed.

  Parameters:
    `bRootOnly` - load only the root?
  Throws:
    `net.sf.statcvs.input.LogSyntaxException` - if the format of the svn info is invalid
    `IOException` - if we can't read from the response stream.

### loadInfo

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

  Loads the information from svn info if needed.

  Parameters:
    `pUtils` - the process util that contains the input stream representing an svn info command.
  Throws:
    `net.sf.statcvs.input.LogSyntaxException` - if the format of the svn info is invalid
    `IOException` - if we can't read from the response stream.

### loadInfo

    public static 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

### urlToAbsolutePath

    public static 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 static 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

### setRootUrl

    protected static void setRootUrl(String rootUrl)

  Sets the project's root URL.

  Parameters:
    `rootUrl` -

### setRepositoryUrl

    protected static void setRepositoryUrl(String repositoryUrl)

  Sets the project's repository URL.

  Parameters:
    `repositoryUrl` -

### replace

    public static String replace(String originalPattern,
                                 String newPattern,
                                 String originalString)

  This method is a 1.4 replacement of the String.replace(CharSequence, CharSequence) found in 1.5.

  Parameters:
    `originalPattern` -
    `newPattern` -
    `originalString` -
  Returns:

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