Class SVNRevision


  • public class SVNRevision
    extends java.lang.Object
    SVNRevision is a revision wrapper used for an abstract representation of revision information.

    Most of high-level API classes' methods receive revision parameters as SVNRevision objects to get information on SVN revisions and use it in version control operations.

    This class provides advantages of specifying revisions either as just long numbers or dated revisions (when a revision is determined according to a particular timestamp) or SVN compatible keywords denoting the latest revision (HEAD), Working Copy pristine revision (BASE) and so on. And one more feature is that SVNRevision can parse strings (that can be anything: string representations of numbers, dates, keywords) to construct an SVNRevision to use.

    Since:
    1.2
    Version:
    1.3
    Author:
    TMate Software Ltd.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static SVNRevision BASE
      Denotes the 'pristine' revision of a Working Copy item.
      static SVNRevision COMMITTED
      Denotes the last revision in which an item was changed before (or at) BASE.
      static SVNRevision HEAD
      Denotes the latest repository revision.
      static SVNRevision PREVIOUS
      Denotes the revision just before the one when an item was last changed (technically, COMMITTED - 1).
      static SVNRevision UNDEFINED
      Used to denote that a revision is undefined (not available or not valid).
      static SVNRevision WORKING
      Denotes an item's working (current) revision.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static SVNRevision create​(long revisionNumber)
      Creates an SVNRevision object given a revision number.
      static SVNRevision create​(java.util.Date date)
      Creates an SVNRevision object given a particular timestamp.
      boolean equals​(java.lang.Object o)
      Compares this object with another SVNRevision object.
      java.util.Date getDate()
      Gets the timestamp used to specify a revision.
      int getID()
      Gets the identifier of the revision information kind this object represents.
      java.lang.String getName()
      Gets the revision keyword name.
      long getNumber()
      Gets the revision number represented by this object.
      int hashCode()
      Evaluates the hash code for this object.
      boolean isLocal()
      Determines if the revision represented by this abstract object is Working Copy specific - that is one of BASE or WORKING.
      boolean isValid()
      Checks if the revision information represented by this object is valid.
      static boolean isValidRevisionNumber​(long revision)
      Checks whether a revision number is valid.
      static SVNRevision parse​(java.lang.String value)
      Parses an input string and be it a representation of either a revision number, or a timestamp, or a revision keyword, constructs an SVNRevision representation of the revision.
      java.lang.String toString()
      Gives a string representation of this object.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • HEAD

        public static final SVNRevision HEAD
        Denotes the latest repository revision. SVN's analogue keyword: HEAD.
      • WORKING

        public static final SVNRevision WORKING
        Denotes an item's working (current) revision. This is a SVNKit constant that should be provided to mean working revisions (what the native SVN client assumes by default).
      • PREVIOUS

        public static final SVNRevision PREVIOUS
        Denotes the revision just before the one when an item was last changed (technically, COMMITTED - 1). SVN's analogue keyword: PREV.
      • BASE

        public static final SVNRevision BASE
        Denotes the 'pristine' revision of a Working Copy item. SVN's analogue keyword: BASE.
      • COMMITTED

        public static final SVNRevision COMMITTED
        Denotes the last revision in which an item was changed before (or at) BASE. SVN's analogue keyword: COMMITTED.
      • UNDEFINED

        public static final SVNRevision UNDEFINED
        Used to denote that a revision is undefined (not available or not valid).
    • Method Detail

      • getName

        public java.lang.String getName()
        Gets the revision keyword name. Each of SVNRevision's constant fields that represent revision keywords also have its own name.
        Returns:
        a revision keyword name
      • getNumber

        public long getNumber()
        Gets the revision number represented by this object.
        Returns:
        a revision number; -1 is returned when this object represents a revision information not using a revision number.
      • getDate

        public java.util.Date getDate()
        Gets the timestamp used to specify a revision.
        Returns:
        a timestamp if any specified for this object
      • isValid

        public boolean isValid()
        Checks if the revision information represented by this object is valid.

        UNDEFINED is not a valid revision.

        Returns:
        true if valid, otherwise false
      • getID

        public int getID()
        Gets the identifier of the revision information kind this object represents.
        Returns:
        this object's id
      • hashCode

        public int hashCode()
        Evaluates the hash code for this object. A hash code is evaluated in this way:
        • if this object represents revision info as a revision number then hash code = (int) revisionNumber & 0xFFFFFFFF;
        • if this object represents revision info as a timestamp then Date.hashCode() is used;
        • if this object represents revision info as a keyword then String.hashCode() is used for the keyword name;
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        this object's hash code
      • equals

        public boolean equals​(java.lang.Object o)
        Compares this object with another SVNRevision object.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - an object to be compared with; if it's not an SVNRevision then this method certainly returns false
        Returns:
        true if equal, otherwise false
      • isValidRevisionNumber

        public static boolean isValidRevisionNumber​(long revision)
        Checks whether a revision number is valid.
        Parameters:
        revision - a revision number
        Returns:
        true if valid (>=0), otherwise false
      • create

        public static SVNRevision create​(long revisionNumber)
        Creates an SVNRevision object given a revision number.
        Parameters:
        revisionNumber - a definite revision number
        Returns:
        the constructed SVNRevision object
      • create

        public static SVNRevision create​(java.util.Date date)
        Creates an SVNRevision object given a particular timestamp.
        Parameters:
        date - a timestamp represented as a Date instance
        Returns:
        the constructed SVNRevision object
      • isLocal

        public boolean isLocal()
        Determines if the revision represented by this abstract object is Working Copy specific - that is one of BASE or WORKING.
        Returns:
        true if this object represents a kind of a local revision, otherwise false
      • parse

        public static SVNRevision parse​(java.lang.String value)
        Parses an input string and be it a representation of either a revision number, or a timestamp, or a revision keyword, constructs an SVNRevision representation of the revision.
        Parameters:
        value - a string to be parsed
        Returns:
        an SVNRevision object that holds the revision information parsed from value; however if an input string is not a valid one which can be successfully transformed to an SVNRevision the return value is UNDEFINED
      • toString

        public java.lang.String toString()
        Gives a string representation of this object.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string representing this object