net.sf.statcvs.model

## Class VersionedFile

- java.lang.Object
- - net.sf.statcvs.model.VersionedFile

- All Implemented Interfaces:
    java.lang.Comparable

      public class VersionedFile
      extends java.lang.Object
      implements java.lang.Comparable

  Represents one versioned file in the `Repository`, including its name, `Directory` and `Revision` list. Revisions can be created using the `addXXXRevision` factory methods. Revisions can be created in any order. TODO: Rename class to something like VersionedFile, getCurrentLinesOfCode() to getCurrentLines(), maybe getFilenameXXX, isDead() to isDeleted()
  Version:
    $Id: VersionedFile.java,v 1.5 2009/08/31 19:16:35 benoitx Exp $
  Author:
    Manuel Schulze, Richard Cyganiak

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `VersionedFile(java.lang.String name, Directory directory)` Creates a VersionedFile object.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Revision` | `addBeginOfLogRevision(java.util.Date date, int lines, java.util.SortedSet symbolicNames)` Adds a "begin of log" revision to the file.
    `Revision` | `addChangeRevision(java.lang.String revisionNumber, Author author, java.util.Date date, java.lang.String comment, int lines, int linesDelta, int replacedLines, java.util.SortedSet symbolicNames)` Adds a change revision to the file.
    `Revision` | `addDeletionRevision(java.lang.String revisionNumber, Author author, java.util.Date date, java.lang.String comment, int lines, java.util.SortedSet symbolicNames)` Adds a deletion revision to the file.
    `Revision` | `addInitialRevision(java.lang.String revisionNumber, Author author, java.util.Date date, java.lang.String comment, int lines, java.util.SortedSet symbolicNames)` Adds an initial revision to the file.
    `int` | `compareTo(java.lang.Object other)` Compares this file to another one, based on filename.
    `boolean` | `equals(java.lang.Object rhs)`
    `java.util.Set` | `getAuthors()` Returns a list of authors that have commited at least one revision of the file.
    `int` | `getCurrentLinesOfCode()` Returns the current number of lines for this file.
    `Directory` | `getDirectory()` Returns the file's `Directory`.
    `java.lang.String` | `getFilename()` Returns the filename without path.
    `java.lang.String` | `getFilenameWithPath()` Returns the full filename.
    `Revision` | `getInitialRevision()` Gets the earliest revision of this file.
    `Revision` | `getLatestRevision()` Gets the latest revision of this file.
    `Module` | `getModule()`
    `Revision` | `getPreviousRevision(Revision revision)` Returns the revision which was replaced by the revision given as argument.
    `java.util.SortedSet` | `getRevisions()` Returns the list of `Revision`s of this file, sorted from earliest to most recent.
    `boolean` | `hasAuthor(Author author)` Returns true, if `author` worked on this file.
    `int` | `hashCode()`
    `boolean` | `isDead()` Returns `true` if the latest revision of this file was a deletion.
    `void` | `setModule(Module module)`
    `java.lang.String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### VersionedFile

          public VersionedFile(java.lang.String name,
                       Directory directory)

      Creates a VersionedFile object.
      Parameters:
        `name` - The full name of the file
        `directory` - the directory where the file resides

  - ### Method Detail

    - #### getAuthors

          public java.util.Set getAuthors()

      Returns a list of authors that have commited at least one revision of the file.
      Returns:
        a list of authors

    - #### getFilenameWithPath

          public java.lang.String getFilenameWithPath()

      Returns the full filename.
      Returns:
        the full filename

    - #### getFilename

          public java.lang.String getFilename()

      Returns the filename without path.
      Returns:
        the filename without path

    - #### getDirectory

          public Directory getDirectory()

      Returns the file's `Directory`.
      Returns:
        the file's `Directory`

    - #### getLatestRevision

          public Revision getLatestRevision()

      Gets the latest revision of this file.
      Returns:
        the latest revision of this file

    - #### getInitialRevision

          public Revision getInitialRevision()

      Gets the earliest revision of this file.
      Returns:
        the earliest revision of this file

    - #### getRevisions

          public java.util.SortedSet getRevisions()

      Returns the list of `Revision`s of this file, sorted from earliest to most recent.
      Returns:
        a `SortedSet` of `Revision`s

    - #### getCurrentLinesOfCode

          public int getCurrentLinesOfCode()

      Returns the current number of lines for this file. Binary files and deleted files are assumed to have 0 lines.
      Returns:
        the current number of lines for this file

    - #### isDead

          public boolean isDead()

      Returns `true` if the latest revision of this file was a deletion.
      Returns:
        `true` if this file is deleted

    - #### hasAuthor

          public boolean hasAuthor(Author author)

      Returns true, if `author` worked on this file.
      Parameters:
        `author` - The `Author` to search for
      Returns:
        `true`, if the author is listed in one of this file's revisions

    - #### getPreviousRevision

          public Revision getPreviousRevision(Revision revision)

      Returns the revision which was replaced by the revision given as argument. Returns `null` if the given revision is the initial revision of this file.
      Parameters:
        `revision` - a revision of this file
      Returns:
        this revision's predecessor

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### compareTo

          public int compareTo(java.lang.Object other)

      Compares this file to another one, based on filename.
      Specified by:
        `compareTo` in interface `java.lang.Comparable`
      See Also:
        `Comparable.compareTo(java.lang.Object)`

    - #### equals

          public boolean equals(java.lang.Object rhs)

      Overrides:
        `equals` in class `java.lang.Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### addInitialRevision

          public Revision addInitialRevision(java.lang.String revisionNumber,
                                    Author author,
                                    java.util.Date date,
                                    java.lang.String comment,
                                    int lines,
                                    java.util.SortedSet symbolicNames)

      Adds an initial revision to the file. An initial revision is either the first revision of the file, or a re-add after the file was deleted.
      Parameters:
        `revisionNumber` - the revision number, for example "1.1"
        `author` - the login from which the change was committed
        `date` - the time when the change was committed
        `comment` - the commit message
        `lines` - the number of lines of the new file

    - #### addChangeRevision

          public Revision addChangeRevision(java.lang.String revisionNumber,
                                   Author author,
                                   java.util.Date date,
                                   java.lang.String comment,
                                   int lines,
                                   int linesDelta,
                                   int replacedLines,
                                   java.util.SortedSet symbolicNames)

      Adds a change revision to the file.
      Parameters:
        `revisionNumber` - the revision number, for example "1.1"
        `author` - the login from which the change was committed
        `date` - the time when the change was committed
        `comment` - the commit message
        `lines` - the number of lines in the file after the change
        `linesDelta` - the change in the number of lines
        `replacedLines` - number of lines that were removed and replaced by others

    - #### addDeletionRevision

          public Revision addDeletionRevision(java.lang.String revisionNumber,
                                     Author author,
                                     java.util.Date date,
                                     java.lang.String comment,
                                     int lines,
                                     java.util.SortedSet symbolicNames)

      Adds a deletion revision to the file.
      Parameters:
        `revisionNumber` - the revision number, for example "1.1"
        `author` - the login from which the change was committed
        `date` - the time when the change was committed
        `comment` - the commit message
        `lines` - the number of lines in the file before it was deleted

    - #### addBeginOfLogRevision

          public Revision addBeginOfLogRevision(java.util.Date date,
                                       int lines,
                                       java.util.SortedSet symbolicNames)

      Adds a "begin of log" revision to the file. This kind of revision only marks the beginning of the log timespan if the file was already present in the repository at this time. It is not an actual revision committed by an author.
      Parameters:
        `date` - the begin of the log
        `lines` - the number of lines in the file at that time

    - #### getModule

          public Module getModule()

    - #### setModule

          public void setModule(Module module)